@superatomai/sdk-node 0.0.15 → 0.0.16-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/dist/index.d.mts +1465 -19
- package/dist/index.d.ts +1465 -19
- package/dist/index.js +12919 -3550
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12897 -3548
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
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
|
+
|
|
4
15
|
/**
|
|
5
16
|
* Log levels in hierarchical order
|
|
6
17
|
* - errors: only error logs
|
|
@@ -48,7 +59,18 @@ declare class Logger {
|
|
|
48
59
|
* Log debug message (only shown for verbose level)
|
|
49
60
|
*/
|
|
50
61
|
debug(...args: any[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Write to log file
|
|
64
|
+
*/
|
|
51
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;
|
|
52
74
|
}
|
|
53
75
|
declare const logger: Logger;
|
|
54
76
|
|
|
@@ -79,7 +101,27 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
79
101
|
deps?: string[] | undefined;
|
|
80
102
|
}>, "many">>;
|
|
81
103
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
82
|
-
render: z.ZodType<any, z.ZodTypeDef, any
|
|
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>;
|
|
83
125
|
query: z.ZodOptional<z.ZodObject<{
|
|
84
126
|
graphql: z.ZodOptional<z.ZodString>;
|
|
85
127
|
sql: z.ZodOptional<z.ZodString>;
|
|
@@ -118,6 +160,7 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
118
160
|
dependencies?: string[] | undefined;
|
|
119
161
|
} | undefined;
|
|
120
162
|
props?: Record<string, any> | undefined;
|
|
163
|
+
render?: any;
|
|
121
164
|
states?: Record<string, any> | undefined;
|
|
122
165
|
methods?: Record<string, {
|
|
123
166
|
fn: string;
|
|
@@ -128,7 +171,14 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
128
171
|
deps?: string[] | undefined;
|
|
129
172
|
}[] | undefined;
|
|
130
173
|
data?: Record<string, any> | undefined;
|
|
131
|
-
|
|
174
|
+
pages?: {
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
order: number;
|
|
178
|
+
icon?: string | undefined;
|
|
179
|
+
render?: any;
|
|
180
|
+
}[] | undefined;
|
|
181
|
+
defaultPageId?: string | undefined;
|
|
132
182
|
}, {
|
|
133
183
|
id: string;
|
|
134
184
|
name?: string | undefined;
|
|
@@ -142,6 +192,7 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
142
192
|
dependencies?: string[] | undefined;
|
|
143
193
|
} | undefined;
|
|
144
194
|
props?: Record<string, any> | undefined;
|
|
195
|
+
render?: any;
|
|
145
196
|
states?: Record<string, any> | undefined;
|
|
146
197
|
methods?: Record<string, {
|
|
147
198
|
fn: string;
|
|
@@ -152,7 +203,14 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
152
203
|
deps?: string[] | undefined;
|
|
153
204
|
}[] | undefined;
|
|
154
205
|
data?: Record<string, any> | undefined;
|
|
155
|
-
|
|
206
|
+
pages?: {
|
|
207
|
+
id: string;
|
|
208
|
+
name: string;
|
|
209
|
+
order: number;
|
|
210
|
+
icon?: string | undefined;
|
|
211
|
+
render?: any;
|
|
212
|
+
}[] | undefined;
|
|
213
|
+
defaultPageId?: string | undefined;
|
|
156
214
|
}>;
|
|
157
215
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
158
216
|
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -170,6 +228,7 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
170
228
|
dependencies?: string[] | undefined;
|
|
171
229
|
} | undefined;
|
|
172
230
|
props?: Record<string, any> | undefined;
|
|
231
|
+
render?: any;
|
|
173
232
|
states?: Record<string, any> | undefined;
|
|
174
233
|
methods?: Record<string, {
|
|
175
234
|
fn: string;
|
|
@@ -180,7 +239,14 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
180
239
|
deps?: string[] | undefined;
|
|
181
240
|
}[] | undefined;
|
|
182
241
|
data?: Record<string, any> | undefined;
|
|
183
|
-
|
|
242
|
+
pages?: {
|
|
243
|
+
id: string;
|
|
244
|
+
name: string;
|
|
245
|
+
order: number;
|
|
246
|
+
icon?: string | undefined;
|
|
247
|
+
render?: any;
|
|
248
|
+
}[] | undefined;
|
|
249
|
+
defaultPageId?: string | undefined;
|
|
184
250
|
};
|
|
185
251
|
data?: Record<string, any> | undefined;
|
|
186
252
|
context?: Record<string, any> | undefined;
|
|
@@ -198,6 +264,7 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
198
264
|
dependencies?: string[] | undefined;
|
|
199
265
|
} | undefined;
|
|
200
266
|
props?: Record<string, any> | undefined;
|
|
267
|
+
render?: any;
|
|
201
268
|
states?: Record<string, any> | undefined;
|
|
202
269
|
methods?: Record<string, {
|
|
203
270
|
fn: string;
|
|
@@ -208,7 +275,14 @@ declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
|
208
275
|
deps?: string[] | undefined;
|
|
209
276
|
}[] | undefined;
|
|
210
277
|
data?: Record<string, any> | undefined;
|
|
211
|
-
|
|
278
|
+
pages?: {
|
|
279
|
+
id: string;
|
|
280
|
+
name: string;
|
|
281
|
+
order: number;
|
|
282
|
+
icon?: string | undefined;
|
|
283
|
+
render?: any;
|
|
284
|
+
}[] | undefined;
|
|
285
|
+
defaultPageId?: string | undefined;
|
|
212
286
|
};
|
|
213
287
|
data?: Record<string, any> | undefined;
|
|
214
288
|
context?: Record<string, any> | undefined;
|
|
@@ -281,6 +355,7 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
281
355
|
dependencies?: string[] | undefined;
|
|
282
356
|
} | undefined;
|
|
283
357
|
props?: Record<string, any> | undefined;
|
|
358
|
+
render?: any;
|
|
284
359
|
states?: Record<string, any> | undefined;
|
|
285
360
|
methods?: Record<string, {
|
|
286
361
|
fn: string;
|
|
@@ -291,7 +366,6 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
291
366
|
deps?: string[] | undefined;
|
|
292
367
|
}[] | undefined;
|
|
293
368
|
data?: Record<string, any> | undefined;
|
|
294
|
-
render?: any;
|
|
295
369
|
}, {
|
|
296
370
|
id: string;
|
|
297
371
|
name?: string | undefined;
|
|
@@ -305,6 +379,7 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
305
379
|
dependencies?: string[] | undefined;
|
|
306
380
|
} | undefined;
|
|
307
381
|
props?: Record<string, any> | undefined;
|
|
382
|
+
render?: any;
|
|
308
383
|
states?: Record<string, any> | undefined;
|
|
309
384
|
methods?: Record<string, {
|
|
310
385
|
fn: string;
|
|
@@ -315,7 +390,6 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
315
390
|
deps?: string[] | undefined;
|
|
316
391
|
}[] | undefined;
|
|
317
392
|
data?: Record<string, any> | undefined;
|
|
318
|
-
render?: any;
|
|
319
393
|
}>;
|
|
320
394
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
321
395
|
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -333,6 +407,7 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
333
407
|
dependencies?: string[] | undefined;
|
|
334
408
|
} | undefined;
|
|
335
409
|
props?: Record<string, any> | undefined;
|
|
410
|
+
render?: any;
|
|
336
411
|
states?: Record<string, any> | undefined;
|
|
337
412
|
methods?: Record<string, {
|
|
338
413
|
fn: string;
|
|
@@ -343,7 +418,6 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
343
418
|
deps?: string[] | undefined;
|
|
344
419
|
}[] | undefined;
|
|
345
420
|
data?: Record<string, any> | undefined;
|
|
346
|
-
render?: any;
|
|
347
421
|
};
|
|
348
422
|
data?: Record<string, any> | undefined;
|
|
349
423
|
context?: Record<string, any> | undefined;
|
|
@@ -361,6 +435,7 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
361
435
|
dependencies?: string[] | undefined;
|
|
362
436
|
} | undefined;
|
|
363
437
|
props?: Record<string, any> | undefined;
|
|
438
|
+
render?: any;
|
|
364
439
|
states?: Record<string, any> | undefined;
|
|
365
440
|
methods?: Record<string, {
|
|
366
441
|
fn: string;
|
|
@@ -371,7 +446,6 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
371
446
|
deps?: string[] | undefined;
|
|
372
447
|
}[] | undefined;
|
|
373
448
|
data?: Record<string, any> | undefined;
|
|
374
|
-
render?: any;
|
|
375
449
|
};
|
|
376
450
|
data?: Record<string, any> | undefined;
|
|
377
451
|
context?: Record<string, any> | undefined;
|
|
@@ -384,6 +458,7 @@ declare const UserSchema: z.ZodObject<{
|
|
|
384
458
|
password: z.ZodString;
|
|
385
459
|
fullname: z.ZodOptional<z.ZodString>;
|
|
386
460
|
role: z.ZodOptional<z.ZodString>;
|
|
461
|
+
userInfo: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
387
462
|
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
388
463
|
}, "strip", z.ZodTypeAny, {
|
|
389
464
|
username: string;
|
|
@@ -391,6 +466,7 @@ declare const UserSchema: z.ZodObject<{
|
|
|
391
466
|
email?: string | undefined;
|
|
392
467
|
fullname?: string | undefined;
|
|
393
468
|
role?: string | undefined;
|
|
469
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
394
470
|
wsIds?: string[] | undefined;
|
|
395
471
|
}, {
|
|
396
472
|
username: string;
|
|
@@ -398,6 +474,7 @@ declare const UserSchema: z.ZodObject<{
|
|
|
398
474
|
email?: string | undefined;
|
|
399
475
|
fullname?: string | undefined;
|
|
400
476
|
role?: string | undefined;
|
|
477
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
401
478
|
wsIds?: string[] | undefined;
|
|
402
479
|
}>;
|
|
403
480
|
type User = z.infer<typeof UserSchema>;
|
|
@@ -408,6 +485,7 @@ declare const UsersDataSchema: z.ZodObject<{
|
|
|
408
485
|
password: z.ZodString;
|
|
409
486
|
fullname: z.ZodOptional<z.ZodString>;
|
|
410
487
|
role: z.ZodOptional<z.ZodString>;
|
|
488
|
+
userInfo: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
411
489
|
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
412
490
|
}, "strip", z.ZodTypeAny, {
|
|
413
491
|
username: string;
|
|
@@ -415,6 +493,7 @@ declare const UsersDataSchema: z.ZodObject<{
|
|
|
415
493
|
email?: string | undefined;
|
|
416
494
|
fullname?: string | undefined;
|
|
417
495
|
role?: string | undefined;
|
|
496
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
418
497
|
wsIds?: string[] | undefined;
|
|
419
498
|
}, {
|
|
420
499
|
username: string;
|
|
@@ -422,6 +501,7 @@ declare const UsersDataSchema: z.ZodObject<{
|
|
|
422
501
|
email?: string | undefined;
|
|
423
502
|
fullname?: string | undefined;
|
|
424
503
|
role?: string | undefined;
|
|
504
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
425
505
|
wsIds?: string[] | undefined;
|
|
426
506
|
}>, "many">;
|
|
427
507
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -431,6 +511,7 @@ declare const UsersDataSchema: z.ZodObject<{
|
|
|
431
511
|
email?: string | undefined;
|
|
432
512
|
fullname?: string | undefined;
|
|
433
513
|
role?: string | undefined;
|
|
514
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
434
515
|
wsIds?: string[] | undefined;
|
|
435
516
|
}[];
|
|
436
517
|
}, {
|
|
@@ -440,6 +521,7 @@ declare const UsersDataSchema: z.ZodObject<{
|
|
|
440
521
|
email?: string | undefined;
|
|
441
522
|
fullname?: string | undefined;
|
|
442
523
|
role?: string | undefined;
|
|
524
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
443
525
|
wsIds?: string[] | undefined;
|
|
444
526
|
}[];
|
|
445
527
|
}>;
|
|
@@ -544,42 +626,413 @@ declare const IncomingMessageSchema: z.ZodObject<{
|
|
|
544
626
|
payload?: unknown;
|
|
545
627
|
}>;
|
|
546
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>;
|
|
547
740
|
declare const ToolSchema: z.ZodObject<{
|
|
548
741
|
id: z.ZodString;
|
|
549
742
|
name: z.ZodString;
|
|
550
743
|
description: z.ZodString;
|
|
744
|
+
/** Tool type: "source" = routed through SourceAgent, "direct" = called directly by MainAgent */
|
|
745
|
+
toolType: z.ZodOptional<z.ZodEnum<["source", "direct"]>>;
|
|
746
|
+
/** Full untruncated schema for source agent (all columns visible) */
|
|
747
|
+
fullSchema: z.ZodOptional<z.ZodString>;
|
|
551
748
|
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
552
749
|
fn: z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodAny>;
|
|
750
|
+
outputSchema: z.ZodOptional<z.ZodObject<{
|
|
751
|
+
description: z.ZodString;
|
|
752
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
753
|
+
name: z.ZodString;
|
|
754
|
+
type: z.ZodEnum<["string", "number", "boolean", "date"]>;
|
|
755
|
+
description: z.ZodString;
|
|
756
|
+
}, "strip", z.ZodTypeAny, {
|
|
757
|
+
type: "string" | "number" | "boolean" | "date";
|
|
758
|
+
name: string;
|
|
759
|
+
description: string;
|
|
760
|
+
}, {
|
|
761
|
+
type: "string" | "number" | "boolean" | "date";
|
|
762
|
+
name: string;
|
|
763
|
+
description: string;
|
|
764
|
+
}>, "many">;
|
|
765
|
+
}, "strip", z.ZodTypeAny, {
|
|
766
|
+
description: string;
|
|
767
|
+
fields: {
|
|
768
|
+
type: "string" | "number" | "boolean" | "date";
|
|
769
|
+
name: string;
|
|
770
|
+
description: string;
|
|
771
|
+
}[];
|
|
772
|
+
}, {
|
|
773
|
+
description: string;
|
|
774
|
+
fields: {
|
|
775
|
+
type: "string" | "number" | "boolean" | "date";
|
|
776
|
+
name: string;
|
|
777
|
+
description: string;
|
|
778
|
+
}[];
|
|
779
|
+
}>>;
|
|
553
780
|
}, "strip", z.ZodTypeAny, {
|
|
554
781
|
id: string;
|
|
555
782
|
params: Record<string, string>;
|
|
556
783
|
name: string;
|
|
557
784
|
description: string;
|
|
558
785
|
fn: (args_0: any, ...args: unknown[]) => any;
|
|
786
|
+
toolType?: "source" | "direct" | undefined;
|
|
787
|
+
fullSchema?: string | undefined;
|
|
788
|
+
outputSchema?: {
|
|
789
|
+
description: string;
|
|
790
|
+
fields: {
|
|
791
|
+
type: "string" | "number" | "boolean" | "date";
|
|
792
|
+
name: string;
|
|
793
|
+
description: string;
|
|
794
|
+
}[];
|
|
795
|
+
} | undefined;
|
|
559
796
|
}, {
|
|
560
797
|
id: string;
|
|
561
798
|
params: Record<string, string>;
|
|
562
799
|
name: string;
|
|
563
800
|
description: string;
|
|
564
801
|
fn: (args_0: any, ...args: unknown[]) => any;
|
|
802
|
+
toolType?: "source" | "direct" | undefined;
|
|
803
|
+
fullSchema?: string | undefined;
|
|
804
|
+
outputSchema?: {
|
|
805
|
+
description: string;
|
|
806
|
+
fields: {
|
|
807
|
+
type: "string" | "number" | "boolean" | "date";
|
|
808
|
+
name: string;
|
|
809
|
+
description: string;
|
|
810
|
+
}[];
|
|
811
|
+
} | undefined;
|
|
565
812
|
}>;
|
|
566
813
|
type Tool$1 = z.infer<typeof ToolSchema>;
|
|
567
814
|
type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
|
|
568
815
|
type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
|
|
569
|
-
type LLMProvider = 'anthropic' | 'groq';
|
|
816
|
+
type LLMProvider = 'anthropic' | 'groq' | 'gemini' | 'openai';
|
|
570
817
|
|
|
818
|
+
type DatabaseType = 'postgresql' | 'mssql' | 'snowflake' | 'mysql';
|
|
819
|
+
/**
|
|
820
|
+
* Model strategy for controlling which models are used for different tasks
|
|
821
|
+
* - 'best': Use the best model (e.g., Sonnet) for all tasks - highest quality, higher cost
|
|
822
|
+
* - 'fast': Use the fast model (e.g., Haiku) for all tasks - lower quality, lower cost
|
|
823
|
+
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
824
|
+
*/
|
|
825
|
+
type ModelStrategy = 'best' | 'fast' | 'balanced';
|
|
826
|
+
/**
|
|
827
|
+
* Model configuration for DASH_COMP flow (dashboard component picking)
|
|
828
|
+
* Allows separate control of models used for component selection
|
|
829
|
+
*/
|
|
830
|
+
interface DashCompModelConfig {
|
|
831
|
+
/**
|
|
832
|
+
* Primary model for DASH_COMP requests
|
|
833
|
+
* Format: "provider/model-name" (e.g., "anthropic/claude-sonnet-4-5-20250929")
|
|
834
|
+
*/
|
|
835
|
+
model?: string;
|
|
836
|
+
/**
|
|
837
|
+
* Fast model for simpler DASH_COMP tasks (optional)
|
|
838
|
+
* Format: "provider/model-name" (e.g., "anthropic/claude-haiku-4-5-20251001")
|
|
839
|
+
*/
|
|
840
|
+
fastModel?: string;
|
|
841
|
+
}
|
|
571
842
|
interface SuperatomSDKConfig {
|
|
572
843
|
url?: string;
|
|
573
|
-
apiKey
|
|
844
|
+
apiKey?: string;
|
|
574
845
|
projectId: string;
|
|
575
|
-
userId?: string;
|
|
576
846
|
type?: string;
|
|
577
847
|
bundleDir?: string;
|
|
578
848
|
promptsDir?: string;
|
|
849
|
+
databaseType?: DatabaseType;
|
|
579
850
|
ANTHROPIC_API_KEY?: string;
|
|
580
851
|
GROQ_API_KEY?: string;
|
|
852
|
+
GEMINI_API_KEY?: string;
|
|
853
|
+
OPENAI_API_KEY?: string;
|
|
581
854
|
LLM_PROVIDERS?: LLMProvider[];
|
|
582
855
|
logLevel?: LogLevel;
|
|
856
|
+
/**
|
|
857
|
+
* Model selection strategy for LLM API calls:
|
|
858
|
+
* - 'best': Use best model for all tasks (highest quality, higher cost)
|
|
859
|
+
* - 'fast': Use fast model for all tasks (lower quality, lower cost)
|
|
860
|
+
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
861
|
+
*/
|
|
862
|
+
modelStrategy?: ModelStrategy;
|
|
863
|
+
/**
|
|
864
|
+
* Separate model configuration for DASH_COMP flow (dashboard component picking)
|
|
865
|
+
* If not provided, falls back to provider-based model selection
|
|
866
|
+
*/
|
|
867
|
+
dashCompModels?: DashCompModelConfig;
|
|
868
|
+
/**
|
|
869
|
+
* Similarity threshold for conversation search (semantic matching)
|
|
870
|
+
* Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
871
|
+
* Higher values require closer matches, lower values allow more distant matches
|
|
872
|
+
* Default: 0.8
|
|
873
|
+
*/
|
|
874
|
+
conversationSimilarityThreshold?: number;
|
|
875
|
+
/**
|
|
876
|
+
* Query cache TTL (Time To Live) in minutes
|
|
877
|
+
* Cached query results expire after this duration
|
|
878
|
+
* Default: 5 minutes
|
|
879
|
+
*/
|
|
880
|
+
queryCacheTTL?: number;
|
|
881
|
+
/**
|
|
882
|
+
* Dashboard conversation history TTL (Time To Live) in minutes
|
|
883
|
+
* Per-dashboard conversation histories expire after this duration
|
|
884
|
+
* Default: 30 minutes
|
|
885
|
+
*/
|
|
886
|
+
dashboardHistoryTTL?: number;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
declare const KbNodesQueryFiltersSchema: z.ZodObject<{
|
|
890
|
+
query: z.ZodOptional<z.ZodString>;
|
|
891
|
+
category: z.ZodOptional<z.ZodString>;
|
|
892
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
893
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
894
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
895
|
+
}, "strip", z.ZodTypeAny, {
|
|
896
|
+
type?: "query" | "user" | "global" | undefined;
|
|
897
|
+
query?: string | undefined;
|
|
898
|
+
category?: string | undefined;
|
|
899
|
+
createdBy?: string | undefined;
|
|
900
|
+
tags?: string[] | undefined;
|
|
901
|
+
}, {
|
|
902
|
+
type?: "query" | "user" | "global" | undefined;
|
|
903
|
+
query?: string | undefined;
|
|
904
|
+
category?: string | undefined;
|
|
905
|
+
createdBy?: string | undefined;
|
|
906
|
+
tags?: string[] | undefined;
|
|
907
|
+
}>;
|
|
908
|
+
type KbNodesQueryFilters = z.infer<typeof KbNodesQueryFiltersSchema>;
|
|
909
|
+
declare const KbNodesRequestPayloadSchema: z.ZodObject<{
|
|
910
|
+
operation: z.ZodEnum<["create", "update", "delete", "getAll", "getOne", "search", "getByCategory", "getByUser", "getCategories", "getTags"]>;
|
|
911
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
912
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
913
|
+
title: z.ZodOptional<z.ZodString>;
|
|
914
|
+
content: z.ZodOptional<z.ZodString>;
|
|
915
|
+
category: z.ZodOptional<z.ZodString>;
|
|
916
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
917
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
918
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
919
|
+
updatedBy: z.ZodOptional<z.ZodString>;
|
|
920
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
921
|
+
query: z.ZodOptional<z.ZodString>;
|
|
922
|
+
filters: z.ZodOptional<z.ZodObject<{
|
|
923
|
+
query: z.ZodOptional<z.ZodString>;
|
|
924
|
+
category: z.ZodOptional<z.ZodString>;
|
|
925
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
926
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
927
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
928
|
+
}, "strip", z.ZodTypeAny, {
|
|
929
|
+
type?: "query" | "user" | "global" | undefined;
|
|
930
|
+
query?: string | undefined;
|
|
931
|
+
category?: string | undefined;
|
|
932
|
+
createdBy?: string | undefined;
|
|
933
|
+
tags?: string[] | undefined;
|
|
934
|
+
}, {
|
|
935
|
+
type?: "query" | "user" | "global" | undefined;
|
|
936
|
+
query?: string | undefined;
|
|
937
|
+
category?: string | undefined;
|
|
938
|
+
createdBy?: string | undefined;
|
|
939
|
+
tags?: string[] | undefined;
|
|
940
|
+
}>>;
|
|
941
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
942
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
943
|
+
}, "strip", z.ZodTypeAny, {
|
|
944
|
+
id?: number | undefined;
|
|
945
|
+
type?: "query" | "user" | "global" | undefined;
|
|
946
|
+
query?: string | undefined;
|
|
947
|
+
title?: string | undefined;
|
|
948
|
+
category?: string | undefined;
|
|
949
|
+
userId?: string | undefined;
|
|
950
|
+
limit?: number | undefined;
|
|
951
|
+
filters?: {
|
|
952
|
+
type?: "query" | "user" | "global" | undefined;
|
|
953
|
+
query?: string | undefined;
|
|
954
|
+
category?: string | undefined;
|
|
955
|
+
createdBy?: string | undefined;
|
|
956
|
+
tags?: string[] | undefined;
|
|
957
|
+
} | undefined;
|
|
958
|
+
createdBy?: string | undefined;
|
|
959
|
+
updatedBy?: string | undefined;
|
|
960
|
+
offset?: number | undefined;
|
|
961
|
+
tags?: string[] | undefined;
|
|
962
|
+
content?: string | undefined;
|
|
963
|
+
}, {
|
|
964
|
+
id?: number | undefined;
|
|
965
|
+
type?: "query" | "user" | "global" | undefined;
|
|
966
|
+
query?: string | undefined;
|
|
967
|
+
title?: string | undefined;
|
|
968
|
+
category?: string | undefined;
|
|
969
|
+
userId?: string | undefined;
|
|
970
|
+
limit?: number | undefined;
|
|
971
|
+
filters?: {
|
|
972
|
+
type?: "query" | "user" | "global" | undefined;
|
|
973
|
+
query?: string | undefined;
|
|
974
|
+
category?: string | undefined;
|
|
975
|
+
createdBy?: string | undefined;
|
|
976
|
+
tags?: string[] | undefined;
|
|
977
|
+
} | undefined;
|
|
978
|
+
createdBy?: string | undefined;
|
|
979
|
+
updatedBy?: string | undefined;
|
|
980
|
+
offset?: number | undefined;
|
|
981
|
+
tags?: string[] | undefined;
|
|
982
|
+
content?: string | undefined;
|
|
983
|
+
}>>;
|
|
984
|
+
}, "strip", z.ZodTypeAny, {
|
|
985
|
+
operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
|
|
986
|
+
data?: {
|
|
987
|
+
id?: number | undefined;
|
|
988
|
+
type?: "query" | "user" | "global" | undefined;
|
|
989
|
+
query?: string | undefined;
|
|
990
|
+
title?: string | undefined;
|
|
991
|
+
category?: string | undefined;
|
|
992
|
+
userId?: string | undefined;
|
|
993
|
+
limit?: number | undefined;
|
|
994
|
+
filters?: {
|
|
995
|
+
type?: "query" | "user" | "global" | undefined;
|
|
996
|
+
query?: string | undefined;
|
|
997
|
+
category?: string | undefined;
|
|
998
|
+
createdBy?: string | undefined;
|
|
999
|
+
tags?: string[] | undefined;
|
|
1000
|
+
} | undefined;
|
|
1001
|
+
createdBy?: string | undefined;
|
|
1002
|
+
updatedBy?: string | undefined;
|
|
1003
|
+
offset?: number | undefined;
|
|
1004
|
+
tags?: string[] | undefined;
|
|
1005
|
+
content?: string | undefined;
|
|
1006
|
+
} | undefined;
|
|
1007
|
+
}, {
|
|
1008
|
+
operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
|
|
1009
|
+
data?: {
|
|
1010
|
+
id?: number | undefined;
|
|
1011
|
+
type?: "query" | "user" | "global" | undefined;
|
|
1012
|
+
query?: string | undefined;
|
|
1013
|
+
title?: string | undefined;
|
|
1014
|
+
category?: string | undefined;
|
|
1015
|
+
userId?: string | undefined;
|
|
1016
|
+
limit?: number | undefined;
|
|
1017
|
+
filters?: {
|
|
1018
|
+
type?: "query" | "user" | "global" | undefined;
|
|
1019
|
+
query?: string | undefined;
|
|
1020
|
+
category?: string | undefined;
|
|
1021
|
+
createdBy?: string | undefined;
|
|
1022
|
+
tags?: string[] | undefined;
|
|
1023
|
+
} | undefined;
|
|
1024
|
+
createdBy?: string | undefined;
|
|
1025
|
+
updatedBy?: string | undefined;
|
|
1026
|
+
offset?: number | undefined;
|
|
1027
|
+
tags?: string[] | undefined;
|
|
1028
|
+
content?: string | undefined;
|
|
1029
|
+
} | undefined;
|
|
1030
|
+
}>;
|
|
1031
|
+
type KbNodesRequestPayload = z.infer<typeof KbNodesRequestPayloadSchema>;
|
|
1032
|
+
interface T_RESPONSE {
|
|
1033
|
+
success: boolean;
|
|
1034
|
+
data?: any;
|
|
1035
|
+
errors: string[];
|
|
583
1036
|
}
|
|
584
1037
|
|
|
585
1038
|
/**
|
|
@@ -845,6 +1298,7 @@ type SystemPrompt = string | Anthropic.Messages.TextBlockParam[];
|
|
|
845
1298
|
interface LLMMessages {
|
|
846
1299
|
sys: SystemPrompt;
|
|
847
1300
|
user: string;
|
|
1301
|
+
prefill?: string;
|
|
848
1302
|
}
|
|
849
1303
|
interface LLMOptions {
|
|
850
1304
|
model?: string;
|
|
@@ -895,6 +1349,17 @@ declare class LLM {
|
|
|
895
1349
|
private static _anthropicStreamWithTools;
|
|
896
1350
|
private static _groqText;
|
|
897
1351
|
private static _groqStream;
|
|
1352
|
+
private static _geminiText;
|
|
1353
|
+
private static _geminiStream;
|
|
1354
|
+
/**
|
|
1355
|
+
* Recursively strip unsupported JSON Schema properties for Gemini
|
|
1356
|
+
* Gemini doesn't support: additionalProperties, $schema, etc.
|
|
1357
|
+
*/
|
|
1358
|
+
private static _cleanSchemaForGemini;
|
|
1359
|
+
private static _geminiStreamWithTools;
|
|
1360
|
+
private static _openaiText;
|
|
1361
|
+
private static _openaiStream;
|
|
1362
|
+
private static _openaiStreamWithTools;
|
|
898
1363
|
/**
|
|
899
1364
|
* Parse JSON string, handling markdown code blocks and surrounding text
|
|
900
1365
|
* Enhanced version with jsonrepair to handle malformed JSON from LLMs
|
|
@@ -1310,15 +1775,17 @@ declare const STORAGE_CONFIG: {
|
|
|
1310
1775
|
*/
|
|
1311
1776
|
MAX_ROWS_PER_BLOCK: number;
|
|
1312
1777
|
/**
|
|
1313
|
-
* Maximum size in bytes per UIBlock (
|
|
1778
|
+
* Maximum size in bytes per UIBlock (500KB - reduced to save memory)
|
|
1314
1779
|
*/
|
|
1315
1780
|
MAX_SIZE_PER_BLOCK_BYTES: number;
|
|
1316
1781
|
/**
|
|
1317
1782
|
* Number of days to keep threads before cleanup
|
|
1783
|
+
* Note: This is for in-memory storage. Conversations are also persisted to database.
|
|
1318
1784
|
*/
|
|
1319
1785
|
THREAD_RETENTION_DAYS: number;
|
|
1320
1786
|
/**
|
|
1321
1787
|
* Number of days to keep UIBlocks before cleanup
|
|
1788
|
+
* Note: This is for in-memory storage. Data is also persisted to database.
|
|
1322
1789
|
*/
|
|
1323
1790
|
UIBLOCK_RETENTION_DAYS: number;
|
|
1324
1791
|
};
|
|
@@ -1335,14 +1802,941 @@ declare const CONTEXT_CONFIG: {
|
|
|
1335
1802
|
MAX_CONVERSATION_CONTEXT_BLOCKS: number;
|
|
1336
1803
|
};
|
|
1337
1804
|
|
|
1338
|
-
|
|
1805
|
+
/**
|
|
1806
|
+
* LLM Usage Logger - Tracks token usage, costs, and timing for all LLM API calls
|
|
1807
|
+
*/
|
|
1808
|
+
interface LLMUsageEntry {
|
|
1809
|
+
timestamp: string;
|
|
1810
|
+
requestId: string;
|
|
1811
|
+
provider: string;
|
|
1812
|
+
model: string;
|
|
1813
|
+
method: string;
|
|
1814
|
+
inputTokens: number;
|
|
1815
|
+
outputTokens: number;
|
|
1816
|
+
cacheReadTokens?: number;
|
|
1817
|
+
cacheWriteTokens?: number;
|
|
1818
|
+
totalTokens: number;
|
|
1819
|
+
costUSD: number;
|
|
1820
|
+
durationMs: number;
|
|
1821
|
+
toolCalls?: number;
|
|
1822
|
+
success: boolean;
|
|
1823
|
+
error?: string;
|
|
1824
|
+
}
|
|
1825
|
+
declare class LLMUsageLogger {
|
|
1826
|
+
private logStream;
|
|
1827
|
+
private logPath;
|
|
1828
|
+
private enabled;
|
|
1829
|
+
private sessionStats;
|
|
1830
|
+
constructor();
|
|
1831
|
+
private initLogStream;
|
|
1832
|
+
private writeHeader;
|
|
1833
|
+
/**
|
|
1834
|
+
* Calculate cost based on token usage and model
|
|
1835
|
+
*/
|
|
1836
|
+
calculateCost(model: string, inputTokens: number, outputTokens: number, cacheReadTokens?: number, cacheWriteTokens?: number): number;
|
|
1837
|
+
/**
|
|
1838
|
+
* Log an LLM API call
|
|
1839
|
+
*/
|
|
1840
|
+
log(entry: LLMUsageEntry): void;
|
|
1841
|
+
/**
|
|
1842
|
+
* Log session summary (call at end of request)
|
|
1843
|
+
*/
|
|
1844
|
+
logSessionSummary(requestContext?: string): void;
|
|
1845
|
+
/**
|
|
1846
|
+
* Reset session stats (call at start of new user request)
|
|
1847
|
+
*/
|
|
1848
|
+
resetSession(): void;
|
|
1849
|
+
/**
|
|
1850
|
+
* Reset the log file for a new request (clears previous logs)
|
|
1851
|
+
* Call this at the start of each USER_PROMPT_REQ
|
|
1852
|
+
*/
|
|
1853
|
+
resetLogFile(requestContext?: string): void;
|
|
1854
|
+
/**
|
|
1855
|
+
* Get current session stats
|
|
1856
|
+
*/
|
|
1857
|
+
getSessionStats(): {
|
|
1858
|
+
totalCalls: number;
|
|
1859
|
+
totalInputTokens: number;
|
|
1860
|
+
totalOutputTokens: number;
|
|
1861
|
+
totalCacheReadTokens: number;
|
|
1862
|
+
totalCacheWriteTokens: number;
|
|
1863
|
+
totalCostUSD: number;
|
|
1864
|
+
totalDurationMs: number;
|
|
1865
|
+
};
|
|
1866
|
+
/**
|
|
1867
|
+
* Generate a unique request ID
|
|
1868
|
+
*/
|
|
1869
|
+
generateRequestId(): string;
|
|
1870
|
+
}
|
|
1871
|
+
declare const llmUsageLogger: LLMUsageLogger;
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* User Prompt Error Logger - Captures detailed errors for USER_PROMPT_REQ
|
|
1875
|
+
* Logs full error details including raw strings for parse failures
|
|
1876
|
+
*/
|
|
1877
|
+
declare class UserPromptErrorLogger {
|
|
1878
|
+
private logStream;
|
|
1879
|
+
private logPath;
|
|
1880
|
+
private enabled;
|
|
1881
|
+
private hasErrors;
|
|
1882
|
+
constructor();
|
|
1883
|
+
/**
|
|
1884
|
+
* Reset the error log file for a new request
|
|
1885
|
+
*/
|
|
1886
|
+
resetLogFile(requestContext?: string): void;
|
|
1887
|
+
/**
|
|
1888
|
+
* Log a JSON parse error with the raw string that failed
|
|
1889
|
+
*/
|
|
1890
|
+
logJsonParseError(context: string, rawString: string, error: Error): void;
|
|
1891
|
+
/**
|
|
1892
|
+
* Log a general error with full details
|
|
1893
|
+
*/
|
|
1894
|
+
logError(context: string, error: Error | string, additionalData?: Record<string, any>): void;
|
|
1895
|
+
/**
|
|
1896
|
+
* Log a SQL query error with the full query
|
|
1897
|
+
*/
|
|
1898
|
+
logSqlError(query: string, error: Error | string, params?: any[]): void;
|
|
1899
|
+
/**
|
|
1900
|
+
* Log an LLM API error
|
|
1901
|
+
*/
|
|
1902
|
+
logLlmError(provider: string, model: string, method: string, error: Error | string, requestData?: any): void;
|
|
1903
|
+
/**
|
|
1904
|
+
* Log tool execution error
|
|
1905
|
+
*/
|
|
1906
|
+
logToolError(toolName: string, toolInput: any, error: Error | string): void;
|
|
1907
|
+
/**
|
|
1908
|
+
* Write final summary if there were errors
|
|
1909
|
+
*/
|
|
1910
|
+
writeSummary(): void;
|
|
1911
|
+
/**
|
|
1912
|
+
* Check if any errors were logged
|
|
1913
|
+
*/
|
|
1914
|
+
hadErrors(): boolean;
|
|
1915
|
+
private write;
|
|
1916
|
+
}
|
|
1917
|
+
declare const userPromptErrorLogger: UserPromptErrorLogger;
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* BM25L Reranker for hybrid semantic search
|
|
1921
|
+
*
|
|
1922
|
+
* BM25L is an improved variant of BM25 that provides better handling of
|
|
1923
|
+
* long documents and term frequency saturation. This implementation is
|
|
1924
|
+
* designed to rerank semantic search results from ChromaDB.
|
|
1925
|
+
*
|
|
1926
|
+
* The hybrid approach combines:
|
|
1927
|
+
* 1. Semantic similarity from ChromaDB embeddings (dense vectors)
|
|
1928
|
+
* 2. Lexical matching from BM25L (sparse, keyword-based)
|
|
1929
|
+
*
|
|
1930
|
+
* This addresses the weakness of pure semantic search which may miss
|
|
1931
|
+
* exact keyword matches that are important for user intent.
|
|
1932
|
+
*/
|
|
1933
|
+
interface BM25LOptions {
|
|
1934
|
+
/** Term frequency saturation parameter (default: 1.5) */
|
|
1935
|
+
k1?: number;
|
|
1936
|
+
/** Length normalization parameter (default: 0.75) */
|
|
1937
|
+
b?: number;
|
|
1938
|
+
/** Lower-bound adjustment from BM25L paper (default: 0.5) */
|
|
1939
|
+
delta?: number;
|
|
1940
|
+
}
|
|
1941
|
+
interface RerankedResult<T> {
|
|
1942
|
+
item: T;
|
|
1943
|
+
originalIndex: number;
|
|
1944
|
+
semanticScore: number;
|
|
1945
|
+
bm25Score: number;
|
|
1946
|
+
hybridScore: number;
|
|
1947
|
+
}
|
|
1948
|
+
interface HybridSearchOptions extends BM25LOptions {
|
|
1949
|
+
/** Weight for semantic score (0-1, default: 0.7) */
|
|
1950
|
+
semanticWeight?: number;
|
|
1951
|
+
/** Weight for BM25 score (0-1, default: 0.3) */
|
|
1952
|
+
bm25Weight?: number;
|
|
1953
|
+
/** Minimum hybrid score threshold (0-1, default: 0) */
|
|
1954
|
+
minScore?: number;
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* BM25L implementation for lexical scoring
|
|
1958
|
+
*/
|
|
1959
|
+
declare class BM25L {
|
|
1960
|
+
private k1;
|
|
1961
|
+
private b;
|
|
1962
|
+
private delta;
|
|
1963
|
+
private documents;
|
|
1964
|
+
private docLengths;
|
|
1965
|
+
private avgDocLength;
|
|
1966
|
+
private termDocFreq;
|
|
1967
|
+
/**
|
|
1968
|
+
* @param documents - Array of raw documents (strings)
|
|
1969
|
+
* @param opts - Optional BM25L parameters
|
|
1970
|
+
*/
|
|
1971
|
+
constructor(documents?: string[], opts?: BM25LOptions);
|
|
1972
|
+
/**
|
|
1973
|
+
* Tokenize text into lowercase alphanumeric tokens
|
|
1974
|
+
*/
|
|
1975
|
+
tokenize(text: string): string[];
|
|
1976
|
+
/**
|
|
1977
|
+
* Compute IDF (Inverse Document Frequency) with smoothing
|
|
1978
|
+
*/
|
|
1979
|
+
private idf;
|
|
1980
|
+
/**
|
|
1981
|
+
* Compute BM25L score for a single document
|
|
1982
|
+
*/
|
|
1983
|
+
score(query: string, docIndex: number): number;
|
|
1984
|
+
/**
|
|
1985
|
+
* Search and rank all documents
|
|
1986
|
+
*/
|
|
1987
|
+
search(query: string): Array<{
|
|
1988
|
+
index: number;
|
|
1989
|
+
score: number;
|
|
1990
|
+
}>;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Hybrid reranker that combines semantic and BM25L scores
|
|
1994
|
+
*
|
|
1995
|
+
* @param query - The search query
|
|
1996
|
+
* @param items - Array of items to rerank
|
|
1997
|
+
* @param getDocument - Function to extract document text from an item
|
|
1998
|
+
* @param getSemanticScore - Function to extract semantic similarity score from an item
|
|
1999
|
+
* @param options - Hybrid search options
|
|
2000
|
+
* @returns Reranked items with hybrid scores
|
|
2001
|
+
*/
|
|
2002
|
+
declare function hybridRerank<T>(query: string, items: T[], getDocument: (item: T) => string, getSemanticScore: (item: T) => number, options?: HybridSearchOptions): RerankedResult<T>[];
|
|
2003
|
+
/**
|
|
2004
|
+
* Simple reranking function for ChromaDB results
|
|
2005
|
+
*
|
|
2006
|
+
* This is a convenience wrapper for reranking ChromaDB query results
|
|
2007
|
+
* that follow the standard { ids, documents, metadatas, distances } format.
|
|
2008
|
+
*
|
|
2009
|
+
* @param query - The search query
|
|
2010
|
+
* @param chromaResults - ChromaDB query results
|
|
2011
|
+
* @param options - Hybrid search options
|
|
2012
|
+
* @returns Reranked results with hybrid scores
|
|
2013
|
+
*/
|
|
2014
|
+
declare function rerankChromaResults(query: string, chromaResults: {
|
|
2015
|
+
ids: string[][];
|
|
2016
|
+
documents: (string | null)[][];
|
|
2017
|
+
metadatas: Record<string, any>[][];
|
|
2018
|
+
distances: number[][];
|
|
2019
|
+
}, options?: HybridSearchOptions): Array<{
|
|
2020
|
+
id: string;
|
|
2021
|
+
document: string | null;
|
|
2022
|
+
metadata: Record<string, any>;
|
|
2023
|
+
distance: number;
|
|
2024
|
+
semanticScore: number;
|
|
2025
|
+
bm25Score: number;
|
|
2026
|
+
hybridScore: number;
|
|
2027
|
+
}>;
|
|
2028
|
+
/**
|
|
2029
|
+
* Rerank conversation search results specifically
|
|
2030
|
+
*
|
|
2031
|
+
* This function is designed to work with the conversation-history.search collection
|
|
2032
|
+
* where we need to fetch more results initially and then rerank them.
|
|
2033
|
+
*
|
|
2034
|
+
* @param query - The user's search query
|
|
2035
|
+
* @param results - Array of conversation search results from ChromaDB
|
|
2036
|
+
* @param options - Hybrid search options
|
|
2037
|
+
* @returns Reranked results sorted by hybrid score
|
|
2038
|
+
*/
|
|
2039
|
+
declare function rerankConversationResults<T extends {
|
|
2040
|
+
userPrompt?: string;
|
|
2041
|
+
similarity?: number;
|
|
2042
|
+
}>(query: string, results: T[], options?: HybridSearchOptions): Array<T & {
|
|
2043
|
+
hybridScore: number;
|
|
2044
|
+
bm25Score: number;
|
|
2045
|
+
}>;
|
|
2046
|
+
|
|
2047
|
+
/**
|
|
2048
|
+
* QueryExecutionService - Handles all query execution, validation, and retry logic
|
|
2049
|
+
* Extracted from BaseLLM for better separation of concerns
|
|
2050
|
+
*/
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* Context for component when requesting query fix
|
|
2054
|
+
*/
|
|
2055
|
+
interface ComponentContext {
|
|
2056
|
+
name: string;
|
|
2057
|
+
type: string;
|
|
2058
|
+
title?: string;
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Result of query validation
|
|
2062
|
+
*/
|
|
2063
|
+
interface QueryValidationResult {
|
|
2064
|
+
component: Component | null;
|
|
2065
|
+
queryKey: string;
|
|
2066
|
+
result: any;
|
|
2067
|
+
validated: boolean;
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Result of batch query validation
|
|
2071
|
+
*/
|
|
2072
|
+
interface BatchValidationResult {
|
|
2073
|
+
components: Component[];
|
|
2074
|
+
queryResults: Map<string, any>;
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Configuration for QueryExecutionService
|
|
2078
|
+
*/
|
|
2079
|
+
interface QueryExecutionServiceConfig {
|
|
2080
|
+
defaultLimit: number;
|
|
2081
|
+
getModelForTask: (taskType: 'simple' | 'complex') => string;
|
|
2082
|
+
getApiKey: (apiKey?: string) => string | undefined;
|
|
2083
|
+
providerName: string;
|
|
2084
|
+
}
|
|
2085
|
+
/**
|
|
2086
|
+
* QueryExecutionService handles all query-related operations
|
|
2087
|
+
*/
|
|
2088
|
+
declare class QueryExecutionService {
|
|
2089
|
+
private config;
|
|
2090
|
+
constructor(config: QueryExecutionServiceConfig);
|
|
2091
|
+
/**
|
|
2092
|
+
* Get the cache key for a query
|
|
2093
|
+
* This ensures the cache key matches what the frontend will send
|
|
2094
|
+
*/
|
|
2095
|
+
getQueryCacheKey(query: any): string;
|
|
2096
|
+
/**
|
|
2097
|
+
* Execute a query against the database
|
|
2098
|
+
* @param query - The SQL query to execute (string or object with sql/values)
|
|
2099
|
+
* @param collections - Collections object containing database execute function
|
|
2100
|
+
* @returns Object with result data and cache key
|
|
2101
|
+
*/
|
|
2102
|
+
executeQuery(query: any, collections: any): Promise<{
|
|
2103
|
+
result: any;
|
|
2104
|
+
cacheKey: string;
|
|
2105
|
+
}>;
|
|
2106
|
+
/**
|
|
2107
|
+
* Request the LLM to fix a failed SQL query
|
|
2108
|
+
* @param failedQuery - The query that failed execution
|
|
2109
|
+
* @param errorMessage - The error message from the failed execution
|
|
2110
|
+
* @param componentContext - Context about the component
|
|
2111
|
+
* @param apiKey - Optional API key
|
|
2112
|
+
* @returns Fixed query string
|
|
2113
|
+
*/
|
|
2114
|
+
requestQueryFix(failedQuery: string, errorMessage: string, componentContext: ComponentContext, apiKey?: string): Promise<string>;
|
|
2115
|
+
/**
|
|
2116
|
+
* Validate a single component's query with retry logic
|
|
2117
|
+
* @param component - The component to validate
|
|
2118
|
+
* @param collections - Collections object containing database execute function
|
|
2119
|
+
* @param apiKey - Optional API key for LLM calls
|
|
2120
|
+
* @returns Validation result with component, query key, and result
|
|
2121
|
+
*/
|
|
2122
|
+
validateSingleQuery(component: Component, collections: any, apiKey?: string): Promise<QueryValidationResult>;
|
|
2123
|
+
/**
|
|
2124
|
+
* Validate multiple component queries in parallel
|
|
2125
|
+
* @param components - Array of components with potential queries
|
|
2126
|
+
* @param collections - Collections object containing database execute function
|
|
2127
|
+
* @param apiKey - Optional API key for LLM calls
|
|
2128
|
+
* @returns Object with validated components and query results map
|
|
2129
|
+
*/
|
|
2130
|
+
validateComponentQueries(components: Component[], collections: any, apiKey?: string): Promise<BatchValidationResult>;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
/**
|
|
2134
|
+
* StreamBuffer - Buffered streaming utility for smoother text delivery
|
|
2135
|
+
* Batches small chunks together and flushes at regular intervals
|
|
2136
|
+
*/
|
|
2137
|
+
type StreamCallback = (chunk: string) => void;
|
|
2138
|
+
/**
|
|
2139
|
+
* StreamBuffer class for managing buffered streaming output
|
|
2140
|
+
* Provides smooth text delivery by batching small chunks
|
|
2141
|
+
*/
|
|
2142
|
+
declare class StreamBuffer {
|
|
2143
|
+
private buffer;
|
|
2144
|
+
private flushTimer;
|
|
2145
|
+
private callback;
|
|
2146
|
+
private fullText;
|
|
2147
|
+
constructor(callback?: StreamCallback);
|
|
2148
|
+
/**
|
|
2149
|
+
* Check if the buffer has a callback configured
|
|
2150
|
+
*/
|
|
2151
|
+
hasCallback(): boolean;
|
|
2152
|
+
/**
|
|
2153
|
+
* Get all text that has been written (including already flushed)
|
|
2154
|
+
*/
|
|
2155
|
+
getFullText(): string;
|
|
2156
|
+
/**
|
|
2157
|
+
* Write a chunk to the buffer
|
|
2158
|
+
* Large chunks or chunks with newlines are flushed immediately
|
|
2159
|
+
* Small chunks are batched and flushed after a short interval
|
|
2160
|
+
*
|
|
2161
|
+
* @param chunk - Text chunk to write
|
|
2162
|
+
*/
|
|
2163
|
+
write(chunk: string): void;
|
|
2164
|
+
/**
|
|
2165
|
+
* Flush the buffer immediately
|
|
2166
|
+
* Call this before tool execution or other operations that need clean output
|
|
2167
|
+
*/
|
|
2168
|
+
flush(): void;
|
|
2169
|
+
/**
|
|
2170
|
+
* Internal flush implementation
|
|
2171
|
+
*/
|
|
2172
|
+
private flushNow;
|
|
2173
|
+
/**
|
|
2174
|
+
* Clean up resources
|
|
2175
|
+
* Call this when done with the buffer
|
|
2176
|
+
*/
|
|
2177
|
+
dispose(): void;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* ToolExecutorService - Handles execution of SQL queries and external tools
|
|
2182
|
+
* Extracted from BaseLLM.generateTextResponse for better separation of concerns
|
|
2183
|
+
*/
|
|
2184
|
+
|
|
2185
|
+
/**
|
|
2186
|
+
* External tool definition
|
|
2187
|
+
*/
|
|
2188
|
+
interface ExternalTool {
|
|
2189
|
+
id: string;
|
|
2190
|
+
name: string;
|
|
2191
|
+
description?: string;
|
|
2192
|
+
/** Tool type: "source" = routed through SourceAgent, "direct" = called directly by MainAgent */
|
|
2193
|
+
toolType?: 'source' | 'direct';
|
|
2194
|
+
/** Full untruncated schema for source agent (all columns visible) */
|
|
2195
|
+
fullSchema?: string;
|
|
2196
|
+
/** Schema size tier: small (≤50 tables), medium (51-200), large (201-500), very_large (500+) */
|
|
2197
|
+
schemaTier?: string;
|
|
2198
|
+
/** Schema search function for very_large tier — keyword search over entities */
|
|
2199
|
+
schemaSearchFn?: (keywords: string[]) => string;
|
|
2200
|
+
fn: (input: any) => Promise<any>;
|
|
2201
|
+
limit?: number;
|
|
2202
|
+
outputSchema?: any;
|
|
2203
|
+
executionType?: 'immediate' | 'deferred';
|
|
2204
|
+
userProvidedData?: any;
|
|
2205
|
+
params?: Record<string, any>;
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Executed tool tracking info
|
|
2209
|
+
*/
|
|
2210
|
+
interface ExecutedToolInfo {
|
|
2211
|
+
id: string;
|
|
2212
|
+
name: string;
|
|
2213
|
+
params: any;
|
|
2214
|
+
result: {
|
|
2215
|
+
_totalRecords: number;
|
|
2216
|
+
_recordsShown: number;
|
|
2217
|
+
_metadata?: any;
|
|
2218
|
+
_sampleData: any[];
|
|
2219
|
+
};
|
|
2220
|
+
outputSchema?: any;
|
|
2221
|
+
sourceSchema?: string;
|
|
2222
|
+
sourceType?: string;
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Task types for model selection
|
|
2227
|
+
* - 'complex': Text generation, component matching, parameter adaptation (uses best model in balanced mode)
|
|
2228
|
+
* - 'simple': Classification, action generation (uses fast model in balanced mode)
|
|
2229
|
+
*/
|
|
2230
|
+
type TaskType = 'complex' | 'simple';
|
|
2231
|
+
interface BaseLLMConfig {
|
|
2232
|
+
model?: string;
|
|
2233
|
+
fastModel?: string;
|
|
2234
|
+
defaultLimit?: number;
|
|
2235
|
+
apiKey?: string;
|
|
2236
|
+
/**
|
|
2237
|
+
* Model selection strategy:
|
|
2238
|
+
* - 'best': Use best model for all tasks (highest quality, higher cost)
|
|
2239
|
+
* - 'fast': Use fast model for all tasks (lower quality, lower cost)
|
|
2240
|
+
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
2241
|
+
*/
|
|
2242
|
+
modelStrategy?: ModelStrategy;
|
|
2243
|
+
conversationSimilarityThreshold?: number;
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* BaseLLM abstract class for AI-powered component generation and matching
|
|
2247
|
+
* Provides common functionality for all LLM providers
|
|
2248
|
+
*/
|
|
2249
|
+
declare abstract class BaseLLM {
|
|
2250
|
+
protected model: string;
|
|
2251
|
+
protected fastModel: string;
|
|
2252
|
+
protected defaultLimit: number;
|
|
2253
|
+
protected apiKey?: string;
|
|
2254
|
+
protected modelStrategy: ModelStrategy;
|
|
2255
|
+
protected conversationSimilarityThreshold: number;
|
|
2256
|
+
protected queryService: QueryExecutionService;
|
|
2257
|
+
constructor(config?: BaseLLMConfig);
|
|
2258
|
+
/**
|
|
2259
|
+
* Get the appropriate model based on task type and model strategy
|
|
2260
|
+
* @param taskType - 'complex' for text generation/matching, 'simple' for classification/actions
|
|
2261
|
+
* @returns The model string to use for this task
|
|
2262
|
+
*/
|
|
2263
|
+
protected getModelForTask(taskType: TaskType): string;
|
|
2264
|
+
/**
|
|
2265
|
+
* Set the model strategy at runtime
|
|
2266
|
+
* @param strategy - 'best', 'fast', or 'balanced'
|
|
2267
|
+
*/
|
|
2268
|
+
setModelStrategy(strategy: ModelStrategy): void;
|
|
2269
|
+
/**
|
|
2270
|
+
* Get the current model strategy
|
|
2271
|
+
* @returns The current model strategy
|
|
2272
|
+
*/
|
|
2273
|
+
getModelStrategy(): ModelStrategy;
|
|
2274
|
+
/**
|
|
2275
|
+
* Set the conversation similarity threshold at runtime
|
|
2276
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
2277
|
+
*/
|
|
2278
|
+
setConversationSimilarityThreshold(threshold: number): void;
|
|
2279
|
+
/**
|
|
2280
|
+
* Get the current conversation similarity threshold
|
|
2281
|
+
* @returns The current threshold value
|
|
2282
|
+
*/
|
|
2283
|
+
getConversationSimilarityThreshold(): number;
|
|
2284
|
+
/**
|
|
2285
|
+
* Get the default model for this provider (used for complex tasks like text generation)
|
|
2286
|
+
*/
|
|
2287
|
+
protected abstract getDefaultModel(): string;
|
|
2288
|
+
/**
|
|
2289
|
+
* Get the default fast model for this provider (used for simple tasks: classification, matching, actions)
|
|
2290
|
+
* Should return a cheaper/faster model like Haiku for Anthropic
|
|
2291
|
+
*/
|
|
2292
|
+
protected abstract getDefaultFastModel(): string;
|
|
2293
|
+
/**
|
|
2294
|
+
* Get the default API key from environment
|
|
2295
|
+
*/
|
|
2296
|
+
protected abstract getDefaultApiKey(): string | undefined;
|
|
2297
|
+
/**
|
|
2298
|
+
* Get the provider name (for logging)
|
|
2299
|
+
*/
|
|
2300
|
+
protected abstract getProviderName(): string;
|
|
2301
|
+
/**
|
|
2302
|
+
* Get the API key (from instance, parameter, or environment)
|
|
2303
|
+
*/
|
|
2304
|
+
protected getApiKey(apiKey?: string): string | undefined;
|
|
2305
|
+
/**
|
|
2306
|
+
* Check if a component contains a Form (data_modification component)
|
|
2307
|
+
* Forms have hardcoded defaultValues that become stale when cached
|
|
2308
|
+
* This checks both single Form components and Forms inside MultiComponentContainer
|
|
2309
|
+
*/
|
|
2310
|
+
protected containsFormComponent(component: any): boolean;
|
|
2311
|
+
/**
|
|
2312
|
+
* Match components from text response suggestions and generate follow-up questions
|
|
2313
|
+
* Takes a text response with component suggestions (c1:type format) and matches with available components
|
|
2314
|
+
* Also generates title, description, and intelligent follow-up questions (actions) based on the analysis
|
|
2315
|
+
* All components are placed in a default MultiComponentContainer layout
|
|
2316
|
+
* @param analysisContent - The text response containing component suggestions
|
|
2317
|
+
* @param components - List of available components
|
|
2318
|
+
* @param apiKey - Optional API key
|
|
2319
|
+
* @param componentStreamCallback - Optional callback to stream primary KPI component as soon as it's identified
|
|
2320
|
+
* @returns Object containing matched components, layout title/description, and follow-up actions
|
|
2321
|
+
*/
|
|
2322
|
+
matchComponentsFromAnalysis(analysisContent: string, components: Component[], userPrompt: string, apiKey?: string, componentStreamCallback?: (component: Component) => void, deferredTools?: any[], executedTools?: any[], collections?: any, userId?: string): Promise<{
|
|
2323
|
+
components: Component[];
|
|
2324
|
+
layoutTitle: string;
|
|
2325
|
+
layoutDescription: string;
|
|
2326
|
+
actions: Action[];
|
|
2327
|
+
}>;
|
|
2328
|
+
/**
|
|
2329
|
+
* Classify user question into category and detect external tools needed
|
|
2330
|
+
* Determines if question is for data analysis, requires external tools, or needs text response
|
|
2331
|
+
*/
|
|
2332
|
+
classifyQuestionCategory(userPrompt: string, apiKey?: string, conversationHistory?: string, externalTools?: any[]): Promise<{
|
|
2333
|
+
category: 'data_analysis' | 'data_modification' | 'general';
|
|
2334
|
+
externalTools: Array<{
|
|
2335
|
+
type: string;
|
|
2336
|
+
name: string;
|
|
2337
|
+
description: string;
|
|
2338
|
+
parameters: Record<string, any>;
|
|
2339
|
+
}>;
|
|
2340
|
+
dataAnalysisType?: 'visualization' | 'calculation' | 'comparison' | 'trend';
|
|
2341
|
+
reasoning: string;
|
|
2342
|
+
confidence: number;
|
|
2343
|
+
}>;
|
|
2344
|
+
/**
|
|
2345
|
+
* Adapt UI block parameters based on current user question
|
|
2346
|
+
* Takes a matched UI block from semantic search and modifies its props to answer the new question
|
|
2347
|
+
* Also adapts the cached text response to match the new question
|
|
2348
|
+
*/
|
|
2349
|
+
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, cachedTextResponse?: string): Promise<{
|
|
2350
|
+
success: boolean;
|
|
2351
|
+
adaptedComponent?: Component;
|
|
2352
|
+
adaptedTextResponse?: string;
|
|
2353
|
+
parametersChanged?: Array<{
|
|
2354
|
+
field: string;
|
|
2355
|
+
reason: string;
|
|
2356
|
+
}>;
|
|
2357
|
+
explanation: string;
|
|
2358
|
+
}>;
|
|
2359
|
+
/**
|
|
2360
|
+
* Generate text-based response for user question
|
|
2361
|
+
* This provides conversational text responses instead of component generation
|
|
2362
|
+
* Supports tool calling for query execution with automatic retry on errors (max 3 attempts)
|
|
2363
|
+
* After generating text response, if components are provided, matches suggested components
|
|
2364
|
+
*/
|
|
2365
|
+
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>;
|
|
2366
|
+
/**
|
|
2367
|
+
* Main orchestration function with semantic search and multi-step classification
|
|
2368
|
+
* NEW FLOW (Recommended):
|
|
2369
|
+
* 1. Semantic search: Check previous conversations (>60% match)
|
|
2370
|
+
* - If match found → Adapt UI block parameters and return
|
|
2371
|
+
* 2. Category classification: Determine if data_analysis, requires_external_tools, or text_response
|
|
2372
|
+
* 3. Route appropriately based on category and response mode
|
|
2373
|
+
*/
|
|
2374
|
+
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>;
|
|
2375
|
+
/**
|
|
2376
|
+
* Generate next questions that the user might ask based on the original prompt and generated component
|
|
2377
|
+
* This helps provide intelligent suggestions for follow-up queries
|
|
2378
|
+
* For general/conversational questions without components, pass textResponse instead
|
|
2379
|
+
*/
|
|
2380
|
+
generateNextQuestions(originalUserPrompt: string, component?: Component | null, componentData?: Record<string, unknown>, apiKey?: string, conversationHistory?: string, textResponse?: string): Promise<string[]>;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
interface AnthropicLLMConfig extends BaseLLMConfig {
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* AnthropicLLM class for handling AI-powered component generation and matching using Anthropic Claude
|
|
2387
|
+
*/
|
|
2388
|
+
declare class AnthropicLLM extends BaseLLM {
|
|
2389
|
+
constructor(config?: AnthropicLLMConfig);
|
|
2390
|
+
protected getDefaultModel(): string;
|
|
2391
|
+
protected getDefaultFastModel(): string;
|
|
2392
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2393
|
+
protected getProviderName(): string;
|
|
2394
|
+
}
|
|
2395
|
+
declare const anthropicLLM: AnthropicLLM;
|
|
2396
|
+
|
|
2397
|
+
interface GroqLLMConfig extends BaseLLMConfig {
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* GroqLLM class for handling AI-powered component generation and matching using Groq
|
|
2401
|
+
*/
|
|
2402
|
+
declare class GroqLLM extends BaseLLM {
|
|
2403
|
+
constructor(config?: GroqLLMConfig);
|
|
2404
|
+
protected getDefaultModel(): string;
|
|
2405
|
+
protected getDefaultFastModel(): string;
|
|
2406
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2407
|
+
protected getProviderName(): string;
|
|
2408
|
+
}
|
|
2409
|
+
declare const groqLLM: GroqLLM;
|
|
2410
|
+
|
|
2411
|
+
interface GeminiLLMConfig extends BaseLLMConfig {
|
|
2412
|
+
}
|
|
2413
|
+
/**
|
|
2414
|
+
* GeminiLLM class for handling AI-powered component generation and matching using Google Gemini
|
|
2415
|
+
*/
|
|
2416
|
+
declare class GeminiLLM extends BaseLLM {
|
|
2417
|
+
constructor(config?: GeminiLLMConfig);
|
|
2418
|
+
protected getDefaultModel(): string;
|
|
2419
|
+
protected getDefaultFastModel(): string;
|
|
2420
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2421
|
+
protected getProviderName(): string;
|
|
2422
|
+
}
|
|
2423
|
+
declare const geminiLLM: GeminiLLM;
|
|
2424
|
+
|
|
2425
|
+
interface OpenAILLMConfig extends BaseLLMConfig {
|
|
2426
|
+
}
|
|
2427
|
+
/**
|
|
2428
|
+
* OpenAILLM class for handling AI-powered component generation and matching using OpenAI GPT models
|
|
2429
|
+
*/
|
|
2430
|
+
declare class OpenAILLM extends BaseLLM {
|
|
2431
|
+
constructor(config?: OpenAILLMConfig);
|
|
2432
|
+
protected getDefaultModel(): string;
|
|
2433
|
+
protected getDefaultFastModel(): string;
|
|
2434
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2435
|
+
protected getProviderName(): string;
|
|
2436
|
+
}
|
|
2437
|
+
declare const openaiLLM: OpenAILLM;
|
|
2438
|
+
|
|
2439
|
+
/**
|
|
2440
|
+
* Query Cache - Stores query results with configurable TTL
|
|
2441
|
+
* Used to avoid re-executing queries that were already validated
|
|
2442
|
+
*/
|
|
2443
|
+
declare class QueryCache {
|
|
2444
|
+
private cache;
|
|
2445
|
+
private queryIdCache;
|
|
2446
|
+
private ttlMs;
|
|
2447
|
+
private cleanupInterval;
|
|
2448
|
+
constructor();
|
|
2449
|
+
/**
|
|
2450
|
+
* Set the cache TTL (Time To Live)
|
|
2451
|
+
* @param minutes - TTL in minutes (default: 5)
|
|
2452
|
+
*/
|
|
2453
|
+
setTTL(minutes: number): void;
|
|
2454
|
+
/**
|
|
2455
|
+
* Get the current TTL in minutes
|
|
2456
|
+
*/
|
|
2457
|
+
getTTL(): number;
|
|
2458
|
+
/**
|
|
2459
|
+
* Store query result in cache
|
|
2460
|
+
* Key is the exact query string (or JSON for parameterized queries)
|
|
2461
|
+
*/
|
|
2462
|
+
set(query: string, data: any): void;
|
|
2463
|
+
/**
|
|
2464
|
+
* Get cached result if exists and not expired
|
|
2465
|
+
*/
|
|
2466
|
+
get(query: string): any | null;
|
|
2467
|
+
/**
|
|
2468
|
+
* Check if query exists in cache (not expired)
|
|
2469
|
+
*/
|
|
2470
|
+
has(query: string): boolean;
|
|
2471
|
+
/**
|
|
2472
|
+
* Remove a specific query from cache
|
|
2473
|
+
*/
|
|
2474
|
+
delete(query: string): void;
|
|
2475
|
+
/**
|
|
2476
|
+
* Clear all cached entries
|
|
2477
|
+
*/
|
|
2478
|
+
clear(): void;
|
|
2479
|
+
/**
|
|
2480
|
+
* Get cache statistics
|
|
2481
|
+
*/
|
|
2482
|
+
getStats(): {
|
|
2483
|
+
size: number;
|
|
2484
|
+
oldestEntryAge: number | null;
|
|
2485
|
+
};
|
|
2486
|
+
/**
|
|
2487
|
+
* Start periodic cleanup of expired entries
|
|
2488
|
+
*/
|
|
2489
|
+
private startCleanup;
|
|
2490
|
+
/**
|
|
2491
|
+
* Generate a unique query ID
|
|
2492
|
+
*/
|
|
2493
|
+
private generateQueryId;
|
|
2494
|
+
/**
|
|
2495
|
+
* Store a query by ID. Returns the generated queryId.
|
|
2496
|
+
* The query is stored server-side; only the queryId is sent to the frontend.
|
|
2497
|
+
*/
|
|
2498
|
+
storeQuery(query: any, data?: any): string;
|
|
2499
|
+
/**
|
|
2500
|
+
* Get a stored query by its ID (not expired)
|
|
2501
|
+
*/
|
|
2502
|
+
getQuery(queryId: string): {
|
|
2503
|
+
query: any;
|
|
2504
|
+
data: any;
|
|
2505
|
+
} | null;
|
|
2506
|
+
/**
|
|
2507
|
+
* Update cached data for a queryId
|
|
2508
|
+
*/
|
|
2509
|
+
setQueryData(queryId: string, data: any): void;
|
|
2510
|
+
/**
|
|
2511
|
+
* Stop cleanup interval (for graceful shutdown)
|
|
2512
|
+
*/
|
|
2513
|
+
destroy(): void;
|
|
2514
|
+
}
|
|
2515
|
+
declare const queryCache: QueryCache;
|
|
2516
|
+
|
|
2517
|
+
/**
|
|
2518
|
+
* Manages conversation history scoped per user + dashboard.
|
|
2519
|
+
* Each user-dashboard pair has its own isolated history that expires after a configurable TTL.
|
|
2520
|
+
*/
|
|
2521
|
+
declare class DashboardConversationHistory {
|
|
2522
|
+
private histories;
|
|
2523
|
+
private ttlMs;
|
|
2524
|
+
private maxEntries;
|
|
2525
|
+
private cleanupInterval;
|
|
2526
|
+
constructor();
|
|
2527
|
+
/**
|
|
2528
|
+
* Set the TTL for dashboard histories
|
|
2529
|
+
* @param minutes - TTL in minutes
|
|
2530
|
+
*/
|
|
2531
|
+
setTTL(minutes: number): void;
|
|
2532
|
+
/**
|
|
2533
|
+
* Set max entries per dashboard
|
|
2534
|
+
*/
|
|
2535
|
+
setMaxEntries(max: number): void;
|
|
2536
|
+
/**
|
|
2537
|
+
* Add a conversation entry for a user's dashboard
|
|
2538
|
+
*/
|
|
2539
|
+
addEntry(dashboardId: string, userPrompt: string, componentSummary: string, userId?: string): void;
|
|
2540
|
+
/**
|
|
2541
|
+
* Get formatted conversation history for a user's dashboard
|
|
2542
|
+
*/
|
|
2543
|
+
getHistory(dashboardId: string, userId?: string): string;
|
|
2544
|
+
/**
|
|
2545
|
+
* Clear history for a specific user's dashboard
|
|
2546
|
+
*/
|
|
2547
|
+
clearDashboard(dashboardId: string, userId?: string): void;
|
|
2548
|
+
/**
|
|
2549
|
+
* Clear all dashboard histories
|
|
2550
|
+
*/
|
|
2551
|
+
clearAll(): void;
|
|
2552
|
+
/**
|
|
2553
|
+
* Start periodic cleanup of expired histories
|
|
2554
|
+
*/
|
|
2555
|
+
private startCleanup;
|
|
2556
|
+
/**
|
|
2557
|
+
* Stop cleanup interval (for graceful shutdown)
|
|
2558
|
+
*/
|
|
2559
|
+
destroy(): void;
|
|
2560
|
+
}
|
|
2561
|
+
declare const dashboardConversationHistory: DashboardConversationHistory;
|
|
2562
|
+
|
|
2563
|
+
/**
|
|
2564
|
+
* Multi-Agent Architecture Types
|
|
2565
|
+
*
|
|
2566
|
+
* Defines interfaces for the hierarchical agent system:
|
|
2567
|
+
* - Main Agent: ONE LLM.streamWithTools() call with source agent tools
|
|
2568
|
+
* - Source Agents: independent agents that query individual data sources
|
|
2569
|
+
*
|
|
2570
|
+
* The main agent sees only source summaries. When it calls a source tool,
|
|
2571
|
+
* the SourceAgent runs independently (own LLM, own retries) and returns clean data.
|
|
2572
|
+
*/
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* Per-entity detail: name, row count, and column names.
|
|
2576
|
+
* Gives the main agent enough context to route to the right source.
|
|
2577
|
+
*/
|
|
2578
|
+
interface EntityDetail {
|
|
2579
|
+
/** Entity name (table, sheet, endpoint) */
|
|
2580
|
+
name: string;
|
|
2581
|
+
/** Approximate row count */
|
|
2582
|
+
rowCount?: number;
|
|
2583
|
+
/** Column/field names */
|
|
2584
|
+
columns: string[];
|
|
2585
|
+
}
|
|
2586
|
+
/**
|
|
2587
|
+
* Representation of a data source for the main agent.
|
|
2588
|
+
* Contains entity names WITH column names so the LLM can route accurately.
|
|
2589
|
+
*/
|
|
2590
|
+
interface SourceSummary {
|
|
2591
|
+
/** Source ID (matches tool ID prefix) */
|
|
2592
|
+
id: string;
|
|
2593
|
+
/** Human-readable source name */
|
|
2594
|
+
name: string;
|
|
2595
|
+
/** Source type: postgres, excel, rest_api, etc. */
|
|
2596
|
+
type: string;
|
|
2597
|
+
/** Brief description of what data this source contains */
|
|
2598
|
+
description: string;
|
|
2599
|
+
/** Detailed entity info with column names for routing */
|
|
2600
|
+
entityDetails: EntityDetail[];
|
|
2601
|
+
/** The tool ID associated with this source */
|
|
2602
|
+
toolId: string;
|
|
2603
|
+
}
|
|
2604
|
+
/**
|
|
2605
|
+
* What a source agent returns after querying its data source.
|
|
2606
|
+
* The main agent uses this to analyze and compose the final response.
|
|
2607
|
+
*/
|
|
2608
|
+
interface SourceAgentResult {
|
|
2609
|
+
/** Source ID */
|
|
2610
|
+
sourceId: string;
|
|
2611
|
+
/** Source name */
|
|
2612
|
+
sourceName: string;
|
|
2613
|
+
/** Whether the query succeeded */
|
|
2614
|
+
success: boolean;
|
|
2615
|
+
/** Result data rows */
|
|
2616
|
+
data: any[];
|
|
2617
|
+
/** Metadata about the query execution */
|
|
2618
|
+
metadata: SourceAgentMetadata;
|
|
2619
|
+
/** Tool execution info (reused for component generation) */
|
|
2620
|
+
executedTool: ExecutedToolInfo;
|
|
2621
|
+
/** Error message if failed */
|
|
2622
|
+
error?: string;
|
|
2623
|
+
}
|
|
2624
|
+
interface SourceAgentMetadata {
|
|
2625
|
+
/** Total rows that matched the query (before limit) */
|
|
2626
|
+
totalRowsMatched: number;
|
|
2627
|
+
/** Rows actually returned (after limit) */
|
|
2628
|
+
rowsReturned: number;
|
|
2629
|
+
/** Whether the result was truncated by the row limit */
|
|
2630
|
+
isLimited: boolean;
|
|
2631
|
+
/** The query/params that were executed */
|
|
2632
|
+
queryExecuted?: string;
|
|
2633
|
+
/** Execution time in milliseconds */
|
|
2634
|
+
executionTimeMs: number;
|
|
2635
|
+
}
|
|
2636
|
+
/**
|
|
2637
|
+
* The complete response from the multi-agent system.
|
|
2638
|
+
* Contains everything needed for text display + component generation.
|
|
2639
|
+
*/
|
|
2640
|
+
interface AgentResponse {
|
|
2641
|
+
/** Generated text response (analysis of the data) */
|
|
2642
|
+
text: string;
|
|
2643
|
+
/** All executed tools across all source agents (for component generation) */
|
|
2644
|
+
executedTools: ExecutedToolInfo[];
|
|
2645
|
+
/** Individual results from each source agent */
|
|
2646
|
+
sourceResults: SourceAgentResult[];
|
|
2647
|
+
}
|
|
2648
|
+
/**
|
|
2649
|
+
* Configuration for the multi-agent system.
|
|
2650
|
+
* Controls limits, models, and behavior.
|
|
2651
|
+
*/
|
|
2652
|
+
interface AgentConfig {
|
|
2653
|
+
/** Max rows a source agent can return (default: 50) */
|
|
2654
|
+
maxRowsPerSource: number;
|
|
2655
|
+
/** Model for the main agent (routing + analysis in one LLM call) */
|
|
2656
|
+
mainAgentModel: string;
|
|
2657
|
+
/** Model for source agent query generation */
|
|
2658
|
+
sourceAgentModel: string;
|
|
2659
|
+
/** API key for LLM calls */
|
|
2660
|
+
apiKey?: string;
|
|
2661
|
+
/** Max retry attempts per source agent */
|
|
2662
|
+
maxRetries: number;
|
|
2663
|
+
/** Max tool calling iterations for the main agent loop */
|
|
2664
|
+
maxIterations: number;
|
|
2665
|
+
/** Global knowledge base context (static, same for all users/questions — cached in system prompt) */
|
|
2666
|
+
globalKnowledgeBase?: string;
|
|
2667
|
+
/** Per-request knowledge base context (user-specific + query-matched — dynamic, not cached) */
|
|
2668
|
+
knowledgeBaseContext?: string;
|
|
2669
|
+
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Default agent configuration
|
|
2672
|
+
*/
|
|
2673
|
+
declare const DEFAULT_AGENT_CONFIG: AgentConfig;
|
|
2674
|
+
|
|
2675
|
+
/**
|
|
2676
|
+
* Main Agent (Orchestrator)
|
|
2677
|
+
*
|
|
2678
|
+
* A single LLM.streamWithTools() call that handles everything:
|
|
2679
|
+
* - Routing: decides which source(s) to query based on summaries
|
|
2680
|
+
* - Querying: calls source tools (each wraps an independent SourceAgent)
|
|
2681
|
+
* - Direct tools: calls pre-built function tools directly with LLM-provided params
|
|
2682
|
+
* - Re-querying: if data is wrong/incomplete, calls tools again with modified intent
|
|
2683
|
+
* - Analysis: generates final text response from the data
|
|
2684
|
+
*
|
|
2685
|
+
* Two tool types:
|
|
2686
|
+
* - "source" tools: main agent sees summaries, SourceAgent handles SQL generation independently
|
|
2687
|
+
* - "direct" tools: main agent calls fn() directly with structured params (no SourceAgent)
|
|
2688
|
+
*/
|
|
2689
|
+
|
|
2690
|
+
declare class MainAgent {
|
|
2691
|
+
private externalTools;
|
|
2692
|
+
private config;
|
|
2693
|
+
private streamBuffer;
|
|
2694
|
+
constructor(externalTools: ExternalTool[], config: AgentConfig, streamBuffer?: StreamBuffer);
|
|
2695
|
+
/**
|
|
2696
|
+
* Handle a user question using the multi-agent system.
|
|
2697
|
+
*
|
|
2698
|
+
* This is ONE LLM.streamWithTools() call. The LLM:
|
|
2699
|
+
* 1. Sees source summaries + direct tool descriptions in system prompt
|
|
2700
|
+
* 2. Decides which tool(s) to call (routing)
|
|
2701
|
+
* 3. Source tools → SourceAgent runs independently → returns data
|
|
2702
|
+
* 4. Direct tools → fn() called directly with LLM params → returns data
|
|
2703
|
+
* 5. Generates final analysis text
|
|
2704
|
+
*/
|
|
2705
|
+
handleQuestion(userPrompt: string, apiKey?: string, conversationHistory?: string, streamCallback?: (chunk: string) => void): Promise<AgentResponse>;
|
|
2706
|
+
/**
|
|
2707
|
+
* Execute a direct tool — call fn() with LLM-provided params, no SourceAgent.
|
|
2708
|
+
*/
|
|
2709
|
+
private handleDirectTool;
|
|
2710
|
+
/**
|
|
2711
|
+
* Build the main agent's system prompt with source summaries and direct tool descriptions.
|
|
2712
|
+
*/
|
|
2713
|
+
private buildSystemPrompt;
|
|
2714
|
+
/**
|
|
2715
|
+
* Build tool definitions for source tools — summary-only descriptions.
|
|
2716
|
+
* The full schema is inside the SourceAgent which runs independently.
|
|
2717
|
+
*/
|
|
2718
|
+
private buildSourceToolDefinitions;
|
|
2719
|
+
/**
|
|
2720
|
+
* Build tool definitions for direct tools — expose their actual params.
|
|
2721
|
+
* These are called directly by the main agent LLM, no SourceAgent.
|
|
2722
|
+
*/
|
|
2723
|
+
private buildDirectToolDefinitions;
|
|
2724
|
+
/**
|
|
2725
|
+
* Format a source agent's result as a clean string for the main agent LLM.
|
|
2726
|
+
*/
|
|
2727
|
+
private formatResultForMainAgent;
|
|
2728
|
+
/**
|
|
2729
|
+
* Get source summaries (for external inspection/debugging).
|
|
2730
|
+
*/
|
|
2731
|
+
getSourceSummaries(): SourceSummary[];
|
|
2732
|
+
}
|
|
2733
|
+
|
|
1339
2734
|
type MessageTypeHandler = (message: IncomingMessage) => void | Promise<void>;
|
|
1340
2735
|
declare class SuperatomSDK {
|
|
1341
2736
|
private ws;
|
|
1342
2737
|
private url;
|
|
1343
|
-
private apiKey
|
|
2738
|
+
private apiKey?;
|
|
1344
2739
|
private projectId;
|
|
1345
|
-
private userId;
|
|
1346
2740
|
private type;
|
|
1347
2741
|
private bundleDir;
|
|
1348
2742
|
private messageHandlers;
|
|
@@ -1355,10 +2749,19 @@ declare class SuperatomSDK {
|
|
|
1355
2749
|
private tools;
|
|
1356
2750
|
private anthropicApiKey;
|
|
1357
2751
|
private groqApiKey;
|
|
2752
|
+
private geminiApiKey;
|
|
2753
|
+
private openaiApiKey;
|
|
1358
2754
|
private llmProviders;
|
|
2755
|
+
private databaseType;
|
|
2756
|
+
private modelStrategy;
|
|
2757
|
+
private conversationSimilarityThreshold;
|
|
1359
2758
|
private userManager;
|
|
1360
2759
|
private dashboardManager;
|
|
1361
2760
|
private reportManager;
|
|
2761
|
+
private pingInterval;
|
|
2762
|
+
private lastPong;
|
|
2763
|
+
private readonly PING_INTERVAL_MS;
|
|
2764
|
+
private readonly PONG_TIMEOUT_MS;
|
|
1362
2765
|
constructor(config: SuperatomSDKConfig);
|
|
1363
2766
|
/**
|
|
1364
2767
|
* Initialize PromptLoader and load prompts into memory
|
|
@@ -1398,9 +2801,11 @@ declare class SuperatomSDK {
|
|
|
1398
2801
|
*/
|
|
1399
2802
|
private handleMessage;
|
|
1400
2803
|
/**
|
|
1401
|
-
* Send a message to the Superatom service
|
|
2804
|
+
* Send a message to the Superatom service.
|
|
2805
|
+
* Returns true if the message was sent, false if the WebSocket is not connected.
|
|
2806
|
+
* Does NOT throw on closed connections — callers can check the return value if needed.
|
|
1402
2807
|
*/
|
|
1403
|
-
send(message: Message):
|
|
2808
|
+
send(message: Message): boolean;
|
|
1404
2809
|
/**
|
|
1405
2810
|
* Register a message handler to receive all messages
|
|
1406
2811
|
*/
|
|
@@ -1426,6 +2831,19 @@ declare class SuperatomSDK {
|
|
|
1426
2831
|
*/
|
|
1427
2832
|
addCollection<TParams = any, TResult = any>(collectionName: string, operation: CollectionOperation | string, handler: CollectionHandler<TParams, TResult>): void;
|
|
1428
2833
|
private handleReconnect;
|
|
2834
|
+
/**
|
|
2835
|
+
* Start heartbeat to keep WebSocket connection alive
|
|
2836
|
+
* Sends PING every 3 minutes to prevent idle timeout from cloud infrastructure
|
|
2837
|
+
*/
|
|
2838
|
+
private startHeartbeat;
|
|
2839
|
+
/**
|
|
2840
|
+
* Stop the heartbeat interval
|
|
2841
|
+
*/
|
|
2842
|
+
private stopHeartbeat;
|
|
2843
|
+
/**
|
|
2844
|
+
* Handle PONG response from server
|
|
2845
|
+
*/
|
|
2846
|
+
private handlePong;
|
|
1429
2847
|
private storeComponents;
|
|
1430
2848
|
/**
|
|
1431
2849
|
* Set tools for the SDK instance
|
|
@@ -1435,6 +2853,34 @@ declare class SuperatomSDK {
|
|
|
1435
2853
|
* Get the stored tools
|
|
1436
2854
|
*/
|
|
1437
2855
|
getTools(): Tool$1[];
|
|
2856
|
+
/**
|
|
2857
|
+
* Apply model strategy to all LLM provider singletons
|
|
2858
|
+
* @param strategy - 'best', 'fast', or 'balanced'
|
|
2859
|
+
*/
|
|
2860
|
+
private applyModelStrategy;
|
|
2861
|
+
/**
|
|
2862
|
+
* Set model strategy at runtime
|
|
2863
|
+
* @param strategy - 'best', 'fast', or 'balanced'
|
|
2864
|
+
*/
|
|
2865
|
+
setModelStrategy(strategy: ModelStrategy): void;
|
|
2866
|
+
/**
|
|
2867
|
+
* Get current model strategy
|
|
2868
|
+
*/
|
|
2869
|
+
getModelStrategy(): ModelStrategy;
|
|
2870
|
+
/**
|
|
2871
|
+
* Apply conversation similarity threshold to all LLM provider singletons
|
|
2872
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
2873
|
+
*/
|
|
2874
|
+
private applyConversationSimilarityThreshold;
|
|
2875
|
+
/**
|
|
2876
|
+
* Set conversation similarity threshold at runtime
|
|
2877
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
2878
|
+
*/
|
|
2879
|
+
setConversationSimilarityThreshold(threshold: number): void;
|
|
2880
|
+
/**
|
|
2881
|
+
* Get current conversation similarity threshold
|
|
2882
|
+
*/
|
|
2883
|
+
getConversationSimilarityThreshold(): number;
|
|
1438
2884
|
}
|
|
1439
2885
|
|
|
1440
|
-
export { type Action, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type IncomingMessage, LLM, type LogLevel, type Message,
|
|
2886
|
+
export { type Action, type AgentConfig, type AgentResponse, BM25L, type BM25LOptions, type BaseLLMConfig, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, DEFAULT_AGENT_CONFIG, type DatabaseType, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, MainAgent, 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, dashboardConversationHistory, geminiLLM, groqLLM, hybridRerank, llmUsageLogger, logger, openaiLLM, queryCache, rerankChromaResults, rerankConversationResults, userPromptErrorLogger };
|