@superatomai/sdk-node 0.0.18-mds → 0.0.19-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.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4210,6 +4210,15 @@ var promptLoader = new PromptLoader({
|
|
|
4210
4210
|
function getDatabaseType() {
|
|
4211
4211
|
return promptLoader.getDatabaseType();
|
|
4212
4212
|
}
|
|
4213
|
+
function getDbTypeFromToolId(toolId) {
|
|
4214
|
+
if (!toolId) return getDatabaseType();
|
|
4215
|
+
const prefix = toolId.split("-")[0]?.toLowerCase();
|
|
4216
|
+
if (prefix === "mssql") return "mssql";
|
|
4217
|
+
if (prefix === "postgres" || prefix === "postgresql") return "postgresql";
|
|
4218
|
+
if (prefix === "mysql") return "mysql";
|
|
4219
|
+
if (prefix === "snowflake") return "snowflake";
|
|
4220
|
+
return getDatabaseType();
|
|
4221
|
+
}
|
|
4213
4222
|
function convertTopToLimit(query) {
|
|
4214
4223
|
if (!query || query.trim().length === 0) {
|
|
4215
4224
|
return query;
|
|
@@ -10397,10 +10406,12 @@ var get_agent_user_response = async (prompt, components, anthropicApiKey, groqAp
|
|
|
10397
10406
|
if (streamBuffer.hasCallback()) {
|
|
10398
10407
|
streamBuffer.write("\n\n\u{1F4CA} **Generating visualization components...**\n\n");
|
|
10399
10408
|
streamBuffer.write("__TEXT_COMPLETE__COMPONENT_GENERATION_START__");
|
|
10409
|
+
streamBuffer.flush();
|
|
10400
10410
|
}
|
|
10401
10411
|
const componentStreamCallback = streamBuffer.hasCallback() ? (component) => {
|
|
10402
10412
|
const answerMarker = `__ANSWER_COMPONENT_START__${JSON.stringify(component)}__ANSWER_COMPONENT_END__`;
|
|
10403
10413
|
streamBuffer.write(answerMarker);
|
|
10414
|
+
streamBuffer.flush();
|
|
10404
10415
|
} : void 0;
|
|
10405
10416
|
const sanitizedTextResponse = textResponse.replace(
|
|
10406
10417
|
/<DataTable>[\s\S]*?<\/DataTable>/g,
|
|
@@ -10742,7 +10753,10 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
|
|
|
10742
10753
|
}
|
|
10743
10754
|
}
|
|
10744
10755
|
}
|
|
10745
|
-
|
|
10756
|
+
let finalTextResponse = responseMode === "text" && accumulatedStreamResponse ? accumulatedStreamResponse : textResponse;
|
|
10757
|
+
if (finalTextResponse) {
|
|
10758
|
+
finalTextResponse = finalTextResponse.replace(/__TEXT_COMPLETE__[\s\S]*/g, "").replace(/__ANSWER_COMPONENT_START__[\s\S]*?__ANSWER_COMPONENT_END__/g, "").replace(/__COMPONENT_GENERATION_START__/g, "").trim();
|
|
10759
|
+
}
|
|
10746
10760
|
const uiBlock = new UIBlock(
|
|
10747
10761
|
prompt,
|
|
10748
10762
|
{},
|
|
@@ -14279,7 +14293,9 @@ Using this data, select the appropriate component and respond with ONLY the JSON
|
|
|
14279
14293
|
}
|
|
14280
14294
|
const etSql = finalComponent.props?.externalTool?.parameters?.sql;
|
|
14281
14295
|
if (etSql && typeof etSql === "string") {
|
|
14282
|
-
finalComponent.props
|
|
14296
|
+
const etToolId = finalComponent.props?.externalTool?.toolId;
|
|
14297
|
+
const etDbType = getDbTypeFromToolId(etToolId);
|
|
14298
|
+
finalComponent.props.externalTool.parameters.sql = ensureQueryLimit(etSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, etDbType);
|
|
14283
14299
|
}
|
|
14284
14300
|
logger.info(`[DASH_COMP_REQ] Successfully picked component: ${finalComponent.name} (${finalComponent.type})`);
|
|
14285
14301
|
if (finalComponent.props?.query && collections?.["database"]?.["execute"]) {
|
|
@@ -14417,7 +14433,7 @@ Fixed SQL query:`;
|
|
|
14417
14433
|
fixedSql = fixedSql.replace(/^```\s*/i, "").replace(/\s*```$/i, "");
|
|
14418
14434
|
const { query: validatedSql } = validateAndFixSqlQuery(fixedSql);
|
|
14419
14435
|
if (validatedSql && validatedSql !== extToolSql) {
|
|
14420
|
-
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT);
|
|
14436
|
+
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, getDbTypeFromToolId(extToolId));
|
|
14421
14437
|
logger.info(`[DASH_COMP_REQ] LLM provided SQL fix, retrying...`);
|
|
14422
14438
|
} else {
|
|
14423
14439
|
logger.warn(`[DASH_COMP_REQ] LLM returned same or empty query, stopping retries`);
|
|
@@ -15149,7 +15165,8 @@ Using this data, generate the complete report with multiple components. Respond
|
|
|
15149
15165
|
};
|
|
15150
15166
|
const etSql = finalComp.props?.externalTool?.parameters?.sql;
|
|
15151
15167
|
if (etSql && typeof etSql === "string") {
|
|
15152
|
-
finalComp.props
|
|
15168
|
+
const etToolId = finalComp.props?.externalTool?.toolId;
|
|
15169
|
+
finalComp.props.externalTool.parameters.sql = ensureQueryLimit(etSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, getDbTypeFromToolId(etToolId));
|
|
15153
15170
|
}
|
|
15154
15171
|
finalComponents.push(finalComp);
|
|
15155
15172
|
}
|
|
@@ -15321,7 +15338,7 @@ Fixed SQL query:`;
|
|
|
15321
15338
|
fixedSql = fixedSql.replace(/^```\s*/i, "").replace(/\s*```$/i, "");
|
|
15322
15339
|
const { query: validatedSql } = validateAndFixSqlQuery(fixedSql);
|
|
15323
15340
|
if (validatedSql && validatedSql !== extToolSql) {
|
|
15324
|
-
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT);
|
|
15341
|
+
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, getDbTypeFromToolId(extToolId));
|
|
15325
15342
|
logger.info(`[REPORT_COMP_REQ] LLM provided SQL fix for ${comp.name}, retrying...`);
|
|
15326
15343
|
} else {
|
|
15327
15344
|
logger.warn(`[REPORT_COMP_REQ] LLM returned same or empty query for ${comp.name}`);
|