@superatomai/sdk-node 0.0.59 → 0.0.60

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.mjs CHANGED
@@ -1885,6 +1885,23 @@ function validateAndFixSqlQuery(query, dbType) {
1885
1885
  }
1886
1886
  fixes.push(`Added ${missingClose} missing closing parenthesis(es)`);
1887
1887
  }
1888
+ const subqueryOrderByPattern = /\(\s*SELECT\s+(?!TOP\s)([^()]*?)\s+ORDER\s+BY\s+[^()]+\)/gi;
1889
+ let subqueryMatch;
1890
+ let subqueryFixed = false;
1891
+ while ((subqueryMatch = subqueryOrderByPattern.exec(fixedQuery)) !== null) {
1892
+ const fullMatch = subqueryMatch[0];
1893
+ if (!/\bTOP\s+\d+/i.test(fullMatch) && !/\bOFFSET\b/i.test(fullMatch)) {
1894
+ const fixedSubquery = fullMatch.replace(
1895
+ /\(\s*SELECT\s+/i,
1896
+ "(SELECT TOP 100 "
1897
+ );
1898
+ fixedQuery = fixedQuery.replace(fullMatch, fixedSubquery);
1899
+ subqueryFixed = true;
1900
+ }
1901
+ }
1902
+ if (subqueryFixed) {
1903
+ fixes.push("Added TOP to subquery with ORDER BY (MSSQL requirement)");
1904
+ }
1888
1905
  const originalLength = fixedQuery.length;
1889
1906
  fixedQuery = fixedQuery.replace(/\s+/g, " ").trim();
1890
1907
  if (fixedQuery.length !== originalLength) {
@@ -6681,7 +6698,13 @@ ${executedToolsText}`);
6681
6698
  (t) => t.executionType === "immediate" || t.executionType === "deferred" && t.userProvidedData
6682
6699
  );
6683
6700
  logger.info(`[${this.getProviderName()}] Executable tools: ${executableTools.length} of ${externalTools.length} total`);
6701
+ const addedToolIds = /* @__PURE__ */ new Set();
6684
6702
  executableTools.forEach((tool) => {
6703
+ if (addedToolIds.has(tool.id)) {
6704
+ logger.info(`[${this.getProviderName()}] Skipping duplicate tool definition: ${tool.id} (already added)`);
6705
+ return;
6706
+ }
6707
+ addedToolIds.add(tool.id);
6685
6708
  logger.info(`[${this.getProviderName()}] Processing executable tool:`, JSON.stringify(tool, null, 2));
6686
6709
  const properties = {};
6687
6710
  const required = [];
@@ -6751,7 +6774,7 @@ ${executedToolsText}`);
6751
6774
  input_schema: inputSchema
6752
6775
  });
6753
6776
  });
6754
- logger.info(`[${this.getProviderName()}] Added ${executableTools.length} executable tools to tool calling capability (${externalTools.length - executableTools.length} deferred tools await form input)`);
6777
+ logger.info(`[${this.getProviderName()}] Added ${addedToolIds.size} unique tool definitions from ${executableTools.length} tool calls (${externalTools.length - executableTools.length} deferred tools await form input)`);
6755
6778
  logger.info(`[${this.getProviderName()}] Complete tools array:`, JSON.stringify(tools, null, 2));
6756
6779
  }
6757
6780
  const queryAttempts = /* @__PURE__ */ new Map();