@superatomai/sdk-node 0.0.59 → 0.0.61

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) {
@@ -2477,7 +2494,13 @@ var ArtifactsRequestPayloadSchema = z3.object({
2477
2494
  limit: z3.number().optional(),
2478
2495
  // Query operation fields
2479
2496
  filters: ArtifactsQueryFiltersSchema.optional(),
2480
- sort: z3.enum(["ASC", "DESC"]).optional()
2497
+ sort: z3.enum(["ASC", "DESC"]).optional(),
2498
+ // Menu grouping fields
2499
+ type: z3.string().optional(),
2500
+ menuId: z3.number().optional(),
2501
+ artifactGroupName: z3.string().optional(),
2502
+ artifactGroupId: z3.string().optional(),
2503
+ artifactGroupIcon: z3.string().optional()
2481
2504
  }).optional()
2482
2505
  });
2483
2506
  var ArtifactsRequestMessageSchema = z3.object({
@@ -2554,7 +2577,9 @@ var MenusRequestPayloadSchema = z3.object({
2554
2577
  items: z3.array(z3.object({
2555
2578
  id: z3.number(),
2556
2579
  sortOrder: z3.number()
2557
- })).optional()
2580
+ })).optional(),
2581
+ menuJson: z3.record(z3.unknown()).optional(),
2582
+ version: z3.number().optional()
2558
2583
  }).optional()
2559
2584
  });
2560
2585
  var MenusRequestMessageSchema = z3.object({
@@ -6681,7 +6706,13 @@ ${executedToolsText}`);
6681
6706
  (t) => t.executionType === "immediate" || t.executionType === "deferred" && t.userProvidedData
6682
6707
  );
6683
6708
  logger.info(`[${this.getProviderName()}] Executable tools: ${executableTools.length} of ${externalTools.length} total`);
6709
+ const addedToolIds = /* @__PURE__ */ new Set();
6684
6710
  executableTools.forEach((tool) => {
6711
+ if (addedToolIds.has(tool.id)) {
6712
+ logger.info(`[${this.getProviderName()}] Skipping duplicate tool definition: ${tool.id} (already added)`);
6713
+ return;
6714
+ }
6715
+ addedToolIds.add(tool.id);
6685
6716
  logger.info(`[${this.getProviderName()}] Processing executable tool:`, JSON.stringify(tool, null, 2));
6686
6717
  const properties = {};
6687
6718
  const required = [];
@@ -6751,7 +6782,7 @@ ${executedToolsText}`);
6751
6782
  input_schema: inputSchema
6752
6783
  });
6753
6784
  });
6754
- logger.info(`[${this.getProviderName()}] Added ${executableTools.length} executable tools to tool calling capability (${externalTools.length - executableTools.length} deferred tools await form input)`);
6785
+ 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
6786
  logger.info(`[${this.getProviderName()}] Complete tools array:`, JSON.stringify(tools, null, 2));
6756
6787
  }
6757
6788
  const queryAttempts = /* @__PURE__ */ new Map();
@@ -10528,6 +10559,7 @@ async function handleArtifactsRequest(data, collections, sendMessage) {
10528
10559
  const request = ArtifactsRequestMessageSchema.parse(data);
10529
10560
  const { id, payload, from } = request;
10530
10561
  const { operation, data: requestData } = payload;
10562
+ logger.info("[SDK-NODEJS] Received artifacts request:", JSON.stringify({ operation, requestData }, null, 2));
10531
10563
  const artifactId = requestData?.id;
10532
10564
  const name = requestData?.name;
10533
10565
  const createdBy = requestData?.createdBy;
@@ -10537,9 +10569,22 @@ async function handleArtifactsRequest(data, collections, sendMessage) {
10537
10569
  const limit = requestData?.limit;
10538
10570
  const filters = requestData?.filters;
10539
10571
  const sort = requestData?.sort;
10572
+ const type = requestData?.type;
10573
+ const menuId = requestData?.menuId;
10574
+ const artifactGroupName = requestData?.artifactGroupName;
10575
+ const artifactGroupId = requestData?.artifactGroupId;
10576
+ const artifactGroupIcon = requestData?.artifactGroupIcon;
10577
+ logger.info("[SDK-NODEJS] Extracted params for create:", JSON.stringify({
10578
+ name,
10579
+ type,
10580
+ menuId,
10581
+ artifactGroupName,
10582
+ artifactGroupId,
10583
+ artifactGroupIcon
10584
+ }, null, 2));
10540
10585
  switch (operation) {
10541
10586
  case "create":
10542
- await handleCreate6(id, name, createdBy, dsl, status, executeCollection, sendMessage, from.id);
10587
+ await handleCreate6(id, name, createdBy, dsl, status, type, menuId, artifactGroupName, artifactGroupId, artifactGroupIcon, executeCollection, sendMessage, from.id);
10543
10588
  break;
10544
10589
  case "update":
10545
10590
  await handleUpdate6(id, artifactId, name, dsl, status, deleted, executeCollection, sendMessage, from.id);
@@ -10570,7 +10615,7 @@ async function handleArtifactsRequest(data, collections, sendMessage) {
10570
10615
  }, sendMessage);
10571
10616
  }
10572
10617
  }
10573
- async function handleCreate6(id, name, createdBy, dsl, status, executeCollection, sendMessage, clientId) {
10618
+ async function handleCreate6(id, name, createdBy, dsl, status, type, menuId, artifactGroupName, artifactGroupId, artifactGroupIcon, executeCollection, sendMessage, clientId) {
10574
10619
  if (!name) {
10575
10620
  sendResponse8(id, {
10576
10621
  success: false,
@@ -10579,7 +10624,17 @@ async function handleCreate6(id, name, createdBy, dsl, status, executeCollection
10579
10624
  return;
10580
10625
  }
10581
10626
  try {
10582
- const result = await executeCollection("artifacts", "create", { name, createdBy, dsl, status });
10627
+ const result = await executeCollection("artifacts", "create", {
10628
+ name,
10629
+ createdBy,
10630
+ dsl,
10631
+ status,
10632
+ type,
10633
+ menuId,
10634
+ artifactGroupName,
10635
+ artifactGroupId,
10636
+ artifactGroupIcon
10637
+ });
10583
10638
  sendResponse8(id, {
10584
10639
  success: true,
10585
10640
  data: result.data,