@probelabs/probe 0.6.0-rc174 → 0.6.0-rc175

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.
@@ -3068,6 +3068,31 @@ var init_utils = __esm({
3068
3068
  }
3069
3069
  });
3070
3070
 
3071
+ // src/utils/path-validation.js
3072
+ import path4 from "path";
3073
+ import { promises as fs5 } from "fs";
3074
+ async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
3075
+ const targetPath = inputPath || defaultPath;
3076
+ const normalizedPath = path4.normalize(path4.resolve(targetPath));
3077
+ try {
3078
+ const stats = await fs5.stat(normalizedPath);
3079
+ if (!stats.isDirectory()) {
3080
+ throw new Error(`Path is not a directory: ${normalizedPath}`);
3081
+ }
3082
+ } catch (error) {
3083
+ if (error.code === "ENOENT") {
3084
+ throw new Error(`Path does not exist: ${normalizedPath}`);
3085
+ }
3086
+ throw error;
3087
+ }
3088
+ return normalizedPath;
3089
+ }
3090
+ var init_path_validation = __esm({
3091
+ "src/utils/path-validation.js"() {
3092
+ "use strict";
3093
+ }
3094
+ });
3095
+
3071
3096
  // src/search.js
3072
3097
  import { execFile } from "child_process";
3073
3098
  import { promisify as promisify2 } from "util";
@@ -3109,9 +3134,11 @@ async function search(options) {
3109
3134
  options.session = process.env.PROBE_SESSION_ID;
3110
3135
  }
3111
3136
  const queries = Array.isArray(options.query) ? options.query : [options.query];
3137
+ const cwd = await validateCwdPath(options.cwd);
3112
3138
  if (process.env.DEBUG === "1") {
3113
3139
  let logMessage = `
3114
3140
  Search: query="${queries[0]}" path="${options.path}"`;
3141
+ if (options.cwd) logMessage += ` cwd="${options.cwd}"`;
3115
3142
  if (options.maxResults) logMessage += ` maxResults=${options.maxResults}`;
3116
3143
  logMessage += ` maxTokens=${options.maxTokens}`;
3117
3144
  logMessage += ` timeout=${options.timeout}`;
@@ -3131,6 +3158,7 @@ Search: query="${queries[0]}" path="${options.path}"`;
3131
3158
  }
3132
3159
  try {
3133
3160
  const { stdout, stderr } = await execFileAsync(binaryPath, args, {
3161
+ cwd,
3134
3162
  timeout: options.timeout * 1e3,
3135
3163
  // Convert seconds to milliseconds
3136
3164
  maxBuffer: 50 * 1024 * 1024
@@ -3184,13 +3212,15 @@ Search results: ${resultCount} matches, ${tokenCount} tokens`;
3184
3212
  if (error.code === "ETIMEDOUT" || error.killed) {
3185
3213
  const timeoutMessage = `Search operation timed out after ${options.timeout} seconds.
3186
3214
  Binary: ${binaryPath}
3187
- Args: ${args.join(" ")}`;
3215
+ Args: ${args.join(" ")}
3216
+ Cwd: ${cwd}`;
3188
3217
  console.error(timeoutMessage);
3189
3218
  throw new Error(timeoutMessage);
3190
3219
  }
3191
3220
  const errorMessage = `Error executing search command: ${error.message}
3192
3221
  Binary: ${binaryPath}
3193
- Args: ${args.join(" ")}`;
3222
+ Args: ${args.join(" ")}
3223
+ Cwd: ${cwd}`;
3194
3224
  throw new Error(errorMessage);
3195
3225
  }
3196
3226
  }
@@ -3199,6 +3229,7 @@ var init_search = __esm({
3199
3229
  "src/search.js"() {
3200
3230
  "use strict";
3201
3231
  init_utils();
3232
+ init_path_validation();
3202
3233
  execFileAsync = promisify2(execFile);
3203
3234
  SEARCH_FLAG_MAP = {
3204
3235
  filesOnly: "--files-only",
@@ -3238,8 +3269,10 @@ async function query(options) {
3238
3269
  cliArgs.push("--format", "json");
3239
3270
  }
3240
3271
  cliArgs.push(escapeString(options.pattern), escapeString(options.path));
3272
+ const cwd = await validateCwdPath(options.cwd);
3241
3273
  if (process.env.DEBUG === "1") {
3242
3274
  let logMessage = `Query: pattern="${options.pattern}" path="${options.path}"`;
3275
+ if (options.cwd) logMessage += ` cwd="${options.cwd}"`;
3243
3276
  if (options.language) logMessage += ` language=${options.language}`;
3244
3277
  if (options.maxResults) logMessage += ` maxResults=${options.maxResults}`;
3245
3278
  if (options.allowTests) logMessage += " allowTests=true";
@@ -3247,7 +3280,7 @@ async function query(options) {
3247
3280
  }
3248
3281
  const command = `${binaryPath} query ${cliArgs.join(" ")}`;
3249
3282
  try {
3250
- const { stdout, stderr } = await execAsync(command);
3283
+ const { stdout, stderr } = await execAsync(command, { cwd });
3251
3284
  if (stderr) {
3252
3285
  console.error(`stderr: ${stderr}`);
3253
3286
  }
@@ -3272,7 +3305,8 @@ async function query(options) {
3272
3305
  return stdout;
3273
3306
  } catch (error) {
3274
3307
  const errorMessage = `Error executing query command: ${error.message}
3275
- Command: ${command}`;
3308
+ Command: ${command}
3309
+ Cwd: ${cwd}`;
3276
3310
  throw new Error(errorMessage);
3277
3311
  }
3278
3312
  }
@@ -3281,6 +3315,7 @@ var init_query = __esm({
3281
3315
  "src/query.js"() {
3282
3316
  "use strict";
3283
3317
  init_utils();
3318
+ init_path_validation();
3284
3319
  execAsync = promisify3(exec2);
3285
3320
  QUERY_FLAG_MAP = {
3286
3321
  language: "--language",
@@ -3317,6 +3352,7 @@ async function extract(options) {
3317
3352
  cliArgs.push(escapeString(file));
3318
3353
  }
3319
3354
  }
3355
+ const cwd = await validateCwdPath(options.cwd);
3320
3356
  if (process.env.DEBUG === "1") {
3321
3357
  let logMessage = `
3322
3358
  Extract:`;
@@ -3325,6 +3361,7 @@ Extract:`;
3325
3361
  }
3326
3362
  if (options.inputFile) logMessage += ` inputFile="${options.inputFile}"`;
3327
3363
  if (options.content) logMessage += ` content=(${typeof options.content === "string" ? options.content.length : options.content.byteLength} bytes)`;
3364
+ if (options.cwd) logMessage += ` cwd="${cwd}"`;
3328
3365
  if (options.allowTests) logMessage += " allowTests=true";
3329
3366
  if (options.contextLines) logMessage += ` contextLines=${options.contextLines}`;
3330
3367
  if (options.format) logMessage += ` format=${options.format}`;
@@ -3332,25 +3369,27 @@ Extract:`;
3332
3369
  console.error(logMessage);
3333
3370
  }
3334
3371
  if (hasContent) {
3335
- return extractWithStdin(binaryPath, cliArgs, options.content, options);
3372
+ return extractWithStdin(binaryPath, cliArgs, options.content, options, cwd);
3336
3373
  }
3337
3374
  const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
3338
3375
  try {
3339
- const { stdout, stderr } = await execAsync2(command);
3376
+ const { stdout, stderr } = await execAsync2(command, { cwd });
3340
3377
  if (stderr) {
3341
3378
  console.error(`stderr: ${stderr}`);
3342
3379
  }
3343
3380
  return processExtractOutput(stdout, options);
3344
3381
  } catch (error) {
3345
3382
  const errorMessage = `Error executing extract command: ${error.message}
3346
- Command: ${command}`;
3383
+ Command: ${command}
3384
+ Cwd: ${cwd}`;
3347
3385
  throw new Error(errorMessage);
3348
3386
  }
3349
3387
  }
3350
- function extractWithStdin(binaryPath, cliArgs, content, options) {
3388
+ function extractWithStdin(binaryPath, cliArgs, content, options, cwd) {
3351
3389
  return new Promise((resolve6, reject2) => {
3352
3390
  const childProcess = spawn(binaryPath, ["extract", ...cliArgs], {
3353
- stdio: ["pipe", "pipe", "pipe"]
3391
+ stdio: ["pipe", "pipe", "pipe"],
3392
+ cwd
3354
3393
  });
3355
3394
  let stdout = "";
3356
3395
  let stderr = "";
@@ -3439,6 +3478,7 @@ var init_extract = __esm({
3439
3478
  "src/extract.js"() {
3440
3479
  "use strict";
3441
3480
  init_utils();
3481
+ init_path_validation();
3442
3482
  execAsync2 = promisify4(exec3);
3443
3483
  EXTRACT_FLAG_MAP = {
3444
3484
  allowTests: "--allow-tests",
@@ -3471,7 +3511,7 @@ async function delegate({
3471
3511
  maxIterations = 30,
3472
3512
  tracer = null,
3473
3513
  parentSessionId = null,
3474
- path: path8 = null,
3514
+ path: path9 = null,
3475
3515
  provider = null,
3476
3516
  model = null
3477
3517
  }) {
@@ -3511,7 +3551,7 @@ async function delegate({
3511
3551
  maxIterations: remainingIterations,
3512
3552
  debug,
3513
3553
  tracer,
3514
- path: path8,
3554
+ path: path9,
3515
3555
  // Inherit from parent
3516
3556
  provider,
3517
3557
  // Inherit from parent
@@ -4129,8 +4169,8 @@ var init_parseUtil = __esm({
4129
4169
  init_errors();
4130
4170
  init_en();
4131
4171
  makeIssue = (params) => {
4132
- const { data, path: path8, errorMaps, issueData } = params;
4133
- const fullPath = [...path8, ...issueData.path || []];
4172
+ const { data, path: path9, errorMaps, issueData } = params;
4173
+ const fullPath = [...path9, ...issueData.path || []];
4134
4174
  const fullIssue = {
4135
4175
  ...issueData,
4136
4176
  path: fullPath
@@ -4438,11 +4478,11 @@ var init_types = __esm({
4438
4478
  init_parseUtil();
4439
4479
  init_util2();
4440
4480
  ParseInputLazyPath = class {
4441
- constructor(parent, value, path8, key) {
4481
+ constructor(parent, value, path9, key) {
4442
4482
  this._cachedPath = [];
4443
4483
  this.parent = parent;
4444
4484
  this.data = value;
4445
- this._path = path8;
4485
+ this._path = path9;
4446
4486
  this._key = key;
4447
4487
  }
4448
4488
  get path() {
@@ -8265,15 +8305,15 @@ var init_vercel = __esm({
8265
8305
  name: "search",
8266
8306
  description: searchDescription,
8267
8307
  inputSchema: searchSchema,
8268
- execute: async ({ query: searchQuery, path: path8, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
8308
+ execute: async ({ query: searchQuery, path: path9, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
8269
8309
  try {
8270
8310
  const effectiveMaxTokens = paramMaxTokens || maxTokens;
8271
- let searchPath = path8 || options.defaultPath || ".";
8272
- if ((searchPath === "." || searchPath === "./") && options.defaultPath) {
8311
+ let searchPath = path9 || options.cwd || ".";
8312
+ if ((searchPath === "." || searchPath === "./") && options.cwd) {
8273
8313
  if (debug) {
8274
- console.error(`Using default path "${options.defaultPath}" instead of "${searchPath}"`);
8314
+ console.error(`Using cwd "${options.cwd}" instead of "${searchPath}"`);
8275
8315
  }
8276
- searchPath = options.defaultPath;
8316
+ searchPath = options.cwd;
8277
8317
  }
8278
8318
  if (debug) {
8279
8319
  console.error(`Executing search with query: "${searchQuery}", path: "${searchPath}", exact: ${exact ? "true" : "false"}, language: ${language || "all"}, session: ${sessionId || "none"}`);
@@ -8281,6 +8321,8 @@ var init_vercel = __esm({
8281
8321
  const searchOptions = {
8282
8322
  query: searchQuery,
8283
8323
  path: searchPath,
8324
+ cwd: options.cwd,
8325
+ // Working directory for resolving relative paths
8284
8326
  allowTests: allow_tests,
8285
8327
  exact,
8286
8328
  json: false,
@@ -8308,14 +8350,14 @@ var init_vercel = __esm({
8308
8350
  name: "query",
8309
8351
  description: queryDescription,
8310
8352
  inputSchema: querySchema,
8311
- execute: async ({ pattern, path: path8, language, allow_tests }) => {
8353
+ execute: async ({ pattern, path: path9, language, allow_tests }) => {
8312
8354
  try {
8313
- let queryPath = path8 || options.defaultPath || ".";
8314
- if ((queryPath === "." || queryPath === "./") && options.defaultPath) {
8355
+ let queryPath = path9 || options.cwd || ".";
8356
+ if ((queryPath === "." || queryPath === "./") && options.cwd) {
8315
8357
  if (debug) {
8316
- console.error(`Using default path "${options.defaultPath}" instead of "${queryPath}"`);
8358
+ console.error(`Using cwd "${options.cwd}" instead of "${queryPath}"`);
8317
8359
  }
8318
- queryPath = options.defaultPath;
8360
+ queryPath = options.cwd;
8319
8361
  }
8320
8362
  if (debug) {
8321
8363
  console.error(`Executing query with pattern: "${pattern}", path: "${queryPath}", language: ${language || "auto"}`);
@@ -8323,6 +8365,8 @@ var init_vercel = __esm({
8323
8365
  const results = await query({
8324
8366
  pattern,
8325
8367
  path: queryPath,
8368
+ cwd: options.cwd,
8369
+ // Working directory for resolving relative paths
8326
8370
  language,
8327
8371
  allow_tests,
8328
8372
  json: false
@@ -8343,22 +8387,16 @@ var init_vercel = __esm({
8343
8387
  inputSchema: extractSchema,
8344
8388
  execute: async ({ targets, input_content, line, end_line, allow_tests, context_lines, format }) => {
8345
8389
  try {
8346
- let extractPath = options.defaultPath || ".";
8347
- if ((extractPath === "." || extractPath === "./") && options.defaultPath) {
8348
- if (debug) {
8349
- console.error(`Using default path "${options.defaultPath}" instead of "${extractPath}"`);
8350
- }
8351
- extractPath = options.defaultPath;
8352
- }
8390
+ const effectiveCwd = options.cwd || ".";
8353
8391
  if (debug) {
8354
8392
  if (targets) {
8355
- console.error(`Executing extract with targets: "${targets}", path: "${extractPath}", context lines: ${context_lines || 10}`);
8393
+ console.error(`Executing extract with targets: "${targets}", cwd: "${effectiveCwd}", context lines: ${context_lines || 10}`);
8356
8394
  } else if (input_content) {
8357
- console.error(`Executing extract with input content, path: "${extractPath}", context lines: ${context_lines || 10}`);
8395
+ console.error(`Executing extract with input content, cwd: "${effectiveCwd}", context lines: ${context_lines || 10}`);
8358
8396
  }
8359
8397
  }
8360
8398
  let tempFilePath = null;
8361
- let extractOptions = { path: extractPath };
8399
+ let extractOptions = { cwd: effectiveCwd };
8362
8400
  if (input_content) {
8363
8401
  const { writeFileSync: writeFileSync2, unlinkSync } = await import("fs");
8364
8402
  const { join: join3 } = await import("path");
@@ -8375,6 +8413,7 @@ var init_vercel = __esm({
8375
8413
  }
8376
8414
  extractOptions = {
8377
8415
  inputFile: tempFilePath,
8416
+ cwd: effectiveCwd,
8378
8417
  allowTests: allow_tests,
8379
8418
  contextLines: context_lines,
8380
8419
  format: effectiveFormat
@@ -8387,6 +8426,7 @@ var init_vercel = __esm({
8387
8426
  }
8388
8427
  extractOptions = {
8389
8428
  files,
8429
+ cwd: effectiveCwd,
8390
8430
  allowTests: allow_tests,
8391
8431
  contextLines: context_lines,
8392
8432
  format: effectiveFormat
@@ -8415,12 +8455,12 @@ var init_vercel = __esm({
8415
8455
  });
8416
8456
  };
8417
8457
  delegateTool = (options = {}) => {
8418
- const { debug = false, timeout = 300, defaultPath, allowedFolders } = options;
8458
+ const { debug = false, timeout = 300, cwd, allowedFolders } = options;
8419
8459
  return tool({
8420
8460
  name: "delegate",
8421
8461
  description: delegateDescription,
8422
8462
  inputSchema: delegateSchema,
8423
- execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path8, provider, model, tracer }) => {
8463
+ execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path9, provider, model, tracer }) => {
8424
8464
  if (!task || typeof task !== "string") {
8425
8465
  throw new Error("Task parameter is required and must be a non-empty string");
8426
8466
  }
@@ -8436,7 +8476,7 @@ var init_vercel = __esm({
8436
8476
  if (parentSessionId !== void 0 && parentSessionId !== null && typeof parentSessionId !== "string") {
8437
8477
  throw new TypeError("parentSessionId must be a string, null, or undefined");
8438
8478
  }
8439
- if (path8 !== void 0 && path8 !== null && typeof path8 !== "string") {
8479
+ if (path9 !== void 0 && path9 !== null && typeof path9 !== "string") {
8440
8480
  throw new TypeError("path must be a string, null, or undefined");
8441
8481
  }
8442
8482
  if (provider !== void 0 && provider !== null && typeof provider !== "string") {
@@ -8445,13 +8485,13 @@ var init_vercel = __esm({
8445
8485
  if (model !== void 0 && model !== null && typeof model !== "string") {
8446
8486
  throw new TypeError("model must be a string, null, or undefined");
8447
8487
  }
8448
- const effectivePath = path8 || defaultPath || allowedFolders && allowedFolders[0];
8488
+ const effectivePath = path9 || cwd || allowedFolders && allowedFolders[0];
8449
8489
  if (debug) {
8450
8490
  console.error(`Executing delegate with task: "${task.substring(0, 100)}${task.length > 100 ? "..." : ""}"`);
8451
8491
  if (parentSessionId) {
8452
8492
  console.error(`Parent session: ${parentSessionId}`);
8453
8493
  }
8454
- if (effectivePath && effectivePath !== path8) {
8494
+ if (effectivePath && effectivePath !== path9) {
8455
8495
  console.error(`Using inherited path: ${effectivePath}`);
8456
8496
  }
8457
8497
  }
@@ -9557,7 +9597,7 @@ var init_bash = __esm({
9557
9597
  const {
9558
9598
  bashConfig = {},
9559
9599
  debug = false,
9560
- defaultPath,
9600
+ cwd,
9561
9601
  allowedFolders = []
9562
9602
  } = options;
9563
9603
  const permissionChecker = new BashPermissionChecker({
@@ -9571,8 +9611,8 @@ var init_bash = __esm({
9571
9611
  if (bashConfig.workingDirectory) {
9572
9612
  return bashConfig.workingDirectory;
9573
9613
  }
9574
- if (defaultPath) {
9575
- return defaultPath;
9614
+ if (cwd) {
9615
+ return cwd;
9576
9616
  }
9577
9617
  if (allowedFolders && allowedFolders.length > 0) {
9578
9618
  return allowedFolders[0];
@@ -9717,7 +9757,7 @@ Command failed with exit code ${result.exitCode}`;
9717
9757
 
9718
9758
  // src/tools/edit.js
9719
9759
  import { tool as tool3 } from "ai";
9720
- import { promises as fs5 } from "fs";
9760
+ import { promises as fs6 } from "fs";
9721
9761
  import { dirname, resolve as resolve3, isAbsolute, sep } from "path";
9722
9762
  import { existsSync as existsSync2 } from "fs";
9723
9763
  function isPathAllowed(filePath, allowedFolders) {
@@ -9736,7 +9776,7 @@ function parseFileToolOptions(options = {}) {
9736
9776
  return {
9737
9777
  debug: options.debug || false,
9738
9778
  allowedFolders: options.allowedFolders || [],
9739
- defaultPath: options.defaultPath
9779
+ cwd: options.cwd
9740
9780
  };
9741
9781
  }
9742
9782
  var editTool, createTool, editDescription, createDescription, editToolDefinition, createToolDefinition;
@@ -9744,7 +9784,7 @@ var init_edit = __esm({
9744
9784
  "src/tools/edit.js"() {
9745
9785
  "use strict";
9746
9786
  editTool = (options = {}) => {
9747
- const { debug, allowedFolders, defaultPath } = parseFileToolOptions(options);
9787
+ const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
9748
9788
  return tool3({
9749
9789
  name: "edit",
9750
9790
  description: `Edit files using exact string replacement (Claude Code style).
@@ -9795,7 +9835,7 @@ Important:
9795
9835
  if (new_string === void 0 || new_string === null || typeof new_string !== "string") {
9796
9836
  return `Error editing file: Invalid new_string - must be a string`;
9797
9837
  }
9798
- const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(defaultPath || process.cwd(), file_path);
9838
+ const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(cwd || process.cwd(), file_path);
9799
9839
  if (debug) {
9800
9840
  console.error(`[Edit] Attempting to edit file: ${resolvedPath}`);
9801
9841
  }
@@ -9805,7 +9845,7 @@ Important:
9805
9845
  if (!existsSync2(resolvedPath)) {
9806
9846
  return `Error editing file: File not found - ${file_path}`;
9807
9847
  }
9808
- const content = await fs5.readFile(resolvedPath, "utf-8");
9848
+ const content = await fs6.readFile(resolvedPath, "utf-8");
9809
9849
  if (!content.includes(old_string)) {
9810
9850
  return `Error editing file: String not found - the specified old_string was not found in ${file_path}`;
9811
9851
  }
@@ -9822,7 +9862,7 @@ Important:
9822
9862
  if (newContent === content) {
9823
9863
  return `Error editing file: No changes made - old_string and new_string might be the same`;
9824
9864
  }
9825
- await fs5.writeFile(resolvedPath, newContent, "utf-8");
9865
+ await fs6.writeFile(resolvedPath, newContent, "utf-8");
9826
9866
  const replacedCount = replace_all ? occurrences : 1;
9827
9867
  if (debug) {
9828
9868
  console.error(`[Edit] Successfully edited ${resolvedPath}, replaced ${replacedCount} occurrence(s)`);
@@ -9836,7 +9876,7 @@ Important:
9836
9876
  });
9837
9877
  };
9838
9878
  createTool = (options = {}) => {
9839
- const { debug, allowedFolders, defaultPath } = parseFileToolOptions(options);
9879
+ const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
9840
9880
  return tool3({
9841
9881
  name: "create",
9842
9882
  description: `Create new files with specified content.
@@ -9879,7 +9919,7 @@ Important:
9879
9919
  if (content === void 0 || content === null || typeof content !== "string") {
9880
9920
  return `Error creating file: Invalid content - must be a string`;
9881
9921
  }
9882
- const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(defaultPath || process.cwd(), file_path);
9922
+ const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(cwd || process.cwd(), file_path);
9883
9923
  if (debug) {
9884
9924
  console.error(`[Create] Attempting to create file: ${resolvedPath}`);
9885
9925
  }
@@ -9890,8 +9930,8 @@ Important:
9890
9930
  return `Error creating file: File already exists - ${file_path}. Use overwrite: true to replace it.`;
9891
9931
  }
9892
9932
  const dir = dirname(resolvedPath);
9893
- await fs5.mkdir(dir, { recursive: true });
9894
- await fs5.writeFile(resolvedPath, content, "utf-8");
9933
+ await fs6.mkdir(dir, { recursive: true });
9934
+ await fs6.writeFile(resolvedPath, content, "utf-8");
9895
9935
  const action = existsSync2(resolvedPath) && overwrite ? "overwrote" : "created";
9896
9936
  const bytes = Buffer.byteLength(content, "utf-8");
9897
9937
  if (debug) {
@@ -10161,8 +10201,8 @@ var init_tools = __esm({
10161
10201
  });
10162
10202
 
10163
10203
  // src/utils/file-lister.js
10164
- import fs6 from "fs";
10165
- import path4 from "path";
10204
+ import fs7 from "fs";
10205
+ import path5 from "path";
10166
10206
  import { promisify as promisify6 } from "util";
10167
10207
  import { exec as exec4 } from "child_process";
10168
10208
  async function listFilesByLevel(options) {
@@ -10171,10 +10211,10 @@ async function listFilesByLevel(options) {
10171
10211
  maxFiles = 100,
10172
10212
  respectGitignore = true
10173
10213
  } = options;
10174
- if (!fs6.existsSync(directory)) {
10214
+ if (!fs7.existsSync(directory)) {
10175
10215
  throw new Error(`Directory does not exist: ${directory}`);
10176
10216
  }
10177
- const gitDirExists = fs6.existsSync(path4.join(directory, ".git"));
10217
+ const gitDirExists = fs7.existsSync(path5.join(directory, ".git"));
10178
10218
  if (gitDirExists && respectGitignore) {
10179
10219
  try {
10180
10220
  return await listFilesUsingGit(directory, maxFiles);
@@ -10189,8 +10229,8 @@ async function listFilesUsingGit(directory, maxFiles) {
10189
10229
  const { stdout } = await execAsync3("git ls-files", { cwd: directory });
10190
10230
  const files = stdout.split("\n").filter(Boolean);
10191
10231
  const sortedFiles = files.sort((a, b) => {
10192
- const depthA = a.split(path4.sep).length;
10193
- const depthB = b.split(path4.sep).length;
10232
+ const depthA = a.split(path5.sep).length;
10233
+ const depthB = b.split(path5.sep).length;
10194
10234
  return depthA - depthB;
10195
10235
  });
10196
10236
  return sortedFiles.slice(0, maxFiles);
@@ -10205,25 +10245,25 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
10205
10245
  while (queue.length > 0 && result.length < maxFiles) {
10206
10246
  const { dir, level } = queue.shift();
10207
10247
  try {
10208
- const entries = fs6.readdirSync(dir, { withFileTypes: true });
10248
+ const entries = fs7.readdirSync(dir, { withFileTypes: true });
10209
10249
  const files = entries.filter((entry) => {
10210
- const fullPath = path4.join(dir, entry.name);
10250
+ const fullPath = path5.join(dir, entry.name);
10211
10251
  return getEntryTypeSync(entry, fullPath).isFile;
10212
10252
  });
10213
10253
  for (const file of files) {
10214
10254
  if (result.length >= maxFiles) break;
10215
- const filePath = path4.join(dir, file.name);
10216
- const relativePath = path4.relative(directory, filePath);
10255
+ const filePath = path5.join(dir, file.name);
10256
+ const relativePath = path5.relative(directory, filePath);
10217
10257
  if (shouldIgnore(relativePath, ignorePatterns)) continue;
10218
10258
  result.push(relativePath);
10219
10259
  }
10220
10260
  const dirs = entries.filter((entry) => {
10221
- const fullPath = path4.join(dir, entry.name);
10261
+ const fullPath = path5.join(dir, entry.name);
10222
10262
  return getEntryTypeSync(entry, fullPath).isDirectory;
10223
10263
  });
10224
10264
  for (const subdir of dirs) {
10225
- const subdirPath = path4.join(dir, subdir.name);
10226
- const relativeSubdirPath = path4.relative(directory, subdirPath);
10265
+ const subdirPath = path5.join(dir, subdir.name);
10266
+ const relativeSubdirPath = path5.relative(directory, subdirPath);
10227
10267
  if (shouldIgnore(relativeSubdirPath, ignorePatterns)) continue;
10228
10268
  if (subdir.name === "node_modules" || subdir.name === ".git") continue;
10229
10269
  queue.push({ dir: subdirPath, level: level + 1 });
@@ -10235,12 +10275,12 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
10235
10275
  return result;
10236
10276
  }
10237
10277
  function loadGitignorePatterns(directory) {
10238
- const gitignorePath = path4.join(directory, ".gitignore");
10239
- if (!fs6.existsSync(gitignorePath)) {
10278
+ const gitignorePath = path5.join(directory, ".gitignore");
10279
+ if (!fs7.existsSync(gitignorePath)) {
10240
10280
  return [];
10241
10281
  }
10242
10282
  try {
10243
- const content = fs6.readFileSync(gitignorePath, "utf8");
10283
+ const content = fs7.readFileSync(gitignorePath, "utf8");
10244
10284
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
10245
10285
  } catch (error) {
10246
10286
  console.error(`Warning: Could not read .gitignore: ${error.message}`);
@@ -11337,7 +11377,7 @@ var init_escape = __esm({
11337
11377
  });
11338
11378
 
11339
11379
  // node_modules/minimatch/dist/esm/index.js
11340
- var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path5, sep2, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
11380
+ var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path6, sep2, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
11341
11381
  var init_esm = __esm({
11342
11382
  "node_modules/minimatch/dist/esm/index.js"() {
11343
11383
  import_brace_expansion = __toESM(require_brace_expansion(), 1);
@@ -11406,11 +11446,11 @@ var init_esm = __esm({
11406
11446
  return (f) => f.length === len && f !== "." && f !== "..";
11407
11447
  };
11408
11448
  defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
11409
- path5 = {
11449
+ path6 = {
11410
11450
  win32: { sep: "\\" },
11411
11451
  posix: { sep: "/" }
11412
11452
  };
11413
- sep2 = defaultPlatform === "win32" ? path5.win32.sep : path5.posix.sep;
11453
+ sep2 = defaultPlatform === "win32" ? path6.win32.sep : path6.posix.sep;
11414
11454
  minimatch.sep = sep2;
11415
11455
  GLOBSTAR = Symbol("globstar **");
11416
11456
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -14597,12 +14637,12 @@ var init_esm4 = __esm({
14597
14637
  /**
14598
14638
  * Get the Path object referenced by the string path, resolved from this Path
14599
14639
  */
14600
- resolve(path8) {
14601
- if (!path8) {
14640
+ resolve(path9) {
14641
+ if (!path9) {
14602
14642
  return this;
14603
14643
  }
14604
- const rootPath = this.getRootString(path8);
14605
- const dir = path8.substring(rootPath.length);
14644
+ const rootPath = this.getRootString(path9);
14645
+ const dir = path9.substring(rootPath.length);
14606
14646
  const dirParts = dir.split(this.splitSep);
14607
14647
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
14608
14648
  return result;
@@ -15354,8 +15394,8 @@ var init_esm4 = __esm({
15354
15394
  /**
15355
15395
  * @internal
15356
15396
  */
15357
- getRootString(path8) {
15358
- return win32.parse(path8).root;
15397
+ getRootString(path9) {
15398
+ return win32.parse(path9).root;
15359
15399
  }
15360
15400
  /**
15361
15401
  * @internal
@@ -15401,8 +15441,8 @@ var init_esm4 = __esm({
15401
15441
  /**
15402
15442
  * @internal
15403
15443
  */
15404
- getRootString(path8) {
15405
- return path8.startsWith("/") ? "/" : "";
15444
+ getRootString(path9) {
15445
+ return path9.startsWith("/") ? "/" : "";
15406
15446
  }
15407
15447
  /**
15408
15448
  * @internal
@@ -15451,8 +15491,8 @@ var init_esm4 = __esm({
15451
15491
  *
15452
15492
  * @internal
15453
15493
  */
15454
- constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs9 = defaultFS } = {}) {
15455
- this.#fs = fsFromOption(fs9);
15494
+ constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs10 = defaultFS } = {}) {
15495
+ this.#fs = fsFromOption(fs10);
15456
15496
  if (cwd instanceof URL || cwd.startsWith("file://")) {
15457
15497
  cwd = fileURLToPath4(cwd);
15458
15498
  }
@@ -15491,11 +15531,11 @@ var init_esm4 = __esm({
15491
15531
  /**
15492
15532
  * Get the depth of a provided path, string, or the cwd
15493
15533
  */
15494
- depth(path8 = this.cwd) {
15495
- if (typeof path8 === "string") {
15496
- path8 = this.cwd.resolve(path8);
15534
+ depth(path9 = this.cwd) {
15535
+ if (typeof path9 === "string") {
15536
+ path9 = this.cwd.resolve(path9);
15497
15537
  }
15498
- return path8.depth();
15538
+ return path9.depth();
15499
15539
  }
15500
15540
  /**
15501
15541
  * Return the cache of child entries. Exposed so subclasses can create
@@ -15982,9 +16022,9 @@ var init_esm4 = __esm({
15982
16022
  process2();
15983
16023
  return results;
15984
16024
  }
15985
- chdir(path8 = this.cwd) {
16025
+ chdir(path9 = this.cwd) {
15986
16026
  const oldCwd = this.cwd;
15987
- this.cwd = typeof path8 === "string" ? this.cwd.resolve(path8) : path8;
16027
+ this.cwd = typeof path9 === "string" ? this.cwd.resolve(path9) : path9;
15988
16028
  this.cwd[setAsCwd](oldCwd);
15989
16029
  }
15990
16030
  };
@@ -16010,8 +16050,8 @@ var init_esm4 = __esm({
16010
16050
  /**
16011
16051
  * @internal
16012
16052
  */
16013
- newRoot(fs9) {
16014
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
16053
+ newRoot(fs10) {
16054
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
16015
16055
  }
16016
16056
  /**
16017
16057
  * Return true if the provided path string is an absolute path
@@ -16039,8 +16079,8 @@ var init_esm4 = __esm({
16039
16079
  /**
16040
16080
  * @internal
16041
16081
  */
16042
- newRoot(fs9) {
16043
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
16082
+ newRoot(fs10) {
16083
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
16044
16084
  }
16045
16085
  /**
16046
16086
  * Return true if the provided path string is an absolute path
@@ -16359,8 +16399,8 @@ var init_processor = __esm({
16359
16399
  }
16360
16400
  // match, absolute, ifdir
16361
16401
  entries() {
16362
- return [...this.store.entries()].map(([path8, n]) => [
16363
- path8,
16402
+ return [...this.store.entries()].map(([path9, n]) => [
16403
+ path9,
16364
16404
  !!(n & 2),
16365
16405
  !!(n & 1)
16366
16406
  ]);
@@ -16573,9 +16613,9 @@ var init_walker = __esm({
16573
16613
  signal;
16574
16614
  maxDepth;
16575
16615
  includeChildMatches;
16576
- constructor(patterns, path8, opts) {
16616
+ constructor(patterns, path9, opts) {
16577
16617
  this.patterns = patterns;
16578
- this.path = path8;
16618
+ this.path = path9;
16579
16619
  this.opts = opts;
16580
16620
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
16581
16621
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -16594,11 +16634,11 @@ var init_walker = __esm({
16594
16634
  });
16595
16635
  }
16596
16636
  }
16597
- #ignored(path8) {
16598
- return this.seen.has(path8) || !!this.#ignore?.ignored?.(path8);
16637
+ #ignored(path9) {
16638
+ return this.seen.has(path9) || !!this.#ignore?.ignored?.(path9);
16599
16639
  }
16600
- #childrenIgnored(path8) {
16601
- return !!this.#ignore?.childrenIgnored?.(path8);
16640
+ #childrenIgnored(path9) {
16641
+ return !!this.#ignore?.childrenIgnored?.(path9);
16602
16642
  }
16603
16643
  // backpressure mechanism
16604
16644
  pause() {
@@ -16813,8 +16853,8 @@ var init_walker = __esm({
16813
16853
  };
16814
16854
  GlobWalker = class extends GlobUtil {
16815
16855
  matches = /* @__PURE__ */ new Set();
16816
- constructor(patterns, path8, opts) {
16817
- super(patterns, path8, opts);
16856
+ constructor(patterns, path9, opts) {
16857
+ super(patterns, path9, opts);
16818
16858
  }
16819
16859
  matchEmit(e) {
16820
16860
  this.matches.add(e);
@@ -16851,8 +16891,8 @@ var init_walker = __esm({
16851
16891
  };
16852
16892
  GlobStream = class extends GlobUtil {
16853
16893
  results;
16854
- constructor(patterns, path8, opts) {
16855
- super(patterns, path8, opts);
16894
+ constructor(patterns, path9, opts) {
16895
+ super(patterns, path9, opts);
16856
16896
  this.results = new Minipass({
16857
16897
  signal: this.signal,
16858
16898
  objectMode: true
@@ -17180,9 +17220,9 @@ import { exec as exec5 } from "child_process";
17180
17220
  import { promisify as promisify7 } from "util";
17181
17221
  import { randomUUID as randomUUID2 } from "crypto";
17182
17222
  import { EventEmitter as EventEmitter2 } from "events";
17183
- import fs7 from "fs";
17223
+ import fs8 from "fs";
17184
17224
  import { promises as fsPromises2 } from "fs";
17185
- import path6 from "path";
17225
+ import path7 from "path";
17186
17226
  function isSessionCancelled(sessionId) {
17187
17227
  return activeToolExecutions.get(sessionId)?.cancelled || false;
17188
17228
  }
@@ -17349,17 +17389,17 @@ var init_probeTool = __esm({
17349
17389
  execute: async (params) => {
17350
17390
  const { directory = ".", workingDirectory } = params;
17351
17391
  const baseCwd = workingDirectory || process.cwd();
17352
- const secureBaseDir = path6.resolve(baseCwd);
17392
+ const secureBaseDir = path7.resolve(baseCwd);
17353
17393
  const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
17354
17394
  let targetDir;
17355
- if (path6.isAbsolute(directory)) {
17356
- targetDir = path6.resolve(directory);
17357
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17395
+ if (path7.isAbsolute(directory)) {
17396
+ targetDir = path7.resolve(directory);
17397
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17358
17398
  throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
17359
17399
  }
17360
17400
  } else {
17361
- targetDir = path6.resolve(secureBaseDir, directory);
17362
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17401
+ targetDir = path7.resolve(secureBaseDir, directory);
17402
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17363
17403
  throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
17364
17404
  }
17365
17405
  }
@@ -17376,7 +17416,7 @@ var init_probeTool = __esm({
17376
17416
  return `${(size / (1024 * 1024 * 1024)).toFixed(1)}G`;
17377
17417
  };
17378
17418
  const entries = await Promise.all(files.map(async (file) => {
17379
- const fullPath = path6.join(targetDir, file.name);
17419
+ const fullPath = path7.join(targetDir, file.name);
17380
17420
  const entryType = await getEntryType(file, fullPath);
17381
17421
  return {
17382
17422
  name: file.name,
@@ -17413,17 +17453,17 @@ var init_probeTool = __esm({
17413
17453
  throw new Error("Pattern is required for file search");
17414
17454
  }
17415
17455
  const baseCwd = workingDirectory || process.cwd();
17416
- const secureBaseDir = path6.resolve(baseCwd);
17456
+ const secureBaseDir = path7.resolve(baseCwd);
17417
17457
  const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
17418
17458
  let targetDir;
17419
- if (path6.isAbsolute(directory)) {
17420
- targetDir = path6.resolve(directory);
17421
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17459
+ if (path7.isAbsolute(directory)) {
17460
+ targetDir = path7.resolve(directory);
17461
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17422
17462
  throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
17423
17463
  }
17424
17464
  } else {
17425
- targetDir = path6.resolve(secureBaseDir, directory);
17426
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17465
+ targetDir = path7.resolve(secureBaseDir, directory);
17466
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17427
17467
  throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
17428
17468
  }
17429
17469
  }
@@ -19550,11 +19590,11 @@ var init_toKey = __esm({
19550
19590
  });
19551
19591
 
19552
19592
  // node_modules/lodash-es/_baseGet.js
19553
- function baseGet(object, path8) {
19554
- path8 = castPath_default(path8, object);
19555
- var index = 0, length = path8.length;
19593
+ function baseGet(object, path9) {
19594
+ path9 = castPath_default(path9, object);
19595
+ var index = 0, length = path9.length;
19556
19596
  while (object != null && index < length) {
19557
- object = object[toKey_default(path8[index++])];
19597
+ object = object[toKey_default(path9[index++])];
19558
19598
  }
19559
19599
  return index && index == length ? object : void 0;
19560
19600
  }
@@ -19568,8 +19608,8 @@ var init_baseGet = __esm({
19568
19608
  });
19569
19609
 
19570
19610
  // node_modules/lodash-es/get.js
19571
- function get(object, path8, defaultValue) {
19572
- var result = object == null ? void 0 : baseGet_default(object, path8);
19611
+ function get(object, path9, defaultValue) {
19612
+ var result = object == null ? void 0 : baseGet_default(object, path9);
19573
19613
  return result === void 0 ? defaultValue : result;
19574
19614
  }
19575
19615
  var get_default;
@@ -20932,11 +20972,11 @@ var init_baseHasIn = __esm({
20932
20972
  });
20933
20973
 
20934
20974
  // node_modules/lodash-es/_hasPath.js
20935
- function hasPath(object, path8, hasFunc) {
20936
- path8 = castPath_default(path8, object);
20937
- var index = -1, length = path8.length, result = false;
20975
+ function hasPath(object, path9, hasFunc) {
20976
+ path9 = castPath_default(path9, object);
20977
+ var index = -1, length = path9.length, result = false;
20938
20978
  while (++index < length) {
20939
- var key = toKey_default(path8[index]);
20979
+ var key = toKey_default(path9[index]);
20940
20980
  if (!(result = object != null && hasFunc(object, key))) {
20941
20981
  break;
20942
20982
  }
@@ -20962,8 +21002,8 @@ var init_hasPath = __esm({
20962
21002
  });
20963
21003
 
20964
21004
  // node_modules/lodash-es/hasIn.js
20965
- function hasIn(object, path8) {
20966
- return object != null && hasPath_default(object, path8, baseHasIn_default);
21005
+ function hasIn(object, path9) {
21006
+ return object != null && hasPath_default(object, path9, baseHasIn_default);
20967
21007
  }
20968
21008
  var hasIn_default;
20969
21009
  var init_hasIn = __esm({
@@ -20975,13 +21015,13 @@ var init_hasIn = __esm({
20975
21015
  });
20976
21016
 
20977
21017
  // node_modules/lodash-es/_baseMatchesProperty.js
20978
- function baseMatchesProperty(path8, srcValue) {
20979
- if (isKey_default(path8) && isStrictComparable_default(srcValue)) {
20980
- return matchesStrictComparable_default(toKey_default(path8), srcValue);
21018
+ function baseMatchesProperty(path9, srcValue) {
21019
+ if (isKey_default(path9) && isStrictComparable_default(srcValue)) {
21020
+ return matchesStrictComparable_default(toKey_default(path9), srcValue);
20981
21021
  }
20982
21022
  return function(object) {
20983
- var objValue = get_default(object, path8);
20984
- return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path8) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
21023
+ var objValue = get_default(object, path9);
21024
+ return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path9) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
20985
21025
  };
20986
21026
  }
20987
21027
  var COMPARE_PARTIAL_FLAG6, COMPARE_UNORDERED_FLAG4, baseMatchesProperty_default;
@@ -21014,9 +21054,9 @@ var init_baseProperty = __esm({
21014
21054
  });
21015
21055
 
21016
21056
  // node_modules/lodash-es/_basePropertyDeep.js
21017
- function basePropertyDeep(path8) {
21057
+ function basePropertyDeep(path9) {
21018
21058
  return function(object) {
21019
- return baseGet_default(object, path8);
21059
+ return baseGet_default(object, path9);
21020
21060
  };
21021
21061
  }
21022
21062
  var basePropertyDeep_default;
@@ -21028,8 +21068,8 @@ var init_basePropertyDeep = __esm({
21028
21068
  });
21029
21069
 
21030
21070
  // node_modules/lodash-es/property.js
21031
- function property(path8) {
21032
- return isKey_default(path8) ? baseProperty_default(toKey_default(path8)) : basePropertyDeep_default(path8);
21071
+ function property(path9) {
21072
+ return isKey_default(path9) ? baseProperty_default(toKey_default(path9)) : basePropertyDeep_default(path9);
21033
21073
  }
21034
21074
  var property_default;
21035
21075
  var init_property = __esm({
@@ -21648,8 +21688,8 @@ var init_baseHas = __esm({
21648
21688
  });
21649
21689
 
21650
21690
  // node_modules/lodash-es/has.js
21651
- function has(object, path8) {
21652
- return object != null && hasPath_default(object, path8, baseHas_default);
21691
+ function has(object, path9) {
21692
+ return object != null && hasPath_default(object, path9, baseHas_default);
21653
21693
  }
21654
21694
  var has_default;
21655
21695
  var init_has = __esm({
@@ -21855,14 +21895,14 @@ var init_negate = __esm({
21855
21895
  });
21856
21896
 
21857
21897
  // node_modules/lodash-es/_baseSet.js
21858
- function baseSet(object, path8, value, customizer) {
21898
+ function baseSet(object, path9, value, customizer) {
21859
21899
  if (!isObject_default(object)) {
21860
21900
  return object;
21861
21901
  }
21862
- path8 = castPath_default(path8, object);
21863
- var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
21902
+ path9 = castPath_default(path9, object);
21903
+ var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
21864
21904
  while (nested != null && ++index < length) {
21865
- var key = toKey_default(path8[index]), newValue = value;
21905
+ var key = toKey_default(path9[index]), newValue = value;
21866
21906
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
21867
21907
  return object;
21868
21908
  }
@@ -21870,7 +21910,7 @@ function baseSet(object, path8, value, customizer) {
21870
21910
  var objValue = nested[key];
21871
21911
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
21872
21912
  if (newValue === void 0) {
21873
- newValue = isObject_default(objValue) ? objValue : isIndex_default(path8[index + 1]) ? [] : {};
21913
+ newValue = isObject_default(objValue) ? objValue : isIndex_default(path9[index + 1]) ? [] : {};
21874
21914
  }
21875
21915
  }
21876
21916
  assignValue_default(nested, key, newValue);
@@ -21894,9 +21934,9 @@ var init_baseSet = __esm({
21894
21934
  function basePickBy(object, paths, predicate) {
21895
21935
  var index = -1, length = paths.length, result = {};
21896
21936
  while (++index < length) {
21897
- var path8 = paths[index], value = baseGet_default(object, path8);
21898
- if (predicate(value, path8)) {
21899
- baseSet_default(result, castPath_default(path8, object), value);
21937
+ var path9 = paths[index], value = baseGet_default(object, path9);
21938
+ if (predicate(value, path9)) {
21939
+ baseSet_default(result, castPath_default(path9, object), value);
21900
21940
  }
21901
21941
  }
21902
21942
  return result;
@@ -21920,8 +21960,8 @@ function pickBy(object, predicate) {
21920
21960
  return [prop];
21921
21961
  });
21922
21962
  predicate = baseIteratee_default(predicate);
21923
- return basePickBy_default(object, props, function(value, path8) {
21924
- return predicate(value, path8[0]);
21963
+ return basePickBy_default(object, props, function(value, path9) {
21964
+ return predicate(value, path9[0]);
21925
21965
  });
21926
21966
  }
21927
21967
  var pickBy_default;
@@ -24634,12 +24674,12 @@ function assignCategoriesMapProp(tokenTypes) {
24634
24674
  singleAssignCategoriesToksMap([], currTokType);
24635
24675
  });
24636
24676
  }
24637
- function singleAssignCategoriesToksMap(path8, nextNode) {
24638
- forEach_default(path8, (pathNode) => {
24677
+ function singleAssignCategoriesToksMap(path9, nextNode) {
24678
+ forEach_default(path9, (pathNode) => {
24639
24679
  nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;
24640
24680
  });
24641
24681
  forEach_default(nextNode.CATEGORIES, (nextCategory) => {
24642
- const newPath = path8.concat(nextNode);
24682
+ const newPath = path9.concat(nextNode);
24643
24683
  if (!includes_default(newPath, nextCategory)) {
24644
24684
  singleAssignCategoriesToksMap(newPath, nextCategory);
24645
24685
  }
@@ -25809,10 +25849,10 @@ var init_interpreter = __esm({
25809
25849
  init_rest();
25810
25850
  init_api2();
25811
25851
  AbstractNextPossibleTokensWalker = class extends RestWalker {
25812
- constructor(topProd, path8) {
25852
+ constructor(topProd, path9) {
25813
25853
  super();
25814
25854
  this.topProd = topProd;
25815
- this.path = path8;
25855
+ this.path = path9;
25816
25856
  this.possibleTokTypes = [];
25817
25857
  this.nextProductionName = "";
25818
25858
  this.nextProductionOccurrence = 0;
@@ -25856,9 +25896,9 @@ var init_interpreter = __esm({
25856
25896
  }
25857
25897
  };
25858
25898
  NextAfterTokenWalker = class extends AbstractNextPossibleTokensWalker {
25859
- constructor(topProd, path8) {
25860
- super(topProd, path8);
25861
- this.path = path8;
25899
+ constructor(topProd, path9) {
25900
+ super(topProd, path9);
25901
+ this.path = path9;
25862
25902
  this.nextTerminalName = "";
25863
25903
  this.nextTerminalOccurrence = 0;
25864
25904
  this.nextTerminalName = this.path.lastTok.name;
@@ -26099,10 +26139,10 @@ function initializeArrayOfArrays(size) {
26099
26139
  }
26100
26140
  return result;
26101
26141
  }
26102
- function pathToHashKeys(path8) {
26142
+ function pathToHashKeys(path9) {
26103
26143
  let keys2 = [""];
26104
- for (let i = 0; i < path8.length; i++) {
26105
- const tokType = path8[i];
26144
+ for (let i = 0; i < path9.length; i++) {
26145
+ const tokType = path9[i];
26106
26146
  const longerKeys = [];
26107
26147
  for (let j = 0; j < keys2.length; j++) {
26108
26148
  const currShorterKey = keys2[j];
@@ -26405,7 +26445,7 @@ function validateRuleIsOverridden(ruleName, definedRulesNames, className) {
26405
26445
  }
26406
26446
  return errors;
26407
26447
  }
26408
- function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = []) {
26448
+ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path9 = []) {
26409
26449
  const errors = [];
26410
26450
  const nextNonTerminals = getFirstNoneTerminal(currRule.definition);
26411
26451
  if (isEmpty_default(nextNonTerminals)) {
@@ -26417,15 +26457,15 @@ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = [])
26417
26457
  errors.push({
26418
26458
  message: errMsgProvider.buildLeftRecursionError({
26419
26459
  topLevelRule: topRule,
26420
- leftRecursionPath: path8
26460
+ leftRecursionPath: path9
26421
26461
  }),
26422
26462
  type: ParserDefinitionErrorType.LEFT_RECURSION,
26423
26463
  ruleName
26424
26464
  });
26425
26465
  }
26426
- const validNextSteps = difference_default(nextNonTerminals, path8.concat([topRule]));
26466
+ const validNextSteps = difference_default(nextNonTerminals, path9.concat([topRule]));
26427
26467
  const errorsFromNextSteps = flatMap_default(validNextSteps, (currRefRule) => {
26428
- const newPath = clone_default(path8);
26468
+ const newPath = clone_default(path9);
26429
26469
  newPath.push(currRefRule);
26430
26470
  return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);
26431
26471
  });
@@ -39029,11 +39069,11 @@ var require_baseGet = __commonJS({
39029
39069
  "node_modules/lodash/_baseGet.js"(exports2, module2) {
39030
39070
  var castPath2 = require_castPath();
39031
39071
  var toKey2 = require_toKey();
39032
- function baseGet2(object, path8) {
39033
- path8 = castPath2(path8, object);
39034
- var index = 0, length = path8.length;
39072
+ function baseGet2(object, path9) {
39073
+ path9 = castPath2(path9, object);
39074
+ var index = 0, length = path9.length;
39035
39075
  while (object != null && index < length) {
39036
- object = object[toKey2(path8[index++])];
39076
+ object = object[toKey2(path9[index++])];
39037
39077
  }
39038
39078
  return index && index == length ? object : void 0;
39039
39079
  }
@@ -39045,8 +39085,8 @@ var require_baseGet = __commonJS({
39045
39085
  var require_get = __commonJS({
39046
39086
  "node_modules/lodash/get.js"(exports2, module2) {
39047
39087
  var baseGet2 = require_baseGet();
39048
- function get2(object, path8, defaultValue) {
39049
- var result = object == null ? void 0 : baseGet2(object, path8);
39088
+ function get2(object, path9, defaultValue) {
39089
+ var result = object == null ? void 0 : baseGet2(object, path9);
39050
39090
  return result === void 0 ? defaultValue : result;
39051
39091
  }
39052
39092
  module2.exports = get2;
@@ -39072,11 +39112,11 @@ var require_hasPath = __commonJS({
39072
39112
  var isIndex2 = require_isIndex();
39073
39113
  var isLength2 = require_isLength();
39074
39114
  var toKey2 = require_toKey();
39075
- function hasPath2(object, path8, hasFunc) {
39076
- path8 = castPath2(path8, object);
39077
- var index = -1, length = path8.length, result = false;
39115
+ function hasPath2(object, path9, hasFunc) {
39116
+ path9 = castPath2(path9, object);
39117
+ var index = -1, length = path9.length, result = false;
39078
39118
  while (++index < length) {
39079
- var key = toKey2(path8[index]);
39119
+ var key = toKey2(path9[index]);
39080
39120
  if (!(result = object != null && hasFunc(object, key))) {
39081
39121
  break;
39082
39122
  }
@@ -39097,8 +39137,8 @@ var require_hasIn = __commonJS({
39097
39137
  "node_modules/lodash/hasIn.js"(exports2, module2) {
39098
39138
  var baseHasIn2 = require_baseHasIn();
39099
39139
  var hasPath2 = require_hasPath();
39100
- function hasIn2(object, path8) {
39101
- return object != null && hasPath2(object, path8, baseHasIn2);
39140
+ function hasIn2(object, path9) {
39141
+ return object != null && hasPath2(object, path9, baseHasIn2);
39102
39142
  }
39103
39143
  module2.exports = hasIn2;
39104
39144
  }
@@ -39116,13 +39156,13 @@ var require_baseMatchesProperty = __commonJS({
39116
39156
  var toKey2 = require_toKey();
39117
39157
  var COMPARE_PARTIAL_FLAG7 = 1;
39118
39158
  var COMPARE_UNORDERED_FLAG5 = 2;
39119
- function baseMatchesProperty2(path8, srcValue) {
39120
- if (isKey2(path8) && isStrictComparable2(srcValue)) {
39121
- return matchesStrictComparable2(toKey2(path8), srcValue);
39159
+ function baseMatchesProperty2(path9, srcValue) {
39160
+ if (isKey2(path9) && isStrictComparable2(srcValue)) {
39161
+ return matchesStrictComparable2(toKey2(path9), srcValue);
39122
39162
  }
39123
39163
  return function(object) {
39124
- var objValue = get2(object, path8);
39125
- return objValue === void 0 && objValue === srcValue ? hasIn2(object, path8) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
39164
+ var objValue = get2(object, path9);
39165
+ return objValue === void 0 && objValue === srcValue ? hasIn2(object, path9) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
39126
39166
  };
39127
39167
  }
39128
39168
  module2.exports = baseMatchesProperty2;
@@ -39145,9 +39185,9 @@ var require_baseProperty = __commonJS({
39145
39185
  var require_basePropertyDeep = __commonJS({
39146
39186
  "node_modules/lodash/_basePropertyDeep.js"(exports2, module2) {
39147
39187
  var baseGet2 = require_baseGet();
39148
- function basePropertyDeep2(path8) {
39188
+ function basePropertyDeep2(path9) {
39149
39189
  return function(object) {
39150
- return baseGet2(object, path8);
39190
+ return baseGet2(object, path9);
39151
39191
  };
39152
39192
  }
39153
39193
  module2.exports = basePropertyDeep2;
@@ -39161,8 +39201,8 @@ var require_property = __commonJS({
39161
39201
  var basePropertyDeep2 = require_basePropertyDeep();
39162
39202
  var isKey2 = require_isKey();
39163
39203
  var toKey2 = require_toKey();
39164
- function property2(path8) {
39165
- return isKey2(path8) ? baseProperty2(toKey2(path8)) : basePropertyDeep2(path8);
39204
+ function property2(path9) {
39205
+ return isKey2(path9) ? baseProperty2(toKey2(path9)) : basePropertyDeep2(path9);
39166
39206
  }
39167
39207
  module2.exports = property2;
39168
39208
  }
@@ -39224,8 +39264,8 @@ var require_has = __commonJS({
39224
39264
  "node_modules/lodash/has.js"(exports2, module2) {
39225
39265
  var baseHas2 = require_baseHas();
39226
39266
  var hasPath2 = require_hasPath();
39227
- function has2(object, path8) {
39228
- return object != null && hasPath2(object, path8, baseHas2);
39267
+ function has2(object, path9) {
39268
+ return object != null && hasPath2(object, path9, baseHas2);
39229
39269
  }
39230
39270
  module2.exports = has2;
39231
39271
  }
@@ -41499,14 +41539,14 @@ var require_baseSet = __commonJS({
41499
41539
  var isIndex2 = require_isIndex();
41500
41540
  var isObject2 = require_isObject();
41501
41541
  var toKey2 = require_toKey();
41502
- function baseSet2(object, path8, value, customizer) {
41542
+ function baseSet2(object, path9, value, customizer) {
41503
41543
  if (!isObject2(object)) {
41504
41544
  return object;
41505
41545
  }
41506
- path8 = castPath2(path8, object);
41507
- var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
41546
+ path9 = castPath2(path9, object);
41547
+ var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
41508
41548
  while (nested != null && ++index < length) {
41509
- var key = toKey2(path8[index]), newValue = value;
41549
+ var key = toKey2(path9[index]), newValue = value;
41510
41550
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
41511
41551
  return object;
41512
41552
  }
@@ -41514,7 +41554,7 @@ var require_baseSet = __commonJS({
41514
41554
  var objValue = nested[key];
41515
41555
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
41516
41556
  if (newValue === void 0) {
41517
- newValue = isObject2(objValue) ? objValue : isIndex2(path8[index + 1]) ? [] : {};
41557
+ newValue = isObject2(objValue) ? objValue : isIndex2(path9[index + 1]) ? [] : {};
41518
41558
  }
41519
41559
  }
41520
41560
  assignValue2(nested, key, newValue);
@@ -41535,9 +41575,9 @@ var require_basePickBy = __commonJS({
41535
41575
  function basePickBy2(object, paths, predicate) {
41536
41576
  var index = -1, length = paths.length, result = {};
41537
41577
  while (++index < length) {
41538
- var path8 = paths[index], value = baseGet2(object, path8);
41539
- if (predicate(value, path8)) {
41540
- baseSet2(result, castPath2(path8, object), value);
41578
+ var path9 = paths[index], value = baseGet2(object, path9);
41579
+ if (predicate(value, path9)) {
41580
+ baseSet2(result, castPath2(path9, object), value);
41541
41581
  }
41542
41582
  }
41543
41583
  return result;
@@ -41552,8 +41592,8 @@ var require_basePick = __commonJS({
41552
41592
  var basePickBy2 = require_basePickBy();
41553
41593
  var hasIn2 = require_hasIn();
41554
41594
  function basePick(object, paths) {
41555
- return basePickBy2(object, paths, function(value, path8) {
41556
- return hasIn2(object, path8);
41595
+ return basePickBy2(object, paths, function(value, path9) {
41596
+ return hasIn2(object, path9);
41557
41597
  });
41558
41598
  }
41559
41599
  module2.exports = basePick;
@@ -42607,15 +42647,15 @@ var require_parent_dummy_chains = __commonJS({
42607
42647
  var node = g.node(v);
42608
42648
  var edgeObj = node.edgeObj;
42609
42649
  var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w);
42610
- var path8 = pathData.path;
42650
+ var path9 = pathData.path;
42611
42651
  var lca = pathData.lca;
42612
42652
  var pathIdx = 0;
42613
- var pathV = path8[pathIdx];
42653
+ var pathV = path9[pathIdx];
42614
42654
  var ascending = true;
42615
42655
  while (v !== edgeObj.w) {
42616
42656
  node = g.node(v);
42617
42657
  if (ascending) {
42618
- while ((pathV = path8[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) {
42658
+ while ((pathV = path9[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) {
42619
42659
  pathIdx++;
42620
42660
  }
42621
42661
  if (pathV === lca) {
@@ -42623,10 +42663,10 @@ var require_parent_dummy_chains = __commonJS({
42623
42663
  }
42624
42664
  }
42625
42665
  if (!ascending) {
42626
- while (pathIdx < path8.length - 1 && g.node(pathV = path8[pathIdx + 1]).minRank <= node.rank) {
42666
+ while (pathIdx < path9.length - 1 && g.node(pathV = path9[pathIdx + 1]).minRank <= node.rank) {
42627
42667
  pathIdx++;
42628
42668
  }
42629
- pathV = path8[pathIdx];
42669
+ pathV = path9[pathIdx];
42630
42670
  }
42631
42671
  g.setParent(v, pathV);
42632
42672
  v = g.successors(v)[0];
@@ -44799,8 +44839,8 @@ var init_svg_generator = __esm({
44799
44839
  elements.push(this.generateNodeWithPad(node, padX, padY));
44800
44840
  }
44801
44841
  for (const edge of layout.edges) {
44802
- const { path: path8, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
44803
- elements.push(path8);
44842
+ const { path: path9, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
44843
+ elements.push(path9);
44804
44844
  if (overlay)
44805
44845
  overlays.push(overlay);
44806
44846
  }
@@ -51116,8 +51156,8 @@ var require_utils = __commonJS({
51116
51156
  }
51117
51157
  return ind;
51118
51158
  }
51119
- function removeDotSegments(path8) {
51120
- let input = path8;
51159
+ function removeDotSegments(path9) {
51160
+ let input = path9;
51121
51161
  const output = [];
51122
51162
  let nextSlash = -1;
51123
51163
  let len = 0;
@@ -51316,8 +51356,8 @@ var require_schemes = __commonJS({
51316
51356
  wsComponent.secure = void 0;
51317
51357
  }
51318
51358
  if (wsComponent.resourceName) {
51319
- const [path8, query2] = wsComponent.resourceName.split("?");
51320
- wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
51359
+ const [path9, query2] = wsComponent.resourceName.split("?");
51360
+ wsComponent.path = path9 && path9 !== "/" ? path9 : void 0;
51321
51361
  wsComponent.query = query2;
51322
51362
  wsComponent.resourceName = void 0;
51323
51363
  }
@@ -54660,7 +54700,7 @@ function validateJsonResponse(response, options = {}) {
54660
54700
  }
54661
54701
  if (!valid) {
54662
54702
  const formattedErrors = validate2.errors.map((err) => {
54663
- const path8 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
54703
+ const path9 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
54664
54704
  let message = "";
54665
54705
  let suggestion = "";
54666
54706
  if (err.keyword === "additionalProperties") {
@@ -54698,7 +54738,7 @@ function validateJsonResponse(response, options = {}) {
54698
54738
  message = err.message;
54699
54739
  suggestion = "";
54700
54740
  }
54701
- const location = path8 ? `at '${path8}'` : "at root";
54741
+ const location = path9 ? `at '${path9}'` : "at root";
54702
54742
  return suggestion ? `${location}: ${message} \u2192 ${suggestion}` : `${location}: ${message}`;
54703
54743
  });
54704
54744
  const errorSummary = formattedErrors.join("\n ");
@@ -55021,7 +55061,7 @@ function extractMermaidFromJson(response) {
55021
55061
  }
55022
55062
  const diagrams = [];
55023
55063
  const jsonPaths = [];
55024
- function searchObject(obj, path8 = []) {
55064
+ function searchObject(obj, path9 = []) {
55025
55065
  if (typeof obj === "string") {
55026
55066
  const mermaidPattern = /```mermaid([^\n`]*?)(?:\n|\\n)([\s\S]*?)```/gi;
55027
55067
  let match2;
@@ -55035,14 +55075,14 @@ function extractMermaidFromJson(response) {
55035
55075
  endIndex: match2.index + match2[0].length,
55036
55076
  attributes,
55037
55077
  isInJson: true,
55038
- jsonPath: path8.join(".")
55078
+ jsonPath: path9.join(".")
55039
55079
  });
55040
- jsonPaths.push(path8.join("."));
55080
+ jsonPaths.push(path9.join("."));
55041
55081
  }
55042
55082
  } else if (Array.isArray(obj)) {
55043
- obj.forEach((item, index) => searchObject(item, [...path8, `[${index}]`]));
55083
+ obj.forEach((item, index) => searchObject(item, [...path9, `[${index}]`]));
55044
55084
  } else if (obj && typeof obj === "object") {
55045
- Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path8, key]));
55085
+ Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path9, key]));
55046
55086
  }
55047
55087
  }
55048
55088
  searchObject(parsedJson);
@@ -55299,7 +55339,7 @@ async function tryMaidAutoFix(diagramContent, options = {}) {
55299
55339
  }
55300
55340
  }
55301
55341
  async function validateAndFixMermaidResponse(response, options = {}) {
55302
- const { schema, debug, path: path8, provider, model, tracer } = options;
55342
+ const { schema, debug, path: path9, provider, model, tracer } = options;
55303
55343
  const startTime = Date.now();
55304
55344
  if (debug) {
55305
55345
  console.log(`[DEBUG] Mermaid validation: Starting maid-based validation for response (${response.length} chars)`);
@@ -55456,7 +55496,7 @@ ${maidResult.fixed}
55456
55496
  }
55457
55497
  const aiFixingStart = Date.now();
55458
55498
  const mermaidFixer = new MermaidFixingAgent({
55459
- path: path8,
55499
+ path: path9,
55460
55500
  provider,
55461
55501
  model,
55462
55502
  debug,
@@ -55698,8 +55738,8 @@ Schema Validation Errors:
55698
55738
  ${validationResult.errorSummary}`;
55699
55739
  } else if (validationResult.schemaErrors && validationResult.schemaErrors.length > 0) {
55700
55740
  const errors = validationResult.schemaErrors.map((err) => {
55701
- const path8 = err.instancePath || "(root)";
55702
- return ` ${path8}: ${err.message}`;
55741
+ const path9 = err.instancePath || "(root)";
55742
+ return ` ${path9}: ${err.message}`;
55703
55743
  }).join("\n");
55704
55744
  schemaErrorDetails = `
55705
55745
 
@@ -58307,8 +58347,8 @@ __export(enhanced_claude_code_exports, {
58307
58347
  });
58308
58348
  import { spawn as spawn3 } from "child_process";
58309
58349
  import { randomBytes } from "crypto";
58310
- import fs8 from "fs/promises";
58311
- import path7 from "path";
58350
+ import fs9 from "fs/promises";
58351
+ import path8 from "path";
58312
58352
  import os3 from "os";
58313
58353
  import { EventEmitter as EventEmitter4 } from "events";
58314
58354
  async function createEnhancedClaudeCLIEngine(options = {}) {
@@ -58331,12 +58371,12 @@ async function createEnhancedClaudeCLIEngine(options = {}) {
58331
58371
  console.log("[DEBUG] Built-in MCP server started");
58332
58372
  console.log("[DEBUG] MCP URL:", `http://${host}:${port}/mcp`);
58333
58373
  }
58334
- mcpConfigPath = path7.join(os3.tmpdir(), `probe-mcp-${session.id}.json`);
58374
+ mcpConfigPath = path8.join(os3.tmpdir(), `probe-mcp-${session.id}.json`);
58335
58375
  const mcpConfig = {
58336
58376
  mcpServers: {
58337
58377
  probe: {
58338
58378
  command: "node",
58339
- args: [path7.join(process.cwd(), "mcp-probe-server.js")],
58379
+ args: [path8.join(process.cwd(), "mcp-probe-server.js")],
58340
58380
  env: {
58341
58381
  PROBE_WORKSPACE: process.cwd(),
58342
58382
  DEBUG: debug ? "true" : "false"
@@ -58344,7 +58384,7 @@ async function createEnhancedClaudeCLIEngine(options = {}) {
58344
58384
  }
58345
58385
  }
58346
58386
  };
58347
- await fs8.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
58387
+ await fs9.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
58348
58388
  }
58349
58389
  if (debug) {
58350
58390
  console.log("[DEBUG] Enhanced Claude Code Engine");
@@ -58538,7 +58578,7 @@ ${opts.schema}`;
58538
58578
  }
58539
58579
  }
58540
58580
  if (mcpConfigPath) {
58541
- await fs8.unlink(mcpConfigPath).catch(() => {
58581
+ await fs9.unlink(mcpConfigPath).catch(() => {
58542
58582
  });
58543
58583
  if (debug) {
58544
58584
  console.log("[DEBUG] MCP config file removed");
@@ -59113,6 +59153,7 @@ var init_ProbeAgent = __esm({
59113
59153
  * @param {boolean} [options.allowEdit=false] - Allow the use of the 'implement' tool
59114
59154
  * @param {boolean} [options.enableDelegate=false] - Enable the delegate tool for task distribution to subagents
59115
59155
  * @param {string} [options.path] - Search directory path
59156
+ * @param {string} [options.cwd] - Working directory for resolving relative paths (independent of allowedFolders)
59116
59157
  * @param {string} [options.provider] - Force specific AI provider
59117
59158
  * @param {string} [options.model] - Override model name
59118
59159
  * @param {boolean} [options.debug] - Enable debug mode
@@ -59141,6 +59182,7 @@ var init_ProbeAgent = __esm({
59141
59182
  * @param {Array<Object>} [options.fallback.providers] - List of provider configurations for custom fallback
59142
59183
  * @param {boolean} [options.fallback.stopOnSuccess=true] - Stop on first success
59143
59184
  * @param {number} [options.fallback.maxTotalAttempts=10] - Maximum total attempts across all providers
59185
+ * @param {string} [options.completionPrompt] - Custom prompt to run after attempt_completion for validation/review (runs before mermaid/JSON validation)
59144
59186
  */
59145
59187
  constructor(options = {}) {
59146
59188
  this.sessionId = options.sessionId || randomUUID5();
@@ -59162,6 +59204,7 @@ var init_ProbeAgent = __esm({
59162
59204
  this.maxIterations = options.maxIterations || null;
59163
59205
  this.disableMermaidValidation = !!options.disableMermaidValidation;
59164
59206
  this.disableJsonValidation = !!options.disableJsonValidation;
59207
+ this.completionPrompt = options.completionPrompt || null;
59165
59208
  const effectiveAllowedTools = options.disableTools ? [] : options.allowedTools;
59166
59209
  this.allowedTools = this._parseAllowedTools(effectiveAllowedTools);
59167
59210
  this.storageAdapter = options.storageAdapter || new InMemoryStorageAdapter();
@@ -59180,6 +59223,7 @@ var init_ProbeAgent = __esm({
59180
59223
  } else {
59181
59224
  this.allowedFolders = [process.cwd()];
59182
59225
  }
59226
+ this.cwd = options.cwd || null;
59183
59227
  this.clientApiProvider = options.provider || null;
59184
59228
  this.clientApiModel = options.model || null;
59185
59229
  this.clientApiKey = null;
@@ -59358,7 +59402,8 @@ var init_ProbeAgent = __esm({
59358
59402
  const configOptions = {
59359
59403
  sessionId: this.sessionId,
59360
59404
  debug: this.debug,
59361
- defaultPath: this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd(),
59405
+ // Use explicit cwd if set, otherwise fall back to first allowed folder
59406
+ cwd: this.cwd || (this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd()),
59362
59407
  allowedFolders: this.allowedFolders,
59363
59408
  outline: this.outline,
59364
59409
  allowEdit: this.allowEdit,
@@ -61209,6 +61254,46 @@ IMPORTANT: When using <attempt_complete>, this must be the ONLY content in your
61209
61254
  } catch (error) {
61210
61255
  console.error(`[ERROR] Failed to save messages to storage:`, error);
61211
61256
  }
61257
+ if (completionAttempted && this.completionPrompt && !options._completionPromptProcessed) {
61258
+ if (this.debug) {
61259
+ console.log("[DEBUG] Running completion prompt for post-completion validation/review...");
61260
+ }
61261
+ try {
61262
+ if (this.tracer) {
61263
+ this.tracer.recordEvent("completion_prompt.started", {
61264
+ "completion_prompt.original_result_length": finalResult?.length || 0
61265
+ });
61266
+ }
61267
+ const completionPromptMessage = `${this.completionPrompt}
61268
+
61269
+ Here is the result to review:
61270
+ <result>
61271
+ ${finalResult}
61272
+ </result>
61273
+
61274
+ After reviewing, provide your final answer using attempt_completion.`;
61275
+ const completionResult = await this.answer(completionPromptMessage, [], {
61276
+ ...options,
61277
+ _completionPromptProcessed: true
61278
+ });
61279
+ finalResult = completionResult;
61280
+ if (this.debug) {
61281
+ console.log(`[DEBUG] Completion prompt finished. New result length: ${finalResult?.length || 0}`);
61282
+ }
61283
+ if (this.tracer) {
61284
+ this.tracer.recordEvent("completion_prompt.completed", {
61285
+ "completion_prompt.final_result_length": finalResult?.length || 0
61286
+ });
61287
+ }
61288
+ } catch (error) {
61289
+ console.error("[ERROR] Completion prompt failed:", error);
61290
+ if (this.tracer) {
61291
+ this.tracer.recordEvent("completion_prompt.error", {
61292
+ "completion_prompt.error": error.message
61293
+ });
61294
+ }
61295
+ }
61296
+ }
61212
61297
  const reachedMaxIterations = currentIteration >= maxIterations && !completionAttempted;
61213
61298
  if (options.schema && !options._schemaFormatted && !completionAttempted && !reachedMaxIterations) {
61214
61299
  if (this.debug) {
@@ -61675,6 +61760,8 @@ Convert your previous response content into actual JSON data that follows this s
61675
61760
  path: this.allowedFolders[0],
61676
61761
  // Use first allowed folder as primary path
61677
61762
  allowedFolders: [...this.allowedFolders],
61763
+ cwd: this.cwd,
61764
+ // Preserve explicit working directory
61678
61765
  provider: this.clientApiProvider,
61679
61766
  model: this.clientApiModel,
61680
61767
  debug: this.debug,
@@ -61683,6 +61770,7 @@ Convert your previous response content into actual JSON data that follows this s
61683
61770
  maxIterations: this.maxIterations,
61684
61771
  disableMermaidValidation: this.disableMermaidValidation,
61685
61772
  disableJsonValidation: this.disableJsonValidation,
61773
+ completionPrompt: this.completionPrompt,
61686
61774
  allowedTools: allowedToolsArray,
61687
61775
  enableMcp: !!this.mcpBridge,
61688
61776
  mcpConfig: this.mcpConfig,