@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.js
CHANGED
|
@@ -4270,6 +4270,15 @@ var promptLoader = new PromptLoader({
|
|
|
4270
4270
|
function getDatabaseType() {
|
|
4271
4271
|
return promptLoader.getDatabaseType();
|
|
4272
4272
|
}
|
|
4273
|
+
function getDbTypeFromToolId(toolId) {
|
|
4274
|
+
if (!toolId) return getDatabaseType();
|
|
4275
|
+
const prefix = toolId.split("-")[0]?.toLowerCase();
|
|
4276
|
+
if (prefix === "mssql") return "mssql";
|
|
4277
|
+
if (prefix === "postgres" || prefix === "postgresql") return "postgresql";
|
|
4278
|
+
if (prefix === "mysql") return "mysql";
|
|
4279
|
+
if (prefix === "snowflake") return "snowflake";
|
|
4280
|
+
return getDatabaseType();
|
|
4281
|
+
}
|
|
4273
4282
|
function convertTopToLimit(query) {
|
|
4274
4283
|
if (!query || query.trim().length === 0) {
|
|
4275
4284
|
return query;
|
|
@@ -10457,10 +10466,12 @@ var get_agent_user_response = async (prompt, components, anthropicApiKey, groqAp
|
|
|
10457
10466
|
if (streamBuffer.hasCallback()) {
|
|
10458
10467
|
streamBuffer.write("\n\n\u{1F4CA} **Generating visualization components...**\n\n");
|
|
10459
10468
|
streamBuffer.write("__TEXT_COMPLETE__COMPONENT_GENERATION_START__");
|
|
10469
|
+
streamBuffer.flush();
|
|
10460
10470
|
}
|
|
10461
10471
|
const componentStreamCallback = streamBuffer.hasCallback() ? (component) => {
|
|
10462
10472
|
const answerMarker = `__ANSWER_COMPONENT_START__${JSON.stringify(component)}__ANSWER_COMPONENT_END__`;
|
|
10463
10473
|
streamBuffer.write(answerMarker);
|
|
10474
|
+
streamBuffer.flush();
|
|
10464
10475
|
} : void 0;
|
|
10465
10476
|
const sanitizedTextResponse = textResponse.replace(
|
|
10466
10477
|
/<DataTable>[\s\S]*?<\/DataTable>/g,
|
|
@@ -10802,7 +10813,10 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
|
|
|
10802
10813
|
}
|
|
10803
10814
|
}
|
|
10804
10815
|
}
|
|
10805
|
-
|
|
10816
|
+
let finalTextResponse = responseMode === "text" && accumulatedStreamResponse ? accumulatedStreamResponse : textResponse;
|
|
10817
|
+
if (finalTextResponse) {
|
|
10818
|
+
finalTextResponse = finalTextResponse.replace(/__TEXT_COMPLETE__[\s\S]*/g, "").replace(/__ANSWER_COMPONENT_START__[\s\S]*?__ANSWER_COMPONENT_END__/g, "").replace(/__COMPONENT_GENERATION_START__/g, "").trim();
|
|
10819
|
+
}
|
|
10806
10820
|
const uiBlock = new UIBlock(
|
|
10807
10821
|
prompt,
|
|
10808
10822
|
{},
|
|
@@ -14339,7 +14353,9 @@ Using this data, select the appropriate component and respond with ONLY the JSON
|
|
|
14339
14353
|
}
|
|
14340
14354
|
const etSql = finalComponent.props?.externalTool?.parameters?.sql;
|
|
14341
14355
|
if (etSql && typeof etSql === "string") {
|
|
14342
|
-
finalComponent.props
|
|
14356
|
+
const etToolId = finalComponent.props?.externalTool?.toolId;
|
|
14357
|
+
const etDbType = getDbTypeFromToolId(etToolId);
|
|
14358
|
+
finalComponent.props.externalTool.parameters.sql = ensureQueryLimit(etSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, etDbType);
|
|
14343
14359
|
}
|
|
14344
14360
|
logger.info(`[DASH_COMP_REQ] Successfully picked component: ${finalComponent.name} (${finalComponent.type})`);
|
|
14345
14361
|
if (finalComponent.props?.query && collections?.["database"]?.["execute"]) {
|
|
@@ -14477,7 +14493,7 @@ Fixed SQL query:`;
|
|
|
14477
14493
|
fixedSql = fixedSql.replace(/^```\s*/i, "").replace(/\s*```$/i, "");
|
|
14478
14494
|
const { query: validatedSql } = validateAndFixSqlQuery(fixedSql);
|
|
14479
14495
|
if (validatedSql && validatedSql !== extToolSql) {
|
|
14480
|
-
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT);
|
|
14496
|
+
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, getDbTypeFromToolId(extToolId));
|
|
14481
14497
|
logger.info(`[DASH_COMP_REQ] LLM provided SQL fix, retrying...`);
|
|
14482
14498
|
} else {
|
|
14483
14499
|
logger.warn(`[DASH_COMP_REQ] LLM returned same or empty query, stopping retries`);
|
|
@@ -15209,7 +15225,8 @@ Using this data, generate the complete report with multiple components. Respond
|
|
|
15209
15225
|
};
|
|
15210
15226
|
const etSql = finalComp.props?.externalTool?.parameters?.sql;
|
|
15211
15227
|
if (etSql && typeof etSql === "string") {
|
|
15212
|
-
finalComp.props
|
|
15228
|
+
const etToolId = finalComp.props?.externalTool?.toolId;
|
|
15229
|
+
finalComp.props.externalTool.parameters.sql = ensureQueryLimit(etSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, getDbTypeFromToolId(etToolId));
|
|
15213
15230
|
}
|
|
15214
15231
|
finalComponents.push(finalComp);
|
|
15215
15232
|
}
|
|
@@ -15381,7 +15398,7 @@ Fixed SQL query:`;
|
|
|
15381
15398
|
fixedSql = fixedSql.replace(/^```\s*/i, "").replace(/\s*```$/i, "");
|
|
15382
15399
|
const { query: validatedSql } = validateAndFixSqlQuery(fixedSql);
|
|
15383
15400
|
if (validatedSql && validatedSql !== extToolSql) {
|
|
15384
|
-
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT);
|
|
15401
|
+
extToolSql = ensureQueryLimit(validatedSql, DEFAULT_QUERY_LIMIT, MAX_COMPONENT_QUERY_LIMIT, getDbTypeFromToolId(extToolId));
|
|
15385
15402
|
logger.info(`[REPORT_COMP_REQ] LLM provided SQL fix for ${comp.name}, retrying...`);
|
|
15386
15403
|
} else {
|
|
15387
15404
|
logger.warn(`[REPORT_COMP_REQ] LLM returned same or empty query for ${comp.name}`);
|