@superatomai/sdk-node 0.0.41 → 0.0.42-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 +885 -79
- package/dist/index.d.ts +885 -79
- package/dist/index.js +14265 -8287
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14236 -8268
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -59,7 +59,18 @@ declare class Logger {
|
|
|
59
59
|
* Log debug message (only shown for verbose level)
|
|
60
60
|
*/
|
|
61
61
|
debug(...args: any[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Write to log file
|
|
64
|
+
*/
|
|
62
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;
|
|
63
74
|
}
|
|
64
75
|
declare const logger: Logger;
|
|
65
76
|
|
|
@@ -623,24 +634,24 @@ declare const ComponentSchema: z.ZodObject<{
|
|
|
623
634
|
type: z.ZodString;
|
|
624
635
|
description: z.ZodString;
|
|
625
636
|
props: z.ZodObject<{
|
|
626
|
-
query: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]
|
|
637
|
+
query: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
627
638
|
title: z.ZodOptional<z.ZodString>;
|
|
628
639
|
description: z.ZodOptional<z.ZodString>;
|
|
629
640
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
630
641
|
actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
631
|
-
}, "
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
config
|
|
636
|
-
actions
|
|
637
|
-
}, {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
config
|
|
642
|
-
actions
|
|
643
|
-
}
|
|
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">>;
|
|
644
655
|
category: z.ZodOptional<z.ZodString>;
|
|
645
656
|
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
646
657
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -650,10 +661,12 @@ declare const ComponentSchema: z.ZodObject<{
|
|
|
650
661
|
description: string;
|
|
651
662
|
props: {
|
|
652
663
|
description?: string | undefined;
|
|
653
|
-
query?: string | {} | undefined;
|
|
664
|
+
query?: string | {} | null | undefined;
|
|
654
665
|
title?: string | undefined;
|
|
655
666
|
config?: Record<string, unknown> | undefined;
|
|
656
667
|
actions?: any[] | undefined;
|
|
668
|
+
} & {
|
|
669
|
+
[k: string]: unknown;
|
|
657
670
|
};
|
|
658
671
|
displayName?: string | undefined;
|
|
659
672
|
isDisplayComp?: boolean | undefined;
|
|
@@ -666,10 +679,12 @@ declare const ComponentSchema: z.ZodObject<{
|
|
|
666
679
|
description: string;
|
|
667
680
|
props: {
|
|
668
681
|
description?: string | undefined;
|
|
669
|
-
query?: string | {} | undefined;
|
|
682
|
+
query?: string | {} | null | undefined;
|
|
670
683
|
title?: string | undefined;
|
|
671
684
|
config?: Record<string, unknown> | undefined;
|
|
672
685
|
actions?: any[] | undefined;
|
|
686
|
+
} & {
|
|
687
|
+
[k: string]: unknown;
|
|
673
688
|
};
|
|
674
689
|
displayName?: string | undefined;
|
|
675
690
|
isDisplayComp?: boolean | undefined;
|
|
@@ -677,24 +692,123 @@ declare const ComponentSchema: z.ZodObject<{
|
|
|
677
692
|
keywords?: string[] | undefined;
|
|
678
693
|
}>;
|
|
679
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>;
|
|
680
740
|
declare const ToolSchema: z.ZodObject<{
|
|
681
741
|
id: z.ZodString;
|
|
682
742
|
name: z.ZodString;
|
|
683
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>;
|
|
684
748
|
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
685
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
|
+
}>>;
|
|
686
780
|
}, "strip", z.ZodTypeAny, {
|
|
687
781
|
id: string;
|
|
688
782
|
params: Record<string, string>;
|
|
689
783
|
name: string;
|
|
690
784
|
description: string;
|
|
691
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;
|
|
692
796
|
}, {
|
|
693
797
|
id: string;
|
|
694
798
|
params: Record<string, string>;
|
|
695
799
|
name: string;
|
|
696
800
|
description: string;
|
|
697
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;
|
|
698
812
|
}>;
|
|
699
813
|
type Tool$1 = z.infer<typeof ToolSchema>;
|
|
700
814
|
type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
|
|
@@ -709,11 +823,26 @@ type DatabaseType = 'postgresql' | 'mssql' | 'snowflake' | 'mysql';
|
|
|
709
823
|
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
710
824
|
*/
|
|
711
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
|
+
}
|
|
712
842
|
interface SuperatomSDKConfig {
|
|
713
843
|
url?: string;
|
|
714
844
|
apiKey?: string;
|
|
715
845
|
projectId: string;
|
|
716
|
-
userId?: string;
|
|
717
846
|
type?: string;
|
|
718
847
|
bundleDir?: string;
|
|
719
848
|
promptsDir?: string;
|
|
@@ -731,22 +860,61 @@ interface SuperatomSDKConfig {
|
|
|
731
860
|
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
732
861
|
*/
|
|
733
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;
|
|
734
899
|
}
|
|
735
900
|
|
|
736
901
|
declare const KbNodesQueryFiltersSchema: z.ZodObject<{
|
|
737
902
|
query: z.ZodOptional<z.ZodString>;
|
|
738
903
|
category: z.ZodOptional<z.ZodString>;
|
|
739
904
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
740
|
-
|
|
905
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
906
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
741
907
|
}, "strip", z.ZodTypeAny, {
|
|
908
|
+
type?: "query" | "user" | "global" | undefined;
|
|
742
909
|
query?: string | undefined;
|
|
743
910
|
category?: string | undefined;
|
|
744
|
-
createdBy?:
|
|
911
|
+
createdBy?: string | undefined;
|
|
745
912
|
tags?: string[] | undefined;
|
|
746
913
|
}, {
|
|
914
|
+
type?: "query" | "user" | "global" | undefined;
|
|
747
915
|
query?: string | undefined;
|
|
748
916
|
category?: string | undefined;
|
|
749
|
-
createdBy?:
|
|
917
|
+
createdBy?: string | undefined;
|
|
750
918
|
tags?: string[] | undefined;
|
|
751
919
|
}>;
|
|
752
920
|
type KbNodesQueryFilters = z.infer<typeof KbNodesQueryFiltersSchema>;
|
|
@@ -758,106 +926,118 @@ declare const KbNodesRequestPayloadSchema: z.ZodObject<{
|
|
|
758
926
|
content: z.ZodOptional<z.ZodString>;
|
|
759
927
|
category: z.ZodOptional<z.ZodString>;
|
|
760
928
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
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>;
|
|
764
933
|
query: z.ZodOptional<z.ZodString>;
|
|
765
934
|
filters: z.ZodOptional<z.ZodObject<{
|
|
766
935
|
query: z.ZodOptional<z.ZodString>;
|
|
767
936
|
category: z.ZodOptional<z.ZodString>;
|
|
768
937
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
769
|
-
|
|
938
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
939
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
770
940
|
}, "strip", z.ZodTypeAny, {
|
|
941
|
+
type?: "query" | "user" | "global" | undefined;
|
|
771
942
|
query?: string | undefined;
|
|
772
943
|
category?: string | undefined;
|
|
773
|
-
createdBy?:
|
|
944
|
+
createdBy?: string | undefined;
|
|
774
945
|
tags?: string[] | undefined;
|
|
775
946
|
}, {
|
|
947
|
+
type?: "query" | "user" | "global" | undefined;
|
|
776
948
|
query?: string | undefined;
|
|
777
949
|
category?: string | undefined;
|
|
778
|
-
createdBy?:
|
|
950
|
+
createdBy?: string | undefined;
|
|
779
951
|
tags?: string[] | undefined;
|
|
780
952
|
}>>;
|
|
781
953
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
782
954
|
offset: z.ZodOptional<z.ZodNumber>;
|
|
783
955
|
}, "strip", z.ZodTypeAny, {
|
|
784
956
|
id?: number | undefined;
|
|
957
|
+
type?: "query" | "user" | "global" | undefined;
|
|
785
958
|
query?: string | undefined;
|
|
786
959
|
title?: string | undefined;
|
|
787
960
|
category?: string | undefined;
|
|
788
|
-
userId?:
|
|
961
|
+
userId?: string | undefined;
|
|
789
962
|
limit?: number | undefined;
|
|
790
963
|
filters?: {
|
|
964
|
+
type?: "query" | "user" | "global" | undefined;
|
|
791
965
|
query?: string | undefined;
|
|
792
966
|
category?: string | undefined;
|
|
793
|
-
createdBy?:
|
|
967
|
+
createdBy?: string | undefined;
|
|
794
968
|
tags?: string[] | undefined;
|
|
795
969
|
} | undefined;
|
|
796
|
-
createdBy?:
|
|
797
|
-
updatedBy?:
|
|
970
|
+
createdBy?: string | undefined;
|
|
971
|
+
updatedBy?: string | undefined;
|
|
972
|
+
offset?: number | undefined;
|
|
798
973
|
tags?: string[] | undefined;
|
|
799
974
|
content?: string | undefined;
|
|
800
|
-
offset?: number | undefined;
|
|
801
975
|
}, {
|
|
802
976
|
id?: number | undefined;
|
|
977
|
+
type?: "query" | "user" | "global" | undefined;
|
|
803
978
|
query?: string | undefined;
|
|
804
979
|
title?: string | undefined;
|
|
805
980
|
category?: string | undefined;
|
|
806
|
-
userId?:
|
|
981
|
+
userId?: string | undefined;
|
|
807
982
|
limit?: number | undefined;
|
|
808
983
|
filters?: {
|
|
984
|
+
type?: "query" | "user" | "global" | undefined;
|
|
809
985
|
query?: string | undefined;
|
|
810
986
|
category?: string | undefined;
|
|
811
|
-
createdBy?:
|
|
987
|
+
createdBy?: string | undefined;
|
|
812
988
|
tags?: string[] | undefined;
|
|
813
989
|
} | undefined;
|
|
814
|
-
createdBy?:
|
|
815
|
-
updatedBy?:
|
|
990
|
+
createdBy?: string | undefined;
|
|
991
|
+
updatedBy?: string | undefined;
|
|
992
|
+
offset?: number | undefined;
|
|
816
993
|
tags?: string[] | undefined;
|
|
817
994
|
content?: string | undefined;
|
|
818
|
-
offset?: number | undefined;
|
|
819
995
|
}>>;
|
|
820
996
|
}, "strip", z.ZodTypeAny, {
|
|
821
997
|
operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
|
|
822
998
|
data?: {
|
|
823
999
|
id?: number | undefined;
|
|
1000
|
+
type?: "query" | "user" | "global" | undefined;
|
|
824
1001
|
query?: string | undefined;
|
|
825
1002
|
title?: string | undefined;
|
|
826
1003
|
category?: string | undefined;
|
|
827
|
-
userId?:
|
|
1004
|
+
userId?: string | undefined;
|
|
828
1005
|
limit?: number | undefined;
|
|
829
1006
|
filters?: {
|
|
1007
|
+
type?: "query" | "user" | "global" | undefined;
|
|
830
1008
|
query?: string | undefined;
|
|
831
1009
|
category?: string | undefined;
|
|
832
|
-
createdBy?:
|
|
1010
|
+
createdBy?: string | undefined;
|
|
833
1011
|
tags?: string[] | undefined;
|
|
834
1012
|
} | undefined;
|
|
835
|
-
createdBy?:
|
|
836
|
-
updatedBy?:
|
|
1013
|
+
createdBy?: string | undefined;
|
|
1014
|
+
updatedBy?: string | undefined;
|
|
1015
|
+
offset?: number | undefined;
|
|
837
1016
|
tags?: string[] | undefined;
|
|
838
1017
|
content?: string | undefined;
|
|
839
|
-
offset?: number | undefined;
|
|
840
1018
|
} | undefined;
|
|
841
1019
|
}, {
|
|
842
1020
|
operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
|
|
843
1021
|
data?: {
|
|
844
1022
|
id?: number | undefined;
|
|
1023
|
+
type?: "query" | "user" | "global" | undefined;
|
|
845
1024
|
query?: string | undefined;
|
|
846
1025
|
title?: string | undefined;
|
|
847
1026
|
category?: string | undefined;
|
|
848
|
-
userId?:
|
|
1027
|
+
userId?: string | undefined;
|
|
849
1028
|
limit?: number | undefined;
|
|
850
1029
|
filters?: {
|
|
1030
|
+
type?: "query" | "user" | "global" | undefined;
|
|
851
1031
|
query?: string | undefined;
|
|
852
1032
|
category?: string | undefined;
|
|
853
|
-
createdBy?:
|
|
1033
|
+
createdBy?: string | undefined;
|
|
854
1034
|
tags?: string[] | undefined;
|
|
855
1035
|
} | undefined;
|
|
856
|
-
createdBy?:
|
|
857
|
-
updatedBy?:
|
|
1036
|
+
createdBy?: string | undefined;
|
|
1037
|
+
updatedBy?: string | undefined;
|
|
1038
|
+
offset?: number | undefined;
|
|
858
1039
|
tags?: string[] | undefined;
|
|
859
1040
|
content?: string | undefined;
|
|
860
|
-
offset?: number | undefined;
|
|
861
1041
|
} | undefined;
|
|
862
1042
|
}>;
|
|
863
1043
|
type KbNodesRequestPayload = z.infer<typeof KbNodesRequestPayloadSchema>;
|
|
@@ -1126,6 +1306,360 @@ declare class ReportManager {
|
|
|
1126
1306
|
getReportCount(): number;
|
|
1127
1307
|
}
|
|
1128
1308
|
|
|
1309
|
+
/**
|
|
1310
|
+
* StreamBuffer - Buffered streaming utility for smoother text delivery
|
|
1311
|
+
* Batches small chunks together and flushes at regular intervals
|
|
1312
|
+
*/
|
|
1313
|
+
type StreamCallback = (chunk: string) => void;
|
|
1314
|
+
/**
|
|
1315
|
+
* StreamBuffer class for managing buffered streaming output
|
|
1316
|
+
* Provides smooth text delivery by batching small chunks
|
|
1317
|
+
*/
|
|
1318
|
+
declare class StreamBuffer {
|
|
1319
|
+
private buffer;
|
|
1320
|
+
private flushTimer;
|
|
1321
|
+
private callback;
|
|
1322
|
+
private fullText;
|
|
1323
|
+
constructor(callback?: StreamCallback);
|
|
1324
|
+
/**
|
|
1325
|
+
* Check if the buffer has a callback configured
|
|
1326
|
+
*/
|
|
1327
|
+
hasCallback(): boolean;
|
|
1328
|
+
/**
|
|
1329
|
+
* Get all text that has been written (including already flushed)
|
|
1330
|
+
*/
|
|
1331
|
+
getFullText(): string;
|
|
1332
|
+
/**
|
|
1333
|
+
* Write a chunk to the buffer
|
|
1334
|
+
* Large chunks or chunks with newlines are flushed immediately
|
|
1335
|
+
* Small chunks are batched and flushed after a short interval
|
|
1336
|
+
*
|
|
1337
|
+
* @param chunk - Text chunk to write
|
|
1338
|
+
*/
|
|
1339
|
+
write(chunk: string): void;
|
|
1340
|
+
/**
|
|
1341
|
+
* Flush the buffer immediately
|
|
1342
|
+
* Call this before tool execution or other operations that need clean output
|
|
1343
|
+
*/
|
|
1344
|
+
flush(): void;
|
|
1345
|
+
/**
|
|
1346
|
+
* Internal flush implementation
|
|
1347
|
+
*/
|
|
1348
|
+
private flushNow;
|
|
1349
|
+
/**
|
|
1350
|
+
* Clean up resources
|
|
1351
|
+
* Call this when done with the buffer
|
|
1352
|
+
*/
|
|
1353
|
+
dispose(): void;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* ToolExecutorService - Handles execution of SQL queries and external tools
|
|
1358
|
+
* Extracted from BaseLLM.generateTextResponse for better separation of concerns
|
|
1359
|
+
*/
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* External tool definition
|
|
1363
|
+
*/
|
|
1364
|
+
interface ExternalTool {
|
|
1365
|
+
id: string;
|
|
1366
|
+
name: string;
|
|
1367
|
+
description?: string;
|
|
1368
|
+
/** Tool type: "source" = routed through SourceAgent, "direct" = called directly by MainAgent */
|
|
1369
|
+
toolType?: 'source' | 'direct';
|
|
1370
|
+
/** Full untruncated schema for source agent (all columns visible) */
|
|
1371
|
+
fullSchema?: string;
|
|
1372
|
+
/** Schema size tier: small (≤50 tables), medium (51-200), large (201-500), very_large (500+) */
|
|
1373
|
+
schemaTier?: string;
|
|
1374
|
+
/** Schema search function for very_large tier — keyword search over entities */
|
|
1375
|
+
schemaSearchFn?: (keywords: string[]) => string;
|
|
1376
|
+
fn: (input: any) => Promise<any>;
|
|
1377
|
+
limit?: number;
|
|
1378
|
+
outputSchema?: any;
|
|
1379
|
+
executionType?: 'immediate' | 'deferred';
|
|
1380
|
+
userProvidedData?: any;
|
|
1381
|
+
params?: Record<string, any>;
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Executed tool tracking info
|
|
1385
|
+
*/
|
|
1386
|
+
interface ExecutedToolInfo {
|
|
1387
|
+
id: string;
|
|
1388
|
+
name: string;
|
|
1389
|
+
params: any;
|
|
1390
|
+
result: {
|
|
1391
|
+
_totalRecords: number;
|
|
1392
|
+
_recordsShown: number;
|
|
1393
|
+
_metadata?: any;
|
|
1394
|
+
_sampleData: any[];
|
|
1395
|
+
};
|
|
1396
|
+
outputSchema?: any;
|
|
1397
|
+
sourceSchema?: string;
|
|
1398
|
+
sourceType?: string;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Multi-Agent Architecture Types
|
|
1403
|
+
*
|
|
1404
|
+
* Defines interfaces for the hierarchical agent system:
|
|
1405
|
+
* - Main Agent: ONE LLM.streamWithTools() call with source agent tools
|
|
1406
|
+
* - Source Agents: independent agents that query individual data sources
|
|
1407
|
+
*
|
|
1408
|
+
* The main agent sees only source summaries. When it calls a source tool,
|
|
1409
|
+
* the SourceAgent runs independently (own LLM, own retries) and returns clean data.
|
|
1410
|
+
*/
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Per-entity detail: name, row count, and column names.
|
|
1414
|
+
* Gives the main agent enough context to route to the right source.
|
|
1415
|
+
*/
|
|
1416
|
+
interface EntityDetail {
|
|
1417
|
+
/** Entity name (table, sheet, endpoint) */
|
|
1418
|
+
name: string;
|
|
1419
|
+
/** Approximate row count */
|
|
1420
|
+
rowCount?: number;
|
|
1421
|
+
/** Column/field names */
|
|
1422
|
+
columns: string[];
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Representation of a data source for the main agent.
|
|
1426
|
+
* Contains entity names WITH column names so the LLM can route accurately.
|
|
1427
|
+
*/
|
|
1428
|
+
interface SourceSummary {
|
|
1429
|
+
/** Source ID (matches tool ID prefix) */
|
|
1430
|
+
id: string;
|
|
1431
|
+
/** Human-readable source name */
|
|
1432
|
+
name: string;
|
|
1433
|
+
/** Source type: postgres, excel, rest_api, etc. */
|
|
1434
|
+
type: string;
|
|
1435
|
+
/** Brief description of what data this source contains */
|
|
1436
|
+
description: string;
|
|
1437
|
+
/** Detailed entity info with column names for routing */
|
|
1438
|
+
entityDetails: EntityDetail[];
|
|
1439
|
+
/** The tool ID associated with this source */
|
|
1440
|
+
toolId: string;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* What a source agent returns after querying its data source.
|
|
1444
|
+
* The main agent uses this to analyze and compose the final response.
|
|
1445
|
+
*/
|
|
1446
|
+
interface SourceAgentResult {
|
|
1447
|
+
/** Source ID */
|
|
1448
|
+
sourceId: string;
|
|
1449
|
+
/** Source name */
|
|
1450
|
+
sourceName: string;
|
|
1451
|
+
/** Whether the query succeeded */
|
|
1452
|
+
success: boolean;
|
|
1453
|
+
/** Result data rows */
|
|
1454
|
+
data: any[];
|
|
1455
|
+
/** Metadata about the query execution */
|
|
1456
|
+
metadata: SourceAgentMetadata;
|
|
1457
|
+
/** Tool execution info for the last successful query (backward compat) */
|
|
1458
|
+
executedTool: ExecutedToolInfo;
|
|
1459
|
+
/** All successful tool executions (primary + follow-up queries) */
|
|
1460
|
+
allExecutedTools?: ExecutedToolInfo[];
|
|
1461
|
+
/** Error message if failed */
|
|
1462
|
+
error?: string;
|
|
1463
|
+
}
|
|
1464
|
+
interface SourceAgentMetadata {
|
|
1465
|
+
/** Total rows that matched the query (before limit) */
|
|
1466
|
+
totalRowsMatched: number;
|
|
1467
|
+
/** Rows actually returned (after limit) */
|
|
1468
|
+
rowsReturned: number;
|
|
1469
|
+
/** Whether the result was truncated by the row limit */
|
|
1470
|
+
isLimited: boolean;
|
|
1471
|
+
/** The query/params that were executed */
|
|
1472
|
+
queryExecuted?: string;
|
|
1473
|
+
/** Execution time in milliseconds */
|
|
1474
|
+
executionTimeMs: number;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* A pre-built, multi-step UI flow registered with the SDK.
|
|
1478
|
+
*
|
|
1479
|
+
* When the main agent decides a user's question matches a workflow's whenToUse
|
|
1480
|
+
* trigger, it picks the workflow instead of running source agents / generating
|
|
1481
|
+
* dashboard components. The LLM extracts the workflow's required props from the
|
|
1482
|
+
* prompt (using `propsSchema` as the tool input_schema) and the SDK returns the
|
|
1483
|
+
* workflow component directly — no analysis text, no chart generation. The
|
|
1484
|
+
* frontend renders the registered workflow component with the LLM-extracted
|
|
1485
|
+
* props.
|
|
1486
|
+
*/
|
|
1487
|
+
interface WorkflowDescriptor {
|
|
1488
|
+
/** Unique workflow id (used as the LLM tool name) */
|
|
1489
|
+
id: string;
|
|
1490
|
+
/** Component name on the frontend (matches the registered React component) */
|
|
1491
|
+
name: string;
|
|
1492
|
+
/** Short human-readable description of what this workflow does */
|
|
1493
|
+
description: string;
|
|
1494
|
+
/**
|
|
1495
|
+
* 1–2 sentence trigger condition. The LLM uses this to decide if the
|
|
1496
|
+
* user's prompt matches this workflow. Be specific — e.g.
|
|
1497
|
+
* "User wants to *initiate* an inventory transfer (review + submit POs),
|
|
1498
|
+
* not just see analysis or charts."
|
|
1499
|
+
*/
|
|
1500
|
+
whenToUse: string;
|
|
1501
|
+
/**
|
|
1502
|
+
* JSON-schema-style description of the props the workflow needs. Becomes
|
|
1503
|
+
* the LLM tool's input_schema, so the model fills these from the prompt.
|
|
1504
|
+
* Use the same shape as `params` on direct tools — string descriptors with
|
|
1505
|
+
* an optional "(optional)" suffix.
|
|
1506
|
+
*
|
|
1507
|
+
* Example:
|
|
1508
|
+
* ```
|
|
1509
|
+
* {
|
|
1510
|
+
* selectedStore: 'object — { id, name } of the source branch',
|
|
1511
|
+
* minROI: 'number (optional) — only show transfers with ROI ≥ this',
|
|
1512
|
+
* }
|
|
1513
|
+
* ```
|
|
1514
|
+
*/
|
|
1515
|
+
propsSchema: Record<string, string>;
|
|
1516
|
+
/**
|
|
1517
|
+
* Optional: static prop defaults merged with LLM-extracted props before
|
|
1518
|
+
* the component is returned. Useful for things like the embedded
|
|
1519
|
+
* `externalTool` config that the workflow uses to fetch its own data.
|
|
1520
|
+
*/
|
|
1521
|
+
defaultProps?: Record<string, any>;
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* The workflow selection captured during a routing call.
|
|
1525
|
+
* Set on AgentResponse when the LLM picks a workflow tool.
|
|
1526
|
+
*/
|
|
1527
|
+
interface SelectedWorkflow {
|
|
1528
|
+
/** Component name (matches WorkflowDescriptor.name) */
|
|
1529
|
+
name: string;
|
|
1530
|
+
/** Props extracted from the prompt + merged with workflow.defaultProps */
|
|
1531
|
+
props: Record<string, any>;
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* The complete response from the multi-agent system.
|
|
1535
|
+
* Contains everything needed for text display + component generation.
|
|
1536
|
+
*/
|
|
1537
|
+
interface AgentResponse {
|
|
1538
|
+
/** Generated text response (analysis of the data) */
|
|
1539
|
+
text: string;
|
|
1540
|
+
/** All executed tools across all source agents (for component generation) */
|
|
1541
|
+
executedTools: ExecutedToolInfo[];
|
|
1542
|
+
/** Individual results from each source agent */
|
|
1543
|
+
sourceResults: SourceAgentResult[];
|
|
1544
|
+
/**
|
|
1545
|
+
* Set when the LLM routed the question to a registered workflow component.
|
|
1546
|
+
* When present, the upstream caller should skip component generation and
|
|
1547
|
+
* return this workflow as the response.
|
|
1548
|
+
*/
|
|
1549
|
+
workflow?: SelectedWorkflow;
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Configuration for the multi-agent system.
|
|
1553
|
+
* Controls limits, models, and behavior.
|
|
1554
|
+
*/
|
|
1555
|
+
interface AgentConfig {
|
|
1556
|
+
/** Max rows a source agent can return (default: 50) */
|
|
1557
|
+
maxRowsPerSource: number;
|
|
1558
|
+
/** Model for the main agent (routing + analysis in one LLM call) */
|
|
1559
|
+
mainAgentModel: string;
|
|
1560
|
+
/** Model for source agent query generation */
|
|
1561
|
+
sourceAgentModel: string;
|
|
1562
|
+
/** API key for LLM calls */
|
|
1563
|
+
apiKey?: string;
|
|
1564
|
+
/** Max retry attempts per source agent */
|
|
1565
|
+
maxRetries: number;
|
|
1566
|
+
/** Max tool calling iterations for the main agent loop */
|
|
1567
|
+
maxIterations: number;
|
|
1568
|
+
/** Global knowledge base context (static, same for all users/questions — cached in system prompt) */
|
|
1569
|
+
globalKnowledgeBase?: string;
|
|
1570
|
+
/** Per-request knowledge base context (user-specific + query-matched — dynamic, not cached) */
|
|
1571
|
+
knowledgeBaseContext?: string;
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Default agent configuration
|
|
1575
|
+
*/
|
|
1576
|
+
declare const DEFAULT_AGENT_CONFIG: AgentConfig;
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Main Agent (Orchestrator)
|
|
1580
|
+
*
|
|
1581
|
+
* A single LLM.streamWithTools() call that handles everything:
|
|
1582
|
+
* - Routing: decides which source(s) to query based on summaries
|
|
1583
|
+
* - Querying: calls source tools (each wraps an independent SourceAgent)
|
|
1584
|
+
* - Direct tools: calls pre-built function tools directly with LLM-provided params
|
|
1585
|
+
* - Re-querying: if data is wrong/incomplete, calls tools again with modified intent
|
|
1586
|
+
* - Analysis: generates final text response from the data
|
|
1587
|
+
*
|
|
1588
|
+
* Two tool types:
|
|
1589
|
+
* - "source" tools: main agent sees summaries, SourceAgent handles SQL generation independently
|
|
1590
|
+
* - "direct" tools: main agent calls fn() directly with structured params (no SourceAgent)
|
|
1591
|
+
*/
|
|
1592
|
+
|
|
1593
|
+
declare class MainAgent {
|
|
1594
|
+
private externalTools;
|
|
1595
|
+
private workflows;
|
|
1596
|
+
private config;
|
|
1597
|
+
private streamBuffer;
|
|
1598
|
+
constructor(externalTools: ExternalTool[], config: AgentConfig, streamBuffer?: StreamBuffer, workflows?: WorkflowDescriptor[]);
|
|
1599
|
+
/**
|
|
1600
|
+
* Handle a user question using the multi-agent system.
|
|
1601
|
+
*
|
|
1602
|
+
* This is ONE LLM.streamWithTools() call. The LLM:
|
|
1603
|
+
* 1. Sees source summaries + direct tool descriptions in system prompt
|
|
1604
|
+
* 2. Decides which tool(s) to call (routing)
|
|
1605
|
+
* 3. Source tools → SourceAgent runs independently → returns data
|
|
1606
|
+
* 4. Direct tools → fn() called directly with LLM params → returns data
|
|
1607
|
+
* 5. Generates final analysis text
|
|
1608
|
+
*/
|
|
1609
|
+
handleQuestion(userPrompt: string, apiKey?: string, conversationHistory?: string, streamCallback?: (chunk: string) => void): Promise<AgentResponse>;
|
|
1610
|
+
/**
|
|
1611
|
+
* Execute a direct tool — call fn() with LLM-provided params, no SourceAgent.
|
|
1612
|
+
*/
|
|
1613
|
+
private handleDirectTool;
|
|
1614
|
+
/**
|
|
1615
|
+
* Build the main agent's system prompt with source summaries, direct tool descriptions,
|
|
1616
|
+
* and workflow component descriptions.
|
|
1617
|
+
*/
|
|
1618
|
+
private buildSystemPrompt;
|
|
1619
|
+
/**
|
|
1620
|
+
* Build tool definitions for source tools — summary-only descriptions.
|
|
1621
|
+
* The full schema is inside the SourceAgent which runs independently.
|
|
1622
|
+
*/
|
|
1623
|
+
private buildSourceToolDefinitions;
|
|
1624
|
+
/**
|
|
1625
|
+
* Build tool definitions for direct tools — expose their actual params.
|
|
1626
|
+
* These are called directly by the main agent LLM, no SourceAgent.
|
|
1627
|
+
*/
|
|
1628
|
+
private buildDirectToolDefinitions;
|
|
1629
|
+
/**
|
|
1630
|
+
* Capture a workflow selection. We do NOT execute anything — the LLM has
|
|
1631
|
+
* already extracted the props it wants the workflow rendered with. We
|
|
1632
|
+
* record the selection (via the capture callback) and return a short
|
|
1633
|
+
* acknowledgement so the LLM ends its turn cleanly without writing
|
|
1634
|
+
* analysis text or calling more tools.
|
|
1635
|
+
*/
|
|
1636
|
+
private handleWorkflow;
|
|
1637
|
+
/**
|
|
1638
|
+
* Build LLM tool definitions for workflow components. The workflow's
|
|
1639
|
+
* propsSchema becomes the tool's input_schema so the LLM extracts props
|
|
1640
|
+
* directly from the prompt — same mechanic as direct tools.
|
|
1641
|
+
*/
|
|
1642
|
+
private buildWorkflowToolDefinitions;
|
|
1643
|
+
/**
|
|
1644
|
+
* Format a source agent's result as a clean string for the main agent LLM.
|
|
1645
|
+
*/
|
|
1646
|
+
private formatResultForMainAgent;
|
|
1647
|
+
/**
|
|
1648
|
+
* Get source summaries (for external inspection/debugging).
|
|
1649
|
+
*/
|
|
1650
|
+
getSourceSummaries(): SourceSummary[];
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Represents an action that can be performed on a UIBlock
|
|
1655
|
+
*/
|
|
1656
|
+
interface Action {
|
|
1657
|
+
id: string;
|
|
1658
|
+
name: string;
|
|
1659
|
+
type: string;
|
|
1660
|
+
[key: string]: any;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1129
1663
|
type SystemPrompt = string | Anthropic.Messages.TextBlockParam[];
|
|
1130
1664
|
interface LLMMessages {
|
|
1131
1665
|
sys: SystemPrompt;
|
|
@@ -1183,6 +1717,11 @@ declare class LLM {
|
|
|
1183
1717
|
private static _groqStream;
|
|
1184
1718
|
private static _geminiText;
|
|
1185
1719
|
private static _geminiStream;
|
|
1720
|
+
/**
|
|
1721
|
+
* Recursively strip unsupported JSON Schema properties for Gemini
|
|
1722
|
+
* Gemini doesn't support: additionalProperties, $schema, etc.
|
|
1723
|
+
*/
|
|
1724
|
+
private static _cleanSchemaForGemini;
|
|
1186
1725
|
private static _geminiStreamWithTools;
|
|
1187
1726
|
private static _openaiText;
|
|
1188
1727
|
private static _openaiStream;
|
|
@@ -1275,16 +1814,6 @@ declare class UILogCollector {
|
|
|
1275
1814
|
setUIBlockId(uiBlockId: string): void;
|
|
1276
1815
|
}
|
|
1277
1816
|
|
|
1278
|
-
/**
|
|
1279
|
-
* Represents an action that can be performed on a UIBlock
|
|
1280
|
-
*/
|
|
1281
|
-
interface Action {
|
|
1282
|
-
id: string;
|
|
1283
|
-
name: string;
|
|
1284
|
-
type: string;
|
|
1285
|
-
[key: string]: any;
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
1817
|
/**
|
|
1289
1818
|
* UIBlock represents a single user and assistant message block in a thread
|
|
1290
1819
|
* Contains user question, component metadata, component data, text response, and available actions
|
|
@@ -1467,12 +1996,20 @@ declare class Thread {
|
|
|
1467
1996
|
|
|
1468
1997
|
/**
|
|
1469
1998
|
* ThreadManager manages all threads globally
|
|
1470
|
-
* Provides methods to create, retrieve, and delete threads
|
|
1999
|
+
* Provides methods to create, retrieve, and delete threads.
|
|
2000
|
+
* Includes automatic cleanup to prevent unbounded memory growth.
|
|
1471
2001
|
*/
|
|
1472
2002
|
declare class ThreadManager {
|
|
1473
2003
|
private static instance;
|
|
1474
2004
|
private threads;
|
|
2005
|
+
private cleanupInterval;
|
|
2006
|
+
private readonly threadTtlMs;
|
|
1475
2007
|
private constructor();
|
|
2008
|
+
/**
|
|
2009
|
+
* Periodically remove threads older than 7 days.
|
|
2010
|
+
* Runs every hour to avoid frequent iteration over the map.
|
|
2011
|
+
*/
|
|
2012
|
+
private startCleanup;
|
|
1476
2013
|
/**
|
|
1477
2014
|
* Get singleton instance of ThreadManager
|
|
1478
2015
|
*/
|
|
@@ -1871,6 +2408,92 @@ declare function rerankConversationResults<T extends {
|
|
|
1871
2408
|
bm25Score: number;
|
|
1872
2409
|
}>;
|
|
1873
2410
|
|
|
2411
|
+
/**
|
|
2412
|
+
* QueryExecutionService - Handles all query execution, validation, and retry logic
|
|
2413
|
+
* Extracted from BaseLLM for better separation of concerns
|
|
2414
|
+
*/
|
|
2415
|
+
|
|
2416
|
+
/**
|
|
2417
|
+
* Context for component when requesting query fix
|
|
2418
|
+
*/
|
|
2419
|
+
interface ComponentContext {
|
|
2420
|
+
name: string;
|
|
2421
|
+
type: string;
|
|
2422
|
+
title?: string;
|
|
2423
|
+
}
|
|
2424
|
+
/**
|
|
2425
|
+
* Result of query validation
|
|
2426
|
+
*/
|
|
2427
|
+
interface QueryValidationResult {
|
|
2428
|
+
component: Component | null;
|
|
2429
|
+
queryKey: string;
|
|
2430
|
+
result: any;
|
|
2431
|
+
validated: boolean;
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Result of batch query validation
|
|
2435
|
+
*/
|
|
2436
|
+
interface BatchValidationResult {
|
|
2437
|
+
components: Component[];
|
|
2438
|
+
queryResults: Map<string, any>;
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Configuration for QueryExecutionService
|
|
2442
|
+
*/
|
|
2443
|
+
interface QueryExecutionServiceConfig {
|
|
2444
|
+
defaultLimit: number;
|
|
2445
|
+
getModelForTask: (taskType: 'simple' | 'complex') => string;
|
|
2446
|
+
getApiKey: (apiKey?: string) => string | undefined;
|
|
2447
|
+
providerName: string;
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* QueryExecutionService handles all query-related operations
|
|
2451
|
+
*/
|
|
2452
|
+
declare class QueryExecutionService {
|
|
2453
|
+
private config;
|
|
2454
|
+
constructor(config: QueryExecutionServiceConfig);
|
|
2455
|
+
/**
|
|
2456
|
+
* Get the cache key for a query
|
|
2457
|
+
* This ensures the cache key matches what the frontend will send
|
|
2458
|
+
*/
|
|
2459
|
+
getQueryCacheKey(query: any): string;
|
|
2460
|
+
/**
|
|
2461
|
+
* Execute a query against the database
|
|
2462
|
+
* @param query - The SQL query to execute (string or object with sql/values)
|
|
2463
|
+
* @param collections - Collections object containing database execute function
|
|
2464
|
+
* @returns Object with result data and cache key
|
|
2465
|
+
*/
|
|
2466
|
+
executeQuery(query: any, collections: any): Promise<{
|
|
2467
|
+
result: any;
|
|
2468
|
+
cacheKey: string;
|
|
2469
|
+
}>;
|
|
2470
|
+
/**
|
|
2471
|
+
* Request the LLM to fix a failed SQL query
|
|
2472
|
+
* @param failedQuery - The query that failed execution
|
|
2473
|
+
* @param errorMessage - The error message from the failed execution
|
|
2474
|
+
* @param componentContext - Context about the component
|
|
2475
|
+
* @param apiKey - Optional API key
|
|
2476
|
+
* @returns Fixed query string
|
|
2477
|
+
*/
|
|
2478
|
+
requestQueryFix(failedQuery: string, errorMessage: string, componentContext: ComponentContext, apiKey?: string): Promise<string>;
|
|
2479
|
+
/**
|
|
2480
|
+
* Validate a single component's query with retry logic
|
|
2481
|
+
* @param component - The component to validate
|
|
2482
|
+
* @param collections - Collections object containing database execute function
|
|
2483
|
+
* @param apiKey - Optional API key for LLM calls
|
|
2484
|
+
* @returns Validation result with component, query key, and result
|
|
2485
|
+
*/
|
|
2486
|
+
validateSingleQuery(component: Component, collections: any, apiKey?: string): Promise<QueryValidationResult>;
|
|
2487
|
+
/**
|
|
2488
|
+
* Validate multiple component queries in parallel
|
|
2489
|
+
* @param components - Array of components with potential queries
|
|
2490
|
+
* @param collections - Collections object containing database execute function
|
|
2491
|
+
* @param apiKey - Optional API key for LLM calls
|
|
2492
|
+
* @returns Object with validated components and query results map
|
|
2493
|
+
*/
|
|
2494
|
+
validateComponentQueries(components: Component[], collections: any, apiKey?: string): Promise<BatchValidationResult>;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
1874
2497
|
/**
|
|
1875
2498
|
* Task types for model selection
|
|
1876
2499
|
* - 'complex': Text generation, component matching, parameter adaptation (uses best model in balanced mode)
|
|
@@ -1889,6 +2512,7 @@ interface BaseLLMConfig {
|
|
|
1889
2512
|
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
1890
2513
|
*/
|
|
1891
2514
|
modelStrategy?: ModelStrategy;
|
|
2515
|
+
conversationSimilarityThreshold?: number;
|
|
1892
2516
|
}
|
|
1893
2517
|
/**
|
|
1894
2518
|
* BaseLLM abstract class for AI-powered component generation and matching
|
|
@@ -1900,6 +2524,8 @@ declare abstract class BaseLLM {
|
|
|
1900
2524
|
protected defaultLimit: number;
|
|
1901
2525
|
protected apiKey?: string;
|
|
1902
2526
|
protected modelStrategy: ModelStrategy;
|
|
2527
|
+
protected conversationSimilarityThreshold: number;
|
|
2528
|
+
protected queryService: QueryExecutionService;
|
|
1903
2529
|
constructor(config?: BaseLLMConfig);
|
|
1904
2530
|
/**
|
|
1905
2531
|
* Get the appropriate model based on task type and model strategy
|
|
@@ -1917,6 +2543,16 @@ declare abstract class BaseLLM {
|
|
|
1917
2543
|
* @returns The current model strategy
|
|
1918
2544
|
*/
|
|
1919
2545
|
getModelStrategy(): ModelStrategy;
|
|
2546
|
+
/**
|
|
2547
|
+
* Set the conversation similarity threshold at runtime
|
|
2548
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
2549
|
+
*/
|
|
2550
|
+
setConversationSimilarityThreshold(threshold: number): void;
|
|
2551
|
+
/**
|
|
2552
|
+
* Get the current conversation similarity threshold
|
|
2553
|
+
* @returns The current threshold value
|
|
2554
|
+
*/
|
|
2555
|
+
getConversationSimilarityThreshold(): number;
|
|
1920
2556
|
/**
|
|
1921
2557
|
* Get the default model for this provider (used for complex tasks like text generation)
|
|
1922
2558
|
*/
|
|
@@ -1952,11 +2588,10 @@ declare abstract class BaseLLM {
|
|
|
1952
2588
|
* @param analysisContent - The text response containing component suggestions
|
|
1953
2589
|
* @param components - List of available components
|
|
1954
2590
|
* @param apiKey - Optional API key
|
|
1955
|
-
* @param logCollector - Optional log collector
|
|
1956
2591
|
* @param componentStreamCallback - Optional callback to stream primary KPI component as soon as it's identified
|
|
1957
2592
|
* @returns Object containing matched components, layout title/description, and follow-up actions
|
|
1958
2593
|
*/
|
|
1959
|
-
matchComponentsFromAnalysis(analysisContent: string, components: Component[],
|
|
2594
|
+
matchComponentsFromAnalysis(analysisContent: string, components: Component[], userPrompt: string, apiKey?: string, componentStreamCallback?: (component: Component) => void, deferredTools?: any[], executedTools?: any[], collections?: any, userId?: string): Promise<{
|
|
1960
2595
|
components: Component[];
|
|
1961
2596
|
layoutTitle: string;
|
|
1962
2597
|
layoutDescription: string;
|
|
@@ -1966,7 +2601,7 @@ declare abstract class BaseLLM {
|
|
|
1966
2601
|
* Classify user question into category and detect external tools needed
|
|
1967
2602
|
* Determines if question is for data analysis, requires external tools, or needs text response
|
|
1968
2603
|
*/
|
|
1969
|
-
classifyQuestionCategory(userPrompt: string, apiKey?: string,
|
|
2604
|
+
classifyQuestionCategory(userPrompt: string, apiKey?: string, conversationHistory?: string, externalTools?: any[]): Promise<{
|
|
1970
2605
|
category: 'data_analysis' | 'data_modification' | 'general';
|
|
1971
2606
|
externalTools: Array<{
|
|
1972
2607
|
type: string;
|
|
@@ -1981,10 +2616,12 @@ declare abstract class BaseLLM {
|
|
|
1981
2616
|
/**
|
|
1982
2617
|
* Adapt UI block parameters based on current user question
|
|
1983
2618
|
* Takes a matched UI block from semantic search and modifies its props to answer the new question
|
|
2619
|
+
* Also adapts the cached text response to match the new question
|
|
1984
2620
|
*/
|
|
1985
|
-
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string,
|
|
2621
|
+
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, cachedTextResponse?: string): Promise<{
|
|
1986
2622
|
success: boolean;
|
|
1987
2623
|
adaptedComponent?: Component;
|
|
2624
|
+
adaptedTextResponse?: string;
|
|
1988
2625
|
parametersChanged?: Array<{
|
|
1989
2626
|
field: string;
|
|
1990
2627
|
reason: string;
|
|
@@ -1996,13 +2633,8 @@ declare abstract class BaseLLM {
|
|
|
1996
2633
|
* This provides conversational text responses instead of component generation
|
|
1997
2634
|
* Supports tool calling for query execution with automatic retry on errors (max 3 attempts)
|
|
1998
2635
|
* After generating text response, if components are provided, matches suggested components
|
|
1999
|
-
* @param streamCallback - Optional callback function to receive text chunks as they stream
|
|
2000
|
-
* @param collections - Collection registry for executing database queries via database.execute
|
|
2001
|
-
* @param components - Optional list of available components for matching suggestions
|
|
2002
|
-
* @param externalTools - Optional array of external tools (email, calendar, etc.) that can be called
|
|
2003
|
-
* @param category - Question category ('data_analysis' | 'data_modification' | 'general'). For data_modification, answer component streaming is skipped. For general, component generation is skipped entirely.
|
|
2004
2636
|
*/
|
|
2005
|
-
generateTextResponse(userPrompt: string, apiKey?: string,
|
|
2637
|
+
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>;
|
|
2006
2638
|
/**
|
|
2007
2639
|
* Main orchestration function with semantic search and multi-step classification
|
|
2008
2640
|
* NEW FLOW (Recommended):
|
|
@@ -2010,19 +2642,14 @@ declare abstract class BaseLLM {
|
|
|
2010
2642
|
* - If match found → Adapt UI block parameters and return
|
|
2011
2643
|
* 2. Category classification: Determine if data_analysis, requires_external_tools, or text_response
|
|
2012
2644
|
* 3. Route appropriately based on category and response mode
|
|
2013
|
-
*
|
|
2014
|
-
* @param responseMode - 'component' for component generation (default), 'text' for text responses
|
|
2015
|
-
* @param streamCallback - Optional callback function to receive text chunks as they stream (only for text mode)
|
|
2016
|
-
* @param collections - Collection registry for executing database queries (required for text mode)
|
|
2017
|
-
* @param externalTools - Optional array of external tools (email, calendar, etc.) that can be called (only for text mode)
|
|
2018
2645
|
*/
|
|
2019
|
-
handleUserRequest(userPrompt: string, components: Component[], apiKey?: string,
|
|
2646
|
+
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>;
|
|
2020
2647
|
/**
|
|
2021
2648
|
* Generate next questions that the user might ask based on the original prompt and generated component
|
|
2022
2649
|
* This helps provide intelligent suggestions for follow-up queries
|
|
2023
2650
|
* For general/conversational questions without components, pass textResponse instead
|
|
2024
2651
|
*/
|
|
2025
|
-
generateNextQuestions(originalUserPrompt: string, component?: Component | null, componentData?: Record<string, unknown>, apiKey?: string,
|
|
2652
|
+
generateNextQuestions(originalUserPrompt: string, component?: Component | null, componentData?: Record<string, unknown>, apiKey?: string, conversationHistory?: string, textResponse?: string): Promise<string[]>;
|
|
2026
2653
|
}
|
|
2027
2654
|
|
|
2028
2655
|
interface AnthropicLLMConfig extends BaseLLMConfig {
|
|
@@ -2081,14 +2708,159 @@ declare class OpenAILLM extends BaseLLM {
|
|
|
2081
2708
|
}
|
|
2082
2709
|
declare const openaiLLM: OpenAILLM;
|
|
2083
2710
|
|
|
2084
|
-
|
|
2711
|
+
/**
|
|
2712
|
+
* Query Cache — Two mechanisms:
|
|
2713
|
+
*
|
|
2714
|
+
* 1. `cache` (query string → result data) — TTL-based with max size, for avoiding re-execution
|
|
2715
|
+
* of recently validated queries. True LRU eviction: reads bubble entries to the back via
|
|
2716
|
+
* delete+re-set so the oldest *unused* entry is evicted, not the oldest *inserted*.
|
|
2717
|
+
*
|
|
2718
|
+
* 2. Encrypted queryId tokens — SQL is encrypted into the queryId itself (self-contained).
|
|
2719
|
+
* No server-side storage needed for SQL mappings. The token is decrypted on each request.
|
|
2720
|
+
* This eliminates the unbounded queryIdCache that previously grew forever and caused
|
|
2721
|
+
* memory bloat (hundreds of MBs after thousands of queries).
|
|
2722
|
+
*
|
|
2723
|
+
* Result data can still be cached temporarily via the data cache (mechanism 1).
|
|
2724
|
+
*/
|
|
2725
|
+
declare class QueryCache {
|
|
2726
|
+
private cache;
|
|
2727
|
+
private ttlMs;
|
|
2728
|
+
private maxCacheSize;
|
|
2729
|
+
private cleanupInterval;
|
|
2730
|
+
private readonly algorithm;
|
|
2731
|
+
private encryptionKey;
|
|
2732
|
+
constructor();
|
|
2733
|
+
/**
|
|
2734
|
+
* Set the cache TTL (Time To Live)
|
|
2735
|
+
* @param minutes - TTL in minutes (default: 10)
|
|
2736
|
+
*/
|
|
2737
|
+
setTTL(minutes: number): void;
|
|
2738
|
+
/**
|
|
2739
|
+
* Get the current TTL in minutes
|
|
2740
|
+
*/
|
|
2741
|
+
getTTL(): number;
|
|
2742
|
+
/**
|
|
2743
|
+
* Store query result in data cache.
|
|
2744
|
+
* If the key already exists, it's removed first so the re-insert places it
|
|
2745
|
+
* at the back of the iteration order (LRU). Eviction only fires when adding
|
|
2746
|
+
* a genuinely new key past the size limit.
|
|
2747
|
+
*/
|
|
2748
|
+
set(query: string, data: any): void;
|
|
2749
|
+
/**
|
|
2750
|
+
* Get cached result if exists and not expired.
|
|
2751
|
+
* On hit, re-inserts the entry so it moves to the back of the Map's
|
|
2752
|
+
* iteration order — turning FIFO eviction into true LRU.
|
|
2753
|
+
*/
|
|
2754
|
+
get(query: string): any | null;
|
|
2755
|
+
/**
|
|
2756
|
+
* Check if query exists in cache (not expired)
|
|
2757
|
+
*/
|
|
2758
|
+
has(query: string): boolean;
|
|
2759
|
+
/**
|
|
2760
|
+
* Remove a specific query from cache
|
|
2761
|
+
*/
|
|
2762
|
+
delete(query: string): void;
|
|
2763
|
+
/**
|
|
2764
|
+
* Clear all cached entries
|
|
2765
|
+
*/
|
|
2766
|
+
clear(): void;
|
|
2767
|
+
/**
|
|
2768
|
+
* Get cache statistics
|
|
2769
|
+
*/
|
|
2770
|
+
getStats(): {
|
|
2771
|
+
size: number;
|
|
2772
|
+
queryIdCount: number;
|
|
2773
|
+
oldestEntryAge: number | null;
|
|
2774
|
+
};
|
|
2775
|
+
/**
|
|
2776
|
+
* Start periodic cleanup of expired data cache entries.
|
|
2777
|
+
*/
|
|
2778
|
+
private startCleanup;
|
|
2779
|
+
/**
|
|
2780
|
+
* Encrypt a payload into a self-contained token.
|
|
2781
|
+
*/
|
|
2782
|
+
private encrypt;
|
|
2783
|
+
/**
|
|
2784
|
+
* Decrypt a token back to the original payload.
|
|
2785
|
+
*/
|
|
2786
|
+
private decrypt;
|
|
2787
|
+
/**
|
|
2788
|
+
* Store a query by generating an encrypted token as queryId.
|
|
2789
|
+
* The SQL is encrypted INTO the token — nothing stored in memory.
|
|
2790
|
+
* If data is provided, it's cached temporarily in the data cache.
|
|
2791
|
+
*/
|
|
2792
|
+
storeQuery(query: any, data?: any): string;
|
|
2793
|
+
/**
|
|
2794
|
+
* Get a stored query by decrypting its token.
|
|
2795
|
+
* Returns the SQL + any cached result data.
|
|
2796
|
+
*/
|
|
2797
|
+
getQuery(queryId: string): {
|
|
2798
|
+
query: any;
|
|
2799
|
+
data: any;
|
|
2800
|
+
} | null;
|
|
2801
|
+
/**
|
|
2802
|
+
* Update cached data for a queryId token
|
|
2803
|
+
*/
|
|
2804
|
+
setQueryData(queryId: string, data: any): void;
|
|
2805
|
+
/**
|
|
2806
|
+
* Stop cleanup interval (for graceful shutdown)
|
|
2807
|
+
*/
|
|
2808
|
+
destroy(): void;
|
|
2809
|
+
}
|
|
2810
|
+
declare const queryCache: QueryCache;
|
|
2811
|
+
|
|
2812
|
+
/**
|
|
2813
|
+
* Manages conversation history scoped per user + dashboard.
|
|
2814
|
+
* Each user-dashboard pair has its own isolated history that expires after a configurable TTL.
|
|
2815
|
+
*/
|
|
2816
|
+
declare class DashboardConversationHistory {
|
|
2817
|
+
private histories;
|
|
2818
|
+
private ttlMs;
|
|
2819
|
+
private maxEntries;
|
|
2820
|
+
private cleanupInterval;
|
|
2821
|
+
constructor();
|
|
2822
|
+
/**
|
|
2823
|
+
* Set the TTL for dashboard histories
|
|
2824
|
+
* @param minutes - TTL in minutes
|
|
2825
|
+
*/
|
|
2826
|
+
setTTL(minutes: number): void;
|
|
2827
|
+
/**
|
|
2828
|
+
* Set max entries per dashboard
|
|
2829
|
+
*/
|
|
2830
|
+
setMaxEntries(max: number): void;
|
|
2831
|
+
/**
|
|
2832
|
+
* Add a conversation entry for a user's dashboard
|
|
2833
|
+
*/
|
|
2834
|
+
addEntry(dashboardId: string, userPrompt: string, componentSummary: string, userId?: string): void;
|
|
2835
|
+
/**
|
|
2836
|
+
* Get formatted conversation history for a user's dashboard
|
|
2837
|
+
*/
|
|
2838
|
+
getHistory(dashboardId: string, userId?: string): string;
|
|
2839
|
+
/**
|
|
2840
|
+
* Clear history for a specific user's dashboard
|
|
2841
|
+
*/
|
|
2842
|
+
clearDashboard(dashboardId: string, userId?: string): void;
|
|
2843
|
+
/**
|
|
2844
|
+
* Clear all dashboard histories
|
|
2845
|
+
*/
|
|
2846
|
+
clearAll(): void;
|
|
2847
|
+
/**
|
|
2848
|
+
* Start periodic cleanup of expired histories
|
|
2849
|
+
*/
|
|
2850
|
+
private startCleanup;
|
|
2851
|
+
/**
|
|
2852
|
+
* Stop cleanup interval (for graceful shutdown)
|
|
2853
|
+
*/
|
|
2854
|
+
destroy(): void;
|
|
2855
|
+
}
|
|
2856
|
+
declare const dashboardConversationHistory: DashboardConversationHistory;
|
|
2857
|
+
|
|
2085
2858
|
type MessageTypeHandler = (message: IncomingMessage) => void | Promise<void>;
|
|
2086
2859
|
declare class SuperatomSDK {
|
|
2087
2860
|
private ws;
|
|
2088
2861
|
private url;
|
|
2089
2862
|
private apiKey?;
|
|
2090
2863
|
private projectId;
|
|
2091
|
-
private userId;
|
|
2092
2864
|
private type;
|
|
2093
2865
|
private bundleDir;
|
|
2094
2866
|
private messageHandlers;
|
|
@@ -2099,6 +2871,7 @@ declare class SuperatomSDK {
|
|
|
2099
2871
|
private collections;
|
|
2100
2872
|
private components;
|
|
2101
2873
|
private tools;
|
|
2874
|
+
private workflows;
|
|
2102
2875
|
private anthropicApiKey;
|
|
2103
2876
|
private groqApiKey;
|
|
2104
2877
|
private geminiApiKey;
|
|
@@ -2106,6 +2879,10 @@ declare class SuperatomSDK {
|
|
|
2106
2879
|
private llmProviders;
|
|
2107
2880
|
private databaseType;
|
|
2108
2881
|
private modelStrategy;
|
|
2882
|
+
private mainAgentModel;
|
|
2883
|
+
private sourceAgentModel;
|
|
2884
|
+
private dashCompModels?;
|
|
2885
|
+
private conversationSimilarityThreshold;
|
|
2109
2886
|
private userManager;
|
|
2110
2887
|
private dashboardManager;
|
|
2111
2888
|
private reportManager;
|
|
@@ -2152,9 +2929,11 @@ declare class SuperatomSDK {
|
|
|
2152
2929
|
*/
|
|
2153
2930
|
private handleMessage;
|
|
2154
2931
|
/**
|
|
2155
|
-
* Send a message to the Superatom service
|
|
2932
|
+
* Send a message to the Superatom service.
|
|
2933
|
+
* Returns true if the message was sent, false if the WebSocket is not connected.
|
|
2934
|
+
* Does NOT throw on closed connections — callers can check the return value if needed.
|
|
2156
2935
|
*/
|
|
2157
|
-
send(message: Message):
|
|
2936
|
+
send(message: Message): boolean;
|
|
2158
2937
|
/**
|
|
2159
2938
|
* Register a message handler to receive all messages
|
|
2160
2939
|
*/
|
|
@@ -2202,6 +2981,19 @@ declare class SuperatomSDK {
|
|
|
2202
2981
|
* Get the stored tools
|
|
2203
2982
|
*/
|
|
2204
2983
|
getTools(): Tool$1[];
|
|
2984
|
+
/**
|
|
2985
|
+
* Register workflow components for the SDK instance.
|
|
2986
|
+
*
|
|
2987
|
+
* Workflows are pre-built multi-step UI flows the main agent can pick when
|
|
2988
|
+
* the user's prompt matches a workflow's `whenToUse` trigger. Picking a
|
|
2989
|
+
* workflow short-circuits analysis text + dashboard component generation —
|
|
2990
|
+
* the workflow component is returned directly, with the LLM-extracted props.
|
|
2991
|
+
*/
|
|
2992
|
+
setWorkflows(workflows: WorkflowDescriptor[]): void;
|
|
2993
|
+
/**
|
|
2994
|
+
* Get the registered workflow components.
|
|
2995
|
+
*/
|
|
2996
|
+
getWorkflows(): WorkflowDescriptor[];
|
|
2205
2997
|
/**
|
|
2206
2998
|
* Apply model strategy to all LLM provider singletons
|
|
2207
2999
|
* @param strategy - 'best', 'fast', or 'balanced'
|
|
@@ -2216,6 +3008,20 @@ declare class SuperatomSDK {
|
|
|
2216
3008
|
* Get current model strategy
|
|
2217
3009
|
*/
|
|
2218
3010
|
getModelStrategy(): ModelStrategy;
|
|
3011
|
+
/**
|
|
3012
|
+
* Apply conversation similarity threshold to all LLM provider singletons
|
|
3013
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
3014
|
+
*/
|
|
3015
|
+
private applyConversationSimilarityThreshold;
|
|
3016
|
+
/**
|
|
3017
|
+
* Set conversation similarity threshold at runtime
|
|
3018
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
3019
|
+
*/
|
|
3020
|
+
setConversationSimilarityThreshold(threshold: number): void;
|
|
3021
|
+
/**
|
|
3022
|
+
* Get current conversation similarity threshold
|
|
3023
|
+
*/
|
|
3024
|
+
getConversationSimilarityThreshold(): number;
|
|
2219
3025
|
}
|
|
2220
3026
|
|
|
2221
|
-
export { type Action, BM25L, type BM25LOptions, type BaseLLMConfig, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type DatabaseType, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, type Message, type ModelStrategy, type
|
|
3027
|
+
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, type SelectedWorkflow, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, UIBlock, UILogCollector, type User, UserManager, type UsersData, type WorkflowDescriptor, anthropicLLM, dashboardConversationHistory, geminiLLM, groqLLM, hybridRerank, llmUsageLogger, logger, openaiLLM, queryCache, rerankChromaResults, rerankConversationResults, userPromptErrorLogger };
|