@superatomai/sdk-node 0.0.48 → 0.0.50
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.js +26 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5720,24 +5720,22 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
|
|
|
5720
5720
|
if (executedTools && executedTools.length > 0) {
|
|
5721
5721
|
logger.info(`[${this.getProviderName()}] Passing ${executedTools.length} executed tools to component matching`);
|
|
5722
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) => {
|
|
5723
|
-
let resultPreview = "No result data";
|
|
5724
|
-
if (tool.result) {
|
|
5725
|
-
const resultStr = typeof tool.result === "string" ? tool.result : JSON.stringify(tool.result, null, 2);
|
|
5726
|
-
resultPreview = resultStr.length > 2e3 ? resultStr.substring(0, 2e3) + "\n... (truncated)" : resultStr;
|
|
5727
|
-
}
|
|
5728
5723
|
let outputSchemaText = "Not available";
|
|
5724
|
+
let recordCount = "unknown";
|
|
5729
5725
|
if (tool.outputSchema) {
|
|
5730
5726
|
const fields = tool.outputSchema.fields || [];
|
|
5727
|
+
recordCount = tool.result?._recordCount || (Array.isArray(tool.result) ? tool.result.length : "unknown");
|
|
5731
5728
|
outputSchemaText = `${tool.outputSchema.description}
|
|
5732
|
-
Fields
|
|
5729
|
+
Fields in EACH ROW (per-row values, NOT aggregates):
|
|
5733
5730
|
${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")}`;
|
|
5734
5731
|
}
|
|
5735
5732
|
return `${idx + 1}. **${tool.name}**
|
|
5736
5733
|
toolId: "${tool.id}" (USE THIS EXACT VALUE for externalTool.toolId)
|
|
5737
5734
|
toolName: "${tool.name}" (USE THIS EXACT VALUE for externalTool.toolName)
|
|
5738
5735
|
parameters: ${JSON.stringify(tool.params || {})} (USE THESE for externalTool.parameters)
|
|
5736
|
+
recordCount: ${recordCount} rows returned
|
|
5739
5737
|
outputSchema: ${outputSchemaText}
|
|
5740
|
-
|
|
5738
|
+
\u26A0\uFE0F DO NOT embed this tool's data in SQL - use externalTool prop OR query database tables`;
|
|
5741
5739
|
}).join("\n\n");
|
|
5742
5740
|
}
|
|
5743
5741
|
const schemaDoc = schema.generateSchemaDocumentation();
|
|
@@ -5850,23 +5848,9 @@ ${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")
|
|
|
5850
5848
|
true
|
|
5851
5849
|
// Parse as JSON
|
|
5852
5850
|
);
|
|
5853
|
-
logger.debug(`[${this.getProviderName()}] Component matching response parsed successfully`);
|
|
5854
|
-
const componentSuggestionPattern = /c\d+:(\w+)\s*:\s*(.+)/g;
|
|
5855
|
-
const suggestedComponents = [];
|
|
5856
|
-
let match;
|
|
5857
|
-
while ((match = componentSuggestionPattern.exec(analysisContent)) !== null) {
|
|
5858
|
-
suggestedComponents.push({
|
|
5859
|
-
type: match[1],
|
|
5860
|
-
reasoning: match[2].trim()
|
|
5861
|
-
});
|
|
5862
|
-
}
|
|
5863
5851
|
const matchedComponents = result.matchedComponents || [];
|
|
5864
5852
|
const layoutTitle = result.layoutTitle || "Dashboard";
|
|
5865
5853
|
const layoutDescription = result.layoutDescription || "Multi-component dashboard";
|
|
5866
|
-
logger.info(`[${this.getProviderName()}] \u{1F4CA} Component Suggestions from Text Analysis: ${suggestedComponents.length}`);
|
|
5867
|
-
suggestedComponents.forEach((comp, idx) => {
|
|
5868
|
-
logger.info(`[${this.getProviderName()}] c${idx + 1}: ${comp.type} - ${comp.reasoning}`);
|
|
5869
|
-
});
|
|
5870
5854
|
logger.info(`[${this.getProviderName()}] \u{1F4E6} Matched Components from LLM: ${matchedComponents.length}`);
|
|
5871
5855
|
matchedComponents.forEach((comp, idx) => {
|
|
5872
5856
|
logger.info(`[${this.getProviderName()}] ${idx + 1}. ${comp.componentType} (${comp.componentName}) - ${comp.originalSuggestion || "N/A"}`);
|
|
@@ -5874,22 +5858,7 @@ ${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")
|
|
|
5874
5858
|
logger.file("\n=============================\nFull LLM response:", JSON.stringify(result, null, 2));
|
|
5875
5859
|
const rawActions = result.actions || [];
|
|
5876
5860
|
const actions = convertQuestionsToActions(rawActions);
|
|
5877
|
-
logger.info(`[${this.getProviderName()}] Matched ${matchedComponents.length} components from text response`);
|
|
5878
|
-
logger.info(`[${this.getProviderName()}] Layout title: "${layoutTitle}"`);
|
|
5879
|
-
logger.info(`[${this.getProviderName()}] Layout description: "${layoutDescription}"`);
|
|
5880
|
-
logger.info(`[${this.getProviderName()}] Generated ${actions.length} follow-up actions`);
|
|
5881
|
-
if (suggestedComponents.length > 0) {
|
|
5882
|
-
logCollector?.info(`\u{1F4DD} Text Analysis suggested ${suggestedComponents.length} dashboard components:`);
|
|
5883
|
-
suggestedComponents.forEach((comp, idx) => {
|
|
5884
|
-
logCollector?.info(` c${idx + 1}: ${comp.type} - ${comp.reasoning}`);
|
|
5885
|
-
});
|
|
5886
|
-
}
|
|
5887
5861
|
if (matchedComponents.length > 0) {
|
|
5888
|
-
logCollector?.info(`\u{1F4E6} Matched ${matchedComponents.length} components for dashboard`);
|
|
5889
|
-
if (suggestedComponents.length !== matchedComponents.length) {
|
|
5890
|
-
logCollector?.warn(`\u26A0\uFE0F Component count mismatch: Suggested ${suggestedComponents.length}, but matched ${matchedComponents.length}`);
|
|
5891
|
-
}
|
|
5892
|
-
logCollector?.info(`Dashboard: "${layoutTitle}"`);
|
|
5893
5862
|
matchedComponents.forEach((comp, idx) => {
|
|
5894
5863
|
logCollector?.info(` ${idx + 1}. ${comp.componentName} (${comp.componentType}): ${comp.reasoning}`);
|
|
5895
5864
|
if (comp.props?.query) {
|
|
@@ -5901,23 +5870,37 @@ ${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")
|
|
|
5901
5870
|
}
|
|
5902
5871
|
});
|
|
5903
5872
|
}
|
|
5904
|
-
if (actions.length > 0) {
|
|
5905
|
-
logCollector?.info(`Generated ${actions.length} follow-up questions`);
|
|
5906
|
-
actions.forEach((action, idx) => {
|
|
5907
|
-
logCollector?.info(` ${idx + 1}. ${action.name}`);
|
|
5908
|
-
});
|
|
5909
|
-
}
|
|
5910
5873
|
const finalComponents = matchedComponents.map((mc) => {
|
|
5911
5874
|
const originalComponent = components.find((c) => c.id === mc.componentId);
|
|
5912
5875
|
if (!originalComponent) {
|
|
5913
5876
|
logger.warn(`[${this.getProviderName()}] Component ${mc.componentId} not found in available components`);
|
|
5914
5877
|
return null;
|
|
5915
5878
|
}
|
|
5879
|
+
let cleanedProps = { ...mc.props };
|
|
5880
|
+
if (cleanedProps.externalTool) {
|
|
5881
|
+
const toolId = cleanedProps.externalTool.toolId;
|
|
5882
|
+
const validToolIds = (executedTools || []).map((t) => t.id);
|
|
5883
|
+
const isValidTool = toolId && typeof toolId === "string" && validToolIds.includes(toolId);
|
|
5884
|
+
if (!isValidTool) {
|
|
5885
|
+
logger.warn(`[${this.getProviderName()}] externalTool.toolId "${toolId}" not found in executed tools [${validToolIds.join(", ")}], setting to null`);
|
|
5886
|
+
cleanedProps.externalTool = null;
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
if (cleanedProps.query) {
|
|
5890
|
+
const queryStr = typeof cleanedProps.query === "string" ? cleanedProps.query : cleanedProps.query?.sql || "";
|
|
5891
|
+
if (queryStr.includes("OPENJSON") || queryStr.includes("JSON_VALUE")) {
|
|
5892
|
+
logger.warn(`[${this.getProviderName()}] Query contains OPENJSON/JSON_VALUE (invalid - cannot parse tool result), setting query to null`);
|
|
5893
|
+
cleanedProps.query = null;
|
|
5894
|
+
}
|
|
5895
|
+
}
|
|
5896
|
+
if (cleanedProps.query && cleanedProps.externalTool) {
|
|
5897
|
+
logger.info(`[${this.getProviderName()}] Both query and externalTool exist, keeping both - frontend will decide`);
|
|
5898
|
+
}
|
|
5916
5899
|
return {
|
|
5917
5900
|
...originalComponent,
|
|
5918
5901
|
props: {
|
|
5919
5902
|
...originalComponent.props,
|
|
5920
|
-
...
|
|
5903
|
+
...cleanedProps
|
|
5921
5904
|
}
|
|
5922
5905
|
};
|
|
5923
5906
|
}).filter(Boolean);
|