@probelabs/probe 0.6.0-rc165 → 0.6.0-rc167

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.
@@ -3404,7 +3404,7 @@ async function delegate({
3404
3404
  maxIterations = 30,
3405
3405
  tracer = null,
3406
3406
  parentSessionId = null,
3407
- path: path7 = null,
3407
+ path: path8 = null,
3408
3408
  provider = null,
3409
3409
  model = null
3410
3410
  }) {
@@ -3444,7 +3444,7 @@ async function delegate({
3444
3444
  maxIterations: remainingIterations,
3445
3445
  debug,
3446
3446
  tracer,
3447
- path: path7,
3447
+ path: path8,
3448
3448
  // Inherit from parent
3449
3449
  provider,
3450
3450
  // Inherit from parent
@@ -4062,8 +4062,8 @@ var init_parseUtil = __esm({
4062
4062
  init_errors();
4063
4063
  init_en();
4064
4064
  makeIssue = (params) => {
4065
- const { data, path: path7, errorMaps, issueData } = params;
4066
- const fullPath = [...path7, ...issueData.path || []];
4065
+ const { data, path: path8, errorMaps, issueData } = params;
4066
+ const fullPath = [...path8, ...issueData.path || []];
4067
4067
  const fullIssue = {
4068
4068
  ...issueData,
4069
4069
  path: fullPath
@@ -4371,11 +4371,11 @@ var init_types = __esm({
4371
4371
  init_parseUtil();
4372
4372
  init_util2();
4373
4373
  ParseInputLazyPath = class {
4374
- constructor(parent, value, path7, key) {
4374
+ constructor(parent, value, path8, key) {
4375
4375
  this._cachedPath = [];
4376
4376
  this.parent = parent;
4377
4377
  this.data = value;
4378
- this._path = path7;
4378
+ this._path = path8;
4379
4379
  this._key = key;
4380
4380
  }
4381
4381
  get path() {
@@ -8198,10 +8198,10 @@ var init_vercel = __esm({
8198
8198
  name: "search",
8199
8199
  description: searchDescription,
8200
8200
  inputSchema: searchSchema,
8201
- execute: async ({ query: searchQuery, path: path7, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
8201
+ execute: async ({ query: searchQuery, path: path8, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
8202
8202
  try {
8203
8203
  const effectiveMaxTokens = paramMaxTokens || maxTokens;
8204
- let searchPath = path7 || options.defaultPath || ".";
8204
+ let searchPath = path8 || options.defaultPath || ".";
8205
8205
  if ((searchPath === "." || searchPath === "./") && options.defaultPath) {
8206
8206
  if (debug) {
8207
8207
  console.error(`Using default path "${options.defaultPath}" instead of "${searchPath}"`);
@@ -8241,9 +8241,9 @@ var init_vercel = __esm({
8241
8241
  name: "query",
8242
8242
  description: queryDescription,
8243
8243
  inputSchema: querySchema,
8244
- execute: async ({ pattern, path: path7, language, allow_tests }) => {
8244
+ execute: async ({ pattern, path: path8, language, allow_tests }) => {
8245
8245
  try {
8246
- let queryPath = path7 || options.defaultPath || ".";
8246
+ let queryPath = path8 || options.defaultPath || ".";
8247
8247
  if ((queryPath === "." || queryPath === "./") && options.defaultPath) {
8248
8248
  if (debug) {
8249
8249
  console.error(`Using default path "${options.defaultPath}" instead of "${queryPath}"`);
@@ -8353,7 +8353,7 @@ var init_vercel = __esm({
8353
8353
  name: "delegate",
8354
8354
  description: delegateDescription,
8355
8355
  inputSchema: delegateSchema,
8356
- execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path7, provider, model, tracer }) => {
8356
+ execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path8, provider, model, tracer }) => {
8357
8357
  if (!task || typeof task !== "string") {
8358
8358
  throw new Error("Task parameter is required and must be a non-empty string");
8359
8359
  }
@@ -8369,7 +8369,7 @@ var init_vercel = __esm({
8369
8369
  if (parentSessionId !== void 0 && parentSessionId !== null && typeof parentSessionId !== "string") {
8370
8370
  throw new TypeError("parentSessionId must be a string, null, or undefined");
8371
8371
  }
8372
- if (path7 !== void 0 && path7 !== null && typeof path7 !== "string") {
8372
+ if (path8 !== void 0 && path8 !== null && typeof path8 !== "string") {
8373
8373
  throw new TypeError("path must be a string, null, or undefined");
8374
8374
  }
8375
8375
  if (provider !== void 0 && provider !== null && typeof provider !== "string") {
@@ -8391,7 +8391,7 @@ var init_vercel = __esm({
8391
8391
  currentIteration: currentIteration || 0,
8392
8392
  maxIterations: maxIterations || 30,
8393
8393
  parentSessionId,
8394
- path: path7,
8394
+ path: path8,
8395
8395
  provider,
8396
8396
  model,
8397
8397
  tracer
@@ -14519,12 +14519,12 @@ var init_esm4 = __esm({
14519
14519
  /**
14520
14520
  * Get the Path object referenced by the string path, resolved from this Path
14521
14521
  */
14522
- resolve(path7) {
14523
- if (!path7) {
14522
+ resolve(path8) {
14523
+ if (!path8) {
14524
14524
  return this;
14525
14525
  }
14526
- const rootPath = this.getRootString(path7);
14527
- const dir = path7.substring(rootPath.length);
14526
+ const rootPath = this.getRootString(path8);
14527
+ const dir = path8.substring(rootPath.length);
14528
14528
  const dirParts = dir.split(this.splitSep);
14529
14529
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
14530
14530
  return result;
@@ -15276,8 +15276,8 @@ var init_esm4 = __esm({
15276
15276
  /**
15277
15277
  * @internal
15278
15278
  */
15279
- getRootString(path7) {
15280
- return win32.parse(path7).root;
15279
+ getRootString(path8) {
15280
+ return win32.parse(path8).root;
15281
15281
  }
15282
15282
  /**
15283
15283
  * @internal
@@ -15323,8 +15323,8 @@ var init_esm4 = __esm({
15323
15323
  /**
15324
15324
  * @internal
15325
15325
  */
15326
- getRootString(path7) {
15327
- return path7.startsWith("/") ? "/" : "";
15326
+ getRootString(path8) {
15327
+ return path8.startsWith("/") ? "/" : "";
15328
15328
  }
15329
15329
  /**
15330
15330
  * @internal
@@ -15373,8 +15373,8 @@ var init_esm4 = __esm({
15373
15373
  *
15374
15374
  * @internal
15375
15375
  */
15376
- constructor(cwd = process.cwd(), pathImpl, sep3, { nocase, childrenCacheSize = 16 * 1024, fs: fs7 = defaultFS } = {}) {
15377
- this.#fs = fsFromOption(fs7);
15376
+ constructor(cwd = process.cwd(), pathImpl, sep3, { nocase, childrenCacheSize = 16 * 1024, fs: fs8 = defaultFS } = {}) {
15377
+ this.#fs = fsFromOption(fs8);
15378
15378
  if (cwd instanceof URL || cwd.startsWith("file://")) {
15379
15379
  cwd = fileURLToPath4(cwd);
15380
15380
  }
@@ -15413,11 +15413,11 @@ var init_esm4 = __esm({
15413
15413
  /**
15414
15414
  * Get the depth of a provided path, string, or the cwd
15415
15415
  */
15416
- depth(path7 = this.cwd) {
15417
- if (typeof path7 === "string") {
15418
- path7 = this.cwd.resolve(path7);
15416
+ depth(path8 = this.cwd) {
15417
+ if (typeof path8 === "string") {
15418
+ path8 = this.cwd.resolve(path8);
15419
15419
  }
15420
- return path7.depth();
15420
+ return path8.depth();
15421
15421
  }
15422
15422
  /**
15423
15423
  * Return the cache of child entries. Exposed so subclasses can create
@@ -15904,9 +15904,9 @@ var init_esm4 = __esm({
15904
15904
  process2();
15905
15905
  return results;
15906
15906
  }
15907
- chdir(path7 = this.cwd) {
15907
+ chdir(path8 = this.cwd) {
15908
15908
  const oldCwd = this.cwd;
15909
- this.cwd = typeof path7 === "string" ? this.cwd.resolve(path7) : path7;
15909
+ this.cwd = typeof path8 === "string" ? this.cwd.resolve(path8) : path8;
15910
15910
  this.cwd[setAsCwd](oldCwd);
15911
15911
  }
15912
15912
  };
@@ -15932,8 +15932,8 @@ var init_esm4 = __esm({
15932
15932
  /**
15933
15933
  * @internal
15934
15934
  */
15935
- newRoot(fs7) {
15936
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
15935
+ newRoot(fs8) {
15936
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs8 });
15937
15937
  }
15938
15938
  /**
15939
15939
  * Return true if the provided path string is an absolute path
@@ -15961,8 +15961,8 @@ var init_esm4 = __esm({
15961
15961
  /**
15962
15962
  * @internal
15963
15963
  */
15964
- newRoot(fs7) {
15965
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs7 });
15964
+ newRoot(fs8) {
15965
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs8 });
15966
15966
  }
15967
15967
  /**
15968
15968
  * Return true if the provided path string is an absolute path
@@ -16281,8 +16281,8 @@ var init_processor = __esm({
16281
16281
  }
16282
16282
  // match, absolute, ifdir
16283
16283
  entries() {
16284
- return [...this.store.entries()].map(([path7, n]) => [
16285
- path7,
16284
+ return [...this.store.entries()].map(([path8, n]) => [
16285
+ path8,
16286
16286
  !!(n & 2),
16287
16287
  !!(n & 1)
16288
16288
  ]);
@@ -16495,9 +16495,9 @@ var init_walker = __esm({
16495
16495
  signal;
16496
16496
  maxDepth;
16497
16497
  includeChildMatches;
16498
- constructor(patterns, path7, opts) {
16498
+ constructor(patterns, path8, opts) {
16499
16499
  this.patterns = patterns;
16500
- this.path = path7;
16500
+ this.path = path8;
16501
16501
  this.opts = opts;
16502
16502
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
16503
16503
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -16516,11 +16516,11 @@ var init_walker = __esm({
16516
16516
  });
16517
16517
  }
16518
16518
  }
16519
- #ignored(path7) {
16520
- return this.seen.has(path7) || !!this.#ignore?.ignored?.(path7);
16519
+ #ignored(path8) {
16520
+ return this.seen.has(path8) || !!this.#ignore?.ignored?.(path8);
16521
16521
  }
16522
- #childrenIgnored(path7) {
16523
- return !!this.#ignore?.childrenIgnored?.(path7);
16522
+ #childrenIgnored(path8) {
16523
+ return !!this.#ignore?.childrenIgnored?.(path8);
16524
16524
  }
16525
16525
  // backpressure mechanism
16526
16526
  pause() {
@@ -16735,8 +16735,8 @@ var init_walker = __esm({
16735
16735
  };
16736
16736
  GlobWalker = class extends GlobUtil {
16737
16737
  matches = /* @__PURE__ */ new Set();
16738
- constructor(patterns, path7, opts) {
16739
- super(patterns, path7, opts);
16738
+ constructor(patterns, path8, opts) {
16739
+ super(patterns, path8, opts);
16740
16740
  }
16741
16741
  matchEmit(e) {
16742
16742
  this.matches.add(e);
@@ -16773,8 +16773,8 @@ var init_walker = __esm({
16773
16773
  };
16774
16774
  GlobStream = class extends GlobUtil {
16775
16775
  results;
16776
- constructor(patterns, path7, opts) {
16777
- super(patterns, path7, opts);
16776
+ constructor(patterns, path8, opts) {
16777
+ super(patterns, path8, opts);
16778
16778
  this.results = new Minipass({
16779
16779
  signal: this.signal,
16780
16780
  objectMode: true
@@ -17572,7 +17572,7 @@ function parseXmlToolCallWithThinking(xmlString, validTools) {
17572
17572
  }
17573
17573
  return parseXmlToolCall(cleanedXmlString, validTools);
17574
17574
  }
17575
- var implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition;
17575
+ var implementToolDefinition, listFilesToolDefinition, searchFilesToolDefinition, readImageToolDefinition;
17576
17576
  var init_tools2 = __esm({
17577
17577
  "src/agent/tools.js"() {
17578
17578
  "use strict";
@@ -17650,6 +17650,29 @@ User: Find all markdown files in the docs directory, but only at the top level.
17650
17650
  <recursive>false</recursive>
17651
17651
  </searchFiles>
17652
17652
 
17653
+ </examples>
17654
+ `;
17655
+ readImageToolDefinition = `
17656
+ ## readImage
17657
+ Description: Read and load an image file so it can be viewed by the AI. Use this when you need to analyze, describe, or work with image content. Images from user messages are automatically loaded, but use this tool to explicitly read images mentioned in tool outputs or when you need to examine specific image files.
17658
+
17659
+ Parameters:
17660
+ - path: (required) The path to the image file to read. Supports png, jpg, jpeg, webp, bmp, and svg formats.
17661
+
17662
+ Usage Example:
17663
+
17664
+ <examples>
17665
+
17666
+ User: Can you describe what's in screenshot.png?
17667
+ <readImage>
17668
+ <path>screenshot.png</path>
17669
+ </readImage>
17670
+
17671
+ User: Analyze the diagram in docs/architecture.svg
17672
+ <readImage>
17673
+ <path>docs/architecture.svg</path>
17674
+ </readImage>
17675
+
17653
17676
  </examples>
17654
17677
  `;
17655
17678
  }
@@ -19444,11 +19467,11 @@ var init_toKey = __esm({
19444
19467
  });
19445
19468
 
19446
19469
  // node_modules/lodash-es/_baseGet.js
19447
- function baseGet(object, path7) {
19448
- path7 = castPath_default(path7, object);
19449
- var index = 0, length = path7.length;
19470
+ function baseGet(object, path8) {
19471
+ path8 = castPath_default(path8, object);
19472
+ var index = 0, length = path8.length;
19450
19473
  while (object != null && index < length) {
19451
- object = object[toKey_default(path7[index++])];
19474
+ object = object[toKey_default(path8[index++])];
19452
19475
  }
19453
19476
  return index && index == length ? object : void 0;
19454
19477
  }
@@ -19462,8 +19485,8 @@ var init_baseGet = __esm({
19462
19485
  });
19463
19486
 
19464
19487
  // node_modules/lodash-es/get.js
19465
- function get(object, path7, defaultValue) {
19466
- var result = object == null ? void 0 : baseGet_default(object, path7);
19488
+ function get(object, path8, defaultValue) {
19489
+ var result = object == null ? void 0 : baseGet_default(object, path8);
19467
19490
  return result === void 0 ? defaultValue : result;
19468
19491
  }
19469
19492
  var get_default;
@@ -20826,11 +20849,11 @@ var init_baseHasIn = __esm({
20826
20849
  });
20827
20850
 
20828
20851
  // node_modules/lodash-es/_hasPath.js
20829
- function hasPath(object, path7, hasFunc) {
20830
- path7 = castPath_default(path7, object);
20831
- var index = -1, length = path7.length, result = false;
20852
+ function hasPath(object, path8, hasFunc) {
20853
+ path8 = castPath_default(path8, object);
20854
+ var index = -1, length = path8.length, result = false;
20832
20855
  while (++index < length) {
20833
- var key = toKey_default(path7[index]);
20856
+ var key = toKey_default(path8[index]);
20834
20857
  if (!(result = object != null && hasFunc(object, key))) {
20835
20858
  break;
20836
20859
  }
@@ -20856,8 +20879,8 @@ var init_hasPath = __esm({
20856
20879
  });
20857
20880
 
20858
20881
  // node_modules/lodash-es/hasIn.js
20859
- function hasIn(object, path7) {
20860
- return object != null && hasPath_default(object, path7, baseHasIn_default);
20882
+ function hasIn(object, path8) {
20883
+ return object != null && hasPath_default(object, path8, baseHasIn_default);
20861
20884
  }
20862
20885
  var hasIn_default;
20863
20886
  var init_hasIn = __esm({
@@ -20869,13 +20892,13 @@ var init_hasIn = __esm({
20869
20892
  });
20870
20893
 
20871
20894
  // node_modules/lodash-es/_baseMatchesProperty.js
20872
- function baseMatchesProperty(path7, srcValue) {
20873
- if (isKey_default(path7) && isStrictComparable_default(srcValue)) {
20874
- return matchesStrictComparable_default(toKey_default(path7), srcValue);
20895
+ function baseMatchesProperty(path8, srcValue) {
20896
+ if (isKey_default(path8) && isStrictComparable_default(srcValue)) {
20897
+ return matchesStrictComparable_default(toKey_default(path8), srcValue);
20875
20898
  }
20876
20899
  return function(object) {
20877
- var objValue = get_default(object, path7);
20878
- return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path7) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
20900
+ var objValue = get_default(object, path8);
20901
+ return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path8) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
20879
20902
  };
20880
20903
  }
20881
20904
  var COMPARE_PARTIAL_FLAG6, COMPARE_UNORDERED_FLAG4, baseMatchesProperty_default;
@@ -20908,9 +20931,9 @@ var init_baseProperty = __esm({
20908
20931
  });
20909
20932
 
20910
20933
  // node_modules/lodash-es/_basePropertyDeep.js
20911
- function basePropertyDeep(path7) {
20934
+ function basePropertyDeep(path8) {
20912
20935
  return function(object) {
20913
- return baseGet_default(object, path7);
20936
+ return baseGet_default(object, path8);
20914
20937
  };
20915
20938
  }
20916
20939
  var basePropertyDeep_default;
@@ -20922,8 +20945,8 @@ var init_basePropertyDeep = __esm({
20922
20945
  });
20923
20946
 
20924
20947
  // node_modules/lodash-es/property.js
20925
- function property(path7) {
20926
- return isKey_default(path7) ? baseProperty_default(toKey_default(path7)) : basePropertyDeep_default(path7);
20948
+ function property(path8) {
20949
+ return isKey_default(path8) ? baseProperty_default(toKey_default(path8)) : basePropertyDeep_default(path8);
20927
20950
  }
20928
20951
  var property_default;
20929
20952
  var init_property = __esm({
@@ -21542,8 +21565,8 @@ var init_baseHas = __esm({
21542
21565
  });
21543
21566
 
21544
21567
  // node_modules/lodash-es/has.js
21545
- function has(object, path7) {
21546
- return object != null && hasPath_default(object, path7, baseHas_default);
21568
+ function has(object, path8) {
21569
+ return object != null && hasPath_default(object, path8, baseHas_default);
21547
21570
  }
21548
21571
  var has_default;
21549
21572
  var init_has = __esm({
@@ -21749,14 +21772,14 @@ var init_negate = __esm({
21749
21772
  });
21750
21773
 
21751
21774
  // node_modules/lodash-es/_baseSet.js
21752
- function baseSet(object, path7, value, customizer) {
21775
+ function baseSet(object, path8, value, customizer) {
21753
21776
  if (!isObject_default(object)) {
21754
21777
  return object;
21755
21778
  }
21756
- path7 = castPath_default(path7, object);
21757
- var index = -1, length = path7.length, lastIndex = length - 1, nested = object;
21779
+ path8 = castPath_default(path8, object);
21780
+ var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
21758
21781
  while (nested != null && ++index < length) {
21759
- var key = toKey_default(path7[index]), newValue = value;
21782
+ var key = toKey_default(path8[index]), newValue = value;
21760
21783
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
21761
21784
  return object;
21762
21785
  }
@@ -21764,7 +21787,7 @@ function baseSet(object, path7, value, customizer) {
21764
21787
  var objValue = nested[key];
21765
21788
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
21766
21789
  if (newValue === void 0) {
21767
- newValue = isObject_default(objValue) ? objValue : isIndex_default(path7[index + 1]) ? [] : {};
21790
+ newValue = isObject_default(objValue) ? objValue : isIndex_default(path8[index + 1]) ? [] : {};
21768
21791
  }
21769
21792
  }
21770
21793
  assignValue_default(nested, key, newValue);
@@ -21788,9 +21811,9 @@ var init_baseSet = __esm({
21788
21811
  function basePickBy(object, paths, predicate) {
21789
21812
  var index = -1, length = paths.length, result = {};
21790
21813
  while (++index < length) {
21791
- var path7 = paths[index], value = baseGet_default(object, path7);
21792
- if (predicate(value, path7)) {
21793
- baseSet_default(result, castPath_default(path7, object), value);
21814
+ var path8 = paths[index], value = baseGet_default(object, path8);
21815
+ if (predicate(value, path8)) {
21816
+ baseSet_default(result, castPath_default(path8, object), value);
21794
21817
  }
21795
21818
  }
21796
21819
  return result;
@@ -21814,8 +21837,8 @@ function pickBy(object, predicate) {
21814
21837
  return [prop];
21815
21838
  });
21816
21839
  predicate = baseIteratee_default(predicate);
21817
- return basePickBy_default(object, props, function(value, path7) {
21818
- return predicate(value, path7[0]);
21840
+ return basePickBy_default(object, props, function(value, path8) {
21841
+ return predicate(value, path8[0]);
21819
21842
  });
21820
21843
  }
21821
21844
  var pickBy_default;
@@ -24528,12 +24551,12 @@ function assignCategoriesMapProp(tokenTypes) {
24528
24551
  singleAssignCategoriesToksMap([], currTokType);
24529
24552
  });
24530
24553
  }
24531
- function singleAssignCategoriesToksMap(path7, nextNode) {
24532
- forEach_default(path7, (pathNode) => {
24554
+ function singleAssignCategoriesToksMap(path8, nextNode) {
24555
+ forEach_default(path8, (pathNode) => {
24533
24556
  nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;
24534
24557
  });
24535
24558
  forEach_default(nextNode.CATEGORIES, (nextCategory) => {
24536
- const newPath = path7.concat(nextNode);
24559
+ const newPath = path8.concat(nextNode);
24537
24560
  if (!includes_default(newPath, nextCategory)) {
24538
24561
  singleAssignCategoriesToksMap(newPath, nextCategory);
24539
24562
  }
@@ -25703,10 +25726,10 @@ var init_interpreter = __esm({
25703
25726
  init_rest();
25704
25727
  init_api2();
25705
25728
  AbstractNextPossibleTokensWalker = class extends RestWalker {
25706
- constructor(topProd, path7) {
25729
+ constructor(topProd, path8) {
25707
25730
  super();
25708
25731
  this.topProd = topProd;
25709
- this.path = path7;
25732
+ this.path = path8;
25710
25733
  this.possibleTokTypes = [];
25711
25734
  this.nextProductionName = "";
25712
25735
  this.nextProductionOccurrence = 0;
@@ -25750,9 +25773,9 @@ var init_interpreter = __esm({
25750
25773
  }
25751
25774
  };
25752
25775
  NextAfterTokenWalker = class extends AbstractNextPossibleTokensWalker {
25753
- constructor(topProd, path7) {
25754
- super(topProd, path7);
25755
- this.path = path7;
25776
+ constructor(topProd, path8) {
25777
+ super(topProd, path8);
25778
+ this.path = path8;
25756
25779
  this.nextTerminalName = "";
25757
25780
  this.nextTerminalOccurrence = 0;
25758
25781
  this.nextTerminalName = this.path.lastTok.name;
@@ -25993,10 +26016,10 @@ function initializeArrayOfArrays(size) {
25993
26016
  }
25994
26017
  return result;
25995
26018
  }
25996
- function pathToHashKeys(path7) {
26019
+ function pathToHashKeys(path8) {
25997
26020
  let keys2 = [""];
25998
- for (let i = 0; i < path7.length; i++) {
25999
- const tokType = path7[i];
26021
+ for (let i = 0; i < path8.length; i++) {
26022
+ const tokType = path8[i];
26000
26023
  const longerKeys = [];
26001
26024
  for (let j = 0; j < keys2.length; j++) {
26002
26025
  const currShorterKey = keys2[j];
@@ -26299,7 +26322,7 @@ function validateRuleIsOverridden(ruleName, definedRulesNames, className) {
26299
26322
  }
26300
26323
  return errors;
26301
26324
  }
26302
- function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path7 = []) {
26325
+ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = []) {
26303
26326
  const errors = [];
26304
26327
  const nextNonTerminals = getFirstNoneTerminal(currRule.definition);
26305
26328
  if (isEmpty_default(nextNonTerminals)) {
@@ -26311,15 +26334,15 @@ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path7 = [])
26311
26334
  errors.push({
26312
26335
  message: errMsgProvider.buildLeftRecursionError({
26313
26336
  topLevelRule: topRule,
26314
- leftRecursionPath: path7
26337
+ leftRecursionPath: path8
26315
26338
  }),
26316
26339
  type: ParserDefinitionErrorType.LEFT_RECURSION,
26317
26340
  ruleName
26318
26341
  });
26319
26342
  }
26320
- const validNextSteps = difference_default(nextNonTerminals, path7.concat([topRule]));
26343
+ const validNextSteps = difference_default(nextNonTerminals, path8.concat([topRule]));
26321
26344
  const errorsFromNextSteps = flatMap_default(validNextSteps, (currRefRule) => {
26322
- const newPath = clone_default(path7);
26345
+ const newPath = clone_default(path8);
26323
26346
  newPath.push(currRefRule);
26324
26347
  return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);
26325
26348
  });
@@ -38916,11 +38939,11 @@ var require_baseGet = __commonJS({
38916
38939
  "node_modules/lodash/_baseGet.js"(exports2, module2) {
38917
38940
  var castPath2 = require_castPath();
38918
38941
  var toKey2 = require_toKey();
38919
- function baseGet2(object, path7) {
38920
- path7 = castPath2(path7, object);
38921
- var index = 0, length = path7.length;
38942
+ function baseGet2(object, path8) {
38943
+ path8 = castPath2(path8, object);
38944
+ var index = 0, length = path8.length;
38922
38945
  while (object != null && index < length) {
38923
- object = object[toKey2(path7[index++])];
38946
+ object = object[toKey2(path8[index++])];
38924
38947
  }
38925
38948
  return index && index == length ? object : void 0;
38926
38949
  }
@@ -38932,8 +38955,8 @@ var require_baseGet = __commonJS({
38932
38955
  var require_get = __commonJS({
38933
38956
  "node_modules/lodash/get.js"(exports2, module2) {
38934
38957
  var baseGet2 = require_baseGet();
38935
- function get2(object, path7, defaultValue) {
38936
- var result = object == null ? void 0 : baseGet2(object, path7);
38958
+ function get2(object, path8, defaultValue) {
38959
+ var result = object == null ? void 0 : baseGet2(object, path8);
38937
38960
  return result === void 0 ? defaultValue : result;
38938
38961
  }
38939
38962
  module2.exports = get2;
@@ -38959,11 +38982,11 @@ var require_hasPath = __commonJS({
38959
38982
  var isIndex2 = require_isIndex();
38960
38983
  var isLength2 = require_isLength();
38961
38984
  var toKey2 = require_toKey();
38962
- function hasPath2(object, path7, hasFunc) {
38963
- path7 = castPath2(path7, object);
38964
- var index = -1, length = path7.length, result = false;
38985
+ function hasPath2(object, path8, hasFunc) {
38986
+ path8 = castPath2(path8, object);
38987
+ var index = -1, length = path8.length, result = false;
38965
38988
  while (++index < length) {
38966
- var key = toKey2(path7[index]);
38989
+ var key = toKey2(path8[index]);
38967
38990
  if (!(result = object != null && hasFunc(object, key))) {
38968
38991
  break;
38969
38992
  }
@@ -38984,8 +39007,8 @@ var require_hasIn = __commonJS({
38984
39007
  "node_modules/lodash/hasIn.js"(exports2, module2) {
38985
39008
  var baseHasIn2 = require_baseHasIn();
38986
39009
  var hasPath2 = require_hasPath();
38987
- function hasIn2(object, path7) {
38988
- return object != null && hasPath2(object, path7, baseHasIn2);
39010
+ function hasIn2(object, path8) {
39011
+ return object != null && hasPath2(object, path8, baseHasIn2);
38989
39012
  }
38990
39013
  module2.exports = hasIn2;
38991
39014
  }
@@ -39003,13 +39026,13 @@ var require_baseMatchesProperty = __commonJS({
39003
39026
  var toKey2 = require_toKey();
39004
39027
  var COMPARE_PARTIAL_FLAG7 = 1;
39005
39028
  var COMPARE_UNORDERED_FLAG5 = 2;
39006
- function baseMatchesProperty2(path7, srcValue) {
39007
- if (isKey2(path7) && isStrictComparable2(srcValue)) {
39008
- return matchesStrictComparable2(toKey2(path7), srcValue);
39029
+ function baseMatchesProperty2(path8, srcValue) {
39030
+ if (isKey2(path8) && isStrictComparable2(srcValue)) {
39031
+ return matchesStrictComparable2(toKey2(path8), srcValue);
39009
39032
  }
39010
39033
  return function(object) {
39011
- var objValue = get2(object, path7);
39012
- return objValue === void 0 && objValue === srcValue ? hasIn2(object, path7) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
39034
+ var objValue = get2(object, path8);
39035
+ return objValue === void 0 && objValue === srcValue ? hasIn2(object, path8) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
39013
39036
  };
39014
39037
  }
39015
39038
  module2.exports = baseMatchesProperty2;
@@ -39032,9 +39055,9 @@ var require_baseProperty = __commonJS({
39032
39055
  var require_basePropertyDeep = __commonJS({
39033
39056
  "node_modules/lodash/_basePropertyDeep.js"(exports2, module2) {
39034
39057
  var baseGet2 = require_baseGet();
39035
- function basePropertyDeep2(path7) {
39058
+ function basePropertyDeep2(path8) {
39036
39059
  return function(object) {
39037
- return baseGet2(object, path7);
39060
+ return baseGet2(object, path8);
39038
39061
  };
39039
39062
  }
39040
39063
  module2.exports = basePropertyDeep2;
@@ -39048,8 +39071,8 @@ var require_property = __commonJS({
39048
39071
  var basePropertyDeep2 = require_basePropertyDeep();
39049
39072
  var isKey2 = require_isKey();
39050
39073
  var toKey2 = require_toKey();
39051
- function property2(path7) {
39052
- return isKey2(path7) ? baseProperty2(toKey2(path7)) : basePropertyDeep2(path7);
39074
+ function property2(path8) {
39075
+ return isKey2(path8) ? baseProperty2(toKey2(path8)) : basePropertyDeep2(path8);
39053
39076
  }
39054
39077
  module2.exports = property2;
39055
39078
  }
@@ -39111,8 +39134,8 @@ var require_has = __commonJS({
39111
39134
  "node_modules/lodash/has.js"(exports2, module2) {
39112
39135
  var baseHas2 = require_baseHas();
39113
39136
  var hasPath2 = require_hasPath();
39114
- function has2(object, path7) {
39115
- return object != null && hasPath2(object, path7, baseHas2);
39137
+ function has2(object, path8) {
39138
+ return object != null && hasPath2(object, path8, baseHas2);
39116
39139
  }
39117
39140
  module2.exports = has2;
39118
39141
  }
@@ -41386,14 +41409,14 @@ var require_baseSet = __commonJS({
41386
41409
  var isIndex2 = require_isIndex();
41387
41410
  var isObject2 = require_isObject();
41388
41411
  var toKey2 = require_toKey();
41389
- function baseSet2(object, path7, value, customizer) {
41412
+ function baseSet2(object, path8, value, customizer) {
41390
41413
  if (!isObject2(object)) {
41391
41414
  return object;
41392
41415
  }
41393
- path7 = castPath2(path7, object);
41394
- var index = -1, length = path7.length, lastIndex = length - 1, nested = object;
41416
+ path8 = castPath2(path8, object);
41417
+ var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
41395
41418
  while (nested != null && ++index < length) {
41396
- var key = toKey2(path7[index]), newValue = value;
41419
+ var key = toKey2(path8[index]), newValue = value;
41397
41420
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
41398
41421
  return object;
41399
41422
  }
@@ -41401,7 +41424,7 @@ var require_baseSet = __commonJS({
41401
41424
  var objValue = nested[key];
41402
41425
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
41403
41426
  if (newValue === void 0) {
41404
- newValue = isObject2(objValue) ? objValue : isIndex2(path7[index + 1]) ? [] : {};
41427
+ newValue = isObject2(objValue) ? objValue : isIndex2(path8[index + 1]) ? [] : {};
41405
41428
  }
41406
41429
  }
41407
41430
  assignValue2(nested, key, newValue);
@@ -41422,9 +41445,9 @@ var require_basePickBy = __commonJS({
41422
41445
  function basePickBy2(object, paths, predicate) {
41423
41446
  var index = -1, length = paths.length, result = {};
41424
41447
  while (++index < length) {
41425
- var path7 = paths[index], value = baseGet2(object, path7);
41426
- if (predicate(value, path7)) {
41427
- baseSet2(result, castPath2(path7, object), value);
41448
+ var path8 = paths[index], value = baseGet2(object, path8);
41449
+ if (predicate(value, path8)) {
41450
+ baseSet2(result, castPath2(path8, object), value);
41428
41451
  }
41429
41452
  }
41430
41453
  return result;
@@ -41439,8 +41462,8 @@ var require_basePick = __commonJS({
41439
41462
  var basePickBy2 = require_basePickBy();
41440
41463
  var hasIn2 = require_hasIn();
41441
41464
  function basePick(object, paths) {
41442
- return basePickBy2(object, paths, function(value, path7) {
41443
- return hasIn2(object, path7);
41465
+ return basePickBy2(object, paths, function(value, path8) {
41466
+ return hasIn2(object, path8);
41444
41467
  });
41445
41468
  }
41446
41469
  module2.exports = basePick;
@@ -42494,15 +42517,15 @@ var require_parent_dummy_chains = __commonJS({
42494
42517
  var node = g.node(v);
42495
42518
  var edgeObj = node.edgeObj;
42496
42519
  var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w);
42497
- var path7 = pathData.path;
42520
+ var path8 = pathData.path;
42498
42521
  var lca = pathData.lca;
42499
42522
  var pathIdx = 0;
42500
- var pathV = path7[pathIdx];
42523
+ var pathV = path8[pathIdx];
42501
42524
  var ascending = true;
42502
42525
  while (v !== edgeObj.w) {
42503
42526
  node = g.node(v);
42504
42527
  if (ascending) {
42505
- while ((pathV = path7[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) {
42528
+ while ((pathV = path8[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) {
42506
42529
  pathIdx++;
42507
42530
  }
42508
42531
  if (pathV === lca) {
@@ -42510,10 +42533,10 @@ var require_parent_dummy_chains = __commonJS({
42510
42533
  }
42511
42534
  }
42512
42535
  if (!ascending) {
42513
- while (pathIdx < path7.length - 1 && g.node(pathV = path7[pathIdx + 1]).minRank <= node.rank) {
42536
+ while (pathIdx < path8.length - 1 && g.node(pathV = path8[pathIdx + 1]).minRank <= node.rank) {
42514
42537
  pathIdx++;
42515
42538
  }
42516
- pathV = path7[pathIdx];
42539
+ pathV = path8[pathIdx];
42517
42540
  }
42518
42541
  g.setParent(v, pathV);
42519
42542
  v = g.successors(v)[0];
@@ -44686,8 +44709,8 @@ var init_svg_generator = __esm({
44686
44709
  elements.push(this.generateNodeWithPad(node, padX, padY));
44687
44710
  }
44688
44711
  for (const edge of layout.edges) {
44689
- const { path: path7, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
44690
- elements.push(path7);
44712
+ const { path: path8, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
44713
+ elements.push(path8);
44691
44714
  if (overlay)
44692
44715
  overlays.push(overlay);
44693
44716
  }
@@ -51003,8 +51026,8 @@ var require_utils = __commonJS({
51003
51026
  }
51004
51027
  return ind;
51005
51028
  }
51006
- function removeDotSegments(path7) {
51007
- let input = path7;
51029
+ function removeDotSegments(path8) {
51030
+ let input = path8;
51008
51031
  const output = [];
51009
51032
  let nextSlash = -1;
51010
51033
  let len = 0;
@@ -51203,8 +51226,8 @@ var require_schemes = __commonJS({
51203
51226
  wsComponent.secure = void 0;
51204
51227
  }
51205
51228
  if (wsComponent.resourceName) {
51206
- const [path7, query2] = wsComponent.resourceName.split("?");
51207
- wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
51229
+ const [path8, query2] = wsComponent.resourceName.split("?");
51230
+ wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
51208
51231
  wsComponent.query = query2;
51209
51232
  wsComponent.resourceName = void 0;
51210
51233
  }
@@ -54547,7 +54570,7 @@ function validateJsonResponse(response, options = {}) {
54547
54570
  }
54548
54571
  if (!valid) {
54549
54572
  const formattedErrors = validate2.errors.map((err) => {
54550
- const path7 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
54573
+ const path8 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
54551
54574
  let message = "";
54552
54575
  let suggestion = "";
54553
54576
  if (err.keyword === "additionalProperties") {
@@ -54585,7 +54608,7 @@ function validateJsonResponse(response, options = {}) {
54585
54608
  message = err.message;
54586
54609
  suggestion = "";
54587
54610
  }
54588
- const location = path7 ? `at '${path7}'` : "at root";
54611
+ const location = path8 ? `at '${path8}'` : "at root";
54589
54612
  return suggestion ? `${location}: ${message} \u2192 ${suggestion}` : `${location}: ${message}`;
54590
54613
  });
54591
54614
  const errorSummary = formattedErrors.join("\n ");
@@ -54908,7 +54931,7 @@ function extractMermaidFromJson(response) {
54908
54931
  }
54909
54932
  const diagrams = [];
54910
54933
  const jsonPaths = [];
54911
- function searchObject(obj, path7 = []) {
54934
+ function searchObject(obj, path8 = []) {
54912
54935
  if (typeof obj === "string") {
54913
54936
  const mermaidPattern = /```mermaid([^\n`]*?)(?:\n|\\n)([\s\S]*?)```/gi;
54914
54937
  let match2;
@@ -54922,14 +54945,14 @@ function extractMermaidFromJson(response) {
54922
54945
  endIndex: match2.index + match2[0].length,
54923
54946
  attributes,
54924
54947
  isInJson: true,
54925
- jsonPath: path7.join(".")
54948
+ jsonPath: path8.join(".")
54926
54949
  });
54927
- jsonPaths.push(path7.join("."));
54950
+ jsonPaths.push(path8.join("."));
54928
54951
  }
54929
54952
  } else if (Array.isArray(obj)) {
54930
- obj.forEach((item, index) => searchObject(item, [...path7, `[${index}]`]));
54953
+ obj.forEach((item, index) => searchObject(item, [...path8, `[${index}]`]));
54931
54954
  } else if (obj && typeof obj === "object") {
54932
- Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path7, key]));
54955
+ Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path8, key]));
54933
54956
  }
54934
54957
  }
54935
54958
  searchObject(parsedJson);
@@ -55186,7 +55209,7 @@ async function tryMaidAutoFix(diagramContent, options = {}) {
55186
55209
  }
55187
55210
  }
55188
55211
  async function validateAndFixMermaidResponse(response, options = {}) {
55189
- const { schema, debug, path: path7, provider, model, tracer } = options;
55212
+ const { schema, debug, path: path8, provider, model, tracer } = options;
55190
55213
  const startTime = Date.now();
55191
55214
  if (debug) {
55192
55215
  console.log(`[DEBUG] Mermaid validation: Starting maid-based validation for response (${response.length} chars)`);
@@ -55343,7 +55366,7 @@ ${maidResult.fixed}
55343
55366
  }
55344
55367
  const aiFixingStart = Date.now();
55345
55368
  const mermaidFixer = new MermaidFixingAgent({
55346
- path: path7,
55369
+ path: path8,
55347
55370
  provider,
55348
55371
  model,
55349
55372
  debug,
@@ -55585,8 +55608,8 @@ Schema Validation Errors:
55585
55608
  ${validationResult.errorSummary}`;
55586
55609
  } else if (validationResult.schemaErrors && validationResult.schemaErrors.length > 0) {
55587
55610
  const errors = validationResult.schemaErrors.map((err) => {
55588
- const path7 = err.instancePath || "(root)";
55589
- return ` ${path7}: ${err.message}`;
55611
+ const path8 = err.instancePath || "(root)";
55612
+ return ` ${path8}: ${err.message}`;
55590
55613
  }).join("\n");
55591
55614
  schemaErrorDetails = `
55592
55615
 
@@ -57357,6 +57380,909 @@ var init_contextCompactor = __esm({
57357
57380
  }
57358
57381
  });
57359
57382
 
57383
+ // src/agent/mcp/built-in-server.js
57384
+ import { createServer } from "http";
57385
+ import { EventEmitter as EventEmitter3 } from "events";
57386
+ import { Server as MCPServer } from "@modelcontextprotocol/sdk/server/index.js";
57387
+ import {
57388
+ CallToolRequestSchema,
57389
+ ListToolsRequestSchema
57390
+ } from "@modelcontextprotocol/sdk/types.js";
57391
+ var BuiltInMCPServer;
57392
+ var init_built_in_server = __esm({
57393
+ "src/agent/mcp/built-in-server.js"() {
57394
+ "use strict";
57395
+ BuiltInMCPServer = class extends EventEmitter3 {
57396
+ constructor(agent, options = {}) {
57397
+ super();
57398
+ this.agent = agent;
57399
+ this.port = options.port || 0;
57400
+ this.host = options.host || "127.0.0.1";
57401
+ this.httpServer = null;
57402
+ this.mcpServer = null;
57403
+ this.connections = /* @__PURE__ */ new Set();
57404
+ this.debug = options.debug || false;
57405
+ }
57406
+ /**
57407
+ * Start the built-in MCP server
57408
+ */
57409
+ async start() {
57410
+ this.httpServer = createServer();
57411
+ this.httpServer.on("request", (req, res) => {
57412
+ this.handleRequest(req, res);
57413
+ });
57414
+ this.mcpServer = new MCPServer({
57415
+ name: "probe-builtin",
57416
+ version: "1.0.0"
57417
+ }, {
57418
+ capabilities: {
57419
+ tools: {}
57420
+ }
57421
+ });
57422
+ this.registerHandlers();
57423
+ return new Promise((resolve6, reject2) => {
57424
+ this.httpServer.listen(this.port, this.host, () => {
57425
+ const address = this.httpServer.address();
57426
+ this.port = address.port;
57427
+ if (this.debug) {
57428
+ console.log(`[MCP] Built-in server started at http://${this.host}:${this.port}`);
57429
+ }
57430
+ this.emit("ready", { host: this.host, port: this.port });
57431
+ resolve6({ host: this.host, port: this.port });
57432
+ });
57433
+ this.httpServer.on("error", reject2);
57434
+ });
57435
+ }
57436
+ /**
57437
+ * Handle HTTP requests (SSE and JSON-RPC)
57438
+ */
57439
+ handleRequest(req, res) {
57440
+ const { method, url } = req;
57441
+ res.setHeader("Access-Control-Allow-Origin", "*");
57442
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
57443
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
57444
+ if (method === "OPTIONS") {
57445
+ res.writeHead(204);
57446
+ res.end();
57447
+ return;
57448
+ }
57449
+ if (url === "/sse" && method === "GET") {
57450
+ this.handleSSE(req, res);
57451
+ return;
57452
+ }
57453
+ if (url === "/rpc" && method === "POST") {
57454
+ this.handleJSONRPC(req, res);
57455
+ return;
57456
+ }
57457
+ if (url === "/mcp" && method === "POST") {
57458
+ this.handleMCPProtocol(req, res);
57459
+ return;
57460
+ }
57461
+ if (url === "/health") {
57462
+ res.writeHead(200, { "Content-Type": "application/json" });
57463
+ res.end(JSON.stringify({
57464
+ status: "ok",
57465
+ server: "probe-builtin-mcp",
57466
+ tools: this.getToolCount()
57467
+ }));
57468
+ return;
57469
+ }
57470
+ res.writeHead(404);
57471
+ res.end("Not Found");
57472
+ }
57473
+ /**
57474
+ * Handle Server-Sent Events connection
57475
+ */
57476
+ handleSSE(req, res) {
57477
+ res.writeHead(200, {
57478
+ "Content-Type": "text/event-stream",
57479
+ "Cache-Control": "no-cache",
57480
+ "Connection": "keep-alive"
57481
+ });
57482
+ res.write("event: connected\n");
57483
+ res.write(`data: ${JSON.stringify({ type: "connected", server: "probe-builtin" })}
57484
+
57485
+ `);
57486
+ this.connections.add(res);
57487
+ req.on("close", () => {
57488
+ this.connections.delete(res);
57489
+ });
57490
+ }
57491
+ /**
57492
+ * Handle JSON-RPC requests
57493
+ */
57494
+ async handleJSONRPC(req, res) {
57495
+ let body = "";
57496
+ req.on("data", (chunk) => {
57497
+ body += chunk.toString();
57498
+ });
57499
+ req.on("end", async () => {
57500
+ try {
57501
+ const request = JSON.parse(body);
57502
+ const response = await this.processRequest(request);
57503
+ res.writeHead(200, { "Content-Type": "application/json" });
57504
+ res.end(JSON.stringify(response));
57505
+ } catch (error) {
57506
+ res.writeHead(400, { "Content-Type": "application/json" });
57507
+ res.end(JSON.stringify({
57508
+ jsonrpc: "2.0",
57509
+ error: {
57510
+ code: -32700,
57511
+ message: "Parse error",
57512
+ data: error.message
57513
+ },
57514
+ id: null
57515
+ }));
57516
+ }
57517
+ });
57518
+ }
57519
+ /**
57520
+ * Handle MCP protocol messages
57521
+ */
57522
+ async handleMCPProtocol(req, res) {
57523
+ let body = "";
57524
+ req.on("data", (chunk) => {
57525
+ body += chunk.toString();
57526
+ });
57527
+ req.on("end", async () => {
57528
+ try {
57529
+ const message = JSON.parse(body);
57530
+ let response;
57531
+ if (message.method === "tools/list") {
57532
+ response = await this.handleListTools();
57533
+ } else if (message.method === "tools/call") {
57534
+ response = await this.handleCallTool(message.params);
57535
+ } else {
57536
+ response = {
57537
+ error: {
57538
+ code: -32601,
57539
+ message: "Method not found"
57540
+ }
57541
+ };
57542
+ }
57543
+ res.writeHead(200, { "Content-Type": "application/json" });
57544
+ res.end(JSON.stringify(response));
57545
+ } catch (error) {
57546
+ res.writeHead(500, { "Content-Type": "application/json" });
57547
+ res.end(JSON.stringify({
57548
+ error: {
57549
+ code: -32603,
57550
+ message: "Internal error",
57551
+ data: error.message
57552
+ }
57553
+ }));
57554
+ }
57555
+ });
57556
+ }
57557
+ /**
57558
+ * Process JSON-RPC request
57559
+ */
57560
+ async processRequest(request) {
57561
+ const { jsonrpc, method, params, id } = request;
57562
+ try {
57563
+ let result;
57564
+ switch (method) {
57565
+ case "tools/list":
57566
+ result = await this.handleListTools();
57567
+ break;
57568
+ case "tools/call":
57569
+ result = await this.handleCallTool(params);
57570
+ break;
57571
+ default:
57572
+ return {
57573
+ jsonrpc: "2.0",
57574
+ error: {
57575
+ code: -32601,
57576
+ message: "Method not found"
57577
+ },
57578
+ id
57579
+ };
57580
+ }
57581
+ return {
57582
+ jsonrpc: "2.0",
57583
+ result,
57584
+ id
57585
+ };
57586
+ } catch (error) {
57587
+ return {
57588
+ jsonrpc: "2.0",
57589
+ error: {
57590
+ code: -32603,
57591
+ message: "Internal error",
57592
+ data: error.message
57593
+ },
57594
+ id
57595
+ };
57596
+ }
57597
+ }
57598
+ /**
57599
+ * Register MCP protocol handlers
57600
+ */
57601
+ registerHandlers() {
57602
+ this.mcpServer.setRequestHandler(ListToolsRequestSchema, async () => {
57603
+ return this.handleListTools();
57604
+ });
57605
+ this.mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
57606
+ return this.handleCallTool(request.params);
57607
+ });
57608
+ }
57609
+ /**
57610
+ * Handle list tools request
57611
+ */
57612
+ async handleListTools() {
57613
+ const tools2 = [];
57614
+ if (this.agent && this.agent.allowedTools) {
57615
+ const toolDefs = {
57616
+ search: {
57617
+ description: "Search for code patterns using semantic search",
57618
+ inputSchema: {
57619
+ type: "object",
57620
+ properties: {
57621
+ query: { type: "string", description: "Search query" },
57622
+ path: { type: "string", description: "Directory to search", default: "." },
57623
+ maxResults: { type: "integer", default: 10 }
57624
+ },
57625
+ required: ["query"]
57626
+ }
57627
+ },
57628
+ extract: {
57629
+ description: "Extract code from specific file location",
57630
+ inputSchema: {
57631
+ type: "object",
57632
+ properties: {
57633
+ path: { type: "string", description: "File path with optional line number" }
57634
+ },
57635
+ required: ["path"]
57636
+ }
57637
+ },
57638
+ listFiles: {
57639
+ description: "List files in a directory",
57640
+ inputSchema: {
57641
+ type: "object",
57642
+ properties: {
57643
+ path: { type: "string", description: "Directory path" },
57644
+ pattern: { type: "string", description: "File pattern" }
57645
+ },
57646
+ required: ["path"]
57647
+ }
57648
+ },
57649
+ searchFiles: {
57650
+ description: "Search for files by name pattern",
57651
+ inputSchema: {
57652
+ type: "object",
57653
+ properties: {
57654
+ pattern: { type: "string", description: "File name pattern" },
57655
+ path: { type: "string", description: "Directory to search" }
57656
+ },
57657
+ required: ["pattern"]
57658
+ }
57659
+ },
57660
+ query: {
57661
+ description: "Query code using AST patterns",
57662
+ inputSchema: {
57663
+ type: "object",
57664
+ properties: {
57665
+ query: { type: "string", description: "AST query" },
57666
+ path: { type: "string", description: "Directory to search" }
57667
+ },
57668
+ required: ["query"]
57669
+ }
57670
+ }
57671
+ };
57672
+ for (const [name, def] of Object.entries(toolDefs)) {
57673
+ if (this.agent.allowedTools.isEnabled(name)) {
57674
+ tools2.push({
57675
+ name: `mcp__probe__${name}`,
57676
+ description: def.description,
57677
+ inputSchema: def.inputSchema
57678
+ });
57679
+ }
57680
+ }
57681
+ }
57682
+ return { tools: tools2 };
57683
+ }
57684
+ /**
57685
+ * Handle tool execution
57686
+ */
57687
+ async handleCallTool(params) {
57688
+ const { name, arguments: args } = params;
57689
+ const toolName = name.replace("mcp__probe__", "");
57690
+ if (!this.agent.allowedTools.isEnabled(toolName)) {
57691
+ throw new Error(`Tool ${name} is not enabled`);
57692
+ }
57693
+ const tool4 = this.agent.toolImplementations[toolName];
57694
+ if (!tool4) {
57695
+ throw new Error(`Tool ${name} not found`);
57696
+ }
57697
+ try {
57698
+ const result = await tool4.execute(args);
57699
+ return {
57700
+ content: [{
57701
+ type: "text",
57702
+ text: typeof result === "string" ? result : JSON.stringify(result, null, 2)
57703
+ }]
57704
+ };
57705
+ } catch (error) {
57706
+ return {
57707
+ content: [{
57708
+ type: "text",
57709
+ text: `Error executing ${name}: ${error.message}`
57710
+ }],
57711
+ isError: true
57712
+ };
57713
+ }
57714
+ }
57715
+ /**
57716
+ * Get the number of available tools
57717
+ */
57718
+ getToolCount() {
57719
+ if (!this.agent || !this.agent.allowedTools) {
57720
+ return 0;
57721
+ }
57722
+ const tools2 = ["search", "extract", "listFiles", "searchFiles", "query"];
57723
+ return tools2.filter((name) => this.agent.allowedTools.isEnabled(name)).length;
57724
+ }
57725
+ /**
57726
+ * Broadcast message to all SSE connections
57727
+ */
57728
+ broadcast(event, data) {
57729
+ const message = `event: ${event}
57730
+ data: ${JSON.stringify(data)}
57731
+
57732
+ `;
57733
+ for (const connection of this.connections) {
57734
+ connection.write(message);
57735
+ }
57736
+ }
57737
+ /**
57738
+ * Stop the server
57739
+ */
57740
+ async stop() {
57741
+ for (const connection of this.connections) {
57742
+ connection.end();
57743
+ }
57744
+ this.connections.clear();
57745
+ if (this.httpServer) {
57746
+ return new Promise((resolve6) => {
57747
+ this.httpServer.close(() => {
57748
+ if (this.debug) {
57749
+ console.log("[MCP] Built-in server stopped");
57750
+ }
57751
+ resolve6();
57752
+ });
57753
+ });
57754
+ }
57755
+ }
57756
+ /**
57757
+ * Get server configuration for MCP clients
57758
+ */
57759
+ getConfig() {
57760
+ return {
57761
+ transport: "http",
57762
+ url: `http://${this.host}:${this.port}/mcp`
57763
+ // Alternative transports:
57764
+ // sse: `http://${this.host}:${this.port}/sse`,
57765
+ // rpc: `http://${this.host}:${this.port}/rpc`
57766
+ };
57767
+ }
57768
+ };
57769
+ }
57770
+ });
57771
+
57772
+ // src/agent/engines/enhanced-claude-code.js
57773
+ var enhanced_claude_code_exports = {};
57774
+ __export(enhanced_claude_code_exports, {
57775
+ createEnhancedClaudeCLIEngine: () => createEnhancedClaudeCLIEngine
57776
+ });
57777
+ import { spawn as spawn3 } from "child_process";
57778
+ import { randomBytes } from "crypto";
57779
+ import fs7 from "fs/promises";
57780
+ import path7 from "path";
57781
+ import os3 from "os";
57782
+ import { EventEmitter as EventEmitter4 } from "events";
57783
+ async function createEnhancedClaudeCLIEngine(options = {}) {
57784
+ const { agent, systemPrompt, customPrompt, debug, sessionId, allowedTools } = options;
57785
+ const session = new ClaudeSession(
57786
+ sessionId || randomBytes(8).toString("hex"),
57787
+ debug
57788
+ );
57789
+ let mcpServer = null;
57790
+ let mcpConfigPath = null;
57791
+ if (agent) {
57792
+ mcpServer = new BuiltInMCPServer(agent, {
57793
+ port: 0,
57794
+ // Ephemeral port
57795
+ host: "127.0.0.1",
57796
+ debug
57797
+ });
57798
+ const { host, port } = await mcpServer.start();
57799
+ if (debug) {
57800
+ console.log("[DEBUG] Built-in MCP server started");
57801
+ console.log("[DEBUG] MCP URL:", `http://${host}:${port}/mcp`);
57802
+ }
57803
+ mcpConfigPath = path7.join(os3.tmpdir(), `probe-mcp-${session.id}.json`);
57804
+ const mcpConfig = {
57805
+ mcpServers: {
57806
+ probe: {
57807
+ command: "node",
57808
+ args: [path7.join(process.cwd(), "mcp-probe-server.js")],
57809
+ env: {
57810
+ PROBE_WORKSPACE: process.cwd(),
57811
+ DEBUG: debug ? "true" : "false"
57812
+ }
57813
+ }
57814
+ }
57815
+ };
57816
+ await fs7.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
57817
+ }
57818
+ if (debug) {
57819
+ console.log("[DEBUG] Enhanced Claude Code Engine");
57820
+ console.log("[DEBUG] Session:", session.id);
57821
+ console.log("[DEBUG] MCP Config:", mcpConfigPath);
57822
+ }
57823
+ const fullSystemPrompt = combinePrompts(systemPrompt, customPrompt, agent);
57824
+ return {
57825
+ sessionId: session.id,
57826
+ session,
57827
+ /**
57828
+ * Query Claude with advanced streaming
57829
+ */
57830
+ async *query(prompt, opts = {}) {
57831
+ const emitter = new EventEmitter4();
57832
+ let buffer = "";
57833
+ let processEnded = false;
57834
+ let currentToolCall = null;
57835
+ let isSchemaMode = false;
57836
+ if (opts.schema || prompt.includes("JSON schema") || prompt.includes("mermaid diagram")) {
57837
+ isSchemaMode = true;
57838
+ if (debug) {
57839
+ console.log("[DEBUG] Schema/validation mode - treating as black box");
57840
+ }
57841
+ }
57842
+ let finalPrompt = prompt;
57843
+ if (opts.schema && isSchemaMode) {
57844
+ finalPrompt = `${prompt}
57845
+
57846
+ Please provide your response in the following JSON format:
57847
+ ${opts.schema}`;
57848
+ }
57849
+ const args = buildClaudeArgs({
57850
+ systemPrompt: fullSystemPrompt,
57851
+ mcpConfigPath,
57852
+ session,
57853
+ debug,
57854
+ prompt: finalPrompt,
57855
+ // Use finalPrompt which may include schema
57856
+ allowedTools: allowedTools || opts.allowedTools
57857
+ // Support tool filtering
57858
+ });
57859
+ if (debug) {
57860
+ console.log("[DEBUG] Executing: claude", args.join(" "));
57861
+ }
57862
+ const shellCmd = `echo "" | claude ${args.map((arg) => {
57863
+ if (typeof arg !== "string") {
57864
+ throw new TypeError(`Invalid argument type: expected string, got ${typeof arg}`);
57865
+ }
57866
+ const escaped = arg.replace(/'/g, "'\\''");
57867
+ return `'${escaped}'`;
57868
+ }).join(" ")}`;
57869
+ if (debug) {
57870
+ console.log("[DEBUG] Shell command length:", shellCmd.length);
57871
+ if (shellCmd.length < 500) {
57872
+ console.log("[DEBUG] Shell command:", shellCmd);
57873
+ } else {
57874
+ console.log("[DEBUG] Shell command (truncated):", shellCmd.substring(0, 200) + "...");
57875
+ }
57876
+ }
57877
+ const toolCollector = [];
57878
+ const proc2 = spawn3("sh", ["-c", shellCmd], {
57879
+ env: { ...process.env, FORCE_COLOR: "0" },
57880
+ stdio: ["ignore", "pipe", "pipe"]
57881
+ // Ignore stdin since echo handles it
57882
+ });
57883
+ proc2.stdout.on("data", (data) => {
57884
+ buffer += data.toString();
57885
+ processJsonBuffer(buffer, emitter, session, debug, toolCollector);
57886
+ const lines = buffer.split("\n");
57887
+ buffer = lines[lines.length - 1] || "";
57888
+ });
57889
+ proc2.stderr.on("data", (data) => {
57890
+ const stderr = data.toString();
57891
+ if (debug) {
57892
+ console.error("[STDERR]", stderr);
57893
+ }
57894
+ if (stderr.includes("command not found")) {
57895
+ emitter.emit("error", new Error("Claude Code not found. Please install it first."));
57896
+ }
57897
+ });
57898
+ proc2.on("close", (code) => {
57899
+ processEnded = true;
57900
+ if (code !== 0 && debug) {
57901
+ console.log(`[DEBUG] Process exited with code ${code}`);
57902
+ }
57903
+ if (buffer.trim()) {
57904
+ processJsonBuffer(buffer, emitter, session, debug, toolCollector);
57905
+ }
57906
+ if (toolCollector.length > 0) {
57907
+ emitter.emit("toolBatch", {
57908
+ tools: toolCollector,
57909
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
57910
+ });
57911
+ if (debug) {
57912
+ console.log(`[DEBUG] Emitting batch of ${toolCollector.length} tool events`);
57913
+ }
57914
+ }
57915
+ emitter.emit("end");
57916
+ });
57917
+ proc2.on("error", (error) => {
57918
+ emitter.emit("error", error);
57919
+ });
57920
+ const messageQueue = [];
57921
+ let resolver = null;
57922
+ emitter.on("message", (msg) => {
57923
+ messageQueue.push(msg);
57924
+ if (resolver) {
57925
+ resolver();
57926
+ resolver = null;
57927
+ }
57928
+ });
57929
+ emitter.on("toolBatch", (batch) => {
57930
+ messageQueue.push({ type: "toolBatch", ...batch });
57931
+ if (resolver) {
57932
+ resolver();
57933
+ resolver = null;
57934
+ }
57935
+ });
57936
+ emitter.on("end", () => {
57937
+ processEnded = true;
57938
+ if (resolver) {
57939
+ resolver();
57940
+ resolver = null;
57941
+ }
57942
+ });
57943
+ emitter.on("error", (error) => {
57944
+ messageQueue.push({ type: "error", error });
57945
+ if (resolver) {
57946
+ resolver();
57947
+ resolver = null;
57948
+ }
57949
+ });
57950
+ while (!processEnded || messageQueue.length > 0) {
57951
+ if (messageQueue.length > 0) {
57952
+ const msg = messageQueue.shift();
57953
+ if (msg.type === "text") {
57954
+ yield { type: "text", content: msg.content };
57955
+ } else if (msg.type === "tool_use") {
57956
+ currentToolCall = msg;
57957
+ yield {
57958
+ type: "text",
57959
+ content: `
57960
+ \u{1F527} Using ${msg.name}: ${JSON.stringify(msg.input)}
57961
+ `
57962
+ };
57963
+ const result = await executeProbleTool(agent, msg.name, msg.input);
57964
+ yield { type: "text", content: `${result}
57965
+ ` };
57966
+ } else if (msg.type === "toolBatch") {
57967
+ yield { type: "toolBatch", tools: msg.tools, timestamp: msg.timestamp };
57968
+ } else if (msg.type === "session_update") {
57969
+ if (debug) {
57970
+ console.log("[DEBUG] Session updated:", msg.conversationId);
57971
+ }
57972
+ } else if (msg.type === "error") {
57973
+ yield { type: "error", error: msg.error };
57974
+ break;
57975
+ }
57976
+ } else if (!processEnded) {
57977
+ await new Promise((resolve6) => {
57978
+ resolver = resolve6;
57979
+ });
57980
+ }
57981
+ }
57982
+ session.incrementMessageCount();
57983
+ yield {
57984
+ type: "metadata",
57985
+ data: {
57986
+ sessionId: session.id,
57987
+ conversationId: session.conversationId,
57988
+ messageCount: session.messageCount
57989
+ }
57990
+ };
57991
+ },
57992
+ /**
57993
+ * Get session info
57994
+ */
57995
+ getSession() {
57996
+ return {
57997
+ id: session.id,
57998
+ conversationId: session.conversationId,
57999
+ messageCount: session.messageCount
58000
+ };
58001
+ },
58002
+ /**
58003
+ * Clean up - MUST be called to stop MCP server and clean resources
58004
+ */
58005
+ async close() {
58006
+ try {
58007
+ if (mcpServer) {
58008
+ await mcpServer.stop();
58009
+ if (debug) {
58010
+ console.log("[DEBUG] Built-in MCP server stopped");
58011
+ }
58012
+ }
58013
+ if (mcpConfigPath) {
58014
+ await fs7.unlink(mcpConfigPath).catch(() => {
58015
+ });
58016
+ if (debug) {
58017
+ console.log("[DEBUG] MCP config file removed");
58018
+ }
58019
+ }
58020
+ if (debug) {
58021
+ console.log("[DEBUG] Engine closed, session:", session.id);
58022
+ }
58023
+ } catch (error) {
58024
+ if (debug) {
58025
+ console.error("[DEBUG] Error during cleanup:", error.message);
58026
+ }
58027
+ }
58028
+ }
58029
+ };
58030
+ }
58031
+ function processJsonBuffer(buffer, emitter, session, debug, toolCollector = null) {
58032
+ const lines = buffer.split("\n");
58033
+ for (const line of lines) {
58034
+ if (!line.trim()) continue;
58035
+ try {
58036
+ const parsed = JSON.parse(line);
58037
+ const messages = Array.isArray(parsed) ? parsed : [parsed];
58038
+ for (const msg of messages) {
58039
+ switch (msg.type) {
58040
+ case "result":
58041
+ if (msg.result) {
58042
+ emitter.emit("message", { type: "text", content: msg.result });
58043
+ }
58044
+ if (msg.session_id) {
58045
+ session.setConversationId(msg.session_id);
58046
+ emitter.emit("message", { type: "session_update", conversationId: msg.session_id });
58047
+ }
58048
+ break;
58049
+ case "conversation":
58050
+ session.setConversationId(msg.id);
58051
+ emitter.emit("message", { type: "session_update", conversationId: msg.id });
58052
+ break;
58053
+ case "text":
58054
+ if (msg.text) {
58055
+ emitter.emit("message", { type: "text", content: msg.text });
58056
+ }
58057
+ break;
58058
+ case "assistant":
58059
+ if (msg.message && msg.message.content) {
58060
+ for (const content of msg.message.content) {
58061
+ if (content.type === "text" && content.text) {
58062
+ emitter.emit("message", { type: "text", content: content.text });
58063
+ } else if (content.type === "tool_use") {
58064
+ if (toolCollector) {
58065
+ toolCollector.push({
58066
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
58067
+ name: content.name,
58068
+ args: content.input || {},
58069
+ id: content.id,
58070
+ status: "started"
58071
+ });
58072
+ }
58073
+ if (debug) {
58074
+ console.log("[DEBUG] Assistant internal tool use:", content.name);
58075
+ }
58076
+ }
58077
+ }
58078
+ }
58079
+ break;
58080
+ case "tool_use":
58081
+ if (toolCollector) {
58082
+ toolCollector.push({
58083
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
58084
+ name: msg.name,
58085
+ args: msg.input || {},
58086
+ id: msg.id,
58087
+ status: "started"
58088
+ });
58089
+ }
58090
+ emitter.emit("message", {
58091
+ type: "tool_use",
58092
+ id: msg.id,
58093
+ name: msg.name,
58094
+ input: msg.input
58095
+ });
58096
+ break;
58097
+ case "tool_result":
58098
+ if (toolCollector && msg.tool_use_id) {
58099
+ const toolCall = toolCollector.find((t) => t.id === msg.tool_use_id);
58100
+ if (toolCall) {
58101
+ toolCall.status = "completed";
58102
+ toolCall.resultPreview = msg.content ? (typeof msg.content === "string" ? msg.content.substring(0, 200) : JSON.stringify(msg.content).substring(0, 200)) + "..." : "No Result";
58103
+ }
58104
+ }
58105
+ if (debug) {
58106
+ console.log("[DEBUG] Tool result:", msg);
58107
+ }
58108
+ break;
58109
+ case "error":
58110
+ emitter.emit("error", new Error(msg.message || "Unknown error"));
58111
+ break;
58112
+ default:
58113
+ if (debug) {
58114
+ console.log("[DEBUG] Unknown message type:", msg.type);
58115
+ console.log("[DEBUG] Full message:", JSON.stringify(msg).substring(0, 200));
58116
+ }
58117
+ }
58118
+ }
58119
+ } catch (e) {
58120
+ if (debug && line.trim()) {
58121
+ console.log("[DEBUG] Non-JSON output:", line);
58122
+ }
58123
+ }
58124
+ }
58125
+ }
58126
+ function buildClaudeArgs({ systemPrompt, mcpConfigPath, session, debug, prompt, allowedTools }) {
58127
+ const args = [
58128
+ "-p",
58129
+ // Short form of --print
58130
+ prompt,
58131
+ // The prompt text goes right after -p
58132
+ "--output-format",
58133
+ "json"
58134
+ ];
58135
+ const resumeArgs = session.getResumeArgs();
58136
+ if (resumeArgs.length > 0) {
58137
+ args.push(...resumeArgs);
58138
+ }
58139
+ if (systemPrompt) {
58140
+ args.push("--system-prompt", systemPrompt);
58141
+ }
58142
+ args.push("--mcp-config", mcpConfigPath);
58143
+ if (allowedTools && Array.isArray(allowedTools) && allowedTools.length > 0) {
58144
+ const mcpTools = allowedTools.map(
58145
+ (tool4) => tool4.startsWith("mcp__") ? tool4 : `mcp__probe__${tool4}`
58146
+ ).join(",");
58147
+ args.push("--allowedTools", mcpTools);
58148
+ } else {
58149
+ args.push("--allowedTools", "mcp__probe__*");
58150
+ }
58151
+ if (debug) {
58152
+ args.push("--verbose");
58153
+ }
58154
+ return args;
58155
+ }
58156
+ async function executeProbleTool(agent, toolName, params) {
58157
+ if (!agent || !agent.toolImplementations) {
58158
+ return "Tool execution not available";
58159
+ }
58160
+ const name = toolName.replace(/^mcp__probe__/, "");
58161
+ const tool4 = agent.toolImplementations[name];
58162
+ if (!tool4) {
58163
+ return `Unknown tool: ${name}`;
58164
+ }
58165
+ try {
58166
+ const result = await tool4.execute(params);
58167
+ return typeof result === "string" ? result : JSON.stringify(result, null, 2);
58168
+ } catch (error) {
58169
+ return `Tool error: ${error.message}`;
58170
+ }
58171
+ }
58172
+ function combinePrompts(systemPrompt, customPrompt, agent) {
58173
+ if (!systemPrompt && customPrompt) {
58174
+ return customPrompt;
58175
+ }
58176
+ if (systemPrompt && customPrompt) {
58177
+ return systemPrompt + "\n\n## Additional Instructions\n" + customPrompt;
58178
+ }
58179
+ return systemPrompt || "";
58180
+ }
58181
+ var ClaudeSession;
58182
+ var init_enhanced_claude_code = __esm({
58183
+ "src/agent/engines/enhanced-claude-code.js"() {
58184
+ "use strict";
58185
+ init_built_in_server();
58186
+ ClaudeSession = class {
58187
+ constructor(id, debug = false) {
58188
+ this.id = id;
58189
+ this.conversationId = null;
58190
+ this.messageCount = 0;
58191
+ this.debug = debug;
58192
+ }
58193
+ /**
58194
+ * Update session with Claude's conversation ID
58195
+ */
58196
+ setConversationId(convId) {
58197
+ this.conversationId = convId;
58198
+ if (this.debug) {
58199
+ console.log(`[Session ${this.id}] Conversation ID: ${convId}`);
58200
+ }
58201
+ }
58202
+ /**
58203
+ * Get resume arguments for continuing conversation
58204
+ */
58205
+ getResumeArgs() {
58206
+ if (this.conversationId && this.messageCount > 0) {
58207
+ return ["--resume", this.conversationId];
58208
+ }
58209
+ return [];
58210
+ }
58211
+ incrementMessageCount() {
58212
+ this.messageCount++;
58213
+ }
58214
+ };
58215
+ }
58216
+ });
58217
+
58218
+ // src/agent/engines/enhanced-vercel.js
58219
+ var enhanced_vercel_exports = {};
58220
+ __export(enhanced_vercel_exports, {
58221
+ createEnhancedVercelEngine: () => createEnhancedVercelEngine
58222
+ });
58223
+ import { streamText } from "ai";
58224
+ function createEnhancedVercelEngine(agent) {
58225
+ return {
58226
+ /**
58227
+ * Query the model using existing Vercel AI SDK implementation
58228
+ * @param {string} prompt - The prompt to send
58229
+ * @param {Object} options - Additional options
58230
+ * @returns {AsyncIterable} Response stream
58231
+ */
58232
+ async *query(prompt, options = {}) {
58233
+ const systemMessage = await agent.getSystemMessage();
58234
+ const messages = [
58235
+ { role: "system", content: systemMessage },
58236
+ ...agent.history,
58237
+ { role: "user", content: prompt }
58238
+ ];
58239
+ const result = await agent.streamTextWithRetryAndFallback({
58240
+ model: agent.provider(agent.model),
58241
+ messages,
58242
+ maxTokens: options.maxTokens || agent.maxResponseTokens,
58243
+ temperature: options.temperature || 0.3,
58244
+ // Note: Vercel AI SDK doesn't use structured tools for XML format
58245
+ // The tools are embedded in the system prompt
58246
+ experimental_telemetry: options.telemetry
58247
+ });
58248
+ let fullContent = "";
58249
+ for await (const chunk of result.textStream) {
58250
+ fullContent += chunk;
58251
+ yield { type: "text", content: chunk };
58252
+ }
58253
+ const toolCalls = agent.parseXmlToolCalls ? agent.parseXmlToolCalls(fullContent) : null;
58254
+ if (toolCalls && toolCalls.length > 0) {
58255
+ yield { type: "tool_calls", toolCalls };
58256
+ }
58257
+ if (result.finishReason) {
58258
+ yield { type: "finish", reason: result.finishReason };
58259
+ }
58260
+ },
58261
+ /**
58262
+ * Get available tools for this engine
58263
+ */
58264
+ getTools() {
58265
+ return agent.toolImplementations || {};
58266
+ },
58267
+ /**
58268
+ * Get system prompt for this engine
58269
+ */
58270
+ async getSystemPrompt() {
58271
+ return agent.getSystemMessage();
58272
+ },
58273
+ /**
58274
+ * Optional cleanup
58275
+ */
58276
+ async close() {
58277
+ }
58278
+ };
58279
+ }
58280
+ var init_enhanced_vercel = __esm({
58281
+ "src/agent/engines/enhanced-vercel.js"() {
58282
+ "use strict";
58283
+ }
58284
+ });
58285
+
57360
58286
  // src/agent/ProbeAgent.js
57361
58287
  var ProbeAgent_exports = {};
57362
58288
  __export(ProbeAgent_exports, {
@@ -57367,9 +58293,9 @@ import { createAnthropic as createAnthropic2 } from "@ai-sdk/anthropic";
57367
58293
  import { createOpenAI as createOpenAI2 } from "@ai-sdk/openai";
57368
58294
  import { createGoogleGenerativeAI as createGoogleGenerativeAI2 } from "@ai-sdk/google";
57369
58295
  import { createAmazonBedrock as createAmazonBedrock2 } from "@ai-sdk/amazon-bedrock";
57370
- import { streamText } from "ai";
58296
+ import { streamText as streamText2 } from "ai";
57371
58297
  import { randomUUID as randomUUID4 } from "crypto";
57372
- import { EventEmitter as EventEmitter3 } from "events";
58298
+ import { EventEmitter as EventEmitter5 } from "events";
57373
58299
  import { existsSync as existsSync5 } from "fs";
57374
58300
  import { readFile, stat } from "fs/promises";
57375
58301
  import { resolve as resolve4, isAbsolute as isAbsolute2, dirname as dirname4 } from "path";
@@ -57494,7 +58420,7 @@ var init_ProbeAgent = __esm({
57494
58420
  this.history = [];
57495
58421
  this.pendingImages = /* @__PURE__ */ new Map();
57496
58422
  this.currentImages = [];
57497
- this.events = new EventEmitter3();
58423
+ this.events = new EventEmitter5();
57498
58424
  this.enableMcp = !!options.enableMcp || process.env.ENABLE_MCP === "1";
57499
58425
  this.mcpConfigPath = options.mcpConfigPath || null;
57500
58426
  this.mcpConfig = options.mcpConfig || null;
@@ -57505,6 +58431,7 @@ var init_ProbeAgent = __esm({
57505
58431
  this.retryManager = null;
57506
58432
  this.fallbackConfig = options.fallback || null;
57507
58433
  this.fallbackManager = null;
58434
+ this.engine = null;
57508
58435
  this.initializeModel();
57509
58436
  }
57510
58437
  /**
@@ -57567,6 +58494,23 @@ var init_ProbeAgent = __esm({
57567
58494
  * This method initializes MCP and merges MCP tools into the tool list, and loads history from storage
57568
58495
  */
57569
58496
  async initialize() {
58497
+ if (!this.provider && !this.clientApiProvider && this.apiType !== "claude-code") {
58498
+ if (this.apiType === "uninitialized") {
58499
+ const claudeAvailable = await this.isClaudeCommandAvailable();
58500
+ if (claudeAvailable) {
58501
+ if (this.debug) {
58502
+ console.log("[DEBUG] No API keys found, but claude command detected");
58503
+ console.log("[DEBUG] Auto-switching to claude-code provider");
58504
+ }
58505
+ this.clientApiProvider = "claude-code";
58506
+ this.provider = null;
58507
+ this.model = this.clientApiModel || "claude-3-5-sonnet-20241022";
58508
+ this.apiType = "claude-code";
58509
+ } else {
58510
+ throw new Error("No API key provided and claude command not found. Please either:\n1. Set an API key: ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, or AWS credentials\n2. Install claude command from https://docs.claude.com/en/docs/claude-code");
58511
+ }
58512
+ }
58513
+ }
57570
58514
  try {
57571
58515
  const history = await this.storageAdapter.loadHistory(this.sessionId);
57572
58516
  this.history = history;
@@ -57643,7 +58587,20 @@ var init_ProbeAgent = __esm({
57643
58587
  extract: wrappedTools.extractToolInstance,
57644
58588
  delegate: wrappedTools.delegateToolInstance,
57645
58589
  listFiles: listFilesToolInstance,
57646
- searchFiles: searchFilesToolInstance
58590
+ searchFiles: searchFilesToolInstance,
58591
+ readImage: {
58592
+ execute: async (params) => {
58593
+ const imagePath = params.path;
58594
+ if (!imagePath) {
58595
+ throw new Error("Image path is required");
58596
+ }
58597
+ const loaded = await this.loadImageIfValid(imagePath);
58598
+ if (!loaded) {
58599
+ throw new Error(`Failed to load image: ${imagePath}. The file may not exist, be too large, have an unsupported format, or be outside allowed directories.`);
58600
+ }
58601
+ return `Image loaded successfully: ${imagePath}. The image is now available for analysis in the conversation.`;
58602
+ }
58603
+ }
57647
58604
  };
57648
58605
  if (this.enableBash && wrappedTools.bashToolInstance) {
57649
58606
  this.toolImplementations.bash = wrappedTools.bashToolInstance;
@@ -57670,6 +58627,20 @@ var init_ProbeAgent = __esm({
57670
58627
  console.error("[DEBUG] ========================================\n");
57671
58628
  }
57672
58629
  }
58630
+ /**
58631
+ * Check if claude command is available on the system
58632
+ * @returns {Promise<boolean>} True if claude command is available
58633
+ * @private
58634
+ */
58635
+ async isClaudeCommandAvailable() {
58636
+ try {
58637
+ const { execSync } = await import("child_process");
58638
+ execSync("claude --version", { stdio: "ignore" });
58639
+ return true;
58640
+ } catch (error) {
58641
+ return false;
58642
+ }
58643
+ }
57673
58644
  /**
57674
58645
  * Initialize the AI model based on available API keys and forced provider setting
57675
58646
  */
@@ -57679,6 +58650,15 @@ var init_ProbeAgent = __esm({
57679
58650
  this.initializeMockModel(modelName);
57680
58651
  return;
57681
58652
  }
58653
+ if (this.clientApiProvider === "claude-code" || process.env.USE_CLAUDE_CODE === "true") {
58654
+ this.provider = null;
58655
+ this.model = modelName || "claude-3-5-sonnet-20241022";
58656
+ this.apiType = "claude-code";
58657
+ if (this.debug) {
58658
+ console.log("[DEBUG] Claude Code engine selected - will use built-in access if available");
58659
+ }
58660
+ return;
58661
+ }
57682
58662
  const anthropicApiKey = process.env.ANTHROPIC_API_KEY || process.env.ANTHROPIC_AUTH_TOKEN;
57683
58663
  const openaiApiKey = process.env.OPENAI_API_KEY;
57684
58664
  const googleApiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY || process.env.GOOGLE_API_KEY;
@@ -57736,7 +58716,10 @@ var init_ProbeAgent = __esm({
57736
58716
  this.initializeBedrockModel(awsAccessKeyId, awsSecretAccessKey, awsRegion, awsSessionToken, awsApiKey, awsBedrockBaseUrl, modelName);
57737
58717
  this.initializeFallbackManager("bedrock", modelName);
57738
58718
  } else {
57739
- throw new Error("No API key provided. Please set ANTHROPIC_API_KEY (or ANTHROPIC_AUTH_TOKEN), OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY (or GOOGLE_API_KEY), AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION), or AWS_BEDROCK_API_KEY environment variables.");
58719
+ this.apiType = "uninitialized";
58720
+ if (this.debug) {
58721
+ console.log("[DEBUG] No API keys found - will check for claude command in initialize()");
58722
+ }
57740
58723
  }
57741
58724
  }
57742
58725
  /**
@@ -57799,6 +58782,44 @@ var init_ProbeAgent = __esm({
57799
58782
  * @private
57800
58783
  */
57801
58784
  async streamTextWithRetryAndFallback(options) {
58785
+ if (this.clientApiProvider === "claude-code" || process.env.USE_CLAUDE_CODE === "true") {
58786
+ try {
58787
+ const engine = await this.getEngine();
58788
+ if (engine && engine.query) {
58789
+ const userMessages = options.messages.filter(
58790
+ (m) => m.role === "user" && !m.content.includes("WARNING: You have reached the maximum tool iterations limit")
58791
+ );
58792
+ const lastUserMessage = userMessages[userMessages.length - 1];
58793
+ const prompt = lastUserMessage ? lastUserMessage.content : "";
58794
+ const engineOptions = {
58795
+ maxTokens: options.maxTokens,
58796
+ temperature: options.temperature,
58797
+ messages: options.messages,
58798
+ systemPrompt: options.messages.find((m) => m.role === "system")?.content
58799
+ };
58800
+ const engineStream = engine.query(prompt, engineOptions);
58801
+ async function* createTextStream() {
58802
+ for await (const message of engineStream) {
58803
+ if (message.type === "text" && message.content) {
58804
+ yield message.content;
58805
+ } else if (typeof message === "string") {
58806
+ yield message;
58807
+ }
58808
+ }
58809
+ }
58810
+ return {
58811
+ textStream: createTextStream(),
58812
+ usage: Promise.resolve({})
58813
+ // Engine should handle its own usage tracking
58814
+ // Add other streamText-compatible properties as needed
58815
+ };
58816
+ }
58817
+ } catch (error) {
58818
+ if (this.debug) {
58819
+ console.log(`[DEBUG] Failed to use Claude Code engine, falling back to Vercel:`, error.message);
58820
+ }
58821
+ }
58822
+ }
57802
58823
  if (!this.retryManager) {
57803
58824
  this.retryManager = new RetryManager({
57804
58825
  maxRetries: this.retryConfig.maxRetries ?? 3,
@@ -57811,7 +58832,7 @@ var init_ProbeAgent = __esm({
57811
58832
  }
57812
58833
  if (!this.fallbackManager) {
57813
58834
  return await this.retryManager.executeWithRetry(
57814
- () => streamText(options),
58835
+ () => streamText2(options),
57815
58836
  {
57816
58837
  provider: this.apiType,
57817
58838
  model: this.model
@@ -57833,7 +58854,7 @@ var init_ProbeAgent = __esm({
57833
58854
  debug: this.debug
57834
58855
  });
57835
58856
  return await providerRetryManager.executeWithRetry(
57836
- () => streamText(fallbackOptions),
58857
+ () => streamText2(fallbackOptions),
57837
58858
  {
57838
58859
  provider: config.provider,
57839
58860
  model
@@ -57915,6 +58936,49 @@ var init_ProbeAgent = __esm({
57915
58936
  console.log(`Using AWS Bedrock API with model: ${this.model}${regionInfo} [Auth: ${authMethod}]${baseUrlInfo}`);
57916
58937
  }
57917
58938
  }
58939
+ /**
58940
+ * Get or create the AI engine based on configuration
58941
+ * @returns {Promise<Object>} Engine interface
58942
+ * @private
58943
+ */
58944
+ async getEngine() {
58945
+ if (this.engine) {
58946
+ return this.engine;
58947
+ }
58948
+ if (this.clientApiProvider === "claude-code" || process.env.USE_CLAUDE_CODE === "true") {
58949
+ try {
58950
+ const { createEnhancedClaudeCLIEngine: createEnhancedClaudeCLIEngine2 } = await Promise.resolve().then(() => (init_enhanced_claude_code(), enhanced_claude_code_exports));
58951
+ const systemPrompt = this.customPrompt || this.getClaudeNativeSystemPrompt();
58952
+ this.engine = await createEnhancedClaudeCLIEngine2({
58953
+ agent: this,
58954
+ // Pass reference to ProbeAgent for tool access
58955
+ systemPrompt,
58956
+ customPrompt: this.customPrompt,
58957
+ sessionId: this.options?.sessionId,
58958
+ debug: this.debug,
58959
+ allowedTools: this.allowedTools
58960
+ // Pass tool filtering configuration
58961
+ });
58962
+ if (this.debug) {
58963
+ console.log("[DEBUG] Using Claude Code engine with Probe tools");
58964
+ if (this.customPrompt) {
58965
+ console.log("[DEBUG] Using custom prompt/persona");
58966
+ }
58967
+ }
58968
+ return this.engine;
58969
+ } catch (error) {
58970
+ console.warn("[WARNING] Failed to load Claude Code engine:", error.message);
58971
+ console.warn("[WARNING] Falling back to Vercel AI SDK");
58972
+ this.clientApiProvider = null;
58973
+ }
58974
+ }
58975
+ const { createEnhancedVercelEngine: createEnhancedVercelEngine2 } = await Promise.resolve().then(() => (init_enhanced_vercel(), enhanced_vercel_exports));
58976
+ this.engine = createEnhancedVercelEngine2(this);
58977
+ if (this.debug) {
58978
+ console.log("[DEBUG] Using Vercel AI SDK engine");
58979
+ }
58980
+ return this.engine;
58981
+ }
57918
58982
  /**
57919
58983
  * Process assistant response content and detect/load image references
57920
58984
  * @param {string} content - The assistant's response content
@@ -58201,6 +59265,55 @@ var init_ProbeAgent = __esm({
58201
59265
  this.mcpBridge = null;
58202
59266
  }
58203
59267
  }
59268
+ /**
59269
+ * Get system prompt for Claude native engines (CLI/SDK) without XML formatting
59270
+ * These engines have native MCP support and don't need XML instructions
59271
+ */
59272
+ getClaudeNativeSystemPrompt() {
59273
+ let systemPrompt = "";
59274
+ if (this.predefinedPrompt) {
59275
+ const personaPrompt = getPromptByType(this.predefinedPrompt);
59276
+ if (personaPrompt?.system) {
59277
+ systemPrompt += personaPrompt.system + "\n\n";
59278
+ }
59279
+ }
59280
+ systemPrompt += `You have access to powerful code search and analysis tools through MCP:
59281
+ - search: Find code patterns using semantic search
59282
+ - extract: Extract specific code sections with context
59283
+ - query: Use AST patterns for structural code matching
59284
+ - listFiles: Browse directory contents
59285
+ - searchFiles: Find files by name patterns`;
59286
+ if (this.enableBash) {
59287
+ systemPrompt += `
59288
+ - bash: Execute bash commands for system operations`;
59289
+ }
59290
+ systemPrompt += `
59291
+
59292
+ When exploring code:
59293
+ 1. Start with search to find relevant code patterns
59294
+ 2. Use extract to get detailed context when needed
59295
+ 3. Prefer focused, specific searches over broad queries
59296
+ 4. Combine multiple tools to build complete understanding`;
59297
+ if (this.allowedFolders && this.allowedFolders.length > 0) {
59298
+ systemPrompt += `
59299
+
59300
+ Workspace: ${this.allowedFolders.join(", ")}`;
59301
+ }
59302
+ if (this.fileList) {
59303
+ systemPrompt += `
59304
+
59305
+ # Repository Structure
59306
+ `;
59307
+ systemPrompt += `You are working with a repository located at: ${this.allowedFolders[0]}
59308
+
59309
+ `;
59310
+ systemPrompt += `Here's an overview of the repository structure (showing up to 100 most relevant files):
59311
+
59312
+ `;
59313
+ systemPrompt += "```\n" + this.fileList + "\n```\n";
59314
+ }
59315
+ return systemPrompt;
59316
+ }
58204
59317
  /**
58205
59318
  * Get the system message with instructions for the AI (XML Tool Format)
58206
59319
  */
@@ -58246,6 +59359,10 @@ var init_ProbeAgent = __esm({
58246
59359
  }
58247
59360
  if (isToolAllowed("searchFiles")) {
58248
59361
  toolDefinitions += `${searchFilesToolDefinition}
59362
+ `;
59363
+ }
59364
+ if (isToolAllowed("readImage")) {
59365
+ toolDefinitions += `${readImageToolDefinition}
58249
59366
  `;
58250
59367
  }
58251
59368
  if (this.allowEdit && isToolAllowed("implement")) {
@@ -58333,6 +59450,7 @@ Available Tools:
58333
59450
  - extract: Extract specific code blocks or lines from files.
58334
59451
  - listFiles: List files and directories in a specified location.
58335
59452
  - searchFiles: Find files matching a glob pattern with recursive search capability.
59453
+ - readImage: Read and load an image file for AI analysis.
58336
59454
  ${this.allowEdit ? "- implement: Implement a feature or fix a bug using aider.\n- edit: Edit files using exact string replacement.\n- create: Create new files with specified content.\n" : ""}${this.enableDelegate ? "- delegate: Delegate big distinct tasks to specialized probe subagents.\n" : ""}${this.enableBash ? "- bash: Execute bash commands for system operations.\n" : ""}
58337
59455
  - attempt_completion: Finalize the task and provide the result to the user.
58338
59456
  - attempt_complete: Quick completion using previous response (shorthand).
@@ -58556,6 +59674,59 @@ You are working with a repository located at: ${searchDirectory}
58556
59674
  let finalResult = "I was unable to complete your request due to reaching the maximum number of tool iterations.";
58557
59675
  const baseMaxIterations = this.maxIterations || MAX_TOOL_ITERATIONS;
58558
59676
  const maxIterations = options.schema ? baseMaxIterations + 4 : baseMaxIterations;
59677
+ const isClaudeCode = this.clientApiProvider === "claude-code" || process.env.USE_CLAUDE_CODE === "true";
59678
+ if (isClaudeCode) {
59679
+ if (this.debug) {
59680
+ console.log(`[DEBUG] Using Claude Code engine - bypassing tool loop (black box mode)`);
59681
+ console.log(`[DEBUG] Sending question directly to Claude Code: ${message.substring(0, 100)}...`);
59682
+ }
59683
+ try {
59684
+ const engine = await this.getEngine();
59685
+ if (engine && engine.query) {
59686
+ let assistantResponseContent = "";
59687
+ let toolBatch = null;
59688
+ for await (const chunk of engine.query(message, options)) {
59689
+ if (chunk.type === "text" && chunk.content) {
59690
+ assistantResponseContent += chunk.content;
59691
+ if (options.onStream) {
59692
+ options.onStream(chunk.content);
59693
+ }
59694
+ } else if (chunk.type === "toolBatch" && chunk.tools) {
59695
+ toolBatch = chunk.tools;
59696
+ if (this.debug) {
59697
+ console.log(`[DEBUG] Received batch of ${chunk.tools.length} tool events from Claude Code`);
59698
+ }
59699
+ } else if (chunk.type === "error") {
59700
+ throw chunk.error;
59701
+ }
59702
+ }
59703
+ if (toolBatch && toolBatch.length > 0 && this.events) {
59704
+ if (this.debug) {
59705
+ console.log(`[DEBUG] Emitting ${toolBatch.length} tool events from Claude Code batch`);
59706
+ }
59707
+ for (const toolEvent of toolBatch) {
59708
+ this.events.emit("toolCall", toolEvent);
59709
+ }
59710
+ }
59711
+ this.history.push(userMessage);
59712
+ this.history.push({
59713
+ role: "assistant",
59714
+ content: assistantResponseContent
59715
+ });
59716
+ await this.hooks.emit(HOOK_TYPES.COMPLETION, {
59717
+ sessionId: this.sessionId,
59718
+ prompt: message,
59719
+ response: assistantResponseContent
59720
+ });
59721
+ return assistantResponseContent;
59722
+ }
59723
+ } catch (error) {
59724
+ if (this.debug) {
59725
+ console.error("[DEBUG] Claude Code error:", error);
59726
+ }
59727
+ throw error;
59728
+ }
59729
+ }
58559
59730
  if (this.debug) {
58560
59731
  console.log(`[DEBUG] Starting agentic flow for question: ${message.substring(0, 100)}...`);
58561
59732
  if (options.schema) {
@@ -58614,7 +59785,7 @@ You are working with a repository located at: ${searchDirectory}
58614
59785
  const executeAIRequest = async () => {
58615
59786
  const messagesForAI = this.prepareMessagesWithImages(currentMessages);
58616
59787
  const result = await this.streamTextWithRetryAndFallback({
58617
- model: this.provider(this.model),
59788
+ model: this.provider ? this.provider(this.model) : this.model,
58618
59789
  messages: messagesForAI,
58619
59790
  maxTokens: maxResponseTokens,
58620
59791
  temperature: 0.3
@@ -58690,15 +59861,13 @@ You are working with a repository located at: ${searchDirectory}
58690
59861
  const assistantPreview = createMessagePreview(assistantResponseContent);
58691
59862
  console.log(`[DEBUG] Assistant response (${assistantResponseContent.length} chars): ${assistantPreview}`);
58692
59863
  }
58693
- if (assistantResponseContent) {
58694
- await this.processImageReferences(assistantResponseContent);
58695
- }
58696
59864
  const validTools = [];
58697
59865
  if (this.allowedTools.isEnabled("search")) validTools.push("search");
58698
59866
  if (this.allowedTools.isEnabled("query")) validTools.push("query");
58699
59867
  if (this.allowedTools.isEnabled("extract")) validTools.push("extract");
58700
59868
  if (this.allowedTools.isEnabled("listFiles")) validTools.push("listFiles");
58701
59869
  if (this.allowedTools.isEnabled("searchFiles")) validTools.push("searchFiles");
59870
+ if (this.allowedTools.isEnabled("readImage")) validTools.push("readImage");
58702
59871
  if (this.allowedTools.isEnabled("attempt_completion")) validTools.push("attempt_completion");
58703
59872
  if (this.allowEdit && this.allowedTools.isEnabled("implement")) {
58704
59873
  validTools.push("implement", "edit", "create");
@@ -59647,10 +60816,10 @@ import dotenv3 from "dotenv";
59647
60816
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
59648
60817
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
59649
60818
  import {
59650
- CallToolRequestSchema,
60819
+ CallToolRequestSchema as CallToolRequestSchema2,
59651
60820
  ErrorCode as ErrorCode2,
59652
60821
  InitializeRequestSchema,
59653
- ListToolsRequestSchema,
60822
+ ListToolsRequestSchema as ListToolsRequestSchema2,
59654
60823
  McpError
59655
60824
  } from "@modelcontextprotocol/sdk/types.js";
59656
60825
  import { readFileSync as readFileSync2, existsSync as existsSync6 } from "fs";
@@ -59660,7 +60829,7 @@ import { resolve as resolve5 } from "path";
59660
60829
  import { randomUUID as randomUUID5 } from "crypto";
59661
60830
 
59662
60831
  // src/agent/acp/connection.js
59663
- import { EventEmitter as EventEmitter4 } from "events";
60832
+ import { EventEmitter as EventEmitter6 } from "events";
59664
60833
 
59665
60834
  // src/agent/acp/types.js
59666
60835
  var ACP_PROTOCOL_VERSION = "1";
@@ -59777,7 +60946,7 @@ function validateMessage(message) {
59777
60946
  }
59778
60947
 
59779
60948
  // src/agent/acp/connection.js
59780
- var ACPConnection = class extends EventEmitter4 {
60949
+ var ACPConnection = class extends EventEmitter6 {
59781
60950
  constructor(inputStream = process.stdin, outputStream = process.stdout) {
59782
60951
  super();
59783
60952
  this.inputStream = inputStream;
@@ -60616,7 +61785,7 @@ var ProbeAgentMcpServer = class {
60616
61785
  }
60617
61786
  };
60618
61787
  });
60619
- this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
61788
+ this.server.setRequestHandler(ListToolsRequestSchema2, async () => ({
60620
61789
  tools: [
60621
61790
  {
60622
61791
  name: "search_code",
@@ -60651,7 +61820,7 @@ var ProbeAgentMcpServer = class {
60651
61820
  }
60652
61821
  ]
60653
61822
  }));
60654
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
61823
+ this.server.setRequestHandler(CallToolRequestSchema2, async (request) => {
60655
61824
  if (request.params.name !== "search_code") {
60656
61825
  throw new McpError(
60657
61826
  ErrorCode2.MethodNotFound,