@probelabs/visor 0.1.78 → 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.
Files changed (2) hide show
  1. package/dist/index.js +251 -60
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- process.env.VISOR_VERSION = '0.1.78';
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
 
@@ -136162,6 +136162,74 @@ var init_extract = __esm({
136162
136162
  }
136163
136163
  });
136164
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
+
136165
136233
  // src/tools/common.js
136166
136234
  function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
136167
136235
  for (const toolName of validTools) {
@@ -136645,7 +136713,7 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
136645
136713
  }
136646
136714
  return new Promise((resolve4, reject2) => {
136647
136715
  const delegationSpan = tracer ? tracer.createDelegationSpan(sessionId, task) : null;
136648
- const process2 = (0, import_child_process5.spawn)(binaryPath, args, {
136716
+ const process2 = (0, import_child_process6.spawn)(binaryPath, args, {
136649
136717
  stdio: ["pipe", "pipe", "pipe"],
136650
136718
  timeout: timeout * 1e3
136651
136719
  });
@@ -136780,11 +136848,11 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
136780
136848
  throw new Error(`Delegation setup failed: ${error2.message}`);
136781
136849
  }
136782
136850
  }
136783
- var import_child_process5, import_crypto2;
136851
+ var import_child_process6, import_crypto2;
136784
136852
  var init_delegate = __esm({
136785
136853
  "src/delegate.js"() {
136786
136854
  "use strict";
136787
- import_child_process5 = __nccwpck_require__(35317);
136855
+ import_child_process6 = __nccwpck_require__(35317);
136788
136856
  import_crypto2 = __nccwpck_require__(76982);
136789
136857
  init_utils();
136790
136858
  init_common();
@@ -137860,7 +137928,7 @@ async function executeBashCommand(command, options = {}) {
137860
137928
  return;
137861
137929
  }
137862
137930
  const [cmd, ...cmdArgs] = args;
137863
- const child = (0, import_child_process6.spawn)(cmd, cmdArgs, {
137931
+ const child = (0, import_child_process7.spawn)(cmd, cmdArgs, {
137864
137932
  cwd,
137865
137933
  env: processEnv,
137866
137934
  stdio: ["ignore", "pipe", "pipe"],
@@ -138044,11 +138112,11 @@ function validateExecutionOptions(options = {}) {
138044
138112
  warnings
138045
138113
  };
138046
138114
  }
138047
- var import_child_process6, import_path4, import_fs;
138115
+ var import_child_process7, import_path4, import_fs;
138048
138116
  var init_bashExecutor = __esm({
138049
138117
  "src/agent/bashExecutor.js"() {
138050
138118
  "use strict";
138051
- import_child_process6 = __nccwpck_require__(35317);
138119
+ import_child_process7 = __nccwpck_require__(35317);
138052
138120
  import_path4 = __nccwpck_require__(16928);
138053
138121
  import_fs = __nccwpck_require__(79896);
138054
138122
  init_bashCommandUtils();
@@ -138573,15 +138641,15 @@ function shouldIgnore(filePath, ignorePatterns) {
138573
138641
  }
138574
138642
  return false;
138575
138643
  }
138576
- var import_fs2, import_path6, import_util5, import_child_process7, execAsync4;
138644
+ var import_fs2, import_path6, import_util6, import_child_process8, execAsync4;
138577
138645
  var init_file_lister = __esm({
138578
138646
  "src/utils/file-lister.js"() {
138579
138647
  "use strict";
138580
138648
  import_fs2 = __toESM(__nccwpck_require__(79896), 1);
138581
138649
  import_path6 = __toESM(__nccwpck_require__(16928), 1);
138582
- import_util5 = __nccwpck_require__(39023);
138583
- import_child_process7 = __nccwpck_require__(35317);
138584
- 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);
138585
138653
  }
138586
138654
  });
138587
138655
 
@@ -159891,8 +159959,8 @@ var require_dist_cjs59 = __commonJS({
159891
159959
  module2.exports = __toCommonJS2(index_exports2);
159892
159960
  var import_property_provider2 = require_dist_cjs24();
159893
159961
  var import_shared_ini_file_loader = require_dist_cjs42();
159894
- var import_child_process9 = __nccwpck_require__(35317);
159895
- var import_util9 = __nccwpck_require__(39023);
159962
+ var import_child_process10 = __nccwpck_require__(35317);
159963
+ var import_util10 = __nccwpck_require__(39023);
159896
159964
  var import_client7 = (init_client(), __toCommonJS(client_exports));
159897
159965
  var getValidatedProcessCredentials = /* @__PURE__ */ __name((profileName, data2, profiles) => {
159898
159966
  if (data2.Version !== 1) {
@@ -159928,7 +159996,7 @@ var require_dist_cjs59 = __commonJS({
159928
159996
  if (profiles[profileName]) {
159929
159997
  const credentialProcess = profile["credential_process"];
159930
159998
  if (credentialProcess !== void 0) {
159931
- 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);
159932
160000
  try {
159933
160001
  const { stdout } = await execPromise(credentialProcess);
159934
160002
  let data2;
@@ -166366,13 +166434,13 @@ function createWrappedTools(baseTools) {
166366
166434
  }
166367
166435
  return wrappedTools;
166368
166436
  }
166369
- 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;
166370
166438
  var init_probeTool = __esm({
166371
166439
  "src/agent/probeTool.js"() {
166372
166440
  "use strict";
166373
166441
  init_index();
166374
- import_child_process8 = __nccwpck_require__(35317);
166375
- import_util8 = __nccwpck_require__(39023);
166442
+ import_child_process9 = __nccwpck_require__(35317);
166443
+ import_util9 = __nccwpck_require__(39023);
166376
166444
  import_crypto4 = __nccwpck_require__(76982);
166377
166445
  import_events = __nccwpck_require__(24434);
166378
166446
  import_fs3 = __toESM(__nccwpck_require__(79896), 1);
@@ -195519,6 +195587,14 @@ function cleanSchemaResponse(response) {
195519
195587
  return response;
195520
195588
  }
195521
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
+ }
195522
195598
  const codeBlockPatterns = [
195523
195599
  /```json\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
195524
195600
  /```\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
@@ -196331,8 +196407,8 @@ function loadMCPConfigurationFromPath(configPath) {
196331
196407
  try {
196332
196408
  const content = (0, import_fs5.readFileSync)(configPath, "utf8");
196333
196409
  const config = JSON.parse(content);
196334
- if (process.env.DEBUG === "1") {
196335
- 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}`);
196336
196412
  }
196337
196413
  return mergeWithEnvironment(config);
196338
196414
  } catch (error2) {
@@ -196358,12 +196434,12 @@ function loadMCPConfiguration() {
196358
196434
  try {
196359
196435
  const content = (0, import_fs5.readFileSync)(configPath, "utf8");
196360
196436
  config = JSON.parse(content);
196361
- if (process.env.DEBUG === "1") {
196362
- 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}`);
196363
196439
  }
196364
196440
  break;
196365
196441
  } catch (error2) {
196366
- console.error(`[MCP] Failed to parse config from ${configPath}:`, error2.message);
196442
+ console.error(`[MCP ERROR] Failed to parse config from ${configPath}:`, error2.message);
196367
196443
  }
196368
196444
  }
196369
196445
  }
@@ -196439,12 +196515,12 @@ function parseEnabledServers(config) {
196439
196515
  }
196440
196516
  if (server.transport === "stdio") {
196441
196517
  if (!server.command) {
196442
- console.error(`[MCP] Server ${name14} missing required 'command' for stdio transport`);
196518
+ console.error(`[MCP ERROR] Server ${name14} missing required 'command' for stdio transport`);
196443
196519
  continue;
196444
196520
  }
196445
196521
  } else if (["websocket", "sse", "http"].includes(server.transport)) {
196446
196522
  if (!server.url) {
196447
- 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`);
196448
196524
  continue;
196449
196525
  }
196450
196526
  }
@@ -196575,20 +196651,45 @@ var init_client2 = __esm({
196575
196651
  async initialize(config = null) {
196576
196652
  this.config = config || loadMCPConfiguration();
196577
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
+ }
196578
196664
  if (this.debug) {
196579
- 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
+ });
196580
196669
  }
196581
196670
  const connectionPromises = servers.map(
196582
196671
  (server) => this.connectToServer(server).catch((error2) => {
196583
- console.error(`[MCP] Failed to connect to ${server.name}:`, error2.message);
196672
+ console.error(`[MCP ERROR] Failed to connect to ${server.name}:`, error2.message);
196584
196673
  return null;
196585
196674
  })
196586
196675
  );
196587
196676
  const results = await Promise.all(connectionPromises);
196588
196677
  const connectedCount = results.filter(Boolean).length;
196589
- if (this.debug) {
196590
- console.error(`[MCP] Successfully connected to ${connectedCount}/${servers.length} servers`);
196591
- 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
+ });
196592
196693
  }
196593
196694
  return {
196594
196695
  connected: connectedCount,
@@ -196604,7 +196705,7 @@ var init_client2 = __esm({
196604
196705
  const { name: name14 } = serverConfig;
196605
196706
  try {
196606
196707
  if (this.debug) {
196607
- console.error(`[MCP] Connecting to ${name14} via ${serverConfig.transport}...`);
196708
+ console.error(`[MCP DEBUG] Connecting to ${name14} via ${serverConfig.transport}...`);
196608
196709
  }
196609
196710
  const transport = createTransport(serverConfig);
196610
196711
  const client = new import_client3.Client(
@@ -196623,6 +196724,7 @@ var init_client2 = __esm({
196623
196724
  config: serverConfig
196624
196725
  });
196625
196726
  const toolsResponse = await client.listTools();
196727
+ const toolCount = toolsResponse?.tools?.length || 0;
196626
196728
  if (toolsResponse && toolsResponse.tools) {
196627
196729
  for (const tool3 of toolsResponse.tools) {
196628
196730
  const qualifiedName = `${name14}_${tool3.name}`;
@@ -196632,16 +196734,17 @@ var init_client2 = __esm({
196632
196734
  originalName: tool3.name
196633
196735
  });
196634
196736
  if (this.debug) {
196635
- console.error(`[MCP] Registered tool: ${qualifiedName}`);
196737
+ console.error(`[MCP DEBUG] Registered tool: ${qualifiedName}`);
196636
196738
  }
196637
196739
  }
196638
196740
  }
196639
- if (this.debug) {
196640
- console.error(`[MCP] Connected to ${name14} with ${toolsResponse?.tools?.length || 0} tools`);
196641
- }
196741
+ console.error(`[MCP INFO] Connected to ${name14}: ${toolCount} tool${toolCount !== 1 ? "s" : ""} loaded`);
196642
196742
  return true;
196643
196743
  } catch (error2) {
196644
- 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
+ }
196645
196748
  return false;
196646
196749
  }
196647
196750
  }
@@ -196661,7 +196764,7 @@ var init_client2 = __esm({
196661
196764
  }
196662
196765
  try {
196663
196766
  if (this.debug) {
196664
- console.error(`[MCP] Calling ${toolName} with args:`, args);
196767
+ console.error(`[MCP DEBUG] Calling ${toolName} with args:`, JSON.stringify(args, null, 2));
196665
196768
  }
196666
196769
  const timeout = this.config?.settings?.timeout || 3e4;
196667
196770
  const timeoutPromise = new Promise((_2, reject2) => {
@@ -196676,9 +196779,15 @@ var init_client2 = __esm({
196676
196779
  }),
196677
196780
  timeoutPromise
196678
196781
  ]);
196782
+ if (this.debug) {
196783
+ console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
196784
+ }
196679
196785
  return result;
196680
196786
  } catch (error2) {
196681
- 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
+ }
196682
196791
  throw error2;
196683
196792
  }
196684
196793
  }
@@ -196723,20 +196832,32 @@ var init_client2 = __esm({
196723
196832
  */
196724
196833
  async disconnect() {
196725
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
+ }
196726
196844
  for (const [name14, clientInfo] of this.clients.entries()) {
196727
196845
  disconnectPromises.push(
196728
196846
  clientInfo.client.close().then(() => {
196729
196847
  if (this.debug) {
196730
- console.error(`[MCP] Disconnected from ${name14}`);
196848
+ console.error(`[MCP DEBUG] Disconnected from ${name14}`);
196731
196849
  }
196732
196850
  }).catch((error2) => {
196733
- console.error(`[MCP] Error disconnecting from ${name14}:`, error2);
196851
+ console.error(`[MCP ERROR] Error disconnecting from ${name14}:`, error2.message);
196734
196852
  })
196735
196853
  );
196736
196854
  }
196737
196855
  await Promise.all(disconnectPromises);
196738
196856
  this.clients.clear();
196739
196857
  this.tools.clear();
196858
+ if (this.debug) {
196859
+ console.error("[MCP DEBUG] All MCP connections closed");
196860
+ }
196740
196861
  }
196741
196862
  };
196742
196863
  }
@@ -196888,31 +197009,58 @@ var init_xmlBridge = __esm({
196888
197009
  async initialize(config = null) {
196889
197010
  let mcpConfigs = null;
196890
197011
  if (!config) {
197012
+ if (this.debug) {
197013
+ console.error("[MCP DEBUG] No config provided, attempting auto-discovery...");
197014
+ }
196891
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
+ }
196892
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
+ }
196893
197028
  mcpConfigs = { mcpServers: config };
196894
197029
  } else {
197030
+ if (this.debug) {
197031
+ console.error("[MCP DEBUG] Using provided MCP config object");
197032
+ }
196895
197033
  mcpConfigs = config;
196896
197034
  }
196897
197035
  if (!mcpConfigs || !mcpConfigs.mcpServers || Object.keys(mcpConfigs.mcpServers).length === 0) {
196898
- if (this.debug) {
196899
- console.error("[MCP] No MCP servers configured");
196900
- }
197036
+ console.error("[MCP INFO] 0 MCP tools available");
196901
197037
  return;
196902
197038
  }
196903
197039
  try {
197040
+ if (this.debug) {
197041
+ console.error("[MCP DEBUG] Initializing MCP client manager...");
197042
+ }
196904
197043
  this.mcpManager = new MCPClientManager({ debug: this.debug });
196905
197044
  const result = await this.mcpManager.initialize(mcpConfigs);
196906
197045
  const vercelTools = this.mcpManager.getVercelTools();
196907
197046
  this.mcpTools = vercelTools;
197047
+ const toolCount = Object.keys(vercelTools).length;
196908
197048
  for (const [name14, tool3] of Object.entries(vercelTools)) {
196909
197049
  this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14, tool3);
196910
197050
  }
196911
- if (this.debug) {
196912
- 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
+ }
196913
197058
  }
196914
197059
  } catch (error2) {
196915
- 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
+ }
196916
197064
  }
196917
197065
  }
196918
197066
  /**
@@ -196937,24 +197085,35 @@ var init_xmlBridge = __esm({
196937
197085
  async executeFromXml(xmlString) {
196938
197086
  const parsed = parseXmlMcpToolCall(xmlString, this.getToolNames());
196939
197087
  if (!parsed) {
197088
+ console.error("[MCP ERROR] No valid MCP tool call found in XML");
196940
197089
  throw new Error("No valid MCP tool call found in XML");
196941
197090
  }
196942
197091
  const { toolName, params } = parsed;
196943
197092
  if (this.debug) {
196944
- 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));
196945
197095
  }
196946
197096
  const tool3 = this.mcpTools[toolName];
196947
197097
  if (!tool3) {
197098
+ console.error(`[MCP ERROR] Unknown MCP tool: ${toolName}`);
197099
+ console.error(`[MCP ERROR] Available tools: ${this.getToolNames().join(", ")}`);
196948
197100
  throw new Error(`Unknown MCP tool: ${toolName}`);
196949
197101
  }
196950
197102
  try {
196951
197103
  const result = await tool3.execute(params);
197104
+ if (this.debug) {
197105
+ console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
197106
+ }
196952
197107
  return {
196953
197108
  success: true,
196954
197109
  toolName,
196955
197110
  result
196956
197111
  };
196957
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
+ }
196958
197117
  return {
196959
197118
  success: false,
196960
197119
  toolName,
@@ -197088,6 +197247,7 @@ var init_ProbeAgent = __esm({
197088
197247
  this.mcpConfig = options.mcpConfig || null;
197089
197248
  this.mcpServers = options.mcpServers || null;
197090
197249
  this.mcpBridge = null;
197250
+ this._mcpInitialized = false;
197091
197251
  this.initializeModel();
197092
197252
  }
197093
197253
  /**
@@ -197095,7 +197255,8 @@ var init_ProbeAgent = __esm({
197095
197255
  * This method initializes MCP and merges MCP tools into the tool list
197096
197256
  */
197097
197257
  async initialize() {
197098
- if (this.enableMcp) {
197258
+ if (this.enableMcp && !this._mcpInitialized) {
197259
+ this._mcpInitialized = true;
197099
197260
  try {
197100
197261
  await this.initializeMCP();
197101
197262
  if (this.mcpBridge) {
@@ -197119,7 +197280,10 @@ var init_ProbeAgent = __esm({
197119
197280
  console.error("[DEBUG] ========================================\n");
197120
197281
  }
197121
197282
  } catch (error2) {
197122
- 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
+ }
197123
197287
  this.mcpBridge = null;
197124
197288
  }
197125
197289
  }
@@ -197543,13 +197707,13 @@ var init_ProbeAgent = __esm({
197543
197707
  if (this.mcpConfig) {
197544
197708
  mcpConfig = this.mcpConfig;
197545
197709
  if (this.debug) {
197546
- console.log("[DEBUG] Using provided MCP config object");
197710
+ console.error("[MCP DEBUG] Using provided MCP config object");
197547
197711
  }
197548
197712
  } else if (this.mcpConfigPath) {
197549
197713
  try {
197550
197714
  mcpConfig = loadMCPConfigurationFromPath(this.mcpConfigPath);
197551
197715
  if (this.debug) {
197552
- console.log(`[DEBUG] Loaded MCP config from: ${this.mcpConfigPath}`);
197716
+ console.error(`[MCP DEBUG] Loaded MCP config from: ${this.mcpConfigPath}`);
197553
197717
  }
197554
197718
  } catch (error2) {
197555
197719
  throw new Error(`Failed to load MCP config from ${this.mcpConfigPath}: ${error2.message}`);
@@ -197557,8 +197721,13 @@ var init_ProbeAgent = __esm({
197557
197721
  } else if (this.mcpServers) {
197558
197722
  mcpConfig = { mcpServers: this.mcpServers };
197559
197723
  if (this.debug) {
197560
- console.warn("[DEBUG] Using deprecated mcpServers option. Consider using mcpConfig instead.");
197724
+ console.error("[MCP DEBUG] Using deprecated mcpServers option. Consider using mcpConfig instead.");
197725
+ }
197726
+ } else {
197727
+ if (this.debug) {
197728
+ console.error("[MCP DEBUG] No explicit MCP config provided, will attempt auto-discovery");
197561
197729
  }
197730
+ mcpConfig = null;
197562
197731
  }
197563
197732
  this.mcpBridge = new MCPXmlBridge({ debug: this.debug });
197564
197733
  await this.mcpBridge.initialize(mcpConfig);
@@ -197566,22 +197735,25 @@ var init_ProbeAgent = __esm({
197566
197735
  const mcpToolCount = mcpToolNames.length;
197567
197736
  if (mcpToolCount > 0) {
197568
197737
  if (this.debug) {
197569
- console.error("\n[DEBUG] ========================================");
197570
- console.error(`[DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
197571
- 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:");
197572
197741
  for (const toolName of mcpToolNames) {
197573
- console.error(`[DEBUG] - ${toolName}`);
197742
+ console.error(`[MCP DEBUG] - ${toolName}`);
197574
197743
  }
197575
- console.error("[DEBUG] ========================================\n");
197744
+ console.error("[MCP DEBUG] ========================================\n");
197576
197745
  }
197577
197746
  } else {
197578
197747
  if (this.debug) {
197579
- console.error("[DEBUG] No MCP tools loaded, setting bridge to null");
197748
+ console.error("[MCP DEBUG] No MCP tools loaded, setting bridge to null");
197580
197749
  }
197581
197750
  this.mcpBridge = null;
197582
197751
  }
197583
197752
  } catch (error2) {
197584
- 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
+ }
197585
197757
  this.mcpBridge = null;
197586
197758
  }
197587
197759
  }
@@ -197589,6 +197761,23 @@ var init_ProbeAgent = __esm({
197589
197761
  * Get the system message with instructions for the AI (XML Tool Format)
197590
197762
  */
197591
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
+ }
197592
197781
  let toolDefinitions = `
197593
197782
  ${searchToolDefinition}
197594
197783
  ${queryToolDefinition}
@@ -198889,6 +199078,7 @@ __export(index_exports, {
198889
199078
  extractTool: () => extractTool,
198890
199079
  extractToolDefinition: () => extractToolDefinition,
198891
199080
  getBinaryPath: () => getBinaryPath,
199081
+ grep: () => grep,
198892
199082
  initializeSimpleTelemetryFromOptions: () => initializeSimpleTelemetryFromOptions,
198893
199083
  listFilesByLevel: () => listFilesByLevel,
198894
199084
  listFilesToolInstance: () => listFilesToolInstance,
@@ -198911,6 +199101,7 @@ var init_index = __esm({
198911
199101
  init_search();
198912
199102
  init_query();
198913
199103
  init_extract();
199104
+ init_grep();
198914
199105
  init_delegate();
198915
199106
  init_utils();
198916
199107
  init_tools();
@@ -228501,7 +228692,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
228501
228692
  /***/ ((module) => {
228502
228693
 
228503
228694
  "use strict";
228504
- module.exports = {"rE":"0.1.78"};
228695
+ module.exports = {"rE":"0.1.79"};
228505
228696
 
228506
228697
  /***/ })
228507
228698
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/visor",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "visor": "./dist/index.js"
@@ -90,18 +90,18 @@
90
90
  "@octokit/auth-app": "^8.1.0",
91
91
  "@octokit/core": "^7.0.3",
92
92
  "@octokit/rest": "^22.0.0",
93
- "@probelabs/probe": "^0.6.0-rc120",
93
+ "@probelabs/probe": "^0.6.0-rc122",
94
94
  "@types/commander": "^2.12.0",
95
95
  "@types/uuid": "^10.0.0",
96
+ "ajv": "^8.17.1",
97
+ "ajv-formats": "^3.0.1",
96
98
  "cli-table3": "^0.6.5",
97
99
  "commander": "^14.0.0",
98
100
  "js-yaml": "^4.1.0",
99
101
  "liquidjs": "^10.21.1",
100
102
  "node-cron": "^3.0.3",
101
103
  "simple-git": "^3.28.0",
102
- "uuid": "^11.1.0",
103
- "ajv": "^8.17.1",
104
- "ajv-formats": "^3.0.1"
104
+ "uuid": "^11.1.0"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@eslint/js": "^9.34.0",
@@ -123,10 +123,10 @@
123
123
  "prettier": "^3.6.2",
124
124
  "reveal-md": "^6.1.2",
125
125
  "ts-jest": "^29.4.1",
126
+ "ts-json-schema-generator": "^1.5.1",
126
127
  "ts-node": "^10.9.2",
127
128
  "tsup": "^8.5.0",
128
129
  "typescript": "^5.9.2",
129
- "ts-json-schema-generator": "^1.5.1",
130
130
  "wrangler": "^3.0.0"
131
131
  },
132
132
  "peerDependencies": {