@superatomai/sdk-node 0.0.50 → 0.0.52
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 +87 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5675,9 +5675,14 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
|
|
|
5675
5675
|
if (tool.outputSchema) {
|
|
5676
5676
|
const fields = tool.outputSchema.fields || [];
|
|
5677
5677
|
recordCount = tool.result?._recordCount || (Array.isArray(tool.result) ? tool.result.length : "unknown");
|
|
5678
|
+
const fieldsText = fields.map(
|
|
5679
|
+
(f) => ` - name: "${f.name}" \u2190 USE THIS EXACT VALUE in config
|
|
5680
|
+
type: ${f.type}
|
|
5681
|
+
description: ${f.description}`
|
|
5682
|
+
).join("\n");
|
|
5678
5683
|
outputSchemaText = `${tool.outputSchema.description}
|
|
5679
|
-
Fields
|
|
5680
|
-
${
|
|
5684
|
+
Fields (use the "name" value in your config):
|
|
5685
|
+
${fieldsText}`;
|
|
5681
5686
|
}
|
|
5682
5687
|
return `${idx + 1}. **${tool.name}**
|
|
5683
5688
|
toolId: "${tool.id}" (USE THIS EXACT VALUE for externalTool.toolId)
|
|
@@ -5834,6 +5839,86 @@ ${fields.map((f) => ` - ${f.name} (${f.type}): ${f.description}`).join("\n")
|
|
|
5834
5839
|
if (!isValidTool) {
|
|
5835
5840
|
logger.warn(`[${this.getProviderName()}] externalTool.toolId "${toolId}" not found in executed tools [${validToolIds.join(", ")}], setting to null`);
|
|
5836
5841
|
cleanedProps.externalTool = null;
|
|
5842
|
+
} else {
|
|
5843
|
+
const executedTool = executedTools?.find((t) => t.id === toolId);
|
|
5844
|
+
if (executedTool?.outputSchema?.fields && cleanedProps.config) {
|
|
5845
|
+
const validFieldNames = executedTool.outputSchema.fields.map((f) => f.name);
|
|
5846
|
+
const validFieldNamesLower = validFieldNames.map((n) => n.toLowerCase());
|
|
5847
|
+
const findMatchingField = (fieldName) => {
|
|
5848
|
+
if (!fieldName) return null;
|
|
5849
|
+
const lowerField = fieldName.toLowerCase();
|
|
5850
|
+
const exactIdx = validFieldNamesLower.indexOf(lowerField);
|
|
5851
|
+
if (exactIdx !== -1) return validFieldNames[exactIdx];
|
|
5852
|
+
const partialMatches = [];
|
|
5853
|
+
for (let i = 0; i < validFieldNames.length; i++) {
|
|
5854
|
+
const validName = validFieldNames[i];
|
|
5855
|
+
const validLower = validFieldNamesLower[i];
|
|
5856
|
+
if (validLower.endsWith(lowerField)) {
|
|
5857
|
+
const score = lowerField.length / validLower.length;
|
|
5858
|
+
partialMatches.push({ name: validName, score });
|
|
5859
|
+
continue;
|
|
5860
|
+
}
|
|
5861
|
+
if (lowerField.endsWith(validLower)) {
|
|
5862
|
+
const score = validLower.length / lowerField.length;
|
|
5863
|
+
partialMatches.push({ name: validName, score });
|
|
5864
|
+
continue;
|
|
5865
|
+
}
|
|
5866
|
+
if (validLower.endsWith(lowerField) || lowerField.length <= 5 && validLower.includes(lowerField)) {
|
|
5867
|
+
const score = lowerField.length <= 5 ? 0.3 : 0.5;
|
|
5868
|
+
partialMatches.push({ name: validName, score });
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
if (partialMatches.length > 0) {
|
|
5872
|
+
partialMatches.sort((a, b) => b.score - a.score);
|
|
5873
|
+
if (partialMatches.length === 1 || partialMatches[0].score > partialMatches[1].score + 0.1) {
|
|
5874
|
+
return partialMatches[0].name;
|
|
5875
|
+
} else {
|
|
5876
|
+
logger.warn(`[${this.getProviderName()}] Ambiguous field match for "${fieldName}": ${partialMatches.map((m) => m.name).join(", ")}`);
|
|
5877
|
+
return null;
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
return null;
|
|
5881
|
+
};
|
|
5882
|
+
const configFieldsToValidate = [
|
|
5883
|
+
"xAxisKey",
|
|
5884
|
+
"yAxisKey",
|
|
5885
|
+
"valueKey",
|
|
5886
|
+
"nameKey",
|
|
5887
|
+
"labelKey",
|
|
5888
|
+
"groupBy",
|
|
5889
|
+
"aggregationField",
|
|
5890
|
+
"seriesKey",
|
|
5891
|
+
"sizeKey",
|
|
5892
|
+
"xAggregationField",
|
|
5893
|
+
"yAggregationField"
|
|
5894
|
+
];
|
|
5895
|
+
for (const configKey of configFieldsToValidate) {
|
|
5896
|
+
const fieldValue = cleanedProps.config[configKey];
|
|
5897
|
+
if (fieldValue && typeof fieldValue === "string") {
|
|
5898
|
+
if (!validFieldNames.includes(fieldValue)) {
|
|
5899
|
+
const correctedField = findMatchingField(fieldValue);
|
|
5900
|
+
if (correctedField) {
|
|
5901
|
+
logger.warn(`[${this.getProviderName()}] Correcting config.${configKey}: "${fieldValue}" \u2192 "${correctedField}"`);
|
|
5902
|
+
cleanedProps.config[configKey] = correctedField;
|
|
5903
|
+
} else {
|
|
5904
|
+
logger.warn(`[${this.getProviderName()}] config.${configKey}="${fieldValue}" not found in outputSchema [${validFieldNames.join(", ")}]`);
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
}
|
|
5908
|
+
}
|
|
5909
|
+
if (Array.isArray(cleanedProps.config.series)) {
|
|
5910
|
+
cleanedProps.config.series = cleanedProps.config.series.map((s) => {
|
|
5911
|
+
if (s.dataKey && typeof s.dataKey === "string" && !validFieldNames.includes(s.dataKey)) {
|
|
5912
|
+
const correctedField = findMatchingField(s.dataKey);
|
|
5913
|
+
if (correctedField) {
|
|
5914
|
+
logger.warn(`[${this.getProviderName()}] Correcting series.dataKey: "${s.dataKey}" \u2192 "${correctedField}"`);
|
|
5915
|
+
return { ...s, dataKey: correctedField };
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5918
|
+
return s;
|
|
5919
|
+
});
|
|
5920
|
+
}
|
|
5921
|
+
}
|
|
5837
5922
|
}
|
|
5838
5923
|
}
|
|
5839
5924
|
if (cleanedProps.query) {
|