@superatomai/sdk-node 0.0.43-mds → 0.0.44-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 +17 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7728,6 +7728,7 @@ var MainAgent = class {
|
|
|
7728
7728
|
maxRows: 5,
|
|
7729
7729
|
maxCharsPerField: 200
|
|
7730
7730
|
});
|
|
7731
|
+
const sampleData = Array.isArray(resultData) ? resultData.slice(0, 3) : Array.isArray(formattedResult.data) ? formattedResult.data.slice(0, 3) : [];
|
|
7731
7732
|
executedTools.push({
|
|
7732
7733
|
id: tool.id,
|
|
7733
7734
|
name: tool.name,
|
|
@@ -7736,7 +7737,7 @@ var MainAgent = class {
|
|
|
7736
7737
|
_totalRecords: result.totalItems || result.count || rowCount,
|
|
7737
7738
|
_recordsShown: rowCount,
|
|
7738
7739
|
_metadata: result.metadata,
|
|
7739
|
-
_sampleData:
|
|
7740
|
+
_sampleData: sampleData
|
|
7740
7741
|
},
|
|
7741
7742
|
outputSchema: tool.outputSchema
|
|
7742
7743
|
});
|
|
@@ -8287,6 +8288,7 @@ function formatExecutedTools(executedTools) {
|
|
|
8287
8288
|
Fields:
|
|
8288
8289
|
${fieldsText}`;
|
|
8289
8290
|
}
|
|
8291
|
+
const MAX_SAMPLE_ROW_CHARS = 4e3;
|
|
8290
8292
|
let sampleDataText = "";
|
|
8291
8293
|
const sampleData = tool.result?._sampleData;
|
|
8292
8294
|
if (Array.isArray(sampleData) && sampleData.length > 0) {
|
|
@@ -8294,8 +8296,10 @@ ${fieldsText}`;
|
|
|
8294
8296
|
sampleDataText = `
|
|
8295
8297
|
\u{1F511} RESULT FIELDS: ${sampleFields.join(", ")}`;
|
|
8296
8298
|
try {
|
|
8299
|
+
const stringified = JSON.stringify(sampleData[0]);
|
|
8300
|
+
const capped = stringified.length > MAX_SAMPLE_ROW_CHARS ? `${stringified.substring(0, MAX_SAMPLE_ROW_CHARS)}... (truncated; ${stringified.length - MAX_SAMPLE_ROW_CHARS} more chars)` : stringified;
|
|
8297
8301
|
sampleDataText += `
|
|
8298
|
-
\u{1F4C4} SAMPLE ROW: ${
|
|
8302
|
+
\u{1F4C4} SAMPLE ROW: ${capped}`;
|
|
8299
8303
|
} catch {
|
|
8300
8304
|
}
|
|
8301
8305
|
}
|
|
@@ -17161,24 +17165,27 @@ var CleanupService = class _CleanupService {
|
|
|
17161
17165
|
// src/index.ts
|
|
17162
17166
|
var DEFAULT_WS_URL = "wss://ws.superatom.ai/websocket";
|
|
17163
17167
|
var SuperatomSDK = class {
|
|
17164
|
-
// 3.5 minutes (PING_INTERVAL + 30s grace)
|
|
17165
17168
|
constructor(config) {
|
|
17166
17169
|
this.ws = null;
|
|
17167
17170
|
this.messageHandlers = /* @__PURE__ */ new Map();
|
|
17168
17171
|
this.messageTypeHandlers = /* @__PURE__ */ new Map();
|
|
17169
17172
|
this.connected = false;
|
|
17170
17173
|
this.reconnectAttempts = 0;
|
|
17171
|
-
|
|
17174
|
+
// Retry forever — the backend must self-heal across NAT timeouts, DO
|
|
17175
|
+
// redeploys, and long network outages. The previous cap (5) gave up after
|
|
17176
|
+
// ~30s and left the singleton SDK dead until process restart.
|
|
17177
|
+
this.maxReconnectAttempts = Infinity;
|
|
17172
17178
|
this.collections = {};
|
|
17173
17179
|
this.components = [];
|
|
17174
17180
|
this.tools = [];
|
|
17175
17181
|
this.workflows = [];
|
|
17176
|
-
// Heartbeat properties for keeping WebSocket connection alive
|
|
17182
|
+
// Heartbeat properties for keeping WebSocket connection alive.
|
|
17183
|
+
// 25s ping + 10s grace stays under common NAT/LB idle thresholds (~60-100s)
|
|
17184
|
+
// so we detect dead sockets within seconds instead of minutes.
|
|
17177
17185
|
this.pingInterval = null;
|
|
17178
17186
|
this.lastPong = Date.now();
|
|
17179
|
-
this.PING_INTERVAL_MS =
|
|
17180
|
-
|
|
17181
|
-
this.PONG_TIMEOUT_MS = 21e4;
|
|
17187
|
+
this.PING_INTERVAL_MS = 25e3;
|
|
17188
|
+
this.PONG_TIMEOUT_MS = 35e3;
|
|
17182
17189
|
if (config.logLevel) {
|
|
17183
17190
|
logger.setLogLevel(config.logLevel);
|
|
17184
17191
|
}
|
|
@@ -17537,9 +17544,9 @@ var SuperatomSDK = class {
|
|
|
17537
17544
|
handleReconnect() {
|
|
17538
17545
|
if (this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
17539
17546
|
this.reconnectAttempts++;
|
|
17540
|
-
const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts),
|
|
17547
|
+
const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts), 3e4);
|
|
17541
17548
|
setTimeout(() => {
|
|
17542
|
-
logger.info(`Attempting to reconnect (${this.reconnectAttempts}
|
|
17549
|
+
logger.info(`Attempting to reconnect (attempt ${this.reconnectAttempts})...`);
|
|
17543
17550
|
this.connect().catch((error) => {
|
|
17544
17551
|
logger.error("Reconnection failed:", error);
|
|
17545
17552
|
});
|