@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.mjs
CHANGED
|
@@ -5670,26 +5670,22 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
|
|
|
5670
5670
|
if (executedTools && executedTools.length > 0) {
|
|
5671
5671
|
logger.info(`[${this.getProviderName()}] Passing ${executedTools.length} executed tools to component matching`);
|
|
5672
5672
|
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) => {
|
|
5673
|
-
let resultPreview = "No result data";
|
|
5674
|
-
if (tool.result) {
|
|
5675
|
-
const resultStr = typeof tool.result === "string" ? tool.result : JSON.stringify(tool.result, null, 2);
|
|
5676
|
-
resultPreview = resultStr.length > 2e3 ? resultStr.substring(0, 2e3) + "\n... (truncated)" : resultStr;
|
|
5677
|
-
}
|
|
5678
5673
|
let outputSchemaText = "Not available";
|
|
5674
|
+
let recordCount = "unknown";
|
|
5679
5675
|
if (tool.outputSchema) {
|
|
5680
5676
|
const fields = tool.outputSchema.fields || [];
|
|
5681
|
-
|
|
5682
|
-
outputSchemaText =
|
|
5683
|
-
Fields in EACH ROW (
|
|
5684
|
-
${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")}
|
|
5685
|
-
NOTE: For aggregate values (SUM, COUNT, AVG across all rows), write SQL query instead.`;
|
|
5677
|
+
recordCount = tool.result?._recordCount || (Array.isArray(tool.result) ? tool.result.length : "unknown");
|
|
5678
|
+
outputSchemaText = `${tool.outputSchema.description}
|
|
5679
|
+
Fields in EACH ROW (per-row values, NOT aggregates):
|
|
5680
|
+
${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")}`;
|
|
5686
5681
|
}
|
|
5687
5682
|
return `${idx + 1}. **${tool.name}**
|
|
5688
5683
|
toolId: "${tool.id}" (USE THIS EXACT VALUE for externalTool.toolId)
|
|
5689
5684
|
toolName: "${tool.name}" (USE THIS EXACT VALUE for externalTool.toolName)
|
|
5690
5685
|
parameters: ${JSON.stringify(tool.params || {})} (USE THESE for externalTool.parameters)
|
|
5686
|
+
recordCount: ${recordCount} rows returned
|
|
5691
5687
|
outputSchema: ${outputSchemaText}
|
|
5692
|
-
|
|
5688
|
+
\u26A0\uFE0F DO NOT embed this tool's data in SQL - use externalTool prop OR query database tables`;
|
|
5693
5689
|
}).join("\n\n");
|
|
5694
5690
|
}
|
|
5695
5691
|
const schemaDoc = schema.generateSchemaDocumentation();
|
|
@@ -5830,11 +5826,31 @@ ${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")
|
|
|
5830
5826
|
logger.warn(`[${this.getProviderName()}] Component ${mc.componentId} not found in available components`);
|
|
5831
5827
|
return null;
|
|
5832
5828
|
}
|
|
5829
|
+
let cleanedProps = { ...mc.props };
|
|
5830
|
+
if (cleanedProps.externalTool) {
|
|
5831
|
+
const toolId = cleanedProps.externalTool.toolId;
|
|
5832
|
+
const validToolIds = (executedTools || []).map((t) => t.id);
|
|
5833
|
+
const isValidTool = toolId && typeof toolId === "string" && validToolIds.includes(toolId);
|
|
5834
|
+
if (!isValidTool) {
|
|
5835
|
+
logger.warn(`[${this.getProviderName()}] externalTool.toolId "${toolId}" not found in executed tools [${validToolIds.join(", ")}], setting to null`);
|
|
5836
|
+
cleanedProps.externalTool = null;
|
|
5837
|
+
}
|
|
5838
|
+
}
|
|
5839
|
+
if (cleanedProps.query) {
|
|
5840
|
+
const queryStr = typeof cleanedProps.query === "string" ? cleanedProps.query : cleanedProps.query?.sql || "";
|
|
5841
|
+
if (queryStr.includes("OPENJSON") || queryStr.includes("JSON_VALUE")) {
|
|
5842
|
+
logger.warn(`[${this.getProviderName()}] Query contains OPENJSON/JSON_VALUE (invalid - cannot parse tool result), setting query to null`);
|
|
5843
|
+
cleanedProps.query = null;
|
|
5844
|
+
}
|
|
5845
|
+
}
|
|
5846
|
+
if (cleanedProps.query && cleanedProps.externalTool) {
|
|
5847
|
+
logger.info(`[${this.getProviderName()}] Both query and externalTool exist, keeping both - frontend will decide`);
|
|
5848
|
+
}
|
|
5833
5849
|
return {
|
|
5834
5850
|
...originalComponent,
|
|
5835
5851
|
props: {
|
|
5836
5852
|
...originalComponent.props,
|
|
5837
|
-
...
|
|
5853
|
+
...cleanedProps
|
|
5838
5854
|
}
|
|
5839
5855
|
};
|
|
5840
5856
|
}).filter(Boolean);
|