@superatomai/sdk-node 0.0.49 → 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 +28 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5720,26 +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 || [];
|
|
5731
|
-
|
|
5732
|
-
outputSchemaText =
|
|
5733
|
-
Fields in EACH ROW (
|
|
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.`;
|
|
5727
|
+
recordCount = tool.result?._recordCount || (Array.isArray(tool.result) ? tool.result.length : "unknown");
|
|
5728
|
+
outputSchemaText = `${tool.outputSchema.description}
|
|
5729
|
+
Fields in EACH ROW (per-row values, NOT aggregates):
|
|
5730
|
+
${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")}`;
|
|
5736
5731
|
}
|
|
5737
5732
|
return `${idx + 1}. **${tool.name}**
|
|
5738
5733
|
toolId: "${tool.id}" (USE THIS EXACT VALUE for externalTool.toolId)
|
|
5739
5734
|
toolName: "${tool.name}" (USE THIS EXACT VALUE for externalTool.toolName)
|
|
5740
5735
|
parameters: ${JSON.stringify(tool.params || {})} (USE THESE for externalTool.parameters)
|
|
5736
|
+
recordCount: ${recordCount} rows returned
|
|
5741
5737
|
outputSchema: ${outputSchemaText}
|
|
5742
|
-
|
|
5738
|
+
\u26A0\uFE0F DO NOT embed this tool's data in SQL - use externalTool prop OR query database tables`;
|
|
5743
5739
|
}).join("\n\n");
|
|
5744
5740
|
}
|
|
5745
5741
|
const schemaDoc = schema.generateSchemaDocumentation();
|
|
@@ -5880,11 +5876,31 @@ ${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")
|
|
|
5880
5876
|
logger.warn(`[${this.getProviderName()}] Component ${mc.componentId} not found in available components`);
|
|
5881
5877
|
return null;
|
|
5882
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
|
+
}
|
|
5883
5899
|
return {
|
|
5884
5900
|
...originalComponent,
|
|
5885
5901
|
props: {
|
|
5886
5902
|
...originalComponent.props,
|
|
5887
|
-
...
|
|
5903
|
+
...cleanedProps
|
|
5888
5904
|
}
|
|
5889
5905
|
};
|
|
5890
5906
|
}).filter(Boolean);
|