@probelabs/probe 0.6.0-rc174 → 0.6.0-rc176

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,7 +8321,9 @@ var init_vercel = __esm({
8281
8321
  const searchOptions = {
8282
8322
  query: searchQuery,
8283
8323
  path: searchPath,
8284
- allowTests: allow_tests,
8324
+ cwd: options.cwd,
8325
+ // Working directory for resolving relative paths
8326
+ allowTests: allow_tests ?? true,
8285
8327
  exact,
8286
8328
  json: false,
8287
8329
  maxTokens: effectiveMaxTokens,
@@ -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,8 +8365,10 @@ 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
- allow_tests,
8371
+ allowTests: allow_tests ?? true,
8328
8372
  json: false
8329
8373
  });
8330
8374
  return results;
@@ -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,7 +8413,8 @@ var init_vercel = __esm({
8375
8413
  }
8376
8414
  extractOptions = {
8377
8415
  inputFile: tempFilePath,
8378
- allowTests: allow_tests,
8416
+ cwd: effectiveCwd,
8417
+ allowTests: allow_tests ?? true,
8379
8418
  contextLines: context_lines,
8380
8419
  format: effectiveFormat
8381
8420
  };
@@ -8387,7 +8426,8 @@ var init_vercel = __esm({
8387
8426
  }
8388
8427
  extractOptions = {
8389
8428
  files,
8390
- allowTests: allow_tests,
8429
+ cwd: effectiveCwd,
8430
+ allowTests: allow_tests ?? true,
8391
8431
  contextLines: context_lines,
8392
8432
  format: effectiveFormat
8393
8433
  };
@@ -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}`);
@@ -10420,6 +10460,17 @@ var init_simpleTelemetry = __esm({
10420
10460
  console.log("[Event]", name, attributes);
10421
10461
  }
10422
10462
  }
10463
+ /**
10464
+ * Record a generic event (used by completionPrompt and other features)
10465
+ */
10466
+ // visor-disable: SimpleAppTracer uses this.sessionId because it's a per-session instance. AppTracer extracts from attributes because it's a singleton managing multiple sessions. Different architectures require different approaches.
10467
+ recordEvent(name, attributes = {}) {
10468
+ if (!this.isEnabled()) return;
10469
+ this.addEvent(name, {
10470
+ "session.id": this.sessionId,
10471
+ ...attributes
10472
+ });
10473
+ }
10423
10474
  /**
10424
10475
  * Record delegation events
10425
10476
  */
@@ -11337,7 +11388,7 @@ var init_escape = __esm({
11337
11388
  });
11338
11389
 
11339
11390
  // 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;
11391
+ 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
11392
  var init_esm = __esm({
11342
11393
  "node_modules/minimatch/dist/esm/index.js"() {
11343
11394
  import_brace_expansion = __toESM(require_brace_expansion(), 1);
@@ -11406,11 +11457,11 @@ var init_esm = __esm({
11406
11457
  return (f) => f.length === len && f !== "." && f !== "..";
11407
11458
  };
11408
11459
  defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
11409
- path5 = {
11460
+ path6 = {
11410
11461
  win32: { sep: "\\" },
11411
11462
  posix: { sep: "/" }
11412
11463
  };
11413
- sep2 = defaultPlatform === "win32" ? path5.win32.sep : path5.posix.sep;
11464
+ sep2 = defaultPlatform === "win32" ? path6.win32.sep : path6.posix.sep;
11414
11465
  minimatch.sep = sep2;
11415
11466
  GLOBSTAR = Symbol("globstar **");
11416
11467
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -14597,12 +14648,12 @@ var init_esm4 = __esm({
14597
14648
  /**
14598
14649
  * Get the Path object referenced by the string path, resolved from this Path
14599
14650
  */
14600
- resolve(path8) {
14601
- if (!path8) {
14651
+ resolve(path9) {
14652
+ if (!path9) {
14602
14653
  return this;
14603
14654
  }
14604
- const rootPath = this.getRootString(path8);
14605
- const dir = path8.substring(rootPath.length);
14655
+ const rootPath = this.getRootString(path9);
14656
+ const dir = path9.substring(rootPath.length);
14606
14657
  const dirParts = dir.split(this.splitSep);
14607
14658
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
14608
14659
  return result;
@@ -15354,8 +15405,8 @@ var init_esm4 = __esm({
15354
15405
  /**
15355
15406
  * @internal
15356
15407
  */
15357
- getRootString(path8) {
15358
- return win32.parse(path8).root;
15408
+ getRootString(path9) {
15409
+ return win32.parse(path9).root;
15359
15410
  }
15360
15411
  /**
15361
15412
  * @internal
@@ -15401,8 +15452,8 @@ var init_esm4 = __esm({
15401
15452
  /**
15402
15453
  * @internal
15403
15454
  */
15404
- getRootString(path8) {
15405
- return path8.startsWith("/") ? "/" : "";
15455
+ getRootString(path9) {
15456
+ return path9.startsWith("/") ? "/" : "";
15406
15457
  }
15407
15458
  /**
15408
15459
  * @internal
@@ -15451,8 +15502,8 @@ var init_esm4 = __esm({
15451
15502
  *
15452
15503
  * @internal
15453
15504
  */
15454
- constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs9 = defaultFS } = {}) {
15455
- this.#fs = fsFromOption(fs9);
15505
+ constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs10 = defaultFS } = {}) {
15506
+ this.#fs = fsFromOption(fs10);
15456
15507
  if (cwd instanceof URL || cwd.startsWith("file://")) {
15457
15508
  cwd = fileURLToPath4(cwd);
15458
15509
  }
@@ -15491,11 +15542,11 @@ var init_esm4 = __esm({
15491
15542
  /**
15492
15543
  * Get the depth of a provided path, string, or the cwd
15493
15544
  */
15494
- depth(path8 = this.cwd) {
15495
- if (typeof path8 === "string") {
15496
- path8 = this.cwd.resolve(path8);
15545
+ depth(path9 = this.cwd) {
15546
+ if (typeof path9 === "string") {
15547
+ path9 = this.cwd.resolve(path9);
15497
15548
  }
15498
- return path8.depth();
15549
+ return path9.depth();
15499
15550
  }
15500
15551
  /**
15501
15552
  * Return the cache of child entries. Exposed so subclasses can create
@@ -15982,9 +16033,9 @@ var init_esm4 = __esm({
15982
16033
  process2();
15983
16034
  return results;
15984
16035
  }
15985
- chdir(path8 = this.cwd) {
16036
+ chdir(path9 = this.cwd) {
15986
16037
  const oldCwd = this.cwd;
15987
- this.cwd = typeof path8 === "string" ? this.cwd.resolve(path8) : path8;
16038
+ this.cwd = typeof path9 === "string" ? this.cwd.resolve(path9) : path9;
15988
16039
  this.cwd[setAsCwd](oldCwd);
15989
16040
  }
15990
16041
  };
@@ -16010,8 +16061,8 @@ var init_esm4 = __esm({
16010
16061
  /**
16011
16062
  * @internal
16012
16063
  */
16013
- newRoot(fs9) {
16014
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
16064
+ newRoot(fs10) {
16065
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
16015
16066
  }
16016
16067
  /**
16017
16068
  * Return true if the provided path string is an absolute path
@@ -16039,8 +16090,8 @@ var init_esm4 = __esm({
16039
16090
  /**
16040
16091
  * @internal
16041
16092
  */
16042
- newRoot(fs9) {
16043
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
16093
+ newRoot(fs10) {
16094
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
16044
16095
  }
16045
16096
  /**
16046
16097
  * Return true if the provided path string is an absolute path
@@ -16359,8 +16410,8 @@ var init_processor = __esm({
16359
16410
  }
16360
16411
  // match, absolute, ifdir
16361
16412
  entries() {
16362
- return [...this.store.entries()].map(([path8, n]) => [
16363
- path8,
16413
+ return [...this.store.entries()].map(([path9, n]) => [
16414
+ path9,
16364
16415
  !!(n & 2),
16365
16416
  !!(n & 1)
16366
16417
  ]);
@@ -16573,9 +16624,9 @@ var init_walker = __esm({
16573
16624
  signal;
16574
16625
  maxDepth;
16575
16626
  includeChildMatches;
16576
- constructor(patterns, path8, opts) {
16627
+ constructor(patterns, path9, opts) {
16577
16628
  this.patterns = patterns;
16578
- this.path = path8;
16629
+ this.path = path9;
16579
16630
  this.opts = opts;
16580
16631
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
16581
16632
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -16594,11 +16645,11 @@ var init_walker = __esm({
16594
16645
  });
16595
16646
  }
16596
16647
  }
16597
- #ignored(path8) {
16598
- return this.seen.has(path8) || !!this.#ignore?.ignored?.(path8);
16648
+ #ignored(path9) {
16649
+ return this.seen.has(path9) || !!this.#ignore?.ignored?.(path9);
16599
16650
  }
16600
- #childrenIgnored(path8) {
16601
- return !!this.#ignore?.childrenIgnored?.(path8);
16651
+ #childrenIgnored(path9) {
16652
+ return !!this.#ignore?.childrenIgnored?.(path9);
16602
16653
  }
16603
16654
  // backpressure mechanism
16604
16655
  pause() {
@@ -16813,8 +16864,8 @@ var init_walker = __esm({
16813
16864
  };
16814
16865
  GlobWalker = class extends GlobUtil {
16815
16866
  matches = /* @__PURE__ */ new Set();
16816
- constructor(patterns, path8, opts) {
16817
- super(patterns, path8, opts);
16867
+ constructor(patterns, path9, opts) {
16868
+ super(patterns, path9, opts);
16818
16869
  }
16819
16870
  matchEmit(e) {
16820
16871
  this.matches.add(e);
@@ -16851,8 +16902,8 @@ var init_walker = __esm({
16851
16902
  };
16852
16903
  GlobStream = class extends GlobUtil {
16853
16904
  results;
16854
- constructor(patterns, path8, opts) {
16855
- super(patterns, path8, opts);
16905
+ constructor(patterns, path9, opts) {
16906
+ super(patterns, path9, opts);
16856
16907
  this.results = new Minipass({
16857
16908
  signal: this.signal,
16858
16909
  objectMode: true
@@ -17180,9 +17231,9 @@ import { exec as exec5 } from "child_process";
17180
17231
  import { promisify as promisify7 } from "util";
17181
17232
  import { randomUUID as randomUUID2 } from "crypto";
17182
17233
  import { EventEmitter as EventEmitter2 } from "events";
17183
- import fs7 from "fs";
17234
+ import fs8 from "fs";
17184
17235
  import { promises as fsPromises2 } from "fs";
17185
- import path6 from "path";
17236
+ import path7 from "path";
17186
17237
  function isSessionCancelled(sessionId) {
17187
17238
  return activeToolExecutions.get(sessionId)?.cancelled || false;
17188
17239
  }
@@ -17349,17 +17400,17 @@ var init_probeTool = __esm({
17349
17400
  execute: async (params) => {
17350
17401
  const { directory = ".", workingDirectory } = params;
17351
17402
  const baseCwd = workingDirectory || process.cwd();
17352
- const secureBaseDir = path6.resolve(baseCwd);
17403
+ const secureBaseDir = path7.resolve(baseCwd);
17353
17404
  const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
17354
17405
  let targetDir;
17355
- if (path6.isAbsolute(directory)) {
17356
- targetDir = path6.resolve(directory);
17357
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17406
+ if (path7.isAbsolute(directory)) {
17407
+ targetDir = path7.resolve(directory);
17408
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17358
17409
  throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
17359
17410
  }
17360
17411
  } else {
17361
- targetDir = path6.resolve(secureBaseDir, directory);
17362
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17412
+ targetDir = path7.resolve(secureBaseDir, directory);
17413
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17363
17414
  throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
17364
17415
  }
17365
17416
  }
@@ -17376,7 +17427,7 @@ var init_probeTool = __esm({
17376
17427
  return `${(size / (1024 * 1024 * 1024)).toFixed(1)}G`;
17377
17428
  };
17378
17429
  const entries = await Promise.all(files.map(async (file) => {
17379
- const fullPath = path6.join(targetDir, file.name);
17430
+ const fullPath = path7.join(targetDir, file.name);
17380
17431
  const entryType = await getEntryType(file, fullPath);
17381
17432
  return {
17382
17433
  name: file.name,
@@ -17413,17 +17464,17 @@ var init_probeTool = __esm({
17413
17464
  throw new Error("Pattern is required for file search");
17414
17465
  }
17415
17466
  const baseCwd = workingDirectory || process.cwd();
17416
- const secureBaseDir = path6.resolve(baseCwd);
17467
+ const secureBaseDir = path7.resolve(baseCwd);
17417
17468
  const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
17418
17469
  let targetDir;
17419
- if (path6.isAbsolute(directory)) {
17420
- targetDir = path6.resolve(directory);
17421
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17470
+ if (path7.isAbsolute(directory)) {
17471
+ targetDir = path7.resolve(directory);
17472
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17422
17473
  throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
17423
17474
  }
17424
17475
  } else {
17425
- targetDir = path6.resolve(secureBaseDir, directory);
17426
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path6.sep) && targetDir !== secureBaseDir) {
17476
+ targetDir = path7.resolve(secureBaseDir, directory);
17477
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
17427
17478
  throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
17428
17479
  }
17429
17480
  }
@@ -19550,11 +19601,11 @@ var init_toKey = __esm({
19550
19601
  });
19551
19602
 
19552
19603
  // node_modules/lodash-es/_baseGet.js
19553
- function baseGet(object, path8) {
19554
- path8 = castPath_default(path8, object);
19555
- var index = 0, length = path8.length;
19604
+ function baseGet(object, path9) {
19605
+ path9 = castPath_default(path9, object);
19606
+ var index = 0, length = path9.length;
19556
19607
  while (object != null && index < length) {
19557
- object = object[toKey_default(path8[index++])];
19608
+ object = object[toKey_default(path9[index++])];
19558
19609
  }
19559
19610
  return index && index == length ? object : void 0;
19560
19611
  }
@@ -19568,8 +19619,8 @@ var init_baseGet = __esm({
19568
19619
  });
19569
19620
 
19570
19621
  // node_modules/lodash-es/get.js
19571
- function get(object, path8, defaultValue) {
19572
- var result = object == null ? void 0 : baseGet_default(object, path8);
19622
+ function get(object, path9, defaultValue) {
19623
+ var result = object == null ? void 0 : baseGet_default(object, path9);
19573
19624
  return result === void 0 ? defaultValue : result;
19574
19625
  }
19575
19626
  var get_default;
@@ -20932,11 +20983,11 @@ var init_baseHasIn = __esm({
20932
20983
  });
20933
20984
 
20934
20985
  // 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;
20986
+ function hasPath(object, path9, hasFunc) {
20987
+ path9 = castPath_default(path9, object);
20988
+ var index = -1, length = path9.length, result = false;
20938
20989
  while (++index < length) {
20939
- var key = toKey_default(path8[index]);
20990
+ var key = toKey_default(path9[index]);
20940
20991
  if (!(result = object != null && hasFunc(object, key))) {
20941
20992
  break;
20942
20993
  }
@@ -20962,8 +21013,8 @@ var init_hasPath = __esm({
20962
21013
  });
20963
21014
 
20964
21015
  // node_modules/lodash-es/hasIn.js
20965
- function hasIn(object, path8) {
20966
- return object != null && hasPath_default(object, path8, baseHasIn_default);
21016
+ function hasIn(object, path9) {
21017
+ return object != null && hasPath_default(object, path9, baseHasIn_default);
20967
21018
  }
20968
21019
  var hasIn_default;
20969
21020
  var init_hasIn = __esm({
@@ -20975,13 +21026,13 @@ var init_hasIn = __esm({
20975
21026
  });
20976
21027
 
20977
21028
  // 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);
21029
+ function baseMatchesProperty(path9, srcValue) {
21030
+ if (isKey_default(path9) && isStrictComparable_default(srcValue)) {
21031
+ return matchesStrictComparable_default(toKey_default(path9), srcValue);
20981
21032
  }
20982
21033
  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);
21034
+ var objValue = get_default(object, path9);
21035
+ return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path9) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
20985
21036
  };
20986
21037
  }
20987
21038
  var COMPARE_PARTIAL_FLAG6, COMPARE_UNORDERED_FLAG4, baseMatchesProperty_default;
@@ -21014,9 +21065,9 @@ var init_baseProperty = __esm({
21014
21065
  });
21015
21066
 
21016
21067
  // node_modules/lodash-es/_basePropertyDeep.js
21017
- function basePropertyDeep(path8) {
21068
+ function basePropertyDeep(path9) {
21018
21069
  return function(object) {
21019
- return baseGet_default(object, path8);
21070
+ return baseGet_default(object, path9);
21020
21071
  };
21021
21072
  }
21022
21073
  var basePropertyDeep_default;
@@ -21028,8 +21079,8 @@ var init_basePropertyDeep = __esm({
21028
21079
  });
21029
21080
 
21030
21081
  // node_modules/lodash-es/property.js
21031
- function property(path8) {
21032
- return isKey_default(path8) ? baseProperty_default(toKey_default(path8)) : basePropertyDeep_default(path8);
21082
+ function property(path9) {
21083
+ return isKey_default(path9) ? baseProperty_default(toKey_default(path9)) : basePropertyDeep_default(path9);
21033
21084
  }
21034
21085
  var property_default;
21035
21086
  var init_property = __esm({
@@ -21648,8 +21699,8 @@ var init_baseHas = __esm({
21648
21699
  });
21649
21700
 
21650
21701
  // node_modules/lodash-es/has.js
21651
- function has(object, path8) {
21652
- return object != null && hasPath_default(object, path8, baseHas_default);
21702
+ function has(object, path9) {
21703
+ return object != null && hasPath_default(object, path9, baseHas_default);
21653
21704
  }
21654
21705
  var has_default;
21655
21706
  var init_has = __esm({
@@ -21855,14 +21906,14 @@ var init_negate = __esm({
21855
21906
  });
21856
21907
 
21857
21908
  // node_modules/lodash-es/_baseSet.js
21858
- function baseSet(object, path8, value, customizer) {
21909
+ function baseSet(object, path9, value, customizer) {
21859
21910
  if (!isObject_default(object)) {
21860
21911
  return object;
21861
21912
  }
21862
- path8 = castPath_default(path8, object);
21863
- var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
21913
+ path9 = castPath_default(path9, object);
21914
+ var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
21864
21915
  while (nested != null && ++index < length) {
21865
- var key = toKey_default(path8[index]), newValue = value;
21916
+ var key = toKey_default(path9[index]), newValue = value;
21866
21917
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
21867
21918
  return object;
21868
21919
  }
@@ -21870,7 +21921,7 @@ function baseSet(object, path8, value, customizer) {
21870
21921
  var objValue = nested[key];
21871
21922
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
21872
21923
  if (newValue === void 0) {
21873
- newValue = isObject_default(objValue) ? objValue : isIndex_default(path8[index + 1]) ? [] : {};
21924
+ newValue = isObject_default(objValue) ? objValue : isIndex_default(path9[index + 1]) ? [] : {};
21874
21925
  }
21875
21926
  }
21876
21927
  assignValue_default(nested, key, newValue);
@@ -21894,9 +21945,9 @@ var init_baseSet = __esm({
21894
21945
  function basePickBy(object, paths, predicate) {
21895
21946
  var index = -1, length = paths.length, result = {};
21896
21947
  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);
21948
+ var path9 = paths[index], value = baseGet_default(object, path9);
21949
+ if (predicate(value, path9)) {
21950
+ baseSet_default(result, castPath_default(path9, object), value);
21900
21951
  }
21901
21952
  }
21902
21953
  return result;
@@ -21920,8 +21971,8 @@ function pickBy(object, predicate) {
21920
21971
  return [prop];
21921
21972
  });
21922
21973
  predicate = baseIteratee_default(predicate);
21923
- return basePickBy_default(object, props, function(value, path8) {
21924
- return predicate(value, path8[0]);
21974
+ return basePickBy_default(object, props, function(value, path9) {
21975
+ return predicate(value, path9[0]);
21925
21976
  });
21926
21977
  }
21927
21978
  var pickBy_default;
@@ -24634,12 +24685,12 @@ function assignCategoriesMapProp(tokenTypes) {
24634
24685
  singleAssignCategoriesToksMap([], currTokType);
24635
24686
  });
24636
24687
  }
24637
- function singleAssignCategoriesToksMap(path8, nextNode) {
24638
- forEach_default(path8, (pathNode) => {
24688
+ function singleAssignCategoriesToksMap(path9, nextNode) {
24689
+ forEach_default(path9, (pathNode) => {
24639
24690
  nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;
24640
24691
  });
24641
24692
  forEach_default(nextNode.CATEGORIES, (nextCategory) => {
24642
- const newPath = path8.concat(nextNode);
24693
+ const newPath = path9.concat(nextNode);
24643
24694
  if (!includes_default(newPath, nextCategory)) {
24644
24695
  singleAssignCategoriesToksMap(newPath, nextCategory);
24645
24696
  }
@@ -25809,10 +25860,10 @@ var init_interpreter = __esm({
25809
25860
  init_rest();
25810
25861
  init_api2();
25811
25862
  AbstractNextPossibleTokensWalker = class extends RestWalker {
25812
- constructor(topProd, path8) {
25863
+ constructor(topProd, path9) {
25813
25864
  super();
25814
25865
  this.topProd = topProd;
25815
- this.path = path8;
25866
+ this.path = path9;
25816
25867
  this.possibleTokTypes = [];
25817
25868
  this.nextProductionName = "";
25818
25869
  this.nextProductionOccurrence = 0;
@@ -25856,9 +25907,9 @@ var init_interpreter = __esm({
25856
25907
  }
25857
25908
  };
25858
25909
  NextAfterTokenWalker = class extends AbstractNextPossibleTokensWalker {
25859
- constructor(topProd, path8) {
25860
- super(topProd, path8);
25861
- this.path = path8;
25910
+ constructor(topProd, path9) {
25911
+ super(topProd, path9);
25912
+ this.path = path9;
25862
25913
  this.nextTerminalName = "";
25863
25914
  this.nextTerminalOccurrence = 0;
25864
25915
  this.nextTerminalName = this.path.lastTok.name;
@@ -26099,10 +26150,10 @@ function initializeArrayOfArrays(size) {
26099
26150
  }
26100
26151
  return result;
26101
26152
  }
26102
- function pathToHashKeys(path8) {
26153
+ function pathToHashKeys(path9) {
26103
26154
  let keys2 = [""];
26104
- for (let i = 0; i < path8.length; i++) {
26105
- const tokType = path8[i];
26155
+ for (let i = 0; i < path9.length; i++) {
26156
+ const tokType = path9[i];
26106
26157
  const longerKeys = [];
26107
26158
  for (let j = 0; j < keys2.length; j++) {
26108
26159
  const currShorterKey = keys2[j];
@@ -26405,7 +26456,7 @@ function validateRuleIsOverridden(ruleName, definedRulesNames, className) {
26405
26456
  }
26406
26457
  return errors;
26407
26458
  }
26408
- function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = []) {
26459
+ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path9 = []) {
26409
26460
  const errors = [];
26410
26461
  const nextNonTerminals = getFirstNoneTerminal(currRule.definition);
26411
26462
  if (isEmpty_default(nextNonTerminals)) {
@@ -26417,15 +26468,15 @@ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = [])
26417
26468
  errors.push({
26418
26469
  message: errMsgProvider.buildLeftRecursionError({
26419
26470
  topLevelRule: topRule,
26420
- leftRecursionPath: path8
26471
+ leftRecursionPath: path9
26421
26472
  }),
26422
26473
  type: ParserDefinitionErrorType.LEFT_RECURSION,
26423
26474
  ruleName
26424
26475
  });
26425
26476
  }
26426
- const validNextSteps = difference_default(nextNonTerminals, path8.concat([topRule]));
26477
+ const validNextSteps = difference_default(nextNonTerminals, path9.concat([topRule]));
26427
26478
  const errorsFromNextSteps = flatMap_default(validNextSteps, (currRefRule) => {
26428
- const newPath = clone_default(path8);
26479
+ const newPath = clone_default(path9);
26429
26480
  newPath.push(currRefRule);
26430
26481
  return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);
26431
26482
  });
@@ -39029,11 +39080,11 @@ var require_baseGet = __commonJS({
39029
39080
  "node_modules/lodash/_baseGet.js"(exports2, module2) {
39030
39081
  var castPath2 = require_castPath();
39031
39082
  var toKey2 = require_toKey();
39032
- function baseGet2(object, path8) {
39033
- path8 = castPath2(path8, object);
39034
- var index = 0, length = path8.length;
39083
+ function baseGet2(object, path9) {
39084
+ path9 = castPath2(path9, object);
39085
+ var index = 0, length = path9.length;
39035
39086
  while (object != null && index < length) {
39036
- object = object[toKey2(path8[index++])];
39087
+ object = object[toKey2(path9[index++])];
39037
39088
  }
39038
39089
  return index && index == length ? object : void 0;
39039
39090
  }
@@ -39045,8 +39096,8 @@ var require_baseGet = __commonJS({
39045
39096
  var require_get = __commonJS({
39046
39097
  "node_modules/lodash/get.js"(exports2, module2) {
39047
39098
  var baseGet2 = require_baseGet();
39048
- function get2(object, path8, defaultValue) {
39049
- var result = object == null ? void 0 : baseGet2(object, path8);
39099
+ function get2(object, path9, defaultValue) {
39100
+ var result = object == null ? void 0 : baseGet2(object, path9);
39050
39101
  return result === void 0 ? defaultValue : result;
39051
39102
  }
39052
39103
  module2.exports = get2;
@@ -39072,11 +39123,11 @@ var require_hasPath = __commonJS({
39072
39123
  var isIndex2 = require_isIndex();
39073
39124
  var isLength2 = require_isLength();
39074
39125
  var toKey2 = require_toKey();
39075
- function hasPath2(object, path8, hasFunc) {
39076
- path8 = castPath2(path8, object);
39077
- var index = -1, length = path8.length, result = false;
39126
+ function hasPath2(object, path9, hasFunc) {
39127
+ path9 = castPath2(path9, object);
39128
+ var index = -1, length = path9.length, result = false;
39078
39129
  while (++index < length) {
39079
- var key = toKey2(path8[index]);
39130
+ var key = toKey2(path9[index]);
39080
39131
  if (!(result = object != null && hasFunc(object, key))) {
39081
39132
  break;
39082
39133
  }
@@ -39097,8 +39148,8 @@ var require_hasIn = __commonJS({
39097
39148
  "node_modules/lodash/hasIn.js"(exports2, module2) {
39098
39149
  var baseHasIn2 = require_baseHasIn();
39099
39150
  var hasPath2 = require_hasPath();
39100
- function hasIn2(object, path8) {
39101
- return object != null && hasPath2(object, path8, baseHasIn2);
39151
+ function hasIn2(object, path9) {
39152
+ return object != null && hasPath2(object, path9, baseHasIn2);
39102
39153
  }
39103
39154
  module2.exports = hasIn2;
39104
39155
  }
@@ -39116,13 +39167,13 @@ var require_baseMatchesProperty = __commonJS({
39116
39167
  var toKey2 = require_toKey();
39117
39168
  var COMPARE_PARTIAL_FLAG7 = 1;
39118
39169
  var COMPARE_UNORDERED_FLAG5 = 2;
39119
- function baseMatchesProperty2(path8, srcValue) {
39120
- if (isKey2(path8) && isStrictComparable2(srcValue)) {
39121
- return matchesStrictComparable2(toKey2(path8), srcValue);
39170
+ function baseMatchesProperty2(path9, srcValue) {
39171
+ if (isKey2(path9) && isStrictComparable2(srcValue)) {
39172
+ return matchesStrictComparable2(toKey2(path9), srcValue);
39122
39173
  }
39123
39174
  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);
39175
+ var objValue = get2(object, path9);
39176
+ return objValue === void 0 && objValue === srcValue ? hasIn2(object, path9) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
39126
39177
  };
39127
39178
  }
39128
39179
  module2.exports = baseMatchesProperty2;
@@ -39145,9 +39196,9 @@ var require_baseProperty = __commonJS({
39145
39196
  var require_basePropertyDeep = __commonJS({
39146
39197
  "node_modules/lodash/_basePropertyDeep.js"(exports2, module2) {
39147
39198
  var baseGet2 = require_baseGet();
39148
- function basePropertyDeep2(path8) {
39199
+ function basePropertyDeep2(path9) {
39149
39200
  return function(object) {
39150
- return baseGet2(object, path8);
39201
+ return baseGet2(object, path9);
39151
39202
  };
39152
39203
  }
39153
39204
  module2.exports = basePropertyDeep2;
@@ -39161,8 +39212,8 @@ var require_property = __commonJS({
39161
39212
  var basePropertyDeep2 = require_basePropertyDeep();
39162
39213
  var isKey2 = require_isKey();
39163
39214
  var toKey2 = require_toKey();
39164
- function property2(path8) {
39165
- return isKey2(path8) ? baseProperty2(toKey2(path8)) : basePropertyDeep2(path8);
39215
+ function property2(path9) {
39216
+ return isKey2(path9) ? baseProperty2(toKey2(path9)) : basePropertyDeep2(path9);
39166
39217
  }
39167
39218
  module2.exports = property2;
39168
39219
  }
@@ -39224,8 +39275,8 @@ var require_has = __commonJS({
39224
39275
  "node_modules/lodash/has.js"(exports2, module2) {
39225
39276
  var baseHas2 = require_baseHas();
39226
39277
  var hasPath2 = require_hasPath();
39227
- function has2(object, path8) {
39228
- return object != null && hasPath2(object, path8, baseHas2);
39278
+ function has2(object, path9) {
39279
+ return object != null && hasPath2(object, path9, baseHas2);
39229
39280
  }
39230
39281
  module2.exports = has2;
39231
39282
  }
@@ -41499,14 +41550,14 @@ var require_baseSet = __commonJS({
41499
41550
  var isIndex2 = require_isIndex();
41500
41551
  var isObject2 = require_isObject();
41501
41552
  var toKey2 = require_toKey();
41502
- function baseSet2(object, path8, value, customizer) {
41553
+ function baseSet2(object, path9, value, customizer) {
41503
41554
  if (!isObject2(object)) {
41504
41555
  return object;
41505
41556
  }
41506
- path8 = castPath2(path8, object);
41507
- var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
41557
+ path9 = castPath2(path9, object);
41558
+ var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
41508
41559
  while (nested != null && ++index < length) {
41509
- var key = toKey2(path8[index]), newValue = value;
41560
+ var key = toKey2(path9[index]), newValue = value;
41510
41561
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
41511
41562
  return object;
41512
41563
  }
@@ -41514,7 +41565,7 @@ var require_baseSet = __commonJS({
41514
41565
  var objValue = nested[key];
41515
41566
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
41516
41567
  if (newValue === void 0) {
41517
- newValue = isObject2(objValue) ? objValue : isIndex2(path8[index + 1]) ? [] : {};
41568
+ newValue = isObject2(objValue) ? objValue : isIndex2(path9[index + 1]) ? [] : {};
41518
41569
  }
41519
41570
  }
41520
41571
  assignValue2(nested, key, newValue);
@@ -41535,9 +41586,9 @@ var require_basePickBy = __commonJS({
41535
41586
  function basePickBy2(object, paths, predicate) {
41536
41587
  var index = -1, length = paths.length, result = {};
41537
41588
  while (++index < length) {
41538
- var path8 = paths[index], value = baseGet2(object, path8);
41539
- if (predicate(value, path8)) {
41540
- baseSet2(result, castPath2(path8, object), value);
41589
+ var path9 = paths[index], value = baseGet2(object, path9);
41590
+ if (predicate(value, path9)) {
41591
+ baseSet2(result, castPath2(path9, object), value);
41541
41592
  }
41542
41593
  }
41543
41594
  return result;
@@ -41552,8 +41603,8 @@ var require_basePick = __commonJS({
41552
41603
  var basePickBy2 = require_basePickBy();
41553
41604
  var hasIn2 = require_hasIn();
41554
41605
  function basePick(object, paths) {
41555
- return basePickBy2(object, paths, function(value, path8) {
41556
- return hasIn2(object, path8);
41606
+ return basePickBy2(object, paths, function(value, path9) {
41607
+ return hasIn2(object, path9);
41557
41608
  });
41558
41609
  }
41559
41610
  module2.exports = basePick;
@@ -42607,15 +42658,15 @@ var require_parent_dummy_chains = __commonJS({
42607
42658
  var node = g.node(v);
42608
42659
  var edgeObj = node.edgeObj;
42609
42660
  var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w);
42610
- var path8 = pathData.path;
42661
+ var path9 = pathData.path;
42611
42662
  var lca = pathData.lca;
42612
42663
  var pathIdx = 0;
42613
- var pathV = path8[pathIdx];
42664
+ var pathV = path9[pathIdx];
42614
42665
  var ascending = true;
42615
42666
  while (v !== edgeObj.w) {
42616
42667
  node = g.node(v);
42617
42668
  if (ascending) {
42618
- while ((pathV = path8[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) {
42669
+ while ((pathV = path9[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) {
42619
42670
  pathIdx++;
42620
42671
  }
42621
42672
  if (pathV === lca) {
@@ -42623,10 +42674,10 @@ var require_parent_dummy_chains = __commonJS({
42623
42674
  }
42624
42675
  }
42625
42676
  if (!ascending) {
42626
- while (pathIdx < path8.length - 1 && g.node(pathV = path8[pathIdx + 1]).minRank <= node.rank) {
42677
+ while (pathIdx < path9.length - 1 && g.node(pathV = path9[pathIdx + 1]).minRank <= node.rank) {
42627
42678
  pathIdx++;
42628
42679
  }
42629
- pathV = path8[pathIdx];
42680
+ pathV = path9[pathIdx];
42630
42681
  }
42631
42682
  g.setParent(v, pathV);
42632
42683
  v = g.successors(v)[0];
@@ -44799,8 +44850,8 @@ var init_svg_generator = __esm({
44799
44850
  elements.push(this.generateNodeWithPad(node, padX, padY));
44800
44851
  }
44801
44852
  for (const edge of layout.edges) {
44802
- const { path: path8, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
44803
- elements.push(path8);
44853
+ const { path: path9, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
44854
+ elements.push(path9);
44804
44855
  if (overlay)
44805
44856
  overlays.push(overlay);
44806
44857
  }
@@ -51116,8 +51167,8 @@ var require_utils = __commonJS({
51116
51167
  }
51117
51168
  return ind;
51118
51169
  }
51119
- function removeDotSegments(path8) {
51120
- let input = path8;
51170
+ function removeDotSegments(path9) {
51171
+ let input = path9;
51121
51172
  const output = [];
51122
51173
  let nextSlash = -1;
51123
51174
  let len = 0;
@@ -51316,8 +51367,8 @@ var require_schemes = __commonJS({
51316
51367
  wsComponent.secure = void 0;
51317
51368
  }
51318
51369
  if (wsComponent.resourceName) {
51319
- const [path8, query2] = wsComponent.resourceName.split("?");
51320
- wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
51370
+ const [path9, query2] = wsComponent.resourceName.split("?");
51371
+ wsComponent.path = path9 && path9 !== "/" ? path9 : void 0;
51321
51372
  wsComponent.query = query2;
51322
51373
  wsComponent.resourceName = void 0;
51323
51374
  }
@@ -54660,7 +54711,7 @@ function validateJsonResponse(response, options = {}) {
54660
54711
  }
54661
54712
  if (!valid) {
54662
54713
  const formattedErrors = validate2.errors.map((err) => {
54663
- const path8 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
54714
+ const path9 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
54664
54715
  let message = "";
54665
54716
  let suggestion = "";
54666
54717
  if (err.keyword === "additionalProperties") {
@@ -54698,7 +54749,7 @@ function validateJsonResponse(response, options = {}) {
54698
54749
  message = err.message;
54699
54750
  suggestion = "";
54700
54751
  }
54701
- const location = path8 ? `at '${path8}'` : "at root";
54752
+ const location = path9 ? `at '${path9}'` : "at root";
54702
54753
  return suggestion ? `${location}: ${message} \u2192 ${suggestion}` : `${location}: ${message}`;
54703
54754
  });
54704
54755
  const errorSummary = formattedErrors.join("\n ");
@@ -55021,7 +55072,7 @@ function extractMermaidFromJson(response) {
55021
55072
  }
55022
55073
  const diagrams = [];
55023
55074
  const jsonPaths = [];
55024
- function searchObject(obj, path8 = []) {
55075
+ function searchObject(obj, path9 = []) {
55025
55076
  if (typeof obj === "string") {
55026
55077
  const mermaidPattern = /```mermaid([^\n`]*?)(?:\n|\\n)([\s\S]*?)```/gi;
55027
55078
  let match2;
@@ -55035,14 +55086,14 @@ function extractMermaidFromJson(response) {
55035
55086
  endIndex: match2.index + match2[0].length,
55036
55087
  attributes,
55037
55088
  isInJson: true,
55038
- jsonPath: path8.join(".")
55089
+ jsonPath: path9.join(".")
55039
55090
  });
55040
- jsonPaths.push(path8.join("."));
55091
+ jsonPaths.push(path9.join("."));
55041
55092
  }
55042
55093
  } else if (Array.isArray(obj)) {
55043
- obj.forEach((item, index) => searchObject(item, [...path8, `[${index}]`]));
55094
+ obj.forEach((item, index) => searchObject(item, [...path9, `[${index}]`]));
55044
55095
  } else if (obj && typeof obj === "object") {
55045
- Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path8, key]));
55096
+ Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path9, key]));
55046
55097
  }
55047
55098
  }
55048
55099
  searchObject(parsedJson);
@@ -55299,7 +55350,7 @@ async function tryMaidAutoFix(diagramContent, options = {}) {
55299
55350
  }
55300
55351
  }
55301
55352
  async function validateAndFixMermaidResponse(response, options = {}) {
55302
- const { schema, debug, path: path8, provider, model, tracer } = options;
55353
+ const { schema, debug, path: path9, provider, model, tracer } = options;
55303
55354
  const startTime = Date.now();
55304
55355
  if (debug) {
55305
55356
  console.log(`[DEBUG] Mermaid validation: Starting maid-based validation for response (${response.length} chars)`);
@@ -55456,7 +55507,7 @@ ${maidResult.fixed}
55456
55507
  }
55457
55508
  const aiFixingStart = Date.now();
55458
55509
  const mermaidFixer = new MermaidFixingAgent({
55459
- path: path8,
55510
+ path: path9,
55460
55511
  provider,
55461
55512
  model,
55462
55513
  debug,
@@ -55698,8 +55749,8 @@ Schema Validation Errors:
55698
55749
  ${validationResult.errorSummary}`;
55699
55750
  } else if (validationResult.schemaErrors && validationResult.schemaErrors.length > 0) {
55700
55751
  const errors = validationResult.schemaErrors.map((err) => {
55701
- const path8 = err.instancePath || "(root)";
55702
- return ` ${path8}: ${err.message}`;
55752
+ const path9 = err.instancePath || "(root)";
55753
+ return ` ${path9}: ${err.message}`;
55703
55754
  }).join("\n");
55704
55755
  schemaErrorDetails = `
55705
55756
 
@@ -58307,8 +58358,8 @@ __export(enhanced_claude_code_exports, {
58307
58358
  });
58308
58359
  import { spawn as spawn3 } from "child_process";
58309
58360
  import { randomBytes } from "crypto";
58310
- import fs8 from "fs/promises";
58311
- import path7 from "path";
58361
+ import fs9 from "fs/promises";
58362
+ import path8 from "path";
58312
58363
  import os3 from "os";
58313
58364
  import { EventEmitter as EventEmitter4 } from "events";
58314
58365
  async function createEnhancedClaudeCLIEngine(options = {}) {
@@ -58331,12 +58382,12 @@ async function createEnhancedClaudeCLIEngine(options = {}) {
58331
58382
  console.log("[DEBUG] Built-in MCP server started");
58332
58383
  console.log("[DEBUG] MCP URL:", `http://${host}:${port}/mcp`);
58333
58384
  }
58334
- mcpConfigPath = path7.join(os3.tmpdir(), `probe-mcp-${session.id}.json`);
58385
+ mcpConfigPath = path8.join(os3.tmpdir(), `probe-mcp-${session.id}.json`);
58335
58386
  const mcpConfig = {
58336
58387
  mcpServers: {
58337
58388
  probe: {
58338
58389
  command: "node",
58339
- args: [path7.join(process.cwd(), "mcp-probe-server.js")],
58390
+ args: [path8.join(process.cwd(), "mcp-probe-server.js")],
58340
58391
  env: {
58341
58392
  PROBE_WORKSPACE: process.cwd(),
58342
58393
  DEBUG: debug ? "true" : "false"
@@ -58344,7 +58395,7 @@ async function createEnhancedClaudeCLIEngine(options = {}) {
58344
58395
  }
58345
58396
  }
58346
58397
  };
58347
- await fs8.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
58398
+ await fs9.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
58348
58399
  }
58349
58400
  if (debug) {
58350
58401
  console.log("[DEBUG] Enhanced Claude Code Engine");
@@ -58538,7 +58589,7 @@ ${opts.schema}`;
58538
58589
  }
58539
58590
  }
58540
58591
  if (mcpConfigPath) {
58541
- await fs8.unlink(mcpConfigPath).catch(() => {
58592
+ await fs9.unlink(mcpConfigPath).catch(() => {
58542
58593
  });
58543
58594
  if (debug) {
58544
58595
  console.log("[DEBUG] MCP config file removed");
@@ -59113,6 +59164,7 @@ var init_ProbeAgent = __esm({
59113
59164
  * @param {boolean} [options.allowEdit=false] - Allow the use of the 'implement' tool
59114
59165
  * @param {boolean} [options.enableDelegate=false] - Enable the delegate tool for task distribution to subagents
59115
59166
  * @param {string} [options.path] - Search directory path
59167
+ * @param {string} [options.cwd] - Working directory for resolving relative paths (independent of allowedFolders)
59116
59168
  * @param {string} [options.provider] - Force specific AI provider
59117
59169
  * @param {string} [options.model] - Override model name
59118
59170
  * @param {boolean} [options.debug] - Enable debug mode
@@ -59141,6 +59193,7 @@ var init_ProbeAgent = __esm({
59141
59193
  * @param {Array<Object>} [options.fallback.providers] - List of provider configurations for custom fallback
59142
59194
  * @param {boolean} [options.fallback.stopOnSuccess=true] - Stop on first success
59143
59195
  * @param {number} [options.fallback.maxTotalAttempts=10] - Maximum total attempts across all providers
59196
+ * @param {string} [options.completionPrompt] - Custom prompt to run after attempt_completion for validation/review (runs before mermaid/JSON validation)
59144
59197
  */
59145
59198
  constructor(options = {}) {
59146
59199
  this.sessionId = options.sessionId || randomUUID5();
@@ -59162,6 +59215,7 @@ var init_ProbeAgent = __esm({
59162
59215
  this.maxIterations = options.maxIterations || null;
59163
59216
  this.disableMermaidValidation = !!options.disableMermaidValidation;
59164
59217
  this.disableJsonValidation = !!options.disableJsonValidation;
59218
+ this.completionPrompt = options.completionPrompt || null;
59165
59219
  const effectiveAllowedTools = options.disableTools ? [] : options.allowedTools;
59166
59220
  this.allowedTools = this._parseAllowedTools(effectiveAllowedTools);
59167
59221
  this.storageAdapter = options.storageAdapter || new InMemoryStorageAdapter();
@@ -59180,6 +59234,7 @@ var init_ProbeAgent = __esm({
59180
59234
  } else {
59181
59235
  this.allowedFolders = [process.cwd()];
59182
59236
  }
59237
+ this.cwd = options.cwd || null;
59183
59238
  this.clientApiProvider = options.provider || null;
59184
59239
  this.clientApiModel = options.model || null;
59185
59240
  this.clientApiKey = null;
@@ -59358,7 +59413,8 @@ var init_ProbeAgent = __esm({
59358
59413
  const configOptions = {
59359
59414
  sessionId: this.sessionId,
59360
59415
  debug: this.debug,
59361
- defaultPath: this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd(),
59416
+ // Use explicit cwd if set, otherwise fall back to first allowed folder
59417
+ cwd: this.cwd || (this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd()),
59362
59418
  allowedFolders: this.allowedFolders,
59363
59419
  outline: this.outline,
59364
59420
  allowEdit: this.allowEdit,
@@ -61209,6 +61265,46 @@ IMPORTANT: When using <attempt_complete>, this must be the ONLY content in your
61209
61265
  } catch (error) {
61210
61266
  console.error(`[ERROR] Failed to save messages to storage:`, error);
61211
61267
  }
61268
+ if (completionAttempted && this.completionPrompt && !options._completionPromptProcessed) {
61269
+ if (this.debug) {
61270
+ console.log("[DEBUG] Running completion prompt for post-completion validation/review...");
61271
+ }
61272
+ try {
61273
+ if (this.tracer) {
61274
+ this.tracer.recordEvent("completion_prompt.started", {
61275
+ "completion_prompt.original_result_length": finalResult?.length || 0
61276
+ });
61277
+ }
61278
+ const completionPromptMessage = `${this.completionPrompt}
61279
+
61280
+ Here is the result to review:
61281
+ <result>
61282
+ ${finalResult}
61283
+ </result>
61284
+
61285
+ After reviewing, provide your final answer using attempt_completion.`;
61286
+ const completionResult = await this.answer(completionPromptMessage, [], {
61287
+ ...options,
61288
+ _completionPromptProcessed: true
61289
+ });
61290
+ finalResult = completionResult;
61291
+ if (this.debug) {
61292
+ console.log(`[DEBUG] Completion prompt finished. New result length: ${finalResult?.length || 0}`);
61293
+ }
61294
+ if (this.tracer) {
61295
+ this.tracer.recordEvent("completion_prompt.completed", {
61296
+ "completion_prompt.final_result_length": finalResult?.length || 0
61297
+ });
61298
+ }
61299
+ } catch (error) {
61300
+ console.error("[ERROR] Completion prompt failed:", error);
61301
+ if (this.tracer) {
61302
+ this.tracer.recordEvent("completion_prompt.error", {
61303
+ "completion_prompt.error": error.message
61304
+ });
61305
+ }
61306
+ }
61307
+ }
61212
61308
  const reachedMaxIterations = currentIteration >= maxIterations && !completionAttempted;
61213
61309
  if (options.schema && !options._schemaFormatted && !completionAttempted && !reachedMaxIterations) {
61214
61310
  if (this.debug) {
@@ -61675,6 +61771,8 @@ Convert your previous response content into actual JSON data that follows this s
61675
61771
  path: this.allowedFolders[0],
61676
61772
  // Use first allowed folder as primary path
61677
61773
  allowedFolders: [...this.allowedFolders],
61774
+ cwd: this.cwd,
61775
+ // Preserve explicit working directory
61678
61776
  provider: this.clientApiProvider,
61679
61777
  model: this.clientApiModel,
61680
61778
  debug: this.debug,
@@ -61683,6 +61781,7 @@ Convert your previous response content into actual JSON data that follows this s
61683
61781
  maxIterations: this.maxIterations,
61684
61782
  disableMermaidValidation: this.disableMermaidValidation,
61685
61783
  disableJsonValidation: this.disableJsonValidation,
61784
+ completionPrompt: this.completionPrompt,
61686
61785
  allowedTools: allowedToolsArray,
61687
61786
  enableMcp: !!this.mcpBridge,
61688
61787
  mcpConfig: this.mcpConfig,