@flutchai/flutch-sdk 0.1.26 → 0.1.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.cjs CHANGED
@@ -6119,7 +6119,8 @@ exports.McpRuntimeHttpClient = class McpRuntimeHttpClient {
6119
6119
  await runManager?.handleToolEnd(content);
6120
6120
  return {
6121
6121
  content,
6122
- success: result.success
6122
+ success: result.success,
6123
+ rawResult: result.success ? result.result : void 0
6123
6124
  };
6124
6125
  } catch (error) {
6125
6126
  this.logger.error(`Error executing tool ${toolName}:`, error);
@@ -6139,6 +6140,69 @@ exports.McpRuntimeHttpClient = __decorateClass([
6139
6140
  common.Injectable()
6140
6141
  ], exports.McpRuntimeHttpClient);
6141
6142
 
6143
+ // src/tools/attachment-summary.ts
6144
+ var MAX_SAMPLE_ROWS = 5;
6145
+ var MAX_TEXT_PREVIEW_LENGTH = 500;
6146
+ function generateAttachmentSummary(data, toolCallId) {
6147
+ try {
6148
+ if (Array.isArray(data) && data.length > 0 && isTabular(data)) {
6149
+ return generateTabularSummary(data, toolCallId);
6150
+ }
6151
+ return generateTextSummary(data, toolCallId);
6152
+ } catch {
6153
+ return `[Data stored as attachment: ${toolCallId}]`;
6154
+ }
6155
+ }
6156
+ function createGraphAttachment(data, toolName, toolCallId) {
6157
+ return {
6158
+ data,
6159
+ summary: generateAttachmentSummary(data, toolCallId),
6160
+ toolName,
6161
+ toolCallId,
6162
+ createdAt: Date.now()
6163
+ };
6164
+ }
6165
+ function isTabular(data) {
6166
+ const first = data[0];
6167
+ return first !== null && typeof first === "object" && !Array.isArray(first);
6168
+ }
6169
+ function generateTabularSummary(data, toolCallId) {
6170
+ const rowCount = data.length;
6171
+ const columns = Object.keys(data[0]);
6172
+ const sampleRows = data.slice(0, MAX_SAMPLE_ROWS);
6173
+ const rowLabel = rowCount === 1 ? "row" : "rows";
6174
+ const colLabel = columns.length === 1 ? "column" : "columns";
6175
+ let summary = `${rowCount} ${rowLabel}, ${columns.length} ${colLabel} (${columns.join(", ")})
6176
+ `;
6177
+ summary += `Sample data:
6178
+ `;
6179
+ for (const row of sampleRows) {
6180
+ try {
6181
+ summary += JSON.stringify(row) + "\n";
6182
+ } catch {
6183
+ summary += "[unserializable row]\n";
6184
+ }
6185
+ }
6186
+ summary += `[Data stored as attachment: ${toolCallId}]`;
6187
+ return summary;
6188
+ }
6189
+ function generateTextSummary(data, toolCallId) {
6190
+ let text;
6191
+ try {
6192
+ text = typeof data === "string" ? data : JSON.stringify(data);
6193
+ } catch {
6194
+ text = String(data);
6195
+ }
6196
+ const preview = text.slice(0, MAX_TEXT_PREVIEW_LENGTH);
6197
+ const suffix = text.length > MAX_TEXT_PREVIEW_LENGTH ? "..." : "";
6198
+ let summary = `${text.length} characters
6199
+ `;
6200
+ summary += `Preview: ${preview}${suffix}
6201
+ `;
6202
+ summary += `[Data stored as attachment: ${toolCallId}]`;
6203
+ return summary;
6204
+ }
6205
+
6142
6206
  // src/models/enums.ts
6143
6207
  var ModelProvider = /* @__PURE__ */ ((ModelProvider2) => {
6144
6208
  ModelProvider2["FLUTCH"] = "flutch";
@@ -7390,10 +7454,12 @@ exports.WithEndpoints = WithEndpoints;
7390
7454
  exports.WithUIEndpoints = WithUIEndpoints;
7391
7455
  exports.bootstrap = bootstrap;
7392
7456
  exports.createEndpointDescriptors = createEndpointDescriptors;
7457
+ exports.createGraphAttachment = createGraphAttachment;
7393
7458
  exports.createMongoClientAdapter = createMongoClientAdapter;
7394
7459
  exports.createStaticMessage = createStaticMessage;
7395
7460
  exports.findCallbackMethod = findCallbackMethod;
7396
7461
  exports.findEndpointMethod = findEndpointMethod;
7462
+ exports.generateAttachmentSummary = generateAttachmentSummary;
7397
7463
  exports.getCallbackMetadata = getCallbackMetadata;
7398
7464
  exports.getEndpointMetadata = getEndpointMetadata;
7399
7465
  exports.getUIEndpointClassMetadata = getUIEndpointClassMetadata;