@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.mjs CHANGED
@@ -7668,6 +7668,7 @@ var MainAgent = class {
7668
7668
  maxRows: 5,
7669
7669
  maxCharsPerField: 200
7670
7670
  });
7671
+ const sampleData = Array.isArray(resultData) ? resultData.slice(0, 3) : Array.isArray(formattedResult.data) ? formattedResult.data.slice(0, 3) : [];
7671
7672
  executedTools.push({
7672
7673
  id: tool.id,
7673
7674
  name: tool.name,
@@ -7676,7 +7677,7 @@ var MainAgent = class {
7676
7677
  _totalRecords: result.totalItems || result.count || rowCount,
7677
7678
  _recordsShown: rowCount,
7678
7679
  _metadata: result.metadata,
7679
- _sampleData: Array.isArray(resultData) ? resultData.slice(0, 3) : [resultData]
7680
+ _sampleData: sampleData
7680
7681
  },
7681
7682
  outputSchema: tool.outputSchema
7682
7683
  });
@@ -8227,6 +8228,7 @@ function formatExecutedTools(executedTools) {
8227
8228
  Fields:
8228
8229
  ${fieldsText}`;
8229
8230
  }
8231
+ const MAX_SAMPLE_ROW_CHARS = 4e3;
8230
8232
  let sampleDataText = "";
8231
8233
  const sampleData = tool.result?._sampleData;
8232
8234
  if (Array.isArray(sampleData) && sampleData.length > 0) {
@@ -8234,8 +8236,10 @@ ${fieldsText}`;
8234
8236
  sampleDataText = `
8235
8237
  \u{1F511} RESULT FIELDS: ${sampleFields.join(", ")}`;
8236
8238
  try {
8239
+ const stringified = JSON.stringify(sampleData[0]);
8240
+ 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;
8237
8241
  sampleDataText += `
8238
- \u{1F4C4} SAMPLE ROW: ${JSON.stringify(sampleData[0])}`;
8242
+ \u{1F4C4} SAMPLE ROW: ${capped}`;
8239
8243
  } catch {
8240
8244
  }
8241
8245
  }
@@ -17101,24 +17105,27 @@ var CleanupService = class _CleanupService {
17101
17105
  // src/index.ts
17102
17106
  var DEFAULT_WS_URL = "wss://ws.superatom.ai/websocket";
17103
17107
  var SuperatomSDK = class {
17104
- // 3.5 minutes (PING_INTERVAL + 30s grace)
17105
17108
  constructor(config) {
17106
17109
  this.ws = null;
17107
17110
  this.messageHandlers = /* @__PURE__ */ new Map();
17108
17111
  this.messageTypeHandlers = /* @__PURE__ */ new Map();
17109
17112
  this.connected = false;
17110
17113
  this.reconnectAttempts = 0;
17111
- this.maxReconnectAttempts = 5;
17114
+ // Retry forever — the backend must self-heal across NAT timeouts, DO
17115
+ // redeploys, and long network outages. The previous cap (5) gave up after
17116
+ // ~30s and left the singleton SDK dead until process restart.
17117
+ this.maxReconnectAttempts = Infinity;
17112
17118
  this.collections = {};
17113
17119
  this.components = [];
17114
17120
  this.tools = [];
17115
17121
  this.workflows = [];
17116
- // Heartbeat properties for keeping WebSocket connection alive
17122
+ // Heartbeat properties for keeping WebSocket connection alive.
17123
+ // 25s ping + 10s grace stays under common NAT/LB idle thresholds (~60-100s)
17124
+ // so we detect dead sockets within seconds instead of minutes.
17117
17125
  this.pingInterval = null;
17118
17126
  this.lastPong = Date.now();
17119
- this.PING_INTERVAL_MS = 18e4;
17120
- // 3 minutes
17121
- this.PONG_TIMEOUT_MS = 21e4;
17127
+ this.PING_INTERVAL_MS = 25e3;
17128
+ this.PONG_TIMEOUT_MS = 35e3;
17122
17129
  if (config.logLevel) {
17123
17130
  logger.setLogLevel(config.logLevel);
17124
17131
  }
@@ -17477,9 +17484,9 @@ var SuperatomSDK = class {
17477
17484
  handleReconnect() {
17478
17485
  if (this.reconnectAttempts < this.maxReconnectAttempts) {
17479
17486
  this.reconnectAttempts++;
17480
- const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts), 1e4);
17487
+ const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts), 3e4);
17481
17488
  setTimeout(() => {
17482
- logger.info(`Attempting to reconnect (${this.reconnectAttempts}/${this.maxReconnectAttempts})...`);
17489
+ logger.info(`Attempting to reconnect (attempt ${this.reconnectAttempts})...`);
17483
17490
  this.connect().catch((error) => {
17484
17491
  logger.error("Reconnection failed:", error);
17485
17492
  });