@superatomai/sdk-node 0.0.55 → 0.0.56
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 +41 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6498,6 +6498,32 @@ ${executedToolsText}`);
|
|
|
6498
6498
|
fullStreamedText += chunk;
|
|
6499
6499
|
streamCallback(chunk);
|
|
6500
6500
|
} : void 0;
|
|
6501
|
+
const withProgressHeartbeat = async (operation, progressMessage, intervalMs = 1e3) => {
|
|
6502
|
+
if (!wrappedStreamCallback) {
|
|
6503
|
+
return operation();
|
|
6504
|
+
}
|
|
6505
|
+
const startTime = Date.now();
|
|
6506
|
+
let dotCount = 0;
|
|
6507
|
+
const maxDots = 3;
|
|
6508
|
+
wrappedStreamCallback(`\u23F3 ${progressMessage}`);
|
|
6509
|
+
const heartbeatInterval = setInterval(() => {
|
|
6510
|
+
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1e3);
|
|
6511
|
+
dotCount = (dotCount + 1) % (maxDots + 1);
|
|
6512
|
+
const dots = ".".repeat(dotCount || 1);
|
|
6513
|
+
if (elapsedSeconds >= 2) {
|
|
6514
|
+
wrappedStreamCallback(`${dots} (${elapsedSeconds}s)`);
|
|
6515
|
+
} else {
|
|
6516
|
+
wrappedStreamCallback(dots);
|
|
6517
|
+
}
|
|
6518
|
+
}, intervalMs);
|
|
6519
|
+
try {
|
|
6520
|
+
const result2 = await operation();
|
|
6521
|
+
return result2;
|
|
6522
|
+
} finally {
|
|
6523
|
+
clearInterval(heartbeatInterval);
|
|
6524
|
+
wrappedStreamCallback("\n\n");
|
|
6525
|
+
}
|
|
6526
|
+
};
|
|
6501
6527
|
const toolHandler = async (toolName, toolInput) => {
|
|
6502
6528
|
if (toolName === "execute_query") {
|
|
6503
6529
|
let sql = toolInput.sql;
|
|
@@ -6551,9 +6577,6 @@ Please try rephrasing your question or simplifying your request.
|
|
|
6551
6577
|
${sql}
|
|
6552
6578
|
\`\`\`${paramsDisplay}
|
|
6553
6579
|
|
|
6554
|
-
`);
|
|
6555
|
-
wrappedStreamCallback(`\u26A1 **Executing query...**
|
|
6556
|
-
|
|
6557
6580
|
`);
|
|
6558
6581
|
} else {
|
|
6559
6582
|
wrappedStreamCallback(`
|
|
@@ -6571,9 +6594,6 @@ ${sql}
|
|
|
6571
6594
|
${sql}
|
|
6572
6595
|
\`\`\`${paramsDisplay}
|
|
6573
6596
|
|
|
6574
|
-
`);
|
|
6575
|
-
wrappedStreamCallback(`\u26A1 **Executing query...**
|
|
6576
|
-
|
|
6577
6597
|
`);
|
|
6578
6598
|
}
|
|
6579
6599
|
}
|
|
@@ -6586,13 +6606,19 @@ ${sql}
|
|
|
6586
6606
|
throw new Error("Database collection not registered. Please register database.execute collection to execute queries.");
|
|
6587
6607
|
}
|
|
6588
6608
|
const queryPayload = Object.keys(params).length > 0 ? { sql: JSON.stringify({ sql, values: params }) } : { sql };
|
|
6589
|
-
const result2 = await
|
|
6609
|
+
const result2 = await withProgressHeartbeat(
|
|
6610
|
+
() => collections["database"]["execute"](queryPayload),
|
|
6611
|
+
"Executing database query",
|
|
6612
|
+
800
|
|
6613
|
+
// Send heartbeat every 800ms for responsive feedback
|
|
6614
|
+
);
|
|
6590
6615
|
const data = result2?.data || result2;
|
|
6591
6616
|
const rowCount = result2?.count ?? (Array.isArray(data) ? data.length : "N/A");
|
|
6592
6617
|
logger.info(`[${this.getProviderName()}] Query executed successfully, rows returned: ${rowCount}`);
|
|
6593
6618
|
logCollector?.info(`Query successful, returned ${rowCount} rows`);
|
|
6594
6619
|
if (wrappedStreamCallback) {
|
|
6595
|
-
wrappedStreamCallback(
|
|
6620
|
+
wrappedStreamCallback(`
|
|
6621
|
+
\u2705 **Query executed successfully!**
|
|
6596
6622
|
|
|
6597
6623
|
`);
|
|
6598
6624
|
if (Array.isArray(data) && data.length > 0) {
|
|
@@ -6679,7 +6705,12 @@ Please try rephrasing your request or contact support.
|
|
|
6679
6705
|
`);
|
|
6680
6706
|
}
|
|
6681
6707
|
}
|
|
6682
|
-
const result2 = await
|
|
6708
|
+
const result2 = await withProgressHeartbeat(
|
|
6709
|
+
() => externalTool.fn(toolInput),
|
|
6710
|
+
`Running ${externalTool.name}`,
|
|
6711
|
+
800
|
|
6712
|
+
// Send heartbeat every 800ms
|
|
6713
|
+
);
|
|
6683
6714
|
logger.info(`[${this.getProviderName()}] External tool ${externalTool.name} executed successfully`);
|
|
6684
6715
|
logCollector?.info(`\u2713 ${externalTool.name} executed successfully`);
|
|
6685
6716
|
if (!executedToolsList.find((t) => t.id === externalTool.id)) {
|
|
@@ -6781,6 +6812,7 @@ ${errorMsg}
|
|
|
6781
6812
|
}
|
|
6782
6813
|
);
|
|
6783
6814
|
if (wrappedStreamCallback && components && components.length > 0 && category !== "general") {
|
|
6815
|
+
wrappedStreamCallback("\n\n\u{1F4CA} **Generating visualization components...**\n\n");
|
|
6784
6816
|
wrappedStreamCallback("__TEXT_COMPLETE__COMPONENT_GENERATION_START__");
|
|
6785
6817
|
}
|
|
6786
6818
|
let matchedComponents = [];
|