@superatomai/sdk-node 0.0.32-mds → 0.0.33-mds

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
@@ -7843,12 +7843,13 @@ function validateAndCleanQuery(query, config) {
7843
7843
  cleanedQuery = { ...cleanedQuery, sql: fixedQuery };
7844
7844
  }
7845
7845
  }
7846
+ const maxLimit = config.maxLimit ?? MAX_AGENT_QUERY_LIMIT;
7846
7847
  if (typeof cleanedQuery === "string") {
7847
- const limitedQuery = ensureQueryLimit(cleanedQuery, config.defaultLimit, MAX_AGENT_QUERY_LIMIT);
7848
+ const limitedQuery = ensureQueryLimit(cleanedQuery, config.defaultLimit, maxLimit);
7848
7849
  if (limitedQuery !== cleanedQuery) wasModified = true;
7849
7850
  cleanedQuery = limitedQuery;
7850
7851
  } else if (cleanedQuery?.sql) {
7851
- const limitedSql = ensureQueryLimit(cleanedQuery.sql, config.defaultLimit, MAX_AGENT_QUERY_LIMIT);
7852
+ const limitedSql = ensureQueryLimit(cleanedQuery.sql, config.defaultLimit, maxLimit);
7852
7853
  if (limitedSql !== cleanedQuery.sql) wasModified = true;
7853
7854
  cleanedQuery = { ...cleanedQuery, sql: limitedSql };
7854
7855
  }
@@ -8004,7 +8005,7 @@ ${executedToolsText}`);
8004
8005
  const cleanedProps = processComponentProps(
8005
8006
  mc.props,
8006
8007
  executedTools,
8007
- { providerName: "AgentComponentGen", defaultLimit: 10 }
8008
+ { providerName: "AgentComponentGen", defaultLimit: DEFAULT_QUERY_LIMIT, maxLimit: MAX_COMPONENT_QUERY_LIMIT }
8008
8009
  );
8009
8010
  return {
8010
8011
  ...originalComponent,
@@ -8143,10 +8144,16 @@ function tryStreamAnswerComponent(text, components, executedTools, collections,
8143
8144
  props: { ...original.props, ...answerData.props }
8144
8145
  };
8145
8146
  const answerProps = answerComponent.props;
8146
- const sql = answerProps?.externalTool?.parameters?.sql;
8147
+ let sql = answerProps?.externalTool?.parameters?.sql;
8147
8148
  if (sql && collections?.["external-tools"]?.["execute"]) {
8148
8149
  const toolId = answerProps.externalTool.toolId;
8149
8150
  const toolName = answerProps.externalTool.toolName;
8151
+ const executedTool = executedTools.find((t) => t.id === toolId);
8152
+ const dbType = executedTool?.sourceType;
8153
+ if (dbType) {
8154
+ sql = ensureQueryLimit(sql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, dbType);
8155
+ answerProps.externalTool.parameters.sql = sql;
8156
+ }
8150
8157
  (async () => {
8151
8158
  try {
8152
8159
  const result = await collections["external-tools"]["execute"]({
@@ -8249,7 +8256,7 @@ async function validateSingleExternalToolQuery(component, collections, executedT
8249
8256
  const executedTool = executedTools.find((t) => t.id === toolId);
8250
8257
  const dbType = executedTool?.sourceType;
8251
8258
  if (dbType) {
8252
- currentSql = ensureQueryLimit(currentSql, 10, MAX_AGENT_QUERY_LIMIT, dbType);
8259
+ currentSql = ensureQueryLimit(currentSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, dbType);
8253
8260
  }
8254
8261
  let attempts = 0;
8255
8262
  while (attempts < MAX_QUERY_VALIDATION_RETRIES) {
@@ -8300,7 +8307,7 @@ async function validateSingleExternalToolQuery(component, collections, executedT
8300
8307
  apiKey
8301
8308
  );
8302
8309
  if (fixedSql && fixedSql !== currentSql) {
8303
- currentSql = dbType ? ensureQueryLimit(fixedSql, 10, MAX_AGENT_QUERY_LIMIT, dbType) : fixedSql;
8310
+ currentSql = dbType ? ensureQueryLimit(fixedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, dbType) : fixedSql;
8304
8311
  logger.info(`[AgentComponentGen] LLM provided fix for ${component.name}, retrying...`);
8305
8312
  } else {
8306
8313
  logger.warn(`[AgentComponentGen] LLM returned same or empty query, stopping retries`);