@superatomai/sdk-node 0.0.27-mds → 0.0.28-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.d.mts CHANGED
@@ -2637,8 +2637,10 @@ interface SourceAgentResult {
2637
2637
  data: any[];
2638
2638
  /** Metadata about the query execution */
2639
2639
  metadata: SourceAgentMetadata;
2640
- /** Tool execution info (reused for component generation) */
2640
+ /** Tool execution info for the last successful query (backward compat) */
2641
2641
  executedTool: ExecutedToolInfo;
2642
+ /** All successful tool executions (primary + follow-up queries) */
2643
+ allExecutedTools?: ExecutedToolInfo[];
2642
2644
  /** Error message if failed */
2643
2645
  error?: string;
2644
2646
  }
package/dist/index.d.ts CHANGED
@@ -2637,8 +2637,10 @@ interface SourceAgentResult {
2637
2637
  data: any[];
2638
2638
  /** Metadata about the query execution */
2639
2639
  metadata: SourceAgentMetadata;
2640
- /** Tool execution info (reused for component generation) */
2640
+ /** Tool execution info for the last successful query (backward compat) */
2641
2641
  executedTool: ExecutedToolInfo;
2642
+ /** All successful tool executions (primary + follow-up queries) */
2643
+ allExecutedTools?: ExecutedToolInfo[];
2642
2644
  /** Error message if failed */
2643
2645
  error?: string;
2644
2646
  }
package/dist/index.js CHANGED
@@ -1362,13 +1362,15 @@ var Thread = class {
1362
1362
  if (metadata.description) {
1363
1363
  parts.push(`Description: ${metadata.description}`);
1364
1364
  }
1365
- if (metadata.props) {
1366
- parts.push(`Props: ${JSON.stringify(metadata.props)}`);
1365
+ const layoutTitle = metadata.props?.config?.title;
1366
+ if (layoutTitle) {
1367
+ parts.push(`Dashboard Title: ${layoutTitle}`);
1367
1368
  }
1368
1369
  responseParts.push(parts.join("\n"));
1369
1370
  }
1370
1371
  if (hasTextResponse) {
1371
- responseParts.push(textResponse);
1372
+ const trimmedText = textResponse.length > 500 ? textResponse.substring(0, 500) + "...[truncated]" : textResponse;
1373
+ responseParts.push(trimmedText);
1372
1374
  }
1373
1375
  if (responseParts.length > 0) {
1374
1376
  assistantResponse = responseParts.join("\n");
@@ -7056,6 +7058,7 @@ var SourceAgent = class {
7056
7058
  logger.logLLMPrompt(`sourceAgent:${this.tool.name}`, "user", prompts.user);
7057
7059
  const tools = this.buildToolDefinitions();
7058
7060
  let executedTool = null;
7061
+ let allExecutedTools = [];
7059
7062
  let resultData = [];
7060
7063
  let queryExecuted;
7061
7064
  let totalRowsMatched = 0;
@@ -7184,6 +7187,7 @@ Analyze the error and try again with a corrected query.`;
7184
7187
  sourceSchema: this.tool.description,
7185
7188
  sourceType: this.extractSourceType()
7186
7189
  };
7190
+ allExecutedTools.push(executedTool);
7187
7191
  const formatted = typeof formattedResult === "string" ? formattedResult : JSON.stringify(formattedResult);
7188
7192
  const followUpNote = successfulQueries < 2 ? "You may make ONE follow-up query if this data is incomplete for the intent. Otherwise, STOP." : "Maximum queries reached. Use the data you have.";
7189
7193
  return `\u2705 Query executed successfully. ${resultData.length} rows returned (${totalRowsMatched} total matched). ${followUpNote}
@@ -7255,7 +7259,8 @@ Analyze the error and try again with a corrected query.`;
7255
7259
  queryExecuted,
7256
7260
  executionTimeMs
7257
7261
  },
7258
- executedTool
7262
+ executedTool,
7263
+ allExecutedTools
7259
7264
  };
7260
7265
  } catch (error) {
7261
7266
  const executionTimeMs = Date.now() - startTime;
@@ -7511,7 +7516,11 @@ var MainAgent = class {
7511
7516
  const result = await sourceAgent.execute(sourceInput);
7512
7517
  sourceResults.push(result);
7513
7518
  if (result.success) {
7514
- executedTools.push(result.executedTool);
7519
+ if (result.allExecutedTools && result.allExecutedTools.length > 0) {
7520
+ executedTools.push(...result.allExecutedTools);
7521
+ } else {
7522
+ executedTools.push(result.executedTool);
7523
+ }
7515
7524
  }
7516
7525
  return this.formatResultForMainAgent(result);
7517
7526
  };
@@ -8053,12 +8062,24 @@ function formatExecutedTools(executedTools) {
8053
8062
  Fields:
8054
8063
  ${fieldsText}`;
8055
8064
  }
8065
+ let sampleDataText = "";
8066
+ const sampleData = tool.result?._sampleData;
8067
+ if (Array.isArray(sampleData) && sampleData.length > 0) {
8068
+ const sampleFields = Object.keys(sampleData[0]);
8069
+ sampleDataText = `
8070
+ \u{1F511} RESULT FIELDS: ${sampleFields.join(", ")}`;
8071
+ try {
8072
+ sampleDataText += `
8073
+ \u{1F4C4} SAMPLE ROW: ${JSON.stringify(sampleData[0])}`;
8074
+ } catch {
8075
+ }
8076
+ }
8056
8077
  return `${idx + 1}. **${tool.name}**
8057
8078
  toolId: "${tool.id}"
8058
8079
  toolName: "${tool.name}"
8059
8080
  parameters: ${JSON.stringify(tool.params || {})}
8060
8081
  recordCount: ${recordCount} rows returned${metadataText}
8061
- outputSchema: ${outputSchemaText}${fieldNamesList}`;
8082
+ outputSchema: ${outputSchemaText}${fieldNamesList}${sampleDataText}`;
8062
8083
  }).join("\n\n");
8063
8084
  }
8064
8085
  function tryStreamAnswerComponent(text, components, executedTools, collections, apiKey, callback) {
@@ -10453,7 +10474,7 @@ var get_agent_user_response = async (prompt, components, anthropicApiKey, groqAp
10453
10474
  streamBuffer.hasCallback() ? (chunk) => streamBuffer.write(chunk) : void 0
10454
10475
  );
10455
10476
  const rawText = streamBuffer.getFullText() || agentResponse.text || "I apologize, but I was unable to generate a response.";
10456
- const textResponse = rawText.replace(/__SB_\w+_(?:START|MSG)__/g, "").replace(/__SB_END__/g, "").replace(/__QUERY_TIMER_START_[^_]*__/g, "").replace(/__QUERY_TIMER_DONE_[\d.]+__/g, "").replace(/__TEXT_COMPLETE__COMPONENT_GENERATION_START__/g, "");
10477
+ const textResponse = rawText.replace(/_?_?SB_END_?_?/g, "").replace(/__SB_\w+_(?:START|MSG)_?_?/g, "").replace(/__QUERY_TIMER_START_[^_]*__/g, "").replace(/__QUERY_TIMER_DONE_[\d.]+__/g, "").replace(/__TEXT_COMPLETE__COMPONENT_GENERATION_START__/g, "").replace(/\[COMPLEXITY:\s*(?:simple|medium|complex)\]/gi, "");
10457
10478
  streamBuffer.flush();
10458
10479
  const hasExecutedTools = agentResponse.executedTools.length > 0;
10459
10480
  let matchedComponents = [];
@@ -10496,12 +10517,12 @@ var get_agent_user_response = async (prompt, components, anthropicApiKey, groqAp
10496
10517
  streamBuffer.write(answerMarker);
10497
10518
  streamBuffer.flush();
10498
10519
  } : void 0;
10499
- const sanitizedTextResponse = textResponse.replace(
10520
+ const cleanAnalysis = (agentResponse.text || textResponse).replace(/__SB_\w+_(?:START|MSG)_?_?/g, "").replace(/_?_?SB_END_?_?/g, "").replace(/__QUERY_TIMER_START_[^_]*__/g, "").replace(/__QUERY_TIMER_DONE_[\d.]+__/g, "").replace(/\[COMPLEXITY:\s*(?:simple|medium|complex)\]/gi, "").replace(
10500
10521
  /<DataTable>[\s\S]*?<\/DataTable>/g,
10501
- "<DataTable>[Data preview removed - for table components, REUSE the exact SQL query shown above (the one that returned these results). Do NOT write a new query or embed data in props.]</DataTable>"
10522
+ "<DataTable>[Data preview removed - for table components, REUSE the exact SQL from EXECUTED_TOOLS parameters. Do NOT write a new query or embed data in props.]</DataTable>"
10502
10523
  );
10503
10524
  const matchResult = await generateAgentComponents({
10504
- analysisContent: sanitizedTextResponse,
10525
+ analysisContent: cleanAnalysis,
10505
10526
  components,
10506
10527
  userPrompt: prompt,
10507
10528
  executedTools: agentResponse.executedTools,