@superatomai/sdk-node 0.0.47 → 0.0.49

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 CHANGED
@@ -681,24 +681,115 @@ declare const ComponentSchema: z.ZodObject<{
681
681
  keywords?: string[] | undefined;
682
682
  }>;
683
683
  type Component = z.infer<typeof ComponentSchema>;
684
+ declare const OutputFieldSchema: z.ZodObject<{
685
+ name: z.ZodString;
686
+ type: z.ZodEnum<["string", "number", "boolean", "date"]>;
687
+ description: z.ZodString;
688
+ }, "strip", z.ZodTypeAny, {
689
+ type: "string" | "number" | "boolean" | "date";
690
+ name: string;
691
+ description: string;
692
+ }, {
693
+ type: "string" | "number" | "boolean" | "date";
694
+ name: string;
695
+ description: string;
696
+ }>;
697
+ type OutputField = z.infer<typeof OutputFieldSchema>;
698
+ declare const OutputSchema: z.ZodObject<{
699
+ description: z.ZodString;
700
+ fields: z.ZodArray<z.ZodObject<{
701
+ name: z.ZodString;
702
+ type: z.ZodEnum<["string", "number", "boolean", "date"]>;
703
+ description: z.ZodString;
704
+ }, "strip", z.ZodTypeAny, {
705
+ type: "string" | "number" | "boolean" | "date";
706
+ name: string;
707
+ description: string;
708
+ }, {
709
+ type: "string" | "number" | "boolean" | "date";
710
+ name: string;
711
+ description: string;
712
+ }>, "many">;
713
+ }, "strip", z.ZodTypeAny, {
714
+ description: string;
715
+ fields: {
716
+ type: "string" | "number" | "boolean" | "date";
717
+ name: string;
718
+ description: string;
719
+ }[];
720
+ }, {
721
+ description: string;
722
+ fields: {
723
+ type: "string" | "number" | "boolean" | "date";
724
+ name: string;
725
+ description: string;
726
+ }[];
727
+ }>;
728
+ type ToolOutputSchema = z.infer<typeof OutputSchema>;
684
729
  declare const ToolSchema: z.ZodObject<{
685
730
  id: z.ZodString;
686
731
  name: z.ZodString;
687
732
  description: z.ZodString;
688
733
  params: z.ZodRecord<z.ZodString, z.ZodString>;
689
734
  fn: z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodAny>;
735
+ outputSchema: z.ZodOptional<z.ZodObject<{
736
+ description: z.ZodString;
737
+ fields: z.ZodArray<z.ZodObject<{
738
+ name: z.ZodString;
739
+ type: z.ZodEnum<["string", "number", "boolean", "date"]>;
740
+ description: z.ZodString;
741
+ }, "strip", z.ZodTypeAny, {
742
+ type: "string" | "number" | "boolean" | "date";
743
+ name: string;
744
+ description: string;
745
+ }, {
746
+ type: "string" | "number" | "boolean" | "date";
747
+ name: string;
748
+ description: string;
749
+ }>, "many">;
750
+ }, "strip", z.ZodTypeAny, {
751
+ description: string;
752
+ fields: {
753
+ type: "string" | "number" | "boolean" | "date";
754
+ name: string;
755
+ description: string;
756
+ }[];
757
+ }, {
758
+ description: string;
759
+ fields: {
760
+ type: "string" | "number" | "boolean" | "date";
761
+ name: string;
762
+ description: string;
763
+ }[];
764
+ }>>;
690
765
  }, "strip", z.ZodTypeAny, {
691
766
  id: string;
692
767
  params: Record<string, string>;
693
768
  name: string;
694
769
  description: string;
695
770
  fn: (args_0: any, ...args: unknown[]) => any;
771
+ outputSchema?: {
772
+ description: string;
773
+ fields: {
774
+ type: "string" | "number" | "boolean" | "date";
775
+ name: string;
776
+ description: string;
777
+ }[];
778
+ } | undefined;
696
779
  }, {
697
780
  id: string;
698
781
  params: Record<string, string>;
699
782
  name: string;
700
783
  description: string;
701
784
  fn: (args_0: any, ...args: unknown[]) => any;
785
+ outputSchema?: {
786
+ description: string;
787
+ fields: {
788
+ type: "string" | "number" | "boolean" | "date";
789
+ name: string;
790
+ description: string;
791
+ }[];
792
+ } | undefined;
702
793
  }>;
703
794
  type Tool$1 = z.infer<typeof ToolSchema>;
704
795
  type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
@@ -2243,4 +2334,4 @@ declare class SuperatomSDK {
2243
2334
  getModelStrategy(): ModelStrategy;
2244
2335
  }
2245
2336
 
2246
- 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 RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, UIBlock, UILogCollector, type User, UserManager, type UsersData, anthropicLLM, geminiLLM, groqLLM, hybridRerank, llmUsageLogger, logger, openaiLLM, rerankChromaResults, rerankConversationResults, userPromptErrorLogger };
2337
+ export { type Action, BM25L, type BM25LOptions, type BaseLLMConfig, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type DatabaseType, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, type Message, type ModelStrategy, type OutputField, type RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, UIBlock, UILogCollector, type User, UserManager, type UsersData, anthropicLLM, geminiLLM, groqLLM, hybridRerank, llmUsageLogger, logger, openaiLLM, rerankChromaResults, rerankConversationResults, userPromptErrorLogger };
package/dist/index.d.ts CHANGED
@@ -681,24 +681,115 @@ declare const ComponentSchema: z.ZodObject<{
681
681
  keywords?: string[] | undefined;
682
682
  }>;
683
683
  type Component = z.infer<typeof ComponentSchema>;
684
+ declare const OutputFieldSchema: z.ZodObject<{
685
+ name: z.ZodString;
686
+ type: z.ZodEnum<["string", "number", "boolean", "date"]>;
687
+ description: z.ZodString;
688
+ }, "strip", z.ZodTypeAny, {
689
+ type: "string" | "number" | "boolean" | "date";
690
+ name: string;
691
+ description: string;
692
+ }, {
693
+ type: "string" | "number" | "boolean" | "date";
694
+ name: string;
695
+ description: string;
696
+ }>;
697
+ type OutputField = z.infer<typeof OutputFieldSchema>;
698
+ declare const OutputSchema: z.ZodObject<{
699
+ description: z.ZodString;
700
+ fields: z.ZodArray<z.ZodObject<{
701
+ name: z.ZodString;
702
+ type: z.ZodEnum<["string", "number", "boolean", "date"]>;
703
+ description: z.ZodString;
704
+ }, "strip", z.ZodTypeAny, {
705
+ type: "string" | "number" | "boolean" | "date";
706
+ name: string;
707
+ description: string;
708
+ }, {
709
+ type: "string" | "number" | "boolean" | "date";
710
+ name: string;
711
+ description: string;
712
+ }>, "many">;
713
+ }, "strip", z.ZodTypeAny, {
714
+ description: string;
715
+ fields: {
716
+ type: "string" | "number" | "boolean" | "date";
717
+ name: string;
718
+ description: string;
719
+ }[];
720
+ }, {
721
+ description: string;
722
+ fields: {
723
+ type: "string" | "number" | "boolean" | "date";
724
+ name: string;
725
+ description: string;
726
+ }[];
727
+ }>;
728
+ type ToolOutputSchema = z.infer<typeof OutputSchema>;
684
729
  declare const ToolSchema: z.ZodObject<{
685
730
  id: z.ZodString;
686
731
  name: z.ZodString;
687
732
  description: z.ZodString;
688
733
  params: z.ZodRecord<z.ZodString, z.ZodString>;
689
734
  fn: z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodAny>;
735
+ outputSchema: z.ZodOptional<z.ZodObject<{
736
+ description: z.ZodString;
737
+ fields: z.ZodArray<z.ZodObject<{
738
+ name: z.ZodString;
739
+ type: z.ZodEnum<["string", "number", "boolean", "date"]>;
740
+ description: z.ZodString;
741
+ }, "strip", z.ZodTypeAny, {
742
+ type: "string" | "number" | "boolean" | "date";
743
+ name: string;
744
+ description: string;
745
+ }, {
746
+ type: "string" | "number" | "boolean" | "date";
747
+ name: string;
748
+ description: string;
749
+ }>, "many">;
750
+ }, "strip", z.ZodTypeAny, {
751
+ description: string;
752
+ fields: {
753
+ type: "string" | "number" | "boolean" | "date";
754
+ name: string;
755
+ description: string;
756
+ }[];
757
+ }, {
758
+ description: string;
759
+ fields: {
760
+ type: "string" | "number" | "boolean" | "date";
761
+ name: string;
762
+ description: string;
763
+ }[];
764
+ }>>;
690
765
  }, "strip", z.ZodTypeAny, {
691
766
  id: string;
692
767
  params: Record<string, string>;
693
768
  name: string;
694
769
  description: string;
695
770
  fn: (args_0: any, ...args: unknown[]) => any;
771
+ outputSchema?: {
772
+ description: string;
773
+ fields: {
774
+ type: "string" | "number" | "boolean" | "date";
775
+ name: string;
776
+ description: string;
777
+ }[];
778
+ } | undefined;
696
779
  }, {
697
780
  id: string;
698
781
  params: Record<string, string>;
699
782
  name: string;
700
783
  description: string;
701
784
  fn: (args_0: any, ...args: unknown[]) => any;
785
+ outputSchema?: {
786
+ description: string;
787
+ fields: {
788
+ type: "string" | "number" | "boolean" | "date";
789
+ name: string;
790
+ description: string;
791
+ }[];
792
+ } | undefined;
702
793
  }>;
703
794
  type Tool$1 = z.infer<typeof ToolSchema>;
704
795
  type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
@@ -2243,4 +2334,4 @@ declare class SuperatomSDK {
2243
2334
  getModelStrategy(): ModelStrategy;
2244
2335
  }
2245
2336
 
2246
- 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 RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, UIBlock, UILogCollector, type User, UserManager, type UsersData, anthropicLLM, geminiLLM, groqLLM, hybridRerank, llmUsageLogger, logger, openaiLLM, rerankChromaResults, rerankConversationResults, userPromptErrorLogger };
2337
+ export { type Action, BM25L, type BM25LOptions, type BaseLLMConfig, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type DatabaseType, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, type Message, type ModelStrategy, type OutputField, type RerankedResult, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, UIBlock, UILogCollector, type User, UserManager, type UsersData, anthropicLLM, geminiLLM, groqLLM, hybridRerank, llmUsageLogger, logger, openaiLLM, rerankChromaResults, rerankConversationResults, userPromptErrorLogger };
package/dist/index.js CHANGED
@@ -2093,12 +2093,27 @@ var ComponentListResponseMessageSchema = import_zod3.z.object({
2093
2093
  type: import_zod3.z.literal("COMPONENT_LIST_RES"),
2094
2094
  payload: ComponentListResponsePayloadSchema
2095
2095
  });
2096
+ var OutputFieldSchema = import_zod3.z.object({
2097
+ name: import_zod3.z.string(),
2098
+ // Field name (column name in the result)
2099
+ type: import_zod3.z.enum(["string", "number", "boolean", "date"]),
2100
+ description: import_zod3.z.string()
2101
+ // What this field contains
2102
+ });
2103
+ var OutputSchema = import_zod3.z.object({
2104
+ description: import_zod3.z.string(),
2105
+ // Brief description of what the output represents
2106
+ fields: import_zod3.z.array(OutputFieldSchema)
2107
+ // List of fields in each record (like columns in a table)
2108
+ });
2096
2109
  var ToolSchema = import_zod3.z.object({
2097
2110
  id: import_zod3.z.string(),
2098
2111
  name: import_zod3.z.string(),
2099
2112
  description: import_zod3.z.string(),
2100
2113
  params: import_zod3.z.record(import_zod3.z.string()),
2101
- fn: import_zod3.z.function().args(import_zod3.z.any()).returns(import_zod3.z.any())
2114
+ fn: import_zod3.z.function().args(import_zod3.z.any()).returns(import_zod3.z.any()),
2115
+ outputSchema: OutputSchema.optional()
2116
+ // Optional: describes the data structure returned by this tool
2102
2117
  });
2103
2118
  var UserQueryFiltersSchema = import_zod3.z.object({
2104
2119
  username: import_zod3.z.string().optional(),
@@ -5704,17 +5719,27 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
5704
5719
  let executedToolsText = "No external tools were executed for data fetching.";
5705
5720
  if (executedTools && executedTools.length > 0) {
5706
5721
  logger.info(`[${this.getProviderName()}] Passing ${executedTools.length} executed tools to component matching`);
5707
- executedToolsText = "The following external tools were executed to fetch data.\n**IMPORTANT: For components displaying this data, use externalTool prop instead of query.**\n**IMPORTANT: Use the result data to populate deferred tool parameters when applicable.**\n\n" + executedTools.map((tool, idx) => {
5722
+ executedToolsText = "The following external tools were executed to fetch data.\n**IMPORTANT: For components displaying this data, use externalTool prop instead of query.**\n**IMPORTANT: Use the outputSchema fields to set correct config keys (xAxisKey, yAxisKey, valueKey, nameKey, etc.)**\n**IMPORTANT: Use the result data to populate deferred tool parameters when applicable.**\n\n" + executedTools.map((tool, idx) => {
5708
5723
  let resultPreview = "No result data";
5709
5724
  if (tool.result) {
5710
5725
  const resultStr = typeof tool.result === "string" ? tool.result : JSON.stringify(tool.result, null, 2);
5711
5726
  resultPreview = resultStr.length > 2e3 ? resultStr.substring(0, 2e3) + "\n... (truncated)" : resultStr;
5712
5727
  }
5728
+ let outputSchemaText = "Not available";
5729
+ if (tool.outputSchema) {
5730
+ const fields = tool.outputSchema.fields || [];
5731
+ const recordCount = tool.result?._recordCount || (Array.isArray(tool.result) ? tool.result.length : "unknown");
5732
+ outputSchemaText = `Returns ARRAY of ${recordCount} records. ${tool.outputSchema.description}
5733
+ Fields in EACH ROW (these are per-row values, NOT aggregates):
5734
+ ${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")}
5735
+ NOTE: For aggregate values (SUM, COUNT, AVG across all rows), write SQL query instead.`;
5736
+ }
5713
5737
  return `${idx + 1}. **${tool.name}**
5714
5738
  toolId: "${tool.id}" (USE THIS EXACT VALUE for externalTool.toolId)
5715
5739
  toolName: "${tool.name}" (USE THIS EXACT VALUE for externalTool.toolName)
5716
5740
  parameters: ${JSON.stringify(tool.params || {})} (USE THESE for externalTool.parameters)
5717
- result: ${resultPreview}`;
5741
+ outputSchema: ${outputSchemaText}
5742
+ result preview: ${resultPreview}`;
5718
5743
  }).join("\n\n");
5719
5744
  }
5720
5745
  const schemaDoc = schema.generateSchemaDocumentation();
@@ -5827,23 +5852,9 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
5827
5852
  true
5828
5853
  // Parse as JSON
5829
5854
  );
5830
- logger.debug(`[${this.getProviderName()}] Component matching response parsed successfully`);
5831
- const componentSuggestionPattern = /c\d+:(\w+)\s*:\s*(.+)/g;
5832
- const suggestedComponents = [];
5833
- let match;
5834
- while ((match = componentSuggestionPattern.exec(analysisContent)) !== null) {
5835
- suggestedComponents.push({
5836
- type: match[1],
5837
- reasoning: match[2].trim()
5838
- });
5839
- }
5840
5855
  const matchedComponents = result.matchedComponents || [];
5841
5856
  const layoutTitle = result.layoutTitle || "Dashboard";
5842
5857
  const layoutDescription = result.layoutDescription || "Multi-component dashboard";
5843
- logger.info(`[${this.getProviderName()}] \u{1F4CA} Component Suggestions from Text Analysis: ${suggestedComponents.length}`);
5844
- suggestedComponents.forEach((comp, idx) => {
5845
- logger.info(`[${this.getProviderName()}] c${idx + 1}: ${comp.type} - ${comp.reasoning}`);
5846
- });
5847
5858
  logger.info(`[${this.getProviderName()}] \u{1F4E6} Matched Components from LLM: ${matchedComponents.length}`);
5848
5859
  matchedComponents.forEach((comp, idx) => {
5849
5860
  logger.info(`[${this.getProviderName()}] ${idx + 1}. ${comp.componentType} (${comp.componentName}) - ${comp.originalSuggestion || "N/A"}`);
@@ -5851,22 +5862,7 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
5851
5862
  logger.file("\n=============================\nFull LLM response:", JSON.stringify(result, null, 2));
5852
5863
  const rawActions = result.actions || [];
5853
5864
  const actions = convertQuestionsToActions(rawActions);
5854
- logger.info(`[${this.getProviderName()}] Matched ${matchedComponents.length} components from text response`);
5855
- logger.info(`[${this.getProviderName()}] Layout title: "${layoutTitle}"`);
5856
- logger.info(`[${this.getProviderName()}] Layout description: "${layoutDescription}"`);
5857
- logger.info(`[${this.getProviderName()}] Generated ${actions.length} follow-up actions`);
5858
- if (suggestedComponents.length > 0) {
5859
- logCollector?.info(`\u{1F4DD} Text Analysis suggested ${suggestedComponents.length} dashboard components:`);
5860
- suggestedComponents.forEach((comp, idx) => {
5861
- logCollector?.info(` c${idx + 1}: ${comp.type} - ${comp.reasoning}`);
5862
- });
5863
- }
5864
5865
  if (matchedComponents.length > 0) {
5865
- logCollector?.info(`\u{1F4E6} Matched ${matchedComponents.length} components for dashboard`);
5866
- if (suggestedComponents.length !== matchedComponents.length) {
5867
- logCollector?.warn(`\u26A0\uFE0F Component count mismatch: Suggested ${suggestedComponents.length}, but matched ${matchedComponents.length}`);
5868
- }
5869
- logCollector?.info(`Dashboard: "${layoutTitle}"`);
5870
5866
  matchedComponents.forEach((comp, idx) => {
5871
5867
  logCollector?.info(` ${idx + 1}. ${comp.componentName} (${comp.componentType}): ${comp.reasoning}`);
5872
5868
  if (comp.props?.query) {
@@ -5878,12 +5874,6 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
5878
5874
  }
5879
5875
  });
5880
5876
  }
5881
- if (actions.length > 0) {
5882
- logCollector?.info(`Generated ${actions.length} follow-up questions`);
5883
- actions.forEach((action, idx) => {
5884
- logCollector?.info(` ${idx + 1}. ${action.name}`);
5885
- });
5886
- }
5887
5877
  const finalComponents = matchedComponents.map((mc) => {
5888
5878
  const originalComponent = components.find((c) => c.id === mc.componentId);
5889
5879
  if (!originalComponent) {
@@ -6452,8 +6442,10 @@ Please try rephrasing your request or contact support.
6452
6442
  name: externalTool.name,
6453
6443
  params: toolInput,
6454
6444
  // The actual parameters used in this execution
6455
- result: resultSummary
6445
+ result: resultSummary,
6456
6446
  // Store summary instead of full result to save memory
6447
+ outputSchema: externalTool.outputSchema
6448
+ // Include output schema for component config generation
6457
6449
  });
6458
6450
  logger.info(`[${this.getProviderName()}] Tracked executed tool: ${externalTool.name} with params: ${JSON.stringify(toolInput)}`);
6459
6451
  }