@superatomai/sdk-node 0.0.26-mds → 0.0.27-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 +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +25 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1431,14 +1431,14 @@ var QueryCache = class {
|
|
|
1431
1431
|
constructor() {
|
|
1432
1432
|
this.cache = /* @__PURE__ */ new Map();
|
|
1433
1433
|
this.queryIdCache = /* @__PURE__ */ new Map();
|
|
1434
|
-
this.ttlMs =
|
|
1435
|
-
// Default:
|
|
1434
|
+
this.ttlMs = 10 * 60 * 1e3;
|
|
1435
|
+
// Default: 10 minutes (for data cache only)
|
|
1436
1436
|
this.cleanupInterval = null;
|
|
1437
1437
|
this.startCleanup();
|
|
1438
1438
|
}
|
|
1439
1439
|
/**
|
|
1440
1440
|
* Set the cache TTL (Time To Live)
|
|
1441
|
-
* @param minutes - TTL in minutes (default:
|
|
1441
|
+
* @param minutes - TTL in minutes (default: 10)
|
|
1442
1442
|
*/
|
|
1443
1443
|
setTTL(minutes) {
|
|
1444
1444
|
this.ttlMs = minutes * 60 * 1e3;
|
|
@@ -1509,11 +1509,14 @@ var QueryCache = class {
|
|
|
1509
1509
|
}
|
|
1510
1510
|
return {
|
|
1511
1511
|
size: this.cache.size,
|
|
1512
|
+
queryIdCount: this.queryIdCache.size,
|
|
1512
1513
|
oldestEntryAge: oldestTimestamp ? Date.now() - oldestTimestamp : null
|
|
1513
1514
|
};
|
|
1514
1515
|
}
|
|
1515
1516
|
/**
|
|
1516
|
-
* Start periodic cleanup of expired entries
|
|
1517
|
+
* Start periodic cleanup of expired entries.
|
|
1518
|
+
* Only cleans the data cache — queryIdCache entries are permanent (server lifetime)
|
|
1519
|
+
* because queryIds are persisted in dashboard widgets.
|
|
1517
1520
|
*/
|
|
1518
1521
|
startCleanup() {
|
|
1519
1522
|
this.cleanupInterval = setInterval(() => {
|
|
@@ -1525,14 +1528,13 @@ var QueryCache = class {
|
|
|
1525
1528
|
expiredCount++;
|
|
1526
1529
|
}
|
|
1527
1530
|
}
|
|
1528
|
-
for (const
|
|
1529
|
-
if (now - entry.timestamp > this.ttlMs) {
|
|
1530
|
-
|
|
1531
|
-
expiredCount++;
|
|
1531
|
+
for (const entry of this.queryIdCache.values()) {
|
|
1532
|
+
if (entry.data && now - entry.timestamp > this.ttlMs) {
|
|
1533
|
+
entry.data = null;
|
|
1532
1534
|
}
|
|
1533
1535
|
}
|
|
1534
1536
|
if (expiredCount > 0) {
|
|
1535
|
-
logger.debug(`[QueryCache] Cleaned up ${expiredCount} expired entries`);
|
|
1537
|
+
logger.debug(`[QueryCache] Cleaned up ${expiredCount} expired data-cache entries`);
|
|
1536
1538
|
}
|
|
1537
1539
|
}, 2 * 60 * 1e3);
|
|
1538
1540
|
}
|
|
@@ -1562,15 +1564,14 @@ var QueryCache = class {
|
|
|
1562
1564
|
return queryId;
|
|
1563
1565
|
}
|
|
1564
1566
|
/**
|
|
1565
|
-
* Get a stored query by its ID
|
|
1567
|
+
* Get a stored query by its ID.
|
|
1568
|
+
* The SQL mapping never expires (queryIds are persisted in dashboard widgets).
|
|
1569
|
+
* Cached data may be null if it was evicted by the cleanup interval.
|
|
1566
1570
|
*/
|
|
1567
1571
|
getQuery(queryId) {
|
|
1568
1572
|
const entry = this.queryIdCache.get(queryId);
|
|
1569
1573
|
if (!entry) return null;
|
|
1570
|
-
|
|
1571
|
-
this.queryIdCache.delete(queryId);
|
|
1572
|
-
return null;
|
|
1573
|
-
}
|
|
1574
|
+
entry.timestamp = Date.now();
|
|
1574
1575
|
return { query: entry.query, data: entry.data };
|
|
1575
1576
|
}
|
|
1576
1577
|
/**
|
|
@@ -7886,17 +7887,8 @@ ${executedToolsText}`);
|
|
|
7886
7887
|
let matchedComponents = result.matchedComponents || [];
|
|
7887
7888
|
const layoutTitle = result.layoutTitle || "Dashboard";
|
|
7888
7889
|
const layoutDescription = result.layoutDescription || "Multi-component dashboard";
|
|
7889
|
-
const complexityMatch = analysisContent.match(/\[COMPLEXITY:\s*(simple|medium|complex)\]/i);
|
|
7890
|
-
const complexity = complexityMatch ? complexityMatch[1].toLowerCase() : "medium";
|
|
7891
|
-
const maxVisualizations = complexity === "simple" ? 1 : complexity === "medium" ? 3 : 5;
|
|
7892
|
-
const markdownComps = matchedComponents.filter((mc) => mc.componentName === "DynamicMarkdownBlock");
|
|
7893
7890
|
const vizComps = matchedComponents.filter((mc) => mc.componentName !== "DynamicMarkdownBlock");
|
|
7894
|
-
|
|
7895
|
-
logger.info(`[AgentComponentGen] Trimming ${vizComps.length} visualizations to ${maxVisualizations} (complexity: ${complexity})`);
|
|
7896
|
-
matchedComponents = [...vizComps.slice(0, maxVisualizations), ...markdownComps];
|
|
7897
|
-
} else {
|
|
7898
|
-
logger.info(`[AgentComponentGen] Complexity: ${complexity} | ${vizComps.length} visualizations (limit: ${maxVisualizations})`);
|
|
7899
|
-
}
|
|
7891
|
+
logger.info(`[AgentComponentGen] ${vizComps.length} visualizations, ${matchedComponents.length - vizComps.length} markdown blocks`);
|
|
7900
7892
|
if (result.hasAnswerComponent && result.answerComponent?.componentId) {
|
|
7901
7893
|
const answer = result.answerComponent;
|
|
7902
7894
|
const answerSql = answer.props?.externalTool?.parameters?.sql || "";
|
|
@@ -14654,8 +14646,15 @@ async function createFilterWithLLM(prompt, components, existingComponents, anthr
|
|
|
14654
14646
|
5
|
|
14655
14647
|
// max iterations
|
|
14656
14648
|
);
|
|
14657
|
-
const
|
|
14658
|
-
const
|
|
14649
|
+
const cleaned = rawResult.replace(/```(?:json)?\s*/g, "").replace(/```\s*/g, "");
|
|
14650
|
+
const jsonMatch = cleaned.match(/\{[\s\S]*\}/);
|
|
14651
|
+
const result = jsonMatch ? (() => {
|
|
14652
|
+
try {
|
|
14653
|
+
return JSON.parse(jsonMatch[0]);
|
|
14654
|
+
} catch {
|
|
14655
|
+
return null;
|
|
14656
|
+
}
|
|
14657
|
+
})() : null;
|
|
14659
14658
|
if (!result) {
|
|
14660
14659
|
errors.push("Failed to parse LLM response as JSON");
|
|
14661
14660
|
errors.push(`LLM Response: ${rawResult}`);
|