@superatomai/sdk-node 0.0.19 → 0.0.20-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.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
- render?: any;
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
- render?: any;
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
- render?: any;
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
- render?: any;
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,44 +626,425 @@ 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
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
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;
581
852
  GEMINI_API_KEY?: string;
582
853
  OPENAI_API_KEY?: string;
583
854
  LLM_PROVIDERS?: LLMProvider[];
584
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
+ * Model for the main agent (routing + analysis).
865
+ * Format: "provider/model-name" (e.g., "anthropic/claude-haiku-4-5-20251001")
866
+ * If not set, uses the provider's default model.
867
+ */
868
+ mainAgentModel?: string;
869
+ /**
870
+ * Model for source agents (per-source query generation).
871
+ * Format: "provider/model-name" (e.g., "anthropic/claude-haiku-4-5-20251001")
872
+ * If not set, uses the provider's default model.
873
+ */
874
+ sourceAgentModel?: string;
875
+ /**
876
+ * Separate model configuration for DASH_COMP flow (dashboard component picking)
877
+ * If not provided, falls back to provider-based model selection
878
+ */
879
+ dashCompModels?: DashCompModelConfig;
880
+ /**
881
+ * Similarity threshold for conversation search (semantic matching)
882
+ * Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
883
+ * Higher values require closer matches, lower values allow more distant matches
884
+ * Default: 0.8
885
+ */
886
+ conversationSimilarityThreshold?: number;
887
+ /**
888
+ * Query cache TTL (Time To Live) in minutes
889
+ * Cached query results expire after this duration
890
+ * Default: 5 minutes
891
+ */
892
+ queryCacheTTL?: number;
893
+ /**
894
+ * Dashboard conversation history TTL (Time To Live) in minutes
895
+ * Per-dashboard conversation histories expire after this duration
896
+ * Default: 30 minutes
897
+ */
898
+ dashboardHistoryTTL?: number;
899
+ }
900
+
901
+ declare const KbNodesQueryFiltersSchema: z.ZodObject<{
902
+ query: z.ZodOptional<z.ZodString>;
903
+ category: z.ZodOptional<z.ZodString>;
904
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
905
+ type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
906
+ createdBy: z.ZodOptional<z.ZodString>;
907
+ }, "strip", z.ZodTypeAny, {
908
+ type?: "query" | "user" | "global" | undefined;
909
+ query?: string | undefined;
910
+ category?: string | undefined;
911
+ createdBy?: string | undefined;
912
+ tags?: string[] | undefined;
913
+ }, {
914
+ type?: "query" | "user" | "global" | undefined;
915
+ query?: string | undefined;
916
+ category?: string | undefined;
917
+ createdBy?: string | undefined;
918
+ tags?: string[] | undefined;
919
+ }>;
920
+ type KbNodesQueryFilters = z.infer<typeof KbNodesQueryFiltersSchema>;
921
+ declare const KbNodesRequestPayloadSchema: z.ZodObject<{
922
+ operation: z.ZodEnum<["create", "update", "delete", "getAll", "getOne", "search", "getByCategory", "getByUser", "getCategories", "getTags"]>;
923
+ data: z.ZodOptional<z.ZodObject<{
924
+ id: z.ZodOptional<z.ZodNumber>;
925
+ title: z.ZodOptional<z.ZodString>;
926
+ content: z.ZodOptional<z.ZodString>;
927
+ category: z.ZodOptional<z.ZodString>;
928
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
929
+ type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
930
+ createdBy: z.ZodOptional<z.ZodString>;
931
+ updatedBy: z.ZodOptional<z.ZodString>;
932
+ userId: z.ZodOptional<z.ZodString>;
933
+ query: z.ZodOptional<z.ZodString>;
934
+ filters: z.ZodOptional<z.ZodObject<{
935
+ query: z.ZodOptional<z.ZodString>;
936
+ category: z.ZodOptional<z.ZodString>;
937
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
938
+ type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
939
+ createdBy: z.ZodOptional<z.ZodString>;
940
+ }, "strip", z.ZodTypeAny, {
941
+ type?: "query" | "user" | "global" | undefined;
942
+ query?: string | undefined;
943
+ category?: string | undefined;
944
+ createdBy?: string | undefined;
945
+ tags?: string[] | undefined;
946
+ }, {
947
+ type?: "query" | "user" | "global" | undefined;
948
+ query?: string | undefined;
949
+ category?: string | undefined;
950
+ createdBy?: string | undefined;
951
+ tags?: string[] | undefined;
952
+ }>>;
953
+ limit: z.ZodOptional<z.ZodNumber>;
954
+ offset: z.ZodOptional<z.ZodNumber>;
955
+ }, "strip", z.ZodTypeAny, {
956
+ id?: number | undefined;
957
+ type?: "query" | "user" | "global" | undefined;
958
+ query?: string | undefined;
959
+ title?: string | undefined;
960
+ category?: string | undefined;
961
+ userId?: string | undefined;
962
+ limit?: number | undefined;
963
+ filters?: {
964
+ type?: "query" | "user" | "global" | undefined;
965
+ query?: string | undefined;
966
+ category?: string | undefined;
967
+ createdBy?: string | undefined;
968
+ tags?: string[] | undefined;
969
+ } | undefined;
970
+ createdBy?: string | undefined;
971
+ updatedBy?: string | undefined;
972
+ offset?: number | undefined;
973
+ tags?: string[] | undefined;
974
+ content?: string | undefined;
975
+ }, {
976
+ id?: number | undefined;
977
+ type?: "query" | "user" | "global" | undefined;
978
+ query?: string | undefined;
979
+ title?: string | undefined;
980
+ category?: string | undefined;
981
+ userId?: string | undefined;
982
+ limit?: number | undefined;
983
+ filters?: {
984
+ type?: "query" | "user" | "global" | undefined;
985
+ query?: string | undefined;
986
+ category?: string | undefined;
987
+ createdBy?: string | undefined;
988
+ tags?: string[] | undefined;
989
+ } | undefined;
990
+ createdBy?: string | undefined;
991
+ updatedBy?: string | undefined;
992
+ offset?: number | undefined;
993
+ tags?: string[] | undefined;
994
+ content?: string | undefined;
995
+ }>>;
996
+ }, "strip", z.ZodTypeAny, {
997
+ operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
998
+ data?: {
999
+ id?: number | undefined;
1000
+ type?: "query" | "user" | "global" | undefined;
1001
+ query?: string | undefined;
1002
+ title?: string | undefined;
1003
+ category?: string | undefined;
1004
+ userId?: string | undefined;
1005
+ limit?: number | undefined;
1006
+ filters?: {
1007
+ type?: "query" | "user" | "global" | undefined;
1008
+ query?: string | undefined;
1009
+ category?: string | undefined;
1010
+ createdBy?: string | undefined;
1011
+ tags?: string[] | undefined;
1012
+ } | undefined;
1013
+ createdBy?: string | undefined;
1014
+ updatedBy?: string | undefined;
1015
+ offset?: number | undefined;
1016
+ tags?: string[] | undefined;
1017
+ content?: string | undefined;
1018
+ } | undefined;
1019
+ }, {
1020
+ operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
1021
+ data?: {
1022
+ id?: number | undefined;
1023
+ type?: "query" | "user" | "global" | undefined;
1024
+ query?: string | undefined;
1025
+ title?: string | undefined;
1026
+ category?: string | undefined;
1027
+ userId?: string | undefined;
1028
+ limit?: number | undefined;
1029
+ filters?: {
1030
+ type?: "query" | "user" | "global" | undefined;
1031
+ query?: string | undefined;
1032
+ category?: string | undefined;
1033
+ createdBy?: string | undefined;
1034
+ tags?: string[] | undefined;
1035
+ } | undefined;
1036
+ createdBy?: string | undefined;
1037
+ updatedBy?: string | undefined;
1038
+ offset?: number | undefined;
1039
+ tags?: string[] | undefined;
1040
+ content?: string | undefined;
1041
+ } | undefined;
1042
+ }>;
1043
+ type KbNodesRequestPayload = z.infer<typeof KbNodesRequestPayloadSchema>;
1044
+ interface T_RESPONSE {
1045
+ success: boolean;
1046
+ data?: any;
1047
+ errors: string[];
585
1048
  }
586
1049
 
587
1050
  /**
@@ -847,6 +1310,7 @@ type SystemPrompt = string | Anthropic.Messages.TextBlockParam[];
847
1310
  interface LLMMessages {
848
1311
  sys: SystemPrompt;
849
1312
  user: string;
1313
+ prefill?: string;
850
1314
  }
851
1315
  interface LLMOptions {
852
1316
  model?: string;
@@ -899,6 +1363,11 @@ declare class LLM {
899
1363
  private static _groqStream;
900
1364
  private static _geminiText;
901
1365
  private static _geminiStream;
1366
+ /**
1367
+ * Recursively strip unsupported JSON Schema properties for Gemini
1368
+ * Gemini doesn't support: additionalProperties, $schema, etc.
1369
+ */
1370
+ private static _cleanSchemaForGemini;
902
1371
  private static _geminiStreamWithTools;
903
1372
  private static _openaiText;
904
1373
  private static _openaiStream;
@@ -1318,15 +1787,17 @@ declare const STORAGE_CONFIG: {
1318
1787
  */
1319
1788
  MAX_ROWS_PER_BLOCK: number;
1320
1789
  /**
1321
- * Maximum size in bytes per UIBlock (1MB)
1790
+ * Maximum size in bytes per UIBlock (500KB - reduced to save memory)
1322
1791
  */
1323
1792
  MAX_SIZE_PER_BLOCK_BYTES: number;
1324
1793
  /**
1325
1794
  * Number of days to keep threads before cleanup
1795
+ * Note: This is for in-memory storage. Conversations are also persisted to database.
1326
1796
  */
1327
1797
  THREAD_RETENTION_DAYS: number;
1328
1798
  /**
1329
1799
  * Number of days to keep UIBlocks before cleanup
1800
+ * Note: This is for in-memory storage. Data is also persisted to database.
1330
1801
  */
1331
1802
  UIBLOCK_RETENTION_DAYS: number;
1332
1803
  };
@@ -1343,14 +1814,941 @@ declare const CONTEXT_CONFIG: {
1343
1814
  MAX_CONVERSATION_CONTEXT_BLOCKS: number;
1344
1815
  };
1345
1816
 
1346
- declare const SDK_VERSION = "0.0.8";
1817
+ /**
1818
+ * LLM Usage Logger - Tracks token usage, costs, and timing for all LLM API calls
1819
+ */
1820
+ interface LLMUsageEntry {
1821
+ timestamp: string;
1822
+ requestId: string;
1823
+ provider: string;
1824
+ model: string;
1825
+ method: string;
1826
+ inputTokens: number;
1827
+ outputTokens: number;
1828
+ cacheReadTokens?: number;
1829
+ cacheWriteTokens?: number;
1830
+ totalTokens: number;
1831
+ costUSD: number;
1832
+ durationMs: number;
1833
+ toolCalls?: number;
1834
+ success: boolean;
1835
+ error?: string;
1836
+ }
1837
+ declare class LLMUsageLogger {
1838
+ private logStream;
1839
+ private logPath;
1840
+ private enabled;
1841
+ private sessionStats;
1842
+ constructor();
1843
+ private initLogStream;
1844
+ private writeHeader;
1845
+ /**
1846
+ * Calculate cost based on token usage and model
1847
+ */
1848
+ calculateCost(model: string, inputTokens: number, outputTokens: number, cacheReadTokens?: number, cacheWriteTokens?: number): number;
1849
+ /**
1850
+ * Log an LLM API call
1851
+ */
1852
+ log(entry: LLMUsageEntry): void;
1853
+ /**
1854
+ * Log session summary (call at end of request)
1855
+ */
1856
+ logSessionSummary(requestContext?: string): void;
1857
+ /**
1858
+ * Reset session stats (call at start of new user request)
1859
+ */
1860
+ resetSession(): void;
1861
+ /**
1862
+ * Reset the log file for a new request (clears previous logs)
1863
+ * Call this at the start of each USER_PROMPT_REQ
1864
+ */
1865
+ resetLogFile(requestContext?: string): void;
1866
+ /**
1867
+ * Get current session stats
1868
+ */
1869
+ getSessionStats(): {
1870
+ totalCalls: number;
1871
+ totalInputTokens: number;
1872
+ totalOutputTokens: number;
1873
+ totalCacheReadTokens: number;
1874
+ totalCacheWriteTokens: number;
1875
+ totalCostUSD: number;
1876
+ totalDurationMs: number;
1877
+ };
1878
+ /**
1879
+ * Generate a unique request ID
1880
+ */
1881
+ generateRequestId(): string;
1882
+ }
1883
+ declare const llmUsageLogger: LLMUsageLogger;
1884
+
1885
+ /**
1886
+ * User Prompt Error Logger - Captures detailed errors for USER_PROMPT_REQ
1887
+ * Logs full error details including raw strings for parse failures
1888
+ */
1889
+ declare class UserPromptErrorLogger {
1890
+ private logStream;
1891
+ private logPath;
1892
+ private enabled;
1893
+ private hasErrors;
1894
+ constructor();
1895
+ /**
1896
+ * Reset the error log file for a new request
1897
+ */
1898
+ resetLogFile(requestContext?: string): void;
1899
+ /**
1900
+ * Log a JSON parse error with the raw string that failed
1901
+ */
1902
+ logJsonParseError(context: string, rawString: string, error: Error): void;
1903
+ /**
1904
+ * Log a general error with full details
1905
+ */
1906
+ logError(context: string, error: Error | string, additionalData?: Record<string, any>): void;
1907
+ /**
1908
+ * Log a SQL query error with the full query
1909
+ */
1910
+ logSqlError(query: string, error: Error | string, params?: any[]): void;
1911
+ /**
1912
+ * Log an LLM API error
1913
+ */
1914
+ logLlmError(provider: string, model: string, method: string, error: Error | string, requestData?: any): void;
1915
+ /**
1916
+ * Log tool execution error
1917
+ */
1918
+ logToolError(toolName: string, toolInput: any, error: Error | string): void;
1919
+ /**
1920
+ * Write final summary if there were errors
1921
+ */
1922
+ writeSummary(): void;
1923
+ /**
1924
+ * Check if any errors were logged
1925
+ */
1926
+ hadErrors(): boolean;
1927
+ private write;
1928
+ }
1929
+ declare const userPromptErrorLogger: UserPromptErrorLogger;
1930
+
1931
+ /**
1932
+ * BM25L Reranker for hybrid semantic search
1933
+ *
1934
+ * BM25L is an improved variant of BM25 that provides better handling of
1935
+ * long documents and term frequency saturation. This implementation is
1936
+ * designed to rerank semantic search results from ChromaDB.
1937
+ *
1938
+ * The hybrid approach combines:
1939
+ * 1. Semantic similarity from ChromaDB embeddings (dense vectors)
1940
+ * 2. Lexical matching from BM25L (sparse, keyword-based)
1941
+ *
1942
+ * This addresses the weakness of pure semantic search which may miss
1943
+ * exact keyword matches that are important for user intent.
1944
+ */
1945
+ interface BM25LOptions {
1946
+ /** Term frequency saturation parameter (default: 1.5) */
1947
+ k1?: number;
1948
+ /** Length normalization parameter (default: 0.75) */
1949
+ b?: number;
1950
+ /** Lower-bound adjustment from BM25L paper (default: 0.5) */
1951
+ delta?: number;
1952
+ }
1953
+ interface RerankedResult<T> {
1954
+ item: T;
1955
+ originalIndex: number;
1956
+ semanticScore: number;
1957
+ bm25Score: number;
1958
+ hybridScore: number;
1959
+ }
1960
+ interface HybridSearchOptions extends BM25LOptions {
1961
+ /** Weight for semantic score (0-1, default: 0.7) */
1962
+ semanticWeight?: number;
1963
+ /** Weight for BM25 score (0-1, default: 0.3) */
1964
+ bm25Weight?: number;
1965
+ /** Minimum hybrid score threshold (0-1, default: 0) */
1966
+ minScore?: number;
1967
+ }
1968
+ /**
1969
+ * BM25L implementation for lexical scoring
1970
+ */
1971
+ declare class BM25L {
1972
+ private k1;
1973
+ private b;
1974
+ private delta;
1975
+ private documents;
1976
+ private docLengths;
1977
+ private avgDocLength;
1978
+ private termDocFreq;
1979
+ /**
1980
+ * @param documents - Array of raw documents (strings)
1981
+ * @param opts - Optional BM25L parameters
1982
+ */
1983
+ constructor(documents?: string[], opts?: BM25LOptions);
1984
+ /**
1985
+ * Tokenize text into lowercase alphanumeric tokens
1986
+ */
1987
+ tokenize(text: string): string[];
1988
+ /**
1989
+ * Compute IDF (Inverse Document Frequency) with smoothing
1990
+ */
1991
+ private idf;
1992
+ /**
1993
+ * Compute BM25L score for a single document
1994
+ */
1995
+ score(query: string, docIndex: number): number;
1996
+ /**
1997
+ * Search and rank all documents
1998
+ */
1999
+ search(query: string): Array<{
2000
+ index: number;
2001
+ score: number;
2002
+ }>;
2003
+ }
2004
+ /**
2005
+ * Hybrid reranker that combines semantic and BM25L scores
2006
+ *
2007
+ * @param query - The search query
2008
+ * @param items - Array of items to rerank
2009
+ * @param getDocument - Function to extract document text from an item
2010
+ * @param getSemanticScore - Function to extract semantic similarity score from an item
2011
+ * @param options - Hybrid search options
2012
+ * @returns Reranked items with hybrid scores
2013
+ */
2014
+ declare function hybridRerank<T>(query: string, items: T[], getDocument: (item: T) => string, getSemanticScore: (item: T) => number, options?: HybridSearchOptions): RerankedResult<T>[];
2015
+ /**
2016
+ * Simple reranking function for ChromaDB results
2017
+ *
2018
+ * This is a convenience wrapper for reranking ChromaDB query results
2019
+ * that follow the standard { ids, documents, metadatas, distances } format.
2020
+ *
2021
+ * @param query - The search query
2022
+ * @param chromaResults - ChromaDB query results
2023
+ * @param options - Hybrid search options
2024
+ * @returns Reranked results with hybrid scores
2025
+ */
2026
+ declare function rerankChromaResults(query: string, chromaResults: {
2027
+ ids: string[][];
2028
+ documents: (string | null)[][];
2029
+ metadatas: Record<string, any>[][];
2030
+ distances: number[][];
2031
+ }, options?: HybridSearchOptions): Array<{
2032
+ id: string;
2033
+ document: string | null;
2034
+ metadata: Record<string, any>;
2035
+ distance: number;
2036
+ semanticScore: number;
2037
+ bm25Score: number;
2038
+ hybridScore: number;
2039
+ }>;
2040
+ /**
2041
+ * Rerank conversation search results specifically
2042
+ *
2043
+ * This function is designed to work with the conversation-history.search collection
2044
+ * where we need to fetch more results initially and then rerank them.
2045
+ *
2046
+ * @param query - The user's search query
2047
+ * @param results - Array of conversation search results from ChromaDB
2048
+ * @param options - Hybrid search options
2049
+ * @returns Reranked results sorted by hybrid score
2050
+ */
2051
+ declare function rerankConversationResults<T extends {
2052
+ userPrompt?: string;
2053
+ similarity?: number;
2054
+ }>(query: string, results: T[], options?: HybridSearchOptions): Array<T & {
2055
+ hybridScore: number;
2056
+ bm25Score: number;
2057
+ }>;
2058
+
2059
+ /**
2060
+ * QueryExecutionService - Handles all query execution, validation, and retry logic
2061
+ * Extracted from BaseLLM for better separation of concerns
2062
+ */
2063
+
2064
+ /**
2065
+ * Context for component when requesting query fix
2066
+ */
2067
+ interface ComponentContext {
2068
+ name: string;
2069
+ type: string;
2070
+ title?: string;
2071
+ }
2072
+ /**
2073
+ * Result of query validation
2074
+ */
2075
+ interface QueryValidationResult {
2076
+ component: Component | null;
2077
+ queryKey: string;
2078
+ result: any;
2079
+ validated: boolean;
2080
+ }
2081
+ /**
2082
+ * Result of batch query validation
2083
+ */
2084
+ interface BatchValidationResult {
2085
+ components: Component[];
2086
+ queryResults: Map<string, any>;
2087
+ }
2088
+ /**
2089
+ * Configuration for QueryExecutionService
2090
+ */
2091
+ interface QueryExecutionServiceConfig {
2092
+ defaultLimit: number;
2093
+ getModelForTask: (taskType: 'simple' | 'complex') => string;
2094
+ getApiKey: (apiKey?: string) => string | undefined;
2095
+ providerName: string;
2096
+ }
2097
+ /**
2098
+ * QueryExecutionService handles all query-related operations
2099
+ */
2100
+ declare class QueryExecutionService {
2101
+ private config;
2102
+ constructor(config: QueryExecutionServiceConfig);
2103
+ /**
2104
+ * Get the cache key for a query
2105
+ * This ensures the cache key matches what the frontend will send
2106
+ */
2107
+ getQueryCacheKey(query: any): string;
2108
+ /**
2109
+ * Execute a query against the database
2110
+ * @param query - The SQL query to execute (string or object with sql/values)
2111
+ * @param collections - Collections object containing database execute function
2112
+ * @returns Object with result data and cache key
2113
+ */
2114
+ executeQuery(query: any, collections: any): Promise<{
2115
+ result: any;
2116
+ cacheKey: string;
2117
+ }>;
2118
+ /**
2119
+ * Request the LLM to fix a failed SQL query
2120
+ * @param failedQuery - The query that failed execution
2121
+ * @param errorMessage - The error message from the failed execution
2122
+ * @param componentContext - Context about the component
2123
+ * @param apiKey - Optional API key
2124
+ * @returns Fixed query string
2125
+ */
2126
+ requestQueryFix(failedQuery: string, errorMessage: string, componentContext: ComponentContext, apiKey?: string): Promise<string>;
2127
+ /**
2128
+ * Validate a single component's query with retry logic
2129
+ * @param component - The component to validate
2130
+ * @param collections - Collections object containing database execute function
2131
+ * @param apiKey - Optional API key for LLM calls
2132
+ * @returns Validation result with component, query key, and result
2133
+ */
2134
+ validateSingleQuery(component: Component, collections: any, apiKey?: string): Promise<QueryValidationResult>;
2135
+ /**
2136
+ * Validate multiple component queries in parallel
2137
+ * @param components - Array of components with potential queries
2138
+ * @param collections - Collections object containing database execute function
2139
+ * @param apiKey - Optional API key for LLM calls
2140
+ * @returns Object with validated components and query results map
2141
+ */
2142
+ validateComponentQueries(components: Component[], collections: any, apiKey?: string): Promise<BatchValidationResult>;
2143
+ }
2144
+
2145
+ /**
2146
+ * StreamBuffer - Buffered streaming utility for smoother text delivery
2147
+ * Batches small chunks together and flushes at regular intervals
2148
+ */
2149
+ type StreamCallback = (chunk: string) => void;
2150
+ /**
2151
+ * StreamBuffer class for managing buffered streaming output
2152
+ * Provides smooth text delivery by batching small chunks
2153
+ */
2154
+ declare class StreamBuffer {
2155
+ private buffer;
2156
+ private flushTimer;
2157
+ private callback;
2158
+ private fullText;
2159
+ constructor(callback?: StreamCallback);
2160
+ /**
2161
+ * Check if the buffer has a callback configured
2162
+ */
2163
+ hasCallback(): boolean;
2164
+ /**
2165
+ * Get all text that has been written (including already flushed)
2166
+ */
2167
+ getFullText(): string;
2168
+ /**
2169
+ * Write a chunk to the buffer
2170
+ * Large chunks or chunks with newlines are flushed immediately
2171
+ * Small chunks are batched and flushed after a short interval
2172
+ *
2173
+ * @param chunk - Text chunk to write
2174
+ */
2175
+ write(chunk: string): void;
2176
+ /**
2177
+ * Flush the buffer immediately
2178
+ * Call this before tool execution or other operations that need clean output
2179
+ */
2180
+ flush(): void;
2181
+ /**
2182
+ * Internal flush implementation
2183
+ */
2184
+ private flushNow;
2185
+ /**
2186
+ * Clean up resources
2187
+ * Call this when done with the buffer
2188
+ */
2189
+ dispose(): void;
2190
+ }
2191
+
2192
+ /**
2193
+ * ToolExecutorService - Handles execution of SQL queries and external tools
2194
+ * Extracted from BaseLLM.generateTextResponse for better separation of concerns
2195
+ */
2196
+
2197
+ /**
2198
+ * External tool definition
2199
+ */
2200
+ interface ExternalTool {
2201
+ id: string;
2202
+ name: string;
2203
+ description?: string;
2204
+ /** Tool type: "source" = routed through SourceAgent, "direct" = called directly by MainAgent */
2205
+ toolType?: 'source' | 'direct';
2206
+ /** Full untruncated schema for source agent (all columns visible) */
2207
+ fullSchema?: string;
2208
+ /** Schema size tier: small (≤50 tables), medium (51-200), large (201-500), very_large (500+) */
2209
+ schemaTier?: string;
2210
+ /** Schema search function for very_large tier — keyword search over entities */
2211
+ schemaSearchFn?: (keywords: string[]) => string;
2212
+ fn: (input: any) => Promise<any>;
2213
+ limit?: number;
2214
+ outputSchema?: any;
2215
+ executionType?: 'immediate' | 'deferred';
2216
+ userProvidedData?: any;
2217
+ params?: Record<string, any>;
2218
+ }
2219
+ /**
2220
+ * Executed tool tracking info
2221
+ */
2222
+ interface ExecutedToolInfo {
2223
+ id: string;
2224
+ name: string;
2225
+ params: any;
2226
+ result: {
2227
+ _totalRecords: number;
2228
+ _recordsShown: number;
2229
+ _metadata?: any;
2230
+ _sampleData: any[];
2231
+ };
2232
+ outputSchema?: any;
2233
+ sourceSchema?: string;
2234
+ sourceType?: string;
2235
+ }
2236
+
2237
+ /**
2238
+ * Task types for model selection
2239
+ * - 'complex': Text generation, component matching, parameter adaptation (uses best model in balanced mode)
2240
+ * - 'simple': Classification, action generation (uses fast model in balanced mode)
2241
+ */
2242
+ type TaskType = 'complex' | 'simple';
2243
+ interface BaseLLMConfig {
2244
+ model?: string;
2245
+ fastModel?: string;
2246
+ defaultLimit?: number;
2247
+ apiKey?: string;
2248
+ /**
2249
+ * Model selection strategy:
2250
+ * - 'best': Use best model for all tasks (highest quality, higher cost)
2251
+ * - 'fast': Use fast model for all tasks (lower quality, lower cost)
2252
+ * - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
2253
+ */
2254
+ modelStrategy?: ModelStrategy;
2255
+ conversationSimilarityThreshold?: number;
2256
+ }
2257
+ /**
2258
+ * BaseLLM abstract class for AI-powered component generation and matching
2259
+ * Provides common functionality for all LLM providers
2260
+ */
2261
+ declare abstract class BaseLLM {
2262
+ protected model: string;
2263
+ protected fastModel: string;
2264
+ protected defaultLimit: number;
2265
+ protected apiKey?: string;
2266
+ protected modelStrategy: ModelStrategy;
2267
+ protected conversationSimilarityThreshold: number;
2268
+ protected queryService: QueryExecutionService;
2269
+ constructor(config?: BaseLLMConfig);
2270
+ /**
2271
+ * Get the appropriate model based on task type and model strategy
2272
+ * @param taskType - 'complex' for text generation/matching, 'simple' for classification/actions
2273
+ * @returns The model string to use for this task
2274
+ */
2275
+ protected getModelForTask(taskType: TaskType): string;
2276
+ /**
2277
+ * Set the model strategy at runtime
2278
+ * @param strategy - 'best', 'fast', or 'balanced'
2279
+ */
2280
+ setModelStrategy(strategy: ModelStrategy): void;
2281
+ /**
2282
+ * Get the current model strategy
2283
+ * @returns The current model strategy
2284
+ */
2285
+ getModelStrategy(): ModelStrategy;
2286
+ /**
2287
+ * Set the conversation similarity threshold at runtime
2288
+ * @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
2289
+ */
2290
+ setConversationSimilarityThreshold(threshold: number): void;
2291
+ /**
2292
+ * Get the current conversation similarity threshold
2293
+ * @returns The current threshold value
2294
+ */
2295
+ getConversationSimilarityThreshold(): number;
2296
+ /**
2297
+ * Get the default model for this provider (used for complex tasks like text generation)
2298
+ */
2299
+ protected abstract getDefaultModel(): string;
2300
+ /**
2301
+ * Get the default fast model for this provider (used for simple tasks: classification, matching, actions)
2302
+ * Should return a cheaper/faster model like Haiku for Anthropic
2303
+ */
2304
+ protected abstract getDefaultFastModel(): string;
2305
+ /**
2306
+ * Get the default API key from environment
2307
+ */
2308
+ protected abstract getDefaultApiKey(): string | undefined;
2309
+ /**
2310
+ * Get the provider name (for logging)
2311
+ */
2312
+ protected abstract getProviderName(): string;
2313
+ /**
2314
+ * Get the API key (from instance, parameter, or environment)
2315
+ */
2316
+ protected getApiKey(apiKey?: string): string | undefined;
2317
+ /**
2318
+ * Check if a component contains a Form (data_modification component)
2319
+ * Forms have hardcoded defaultValues that become stale when cached
2320
+ * This checks both single Form components and Forms inside MultiComponentContainer
2321
+ */
2322
+ protected containsFormComponent(component: any): boolean;
2323
+ /**
2324
+ * Match components from text response suggestions and generate follow-up questions
2325
+ * Takes a text response with component suggestions (c1:type format) and matches with available components
2326
+ * Also generates title, description, and intelligent follow-up questions (actions) based on the analysis
2327
+ * All components are placed in a default MultiComponentContainer layout
2328
+ * @param analysisContent - The text response containing component suggestions
2329
+ * @param components - List of available components
2330
+ * @param apiKey - Optional API key
2331
+ * @param componentStreamCallback - Optional callback to stream primary KPI component as soon as it's identified
2332
+ * @returns Object containing matched components, layout title/description, and follow-up actions
2333
+ */
2334
+ matchComponentsFromAnalysis(analysisContent: string, components: Component[], userPrompt: string, apiKey?: string, componentStreamCallback?: (component: Component) => void, deferredTools?: any[], executedTools?: any[], collections?: any, userId?: string): Promise<{
2335
+ components: Component[];
2336
+ layoutTitle: string;
2337
+ layoutDescription: string;
2338
+ actions: Action[];
2339
+ }>;
2340
+ /**
2341
+ * Classify user question into category and detect external tools needed
2342
+ * Determines if question is for data analysis, requires external tools, or needs text response
2343
+ */
2344
+ classifyQuestionCategory(userPrompt: string, apiKey?: string, conversationHistory?: string, externalTools?: any[]): Promise<{
2345
+ category: 'data_analysis' | 'data_modification' | 'general';
2346
+ externalTools: Array<{
2347
+ type: string;
2348
+ name: string;
2349
+ description: string;
2350
+ parameters: Record<string, any>;
2351
+ }>;
2352
+ dataAnalysisType?: 'visualization' | 'calculation' | 'comparison' | 'trend';
2353
+ reasoning: string;
2354
+ confidence: number;
2355
+ }>;
2356
+ /**
2357
+ * Adapt UI block parameters based on current user question
2358
+ * Takes a matched UI block from semantic search and modifies its props to answer the new question
2359
+ * Also adapts the cached text response to match the new question
2360
+ */
2361
+ adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, cachedTextResponse?: string): Promise<{
2362
+ success: boolean;
2363
+ adaptedComponent?: Component;
2364
+ adaptedTextResponse?: string;
2365
+ parametersChanged?: Array<{
2366
+ field: string;
2367
+ reason: string;
2368
+ }>;
2369
+ explanation: string;
2370
+ }>;
2371
+ /**
2372
+ * Generate text-based response for user question
2373
+ * This provides conversational text responses instead of component generation
2374
+ * Supports tool calling for query execution with automatic retry on errors (max 3 attempts)
2375
+ * After generating text response, if components are provided, matches suggested components
2376
+ */
2377
+ 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>;
2378
+ /**
2379
+ * Main orchestration function with semantic search and multi-step classification
2380
+ * NEW FLOW (Recommended):
2381
+ * 1. Semantic search: Check previous conversations (>60% match)
2382
+ * - If match found → Adapt UI block parameters and return
2383
+ * 2. Category classification: Determine if data_analysis, requires_external_tools, or text_response
2384
+ * 3. Route appropriately based on category and response mode
2385
+ */
2386
+ 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>;
2387
+ /**
2388
+ * Generate next questions that the user might ask based on the original prompt and generated component
2389
+ * This helps provide intelligent suggestions for follow-up queries
2390
+ * For general/conversational questions without components, pass textResponse instead
2391
+ */
2392
+ generateNextQuestions(originalUserPrompt: string, component?: Component | null, componentData?: Record<string, unknown>, apiKey?: string, conversationHistory?: string, textResponse?: string): Promise<string[]>;
2393
+ }
2394
+
2395
+ interface AnthropicLLMConfig extends BaseLLMConfig {
2396
+ }
2397
+ /**
2398
+ * AnthropicLLM class for handling AI-powered component generation and matching using Anthropic Claude
2399
+ */
2400
+ declare class AnthropicLLM extends BaseLLM {
2401
+ constructor(config?: AnthropicLLMConfig);
2402
+ protected getDefaultModel(): string;
2403
+ protected getDefaultFastModel(): string;
2404
+ protected getDefaultApiKey(): string | undefined;
2405
+ protected getProviderName(): string;
2406
+ }
2407
+ declare const anthropicLLM: AnthropicLLM;
2408
+
2409
+ interface GroqLLMConfig extends BaseLLMConfig {
2410
+ }
2411
+ /**
2412
+ * GroqLLM class for handling AI-powered component generation and matching using Groq
2413
+ */
2414
+ declare class GroqLLM extends BaseLLM {
2415
+ constructor(config?: GroqLLMConfig);
2416
+ protected getDefaultModel(): string;
2417
+ protected getDefaultFastModel(): string;
2418
+ protected getDefaultApiKey(): string | undefined;
2419
+ protected getProviderName(): string;
2420
+ }
2421
+ declare const groqLLM: GroqLLM;
2422
+
2423
+ interface GeminiLLMConfig extends BaseLLMConfig {
2424
+ }
2425
+ /**
2426
+ * GeminiLLM class for handling AI-powered component generation and matching using Google Gemini
2427
+ */
2428
+ declare class GeminiLLM extends BaseLLM {
2429
+ constructor(config?: GeminiLLMConfig);
2430
+ protected getDefaultModel(): string;
2431
+ protected getDefaultFastModel(): string;
2432
+ protected getDefaultApiKey(): string | undefined;
2433
+ protected getProviderName(): string;
2434
+ }
2435
+ declare const geminiLLM: GeminiLLM;
2436
+
2437
+ interface OpenAILLMConfig extends BaseLLMConfig {
2438
+ }
2439
+ /**
2440
+ * OpenAILLM class for handling AI-powered component generation and matching using OpenAI GPT models
2441
+ */
2442
+ declare class OpenAILLM extends BaseLLM {
2443
+ constructor(config?: OpenAILLMConfig);
2444
+ protected getDefaultModel(): string;
2445
+ protected getDefaultFastModel(): string;
2446
+ protected getDefaultApiKey(): string | undefined;
2447
+ protected getProviderName(): string;
2448
+ }
2449
+ declare const openaiLLM: OpenAILLM;
2450
+
2451
+ /**
2452
+ * Query Cache - Stores query results with configurable TTL
2453
+ * Used to avoid re-executing queries that were already validated
2454
+ */
2455
+ declare class QueryCache {
2456
+ private cache;
2457
+ private queryIdCache;
2458
+ private ttlMs;
2459
+ private cleanupInterval;
2460
+ constructor();
2461
+ /**
2462
+ * Set the cache TTL (Time To Live)
2463
+ * @param minutes - TTL in minutes (default: 5)
2464
+ */
2465
+ setTTL(minutes: number): void;
2466
+ /**
2467
+ * Get the current TTL in minutes
2468
+ */
2469
+ getTTL(): number;
2470
+ /**
2471
+ * Store query result in cache
2472
+ * Key is the exact query string (or JSON for parameterized queries)
2473
+ */
2474
+ set(query: string, data: any): void;
2475
+ /**
2476
+ * Get cached result if exists and not expired
2477
+ */
2478
+ get(query: string): any | null;
2479
+ /**
2480
+ * Check if query exists in cache (not expired)
2481
+ */
2482
+ has(query: string): boolean;
2483
+ /**
2484
+ * Remove a specific query from cache
2485
+ */
2486
+ delete(query: string): void;
2487
+ /**
2488
+ * Clear all cached entries
2489
+ */
2490
+ clear(): void;
2491
+ /**
2492
+ * Get cache statistics
2493
+ */
2494
+ getStats(): {
2495
+ size: number;
2496
+ oldestEntryAge: number | null;
2497
+ };
2498
+ /**
2499
+ * Start periodic cleanup of expired entries
2500
+ */
2501
+ private startCleanup;
2502
+ /**
2503
+ * Generate a unique query ID
2504
+ */
2505
+ private generateQueryId;
2506
+ /**
2507
+ * Store a query by ID. Returns the generated queryId.
2508
+ * The query is stored server-side; only the queryId is sent to the frontend.
2509
+ */
2510
+ storeQuery(query: any, data?: any): string;
2511
+ /**
2512
+ * Get a stored query by its ID (not expired)
2513
+ */
2514
+ getQuery(queryId: string): {
2515
+ query: any;
2516
+ data: any;
2517
+ } | null;
2518
+ /**
2519
+ * Update cached data for a queryId
2520
+ */
2521
+ setQueryData(queryId: string, data: any): void;
2522
+ /**
2523
+ * Stop cleanup interval (for graceful shutdown)
2524
+ */
2525
+ destroy(): void;
2526
+ }
2527
+ declare const queryCache: QueryCache;
2528
+
2529
+ /**
2530
+ * Manages conversation history scoped per user + dashboard.
2531
+ * Each user-dashboard pair has its own isolated history that expires after a configurable TTL.
2532
+ */
2533
+ declare class DashboardConversationHistory {
2534
+ private histories;
2535
+ private ttlMs;
2536
+ private maxEntries;
2537
+ private cleanupInterval;
2538
+ constructor();
2539
+ /**
2540
+ * Set the TTL for dashboard histories
2541
+ * @param minutes - TTL in minutes
2542
+ */
2543
+ setTTL(minutes: number): void;
2544
+ /**
2545
+ * Set max entries per dashboard
2546
+ */
2547
+ setMaxEntries(max: number): void;
2548
+ /**
2549
+ * Add a conversation entry for a user's dashboard
2550
+ */
2551
+ addEntry(dashboardId: string, userPrompt: string, componentSummary: string, userId?: string): void;
2552
+ /**
2553
+ * Get formatted conversation history for a user's dashboard
2554
+ */
2555
+ getHistory(dashboardId: string, userId?: string): string;
2556
+ /**
2557
+ * Clear history for a specific user's dashboard
2558
+ */
2559
+ clearDashboard(dashboardId: string, userId?: string): void;
2560
+ /**
2561
+ * Clear all dashboard histories
2562
+ */
2563
+ clearAll(): void;
2564
+ /**
2565
+ * Start periodic cleanup of expired histories
2566
+ */
2567
+ private startCleanup;
2568
+ /**
2569
+ * Stop cleanup interval (for graceful shutdown)
2570
+ */
2571
+ destroy(): void;
2572
+ }
2573
+ declare const dashboardConversationHistory: DashboardConversationHistory;
2574
+
2575
+ /**
2576
+ * Multi-Agent Architecture Types
2577
+ *
2578
+ * Defines interfaces for the hierarchical agent system:
2579
+ * - Main Agent: ONE LLM.streamWithTools() call with source agent tools
2580
+ * - Source Agents: independent agents that query individual data sources
2581
+ *
2582
+ * The main agent sees only source summaries. When it calls a source tool,
2583
+ * the SourceAgent runs independently (own LLM, own retries) and returns clean data.
2584
+ */
2585
+
2586
+ /**
2587
+ * Per-entity detail: name, row count, and column names.
2588
+ * Gives the main agent enough context to route to the right source.
2589
+ */
2590
+ interface EntityDetail {
2591
+ /** Entity name (table, sheet, endpoint) */
2592
+ name: string;
2593
+ /** Approximate row count */
2594
+ rowCount?: number;
2595
+ /** Column/field names */
2596
+ columns: string[];
2597
+ }
2598
+ /**
2599
+ * Representation of a data source for the main agent.
2600
+ * Contains entity names WITH column names so the LLM can route accurately.
2601
+ */
2602
+ interface SourceSummary {
2603
+ /** Source ID (matches tool ID prefix) */
2604
+ id: string;
2605
+ /** Human-readable source name */
2606
+ name: string;
2607
+ /** Source type: postgres, excel, rest_api, etc. */
2608
+ type: string;
2609
+ /** Brief description of what data this source contains */
2610
+ description: string;
2611
+ /** Detailed entity info with column names for routing */
2612
+ entityDetails: EntityDetail[];
2613
+ /** The tool ID associated with this source */
2614
+ toolId: string;
2615
+ }
2616
+ /**
2617
+ * What a source agent returns after querying its data source.
2618
+ * The main agent uses this to analyze and compose the final response.
2619
+ */
2620
+ interface SourceAgentResult {
2621
+ /** Source ID */
2622
+ sourceId: string;
2623
+ /** Source name */
2624
+ sourceName: string;
2625
+ /** Whether the query succeeded */
2626
+ success: boolean;
2627
+ /** Result data rows */
2628
+ data: any[];
2629
+ /** Metadata about the query execution */
2630
+ metadata: SourceAgentMetadata;
2631
+ /** Tool execution info (reused for component generation) */
2632
+ executedTool: ExecutedToolInfo;
2633
+ /** Error message if failed */
2634
+ error?: string;
2635
+ }
2636
+ interface SourceAgentMetadata {
2637
+ /** Total rows that matched the query (before limit) */
2638
+ totalRowsMatched: number;
2639
+ /** Rows actually returned (after limit) */
2640
+ rowsReturned: number;
2641
+ /** Whether the result was truncated by the row limit */
2642
+ isLimited: boolean;
2643
+ /** The query/params that were executed */
2644
+ queryExecuted?: string;
2645
+ /** Execution time in milliseconds */
2646
+ executionTimeMs: number;
2647
+ }
2648
+ /**
2649
+ * The complete response from the multi-agent system.
2650
+ * Contains everything needed for text display + component generation.
2651
+ */
2652
+ interface AgentResponse {
2653
+ /** Generated text response (analysis of the data) */
2654
+ text: string;
2655
+ /** All executed tools across all source agents (for component generation) */
2656
+ executedTools: ExecutedToolInfo[];
2657
+ /** Individual results from each source agent */
2658
+ sourceResults: SourceAgentResult[];
2659
+ }
2660
+ /**
2661
+ * Configuration for the multi-agent system.
2662
+ * Controls limits, models, and behavior.
2663
+ */
2664
+ interface AgentConfig {
2665
+ /** Max rows a source agent can return (default: 50) */
2666
+ maxRowsPerSource: number;
2667
+ /** Model for the main agent (routing + analysis in one LLM call) */
2668
+ mainAgentModel: string;
2669
+ /** Model for source agent query generation */
2670
+ sourceAgentModel: string;
2671
+ /** API key for LLM calls */
2672
+ apiKey?: string;
2673
+ /** Max retry attempts per source agent */
2674
+ maxRetries: number;
2675
+ /** Max tool calling iterations for the main agent loop */
2676
+ maxIterations: number;
2677
+ /** Global knowledge base context (static, same for all users/questions — cached in system prompt) */
2678
+ globalKnowledgeBase?: string;
2679
+ /** Per-request knowledge base context (user-specific + query-matched — dynamic, not cached) */
2680
+ knowledgeBaseContext?: string;
2681
+ }
2682
+ /**
2683
+ * Default agent configuration
2684
+ */
2685
+ declare const DEFAULT_AGENT_CONFIG: AgentConfig;
2686
+
2687
+ /**
2688
+ * Main Agent (Orchestrator)
2689
+ *
2690
+ * A single LLM.streamWithTools() call that handles everything:
2691
+ * - Routing: decides which source(s) to query based on summaries
2692
+ * - Querying: calls source tools (each wraps an independent SourceAgent)
2693
+ * - Direct tools: calls pre-built function tools directly with LLM-provided params
2694
+ * - Re-querying: if data is wrong/incomplete, calls tools again with modified intent
2695
+ * - Analysis: generates final text response from the data
2696
+ *
2697
+ * Two tool types:
2698
+ * - "source" tools: main agent sees summaries, SourceAgent handles SQL generation independently
2699
+ * - "direct" tools: main agent calls fn() directly with structured params (no SourceAgent)
2700
+ */
2701
+
2702
+ declare class MainAgent {
2703
+ private externalTools;
2704
+ private config;
2705
+ private streamBuffer;
2706
+ constructor(externalTools: ExternalTool[], config: AgentConfig, streamBuffer?: StreamBuffer);
2707
+ /**
2708
+ * Handle a user question using the multi-agent system.
2709
+ *
2710
+ * This is ONE LLM.streamWithTools() call. The LLM:
2711
+ * 1. Sees source summaries + direct tool descriptions in system prompt
2712
+ * 2. Decides which tool(s) to call (routing)
2713
+ * 3. Source tools → SourceAgent runs independently → returns data
2714
+ * 4. Direct tools → fn() called directly with LLM params → returns data
2715
+ * 5. Generates final analysis text
2716
+ */
2717
+ handleQuestion(userPrompt: string, apiKey?: string, conversationHistory?: string, streamCallback?: (chunk: string) => void): Promise<AgentResponse>;
2718
+ /**
2719
+ * Execute a direct tool — call fn() with LLM-provided params, no SourceAgent.
2720
+ */
2721
+ private handleDirectTool;
2722
+ /**
2723
+ * Build the main agent's system prompt with source summaries and direct tool descriptions.
2724
+ */
2725
+ private buildSystemPrompt;
2726
+ /**
2727
+ * Build tool definitions for source tools — summary-only descriptions.
2728
+ * The full schema is inside the SourceAgent which runs independently.
2729
+ */
2730
+ private buildSourceToolDefinitions;
2731
+ /**
2732
+ * Build tool definitions for direct tools — expose their actual params.
2733
+ * These are called directly by the main agent LLM, no SourceAgent.
2734
+ */
2735
+ private buildDirectToolDefinitions;
2736
+ /**
2737
+ * Format a source agent's result as a clean string for the main agent LLM.
2738
+ */
2739
+ private formatResultForMainAgent;
2740
+ /**
2741
+ * Get source summaries (for external inspection/debugging).
2742
+ */
2743
+ getSourceSummaries(): SourceSummary[];
2744
+ }
2745
+
1347
2746
  type MessageTypeHandler = (message: IncomingMessage) => void | Promise<void>;
1348
2747
  declare class SuperatomSDK {
1349
2748
  private ws;
1350
2749
  private url;
1351
2750
  private apiKey?;
1352
2751
  private projectId;
1353
- private userId;
1354
2752
  private type;
1355
2753
  private bundleDir;
1356
2754
  private messageHandlers;
@@ -1366,9 +2764,18 @@ declare class SuperatomSDK {
1366
2764
  private geminiApiKey;
1367
2765
  private openaiApiKey;
1368
2766
  private llmProviders;
2767
+ private databaseType;
2768
+ private modelStrategy;
2769
+ private mainAgentModel;
2770
+ private sourceAgentModel;
2771
+ private conversationSimilarityThreshold;
1369
2772
  private userManager;
1370
2773
  private dashboardManager;
1371
2774
  private reportManager;
2775
+ private pingInterval;
2776
+ private lastPong;
2777
+ private readonly PING_INTERVAL_MS;
2778
+ private readonly PONG_TIMEOUT_MS;
1372
2779
  constructor(config: SuperatomSDKConfig);
1373
2780
  /**
1374
2781
  * Initialize PromptLoader and load prompts into memory
@@ -1408,9 +2815,11 @@ declare class SuperatomSDK {
1408
2815
  */
1409
2816
  private handleMessage;
1410
2817
  /**
1411
- * Send a message to the Superatom service
2818
+ * Send a message to the Superatom service.
2819
+ * Returns true if the message was sent, false if the WebSocket is not connected.
2820
+ * Does NOT throw on closed connections — callers can check the return value if needed.
1412
2821
  */
1413
- send(message: Message): void;
2822
+ send(message: Message): boolean;
1414
2823
  /**
1415
2824
  * Register a message handler to receive all messages
1416
2825
  */
@@ -1436,6 +2845,19 @@ declare class SuperatomSDK {
1436
2845
  */
1437
2846
  addCollection<TParams = any, TResult = any>(collectionName: string, operation: CollectionOperation | string, handler: CollectionHandler<TParams, TResult>): void;
1438
2847
  private handleReconnect;
2848
+ /**
2849
+ * Start heartbeat to keep WebSocket connection alive
2850
+ * Sends PING every 3 minutes to prevent idle timeout from cloud infrastructure
2851
+ */
2852
+ private startHeartbeat;
2853
+ /**
2854
+ * Stop the heartbeat interval
2855
+ */
2856
+ private stopHeartbeat;
2857
+ /**
2858
+ * Handle PONG response from server
2859
+ */
2860
+ private handlePong;
1439
2861
  private storeComponents;
1440
2862
  /**
1441
2863
  * Set tools for the SDK instance
@@ -1445,6 +2867,34 @@ declare class SuperatomSDK {
1445
2867
  * Get the stored tools
1446
2868
  */
1447
2869
  getTools(): Tool$1[];
2870
+ /**
2871
+ * Apply model strategy to all LLM provider singletons
2872
+ * @param strategy - 'best', 'fast', or 'balanced'
2873
+ */
2874
+ private applyModelStrategy;
2875
+ /**
2876
+ * Set model strategy at runtime
2877
+ * @param strategy - 'best', 'fast', or 'balanced'
2878
+ */
2879
+ setModelStrategy(strategy: ModelStrategy): void;
2880
+ /**
2881
+ * Get current model strategy
2882
+ */
2883
+ getModelStrategy(): ModelStrategy;
2884
+ /**
2885
+ * Apply conversation similarity threshold to all LLM provider singletons
2886
+ * @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
2887
+ */
2888
+ private applyConversationSimilarityThreshold;
2889
+ /**
2890
+ * Set conversation similarity threshold at runtime
2891
+ * @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
2892
+ */
2893
+ setConversationSimilarityThreshold(threshold: number): void;
2894
+ /**
2895
+ * Get current conversation similarity threshold
2896
+ */
2897
+ getConversationSimilarityThreshold(): number;
1448
2898
  }
1449
2899
 
1450
- export { type Action, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type IncomingMessage, LLM, type LogLevel, type Message, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, type Tool$1 as Tool, UIBlock, UILogCollector, type User, UserManager, type UsersData, logger };
2900
+ 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 };