@probelabs/probe 0.6.0-rc225 → 0.6.0-rc226

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.cjs CHANGED
@@ -1645,6 +1645,25 @@ var init_error_types = __esm({
1645
1645
  });
1646
1646
 
1647
1647
  // src/utils/path-validation.js
1648
+ function safeRealpath(inputPath) {
1649
+ try {
1650
+ return (0, import_fs3.realpathSync)(inputPath);
1651
+ } catch (error2) {
1652
+ const normalized = import_path4.default.normalize(inputPath);
1653
+ const parts = normalized.split(import_path4.default.sep);
1654
+ for (let i5 = parts.length - 1; i5 >= 0; i5--) {
1655
+ const ancestorPath = parts.slice(0, i5).join(import_path4.default.sep) || import_path4.default.sep;
1656
+ try {
1657
+ const resolvedAncestor = (0, import_fs3.realpathSync)(ancestorPath);
1658
+ const remainingParts = parts.slice(i5);
1659
+ return import_path4.default.join(resolvedAncestor, ...remainingParts);
1660
+ } catch (ancestorError) {
1661
+ continue;
1662
+ }
1663
+ }
1664
+ return normalized;
1665
+ }
1666
+ }
1648
1667
  async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
1649
1668
  const targetPath = inputPath || defaultPath;
1650
1669
  const normalizedPath = import_path4.default.normalize(import_path4.default.resolve(targetPath));
@@ -1677,6 +1696,53 @@ async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
1677
1696
  }
1678
1697
  return normalizedPath;
1679
1698
  }
1699
+ function getCommonPrefix(folders) {
1700
+ if (!folders || folders.length === 0) {
1701
+ return process.cwd();
1702
+ }
1703
+ if (folders.length === 1) {
1704
+ return safeRealpath(folders[0]);
1705
+ }
1706
+ const normalized = folders.map((f5) => safeRealpath(f5));
1707
+ const segments = normalized.map((f5) => f5.split(import_path4.default.sep));
1708
+ const minLen = Math.min(...segments.map((s5) => s5.length));
1709
+ const commonSegments = [];
1710
+ for (let i5 = 0; i5 < minLen; i5++) {
1711
+ const segment = segments[0][i5];
1712
+ if (segments.every((s5) => s5[i5] === segment)) {
1713
+ commonSegments.push(segment);
1714
+ } else {
1715
+ break;
1716
+ }
1717
+ }
1718
+ if (commonSegments.length === 0) {
1719
+ return normalized[0];
1720
+ }
1721
+ if (commonSegments.length === 1 && /^[a-zA-Z]:$/.test(commonSegments[0])) {
1722
+ return normalized[0];
1723
+ }
1724
+ if (commonSegments.length === 1 && commonSegments[0] === "") {
1725
+ return normalized[0];
1726
+ }
1727
+ return commonSegments.join(import_path4.default.sep);
1728
+ }
1729
+ function toRelativePath(absolutePath, workspaceRoot) {
1730
+ if (!absolutePath || !workspaceRoot) {
1731
+ return absolutePath;
1732
+ }
1733
+ let normalized = safeRealpath(absolutePath);
1734
+ let normalizedRoot = safeRealpath(workspaceRoot);
1735
+ while (normalizedRoot.length > 1 && normalizedRoot.endsWith(import_path4.default.sep)) {
1736
+ normalizedRoot = normalizedRoot.slice(0, -1);
1737
+ }
1738
+ if (normalized === normalizedRoot) {
1739
+ return ".";
1740
+ }
1741
+ if (normalized.startsWith(normalizedRoot + import_path4.default.sep)) {
1742
+ return import_path4.default.relative(normalizedRoot, normalized);
1743
+ }
1744
+ return absolutePath;
1745
+ }
1680
1746
  var import_path4, import_fs3;
1681
1747
  var init_path_validation = __esm({
1682
1748
  "src/utils/path-validation.js"() {
@@ -37304,21 +37370,24 @@ var init_zod = __esm({
37304
37370
  // src/tools/edit.js
37305
37371
  function isPathAllowed(filePath, allowedFolders) {
37306
37372
  if (!allowedFolders || allowedFolders.length === 0) {
37307
- const resolvedPath3 = (0, import_path5.resolve)(filePath);
37308
- const cwd = (0, import_path5.resolve)(process.cwd());
37373
+ const resolvedPath3 = safeRealpath(filePath);
37374
+ const cwd = safeRealpath(process.cwd());
37309
37375
  return resolvedPath3 === cwd || resolvedPath3.startsWith(cwd + import_path5.sep);
37310
37376
  }
37311
- const resolvedPath2 = (0, import_path5.resolve)(filePath);
37377
+ const resolvedPath2 = safeRealpath(filePath);
37312
37378
  return allowedFolders.some((folder) => {
37313
- const allowedPath = (0, import_path5.resolve)(folder);
37379
+ const allowedPath = safeRealpath(folder);
37314
37380
  return resolvedPath2 === allowedPath || resolvedPath2.startsWith(allowedPath + import_path5.sep);
37315
37381
  });
37316
37382
  }
37317
37383
  function parseFileToolOptions(options = {}) {
37384
+ const allowedFolders = options.allowedFolders || [];
37318
37385
  return {
37319
37386
  debug: options.debug || false,
37320
- allowedFolders: options.allowedFolders || [],
37321
- cwd: options.cwd
37387
+ allowedFolders,
37388
+ cwd: options.cwd,
37389
+ // Consistent fallback chain: workspaceRoot > cwd > allowedFolders[0] > process.cwd()
37390
+ workspaceRoot: options.workspaceRoot || options.cwd || allowedFolders.length > 0 && allowedFolders[0] || process.cwd()
37322
37391
  };
37323
37392
  }
37324
37393
  var import_ai, import_fs4, import_path5, import_fs5, editTool, createTool, editSchema, createSchema, editDescription, createDescription, editToolDefinition, createToolDefinition;
@@ -37329,8 +37398,9 @@ var init_edit = __esm({
37329
37398
  import_fs4 = require("fs");
37330
37399
  import_path5 = require("path");
37331
37400
  import_fs5 = require("fs");
37401
+ init_path_validation();
37332
37402
  editTool = (options = {}) => {
37333
- const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
37403
+ const { debug, allowedFolders, cwd, workspaceRoot } = parseFileToolOptions(options);
37334
37404
  return (0, import_ai.tool)({
37335
37405
  name: "edit",
37336
37406
  description: `Edit files using exact string replacement (Claude Code style).
@@ -37386,7 +37456,8 @@ Important:
37386
37456
  console.error(`[Edit] Attempting to edit file: ${resolvedPath2}`);
37387
37457
  }
37388
37458
  if (!isPathAllowed(resolvedPath2, allowedFolders)) {
37389
- return `Error editing file: Permission denied - ${file_path} is outside allowed directories`;
37459
+ const relativePath = toRelativePath(resolvedPath2, workspaceRoot);
37460
+ return `Error editing file: Permission denied - ${relativePath} is outside allowed directories`;
37390
37461
  }
37391
37462
  if (!(0, import_fs5.existsSync)(resolvedPath2)) {
37392
37463
  return `Error editing file: File not found - ${file_path}`;
@@ -37422,7 +37493,7 @@ Important:
37422
37493
  });
37423
37494
  };
37424
37495
  createTool = (options = {}) => {
37425
- const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
37496
+ const { debug, allowedFolders, cwd, workspaceRoot } = parseFileToolOptions(options);
37426
37497
  return (0, import_ai.tool)({
37427
37498
  name: "create",
37428
37499
  description: `Create new files with specified content.
@@ -37470,7 +37541,8 @@ Important:
37470
37541
  console.error(`[Create] Attempting to create file: ${resolvedPath2}`);
37471
37542
  }
37472
37543
  if (!isPathAllowed(resolvedPath2, allowedFolders)) {
37473
- return `Error creating file: Permission denied - ${file_path} is outside allowed directories`;
37544
+ const relativePath = toRelativePath(resolvedPath2, workspaceRoot);
37545
+ return `Error creating file: Permission denied - ${relativePath} is outside allowed directories`;
37474
37546
  }
37475
37547
  if ((0, import_fs5.existsSync)(resolvedPath2) && !overwrite) {
37476
37548
  return `Error creating file: File already exists - ${file_path}. Use overwrite: true to replace it.`;
@@ -43309,7 +43381,7 @@ var init_esm3 = __esm({
43309
43381
  });
43310
43382
 
43311
43383
  // node_modules/path-scurry/dist/esm/index.js
43312
- var import_node_path, import_node_url, import_fs6, actualFS, import_promises, realpathSync, defaultFS, fsFromOption, uncDriveRegexp, uncToDrive, eitherSep, UNKNOWN, IFIFO, IFCHR, IFDIR, IFBLK, IFREG, IFLNK, IFSOCK, IFMT, IFMT_UNKNOWN, READDIR_CALLED, LSTAT_CALLED, ENOTDIR, ENOENT, ENOREADLINK, ENOREALPATH, ENOCHILD, TYPEMASK, entToType, normalizeCache, normalize, normalizeNocaseCache, normalizeNocase, ResolveCache, ChildrenCache, setAsCwd, PathBase, PathWin32, PathPosix, PathScurryBase, PathScurryWin32, PathScurryPosix, PathScurryDarwin, Path, PathScurry;
43384
+ var import_node_path, import_node_url, import_fs6, actualFS, import_promises, realpathSync2, defaultFS, fsFromOption, uncDriveRegexp, uncToDrive, eitherSep, UNKNOWN, IFIFO, IFCHR, IFDIR, IFBLK, IFREG, IFLNK, IFSOCK, IFMT, IFMT_UNKNOWN, READDIR_CALLED, LSTAT_CALLED, ENOTDIR, ENOENT, ENOREADLINK, ENOREALPATH, ENOCHILD, TYPEMASK, entToType, normalizeCache, normalize, normalizeNocaseCache, normalizeNocase, ResolveCache, ChildrenCache, setAsCwd, PathBase, PathWin32, PathPosix, PathScurryBase, PathScurryWin32, PathScurryPosix, PathScurryDarwin, Path, PathScurry;
43313
43385
  var init_esm4 = __esm({
43314
43386
  "node_modules/path-scurry/dist/esm/index.js"() {
43315
43387
  init_esm2();
@@ -43319,13 +43391,13 @@ var init_esm4 = __esm({
43319
43391
  actualFS = __toESM(require("node:fs"), 1);
43320
43392
  import_promises = require("node:fs/promises");
43321
43393
  init_esm3();
43322
- realpathSync = import_fs6.realpathSync.native;
43394
+ realpathSync2 = import_fs6.realpathSync.native;
43323
43395
  defaultFS = {
43324
43396
  lstatSync: import_fs6.lstatSync,
43325
43397
  readdir: import_fs6.readdir,
43326
43398
  readdirSync: import_fs6.readdirSync,
43327
43399
  readlinkSync: import_fs6.readlinkSync,
43328
- realpathSync,
43400
+ realpathSync: realpathSync2,
43329
43401
  promises: {
43330
43402
  lstat: import_promises.lstat,
43331
43403
  readdir: import_promises.readdir,
@@ -95872,6 +95944,7 @@ var init_ProbeAgent = __esm({
95872
95944
  init_FallbackManager();
95873
95945
  init_contextCompactor();
95874
95946
  init_error_types();
95947
+ init_path_validation();
95875
95948
  init_outputTruncator();
95876
95949
  init_delegate();
95877
95950
  init_tasks();
@@ -95989,7 +96062,8 @@ var init_ProbeAgent = __esm({
95989
96062
  } else {
95990
96063
  this.allowedFolders = [process.cwd()];
95991
96064
  }
95992
- this.cwd = options.cwd || null;
96065
+ this.workspaceRoot = getCommonPrefix(this.allowedFolders);
96066
+ this.cwd = options.cwd || this.workspaceRoot;
95993
96067
  this.clientApiProvider = options.provider || null;
95994
96068
  this.clientApiModel = options.model || null;
95995
96069
  this.clientApiKey = null;
@@ -96001,6 +96075,8 @@ var init_ProbeAgent = __esm({
96001
96075
  console.log(`[DEBUG] Maximum tool iterations configured: ${MAX_TOOL_ITERATIONS}`);
96002
96076
  console.log(`[DEBUG] Allow Edit (implement tool): ${this.allowEdit}`);
96003
96077
  console.log(`[DEBUG] Search delegation enabled: ${this.searchDelegate}`);
96078
+ console.log(`[DEBUG] Workspace root: ${this.workspaceRoot}`);
96079
+ console.log(`[DEBUG] Working directory (cwd): ${this.cwd}`);
96004
96080
  }
96005
96081
  this.initializeTools();
96006
96082
  this.history = [];
@@ -96348,8 +96424,9 @@ var init_ProbeAgent = __esm({
96348
96424
  const configOptions = {
96349
96425
  sessionId: this.sessionId,
96350
96426
  debug: this.debug,
96351
- // Use explicit cwd if set, otherwise fall back to first allowed folder
96352
- cwd: this.cwd || (this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd()),
96427
+ // Use cwd (which defaults to workspaceRoot in constructor)
96428
+ cwd: this.cwd,
96429
+ workspaceRoot: this.workspaceRoot,
96353
96430
  allowedFolders: this.allowedFolders,
96354
96431
  outline: this.outline,
96355
96432
  searchDelegate: this.searchDelegate,
@@ -97036,16 +97113,16 @@ var init_ProbeAgent = __esm({
97036
97113
  let absolutePath;
97037
97114
  let isPathAllowed2 = false;
97038
97115
  if ((0, import_path13.isAbsolute)(imagePath)) {
97039
- absolutePath = (0, import_path13.normalize)((0, import_path13.resolve)(imagePath));
97116
+ absolutePath = safeRealpath((0, import_path13.resolve)(imagePath));
97040
97117
  isPathAllowed2 = allowedDirs.some((dir) => {
97041
- const normalizedDir = (0, import_path13.normalize)((0, import_path13.resolve)(dir));
97042
- return absolutePath === normalizedDir || absolutePath.startsWith(normalizedDir + import_path13.sep);
97118
+ const resolvedDir = safeRealpath(dir);
97119
+ return absolutePath === resolvedDir || absolutePath.startsWith(resolvedDir + import_path13.sep);
97043
97120
  });
97044
97121
  } else {
97045
97122
  for (const dir of allowedDirs) {
97046
- const normalizedDir = (0, import_path13.normalize)((0, import_path13.resolve)(dir));
97047
- const resolvedPath2 = (0, import_path13.normalize)((0, import_path13.resolve)(dir, imagePath));
97048
- if (resolvedPath2 === normalizedDir || resolvedPath2.startsWith(normalizedDir + import_path13.sep)) {
97123
+ const resolvedDir = safeRealpath(dir);
97124
+ const resolvedPath2 = safeRealpath((0, import_path13.resolve)(dir, imagePath));
97125
+ if (resolvedPath2 === resolvedDir || resolvedPath2.startsWith(resolvedDir + import_path13.sep)) {
97049
97126
  absolutePath = resolvedPath2;
97050
97127
  isPathAllowed2 = true;
97051
97128
  break;
@@ -97228,7 +97305,7 @@ var init_ProbeAgent = __esm({
97228
97305
  if (this._architectureContextLoaded) {
97229
97306
  return this.architectureContext;
97230
97307
  }
97231
- const rootDirectory = this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd();
97308
+ const rootDirectory = this.workspaceRoot || (this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd());
97232
97309
  const configuredName = typeof this.architectureFileName === "string" ? this.architectureFileName.trim() : "";
97233
97310
  const hasConfiguredName = !!configuredName;
97234
97311
  let guidanceCandidates = [];
@@ -97365,6 +97442,9 @@ ${this.architectureContext.content}
97365
97442
  `;
97366
97443
  }
97367
97444
  _getSkillsRepoRoot() {
97445
+ if (this.workspaceRoot) {
97446
+ return (0, import_path13.resolve)(this.workspaceRoot);
97447
+ }
97368
97448
  if (this.allowedFolders && this.allowedFolders.length > 0) {
97369
97449
  return (0, import_path13.resolve)(this.allowedFolders[0]);
97370
97450
  }
@@ -97432,7 +97512,7 @@ Workspace: ${this.allowedFolders.join(", ")}`;
97432
97512
 
97433
97513
  # Repository Structure
97434
97514
  `;
97435
- systemPrompt += `You are working with a repository located at: ${this.allowedFolders[0]}
97515
+ systemPrompt += `You are working with a repository located at: ${this.workspaceRoot}
97436
97516
 
97437
97517
  `;
97438
97518
  systemPrompt += `Here's an overview of the repository structure (showing up to 100 most relevant files):
@@ -97485,7 +97565,7 @@ Workspace: ${this.allowedFolders.join(", ")}`;
97485
97565
 
97486
97566
  # Repository Structure
97487
97567
  `;
97488
- systemPrompt += `You are working with a repository located at: ${this.allowedFolders[0]}
97568
+ systemPrompt += `You are working with a repository located at: ${this.workspaceRoot}
97489
97569
 
97490
97570
  `;
97491
97571
  systemPrompt += `Here's an overview of the repository structure (showing up to 100 most relevant files):
@@ -97784,21 +97864,34 @@ For MCP tools, use JSON format within the params tag, e.g.:
97784
97864
  `;
97785
97865
  }
97786
97866
  }
97787
- const searchDirectory = this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd();
97867
+ const searchDirectory = this.workspaceRoot;
97788
97868
  if (this.debug) {
97789
- console.log(`[DEBUG] Generating file list for base directory: ${searchDirectory}...`);
97869
+ console.log(`[DEBUG] Generating file list for workspace root: ${searchDirectory}...`);
97870
+ }
97871
+ const relativeWorkspaces = this.allowedFolders.map((f5) => {
97872
+ const rel = toRelativePath(f5, this.workspaceRoot);
97873
+ if (rel && rel !== "." && !rel.startsWith(".") && !rel.startsWith("/")) {
97874
+ return "./" + rel;
97875
+ }
97876
+ return rel;
97877
+ }).filter((f5) => f5 && f5 !== ".");
97878
+ let workspaceDesc;
97879
+ if (relativeWorkspaces.length === 0) {
97880
+ workspaceDesc = ". (current directory)";
97881
+ } else {
97882
+ workspaceDesc = relativeWorkspaces.join(", ");
97790
97883
  }
97791
97884
  try {
97792
97885
  const files = await listFilesByLevel({
97793
97886
  directory: searchDirectory,
97794
97887
  maxFiles: 100,
97795
97888
  respectGitignore: !process.env.PROBE_NO_GITIGNORE || process.env.PROBE_NO_GITIGNORE === "",
97796
- cwd: process.cwd()
97889
+ cwd: this.workspaceRoot
97797
97890
  });
97798
97891
  systemMessage += `
97799
97892
  # Repository Structure
97800
97893
 
97801
- You are working with a repository located at: ${searchDirectory}
97894
+ You are working with a workspace. Available paths: ${workspaceDesc}
97802
97895
 
97803
97896
  Here's an overview of the repository structure (showing up to 100 most relevant files):
97804
97897
 
@@ -97814,15 +97907,22 @@ ${files}
97814
97907
  systemMessage += `
97815
97908
  # Repository Structure
97816
97909
 
97817
- You are working with a repository located at: ${searchDirectory}
97910
+ You are working with a workspace. Available paths: ${workspaceDesc}
97818
97911
 
97819
97912
  `;
97820
97913
  }
97821
97914
  await this.loadArchitectureContext();
97822
97915
  systemMessage += this.getArchitectureSection();
97823
97916
  if (this.allowedFolders.length > 0) {
97917
+ const relativeAllowed = this.allowedFolders.map((f5) => {
97918
+ const rel = toRelativePath(f5, this.workspaceRoot);
97919
+ if (rel && rel !== "." && !rel.startsWith(".") && !rel.startsWith("/")) {
97920
+ return "./" + rel;
97921
+ }
97922
+ return rel;
97923
+ });
97824
97924
  systemMessage += `
97825
- **Important**: For security reasons, you can only search within these allowed folders: ${this.allowedFolders.join(", ")}
97925
+ **Important**: For security reasons, you can only access these paths: ${relativeAllowed.join(", ")}
97826
97926
 
97827
97927
  `;
97828
97928
  }
@@ -98336,6 +98436,7 @@ You are working with a repository located at: ${searchDirectory}
98336
98436
  console.error(`[DEBUG] ========================================
98337
98437
  `);
98338
98438
  }
98439
+ currentMessages.push({ role: "assistant", content: assistantResponseContent });
98339
98440
  currentMessages.push({ role: "user", content: `<tool_result>
98340
98441
  ${toolResultContent}
98341
98442
  </tool_result>` });
@@ -98356,17 +98457,18 @@ ${toolResultContent}
98356
98457
  `);
98357
98458
  }
98358
98459
  const errorXml = formatErrorForAI(error2);
98460
+ currentMessages.push({ role: "assistant", content: assistantResponseContent });
98359
98461
  currentMessages.push({ role: "user", content: `<tool_result>
98360
98462
  ${errorXml}
98361
98463
  </tool_result>` });
98362
98464
  }
98363
98465
  } else if (this.toolImplementations[toolName]) {
98364
98466
  try {
98365
- let resolvedWorkingDirectory = this.cwd || this.allowedFolders && this.allowedFolders[0] || process.cwd();
98467
+ let resolvedWorkingDirectory = this.workspaceRoot || this.cwd || this.allowedFolders && this.allowedFolders[0] || process.cwd();
98366
98468
  if (params.workingDirectory) {
98367
- const requestedDir = (0, import_path13.isAbsolute)(params.workingDirectory) ? (0, import_path13.resolve)(params.workingDirectory) : (0, import_path13.resolve)(resolvedWorkingDirectory, params.workingDirectory);
98469
+ const requestedDir = safeRealpath((0, import_path13.isAbsolute)(params.workingDirectory) ? (0, import_path13.resolve)(params.workingDirectory) : (0, import_path13.resolve)(resolvedWorkingDirectory, params.workingDirectory));
98368
98470
  const isWithinAllowed = !this.allowedFolders || this.allowedFolders.length === 0 || this.allowedFolders.some((folder) => {
98369
- const resolvedFolder = (0, import_path13.resolve)(folder);
98471
+ const resolvedFolder = safeRealpath(folder);
98370
98472
  return requestedDir === resolvedFolder || requestedDir.startsWith(resolvedFolder + import_path13.sep);
98371
98473
  });
98372
98474
  if (isWithinAllowed) {
@@ -98835,7 +98937,7 @@ Convert your previous response content into actual JSON data that follows this s
98835
98937
  }
98836
98938
  const mermaidValidation = await validateAndFixMermaidResponse(finalResult, {
98837
98939
  debug: this.debug,
98838
- path: this.allowedFolders[0],
98940
+ path: this.workspaceRoot || this.allowedFolders[0],
98839
98941
  provider: this.clientApiProvider,
98840
98942
  model: this.model,
98841
98943
  tracer: this.tracer
@@ -98908,7 +99010,7 @@ Convert your previous response content into actual JSON data that follows this s
98908
99010
  }
98909
99011
  const { JsonFixingAgent: JsonFixingAgent2 } = await Promise.resolve().then(() => (init_schemaUtils(), schemaUtils_exports));
98910
99012
  const jsonFixer = new JsonFixingAgent2({
98911
- path: this.allowedFolders[0],
99013
+ path: this.workspaceRoot || this.allowedFolders[0],
98912
99014
  provider: this.clientApiProvider,
98913
99015
  model: this.model,
98914
99016
  debug: this.debug,
@@ -98977,7 +99079,7 @@ Convert your previous response content into actual JSON data that follows this s
98977
99079
  }
98978
99080
  const mermaidValidation = await validateAndFixMermaidResponse(finalResult, {
98979
99081
  debug: this.debug,
98980
- path: this.allowedFolders[0],
99082
+ path: this.workspaceRoot || this.allowedFolders[0],
98981
99083
  provider: this.clientApiProvider,
98982
99084
  model: this.model,
98983
99085
  tracer: this.tracer
@@ -99109,7 +99211,7 @@ Convert your previous response content into actual JSON data that follows this s
99109
99211
  }
99110
99212
  const finalMermaidValidation = await validateAndFixMermaidResponse(finalResult, {
99111
99213
  debug: this.debug,
99112
- path: this.allowedFolders[0],
99214
+ path: this.workspaceRoot || this.allowedFolders[0],
99113
99215
  provider: this.clientApiProvider,
99114
99216
  model: this.model,
99115
99217
  tracer: this.tracer
@@ -99259,8 +99361,7 @@ Convert your previous response content into actual JSON data that follows this s
99259
99361
  allowEdit: this.allowEdit,
99260
99362
  enableDelegate: this.enableDelegate,
99261
99363
  architectureFileName: this.architectureFileName,
99262
- path: this.allowedFolders[0],
99263
- // Use first allowed folder as primary path
99364
+ // Pass allowedFolders which will recompute workspaceRoot correctly
99264
99365
  allowedFolders: [...this.allowedFolders],
99265
99366
  cwd: this.cwd,
99266
99367
  // Preserve explicit working directory
@@ -100223,6 +100324,7 @@ async function analyzeAll(options) {
100223
100324
  sessionId,
100224
100325
  debug = false,
100225
100326
  cwd,
100327
+ workspaceRoot,
100226
100328
  allowedFolders,
100227
100329
  provider,
100228
100330
  model,
@@ -100235,10 +100337,11 @@ async function analyzeAll(options) {
100235
100337
  if (!question) {
100236
100338
  throw new Error('The "question" parameter is required.');
100237
100339
  }
100340
+ const effectiveWorkspaceRoot = workspaceRoot || cwd || allowedFolders?.[0] || path9;
100238
100341
  const delegateOptions = {
100239
100342
  debug,
100240
100343
  sessionId,
100241
- path: allowedFolders?.[0] || cwd || path9,
100344
+ path: effectiveWorkspaceRoot,
100242
100345
  allowedFolders,
100243
100346
  provider,
100244
100347
  model,
@@ -100700,7 +100803,7 @@ var init_vercel = __esm({
100700
100803
  });
100701
100804
  };
100702
100805
  delegateTool = (options = {}) => {
100703
- const { debug = false, timeout = 300, cwd, allowedFolders, enableBash = false, bashConfig, architectureFileName, enableMcp = false, mcpConfig = null, mcpConfigPath = null, delegationManager = null } = options;
100806
+ const { debug = false, timeout = 300, cwd, allowedFolders, workspaceRoot, enableBash = false, bashConfig, architectureFileName, enableMcp = false, mcpConfig = null, mcpConfigPath = null, delegationManager = null } = options;
100704
100807
  return (0, import_ai4.tool)({
100705
100808
  name: "delegate",
100706
100809
  description: delegateDescription,
@@ -100733,8 +100836,8 @@ var init_vercel = __esm({
100733
100836
  if (searchDelegate !== void 0 && typeof searchDelegate !== "boolean") {
100734
100837
  throw new TypeError("searchDelegate must be a boolean if provided");
100735
100838
  }
100736
- const workspaceRoot = allowedFolders && allowedFolders[0];
100737
- const effectivePath = path9 || workspaceRoot || cwd;
100839
+ const effectiveWorkspaceRoot = workspaceRoot || allowedFolders && allowedFolders[0];
100840
+ const effectivePath = path9 || effectiveWorkspaceRoot || cwd;
100738
100841
  if (debug) {
100739
100842
  console.error(`Executing delegate with task: "${task.substring(0, 100)}${task.length > 100 ? "..." : ""}"`);
100740
100843
  if (parentSessionId) {
@@ -100771,7 +100874,7 @@ var init_vercel = __esm({
100771
100874
  });
100772
100875
  };
100773
100876
  analyzeAllTool = (options = {}) => {
100774
- const { sessionId, debug = false, delegationManager = null } = options;
100877
+ const { sessionId, debug = false, delegationManager = null, workspaceRoot } = options;
100775
100878
  return (0, import_ai4.tool)({
100776
100879
  name: "analyze_all",
100777
100880
  description: analyzeAllDescription,
@@ -100790,12 +100893,14 @@ var init_vercel = __esm({
100790
100893
  console.error(`[analyze_all] Question: ${question}`);
100791
100894
  console.error(`[analyze_all] Path: ${searchPath}`);
100792
100895
  }
100896
+ const effectiveWorkspaceRoot = workspaceRoot || options.cwd || options.allowedFolders && options.allowedFolders[0];
100793
100897
  const result = await analyzeAll({
100794
100898
  question,
100795
100899
  path: searchPath,
100796
100900
  sessionId,
100797
100901
  debug,
100798
100902
  cwd: options.cwd,
100903
+ workspaceRoot: effectiveWorkspaceRoot,
100799
100904
  allowedFolders: options.allowedFolders,
100800
100905
  provider: options.provider,
100801
100906
  model: options.model,
@@ -102272,14 +102377,17 @@ var init_bash = __esm({
102272
102377
  import_path15 = require("path");
102273
102378
  init_bashPermissions();
102274
102379
  init_bashExecutor();
102380
+ init_path_validation();
102275
102381
  bashTool = (options = {}) => {
102276
102382
  const {
102277
102383
  bashConfig = {},
102278
102384
  debug = false,
102279
102385
  cwd,
102280
102386
  allowedFolders = [],
102387
+ workspaceRoot: providedWorkspaceRoot,
102281
102388
  tracer = null
102282
102389
  } = options;
102390
+ const workspaceRoot = providedWorkspaceRoot || cwd || allowedFolders.length > 0 && allowedFolders[0] || process.cwd();
102283
102391
  const permissionChecker = new BashPermissionChecker({
102284
102392
  allow: bashConfig.allow,
102285
102393
  deny: bashConfig.deny,
@@ -102295,6 +102403,9 @@ var init_bash = __esm({
102295
102403
  if (cwd) {
102296
102404
  return cwd;
102297
102405
  }
102406
+ if (workspaceRoot) {
102407
+ return workspaceRoot;
102408
+ }
102298
102409
  if (allowedFolders && allowedFolders.length > 0) {
102299
102410
  return allowedFolders[0];
102300
102411
  }
@@ -102382,13 +102493,15 @@ For code exploration, try these safe alternatives:
102382
102493
  const defaultDir = getDefaultWorkingDirectory();
102383
102494
  const workingDir = workingDirectory ? (0, import_path15.isAbsolute)(workingDirectory) ? (0, import_path15.resolve)(workingDirectory) : (0, import_path15.resolve)(defaultDir, workingDirectory) : defaultDir;
102384
102495
  if (allowedFolders && allowedFolders.length > 0) {
102385
- const resolvedWorkingDir = (0, import_path15.resolve)(workingDir);
102496
+ const resolvedWorkingDir = safeRealpath(workingDir);
102386
102497
  const isAllowed = allowedFolders.some((folder) => {
102387
- const resolvedFolder = (0, import_path15.resolve)(folder);
102498
+ const resolvedFolder = safeRealpath(folder);
102388
102499
  return resolvedWorkingDir === resolvedFolder || resolvedWorkingDir.startsWith(resolvedFolder + import_path15.sep);
102389
102500
  });
102390
102501
  if (!isAllowed) {
102391
- return `Error: Working directory "${workingDir}" is not within allowed folders: ${allowedFolders.join(", ")}`;
102502
+ const relativeDir = toRelativePath(workingDir, workspaceRoot);
102503
+ const relativeAllowed = allowedFolders.map((f5) => toRelativePath(f5, workspaceRoot));
102504
+ return `Error: Working directory "${relativeDir}" is not within allowed folders: ${relativeAllowed.join(", ")}`;
102392
102505
  }
102393
102506
  }
102394
102507
  const executionOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc225",
3
+ "version": "0.6.0-rc226",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",