@mcp-use/inspector 0.9.0-canary.1 → 0.9.0-canary.2

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.
@@ -0,0 +1,480 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-cuGVED_J.js","assets/index-BaR5HKmC.js","assets/index-Br7cLVs6.css"])))=>i.map(i=>d[i]);
2
+ import { _ as __name, a as __vitePreload } from "./index-BaR5HKmC.js";
3
+ var chalk = null;
4
+ var highlight = null;
5
+ var stripVTControlCharacters = null;
6
+ var displayPackagesWarned = false;
7
+ var isNode = typeof process !== "undefined" && process.versions?.node;
8
+ (async () => {
9
+ if (isNode) {
10
+ try {
11
+ const utilModule = await __vitePreload(() => import("./util-D59LNlyU.js").then((n) => n.u), true ? [] : void 0);
12
+ stripVTControlCharacters = utilModule.stripVTControlCharacters;
13
+ } catch {
14
+ }
15
+ }
16
+ try {
17
+ const chalkModule = await __vitePreload(() => import("./index-BMuvzxLw.js"), true ? [] : void 0);
18
+ chalk = chalkModule.default;
19
+ } catch {
20
+ }
21
+ try {
22
+ const cliHighlightModule = await __vitePreload(() => import("./index-cuGVED_J.js").then((n) => n.i), true ? __vite__mapDeps([0,1,2]) : void 0);
23
+ highlight = cliHighlightModule.highlight;
24
+ } catch {
25
+ }
26
+ if (isNode && (!chalk || !highlight)) {
27
+ if (!displayPackagesWarned) {
28
+ displayPackagesWarned = true;
29
+ console.warn(
30
+ "\n✨ For enhanced console output with colors and syntax highlighting, install:\n\n npm install chalk cli-highlight\n # or\n pnpm add chalk cli-highlight\n"
31
+ );
32
+ }
33
+ }
34
+ })();
35
+ var TERMINAL_WIDTH = process.stdout.columns || 120;
36
+ var chalkHelper = {
37
+ gray: /* @__PURE__ */ __name((str) => chalk?.gray(str) ?? str, "gray"),
38
+ bold: {
39
+ white: /* @__PURE__ */ __name((str) => chalk?.bold?.white(str) ?? str, "white")
40
+ },
41
+ bgGray: /* @__PURE__ */ __name((str) => chalk?.bgGray(str) ?? str, "bgGray"),
42
+ cyan: /* @__PURE__ */ __name((str) => chalk?.cyan(str) ?? str, "cyan"),
43
+ dim: /* @__PURE__ */ __name((str) => chalk?.dim(str) ?? str, "dim"),
44
+ red: /* @__PURE__ */ __name((str) => chalk?.red(str) ?? str, "red"),
45
+ green: /* @__PURE__ */ __name((str) => chalk?.green(str) ?? str, "green")
46
+ };
47
+ function highlightCode(content, language) {
48
+ if (!highlight) {
49
+ return content;
50
+ }
51
+ try {
52
+ return highlight(content, {
53
+ language: language ?? "javascript",
54
+ ignoreIllegals: true
55
+ });
56
+ } catch {
57
+ return content;
58
+ }
59
+ }
60
+ __name(highlightCode, "highlightCode");
61
+ function stripAnsi(str) {
62
+ if (stripVTControlCharacters) {
63
+ return stripVTControlCharacters(str);
64
+ }
65
+ return str.replace(/\x1b\[[0-9;]*m/g, "");
66
+ }
67
+ __name(stripAnsi, "stripAnsi");
68
+ function wrapAnsiLine(line, maxWidth) {
69
+ const stripped = stripAnsi(line);
70
+ if (stripped.length <= maxWidth) return [line];
71
+ const result = [];
72
+ let visibleCount = 0;
73
+ let current = "";
74
+ let i = 0;
75
+ while (i < line.length) {
76
+ const char = line[i];
77
+ if (char === "\x1B") {
78
+ let sequence = char;
79
+ i++;
80
+ while (i < line.length) {
81
+ const nextChar = line[i];
82
+ sequence += nextChar;
83
+ i++;
84
+ if (nextChar === "m") break;
85
+ }
86
+ current += sequence;
87
+ continue;
88
+ }
89
+ current += char;
90
+ visibleCount++;
91
+ i++;
92
+ if (visibleCount >= maxWidth) {
93
+ result.push(current);
94
+ current = "";
95
+ visibleCount = 0;
96
+ }
97
+ }
98
+ if (current) result.push(current);
99
+ return result;
100
+ }
101
+ __name(wrapAnsiLine, "wrapAnsiLine");
102
+ function printBox(content, title, language, bgColor = false) {
103
+ const width = TERMINAL_WIDTH;
104
+ let displayContent = content;
105
+ if (language) {
106
+ try {
107
+ displayContent = highlightCode(content, language);
108
+ } catch {
109
+ }
110
+ }
111
+ const lines = displayContent.split("\n").flatMap((line) => wrapAnsiLine(line, width - 4));
112
+ console.log(chalkHelper.gray("┌" + "─".repeat(width - 2) + "┐"));
113
+ if (title) {
114
+ const stripped = stripAnsi(title);
115
+ const lineText = `${title} `;
116
+ const padding = Math.max(0, width - 4 - stripped.length - 2);
117
+ console.log(
118
+ chalkHelper.gray("│ ") + chalkHelper.bold.white(lineText) + " ".repeat(padding) + chalkHelper.gray(" │")
119
+ );
120
+ console.log(chalkHelper.gray("├" + "─".repeat(width - 2) + "┤"));
121
+ }
122
+ lines.forEach((line) => {
123
+ const stripped = stripAnsi(line);
124
+ const padding = Math.max(0, width - 4 - stripped.length);
125
+ const finalLine = bgColor ? chalkHelper.bgGray(line + " ".repeat(padding)) : line + " ".repeat(padding);
126
+ console.log(chalkHelper.gray("│ ") + finalLine + chalkHelper.gray(" │"));
127
+ });
128
+ console.log(chalkHelper.gray("└" + "─".repeat(width - 2) + "┘"));
129
+ }
130
+ __name(printBox, "printBox");
131
+ function extractCodeFromToolInput(input) {
132
+ if (typeof input === "object" && input !== null && "code" in input) {
133
+ const inputObj = input;
134
+ return typeof inputObj.code === "string" ? inputObj.code : null;
135
+ }
136
+ return null;
137
+ }
138
+ __name(extractCodeFromToolInput, "extractCodeFromToolInput");
139
+ function isExecuteCodeResult(obj) {
140
+ if (typeof obj !== "object" || obj === null) return false;
141
+ const result = obj;
142
+ return "result" in result && "logs" in result && Array.isArray(result.logs) && "execution_time" in result && typeof result.execution_time === "number" && "error" in result && (typeof result.error === "string" || result.error === null);
143
+ }
144
+ __name(isExecuteCodeResult, "isExecuteCodeResult");
145
+ function parseExecuteCodeResult(output) {
146
+ try {
147
+ if (typeof output === "string") {
148
+ const parsed = JSON.parse(output);
149
+ if (isExecuteCodeResult(parsed)) {
150
+ return parsed;
151
+ }
152
+ }
153
+ if (isExecuteCodeResult(output)) {
154
+ return output;
155
+ }
156
+ } catch (e) {
157
+ }
158
+ return null;
159
+ }
160
+ __name(parseExecuteCodeResult, "parseExecuteCodeResult");
161
+ function renderContent(content) {
162
+ if (content === null || content === void 0) {
163
+ return "null";
164
+ }
165
+ if (typeof content === "object") {
166
+ return JSON.stringify(content, null, 2);
167
+ }
168
+ return String(content);
169
+ }
170
+ __name(renderContent, "renderContent");
171
+ function unwrapToolInput(input) {
172
+ if (typeof input === "object" && input !== null && "input" in input) {
173
+ const inputObj = input;
174
+ if (typeof inputObj.input === "string") {
175
+ try {
176
+ return JSON.parse(inputObj.input);
177
+ } catch (e) {
178
+ return inputObj.input;
179
+ }
180
+ }
181
+ }
182
+ return input;
183
+ }
184
+ __name(unwrapToolInput, "unwrapToolInput");
185
+ function handleToolStart(event) {
186
+ const toolName = event.name || "unknown";
187
+ let input = event.data?.input || {};
188
+ input = unwrapToolInput(input);
189
+ const code = extractCodeFromToolInput(input);
190
+ if (code) {
191
+ printBox(code, `${toolName} - input`, "javascript", false);
192
+ const otherParams = { ...input };
193
+ delete otherParams.code;
194
+ if (Object.keys(otherParams).length > 0) {
195
+ printBox(renderContent(otherParams), "Other Parameters", "json", false);
196
+ }
197
+ } else {
198
+ printBox(renderContent(input), `${toolName} - input`, "json", false);
199
+ }
200
+ }
201
+ __name(handleToolStart, "handleToolStart");
202
+ function extractToolMessageContent(output) {
203
+ try {
204
+ if (typeof output === "object" && output !== null && "name" in output && "content" in output) {
205
+ const outputObj = output;
206
+ const toolName = (typeof outputObj.name === "string" ? outputObj.name : null) || "unknown";
207
+ const lcKwargs = outputObj.lc_kwargs;
208
+ const status = lcKwargs?.status || outputObj.status || "unknown";
209
+ let content = outputObj.content;
210
+ if (typeof content === "string") {
211
+ try {
212
+ content = JSON.parse(content);
213
+ } catch (e) {
214
+ }
215
+ }
216
+ return { toolName, status, content };
217
+ }
218
+ } catch (e) {
219
+ }
220
+ return null;
221
+ }
222
+ __name(extractToolMessageContent, "extractToolMessageContent");
223
+ function formatSearchToolsAsTree(tools, meta, query) {
224
+ const metaLines = [];
225
+ if (meta) {
226
+ if (meta.total_tools !== void 0) {
227
+ metaLines.push(`Total tools: ${meta.total_tools}`);
228
+ }
229
+ if (meta.namespaces && meta.namespaces.length > 0) {
230
+ metaLines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
231
+ }
232
+ if (meta.result_count !== void 0) {
233
+ metaLines.push(`Results: ${meta.result_count}`);
234
+ }
235
+ }
236
+ if (!Array.isArray(tools) || tools.length === 0) {
237
+ const noResultsMsg = query ? `No tools found for query "${query}"` : "(no tools found)";
238
+ if (metaLines.length > 0) {
239
+ return `${metaLines.join("\n")}
240
+
241
+ ${noResultsMsg}`;
242
+ }
243
+ return noResultsMsg;
244
+ }
245
+ const toolsByServer = {};
246
+ for (const tool of tools) {
247
+ const server = tool.server || "unknown";
248
+ if (!toolsByServer[server]) {
249
+ toolsByServer[server] = [];
250
+ }
251
+ toolsByServer[server].push(tool);
252
+ }
253
+ const lines = [];
254
+ if (meta) {
255
+ if (meta.total_tools !== void 0) {
256
+ lines.push(`Total tools: ${meta.total_tools}`);
257
+ }
258
+ if (meta.namespaces && meta.namespaces.length > 0) {
259
+ lines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
260
+ }
261
+ if (meta.result_count !== void 0) {
262
+ lines.push(`Results: ${meta.result_count}`);
263
+ }
264
+ if (lines.length > 0) {
265
+ lines.push("");
266
+ }
267
+ }
268
+ const servers = Object.keys(toolsByServer).sort();
269
+ for (let i = 0; i < servers.length; i++) {
270
+ const server = servers[i];
271
+ const serverTools = toolsByServer[server];
272
+ const isLastServer = i === servers.length - 1;
273
+ const serverPrefix = isLastServer ? "└─" : "├─";
274
+ lines.push(
275
+ `${serverPrefix} ${chalkHelper.cyan(server)} (${serverTools.length} tools)`
276
+ );
277
+ for (let j = 0; j < serverTools.length; j++) {
278
+ const tool = serverTools[j];
279
+ const isLastTool = j === serverTools.length - 1;
280
+ const indent = isLastServer ? " " : "│ ";
281
+ const toolPrefix = isLastTool ? "└─" : "├─";
282
+ const toolLine = `${indent}${toolPrefix} ${tool.name}`;
283
+ lines.push(toolLine);
284
+ if (tool.description) {
285
+ const descAlign = isLastTool ? " " : "│ ";
286
+ const descriptionIndent = `${indent}${descAlign}`;
287
+ const indentLength = stripAnsi(descriptionIndent).length;
288
+ const availableWidth = Math.max(40, TERMINAL_WIDTH - indentLength - 4);
289
+ const words = tool.description.split(/(\s+)/);
290
+ const wrappedLines = [];
291
+ let currentLine = "";
292
+ for (const word of words) {
293
+ const testLine = currentLine + word;
294
+ if (stripAnsi(testLine).length <= availableWidth) {
295
+ currentLine = testLine;
296
+ } else {
297
+ if (currentLine) {
298
+ wrappedLines.push(currentLine.trimEnd());
299
+ }
300
+ currentLine = word.trimStart();
301
+ }
302
+ }
303
+ if (currentLine) {
304
+ wrappedLines.push(currentLine.trimEnd());
305
+ }
306
+ for (const descLine of wrappedLines) {
307
+ lines.push(`${descriptionIndent}${chalkHelper.dim(descLine)}`);
308
+ }
309
+ }
310
+ }
311
+ }
312
+ return lines.join("\n");
313
+ }
314
+ __name(formatSearchToolsAsTree, "formatSearchToolsAsTree");
315
+ function handleToolEnd(event) {
316
+ const output = event.data?.output;
317
+ const toolMessage = extractToolMessageContent(output);
318
+ if (toolMessage) {
319
+ const { toolName, status, content } = toolMessage;
320
+ if (toolName === "execute_code") {
321
+ let actualContent = content;
322
+ if (typeof content === "object" && content !== null && "content" in content) {
323
+ const innerContent = content.content;
324
+ if (Array.isArray(innerContent) && innerContent.length > 0) {
325
+ if (innerContent[0].type === "text" && innerContent[0].text) {
326
+ actualContent = innerContent[0].text;
327
+ }
328
+ }
329
+ }
330
+ const execResult2 = parseExecuteCodeResult(actualContent);
331
+ if (execResult2) {
332
+ const timeMs = execResult2.execution_time ? Math.round(execResult2.execution_time * 1e3) : 0;
333
+ const timeStr = `${timeMs}ms`;
334
+ const isError2 = execResult2.error !== null && execResult2.error !== void 0 && execResult2.error !== "";
335
+ const statusText = isError2 ? chalkHelper.red("error") : chalkHelper.green("success");
336
+ const title2 = `${toolName} - ${statusText} - ${timeStr}`;
337
+ if (execResult2.result !== null && execResult2.result !== void 0) {
338
+ const resultStr = renderContent(execResult2.result);
339
+ const language3 = typeof execResult2.result === "object" ? "json" : void 0;
340
+ printBox(resultStr, title2, language3, false);
341
+ } else {
342
+ printBox("(no result)", title2, void 0, false);
343
+ }
344
+ if (execResult2.logs && execResult2.logs.length > 0) {
345
+ printBox(execResult2.logs.join("\n"), `Logs`, void 0, false);
346
+ }
347
+ if (execResult2.error) {
348
+ printBox(
349
+ execResult2.error,
350
+ chalkHelper.red("Error"),
351
+ void 0,
352
+ false
353
+ );
354
+ }
355
+ return;
356
+ }
357
+ }
358
+ if (toolName === "search_tools") {
359
+ const toolInput = event.data?.input;
360
+ const query = toolInput?.query;
361
+ let actualContent = content;
362
+ if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
363
+ const innerContent = content.content;
364
+ if (Array.isArray(innerContent) && innerContent.length > 0) {
365
+ if (innerContent[0].type === "text" && innerContent[0].text) {
366
+ try {
367
+ actualContent = JSON.parse(innerContent[0].text);
368
+ } catch (e) {
369
+ actualContent = innerContent[0].text;
370
+ }
371
+ }
372
+ }
373
+ }
374
+ if (typeof actualContent === "object" && actualContent !== null && !Array.isArray(actualContent) && "results" in actualContent && Array.isArray(actualContent.results)) {
375
+ const results = actualContent.results;
376
+ const contentWithMeta = actualContent;
377
+ const meta = contentWithMeta.meta;
378
+ const treeStr = formatSearchToolsAsTree(results, meta, query);
379
+ const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
380
+ const title2 = `${statusText}: ${toolName} - Result`;
381
+ printBox(treeStr, title2, void 0, false);
382
+ return;
383
+ }
384
+ if (Array.isArray(actualContent)) {
385
+ const treeStr = formatSearchToolsAsTree(
386
+ actualContent,
387
+ void 0,
388
+ query
389
+ );
390
+ const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
391
+ const title2 = `${statusText}: ${toolName} - Result`;
392
+ printBox(treeStr, title2, void 0, false);
393
+ return;
394
+ }
395
+ }
396
+ const contentObj = typeof content === "object" && content !== null ? content : null;
397
+ const isError = contentObj && "isError" in contentObj && contentObj.isError === true || status === "error";
398
+ let displayContent = content;
399
+ if (typeof content === "object" && content !== null && "content" in content) {
400
+ displayContent = content.content;
401
+ if (Array.isArray(displayContent) && displayContent.length > 0) {
402
+ if (displayContent[0].type === "text" && displayContent[0].text) {
403
+ displayContent = displayContent[0].text;
404
+ }
405
+ }
406
+ }
407
+ const contentStr = renderContent(displayContent);
408
+ const language2 = typeof displayContent === "object" ? "json" : void 0;
409
+ const statusLabel = status === "success" ? chalkHelper.green("Success") : isError ? chalkHelper.red("Error") : "Result";
410
+ const title = `${statusLabel}: ${toolName} - Result`;
411
+ printBox(contentStr, title, language2, false);
412
+ return;
413
+ }
414
+ const execResult = parseExecuteCodeResult(output);
415
+ if (execResult) {
416
+ const timeMs = execResult.execution_time ? Math.round(execResult.execution_time * 1e3) : 0;
417
+ const timeStr = `${timeMs}ms`;
418
+ if (execResult.result !== null && execResult.result !== void 0) {
419
+ const resultStr = renderContent(execResult.result);
420
+ const language2 = typeof execResult.result === "object" ? "json" : void 0;
421
+ printBox(resultStr, `Result - ${timeStr}`, language2, false);
422
+ }
423
+ if (execResult.logs && execResult.logs.length > 0) {
424
+ printBox(execResult.logs.join("\n"), `Logs`, void 0, false);
425
+ }
426
+ if (execResult.error) {
427
+ printBox(execResult.error, chalkHelper.red("Error"), void 0, false);
428
+ }
429
+ return;
430
+ }
431
+ const outputStr = renderContent(output);
432
+ const language = typeof output === "object" ? "json" : void 0;
433
+ printBox(outputStr, "Result", language, false);
434
+ }
435
+ __name(handleToolEnd, "handleToolEnd");
436
+ async function* prettyStreamEvents(streamEventsGenerator) {
437
+ let finalResponse = "";
438
+ let isFirstTextChunk = true;
439
+ let hasStreamedText = false;
440
+ for await (const event of streamEventsGenerator) {
441
+ if (event.event === "on_tool_start") {
442
+ if (hasStreamedText) {
443
+ process.stdout.write("\n");
444
+ hasStreamedText = false;
445
+ isFirstTextChunk = true;
446
+ }
447
+ handleToolStart(event);
448
+ } else if (event.event === "on_tool_end") {
449
+ handleToolEnd(event);
450
+ } else if (event.event === "on_chat_model_stream") {
451
+ if (event.data?.chunk?.text) {
452
+ const text = event.data.chunk.text;
453
+ if (typeof text === "string" && text.length > 0) {
454
+ if (isFirstTextChunk) {
455
+ process.stdout.write("\n🤖 ");
456
+ isFirstTextChunk = false;
457
+ }
458
+ process.stdout.write(text);
459
+ finalResponse += text;
460
+ hasStreamedText = true;
461
+ }
462
+ }
463
+ }
464
+ yield;
465
+ }
466
+ return finalResponse;
467
+ }
468
+ __name(prettyStreamEvents, "prettyStreamEvents");
469
+ export {
470
+ extractCodeFromToolInput,
471
+ extractToolMessageContent,
472
+ formatSearchToolsAsTree,
473
+ handleToolEnd,
474
+ handleToolStart,
475
+ parseExecuteCodeResult,
476
+ prettyStreamEvents,
477
+ printBox,
478
+ renderContent,
479
+ unwrapToolInput
480
+ };
@@ -1,4 +1,4 @@
1
- import { _ as __export, A as AsyncCaller } from "./index-C74kq9On.js";
1
+ import { _ as __export, A as AsyncCaller } from "./index-B8yt0GKw.js";
2
2
  var chunk_array_exports = {};
3
3
  __export(chunk_array_exports, { chunkArray: () => chunkArray });
4
4
  const chunkArray = (arr, chunkSize) => arr.reduce((chunks, elem, index) => {
@@ -19,3 +19,8 @@ var Embeddings = class {
19
19
  this.caller = new AsyncCaller(params ?? {});
20
20
  }
21
21
  };
22
+ export {
23
+ Embeddings as E,
24
+ chunk_array_exports as c,
25
+ embeddings_exports as e
26
+ };