@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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +31 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1302,13 +1302,15 @@ var Thread = class {
|
|
|
1302
1302
|
if (metadata.description) {
|
|
1303
1303
|
parts.push(`Description: ${metadata.description}`);
|
|
1304
1304
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1305
|
+
const layoutTitle = metadata.props?.config?.title;
|
|
1306
|
+
if (layoutTitle) {
|
|
1307
|
+
parts.push(`Dashboard Title: ${layoutTitle}`);
|
|
1307
1308
|
}
|
|
1308
1309
|
responseParts.push(parts.join("\n"));
|
|
1309
1310
|
}
|
|
1310
1311
|
if (hasTextResponse) {
|
|
1311
|
-
|
|
1312
|
+
const trimmedText = textResponse.length > 500 ? textResponse.substring(0, 500) + "...[truncated]" : textResponse;
|
|
1313
|
+
responseParts.push(trimmedText);
|
|
1312
1314
|
}
|
|
1313
1315
|
if (responseParts.length > 0) {
|
|
1314
1316
|
assistantResponse = responseParts.join("\n");
|
|
@@ -6996,6 +6998,7 @@ var SourceAgent = class {
|
|
|
6996
6998
|
logger.logLLMPrompt(`sourceAgent:${this.tool.name}`, "user", prompts.user);
|
|
6997
6999
|
const tools = this.buildToolDefinitions();
|
|
6998
7000
|
let executedTool = null;
|
|
7001
|
+
let allExecutedTools = [];
|
|
6999
7002
|
let resultData = [];
|
|
7000
7003
|
let queryExecuted;
|
|
7001
7004
|
let totalRowsMatched = 0;
|
|
@@ -7124,6 +7127,7 @@ Analyze the error and try again with a corrected query.`;
|
|
|
7124
7127
|
sourceSchema: this.tool.description,
|
|
7125
7128
|
sourceType: this.extractSourceType()
|
|
7126
7129
|
};
|
|
7130
|
+
allExecutedTools.push(executedTool);
|
|
7127
7131
|
const formatted = typeof formattedResult === "string" ? formattedResult : JSON.stringify(formattedResult);
|
|
7128
7132
|
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.";
|
|
7129
7133
|
return `\u2705 Query executed successfully. ${resultData.length} rows returned (${totalRowsMatched} total matched). ${followUpNote}
|
|
@@ -7195,7 +7199,8 @@ Analyze the error and try again with a corrected query.`;
|
|
|
7195
7199
|
queryExecuted,
|
|
7196
7200
|
executionTimeMs
|
|
7197
7201
|
},
|
|
7198
|
-
executedTool
|
|
7202
|
+
executedTool,
|
|
7203
|
+
allExecutedTools
|
|
7199
7204
|
};
|
|
7200
7205
|
} catch (error) {
|
|
7201
7206
|
const executionTimeMs = Date.now() - startTime;
|
|
@@ -7451,7 +7456,11 @@ var MainAgent = class {
|
|
|
7451
7456
|
const result = await sourceAgent.execute(sourceInput);
|
|
7452
7457
|
sourceResults.push(result);
|
|
7453
7458
|
if (result.success) {
|
|
7454
|
-
|
|
7459
|
+
if (result.allExecutedTools && result.allExecutedTools.length > 0) {
|
|
7460
|
+
executedTools.push(...result.allExecutedTools);
|
|
7461
|
+
} else {
|
|
7462
|
+
executedTools.push(result.executedTool);
|
|
7463
|
+
}
|
|
7455
7464
|
}
|
|
7456
7465
|
return this.formatResultForMainAgent(result);
|
|
7457
7466
|
};
|
|
@@ -7993,12 +8002,24 @@ function formatExecutedTools(executedTools) {
|
|
|
7993
8002
|
Fields:
|
|
7994
8003
|
${fieldsText}`;
|
|
7995
8004
|
}
|
|
8005
|
+
let sampleDataText = "";
|
|
8006
|
+
const sampleData = tool.result?._sampleData;
|
|
8007
|
+
if (Array.isArray(sampleData) && sampleData.length > 0) {
|
|
8008
|
+
const sampleFields = Object.keys(sampleData[0]);
|
|
8009
|
+
sampleDataText = `
|
|
8010
|
+
\u{1F511} RESULT FIELDS: ${sampleFields.join(", ")}`;
|
|
8011
|
+
try {
|
|
8012
|
+
sampleDataText += `
|
|
8013
|
+
\u{1F4C4} SAMPLE ROW: ${JSON.stringify(sampleData[0])}`;
|
|
8014
|
+
} catch {
|
|
8015
|
+
}
|
|
8016
|
+
}
|
|
7996
8017
|
return `${idx + 1}. **${tool.name}**
|
|
7997
8018
|
toolId: "${tool.id}"
|
|
7998
8019
|
toolName: "${tool.name}"
|
|
7999
8020
|
parameters: ${JSON.stringify(tool.params || {})}
|
|
8000
8021
|
recordCount: ${recordCount} rows returned${metadataText}
|
|
8001
|
-
outputSchema: ${outputSchemaText}${fieldNamesList}`;
|
|
8022
|
+
outputSchema: ${outputSchemaText}${fieldNamesList}${sampleDataText}`;
|
|
8002
8023
|
}).join("\n\n");
|
|
8003
8024
|
}
|
|
8004
8025
|
function tryStreamAnswerComponent(text, components, executedTools, collections, apiKey, callback) {
|
|
@@ -10393,7 +10414,7 @@ var get_agent_user_response = async (prompt, components, anthropicApiKey, groqAp
|
|
|
10393
10414
|
streamBuffer.hasCallback() ? (chunk) => streamBuffer.write(chunk) : void 0
|
|
10394
10415
|
);
|
|
10395
10416
|
const rawText = streamBuffer.getFullText() || agentResponse.text || "I apologize, but I was unable to generate a response.";
|
|
10396
|
-
const textResponse = rawText.replace(/__SB_\w+_(?:START|MSG)
|
|
10417
|
+
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, "");
|
|
10397
10418
|
streamBuffer.flush();
|
|
10398
10419
|
const hasExecutedTools = agentResponse.executedTools.length > 0;
|
|
10399
10420
|
let matchedComponents = [];
|
|
@@ -10436,12 +10457,12 @@ var get_agent_user_response = async (prompt, components, anthropicApiKey, groqAp
|
|
|
10436
10457
|
streamBuffer.write(answerMarker);
|
|
10437
10458
|
streamBuffer.flush();
|
|
10438
10459
|
} : void 0;
|
|
10439
|
-
const
|
|
10460
|
+
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(
|
|
10440
10461
|
/<DataTable>[\s\S]*?<\/DataTable>/g,
|
|
10441
|
-
"<DataTable>[Data preview removed - for table components, REUSE the exact SQL
|
|
10462
|
+
"<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>"
|
|
10442
10463
|
);
|
|
10443
10464
|
const matchResult = await generateAgentComponents({
|
|
10444
|
-
analysisContent:
|
|
10465
|
+
analysisContent: cleanAnalysis,
|
|
10445
10466
|
components,
|
|
10446
10467
|
userPrompt: prompt,
|
|
10447
10468
|
executedTools: agentResponse.executedTools,
|