mcp-use 1.4.1-canary.1 → 1.5.0-canary.0

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.
@@ -2408,7 +2408,7 @@ var MCPAgent = class {
2408
2408
  * This method formats and displays tool executions in a user-friendly way with syntax highlighting.
2409
2409
  */
2410
2410
  async *prettyStreamEvents(query, maxSteps, manageConnector = true, externalHistory, outputSchema) {
2411
- const { prettyStreamEvents: prettyStream } = await import("./display-LIYVTGEU.js");
2411
+ const { prettyStreamEvents: prettyStream } = await import("./display-YIYC6WJE.js");
2412
2412
  const finalResponse = "";
2413
2413
  for await (const _ of prettyStream(
2414
2414
  this.streamEvents(
@@ -166,9 +166,27 @@ function extractToolMessageContent(output) {
166
166
  return null;
167
167
  }
168
168
  __name(extractToolMessageContent, "extractToolMessageContent");
169
- function formatSearchToolsAsTree(tools) {
169
+ function formatSearchToolsAsTree(tools, meta, query) {
170
+ const metaLines = [];
171
+ if (meta) {
172
+ if (meta.total_tools !== void 0) {
173
+ metaLines.push(`Total tools: ${meta.total_tools}`);
174
+ }
175
+ if (meta.namespaces && meta.namespaces.length > 0) {
176
+ metaLines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
177
+ }
178
+ if (meta.result_count !== void 0) {
179
+ metaLines.push(`Results: ${meta.result_count}`);
180
+ }
181
+ }
170
182
  if (!Array.isArray(tools) || tools.length === 0) {
171
- return "(no tools found)";
183
+ const noResultsMsg = query ? `No tools found for query "${query}"` : "(no tools found)";
184
+ if (metaLines.length > 0) {
185
+ return `${metaLines.join("\n")}
186
+
187
+ ${noResultsMsg}`;
188
+ }
189
+ return noResultsMsg;
172
190
  }
173
191
  const toolsByServer = {};
174
192
  for (const tool of tools) {
@@ -179,6 +197,20 @@ function formatSearchToolsAsTree(tools) {
179
197
  toolsByServer[server].push(tool);
180
198
  }
181
199
  const lines = [];
200
+ if (meta) {
201
+ if (meta.total_tools !== void 0) {
202
+ lines.push(`Total tools: ${meta.total_tools}`);
203
+ }
204
+ if (meta.namespaces && meta.namespaces.length > 0) {
205
+ lines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
206
+ }
207
+ if (meta.result_count !== void 0) {
208
+ lines.push(`Results: ${meta.result_count}`);
209
+ }
210
+ if (lines.length > 0) {
211
+ lines.push("");
212
+ }
213
+ }
182
214
  const servers = Object.keys(toolsByServer).sort();
183
215
  for (let i = 0; i < servers.length; i++) {
184
216
  const server = servers[i];
@@ -193,11 +225,34 @@ function formatSearchToolsAsTree(tools) {
193
225
  const isLastTool = j === serverTools.length - 1;
194
226
  const indent = isLastServer ? " " : "\u2502 ";
195
227
  const toolPrefix = isLastTool ? "\u2514\u2500" : "\u251C\u2500";
196
- let toolLine = `${indent}${toolPrefix} ${tool.name}`;
228
+ const toolLine = `${indent}${toolPrefix} ${tool.name}`;
229
+ lines.push(toolLine);
197
230
  if (tool.description) {
198
- toolLine += chalk.dim(` - ${tool.description}`);
231
+ const descAlign = isLastTool ? " " : "\u2502 ";
232
+ const descriptionIndent = `${indent}${descAlign}`;
233
+ const indentLength = stripAnsi(descriptionIndent).length;
234
+ const availableWidth = Math.max(40, TERMINAL_WIDTH - indentLength - 4);
235
+ const words = tool.description.split(/(\s+)/);
236
+ const wrappedLines = [];
237
+ let currentLine = "";
238
+ for (const word of words) {
239
+ const testLine = currentLine + word;
240
+ if (stripAnsi(testLine).length <= availableWidth) {
241
+ currentLine = testLine;
242
+ } else {
243
+ if (currentLine) {
244
+ wrappedLines.push(currentLine.trimEnd());
245
+ }
246
+ currentLine = word.trimStart();
247
+ }
248
+ }
249
+ if (currentLine) {
250
+ wrappedLines.push(currentLine.trimEnd());
251
+ }
252
+ for (const descLine of wrappedLines) {
253
+ lines.push(`${descriptionIndent}${chalk.dim(descLine)}`);
254
+ }
199
255
  }
200
- lines.push(toolLine);
201
256
  }
202
257
  }
203
258
  return lines.join("\n");
@@ -242,6 +297,8 @@ function handleToolEnd(event) {
242
297
  }
243
298
  }
244
299
  if (toolName === "search_tools") {
300
+ const toolInput = event.data?.input;
301
+ const query = toolInput?.query;
245
302
  let actualContent = content;
246
303
  if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
247
304
  const innerContent = content.content;
@@ -255,8 +312,22 @@ function handleToolEnd(event) {
255
312
  }
256
313
  }
257
314
  }
315
+ if (typeof actualContent === "object" && actualContent !== null && !Array.isArray(actualContent) && "results" in actualContent && Array.isArray(actualContent.results)) {
316
+ const results = actualContent.results;
317
+ const contentWithMeta = actualContent;
318
+ const meta = contentWithMeta.meta;
319
+ const treeStr = formatSearchToolsAsTree(results, meta, query);
320
+ const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
321
+ const title2 = `${statusText}: ${toolName} - Result`;
322
+ printBox(treeStr, title2, void 0, false);
323
+ return;
324
+ }
258
325
  if (Array.isArray(actualContent)) {
259
- const treeStr = formatSearchToolsAsTree(actualContent);
326
+ const treeStr = formatSearchToolsAsTree(
327
+ actualContent,
328
+ void 0,
329
+ query
330
+ );
260
331
  const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
261
332
  const title2 = `${statusText}: ${toolName} - Result`;
262
333
  printBox(treeStr, title2, void 0, false);
package/dist/index.cjs CHANGED
@@ -722,9 +722,27 @@ function extractToolMessageContent(output) {
722
722
  }
723
723
  return null;
724
724
  }
725
- function formatSearchToolsAsTree(tools) {
725
+ function formatSearchToolsAsTree(tools, meta, query) {
726
+ const metaLines = [];
727
+ if (meta) {
728
+ if (meta.total_tools !== void 0) {
729
+ metaLines.push(`Total tools: ${meta.total_tools}`);
730
+ }
731
+ if (meta.namespaces && meta.namespaces.length > 0) {
732
+ metaLines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
733
+ }
734
+ if (meta.result_count !== void 0) {
735
+ metaLines.push(`Results: ${meta.result_count}`);
736
+ }
737
+ }
726
738
  if (!Array.isArray(tools) || tools.length === 0) {
727
- return "(no tools found)";
739
+ const noResultsMsg = query ? `No tools found for query "${query}"` : "(no tools found)";
740
+ if (metaLines.length > 0) {
741
+ return `${metaLines.join("\n")}
742
+
743
+ ${noResultsMsg}`;
744
+ }
745
+ return noResultsMsg;
728
746
  }
729
747
  const toolsByServer = {};
730
748
  for (const tool of tools) {
@@ -735,6 +753,20 @@ function formatSearchToolsAsTree(tools) {
735
753
  toolsByServer[server].push(tool);
736
754
  }
737
755
  const lines = [];
756
+ if (meta) {
757
+ if (meta.total_tools !== void 0) {
758
+ lines.push(`Total tools: ${meta.total_tools}`);
759
+ }
760
+ if (meta.namespaces && meta.namespaces.length > 0) {
761
+ lines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
762
+ }
763
+ if (meta.result_count !== void 0) {
764
+ lines.push(`Results: ${meta.result_count}`);
765
+ }
766
+ if (lines.length > 0) {
767
+ lines.push("");
768
+ }
769
+ }
738
770
  const servers = Object.keys(toolsByServer).sort();
739
771
  for (let i = 0; i < servers.length; i++) {
740
772
  const server = servers[i];
@@ -749,11 +781,34 @@ function formatSearchToolsAsTree(tools) {
749
781
  const isLastTool = j === serverTools.length - 1;
750
782
  const indent = isLastServer ? " " : "\u2502 ";
751
783
  const toolPrefix = isLastTool ? "\u2514\u2500" : "\u251C\u2500";
752
- let toolLine = `${indent}${toolPrefix} ${tool.name}`;
784
+ const toolLine = `${indent}${toolPrefix} ${tool.name}`;
785
+ lines.push(toolLine);
753
786
  if (tool.description) {
754
- toolLine += import_chalk.default.dim(` - ${tool.description}`);
787
+ const descAlign = isLastTool ? " " : "\u2502 ";
788
+ const descriptionIndent = `${indent}${descAlign}`;
789
+ const indentLength = stripAnsi(descriptionIndent).length;
790
+ const availableWidth = Math.max(40, TERMINAL_WIDTH - indentLength - 4);
791
+ const words = tool.description.split(/(\s+)/);
792
+ const wrappedLines = [];
793
+ let currentLine = "";
794
+ for (const word of words) {
795
+ const testLine = currentLine + word;
796
+ if (stripAnsi(testLine).length <= availableWidth) {
797
+ currentLine = testLine;
798
+ } else {
799
+ if (currentLine) {
800
+ wrappedLines.push(currentLine.trimEnd());
801
+ }
802
+ currentLine = word.trimStart();
803
+ }
804
+ }
805
+ if (currentLine) {
806
+ wrappedLines.push(currentLine.trimEnd());
807
+ }
808
+ for (const descLine of wrappedLines) {
809
+ lines.push(`${descriptionIndent}${import_chalk.default.dim(descLine)}`);
810
+ }
755
811
  }
756
- lines.push(toolLine);
757
812
  }
758
813
  }
759
814
  return lines.join("\n");
@@ -797,6 +852,8 @@ function handleToolEnd(event) {
797
852
  }
798
853
  }
799
854
  if (toolName === "search_tools") {
855
+ const toolInput = event.data?.input;
856
+ const query = toolInput?.query;
800
857
  let actualContent = content;
801
858
  if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
802
859
  const innerContent = content.content;
@@ -810,8 +867,22 @@ function handleToolEnd(event) {
810
867
  }
811
868
  }
812
869
  }
870
+ if (typeof actualContent === "object" && actualContent !== null && !Array.isArray(actualContent) && "results" in actualContent && Array.isArray(actualContent.results)) {
871
+ const results = actualContent.results;
872
+ const contentWithMeta = actualContent;
873
+ const meta = contentWithMeta.meta;
874
+ const treeStr = formatSearchToolsAsTree(results, meta, query);
875
+ const statusText = status === "success" ? import_chalk.default.green("Success") : import_chalk.default.red("Error");
876
+ const title2 = `${statusText}: ${toolName} - Result`;
877
+ printBox(treeStr, title2, void 0, false);
878
+ return;
879
+ }
813
880
  if (Array.isArray(actualContent)) {
814
- const treeStr = formatSearchToolsAsTree(actualContent);
881
+ const treeStr = formatSearchToolsAsTree(
882
+ actualContent,
883
+ void 0,
884
+ query
885
+ );
815
886
  const statusText = status === "success" ? import_chalk.default.green("Success") : import_chalk.default.red("Error");
816
887
  const title2 = `${statusText}: ${toolName} - Result`;
817
888
  printBox(treeStr, title2, void 0, false);
@@ -4016,18 +4087,17 @@ var BaseCodeExecutor = class {
4016
4087
  createSearchToolsFunction() {
4017
4088
  return async (query = "", detailLevel = "full") => {
4018
4089
  const allTools = [];
4090
+ const allNamespaces = /* @__PURE__ */ new Set();
4019
4091
  const queryLower = query.toLowerCase();
4020
4092
  const activeSessions = this.client.getAllActiveSessions();
4021
4093
  for (const [serverName, session] of Object.entries(activeSessions)) {
4022
4094
  if (serverName === "code_mode") continue;
4023
4095
  try {
4024
4096
  const tools = session.connector.tools;
4097
+ if (tools && tools.length > 0) {
4098
+ allNamespaces.add(serverName);
4099
+ }
4025
4100
  for (const tool of tools) {
4026
- if (query) {
4027
- const nameMatch = tool.name.toLowerCase().includes(queryLower);
4028
- const descMatch = tool.description?.toLowerCase().includes(queryLower);
4029
- if (!nameMatch && !descMatch) continue;
4030
- }
4031
4101
  if (detailLevel === "names") {
4032
4102
  allTools.push({ name: tool.name, server: serverName });
4033
4103
  } else if (detailLevel === "descriptions") {
@@ -4049,7 +4119,23 @@ var BaseCodeExecutor = class {
4049
4119
  logger.warn(`Failed to search tools in server ${serverName}: ${e}`);
4050
4120
  }
4051
4121
  }
4052
- return allTools;
4122
+ let filteredTools = allTools;
4123
+ if (query) {
4124
+ filteredTools = allTools.filter((tool) => {
4125
+ const nameMatch = tool.name.toLowerCase().includes(queryLower);
4126
+ const descMatch = tool.description?.toLowerCase().includes(queryLower);
4127
+ const serverMatch = tool.server.toLowerCase().includes(queryLower);
4128
+ return nameMatch || descMatch || serverMatch;
4129
+ });
4130
+ }
4131
+ return {
4132
+ meta: {
4133
+ total_tools: allTools.length,
4134
+ namespaces: Array.from(allNamespaces).sort(),
4135
+ result_count: filteredTools.length
4136
+ },
4137
+ results: filteredTools
4138
+ };
4053
4139
  };
4054
4140
  }
4055
4141
  };
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  ServerManager,
19
19
  Telemetry,
20
20
  setTelemetrySource
21
- } from "./chunk-35A6O3YH.js";
21
+ } from "./chunk-MCF5P6GJ.js";
22
22
  import {
23
23
  CodeModeConnector,
24
24
  PROMPTS
@@ -129,18 +129,17 @@ var BaseCodeExecutor = class {
129
129
  createSearchToolsFunction() {
130
130
  return async (query = "", detailLevel = "full") => {
131
131
  const allTools = [];
132
+ const allNamespaces = /* @__PURE__ */ new Set();
132
133
  const queryLower = query.toLowerCase();
133
134
  const activeSessions = this.client.getAllActiveSessions();
134
135
  for (const [serverName, session] of Object.entries(activeSessions)) {
135
136
  if (serverName === "code_mode") continue;
136
137
  try {
137
138
  const tools = session.connector.tools;
139
+ if (tools && tools.length > 0) {
140
+ allNamespaces.add(serverName);
141
+ }
138
142
  for (const tool of tools) {
139
- if (query) {
140
- const nameMatch = tool.name.toLowerCase().includes(queryLower);
141
- const descMatch = tool.description?.toLowerCase().includes(queryLower);
142
- if (!nameMatch && !descMatch) continue;
143
- }
144
143
  if (detailLevel === "names") {
145
144
  allTools.push({ name: tool.name, server: serverName });
146
145
  } else if (detailLevel === "descriptions") {
@@ -162,7 +161,23 @@ var BaseCodeExecutor = class {
162
161
  logger.warn(`Failed to search tools in server ${serverName}: ${e}`);
163
162
  }
164
163
  }
165
- return allTools;
164
+ let filteredTools = allTools;
165
+ if (query) {
166
+ filteredTools = allTools.filter((tool) => {
167
+ const nameMatch = tool.name.toLowerCase().includes(queryLower);
168
+ const descMatch = tool.description?.toLowerCase().includes(queryLower);
169
+ const serverMatch = tool.server.toLowerCase().includes(queryLower);
170
+ return nameMatch || descMatch || serverMatch;
171
+ });
172
+ }
173
+ return {
174
+ meta: {
175
+ total_tools: allTools.length,
176
+ namespaces: Array.from(allNamespaces).sort(),
177
+ result_count: filteredTools.length
178
+ },
179
+ results: filteredTools
180
+ };
166
181
  };
167
182
  }
168
183
  };
@@ -41,7 +41,11 @@ export declare function formatSearchToolsAsTree(tools: Array<{
41
41
  server: string;
42
42
  name: string;
43
43
  description?: string;
44
- }>): string;
44
+ }>, meta?: {
45
+ total_tools?: number;
46
+ namespaces?: string[];
47
+ result_count?: number;
48
+ }, query?: string): string;
45
49
  /**
46
50
  * Handle tool end event with pretty printing
47
51
  */
@@ -1 +1 @@
1
- {"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../../src/agents/display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EACpE,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7E,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CA0HR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,QA8M/C;AAED;;GAEG;AACH,wBAAuB,kBAAkB,CACvC,qBAAqB,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GAC7D,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAoCpC"}
@@ -722,9 +722,27 @@ function extractToolMessageContent(output) {
722
722
  }
723
723
  return null;
724
724
  }
725
- function formatSearchToolsAsTree(tools) {
725
+ function formatSearchToolsAsTree(tools, meta, query) {
726
+ const metaLines = [];
727
+ if (meta) {
728
+ if (meta.total_tools !== void 0) {
729
+ metaLines.push(`Total tools: ${meta.total_tools}`);
730
+ }
731
+ if (meta.namespaces && meta.namespaces.length > 0) {
732
+ metaLines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
733
+ }
734
+ if (meta.result_count !== void 0) {
735
+ metaLines.push(`Results: ${meta.result_count}`);
736
+ }
737
+ }
726
738
  if (!Array.isArray(tools) || tools.length === 0) {
727
- return "(no tools found)";
739
+ const noResultsMsg = query ? `No tools found for query "${query}"` : "(no tools found)";
740
+ if (metaLines.length > 0) {
741
+ return `${metaLines.join("\n")}
742
+
743
+ ${noResultsMsg}`;
744
+ }
745
+ return noResultsMsg;
728
746
  }
729
747
  const toolsByServer = {};
730
748
  for (const tool of tools) {
@@ -735,6 +753,20 @@ function formatSearchToolsAsTree(tools) {
735
753
  toolsByServer[server].push(tool);
736
754
  }
737
755
  const lines = [];
756
+ if (meta) {
757
+ if (meta.total_tools !== void 0) {
758
+ lines.push(`Total tools: ${meta.total_tools}`);
759
+ }
760
+ if (meta.namespaces && meta.namespaces.length > 0) {
761
+ lines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
762
+ }
763
+ if (meta.result_count !== void 0) {
764
+ lines.push(`Results: ${meta.result_count}`);
765
+ }
766
+ if (lines.length > 0) {
767
+ lines.push("");
768
+ }
769
+ }
738
770
  const servers = Object.keys(toolsByServer).sort();
739
771
  for (let i = 0; i < servers.length; i++) {
740
772
  const server = servers[i];
@@ -749,11 +781,34 @@ function formatSearchToolsAsTree(tools) {
749
781
  const isLastTool = j === serverTools.length - 1;
750
782
  const indent = isLastServer ? " " : "\u2502 ";
751
783
  const toolPrefix = isLastTool ? "\u2514\u2500" : "\u251C\u2500";
752
- let toolLine = `${indent}${toolPrefix} ${tool.name}`;
784
+ const toolLine = `${indent}${toolPrefix} ${tool.name}`;
785
+ lines.push(toolLine);
753
786
  if (tool.description) {
754
- toolLine += import_chalk.default.dim(` - ${tool.description}`);
787
+ const descAlign = isLastTool ? " " : "\u2502 ";
788
+ const descriptionIndent = `${indent}${descAlign}`;
789
+ const indentLength = stripAnsi(descriptionIndent).length;
790
+ const availableWidth = Math.max(40, TERMINAL_WIDTH - indentLength - 4);
791
+ const words = tool.description.split(/(\s+)/);
792
+ const wrappedLines = [];
793
+ let currentLine = "";
794
+ for (const word of words) {
795
+ const testLine = currentLine + word;
796
+ if (stripAnsi(testLine).length <= availableWidth) {
797
+ currentLine = testLine;
798
+ } else {
799
+ if (currentLine) {
800
+ wrappedLines.push(currentLine.trimEnd());
801
+ }
802
+ currentLine = word.trimStart();
803
+ }
804
+ }
805
+ if (currentLine) {
806
+ wrappedLines.push(currentLine.trimEnd());
807
+ }
808
+ for (const descLine of wrappedLines) {
809
+ lines.push(`${descriptionIndent}${import_chalk.default.dim(descLine)}`);
810
+ }
755
811
  }
756
- lines.push(toolLine);
757
812
  }
758
813
  }
759
814
  return lines.join("\n");
@@ -797,6 +852,8 @@ function handleToolEnd(event) {
797
852
  }
798
853
  }
799
854
  if (toolName === "search_tools") {
855
+ const toolInput = event.data?.input;
856
+ const query = toolInput?.query;
800
857
  let actualContent = content;
801
858
  if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
802
859
  const innerContent = content.content;
@@ -810,8 +867,22 @@ function handleToolEnd(event) {
810
867
  }
811
868
  }
812
869
  }
870
+ if (typeof actualContent === "object" && actualContent !== null && !Array.isArray(actualContent) && "results" in actualContent && Array.isArray(actualContent.results)) {
871
+ const results = actualContent.results;
872
+ const contentWithMeta = actualContent;
873
+ const meta = contentWithMeta.meta;
874
+ const treeStr = formatSearchToolsAsTree(results, meta, query);
875
+ const statusText = status === "success" ? import_chalk.default.green("Success") : import_chalk.default.red("Error");
876
+ const title2 = `${statusText}: ${toolName} - Result`;
877
+ printBox(treeStr, title2, void 0, false);
878
+ return;
879
+ }
813
880
  if (Array.isArray(actualContent)) {
814
- const treeStr = formatSearchToolsAsTree(actualContent);
881
+ const treeStr = formatSearchToolsAsTree(
882
+ actualContent,
883
+ void 0,
884
+ query
885
+ );
815
886
  const statusText = status === "success" ? import_chalk.default.green("Success") : import_chalk.default.red("Error");
816
887
  const title2 = `${statusText}: ${toolName} - Result`;
817
888
  printBox(treeStr, title2, void 0, false);
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  MCPAgent,
6
6
  RemoteAgent
7
- } from "../../chunk-35A6O3YH.js";
7
+ } from "../../chunk-MCF5P6GJ.js";
8
8
  import {
9
9
  PROMPTS
10
10
  } from "../../chunk-WERYJ6PF.js";
@@ -722,9 +722,27 @@ function extractToolMessageContent(output) {
722
722
  }
723
723
  return null;
724
724
  }
725
- function formatSearchToolsAsTree(tools) {
725
+ function formatSearchToolsAsTree(tools, meta, query) {
726
+ const metaLines = [];
727
+ if (meta) {
728
+ if (meta.total_tools !== void 0) {
729
+ metaLines.push(`Total tools: ${meta.total_tools}`);
730
+ }
731
+ if (meta.namespaces && meta.namespaces.length > 0) {
732
+ metaLines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
733
+ }
734
+ if (meta.result_count !== void 0) {
735
+ metaLines.push(`Results: ${meta.result_count}`);
736
+ }
737
+ }
726
738
  if (!Array.isArray(tools) || tools.length === 0) {
727
- return "(no tools found)";
739
+ const noResultsMsg = query ? `No tools found for query "${query}"` : "(no tools found)";
740
+ if (metaLines.length > 0) {
741
+ return `${metaLines.join("\n")}
742
+
743
+ ${noResultsMsg}`;
744
+ }
745
+ return noResultsMsg;
728
746
  }
729
747
  const toolsByServer = {};
730
748
  for (const tool of tools) {
@@ -735,6 +753,20 @@ function formatSearchToolsAsTree(tools) {
735
753
  toolsByServer[server].push(tool);
736
754
  }
737
755
  const lines = [];
756
+ if (meta) {
757
+ if (meta.total_tools !== void 0) {
758
+ lines.push(`Total tools: ${meta.total_tools}`);
759
+ }
760
+ if (meta.namespaces && meta.namespaces.length > 0) {
761
+ lines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
762
+ }
763
+ if (meta.result_count !== void 0) {
764
+ lines.push(`Results: ${meta.result_count}`);
765
+ }
766
+ if (lines.length > 0) {
767
+ lines.push("");
768
+ }
769
+ }
738
770
  const servers = Object.keys(toolsByServer).sort();
739
771
  for (let i = 0; i < servers.length; i++) {
740
772
  const server = servers[i];
@@ -749,11 +781,34 @@ function formatSearchToolsAsTree(tools) {
749
781
  const isLastTool = j === serverTools.length - 1;
750
782
  const indent = isLastServer ? " " : "\u2502 ";
751
783
  const toolPrefix = isLastTool ? "\u2514\u2500" : "\u251C\u2500";
752
- let toolLine = `${indent}${toolPrefix} ${tool.name}`;
784
+ const toolLine = `${indent}${toolPrefix} ${tool.name}`;
785
+ lines.push(toolLine);
753
786
  if (tool.description) {
754
- toolLine += import_chalk.default.dim(` - ${tool.description}`);
787
+ const descAlign = isLastTool ? " " : "\u2502 ";
788
+ const descriptionIndent = `${indent}${descAlign}`;
789
+ const indentLength = stripAnsi(descriptionIndent).length;
790
+ const availableWidth = Math.max(40, TERMINAL_WIDTH - indentLength - 4);
791
+ const words = tool.description.split(/(\s+)/);
792
+ const wrappedLines = [];
793
+ let currentLine = "";
794
+ for (const word of words) {
795
+ const testLine = currentLine + word;
796
+ if (stripAnsi(testLine).length <= availableWidth) {
797
+ currentLine = testLine;
798
+ } else {
799
+ if (currentLine) {
800
+ wrappedLines.push(currentLine.trimEnd());
801
+ }
802
+ currentLine = word.trimStart();
803
+ }
804
+ }
805
+ if (currentLine) {
806
+ wrappedLines.push(currentLine.trimEnd());
807
+ }
808
+ for (const descLine of wrappedLines) {
809
+ lines.push(`${descriptionIndent}${import_chalk.default.dim(descLine)}`);
810
+ }
755
811
  }
756
- lines.push(toolLine);
757
812
  }
758
813
  }
759
814
  return lines.join("\n");
@@ -797,6 +852,8 @@ function handleToolEnd(event) {
797
852
  }
798
853
  }
799
854
  if (toolName === "search_tools") {
855
+ const toolInput = event.data?.input;
856
+ const query = toolInput?.query;
800
857
  let actualContent = content;
801
858
  if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
802
859
  const innerContent = content.content;
@@ -810,8 +867,22 @@ function handleToolEnd(event) {
810
867
  }
811
868
  }
812
869
  }
870
+ if (typeof actualContent === "object" && actualContent !== null && !Array.isArray(actualContent) && "results" in actualContent && Array.isArray(actualContent.results)) {
871
+ const results = actualContent.results;
872
+ const contentWithMeta = actualContent;
873
+ const meta = contentWithMeta.meta;
874
+ const treeStr = formatSearchToolsAsTree(results, meta, query);
875
+ const statusText = status === "success" ? import_chalk.default.green("Success") : import_chalk.default.red("Error");
876
+ const title2 = `${statusText}: ${toolName} - Result`;
877
+ printBox(treeStr, title2, void 0, false);
878
+ return;
879
+ }
813
880
  if (Array.isArray(actualContent)) {
814
- const treeStr = formatSearchToolsAsTree(actualContent);
881
+ const treeStr = formatSearchToolsAsTree(
882
+ actualContent,
883
+ void 0,
884
+ query
885
+ );
815
886
  const statusText = status === "success" ? import_chalk.default.green("Success") : import_chalk.default.red("Error");
816
887
  const title2 = `${statusText}: ${toolName} - Result`;
817
888
  printBox(treeStr, title2, void 0, false);
@@ -9,7 +9,7 @@ import {
9
9
  MCPAgent,
10
10
  ObservabilityManager,
11
11
  RemoteAgent
12
- } from "../chunk-35A6O3YH.js";
12
+ } from "../chunk-MCF5P6GJ.js";
13
13
  import {
14
14
  BrowserMCPClient,
15
15
  BrowserOAuthClientProvider,
@@ -1,5 +1,5 @@
1
1
  export { BaseCodeExecutor } from "./executors/base.js";
2
- export type { ExecutionResult, SearchToolsFunction, ToolNamespaceInfo, ToolSearchResult, } from "./executors/base.js";
2
+ export type { ExecutionResult, SearchToolsFunction, ToolNamespaceInfo, ToolSearchResult, ToolSearchMeta, ToolSearchResponse, } from "./executors/base.js";
3
3
  export { E2BCodeExecutor } from "./executors/e2b.js";
4
4
  export { VMCodeExecutor, isVMAvailable } from "./executors/vm.js";
5
5
  export { BaseCodeExecutor as CodeExecutor } from "./executors/base.js";
@@ -1 +1 @@
1
- {"version":3,"file":"codeExecutor.d.ts","sourceRoot":"","sources":["../../../src/client/codeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"codeExecutor.d.ts","sourceRoot":"","sources":["../../../src/client/codeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -12,7 +12,16 @@ export interface ToolSearchResult {
12
12
  description?: string;
13
13
  input_schema?: Tool["inputSchema"];
14
14
  }
15
- export type SearchToolsFunction = (query?: string, detailLevel?: "names" | "descriptions" | "full") => Promise<ToolSearchResult[]>;
15
+ export interface ToolSearchMeta {
16
+ total_tools: number;
17
+ namespaces: string[];
18
+ result_count: number;
19
+ }
20
+ export interface ToolSearchResponse {
21
+ meta: ToolSearchMeta;
22
+ results: ToolSearchResult[];
23
+ }
24
+ export type SearchToolsFunction = (query?: string, detailLevel?: "names" | "descriptions" | "full") => Promise<ToolSearchResponse>;
16
25
  export interface ToolNamespaceInfo {
17
26
  serverName: string;
18
27
  tools: Tool[];