@superatomai/sdk-node 0.0.26 → 0.0.27

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 CHANGED
@@ -1466,15 +1466,17 @@ declare const STORAGE_CONFIG: {
1466
1466
  */
1467
1467
  MAX_ROWS_PER_BLOCK: number;
1468
1468
  /**
1469
- * Maximum size in bytes per UIBlock (1MB)
1469
+ * Maximum size in bytes per UIBlock (500KB - reduced to save memory)
1470
1470
  */
1471
1471
  MAX_SIZE_PER_BLOCK_BYTES: number;
1472
1472
  /**
1473
1473
  * Number of days to keep threads before cleanup
1474
+ * Note: This is for in-memory storage. Conversations are also persisted to database.
1474
1475
  */
1475
1476
  THREAD_RETENTION_DAYS: number;
1476
1477
  /**
1477
1478
  * Number of days to keep UIBlocks before cleanup
1479
+ * Note: This is for in-memory storage. Data is also persisted to database.
1478
1480
  */
1479
1481
  UIBLOCK_RETENTION_DAYS: number;
1480
1482
  };
package/dist/index.d.ts CHANGED
@@ -1466,15 +1466,17 @@ declare const STORAGE_CONFIG: {
1466
1466
  */
1467
1467
  MAX_ROWS_PER_BLOCK: number;
1468
1468
  /**
1469
- * Maximum size in bytes per UIBlock (1MB)
1469
+ * Maximum size in bytes per UIBlock (500KB - reduced to save memory)
1470
1470
  */
1471
1471
  MAX_SIZE_PER_BLOCK_BYTES: number;
1472
1472
  /**
1473
1473
  * Number of days to keep threads before cleanup
1474
+ * Note: This is for in-memory storage. Conversations are also persisted to database.
1474
1475
  */
1475
1476
  THREAD_RETENTION_DAYS: number;
1476
1477
  /**
1477
1478
  * Number of days to keep UIBlocks before cleanup
1479
+ * Note: This is for in-memory storage. Data is also persisted to database.
1478
1480
  */
1479
1481
  UIBLOCK_RETENTION_DAYS: number;
1480
1482
  };
package/dist/index.js CHANGED
@@ -846,18 +846,22 @@ var STORAGE_CONFIG = {
846
846
  */
847
847
  MAX_ROWS_PER_BLOCK: 10,
848
848
  /**
849
- * Maximum size in bytes per UIBlock (1MB)
849
+ * Maximum size in bytes per UIBlock (500KB - reduced to save memory)
850
850
  */
851
- MAX_SIZE_PER_BLOCK_BYTES: 1 * 1024 * 1024,
852
- // 1MB
851
+ MAX_SIZE_PER_BLOCK_BYTES: 500 * 1024,
852
+ // 500KB
853
853
  /**
854
854
  * Number of days to keep threads before cleanup
855
+ * Note: This is for in-memory storage. Conversations are also persisted to database.
855
856
  */
856
- THREAD_RETENTION_DAYS: 7,
857
+ THREAD_RETENTION_DAYS: 2,
858
+ // Reduced from 7 to 1 day for memory efficiency
857
859
  /**
858
860
  * Number of days to keep UIBlocks before cleanup
861
+ * Note: This is for in-memory storage. Data is also persisted to database.
859
862
  */
860
- UIBLOCK_RETENTION_DAYS: 7
863
+ UIBLOCK_RETENTION_DAYS: 2
864
+ // Reduced from 7 to 1 day for memory efficiency
861
865
  };
862
866
 
863
867
  // src/threads/uiblock.ts
@@ -1377,8 +1381,15 @@ async function handleDataRequest(data, collections, sendMessage) {
1377
1381
  }
1378
1382
  }
1379
1383
  if (uiBlock) {
1380
- uiBlock.setComponentData(result || {});
1381
- logger.info(`Updated UIBlock ${uiBlockId} with component data from ${collection}.${op}`);
1384
+ const dataSummary = {
1385
+ _dataReceived: true,
1386
+ _timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1387
+ _collection: collection,
1388
+ _operation: op,
1389
+ _recordCount: Array.isArray(result) ? result.length : result?.data?.length || result?.contacts?.length || result?.salesorders?.length || "unknown"
1390
+ };
1391
+ uiBlock.setComponentData(dataSummary);
1392
+ logger.info(`Updated UIBlock ${uiBlockId} with data summary from ${collection}.${op} (full data not stored to save memory)`);
1382
1393
  } else {
1383
1394
  logger.warn(`UIBlock ${uiBlockId} not found in threads`);
1384
1395
  }
@@ -3385,10 +3396,15 @@ var LLM = class {
3385
3396
  for (const toolUse of toolUses) {
3386
3397
  try {
3387
3398
  const result = await toolHandler(toolUse.name, toolUse.input);
3399
+ let resultContent = typeof result === "string" ? result : JSON.stringify(result);
3400
+ const MAX_RESULT_LENGTH = 5e4;
3401
+ if (resultContent.length > MAX_RESULT_LENGTH) {
3402
+ resultContent = resultContent.substring(0, MAX_RESULT_LENGTH) + "\n\n... [Result truncated - showing first 50000 characters of " + resultContent.length + " total]";
3403
+ }
3388
3404
  toolResults.content.push({
3389
3405
  type: "tool_result",
3390
3406
  tool_use_id: toolUse.id,
3391
- content: typeof result === "string" ? result : JSON.stringify(result)
3407
+ content: resultContent
3392
3408
  });
3393
3409
  } catch (error) {
3394
3410
  toolResults.content.push({
@@ -3567,9 +3583,14 @@ var LLM = class {
3567
3583
  for (const fc of functionCalls) {
3568
3584
  try {
3569
3585
  const result2 = await toolHandler(fc.name, fc.args);
3586
+ let resultContent = typeof result2 === "string" ? result2 : JSON.stringify(result2);
3587
+ const MAX_RESULT_LENGTH = 5e4;
3588
+ if (resultContent.length > MAX_RESULT_LENGTH) {
3589
+ resultContent = resultContent.substring(0, MAX_RESULT_LENGTH) + "\n\n... [Result truncated - showing first 50000 characters of " + resultContent.length + " total]";
3590
+ }
3570
3591
  functionResponses.push({
3571
3592
  name: fc.name,
3572
- response: { result: typeof result2 === "string" ? result2 : JSON.stringify(result2) }
3593
+ response: { result: resultContent }
3573
3594
  });
3574
3595
  } catch (error) {
3575
3596
  functionResponses.push({
@@ -3735,6 +3756,10 @@ var LLM = class {
3735
3756
  const args = JSON.parse(tc.arguments);
3736
3757
  const toolResult = await toolHandler(tc.name, args);
3737
3758
  result = typeof toolResult === "string" ? toolResult : JSON.stringify(toolResult);
3759
+ const MAX_RESULT_LENGTH = 5e4;
3760
+ if (result.length > MAX_RESULT_LENGTH) {
3761
+ result = result.substring(0, MAX_RESULT_LENGTH) + "\n\n... [Result truncated - showing first 50000 characters of " + result.length + " total]";
3762
+ }
3738
3763
  } catch (error) {
3739
3764
  result = JSON.stringify({ error: error instanceof Error ? error.message : String(error) });
3740
3765
  }
@@ -4909,13 +4934,26 @@ Please try rephrasing your request or contact support.
4909
4934
  logger.info(`[${this.getProviderName()}] External tool ${externalTool.name} executed successfully`);
4910
4935
  logCollector?.info(`\u2713 ${externalTool.name} executed successfully`);
4911
4936
  if (!executedToolsList.find((t) => t.id === externalTool.id)) {
4937
+ let resultSummary = null;
4938
+ if (result2) {
4939
+ const resultStr = typeof result2 === "string" ? result2 : JSON.stringify(result2);
4940
+ if (resultStr.length > 1e3) {
4941
+ resultSummary = {
4942
+ _preview: resultStr.substring(0, 1e3) + "... (truncated)",
4943
+ _totalLength: resultStr.length,
4944
+ _recordCount: Array.isArray(result2) ? result2.length : result2?.data?.length || result2?.contacts?.length || result2?.salesorders?.length || "unknown"
4945
+ };
4946
+ } else {
4947
+ resultSummary = result2;
4948
+ }
4949
+ }
4912
4950
  executedToolsList.push({
4913
4951
  id: externalTool.id,
4914
4952
  name: externalTool.name,
4915
4953
  params: toolInput,
4916
4954
  // The actual parameters used in this execution
4917
- result: result2
4918
- // Store the actual result data for populating deferred tool params
4955
+ result: resultSummary
4956
+ // Store summary instead of full result to save memory
4919
4957
  });
4920
4958
  logger.info(`[${this.getProviderName()}] Tracked executed tool: ${externalTool.name} with params: ${JSON.stringify(toolInput)}`);
4921
4959
  }
@@ -5023,8 +5061,6 @@ ${errorMsg}
5023
5061
  if (deferredTools.length > 0) {
5024
5062
  logger.info(`[${this.getProviderName()}] Passing ${deferredTools.length} deferred tools for Form generation`);
5025
5063
  }
5026
- logger.info(`[${this.getProviderName()}] passing deferred tools to the matching function: ${JSON.stringify(deferredTools, null, 2)}`);
5027
- logger.info(`[${this.getProviderName()}] passing executed tools to the matching function: ${JSON.stringify(executedToolsList, null, 2)}`);
5028
5064
  const matchResult = await this.matchComponentsFromAnalysis(
5029
5065
  textResponse,
5030
5066
  components,