@probelabs/visor 0.1.77 → 0.1.79

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- process.env.VISOR_VERSION = '0.1.77';
3
- process.env.PROBE_VERSION = '0.6.0-rc120';
2
+ process.env.VISOR_VERSION = '0.1.79';
3
+ process.env.PROBE_VERSION = '0.6.0-rc122';
4
4
  /******/ (() => { // webpackBootstrap
5
5
  /******/ var __webpack_modules__ = ({
6
6
 
@@ -105343,6 +105343,44 @@ class ConfigManager {
105343
105343
  : 'Both ai_mcp_servers and ai.mcpServers are set; ai.mcpServers takes precedence for this check.',
105344
105344
  });
105345
105345
  }
105346
+ // Type-specific guidance for MCP placement to avoid silent ignores
105347
+ try {
105348
+ const anyCheck = checkConfig;
105349
+ const aiObj = anyCheck.ai || undefined;
105350
+ const hasBareMcpAtCheck = Object.prototype.hasOwnProperty.call(anyCheck, 'mcpServers');
105351
+ const hasAiMcp = aiObj && Object.prototype.hasOwnProperty.call(aiObj, 'mcpServers');
105352
+ const hasClaudeCodeMcp = anyCheck.claude_code &&
105353
+ typeof anyCheck.claude_code === 'object' &&
105354
+ Object.prototype.hasOwnProperty.call(anyCheck.claude_code, 'mcpServers');
105355
+ if (checkConfig.type === 'ai') {
105356
+ if (hasBareMcpAtCheck) {
105357
+ warnings.push({
105358
+ field: `checks.${checkName}.mcpServers`,
105359
+ message: "'mcpServers' at the check root is ignored for type 'ai'. Use 'ai.mcpServers' or 'ai_mcp_servers' instead.",
105360
+ value: anyCheck.mcpServers,
105361
+ });
105362
+ }
105363
+ if (hasClaudeCodeMcp) {
105364
+ warnings.push({
105365
+ field: `checks.${checkName}.claude_code.mcpServers`,
105366
+ message: "'claude_code.mcpServers' is ignored for type 'ai'. Use 'ai.mcpServers' or 'ai_mcp_servers' instead.",
105367
+ });
105368
+ }
105369
+ }
105370
+ if (checkConfig.type === 'claude-code') {
105371
+ if (hasAiMcp || checkConfig.ai_mcp_servers) {
105372
+ warnings.push({
105373
+ field: hasAiMcp
105374
+ ? `checks.${checkName}.ai.mcpServers`
105375
+ : `checks.${checkName}.ai_mcp_servers`,
105376
+ message: "For type 'claude-code', MCP must be configured under 'claude_code.mcpServers'. 'ai.mcpServers' and 'ai_mcp_servers' are ignored for this check.",
105377
+ });
105378
+ }
105379
+ }
105380
+ }
105381
+ catch {
105382
+ // best-effort hints; never fail validation here
105383
+ }
105346
105384
  }
105347
105385
  }
105348
105386
  // Validate global MCP servers if present
@@ -136124,6 +136162,74 @@ var init_extract = __esm({
136124
136162
  }
136125
136163
  });
136126
136164
 
136165
+ // src/grep.js
136166
+ async function grep(options) {
136167
+ if (!options || !options.pattern) {
136168
+ throw new Error("Pattern is required");
136169
+ }
136170
+ if (!options.paths) {
136171
+ throw new Error("Path(s) are required");
136172
+ }
136173
+ const binaryPath = await getBinaryPath(options.binaryOptions || {});
136174
+ const cliArgs = ["grep"];
136175
+ for (const [key, flag] of Object.entries(GREP_FLAG_MAP)) {
136176
+ const value = options[key];
136177
+ if (value === void 0 || value === null) continue;
136178
+ if (typeof value === "boolean" && value) {
136179
+ cliArgs.push(flag);
136180
+ } else if (typeof value === "number") {
136181
+ cliArgs.push(flag, String(value));
136182
+ } else if (typeof value === "string") {
136183
+ cliArgs.push(flag, value);
136184
+ }
136185
+ }
136186
+ cliArgs.push(options.pattern);
136187
+ const paths = Array.isArray(options.paths) ? options.paths : [options.paths];
136188
+ cliArgs.push(...paths);
136189
+ try {
136190
+ const { stdout, stderr } = await execFileAsync(binaryPath, cliArgs, {
136191
+ maxBuffer: 10 * 1024 * 1024,
136192
+ // 10MB buffer
136193
+ env: {
136194
+ ...process.env,
136195
+ // Disable colors in stderr for cleaner output
136196
+ NO_COLOR: "1"
136197
+ }
136198
+ });
136199
+ return stdout;
136200
+ } catch (error2) {
136201
+ if (error2.code === 1 && !error2.stderr) {
136202
+ return error2.stdout || "";
136203
+ }
136204
+ const errorMessage = error2.stderr || error2.message || "Unknown error";
136205
+ throw new Error(`Grep failed: ${errorMessage}`);
136206
+ }
136207
+ }
136208
+ var import_child_process5, import_util5, execFileAsync, GREP_FLAG_MAP;
136209
+ var init_grep = __esm({
136210
+ "src/grep.js"() {
136211
+ "use strict";
136212
+ import_child_process5 = __nccwpck_require__(35317);
136213
+ import_util5 = __nccwpck_require__(39023);
136214
+ init_utils();
136215
+ execFileAsync = (0, import_util5.promisify)(import_child_process5.execFile);
136216
+ GREP_FLAG_MAP = {
136217
+ ignoreCase: "-i",
136218
+ lineNumbers: "-n",
136219
+ count: "-c",
136220
+ filesWithMatches: "-l",
136221
+ filesWithoutMatches: "-L",
136222
+ invertMatch: "-v",
136223
+ beforeContext: "-B",
136224
+ afterContext: "-A",
136225
+ context: "-C",
136226
+ noGitignore: "--no-gitignore",
136227
+ color: "--color",
136228
+ maxCount: "-m"
136229
+ };
136230
+ }
136231
+ });
136232
+
136127
136233
  // src/tools/common.js
136128
136234
  function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
136129
136235
  for (const toolName of validTools) {
@@ -136607,7 +136713,7 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
136607
136713
  }
136608
136714
  return new Promise((resolve4, reject2) => {
136609
136715
  const delegationSpan = tracer ? tracer.createDelegationSpan(sessionId, task) : null;
136610
- const process2 = (0, import_child_process5.spawn)(binaryPath, args, {
136716
+ const process2 = (0, import_child_process6.spawn)(binaryPath, args, {
136611
136717
  stdio: ["pipe", "pipe", "pipe"],
136612
136718
  timeout: timeout * 1e3
136613
136719
  });
@@ -136742,11 +136848,11 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
136742
136848
  throw new Error(`Delegation setup failed: ${error2.message}`);
136743
136849
  }
136744
136850
  }
136745
- var import_child_process5, import_crypto2;
136851
+ var import_child_process6, import_crypto2;
136746
136852
  var init_delegate = __esm({
136747
136853
  "src/delegate.js"() {
136748
136854
  "use strict";
136749
- import_child_process5 = __nccwpck_require__(35317);
136855
+ import_child_process6 = __nccwpck_require__(35317);
136750
136856
  import_crypto2 = __nccwpck_require__(76982);
136751
136857
  init_utils();
136752
136858
  init_common();
@@ -137822,7 +137928,7 @@ async function executeBashCommand(command, options = {}) {
137822
137928
  return;
137823
137929
  }
137824
137930
  const [cmd, ...cmdArgs] = args;
137825
- const child = (0, import_child_process6.spawn)(cmd, cmdArgs, {
137931
+ const child = (0, import_child_process7.spawn)(cmd, cmdArgs, {
137826
137932
  cwd,
137827
137933
  env: processEnv,
137828
137934
  stdio: ["ignore", "pipe", "pipe"],
@@ -138006,11 +138112,11 @@ function validateExecutionOptions(options = {}) {
138006
138112
  warnings
138007
138113
  };
138008
138114
  }
138009
- var import_child_process6, import_path4, import_fs;
138115
+ var import_child_process7, import_path4, import_fs;
138010
138116
  var init_bashExecutor = __esm({
138011
138117
  "src/agent/bashExecutor.js"() {
138012
138118
  "use strict";
138013
- import_child_process6 = __nccwpck_require__(35317);
138119
+ import_child_process7 = __nccwpck_require__(35317);
138014
138120
  import_path4 = __nccwpck_require__(16928);
138015
138121
  import_fs = __nccwpck_require__(79896);
138016
138122
  init_bashCommandUtils();
@@ -138535,15 +138641,15 @@ function shouldIgnore(filePath, ignorePatterns) {
138535
138641
  }
138536
138642
  return false;
138537
138643
  }
138538
- var import_fs2, import_path6, import_util5, import_child_process7, execAsync4;
138644
+ var import_fs2, import_path6, import_util6, import_child_process8, execAsync4;
138539
138645
  var init_file_lister = __esm({
138540
138646
  "src/utils/file-lister.js"() {
138541
138647
  "use strict";
138542
138648
  import_fs2 = __toESM(__nccwpck_require__(79896), 1);
138543
138649
  import_path6 = __toESM(__nccwpck_require__(16928), 1);
138544
- import_util5 = __nccwpck_require__(39023);
138545
- import_child_process7 = __nccwpck_require__(35317);
138546
- execAsync4 = (0, import_util5.promisify)(import_child_process7.exec);
138650
+ import_util6 = __nccwpck_require__(39023);
138651
+ import_child_process8 = __nccwpck_require__(35317);
138652
+ execAsync4 = (0, import_util6.promisify)(import_child_process8.exec);
138547
138653
  }
138548
138654
  });
138549
138655
 
@@ -159853,8 +159959,8 @@ var require_dist_cjs59 = __commonJS({
159853
159959
  module2.exports = __toCommonJS2(index_exports2);
159854
159960
  var import_property_provider2 = require_dist_cjs24();
159855
159961
  var import_shared_ini_file_loader = require_dist_cjs42();
159856
- var import_child_process9 = __nccwpck_require__(35317);
159857
- var import_util9 = __nccwpck_require__(39023);
159962
+ var import_child_process10 = __nccwpck_require__(35317);
159963
+ var import_util10 = __nccwpck_require__(39023);
159858
159964
  var import_client7 = (init_client(), __toCommonJS(client_exports));
159859
159965
  var getValidatedProcessCredentials = /* @__PURE__ */ __name((profileName, data2, profiles) => {
159860
159966
  if (data2.Version !== 1) {
@@ -159890,7 +159996,7 @@ var require_dist_cjs59 = __commonJS({
159890
159996
  if (profiles[profileName]) {
159891
159997
  const credentialProcess = profile["credential_process"];
159892
159998
  if (credentialProcess !== void 0) {
159893
- const execPromise = (0, import_util9.promisify)(import_shared_ini_file_loader.externalDataInterceptor?.getTokenRecord?.().exec ?? import_child_process9.exec);
159999
+ const execPromise = (0, import_util10.promisify)(import_shared_ini_file_loader.externalDataInterceptor?.getTokenRecord?.().exec ?? import_child_process10.exec);
159894
160000
  try {
159895
160001
  const { stdout } = await execPromise(credentialProcess);
159896
160002
  let data2;
@@ -166328,13 +166434,13 @@ function createWrappedTools(baseTools) {
166328
166434
  }
166329
166435
  return wrappedTools;
166330
166436
  }
166331
- var import_child_process8, import_util8, import_crypto4, import_events, import_fs3, import_fs4, import_path7, import_glob, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
166437
+ var import_child_process9, import_util9, import_crypto4, import_events, import_fs3, import_fs4, import_path7, import_glob, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
166332
166438
  var init_probeTool = __esm({
166333
166439
  "src/agent/probeTool.js"() {
166334
166440
  "use strict";
166335
166441
  init_index();
166336
- import_child_process8 = __nccwpck_require__(35317);
166337
- import_util8 = __nccwpck_require__(39023);
166442
+ import_child_process9 = __nccwpck_require__(35317);
166443
+ import_util9 = __nccwpck_require__(39023);
166338
166444
  import_crypto4 = __nccwpck_require__(76982);
166339
166445
  import_events = __nccwpck_require__(24434);
166340
166446
  import_fs3 = __toESM(__nccwpck_require__(79896), 1);
@@ -195481,6 +195587,14 @@ function cleanSchemaResponse(response) {
195481
195587
  return response;
195482
195588
  }
195483
195589
  const trimmed = response.trim();
195590
+ const jsonBlockMatch = trimmed.match(/```json\s*\n([\s\S]*?)\n```/);
195591
+ if (jsonBlockMatch) {
195592
+ return jsonBlockMatch[1].trim();
195593
+ }
195594
+ const anyBlockMatch = trimmed.match(/```\s*\n([{\[][\s\S]*?[}\]])\s*```/);
195595
+ if (anyBlockMatch) {
195596
+ return anyBlockMatch[1].trim();
195597
+ }
195484
195598
  const codeBlockPatterns = [
195485
195599
  /```json\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
195486
195600
  /```\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
@@ -196293,8 +196407,8 @@ function loadMCPConfigurationFromPath(configPath) {
196293
196407
  try {
196294
196408
  const content = (0, import_fs5.readFileSync)(configPath, "utf8");
196295
196409
  const config = JSON.parse(content);
196296
- if (process.env.DEBUG === "1") {
196297
- console.error(`[MCP] Loaded configuration from: ${configPath}`);
196410
+ if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
196411
+ console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
196298
196412
  }
196299
196413
  return mergeWithEnvironment(config);
196300
196414
  } catch (error2) {
@@ -196320,12 +196434,12 @@ function loadMCPConfiguration() {
196320
196434
  try {
196321
196435
  const content = (0, import_fs5.readFileSync)(configPath, "utf8");
196322
196436
  config = JSON.parse(content);
196323
- if (process.env.DEBUG === "1") {
196324
- console.error(`[MCP] Loaded configuration from: ${configPath}`);
196437
+ if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
196438
+ console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
196325
196439
  }
196326
196440
  break;
196327
196441
  } catch (error2) {
196328
- console.error(`[MCP] Failed to parse config from ${configPath}:`, error2.message);
196442
+ console.error(`[MCP ERROR] Failed to parse config from ${configPath}:`, error2.message);
196329
196443
  }
196330
196444
  }
196331
196445
  }
@@ -196401,12 +196515,12 @@ function parseEnabledServers(config) {
196401
196515
  }
196402
196516
  if (server.transport === "stdio") {
196403
196517
  if (!server.command) {
196404
- console.error(`[MCP] Server ${name14} missing required 'command' for stdio transport`);
196518
+ console.error(`[MCP ERROR] Server ${name14} missing required 'command' for stdio transport`);
196405
196519
  continue;
196406
196520
  }
196407
196521
  } else if (["websocket", "sse", "http"].includes(server.transport)) {
196408
196522
  if (!server.url) {
196409
- console.error(`[MCP] Server ${name14} missing required 'url' for ${server.transport} transport`);
196523
+ console.error(`[MCP ERROR] Server ${name14} missing required 'url' for ${server.transport} transport`);
196410
196524
  continue;
196411
196525
  }
196412
196526
  }
@@ -196537,20 +196651,45 @@ var init_client2 = __esm({
196537
196651
  async initialize(config = null) {
196538
196652
  this.config = config || loadMCPConfiguration();
196539
196653
  const servers = parseEnabledServers(this.config);
196654
+ console.error(`[MCP INFO] Found ${servers.length} enabled MCP server${servers.length !== 1 ? "s" : ""}`);
196655
+ if (servers.length === 0) {
196656
+ console.error("[MCP INFO] No MCP servers configured or enabled");
196657
+ console.error("[MCP INFO] 0 MCP tools available");
196658
+ return {
196659
+ connected: 0,
196660
+ total: 0,
196661
+ tools: []
196662
+ };
196663
+ }
196540
196664
  if (this.debug) {
196541
- console.error(`[MCP] Found ${servers.length} enabled servers`);
196665
+ console.error("[MCP DEBUG] Server details:");
196666
+ servers.forEach((server) => {
196667
+ console.error(`[MCP DEBUG] - ${server.name} (${server.transport})`);
196668
+ });
196542
196669
  }
196543
196670
  const connectionPromises = servers.map(
196544
196671
  (server) => this.connectToServer(server).catch((error2) => {
196545
- console.error(`[MCP] Failed to connect to ${server.name}:`, error2.message);
196672
+ console.error(`[MCP ERROR] Failed to connect to ${server.name}:`, error2.message);
196546
196673
  return null;
196547
196674
  })
196548
196675
  );
196549
196676
  const results = await Promise.all(connectionPromises);
196550
196677
  const connectedCount = results.filter(Boolean).length;
196551
- if (this.debug) {
196552
- console.error(`[MCP] Successfully connected to ${connectedCount}/${servers.length} servers`);
196553
- console.error(`[MCP] Total tools available: ${this.tools.size}`);
196678
+ if (connectedCount === 0) {
196679
+ console.error(`[MCP ERROR] Failed to connect to all ${servers.length} server${servers.length !== 1 ? "s" : ""}`);
196680
+ console.error("[MCP INFO] 0 MCP tools available");
196681
+ } else if (connectedCount < servers.length) {
196682
+ console.error(`[MCP INFO] Successfully connected to ${connectedCount}/${servers.length} servers`);
196683
+ console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? "s" : ""} available`);
196684
+ } else {
196685
+ console.error(`[MCP INFO] Successfully connected to all ${connectedCount} server${connectedCount !== 1 ? "s" : ""}`);
196686
+ console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? "s" : ""} available`);
196687
+ }
196688
+ if (this.debug && this.tools.size > 0) {
196689
+ console.error("[MCP DEBUG] Available tools:");
196690
+ Array.from(this.tools.keys()).forEach((toolName) => {
196691
+ console.error(`[MCP DEBUG] - ${toolName}`);
196692
+ });
196554
196693
  }
196555
196694
  return {
196556
196695
  connected: connectedCount,
@@ -196566,7 +196705,7 @@ var init_client2 = __esm({
196566
196705
  const { name: name14 } = serverConfig;
196567
196706
  try {
196568
196707
  if (this.debug) {
196569
- console.error(`[MCP] Connecting to ${name14} via ${serverConfig.transport}...`);
196708
+ console.error(`[MCP DEBUG] Connecting to ${name14} via ${serverConfig.transport}...`);
196570
196709
  }
196571
196710
  const transport = createTransport(serverConfig);
196572
196711
  const client = new import_client3.Client(
@@ -196585,6 +196724,7 @@ var init_client2 = __esm({
196585
196724
  config: serverConfig
196586
196725
  });
196587
196726
  const toolsResponse = await client.listTools();
196727
+ const toolCount = toolsResponse?.tools?.length || 0;
196588
196728
  if (toolsResponse && toolsResponse.tools) {
196589
196729
  for (const tool3 of toolsResponse.tools) {
196590
196730
  const qualifiedName = `${name14}_${tool3.name}`;
@@ -196594,16 +196734,17 @@ var init_client2 = __esm({
196594
196734
  originalName: tool3.name
196595
196735
  });
196596
196736
  if (this.debug) {
196597
- console.error(`[MCP] Registered tool: ${qualifiedName}`);
196737
+ console.error(`[MCP DEBUG] Registered tool: ${qualifiedName}`);
196598
196738
  }
196599
196739
  }
196600
196740
  }
196601
- if (this.debug) {
196602
- console.error(`[MCP] Connected to ${name14} with ${toolsResponse?.tools?.length || 0} tools`);
196603
- }
196741
+ console.error(`[MCP INFO] Connected to ${name14}: ${toolCount} tool${toolCount !== 1 ? "s" : ""} loaded`);
196604
196742
  return true;
196605
196743
  } catch (error2) {
196606
- console.error(`[MCP] Error connecting to ${name14}:`, error2.message);
196744
+ console.error(`[MCP ERROR] Error connecting to ${name14}:`, error2.message);
196745
+ if (this.debug) {
196746
+ console.error(`[MCP DEBUG] Full error details:`, error2);
196747
+ }
196607
196748
  return false;
196608
196749
  }
196609
196750
  }
@@ -196623,7 +196764,7 @@ var init_client2 = __esm({
196623
196764
  }
196624
196765
  try {
196625
196766
  if (this.debug) {
196626
- console.error(`[MCP] Calling ${toolName} with args:`, args);
196767
+ console.error(`[MCP DEBUG] Calling ${toolName} with args:`, JSON.stringify(args, null, 2));
196627
196768
  }
196628
196769
  const timeout = this.config?.settings?.timeout || 3e4;
196629
196770
  const timeoutPromise = new Promise((_2, reject2) => {
@@ -196638,9 +196779,15 @@ var init_client2 = __esm({
196638
196779
  }),
196639
196780
  timeoutPromise
196640
196781
  ]);
196782
+ if (this.debug) {
196783
+ console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
196784
+ }
196641
196785
  return result;
196642
196786
  } catch (error2) {
196643
- console.error(`[MCP] Error calling tool ${toolName}:`, error2);
196787
+ console.error(`[MCP ERROR] Error calling tool ${toolName}:`, error2.message);
196788
+ if (this.debug) {
196789
+ console.error(`[MCP DEBUG] Full error details:`, error2);
196790
+ }
196644
196791
  throw error2;
196645
196792
  }
196646
196793
  }
@@ -196685,20 +196832,32 @@ var init_client2 = __esm({
196685
196832
  */
196686
196833
  async disconnect() {
196687
196834
  const disconnectPromises = [];
196835
+ if (this.clients.size === 0) {
196836
+ if (this.debug) {
196837
+ console.error("[MCP DEBUG] No MCP clients to disconnect");
196838
+ }
196839
+ return;
196840
+ }
196841
+ if (this.debug) {
196842
+ console.error(`[MCP DEBUG] Disconnecting from ${this.clients.size} MCP server${this.clients.size !== 1 ? "s" : ""}...`);
196843
+ }
196688
196844
  for (const [name14, clientInfo] of this.clients.entries()) {
196689
196845
  disconnectPromises.push(
196690
196846
  clientInfo.client.close().then(() => {
196691
196847
  if (this.debug) {
196692
- console.error(`[MCP] Disconnected from ${name14}`);
196848
+ console.error(`[MCP DEBUG] Disconnected from ${name14}`);
196693
196849
  }
196694
196850
  }).catch((error2) => {
196695
- console.error(`[MCP] Error disconnecting from ${name14}:`, error2);
196851
+ console.error(`[MCP ERROR] Error disconnecting from ${name14}:`, error2.message);
196696
196852
  })
196697
196853
  );
196698
196854
  }
196699
196855
  await Promise.all(disconnectPromises);
196700
196856
  this.clients.clear();
196701
196857
  this.tools.clear();
196858
+ if (this.debug) {
196859
+ console.error("[MCP DEBUG] All MCP connections closed");
196860
+ }
196702
196861
  }
196703
196862
  };
196704
196863
  }
@@ -196850,31 +197009,58 @@ var init_xmlBridge = __esm({
196850
197009
  async initialize(config = null) {
196851
197010
  let mcpConfigs = null;
196852
197011
  if (!config) {
197012
+ if (this.debug) {
197013
+ console.error("[MCP DEBUG] No config provided, attempting auto-discovery...");
197014
+ }
196853
197015
  mcpConfigs = loadMCPConfiguration();
197016
+ if (!mcpConfigs || !mcpConfigs.mcpServers || Object.keys(mcpConfigs.mcpServers).length === 0) {
197017
+ console.error("[MCP WARNING] MCP enabled but no configuration found");
197018
+ console.error("[MCP INFO] To use MCP, provide configuration via:");
197019
+ console.error("[MCP INFO] - mcpConfig option when creating ProbeAgent");
197020
+ console.error("[MCP INFO] - mcpConfigPath option pointing to a config file");
197021
+ console.error("[MCP INFO] - Config file in standard locations (~/.mcp/config.json, etc.)");
197022
+ console.error("[MCP INFO] - Environment variable MCP_CONFIG_PATH");
197023
+ }
196854
197024
  } else if (Array.isArray(config)) {
197025
+ if (this.debug) {
197026
+ console.error("[MCP DEBUG] Using deprecated array config format (consider using mcpConfig object)");
197027
+ }
196855
197028
  mcpConfigs = { mcpServers: config };
196856
197029
  } else {
197030
+ if (this.debug) {
197031
+ console.error("[MCP DEBUG] Using provided MCP config object");
197032
+ }
196857
197033
  mcpConfigs = config;
196858
197034
  }
196859
197035
  if (!mcpConfigs || !mcpConfigs.mcpServers || Object.keys(mcpConfigs.mcpServers).length === 0) {
196860
- if (this.debug) {
196861
- console.error("[MCP] No MCP servers configured");
196862
- }
197036
+ console.error("[MCP INFO] 0 MCP tools available");
196863
197037
  return;
196864
197038
  }
196865
197039
  try {
197040
+ if (this.debug) {
197041
+ console.error("[MCP DEBUG] Initializing MCP client manager...");
197042
+ }
196866
197043
  this.mcpManager = new MCPClientManager({ debug: this.debug });
196867
197044
  const result = await this.mcpManager.initialize(mcpConfigs);
196868
197045
  const vercelTools = this.mcpManager.getVercelTools();
196869
197046
  this.mcpTools = vercelTools;
197047
+ const toolCount = Object.keys(vercelTools).length;
196870
197048
  for (const [name14, tool3] of Object.entries(vercelTools)) {
196871
197049
  this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14, tool3);
196872
197050
  }
196873
- if (this.debug) {
196874
- console.error(`[MCP] Loaded ${Object.keys(vercelTools).length} MCP tools from ${result.connected} server(s)`);
197051
+ if (toolCount === 0) {
197052
+ console.error("[MCP INFO] MCP initialization complete: 0 tools loaded");
197053
+ } else {
197054
+ console.error(`[MCP INFO] MCP initialization complete: ${toolCount} tool${toolCount !== 1 ? "s" : ""} loaded from ${result.connected} server${result.connected !== 1 ? "s" : ""}`);
197055
+ if (this.debug) {
197056
+ console.error("[MCP DEBUG] Tool definitions generated for XML bridge");
197057
+ }
196875
197058
  }
196876
197059
  } catch (error2) {
196877
- console.error("[MCP] Failed to initialize MCP connections:", error2);
197060
+ console.error("[MCP ERROR] Failed to initialize MCP connections:", error2.message);
197061
+ if (this.debug) {
197062
+ console.error("[MCP DEBUG] Full error details:", error2);
197063
+ }
196878
197064
  }
196879
197065
  }
196880
197066
  /**
@@ -196899,24 +197085,35 @@ var init_xmlBridge = __esm({
196899
197085
  async executeFromXml(xmlString) {
196900
197086
  const parsed = parseXmlMcpToolCall(xmlString, this.getToolNames());
196901
197087
  if (!parsed) {
197088
+ console.error("[MCP ERROR] No valid MCP tool call found in XML");
196902
197089
  throw new Error("No valid MCP tool call found in XML");
196903
197090
  }
196904
197091
  const { toolName, params } = parsed;
196905
197092
  if (this.debug) {
196906
- console.error(`[MCP] Executing MCP tool: ${toolName} with params:`, params);
197093
+ console.error(`[MCP DEBUG] Executing MCP tool: ${toolName}`);
197094
+ console.error(`[MCP DEBUG] Parameters:`, JSON.stringify(params, null, 2));
196907
197095
  }
196908
197096
  const tool3 = this.mcpTools[toolName];
196909
197097
  if (!tool3) {
197098
+ console.error(`[MCP ERROR] Unknown MCP tool: ${toolName}`);
197099
+ console.error(`[MCP ERROR] Available tools: ${this.getToolNames().join(", ")}`);
196910
197100
  throw new Error(`Unknown MCP tool: ${toolName}`);
196911
197101
  }
196912
197102
  try {
196913
197103
  const result = await tool3.execute(params);
197104
+ if (this.debug) {
197105
+ console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
197106
+ }
196914
197107
  return {
196915
197108
  success: true,
196916
197109
  toolName,
196917
197110
  result
196918
197111
  };
196919
197112
  } catch (error2) {
197113
+ console.error(`[MCP ERROR] Tool ${toolName} execution failed:`, error2.message);
197114
+ if (this.debug) {
197115
+ console.error(`[MCP DEBUG] Full error details:`, error2);
197116
+ }
196920
197117
  return {
196921
197118
  success: false,
196922
197119
  toolName,
@@ -197050,6 +197247,7 @@ var init_ProbeAgent = __esm({
197050
197247
  this.mcpConfig = options.mcpConfig || null;
197051
197248
  this.mcpServers = options.mcpServers || null;
197052
197249
  this.mcpBridge = null;
197250
+ this._mcpInitialized = false;
197053
197251
  this.initializeModel();
197054
197252
  }
197055
197253
  /**
@@ -197057,7 +197255,8 @@ var init_ProbeAgent = __esm({
197057
197255
  * This method initializes MCP and merges MCP tools into the tool list
197058
197256
  */
197059
197257
  async initialize() {
197060
- if (this.enableMcp) {
197258
+ if (this.enableMcp && !this._mcpInitialized) {
197259
+ this._mcpInitialized = true;
197061
197260
  try {
197062
197261
  await this.initializeMCP();
197063
197262
  if (this.mcpBridge) {
@@ -197081,7 +197280,10 @@ var init_ProbeAgent = __esm({
197081
197280
  console.error("[DEBUG] ========================================\n");
197082
197281
  }
197083
197282
  } catch (error2) {
197084
- console.error("[MCP] Failed to initialize MCP:", error2);
197283
+ console.error("[MCP ERROR] Failed to initialize MCP:", error2.message);
197284
+ if (this.debug) {
197285
+ console.error("[MCP DEBUG] Full error details:", error2);
197286
+ }
197085
197287
  this.mcpBridge = null;
197086
197288
  }
197087
197289
  }
@@ -197505,13 +197707,13 @@ var init_ProbeAgent = __esm({
197505
197707
  if (this.mcpConfig) {
197506
197708
  mcpConfig = this.mcpConfig;
197507
197709
  if (this.debug) {
197508
- console.log("[DEBUG] Using provided MCP config object");
197710
+ console.error("[MCP DEBUG] Using provided MCP config object");
197509
197711
  }
197510
197712
  } else if (this.mcpConfigPath) {
197511
197713
  try {
197512
197714
  mcpConfig = loadMCPConfigurationFromPath(this.mcpConfigPath);
197513
197715
  if (this.debug) {
197514
- console.log(`[DEBUG] Loaded MCP config from: ${this.mcpConfigPath}`);
197716
+ console.error(`[MCP DEBUG] Loaded MCP config from: ${this.mcpConfigPath}`);
197515
197717
  }
197516
197718
  } catch (error2) {
197517
197719
  throw new Error(`Failed to load MCP config from ${this.mcpConfigPath}: ${error2.message}`);
@@ -197519,8 +197721,13 @@ var init_ProbeAgent = __esm({
197519
197721
  } else if (this.mcpServers) {
197520
197722
  mcpConfig = { mcpServers: this.mcpServers };
197521
197723
  if (this.debug) {
197522
- console.warn("[DEBUG] Using deprecated mcpServers option. Consider using mcpConfig instead.");
197724
+ console.error("[MCP DEBUG] Using deprecated mcpServers option. Consider using mcpConfig instead.");
197523
197725
  }
197726
+ } else {
197727
+ if (this.debug) {
197728
+ console.error("[MCP DEBUG] No explicit MCP config provided, will attempt auto-discovery");
197729
+ }
197730
+ mcpConfig = null;
197524
197731
  }
197525
197732
  this.mcpBridge = new MCPXmlBridge({ debug: this.debug });
197526
197733
  await this.mcpBridge.initialize(mcpConfig);
@@ -197528,22 +197735,25 @@ var init_ProbeAgent = __esm({
197528
197735
  const mcpToolCount = mcpToolNames.length;
197529
197736
  if (mcpToolCount > 0) {
197530
197737
  if (this.debug) {
197531
- console.error("\n[DEBUG] ========================================");
197532
- console.error(`[DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
197533
- console.error("[DEBUG] Available MCP tools:");
197738
+ console.error("\n[MCP DEBUG] ========================================");
197739
+ console.error(`[MCP DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
197740
+ console.error("[MCP DEBUG] Available MCP tools:");
197534
197741
  for (const toolName of mcpToolNames) {
197535
- console.error(`[DEBUG] - ${toolName}`);
197742
+ console.error(`[MCP DEBUG] - ${toolName}`);
197536
197743
  }
197537
- console.error("[DEBUG] ========================================\n");
197744
+ console.error("[MCP DEBUG] ========================================\n");
197538
197745
  }
197539
197746
  } else {
197540
197747
  if (this.debug) {
197541
- console.error("[DEBUG] No MCP tools loaded, setting bridge to null");
197748
+ console.error("[MCP DEBUG] No MCP tools loaded, setting bridge to null");
197542
197749
  }
197543
197750
  this.mcpBridge = null;
197544
197751
  }
197545
197752
  } catch (error2) {
197546
- console.error("[MCP] Error initializing MCP:", error2);
197753
+ console.error("[MCP ERROR] Error initializing MCP:", error2.message);
197754
+ if (this.debug) {
197755
+ console.error("[MCP DEBUG] Full error details:", error2);
197756
+ }
197547
197757
  this.mcpBridge = null;
197548
197758
  }
197549
197759
  }
@@ -197551,6 +197761,23 @@ var init_ProbeAgent = __esm({
197551
197761
  * Get the system message with instructions for the AI (XML Tool Format)
197552
197762
  */
197553
197763
  async getSystemMessage() {
197764
+ if (this.enableMcp && !this.mcpBridge && !this._mcpInitialized) {
197765
+ this._mcpInitialized = true;
197766
+ try {
197767
+ await this.initializeMCP();
197768
+ if (this.mcpBridge) {
197769
+ const mcpTools = this.mcpBridge.mcpTools || {};
197770
+ for (const [toolName, toolImpl] of Object.entries(mcpTools)) {
197771
+ this.toolImplementations[toolName] = toolImpl;
197772
+ }
197773
+ }
197774
+ } catch (error2) {
197775
+ console.error("[MCP ERROR] Failed to lazy-initialize MCP:", error2.message);
197776
+ if (this.debug) {
197777
+ console.error("[MCP DEBUG] Full error details:", error2);
197778
+ }
197779
+ }
197780
+ }
197554
197781
  let toolDefinitions = `
197555
197782
  ${searchToolDefinition}
197556
197783
  ${queryToolDefinition}
@@ -198851,6 +199078,7 @@ __export(index_exports, {
198851
199078
  extractTool: () => extractTool,
198852
199079
  extractToolDefinition: () => extractToolDefinition,
198853
199080
  getBinaryPath: () => getBinaryPath,
199081
+ grep: () => grep,
198854
199082
  initializeSimpleTelemetryFromOptions: () => initializeSimpleTelemetryFromOptions,
198855
199083
  listFilesByLevel: () => listFilesByLevel,
198856
199084
  listFilesToolInstance: () => listFilesToolInstance,
@@ -198873,6 +199101,7 @@ var init_index = __esm({
198873
199101
  init_search();
198874
199102
  init_query();
198875
199103
  init_extract();
199104
+ init_grep();
198876
199105
  init_delegate();
198877
199106
  init_utils();
198878
199107
  init_tools();
@@ -228463,7 +228692,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
228463
228692
  /***/ ((module) => {
228464
228693
 
228465
228694
  "use strict";
228466
- module.exports = {"rE":"0.1.77"};
228695
+ module.exports = {"rE":"0.1.79"};
228467
228696
 
228468
228697
  /***/ })
228469
228698