@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.mjs
CHANGED
|
@@ -6448,6 +6448,32 @@ ${executedToolsText}`);
|
|
|
6448
6448
|
fullStreamedText += chunk;
|
|
6449
6449
|
streamCallback(chunk);
|
|
6450
6450
|
} : void 0;
|
|
6451
|
+
const withProgressHeartbeat = async (operation, progressMessage, intervalMs = 1e3) => {
|
|
6452
|
+
if (!wrappedStreamCallback) {
|
|
6453
|
+
return operation();
|
|
6454
|
+
}
|
|
6455
|
+
const startTime = Date.now();
|
|
6456
|
+
let dotCount = 0;
|
|
6457
|
+
const maxDots = 3;
|
|
6458
|
+
wrappedStreamCallback(`\u23F3 ${progressMessage}`);
|
|
6459
|
+
const heartbeatInterval = setInterval(() => {
|
|
6460
|
+
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1e3);
|
|
6461
|
+
dotCount = (dotCount + 1) % (maxDots + 1);
|
|
6462
|
+
const dots = ".".repeat(dotCount || 1);
|
|
6463
|
+
if (elapsedSeconds >= 2) {
|
|
6464
|
+
wrappedStreamCallback(`${dots} (${elapsedSeconds}s)`);
|
|
6465
|
+
} else {
|
|
6466
|
+
wrappedStreamCallback(dots);
|
|
6467
|
+
}
|
|
6468
|
+
}, intervalMs);
|
|
6469
|
+
try {
|
|
6470
|
+
const result2 = await operation();
|
|
6471
|
+
return result2;
|
|
6472
|
+
} finally {
|
|
6473
|
+
clearInterval(heartbeatInterval);
|
|
6474
|
+
wrappedStreamCallback("\n\n");
|
|
6475
|
+
}
|
|
6476
|
+
};
|
|
6451
6477
|
const toolHandler = async (toolName, toolInput) => {
|
|
6452
6478
|
if (toolName === "execute_query") {
|
|
6453
6479
|
let sql = toolInput.sql;
|
|
@@ -6501,9 +6527,6 @@ Please try rephrasing your question or simplifying your request.
|
|
|
6501
6527
|
${sql}
|
|
6502
6528
|
\`\`\`${paramsDisplay}
|
|
6503
6529
|
|
|
6504
|
-
`);
|
|
6505
|
-
wrappedStreamCallback(`\u26A1 **Executing query...**
|
|
6506
|
-
|
|
6507
6530
|
`);
|
|
6508
6531
|
} else {
|
|
6509
6532
|
wrappedStreamCallback(`
|
|
@@ -6521,9 +6544,6 @@ ${sql}
|
|
|
6521
6544
|
${sql}
|
|
6522
6545
|
\`\`\`${paramsDisplay}
|
|
6523
6546
|
|
|
6524
|
-
`);
|
|
6525
|
-
wrappedStreamCallback(`\u26A1 **Executing query...**
|
|
6526
|
-
|
|
6527
6547
|
`);
|
|
6528
6548
|
}
|
|
6529
6549
|
}
|
|
@@ -6536,13 +6556,19 @@ ${sql}
|
|
|
6536
6556
|
throw new Error("Database collection not registered. Please register database.execute collection to execute queries.");
|
|
6537
6557
|
}
|
|
6538
6558
|
const queryPayload = Object.keys(params).length > 0 ? { sql: JSON.stringify({ sql, values: params }) } : { sql };
|
|
6539
|
-
const result2 = await
|
|
6559
|
+
const result2 = await withProgressHeartbeat(
|
|
6560
|
+
() => collections["database"]["execute"](queryPayload),
|
|
6561
|
+
"Executing database query",
|
|
6562
|
+
800
|
|
6563
|
+
// Send heartbeat every 800ms for responsive feedback
|
|
6564
|
+
);
|
|
6540
6565
|
const data = result2?.data || result2;
|
|
6541
6566
|
const rowCount = result2?.count ?? (Array.isArray(data) ? data.length : "N/A");
|
|
6542
6567
|
logger.info(`[${this.getProviderName()}] Query executed successfully, rows returned: ${rowCount}`);
|
|
6543
6568
|
logCollector?.info(`Query successful, returned ${rowCount} rows`);
|
|
6544
6569
|
if (wrappedStreamCallback) {
|
|
6545
|
-
wrappedStreamCallback(
|
|
6570
|
+
wrappedStreamCallback(`
|
|
6571
|
+
\u2705 **Query executed successfully!**
|
|
6546
6572
|
|
|
6547
6573
|
`);
|
|
6548
6574
|
if (Array.isArray(data) && data.length > 0) {
|
|
@@ -6629,7 +6655,12 @@ Please try rephrasing your request or contact support.
|
|
|
6629
6655
|
`);
|
|
6630
6656
|
}
|
|
6631
6657
|
}
|
|
6632
|
-
const result2 = await
|
|
6658
|
+
const result2 = await withProgressHeartbeat(
|
|
6659
|
+
() => externalTool.fn(toolInput),
|
|
6660
|
+
`Running ${externalTool.name}`,
|
|
6661
|
+
800
|
|
6662
|
+
// Send heartbeat every 800ms
|
|
6663
|
+
);
|
|
6633
6664
|
logger.info(`[${this.getProviderName()}] External tool ${externalTool.name} executed successfully`);
|
|
6634
6665
|
logCollector?.info(`\u2713 ${externalTool.name} executed successfully`);
|
|
6635
6666
|
if (!executedToolsList.find((t) => t.id === externalTool.id)) {
|
|
@@ -6731,6 +6762,7 @@ ${errorMsg}
|
|
|
6731
6762
|
}
|
|
6732
6763
|
);
|
|
6733
6764
|
if (wrappedStreamCallback && components && components.length > 0 && category !== "general") {
|
|
6765
|
+
wrappedStreamCallback("\n\n\u{1F4CA} **Generating visualization components...**\n\n");
|
|
6734
6766
|
wrappedStreamCallback("__TEXT_COMPLETE__COMPONENT_GENERATION_START__");
|
|
6735
6767
|
}
|
|
6736
6768
|
let matchedComponents = [];
|