@probelabs/probe 0.6.0-rc121 → 0.6.0-rc122
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/README.md +36 -2
- package/build/agent/ProbeAgent.js +50 -14
- package/build/agent/index.js +182 -48
- package/build/agent/mcp/client.js +69 -15
- package/build/agent/mcp/config.js +8 -8
- package/build/agent/mcp/xmlBridge.js +52 -7
- package/build/agent/schemaUtils.js +28 -15
- package/build/grep.js +152 -0
- package/build/index.js +2 -0
- package/build/mcp/index.js +105 -87
- package/build/mcp/index.ts +120 -97
- package/cjs/agent/ProbeAgent.cjs +191 -57
- package/cjs/index.cjs +249 -57
- package/index.d.ts +45 -0
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +50 -14
- package/src/agent/index.js +1 -1
- package/src/agent/mcp/client.js +69 -15
- package/src/agent/mcp/config.js +8 -8
- package/src/agent/mcp/xmlBridge.js +52 -7
- package/src/agent/schemaUtils.js +28 -15
- package/src/grep.js +152 -0
- package/src/index.js +2 -0
- package/src/mcp/index.ts +120 -97
package/cjs/index.cjs
CHANGED
|
@@ -1136,6 +1136,74 @@ var init_extract = __esm({
|
|
|
1136
1136
|
}
|
|
1137
1137
|
});
|
|
1138
1138
|
|
|
1139
|
+
// src/grep.js
|
|
1140
|
+
async function grep(options) {
|
|
1141
|
+
if (!options || !options.pattern) {
|
|
1142
|
+
throw new Error("Pattern is required");
|
|
1143
|
+
}
|
|
1144
|
+
if (!options.paths) {
|
|
1145
|
+
throw new Error("Path(s) are required");
|
|
1146
|
+
}
|
|
1147
|
+
const binaryPath = await getBinaryPath(options.binaryOptions || {});
|
|
1148
|
+
const cliArgs = ["grep"];
|
|
1149
|
+
for (const [key, flag] of Object.entries(GREP_FLAG_MAP)) {
|
|
1150
|
+
const value = options[key];
|
|
1151
|
+
if (value === void 0 || value === null) continue;
|
|
1152
|
+
if (typeof value === "boolean" && value) {
|
|
1153
|
+
cliArgs.push(flag);
|
|
1154
|
+
} else if (typeof value === "number") {
|
|
1155
|
+
cliArgs.push(flag, String(value));
|
|
1156
|
+
} else if (typeof value === "string") {
|
|
1157
|
+
cliArgs.push(flag, value);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
cliArgs.push(options.pattern);
|
|
1161
|
+
const paths = Array.isArray(options.paths) ? options.paths : [options.paths];
|
|
1162
|
+
cliArgs.push(...paths);
|
|
1163
|
+
try {
|
|
1164
|
+
const { stdout, stderr } = await execFileAsync(binaryPath, cliArgs, {
|
|
1165
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
1166
|
+
// 10MB buffer
|
|
1167
|
+
env: {
|
|
1168
|
+
...process.env,
|
|
1169
|
+
// Disable colors in stderr for cleaner output
|
|
1170
|
+
NO_COLOR: "1"
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
return stdout;
|
|
1174
|
+
} catch (error2) {
|
|
1175
|
+
if (error2.code === 1 && !error2.stderr) {
|
|
1176
|
+
return error2.stdout || "";
|
|
1177
|
+
}
|
|
1178
|
+
const errorMessage = error2.stderr || error2.message || "Unknown error";
|
|
1179
|
+
throw new Error(`Grep failed: ${errorMessage}`);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
var import_child_process5, import_util5, execFileAsync, GREP_FLAG_MAP;
|
|
1183
|
+
var init_grep = __esm({
|
|
1184
|
+
"src/grep.js"() {
|
|
1185
|
+
"use strict";
|
|
1186
|
+
import_child_process5 = require("child_process");
|
|
1187
|
+
import_util5 = require("util");
|
|
1188
|
+
init_utils();
|
|
1189
|
+
execFileAsync = (0, import_util5.promisify)(import_child_process5.execFile);
|
|
1190
|
+
GREP_FLAG_MAP = {
|
|
1191
|
+
ignoreCase: "-i",
|
|
1192
|
+
lineNumbers: "-n",
|
|
1193
|
+
count: "-c",
|
|
1194
|
+
filesWithMatches: "-l",
|
|
1195
|
+
filesWithoutMatches: "-L",
|
|
1196
|
+
invertMatch: "-v",
|
|
1197
|
+
beforeContext: "-B",
|
|
1198
|
+
afterContext: "-A",
|
|
1199
|
+
context: "-C",
|
|
1200
|
+
noGitignore: "--no-gitignore",
|
|
1201
|
+
color: "--color",
|
|
1202
|
+
maxCount: "-m"
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1139
1207
|
// src/tools/common.js
|
|
1140
1208
|
function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
1141
1209
|
for (const toolName of validTools) {
|
|
@@ -1619,7 +1687,7 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
|
|
|
1619
1687
|
}
|
|
1620
1688
|
return new Promise((resolve4, reject2) => {
|
|
1621
1689
|
const delegationSpan = tracer ? tracer.createDelegationSpan(sessionId, task) : null;
|
|
1622
|
-
const process2 = (0,
|
|
1690
|
+
const process2 = (0, import_child_process6.spawn)(binaryPath, args, {
|
|
1623
1691
|
stdio: ["pipe", "pipe", "pipe"],
|
|
1624
1692
|
timeout: timeout * 1e3
|
|
1625
1693
|
});
|
|
@@ -1754,11 +1822,11 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
|
|
|
1754
1822
|
throw new Error(`Delegation setup failed: ${error2.message}`);
|
|
1755
1823
|
}
|
|
1756
1824
|
}
|
|
1757
|
-
var
|
|
1825
|
+
var import_child_process6, import_crypto2;
|
|
1758
1826
|
var init_delegate = __esm({
|
|
1759
1827
|
"src/delegate.js"() {
|
|
1760
1828
|
"use strict";
|
|
1761
|
-
|
|
1829
|
+
import_child_process6 = require("child_process");
|
|
1762
1830
|
import_crypto2 = require("crypto");
|
|
1763
1831
|
init_utils();
|
|
1764
1832
|
init_common();
|
|
@@ -2834,7 +2902,7 @@ async function executeBashCommand(command, options = {}) {
|
|
|
2834
2902
|
return;
|
|
2835
2903
|
}
|
|
2836
2904
|
const [cmd, ...cmdArgs] = args;
|
|
2837
|
-
const child = (0,
|
|
2905
|
+
const child = (0, import_child_process7.spawn)(cmd, cmdArgs, {
|
|
2838
2906
|
cwd,
|
|
2839
2907
|
env: processEnv,
|
|
2840
2908
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -3018,11 +3086,11 @@ function validateExecutionOptions(options = {}) {
|
|
|
3018
3086
|
warnings
|
|
3019
3087
|
};
|
|
3020
3088
|
}
|
|
3021
|
-
var
|
|
3089
|
+
var import_child_process7, import_path4, import_fs;
|
|
3022
3090
|
var init_bashExecutor = __esm({
|
|
3023
3091
|
"src/agent/bashExecutor.js"() {
|
|
3024
3092
|
"use strict";
|
|
3025
|
-
|
|
3093
|
+
import_child_process7 = require("child_process");
|
|
3026
3094
|
import_path4 = require("path");
|
|
3027
3095
|
import_fs = require("fs");
|
|
3028
3096
|
init_bashCommandUtils();
|
|
@@ -3547,15 +3615,15 @@ function shouldIgnore(filePath, ignorePatterns) {
|
|
|
3547
3615
|
}
|
|
3548
3616
|
return false;
|
|
3549
3617
|
}
|
|
3550
|
-
var import_fs2, import_path6,
|
|
3618
|
+
var import_fs2, import_path6, import_util6, import_child_process8, execAsync4;
|
|
3551
3619
|
var init_file_lister = __esm({
|
|
3552
3620
|
"src/utils/file-lister.js"() {
|
|
3553
3621
|
"use strict";
|
|
3554
3622
|
import_fs2 = __toESM(require("fs"), 1);
|
|
3555
3623
|
import_path6 = __toESM(require("path"), 1);
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
execAsync4 = (0,
|
|
3624
|
+
import_util6 = require("util");
|
|
3625
|
+
import_child_process8 = require("child_process");
|
|
3626
|
+
execAsync4 = (0, import_util6.promisify)(import_child_process8.exec);
|
|
3559
3627
|
}
|
|
3560
3628
|
});
|
|
3561
3629
|
|
|
@@ -24865,8 +24933,8 @@ var require_dist_cjs59 = __commonJS({
|
|
|
24865
24933
|
module2.exports = __toCommonJS2(index_exports2);
|
|
24866
24934
|
var import_property_provider2 = require_dist_cjs24();
|
|
24867
24935
|
var import_shared_ini_file_loader = require_dist_cjs42();
|
|
24868
|
-
var
|
|
24869
|
-
var
|
|
24936
|
+
var import_child_process10 = require("child_process");
|
|
24937
|
+
var import_util10 = require("util");
|
|
24870
24938
|
var import_client7 = (init_client(), __toCommonJS(client_exports));
|
|
24871
24939
|
var getValidatedProcessCredentials = /* @__PURE__ */ __name((profileName, data2, profiles) => {
|
|
24872
24940
|
if (data2.Version !== 1) {
|
|
@@ -24902,7 +24970,7 @@ var require_dist_cjs59 = __commonJS({
|
|
|
24902
24970
|
if (profiles[profileName]) {
|
|
24903
24971
|
const credentialProcess = profile["credential_process"];
|
|
24904
24972
|
if (credentialProcess !== void 0) {
|
|
24905
|
-
const execPromise = (0,
|
|
24973
|
+
const execPromise = (0, import_util10.promisify)(import_shared_ini_file_loader.externalDataInterceptor?.getTokenRecord?.().exec ?? import_child_process10.exec);
|
|
24906
24974
|
try {
|
|
24907
24975
|
const { stdout } = await execPromise(credentialProcess);
|
|
24908
24976
|
let data2;
|
|
@@ -31340,13 +31408,13 @@ function createWrappedTools(baseTools) {
|
|
|
31340
31408
|
}
|
|
31341
31409
|
return wrappedTools;
|
|
31342
31410
|
}
|
|
31343
|
-
var
|
|
31411
|
+
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;
|
|
31344
31412
|
var init_probeTool = __esm({
|
|
31345
31413
|
"src/agent/probeTool.js"() {
|
|
31346
31414
|
"use strict";
|
|
31347
31415
|
init_index();
|
|
31348
|
-
|
|
31349
|
-
|
|
31416
|
+
import_child_process9 = require("child_process");
|
|
31417
|
+
import_util9 = require("util");
|
|
31350
31418
|
import_crypto4 = require("crypto");
|
|
31351
31419
|
import_events = require("events");
|
|
31352
31420
|
import_fs3 = __toESM(require("fs"), 1);
|
|
@@ -60493,6 +60561,14 @@ function cleanSchemaResponse(response) {
|
|
|
60493
60561
|
return response;
|
|
60494
60562
|
}
|
|
60495
60563
|
const trimmed = response.trim();
|
|
60564
|
+
const jsonBlockMatch = trimmed.match(/```json\s*\n([\s\S]*?)\n```/);
|
|
60565
|
+
if (jsonBlockMatch) {
|
|
60566
|
+
return jsonBlockMatch[1].trim();
|
|
60567
|
+
}
|
|
60568
|
+
const anyBlockMatch = trimmed.match(/```\s*\n([{\[][\s\S]*?[}\]])\s*```/);
|
|
60569
|
+
if (anyBlockMatch) {
|
|
60570
|
+
return anyBlockMatch[1].trim();
|
|
60571
|
+
}
|
|
60496
60572
|
const codeBlockPatterns = [
|
|
60497
60573
|
/```json\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
|
|
60498
60574
|
/```\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
|
|
@@ -61305,8 +61381,8 @@ function loadMCPConfigurationFromPath(configPath) {
|
|
|
61305
61381
|
try {
|
|
61306
61382
|
const content = (0, import_fs5.readFileSync)(configPath, "utf8");
|
|
61307
61383
|
const config = JSON.parse(content);
|
|
61308
|
-
if (process.env.DEBUG === "1") {
|
|
61309
|
-
console.error(`[MCP] Loaded configuration from: ${configPath}`);
|
|
61384
|
+
if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
|
|
61385
|
+
console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
|
|
61310
61386
|
}
|
|
61311
61387
|
return mergeWithEnvironment(config);
|
|
61312
61388
|
} catch (error2) {
|
|
@@ -61332,12 +61408,12 @@ function loadMCPConfiguration() {
|
|
|
61332
61408
|
try {
|
|
61333
61409
|
const content = (0, import_fs5.readFileSync)(configPath, "utf8");
|
|
61334
61410
|
config = JSON.parse(content);
|
|
61335
|
-
if (process.env.DEBUG === "1") {
|
|
61336
|
-
console.error(`[MCP] Loaded configuration from: ${configPath}`);
|
|
61411
|
+
if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
|
|
61412
|
+
console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
|
|
61337
61413
|
}
|
|
61338
61414
|
break;
|
|
61339
61415
|
} catch (error2) {
|
|
61340
|
-
console.error(`[MCP] Failed to parse config from ${configPath}:`, error2.message);
|
|
61416
|
+
console.error(`[MCP ERROR] Failed to parse config from ${configPath}:`, error2.message);
|
|
61341
61417
|
}
|
|
61342
61418
|
}
|
|
61343
61419
|
}
|
|
@@ -61413,12 +61489,12 @@ function parseEnabledServers(config) {
|
|
|
61413
61489
|
}
|
|
61414
61490
|
if (server.transport === "stdio") {
|
|
61415
61491
|
if (!server.command) {
|
|
61416
|
-
console.error(`[MCP] Server ${name14} missing required 'command' for stdio transport`);
|
|
61492
|
+
console.error(`[MCP ERROR] Server ${name14} missing required 'command' for stdio transport`);
|
|
61417
61493
|
continue;
|
|
61418
61494
|
}
|
|
61419
61495
|
} else if (["websocket", "sse", "http"].includes(server.transport)) {
|
|
61420
61496
|
if (!server.url) {
|
|
61421
|
-
console.error(`[MCP] Server ${name14} missing required 'url' for ${server.transport} transport`);
|
|
61497
|
+
console.error(`[MCP ERROR] Server ${name14} missing required 'url' for ${server.transport} transport`);
|
|
61422
61498
|
continue;
|
|
61423
61499
|
}
|
|
61424
61500
|
}
|
|
@@ -61549,20 +61625,45 @@ var init_client2 = __esm({
|
|
|
61549
61625
|
async initialize(config = null) {
|
|
61550
61626
|
this.config = config || loadMCPConfiguration();
|
|
61551
61627
|
const servers = parseEnabledServers(this.config);
|
|
61628
|
+
console.error(`[MCP INFO] Found ${servers.length} enabled MCP server${servers.length !== 1 ? "s" : ""}`);
|
|
61629
|
+
if (servers.length === 0) {
|
|
61630
|
+
console.error("[MCP INFO] No MCP servers configured or enabled");
|
|
61631
|
+
console.error("[MCP INFO] 0 MCP tools available");
|
|
61632
|
+
return {
|
|
61633
|
+
connected: 0,
|
|
61634
|
+
total: 0,
|
|
61635
|
+
tools: []
|
|
61636
|
+
};
|
|
61637
|
+
}
|
|
61552
61638
|
if (this.debug) {
|
|
61553
|
-
console.error(
|
|
61639
|
+
console.error("[MCP DEBUG] Server details:");
|
|
61640
|
+
servers.forEach((server) => {
|
|
61641
|
+
console.error(`[MCP DEBUG] - ${server.name} (${server.transport})`);
|
|
61642
|
+
});
|
|
61554
61643
|
}
|
|
61555
61644
|
const connectionPromises = servers.map(
|
|
61556
61645
|
(server) => this.connectToServer(server).catch((error2) => {
|
|
61557
|
-
console.error(`[MCP] Failed to connect to ${server.name}:`, error2.message);
|
|
61646
|
+
console.error(`[MCP ERROR] Failed to connect to ${server.name}:`, error2.message);
|
|
61558
61647
|
return null;
|
|
61559
61648
|
})
|
|
61560
61649
|
);
|
|
61561
61650
|
const results = await Promise.all(connectionPromises);
|
|
61562
61651
|
const connectedCount = results.filter(Boolean).length;
|
|
61563
|
-
if (
|
|
61564
|
-
console.error(`[MCP]
|
|
61565
|
-
console.error(
|
|
61652
|
+
if (connectedCount === 0) {
|
|
61653
|
+
console.error(`[MCP ERROR] Failed to connect to all ${servers.length} server${servers.length !== 1 ? "s" : ""}`);
|
|
61654
|
+
console.error("[MCP INFO] 0 MCP tools available");
|
|
61655
|
+
} else if (connectedCount < servers.length) {
|
|
61656
|
+
console.error(`[MCP INFO] Successfully connected to ${connectedCount}/${servers.length} servers`);
|
|
61657
|
+
console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? "s" : ""} available`);
|
|
61658
|
+
} else {
|
|
61659
|
+
console.error(`[MCP INFO] Successfully connected to all ${connectedCount} server${connectedCount !== 1 ? "s" : ""}`);
|
|
61660
|
+
console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? "s" : ""} available`);
|
|
61661
|
+
}
|
|
61662
|
+
if (this.debug && this.tools.size > 0) {
|
|
61663
|
+
console.error("[MCP DEBUG] Available tools:");
|
|
61664
|
+
Array.from(this.tools.keys()).forEach((toolName) => {
|
|
61665
|
+
console.error(`[MCP DEBUG] - ${toolName}`);
|
|
61666
|
+
});
|
|
61566
61667
|
}
|
|
61567
61668
|
return {
|
|
61568
61669
|
connected: connectedCount,
|
|
@@ -61578,7 +61679,7 @@ var init_client2 = __esm({
|
|
|
61578
61679
|
const { name: name14 } = serverConfig;
|
|
61579
61680
|
try {
|
|
61580
61681
|
if (this.debug) {
|
|
61581
|
-
console.error(`[MCP] Connecting to ${name14} via ${serverConfig.transport}...`);
|
|
61682
|
+
console.error(`[MCP DEBUG] Connecting to ${name14} via ${serverConfig.transport}...`);
|
|
61582
61683
|
}
|
|
61583
61684
|
const transport = createTransport(serverConfig);
|
|
61584
61685
|
const client = new import_client3.Client(
|
|
@@ -61597,6 +61698,7 @@ var init_client2 = __esm({
|
|
|
61597
61698
|
config: serverConfig
|
|
61598
61699
|
});
|
|
61599
61700
|
const toolsResponse = await client.listTools();
|
|
61701
|
+
const toolCount = toolsResponse?.tools?.length || 0;
|
|
61600
61702
|
if (toolsResponse && toolsResponse.tools) {
|
|
61601
61703
|
for (const tool3 of toolsResponse.tools) {
|
|
61602
61704
|
const qualifiedName = `${name14}_${tool3.name}`;
|
|
@@ -61606,16 +61708,17 @@ var init_client2 = __esm({
|
|
|
61606
61708
|
originalName: tool3.name
|
|
61607
61709
|
});
|
|
61608
61710
|
if (this.debug) {
|
|
61609
|
-
console.error(`[MCP]
|
|
61711
|
+
console.error(`[MCP DEBUG] Registered tool: ${qualifiedName}`);
|
|
61610
61712
|
}
|
|
61611
61713
|
}
|
|
61612
61714
|
}
|
|
61613
|
-
|
|
61614
|
-
console.error(`[MCP] Connected to ${name14} with ${toolsResponse?.tools?.length || 0} tools`);
|
|
61615
|
-
}
|
|
61715
|
+
console.error(`[MCP INFO] Connected to ${name14}: ${toolCount} tool${toolCount !== 1 ? "s" : ""} loaded`);
|
|
61616
61716
|
return true;
|
|
61617
61717
|
} catch (error2) {
|
|
61618
|
-
console.error(`[MCP] Error connecting to ${name14}:`, error2.message);
|
|
61718
|
+
console.error(`[MCP ERROR] Error connecting to ${name14}:`, error2.message);
|
|
61719
|
+
if (this.debug) {
|
|
61720
|
+
console.error(`[MCP DEBUG] Full error details:`, error2);
|
|
61721
|
+
}
|
|
61619
61722
|
return false;
|
|
61620
61723
|
}
|
|
61621
61724
|
}
|
|
@@ -61635,7 +61738,7 @@ var init_client2 = __esm({
|
|
|
61635
61738
|
}
|
|
61636
61739
|
try {
|
|
61637
61740
|
if (this.debug) {
|
|
61638
|
-
console.error(`[MCP] Calling ${toolName} with args:`, args);
|
|
61741
|
+
console.error(`[MCP DEBUG] Calling ${toolName} with args:`, JSON.stringify(args, null, 2));
|
|
61639
61742
|
}
|
|
61640
61743
|
const timeout = this.config?.settings?.timeout || 3e4;
|
|
61641
61744
|
const timeoutPromise = new Promise((_2, reject2) => {
|
|
@@ -61650,9 +61753,15 @@ var init_client2 = __esm({
|
|
|
61650
61753
|
}),
|
|
61651
61754
|
timeoutPromise
|
|
61652
61755
|
]);
|
|
61756
|
+
if (this.debug) {
|
|
61757
|
+
console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
|
|
61758
|
+
}
|
|
61653
61759
|
return result;
|
|
61654
61760
|
} catch (error2) {
|
|
61655
|
-
console.error(`[MCP] Error calling tool ${toolName}:`, error2);
|
|
61761
|
+
console.error(`[MCP ERROR] Error calling tool ${toolName}:`, error2.message);
|
|
61762
|
+
if (this.debug) {
|
|
61763
|
+
console.error(`[MCP DEBUG] Full error details:`, error2);
|
|
61764
|
+
}
|
|
61656
61765
|
throw error2;
|
|
61657
61766
|
}
|
|
61658
61767
|
}
|
|
@@ -61697,20 +61806,32 @@ var init_client2 = __esm({
|
|
|
61697
61806
|
*/
|
|
61698
61807
|
async disconnect() {
|
|
61699
61808
|
const disconnectPromises = [];
|
|
61809
|
+
if (this.clients.size === 0) {
|
|
61810
|
+
if (this.debug) {
|
|
61811
|
+
console.error("[MCP DEBUG] No MCP clients to disconnect");
|
|
61812
|
+
}
|
|
61813
|
+
return;
|
|
61814
|
+
}
|
|
61815
|
+
if (this.debug) {
|
|
61816
|
+
console.error(`[MCP DEBUG] Disconnecting from ${this.clients.size} MCP server${this.clients.size !== 1 ? "s" : ""}...`);
|
|
61817
|
+
}
|
|
61700
61818
|
for (const [name14, clientInfo] of this.clients.entries()) {
|
|
61701
61819
|
disconnectPromises.push(
|
|
61702
61820
|
clientInfo.client.close().then(() => {
|
|
61703
61821
|
if (this.debug) {
|
|
61704
|
-
console.error(`[MCP] Disconnected from ${name14}`);
|
|
61822
|
+
console.error(`[MCP DEBUG] Disconnected from ${name14}`);
|
|
61705
61823
|
}
|
|
61706
61824
|
}).catch((error2) => {
|
|
61707
|
-
console.error(`[MCP] Error disconnecting from ${name14}:`, error2);
|
|
61825
|
+
console.error(`[MCP ERROR] Error disconnecting from ${name14}:`, error2.message);
|
|
61708
61826
|
})
|
|
61709
61827
|
);
|
|
61710
61828
|
}
|
|
61711
61829
|
await Promise.all(disconnectPromises);
|
|
61712
61830
|
this.clients.clear();
|
|
61713
61831
|
this.tools.clear();
|
|
61832
|
+
if (this.debug) {
|
|
61833
|
+
console.error("[MCP DEBUG] All MCP connections closed");
|
|
61834
|
+
}
|
|
61714
61835
|
}
|
|
61715
61836
|
};
|
|
61716
61837
|
}
|
|
@@ -61862,31 +61983,58 @@ var init_xmlBridge = __esm({
|
|
|
61862
61983
|
async initialize(config = null) {
|
|
61863
61984
|
let mcpConfigs = null;
|
|
61864
61985
|
if (!config) {
|
|
61986
|
+
if (this.debug) {
|
|
61987
|
+
console.error("[MCP DEBUG] No config provided, attempting auto-discovery...");
|
|
61988
|
+
}
|
|
61865
61989
|
mcpConfigs = loadMCPConfiguration();
|
|
61990
|
+
if (!mcpConfigs || !mcpConfigs.mcpServers || Object.keys(mcpConfigs.mcpServers).length === 0) {
|
|
61991
|
+
console.error("[MCP WARNING] MCP enabled but no configuration found");
|
|
61992
|
+
console.error("[MCP INFO] To use MCP, provide configuration via:");
|
|
61993
|
+
console.error("[MCP INFO] - mcpConfig option when creating ProbeAgent");
|
|
61994
|
+
console.error("[MCP INFO] - mcpConfigPath option pointing to a config file");
|
|
61995
|
+
console.error("[MCP INFO] - Config file in standard locations (~/.mcp/config.json, etc.)");
|
|
61996
|
+
console.error("[MCP INFO] - Environment variable MCP_CONFIG_PATH");
|
|
61997
|
+
}
|
|
61866
61998
|
} else if (Array.isArray(config)) {
|
|
61999
|
+
if (this.debug) {
|
|
62000
|
+
console.error("[MCP DEBUG] Using deprecated array config format (consider using mcpConfig object)");
|
|
62001
|
+
}
|
|
61867
62002
|
mcpConfigs = { mcpServers: config };
|
|
61868
62003
|
} else {
|
|
62004
|
+
if (this.debug) {
|
|
62005
|
+
console.error("[MCP DEBUG] Using provided MCP config object");
|
|
62006
|
+
}
|
|
61869
62007
|
mcpConfigs = config;
|
|
61870
62008
|
}
|
|
61871
62009
|
if (!mcpConfigs || !mcpConfigs.mcpServers || Object.keys(mcpConfigs.mcpServers).length === 0) {
|
|
61872
|
-
|
|
61873
|
-
console.error("[MCP] No MCP servers configured");
|
|
61874
|
-
}
|
|
62010
|
+
console.error("[MCP INFO] 0 MCP tools available");
|
|
61875
62011
|
return;
|
|
61876
62012
|
}
|
|
61877
62013
|
try {
|
|
62014
|
+
if (this.debug) {
|
|
62015
|
+
console.error("[MCP DEBUG] Initializing MCP client manager...");
|
|
62016
|
+
}
|
|
61878
62017
|
this.mcpManager = new MCPClientManager({ debug: this.debug });
|
|
61879
62018
|
const result = await this.mcpManager.initialize(mcpConfigs);
|
|
61880
62019
|
const vercelTools = this.mcpManager.getVercelTools();
|
|
61881
62020
|
this.mcpTools = vercelTools;
|
|
62021
|
+
const toolCount = Object.keys(vercelTools).length;
|
|
61882
62022
|
for (const [name14, tool3] of Object.entries(vercelTools)) {
|
|
61883
62023
|
this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14, tool3);
|
|
61884
62024
|
}
|
|
61885
|
-
if (
|
|
61886
|
-
console.error(
|
|
62025
|
+
if (toolCount === 0) {
|
|
62026
|
+
console.error("[MCP INFO] MCP initialization complete: 0 tools loaded");
|
|
62027
|
+
} else {
|
|
62028
|
+
console.error(`[MCP INFO] MCP initialization complete: ${toolCount} tool${toolCount !== 1 ? "s" : ""} loaded from ${result.connected} server${result.connected !== 1 ? "s" : ""}`);
|
|
62029
|
+
if (this.debug) {
|
|
62030
|
+
console.error("[MCP DEBUG] Tool definitions generated for XML bridge");
|
|
62031
|
+
}
|
|
61887
62032
|
}
|
|
61888
62033
|
} catch (error2) {
|
|
61889
|
-
console.error("[MCP] Failed to initialize MCP connections:", error2);
|
|
62034
|
+
console.error("[MCP ERROR] Failed to initialize MCP connections:", error2.message);
|
|
62035
|
+
if (this.debug) {
|
|
62036
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62037
|
+
}
|
|
61890
62038
|
}
|
|
61891
62039
|
}
|
|
61892
62040
|
/**
|
|
@@ -61911,24 +62059,35 @@ var init_xmlBridge = __esm({
|
|
|
61911
62059
|
async executeFromXml(xmlString) {
|
|
61912
62060
|
const parsed = parseXmlMcpToolCall(xmlString, this.getToolNames());
|
|
61913
62061
|
if (!parsed) {
|
|
62062
|
+
console.error("[MCP ERROR] No valid MCP tool call found in XML");
|
|
61914
62063
|
throw new Error("No valid MCP tool call found in XML");
|
|
61915
62064
|
}
|
|
61916
62065
|
const { toolName, params } = parsed;
|
|
61917
62066
|
if (this.debug) {
|
|
61918
|
-
console.error(`[MCP] Executing MCP tool: ${toolName}
|
|
62067
|
+
console.error(`[MCP DEBUG] Executing MCP tool: ${toolName}`);
|
|
62068
|
+
console.error(`[MCP DEBUG] Parameters:`, JSON.stringify(params, null, 2));
|
|
61919
62069
|
}
|
|
61920
62070
|
const tool3 = this.mcpTools[toolName];
|
|
61921
62071
|
if (!tool3) {
|
|
62072
|
+
console.error(`[MCP ERROR] Unknown MCP tool: ${toolName}`);
|
|
62073
|
+
console.error(`[MCP ERROR] Available tools: ${this.getToolNames().join(", ")}`);
|
|
61922
62074
|
throw new Error(`Unknown MCP tool: ${toolName}`);
|
|
61923
62075
|
}
|
|
61924
62076
|
try {
|
|
61925
62077
|
const result = await tool3.execute(params);
|
|
62078
|
+
if (this.debug) {
|
|
62079
|
+
console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
|
|
62080
|
+
}
|
|
61926
62081
|
return {
|
|
61927
62082
|
success: true,
|
|
61928
62083
|
toolName,
|
|
61929
62084
|
result
|
|
61930
62085
|
};
|
|
61931
62086
|
} catch (error2) {
|
|
62087
|
+
console.error(`[MCP ERROR] Tool ${toolName} execution failed:`, error2.message);
|
|
62088
|
+
if (this.debug) {
|
|
62089
|
+
console.error(`[MCP DEBUG] Full error details:`, error2);
|
|
62090
|
+
}
|
|
61932
62091
|
return {
|
|
61933
62092
|
success: false,
|
|
61934
62093
|
toolName,
|
|
@@ -62062,6 +62221,7 @@ var init_ProbeAgent = __esm({
|
|
|
62062
62221
|
this.mcpConfig = options.mcpConfig || null;
|
|
62063
62222
|
this.mcpServers = options.mcpServers || null;
|
|
62064
62223
|
this.mcpBridge = null;
|
|
62224
|
+
this._mcpInitialized = false;
|
|
62065
62225
|
this.initializeModel();
|
|
62066
62226
|
}
|
|
62067
62227
|
/**
|
|
@@ -62069,7 +62229,8 @@ var init_ProbeAgent = __esm({
|
|
|
62069
62229
|
* This method initializes MCP and merges MCP tools into the tool list
|
|
62070
62230
|
*/
|
|
62071
62231
|
async initialize() {
|
|
62072
|
-
if (this.enableMcp) {
|
|
62232
|
+
if (this.enableMcp && !this._mcpInitialized) {
|
|
62233
|
+
this._mcpInitialized = true;
|
|
62073
62234
|
try {
|
|
62074
62235
|
await this.initializeMCP();
|
|
62075
62236
|
if (this.mcpBridge) {
|
|
@@ -62093,7 +62254,10 @@ var init_ProbeAgent = __esm({
|
|
|
62093
62254
|
console.error("[DEBUG] ========================================\n");
|
|
62094
62255
|
}
|
|
62095
62256
|
} catch (error2) {
|
|
62096
|
-
console.error("[MCP] Failed to initialize MCP:", error2);
|
|
62257
|
+
console.error("[MCP ERROR] Failed to initialize MCP:", error2.message);
|
|
62258
|
+
if (this.debug) {
|
|
62259
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62260
|
+
}
|
|
62097
62261
|
this.mcpBridge = null;
|
|
62098
62262
|
}
|
|
62099
62263
|
}
|
|
@@ -62517,13 +62681,13 @@ var init_ProbeAgent = __esm({
|
|
|
62517
62681
|
if (this.mcpConfig) {
|
|
62518
62682
|
mcpConfig = this.mcpConfig;
|
|
62519
62683
|
if (this.debug) {
|
|
62520
|
-
console.
|
|
62684
|
+
console.error("[MCP DEBUG] Using provided MCP config object");
|
|
62521
62685
|
}
|
|
62522
62686
|
} else if (this.mcpConfigPath) {
|
|
62523
62687
|
try {
|
|
62524
62688
|
mcpConfig = loadMCPConfigurationFromPath(this.mcpConfigPath);
|
|
62525
62689
|
if (this.debug) {
|
|
62526
|
-
console.
|
|
62690
|
+
console.error(`[MCP DEBUG] Loaded MCP config from: ${this.mcpConfigPath}`);
|
|
62527
62691
|
}
|
|
62528
62692
|
} catch (error2) {
|
|
62529
62693
|
throw new Error(`Failed to load MCP config from ${this.mcpConfigPath}: ${error2.message}`);
|
|
@@ -62531,8 +62695,13 @@ var init_ProbeAgent = __esm({
|
|
|
62531
62695
|
} else if (this.mcpServers) {
|
|
62532
62696
|
mcpConfig = { mcpServers: this.mcpServers };
|
|
62533
62697
|
if (this.debug) {
|
|
62534
|
-
console.
|
|
62698
|
+
console.error("[MCP DEBUG] Using deprecated mcpServers option. Consider using mcpConfig instead.");
|
|
62699
|
+
}
|
|
62700
|
+
} else {
|
|
62701
|
+
if (this.debug) {
|
|
62702
|
+
console.error("[MCP DEBUG] No explicit MCP config provided, will attempt auto-discovery");
|
|
62535
62703
|
}
|
|
62704
|
+
mcpConfig = null;
|
|
62536
62705
|
}
|
|
62537
62706
|
this.mcpBridge = new MCPXmlBridge({ debug: this.debug });
|
|
62538
62707
|
await this.mcpBridge.initialize(mcpConfig);
|
|
@@ -62540,22 +62709,25 @@ var init_ProbeAgent = __esm({
|
|
|
62540
62709
|
const mcpToolCount = mcpToolNames.length;
|
|
62541
62710
|
if (mcpToolCount > 0) {
|
|
62542
62711
|
if (this.debug) {
|
|
62543
|
-
console.error("\n[DEBUG] ========================================");
|
|
62544
|
-
console.error(`[DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
|
|
62545
|
-
console.error("[DEBUG] Available MCP tools:");
|
|
62712
|
+
console.error("\n[MCP DEBUG] ========================================");
|
|
62713
|
+
console.error(`[MCP DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
|
|
62714
|
+
console.error("[MCP DEBUG] Available MCP tools:");
|
|
62546
62715
|
for (const toolName of mcpToolNames) {
|
|
62547
|
-
console.error(`[DEBUG] - ${toolName}`);
|
|
62716
|
+
console.error(`[MCP DEBUG] - ${toolName}`);
|
|
62548
62717
|
}
|
|
62549
|
-
console.error("[DEBUG] ========================================\n");
|
|
62718
|
+
console.error("[MCP DEBUG] ========================================\n");
|
|
62550
62719
|
}
|
|
62551
62720
|
} else {
|
|
62552
62721
|
if (this.debug) {
|
|
62553
|
-
console.error("[DEBUG] No MCP tools loaded, setting bridge to null");
|
|
62722
|
+
console.error("[MCP DEBUG] No MCP tools loaded, setting bridge to null");
|
|
62554
62723
|
}
|
|
62555
62724
|
this.mcpBridge = null;
|
|
62556
62725
|
}
|
|
62557
62726
|
} catch (error2) {
|
|
62558
|
-
console.error("[MCP] Error initializing MCP:", error2);
|
|
62727
|
+
console.error("[MCP ERROR] Error initializing MCP:", error2.message);
|
|
62728
|
+
if (this.debug) {
|
|
62729
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62730
|
+
}
|
|
62559
62731
|
this.mcpBridge = null;
|
|
62560
62732
|
}
|
|
62561
62733
|
}
|
|
@@ -62563,6 +62735,23 @@ var init_ProbeAgent = __esm({
|
|
|
62563
62735
|
* Get the system message with instructions for the AI (XML Tool Format)
|
|
62564
62736
|
*/
|
|
62565
62737
|
async getSystemMessage() {
|
|
62738
|
+
if (this.enableMcp && !this.mcpBridge && !this._mcpInitialized) {
|
|
62739
|
+
this._mcpInitialized = true;
|
|
62740
|
+
try {
|
|
62741
|
+
await this.initializeMCP();
|
|
62742
|
+
if (this.mcpBridge) {
|
|
62743
|
+
const mcpTools = this.mcpBridge.mcpTools || {};
|
|
62744
|
+
for (const [toolName, toolImpl] of Object.entries(mcpTools)) {
|
|
62745
|
+
this.toolImplementations[toolName] = toolImpl;
|
|
62746
|
+
}
|
|
62747
|
+
}
|
|
62748
|
+
} catch (error2) {
|
|
62749
|
+
console.error("[MCP ERROR] Failed to lazy-initialize MCP:", error2.message);
|
|
62750
|
+
if (this.debug) {
|
|
62751
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62752
|
+
}
|
|
62753
|
+
}
|
|
62754
|
+
}
|
|
62566
62755
|
let toolDefinitions = `
|
|
62567
62756
|
${searchToolDefinition}
|
|
62568
62757
|
${queryToolDefinition}
|
|
@@ -63863,6 +64052,7 @@ __export(index_exports, {
|
|
|
63863
64052
|
extractTool: () => extractTool,
|
|
63864
64053
|
extractToolDefinition: () => extractToolDefinition,
|
|
63865
64054
|
getBinaryPath: () => getBinaryPath,
|
|
64055
|
+
grep: () => grep,
|
|
63866
64056
|
initializeSimpleTelemetryFromOptions: () => initializeSimpleTelemetryFromOptions,
|
|
63867
64057
|
listFilesByLevel: () => listFilesByLevel,
|
|
63868
64058
|
listFilesToolInstance: () => listFilesToolInstance,
|
|
@@ -63885,6 +64075,7 @@ var init_index = __esm({
|
|
|
63885
64075
|
init_search();
|
|
63886
64076
|
init_query();
|
|
63887
64077
|
init_extract();
|
|
64078
|
+
init_grep();
|
|
63888
64079
|
init_delegate();
|
|
63889
64080
|
init_utils();
|
|
63890
64081
|
init_tools();
|
|
@@ -63919,6 +64110,7 @@ init_index();
|
|
|
63919
64110
|
extractTool,
|
|
63920
64111
|
extractToolDefinition,
|
|
63921
64112
|
getBinaryPath,
|
|
64113
|
+
grep,
|
|
63922
64114
|
initializeSimpleTelemetryFromOptions,
|
|
63923
64115
|
listFilesByLevel,
|
|
63924
64116
|
listFilesToolInstance,
|
package/index.d.ts
CHANGED
|
@@ -303,6 +303,51 @@ export declare function query(
|
|
|
303
303
|
}
|
|
304
304
|
): Promise<any>;
|
|
305
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Standard grep-style search that works across multiple operating systems
|
|
308
|
+
*
|
|
309
|
+
* Use this for searching non-code files (logs, config files, text files, etc.)
|
|
310
|
+
* that are not supported by probe's semantic search. For code files, prefer
|
|
311
|
+
* using the search() function which provides AST-aware semantic search.
|
|
312
|
+
*
|
|
313
|
+
* @param options - Grep options
|
|
314
|
+
* @param options.pattern - Regular expression pattern to search for
|
|
315
|
+
* @param options.paths - Path or array of paths to search in
|
|
316
|
+
* @param options.ignoreCase - Case-insensitive search (-i flag)
|
|
317
|
+
* @param options.lineNumbers - Show line numbers in output (-n flag)
|
|
318
|
+
* @param options.count - Only show count of matches per file (-c flag)
|
|
319
|
+
* @param options.filesWithMatches - Only show filenames that contain matches (-l flag)
|
|
320
|
+
* @param options.filesWithoutMatches - Only show filenames that do not contain matches (-L flag)
|
|
321
|
+
* @param options.invertMatch - Invert match: show lines that do NOT match (-v flag)
|
|
322
|
+
* @param options.beforeContext - Number of lines of context before match (-B flag)
|
|
323
|
+
* @param options.afterContext - Number of lines of context after match (-A flag)
|
|
324
|
+
* @param options.context - Number of lines of context before and after match (-C flag)
|
|
325
|
+
* @param options.noGitignore - Do not respect .gitignore files (--no-gitignore flag)
|
|
326
|
+
* @param options.color - Colorize output: 'always', 'never', 'auto' (--color flag)
|
|
327
|
+
* @param options.maxCount - Stop reading a file after N matching lines (-m flag)
|
|
328
|
+
* @returns Promise resolving to grep results as string
|
|
329
|
+
*/
|
|
330
|
+
export declare function grep(options: {
|
|
331
|
+
pattern: string;
|
|
332
|
+
paths: string | string[];
|
|
333
|
+
ignoreCase?: boolean;
|
|
334
|
+
lineNumbers?: boolean;
|
|
335
|
+
count?: boolean;
|
|
336
|
+
filesWithMatches?: boolean;
|
|
337
|
+
filesWithoutMatches?: boolean;
|
|
338
|
+
invertMatch?: boolean;
|
|
339
|
+
beforeContext?: number;
|
|
340
|
+
afterContext?: number;
|
|
341
|
+
context?: number;
|
|
342
|
+
noGitignore?: boolean;
|
|
343
|
+
color?: 'always' | 'never' | 'auto';
|
|
344
|
+
maxCount?: number;
|
|
345
|
+
binaryOptions?: {
|
|
346
|
+
forceDownload?: boolean;
|
|
347
|
+
version?: string;
|
|
348
|
+
};
|
|
349
|
+
}): Promise<string>;
|
|
350
|
+
|
|
306
351
|
/**
|
|
307
352
|
* Extract code blocks from files
|
|
308
353
|
*/
|