@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.
@@ -104,8 +104,8 @@ var require_package = __commonJS({
104
104
  // node_modules/dotenv/lib/main.js
105
105
  var require_main = __commonJS({
106
106
  "node_modules/dotenv/lib/main.js"(exports2, module2) {
107
- var fs9 = require("fs");
108
- var path8 = require("path");
107
+ var fs10 = require("fs");
108
+ var path9 = require("path");
109
109
  var os4 = require("os");
110
110
  var crypto2 = require("crypto");
111
111
  var packageJson = require_package();
@@ -213,7 +213,7 @@ var require_main = __commonJS({
213
213
  if (options && options.path && options.path.length > 0) {
214
214
  if (Array.isArray(options.path)) {
215
215
  for (const filepath of options.path) {
216
- if (fs9.existsSync(filepath)) {
216
+ if (fs10.existsSync(filepath)) {
217
217
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
218
218
  }
219
219
  }
@@ -221,15 +221,15 @@ var require_main = __commonJS({
221
221
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
222
222
  }
223
223
  } else {
224
- possibleVaultPath = path8.resolve(process.cwd(), ".env.vault");
224
+ possibleVaultPath = path9.resolve(process.cwd(), ".env.vault");
225
225
  }
226
- if (fs9.existsSync(possibleVaultPath)) {
226
+ if (fs10.existsSync(possibleVaultPath)) {
227
227
  return possibleVaultPath;
228
228
  }
229
229
  return null;
230
230
  }
231
231
  function _resolveHome(envPath) {
232
- return envPath[0] === "~" ? path8.join(os4.homedir(), envPath.slice(1)) : envPath;
232
+ return envPath[0] === "~" ? path9.join(os4.homedir(), envPath.slice(1)) : envPath;
233
233
  }
234
234
  function _configVault(options) {
235
235
  const debug = Boolean(options && options.debug);
@@ -246,7 +246,7 @@ var require_main = __commonJS({
246
246
  return { parsed };
247
247
  }
248
248
  function configDotenv(options) {
249
- const dotenvPath = path8.resolve(process.cwd(), ".env");
249
+ const dotenvPath = path9.resolve(process.cwd(), ".env");
250
250
  let encoding = "utf8";
251
251
  const debug = Boolean(options && options.debug);
252
252
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -270,13 +270,13 @@ var require_main = __commonJS({
270
270
  }
271
271
  let lastError;
272
272
  const parsedAll = {};
273
- for (const path9 of optionPaths) {
273
+ for (const path10 of optionPaths) {
274
274
  try {
275
- const parsed = DotenvModule.parse(fs9.readFileSync(path9, { encoding }));
275
+ const parsed = DotenvModule.parse(fs10.readFileSync(path10, { encoding }));
276
276
  DotenvModule.populate(parsedAll, parsed, options);
277
277
  } catch (e4) {
278
278
  if (debug) {
279
- _debug(`Failed to load ${path9} ${e4.message}`);
279
+ _debug(`Failed to load ${path10} ${e4.message}`);
280
280
  }
281
281
  lastError = e4;
282
282
  }
@@ -291,7 +291,7 @@ var require_main = __commonJS({
291
291
  const shortPaths = [];
292
292
  for (const filePath of optionPaths) {
293
293
  try {
294
- const relative = path8.relative(process.cwd(), filePath);
294
+ const relative = path9.relative(process.cwd(), filePath);
295
295
  shortPaths.push(relative);
296
296
  } catch (e4) {
297
297
  if (debug) {
@@ -1684,9 +1684,9 @@ var init_createPaginator = __esm({
1684
1684
  command = withCommand(command) ?? command;
1685
1685
  return await client.send(command, ...args);
1686
1686
  };
1687
- get = (fromObject, path8) => {
1687
+ get = (fromObject, path9) => {
1688
1688
  let cursor2 = fromObject;
1689
- const pathComponents = path8.split(".");
1689
+ const pathComponents = path9.split(".");
1690
1690
  for (const step of pathComponents) {
1691
1691
  if (!cursor2 || typeof cursor2 !== "object") {
1692
1692
  return void 0;
@@ -2649,12 +2649,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2649
2649
  const password = request.password ?? "";
2650
2650
  auth = `${username}:${password}`;
2651
2651
  }
2652
- let path8 = request.path;
2652
+ let path9 = request.path;
2653
2653
  if (queryString) {
2654
- path8 += `?${queryString}`;
2654
+ path9 += `?${queryString}`;
2655
2655
  }
2656
2656
  if (request.fragment) {
2657
- path8 += `#${request.fragment}`;
2657
+ path9 += `#${request.fragment}`;
2658
2658
  }
2659
2659
  let hostname = request.hostname ?? "";
2660
2660
  if (hostname[0] === "[" && hostname.endsWith("]")) {
@@ -2666,7 +2666,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2666
2666
  headers: request.headers,
2667
2667
  host: hostname,
2668
2668
  method: request.method,
2669
- path: path8,
2669
+ path: path9,
2670
2670
  port: request.port,
2671
2671
  agent,
2672
2672
  auth
@@ -2921,16 +2921,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2921
2921
  reject2(err);
2922
2922
  };
2923
2923
  const queryString = querystringBuilder.buildQueryString(query2 || {});
2924
- let path8 = request.path;
2924
+ let path9 = request.path;
2925
2925
  if (queryString) {
2926
- path8 += `?${queryString}`;
2926
+ path9 += `?${queryString}`;
2927
2927
  }
2928
2928
  if (request.fragment) {
2929
- path8 += `#${request.fragment}`;
2929
+ path9 += `#${request.fragment}`;
2930
2930
  }
2931
2931
  const req = session.request({
2932
2932
  ...request.headers,
2933
- [http2.constants.HTTP2_HEADER_PATH]: path8,
2933
+ [http2.constants.HTTP2_HEADER_PATH]: path9,
2934
2934
  [http2.constants.HTTP2_HEADER_METHOD]: method
2935
2935
  });
2936
2936
  session.ref();
@@ -3119,13 +3119,13 @@ var require_dist_cjs16 = __commonJS({
3119
3119
  abortError.name = "AbortError";
3120
3120
  return Promise.reject(abortError);
3121
3121
  }
3122
- let path8 = request.path;
3122
+ let path9 = request.path;
3123
3123
  const queryString = querystringBuilder.buildQueryString(request.query || {});
3124
3124
  if (queryString) {
3125
- path8 += `?${queryString}`;
3125
+ path9 += `?${queryString}`;
3126
3126
  }
3127
3127
  if (request.fragment) {
3128
- path8 += `#${request.fragment}`;
3128
+ path9 += `#${request.fragment}`;
3129
3129
  }
3130
3130
  let auth = "";
3131
3131
  if (request.username != null || request.password != null) {
@@ -3134,7 +3134,7 @@ var require_dist_cjs16 = __commonJS({
3134
3134
  auth = `${username}:${password}@`;
3135
3135
  }
3136
3136
  const { port, method } = request;
3137
- const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path8}`;
3137
+ const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path9}`;
3138
3138
  const body = method === "GET" || method === "HEAD" ? void 0 : request.body;
3139
3139
  const requestOptions = {
3140
3140
  body,
@@ -5196,13 +5196,13 @@ function __disposeResources(env) {
5196
5196
  }
5197
5197
  return next();
5198
5198
  }
5199
- function __rewriteRelativeImportExtension(path8, preserveJsx) {
5200
- if (typeof path8 === "string" && /^\.\.?\//.test(path8)) {
5201
- return path8.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m4, tsx, d4, ext2, cm) {
5199
+ function __rewriteRelativeImportExtension(path9, preserveJsx) {
5200
+ if (typeof path9 === "string" && /^\.\.?\//.test(path9)) {
5201
+ return path9.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m4, tsx, d4, ext2, cm) {
5202
5202
  return tsx ? preserveJsx ? ".jsx" : ".js" : d4 && (!ext2 || !cm) ? m4 : d4 + ext2 + "." + cm.toLowerCase() + "js";
5203
5203
  });
5204
5204
  }
5205
- return path8;
5205
+ return path9;
5206
5206
  }
5207
5207
  var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
5208
5208
  var init_tslib_es6 = __esm({
@@ -6075,11 +6075,11 @@ var init_HttpBindingProtocol = __esm({
6075
6075
  const opTraits = translateTraits(operationSchema.traits);
6076
6076
  if (opTraits.http) {
6077
6077
  request.method = opTraits.http[0];
6078
- const [path8, search2] = opTraits.http[1].split("?");
6078
+ const [path9, search2] = opTraits.http[1].split("?");
6079
6079
  if (request.path == "/") {
6080
- request.path = path8;
6080
+ request.path = path9;
6081
6081
  } else {
6082
- request.path += path8;
6082
+ request.path += path9;
6083
6083
  }
6084
6084
  const traitSearchParams = new URLSearchParams(search2 ?? "");
6085
6085
  Object.assign(query2, Object.fromEntries(traitSearchParams));
@@ -6457,8 +6457,8 @@ var init_requestBuilder = __esm({
6457
6457
  return this;
6458
6458
  }
6459
6459
  p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
6460
- this.resolvePathStack.push((path8) => {
6461
- this.path = resolvedPath(path8, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
6460
+ this.resolvePathStack.push((path9) => {
6461
+ this.path = resolvedPath(path9, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
6462
6462
  });
6463
6463
  return this;
6464
6464
  }
@@ -7108,18 +7108,18 @@ var require_dist_cjs20 = __commonJS({
7108
7108
  }
7109
7109
  };
7110
7110
  var booleanEquals = (value1, value2) => value1 === value2;
7111
- var getAttrPathList = (path8) => {
7112
- const parts = path8.split(".");
7111
+ var getAttrPathList = (path9) => {
7112
+ const parts = path9.split(".");
7113
7113
  const pathList = [];
7114
7114
  for (const part of parts) {
7115
7115
  const squareBracketIndex = part.indexOf("[");
7116
7116
  if (squareBracketIndex !== -1) {
7117
7117
  if (part.indexOf("]") !== part.length - 1) {
7118
- throw new EndpointError(`Path: '${path8}' does not end with ']'`);
7118
+ throw new EndpointError(`Path: '${path9}' does not end with ']'`);
7119
7119
  }
7120
7120
  const arrayIndex = part.slice(squareBracketIndex + 1, -1);
7121
7121
  if (Number.isNaN(parseInt(arrayIndex))) {
7122
- throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path8}'`);
7122
+ throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path9}'`);
7123
7123
  }
7124
7124
  if (squareBracketIndex !== 0) {
7125
7125
  pathList.push(part.slice(0, squareBracketIndex));
@@ -7131,9 +7131,9 @@ var require_dist_cjs20 = __commonJS({
7131
7131
  }
7132
7132
  return pathList;
7133
7133
  };
7134
- var getAttr = (value, path8) => getAttrPathList(path8).reduce((acc, index) => {
7134
+ var getAttr = (value, path9) => getAttrPathList(path9).reduce((acc, index) => {
7135
7135
  if (typeof acc !== "object") {
7136
- throw new EndpointError(`Index '${index}' in '${path8}' not found in '${JSON.stringify(value)}'`);
7136
+ throw new EndpointError(`Index '${index}' in '${path9}' not found in '${JSON.stringify(value)}'`);
7137
7137
  } else if (Array.isArray(acc)) {
7138
7138
  return acc[parseInt(index)];
7139
7139
  }
@@ -7152,8 +7152,8 @@ var require_dist_cjs20 = __commonJS({
7152
7152
  return value;
7153
7153
  }
7154
7154
  if (typeof value === "object" && "hostname" in value) {
7155
- const { hostname: hostname2, port, protocol: protocol2 = "", path: path8 = "", query: query2 = {} } = value;
7156
- const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path8}`);
7155
+ const { hostname: hostname2, port, protocol: protocol2 = "", path: path9 = "", query: query2 = {} } = value;
7156
+ const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path9}`);
7157
7157
  url.search = Object.entries(query2).map(([k4, v4]) => `${k4}=${v4}`).join("&");
7158
7158
  return url;
7159
7159
  }
@@ -8668,10 +8668,10 @@ ${longDate}
8668
8668
  ${credentialScope}
8669
8669
  ${utilHexEncoding.toHex(hashedRequest)}`;
8670
8670
  }
8671
- getCanonicalPath({ path: path8 }) {
8671
+ getCanonicalPath({ path: path9 }) {
8672
8672
  if (this.uriEscapePath) {
8673
8673
  const normalizedPathSegments = [];
8674
- for (const pathSegment of path8.split("/")) {
8674
+ for (const pathSegment of path9.split("/")) {
8675
8675
  if (pathSegment?.length === 0)
8676
8676
  continue;
8677
8677
  if (pathSegment === ".")
@@ -8682,11 +8682,11 @@ ${utilHexEncoding.toHex(hashedRequest)}`;
8682
8682
  normalizedPathSegments.push(pathSegment);
8683
8683
  }
8684
8684
  }
8685
- const normalizedPath = `${path8?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path8?.endsWith("/") ? "/" : ""}`;
8685
+ const normalizedPath = `${path9?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path9?.endsWith("/") ? "/" : ""}`;
8686
8686
  const doubleEncoded = utilUriEscape.escapeUri(normalizedPath);
8687
8687
  return doubleEncoded.replace(/%2F/g, "/");
8688
8688
  }
8689
- return path8;
8689
+ return path9;
8690
8690
  }
8691
8691
  validateResolvedCredentials(credentials) {
8692
8692
  if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
@@ -9947,11 +9947,11 @@ var init_SmithyRpcV2CborProtocol = __esm({
9947
9947
  }
9948
9948
  }
9949
9949
  const { service, operation: operation2 } = (0, import_util_middleware5.getSmithyContext)(context);
9950
- const path8 = `/service/${service}/operation/${operation2}`;
9950
+ const path9 = `/service/${service}/operation/${operation2}`;
9951
9951
  if (request.path.endsWith("/")) {
9952
- request.path += path8.slice(1);
9952
+ request.path += path9.slice(1);
9953
9953
  } else {
9954
- request.path += path8;
9954
+ request.path += path9;
9955
9955
  }
9956
9956
  return request;
9957
9957
  }
@@ -14867,15 +14867,15 @@ var require_dist_cjs34 = __commonJS({
14867
14867
  var querystringBuilder = require_dist_cjs14();
14868
14868
  function formatUrl(request) {
14869
14869
  const { port, query: query2 } = request;
14870
- let { protocol, path: path8, hostname } = request;
14870
+ let { protocol, path: path9, hostname } = request;
14871
14871
  if (protocol && protocol.slice(-1) !== ":") {
14872
14872
  protocol += ":";
14873
14873
  }
14874
14874
  if (port) {
14875
14875
  hostname += `:${port}`;
14876
14876
  }
14877
- if (path8 && path8.charAt(0) !== "/") {
14878
- path8 = `/${path8}`;
14877
+ if (path9 && path9.charAt(0) !== "/") {
14878
+ path9 = `/${path9}`;
14879
14879
  }
14880
14880
  let queryString = query2 ? querystringBuilder.buildQueryString(query2) : "";
14881
14881
  if (queryString && queryString[0] !== "?") {
@@ -14891,7 +14891,7 @@ var require_dist_cjs34 = __commonJS({
14891
14891
  if (request.fragment) {
14892
14892
  fragment = `#${request.fragment}`;
14893
14893
  }
14894
- return `${protocol}//${auth}${hostname}${path8}${queryString}${fragment}`;
14894
+ return `${protocol}//${auth}${hostname}${path9}${queryString}${fragment}`;
14895
14895
  }
14896
14896
  exports2.formatUrl = formatUrl;
14897
14897
  }
@@ -15748,14 +15748,14 @@ var require_readFile = __commonJS({
15748
15748
  var promises_1 = require("node:fs/promises");
15749
15749
  exports2.filePromises = {};
15750
15750
  exports2.fileIntercept = {};
15751
- var readFile2 = (path8, options) => {
15752
- if (exports2.fileIntercept[path8] !== void 0) {
15753
- return exports2.fileIntercept[path8];
15751
+ var readFile2 = (path9, options) => {
15752
+ if (exports2.fileIntercept[path9] !== void 0) {
15753
+ return exports2.fileIntercept[path9];
15754
15754
  }
15755
- if (!exports2.filePromises[path8] || options?.ignoreCache) {
15756
- exports2.filePromises[path8] = (0, promises_1.readFile)(path8, "utf8");
15755
+ if (!exports2.filePromises[path9] || options?.ignoreCache) {
15756
+ exports2.filePromises[path9] = (0, promises_1.readFile)(path9, "utf8");
15757
15757
  }
15758
- return exports2.filePromises[path8];
15758
+ return exports2.filePromises[path9];
15759
15759
  };
15760
15760
  exports2.readFile = readFile2;
15761
15761
  }
@@ -15768,7 +15768,7 @@ var require_dist_cjs42 = __commonJS({
15768
15768
  var getHomeDir = require_getHomeDir();
15769
15769
  var getSSOTokenFilepath = require_getSSOTokenFilepath();
15770
15770
  var getSSOTokenFromFile = require_getSSOTokenFromFile();
15771
- var path8 = require("path");
15771
+ var path9 = require("path");
15772
15772
  var types2 = require_dist_cjs();
15773
15773
  var readFile2 = require_readFile();
15774
15774
  var ENV_PROFILE = "AWS_PROFILE";
@@ -15790,9 +15790,9 @@ var require_dist_cjs42 = __commonJS({
15790
15790
  ...data2.default && { default: data2.default }
15791
15791
  });
15792
15792
  var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
15793
- var getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || path8.join(getHomeDir.getHomeDir(), ".aws", "config");
15793
+ var getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || path9.join(getHomeDir.getHomeDir(), ".aws", "config");
15794
15794
  var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
15795
- var getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || path8.join(getHomeDir.getHomeDir(), ".aws", "credentials");
15795
+ var getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || path9.join(getHomeDir.getHomeDir(), ".aws", "credentials");
15796
15796
  var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
15797
15797
  var profileNameBlockList = ["__proto__", "profile __proto__"];
15798
15798
  var parseIni = (iniData) => {
@@ -15847,11 +15847,11 @@ var require_dist_cjs42 = __commonJS({
15847
15847
  const relativeHomeDirPrefix = "~/";
15848
15848
  let resolvedFilepath = filepath;
15849
15849
  if (filepath.startsWith(relativeHomeDirPrefix)) {
15850
- resolvedFilepath = path8.join(homeDir, filepath.slice(2));
15850
+ resolvedFilepath = path9.join(homeDir, filepath.slice(2));
15851
15851
  }
15852
15852
  let resolvedConfigFilepath = configFilepath;
15853
15853
  if (configFilepath.startsWith(relativeHomeDirPrefix)) {
15854
- resolvedConfigFilepath = path8.join(homeDir, configFilepath.slice(2));
15854
+ resolvedConfigFilepath = path9.join(homeDir, configFilepath.slice(2));
15855
15855
  }
15856
15856
  const parsedFiles = await Promise.all([
15857
15857
  readFile2.readFile(resolvedConfigFilepath, {
@@ -15890,8 +15890,8 @@ var require_dist_cjs42 = __commonJS({
15890
15890
  getFileRecord() {
15891
15891
  return readFile2.fileIntercept;
15892
15892
  },
15893
- interceptFile(path9, contents) {
15894
- readFile2.fileIntercept[path9] = Promise.resolve(contents);
15893
+ interceptFile(path10, contents) {
15894
+ readFile2.fileIntercept[path10] = Promise.resolve(contents);
15895
15895
  },
15896
15896
  getTokenRecord() {
15897
15897
  return getSSOTokenFromFile.tokenIntercept;
@@ -16122,8 +16122,8 @@ var require_dist_cjs44 = __commonJS({
16122
16122
  return endpoint.url.href;
16123
16123
  }
16124
16124
  if ("hostname" in endpoint) {
16125
- const { protocol, hostname, port, path: path8 } = endpoint;
16126
- return `${protocol}//${hostname}${port ? ":" + port : ""}${path8}`;
16125
+ const { protocol, hostname, port, path: path9 } = endpoint;
16126
+ return `${protocol}//${hostname}${port ? ":" + port : ""}${path9}`;
16127
16127
  }
16128
16128
  }
16129
16129
  return endpoint;
@@ -19036,7 +19036,7 @@ var require_dist_cjs56 = __commonJS({
19036
19036
  var httpAuthSchemes = (init_httpAuthSchemes2(), __toCommonJS(httpAuthSchemes_exports));
19037
19037
  var propertyProvider = require_dist_cjs24();
19038
19038
  var sharedIniFileLoader = require_dist_cjs42();
19039
- var fs9 = require("fs");
19039
+ var fs10 = require("fs");
19040
19040
  var fromEnvSigningName = ({ logger: logger2, signingName } = {}) => async () => {
19041
19041
  logger2?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
19042
19042
  if (!signingName) {
@@ -19082,7 +19082,7 @@ var require_dist_cjs56 = __commonJS({
19082
19082
  throw new propertyProvider.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
19083
19083
  }
19084
19084
  };
19085
- var { writeFile } = fs9.promises;
19085
+ var { writeFile } = fs10.promises;
19086
19086
  var writeSSOTokenToFile = (id, ssoToken) => {
19087
19087
  const tokenFilepath = sharedIniFileLoader.getSSOTokenFilepath(id);
19088
19088
  const tokenString = JSON.stringify(ssoToken, null, 2);
@@ -29171,6 +29171,32 @@ var init_utils2 = __esm({
29171
29171
  }
29172
29172
  });
29173
29173
 
29174
+ // src/utils/path-validation.js
29175
+ async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
29176
+ const targetPath = inputPath || defaultPath;
29177
+ const normalizedPath = import_path4.default.normalize(import_path4.default.resolve(targetPath));
29178
+ try {
29179
+ const stats = await import_fs3.promises.stat(normalizedPath);
29180
+ if (!stats.isDirectory()) {
29181
+ throw new Error(`Path is not a directory: ${normalizedPath}`);
29182
+ }
29183
+ } catch (error2) {
29184
+ if (error2.code === "ENOENT") {
29185
+ throw new Error(`Path does not exist: ${normalizedPath}`);
29186
+ }
29187
+ throw error2;
29188
+ }
29189
+ return normalizedPath;
29190
+ }
29191
+ var import_path4, import_fs3;
29192
+ var init_path_validation = __esm({
29193
+ "src/utils/path-validation.js"() {
29194
+ "use strict";
29195
+ import_path4 = __toESM(require("path"), 1);
29196
+ import_fs3 = require("fs");
29197
+ }
29198
+ });
29199
+
29174
29200
  // src/search.js
29175
29201
  async function search(options) {
29176
29202
  if (!options || !options.path) {
@@ -29210,9 +29236,11 @@ async function search(options) {
29210
29236
  options.session = process.env.PROBE_SESSION_ID;
29211
29237
  }
29212
29238
  const queries = Array.isArray(options.query) ? options.query : [options.query];
29239
+ const cwd = await validateCwdPath(options.cwd);
29213
29240
  if (process.env.DEBUG === "1") {
29214
29241
  let logMessage = `
29215
29242
  Search: query="${queries[0]}" path="${options.path}"`;
29243
+ if (options.cwd) logMessage += ` cwd="${options.cwd}"`;
29216
29244
  if (options.maxResults) logMessage += ` maxResults=${options.maxResults}`;
29217
29245
  logMessage += ` maxTokens=${options.maxTokens}`;
29218
29246
  logMessage += ` timeout=${options.timeout}`;
@@ -29232,6 +29260,7 @@ Search: query="${queries[0]}" path="${options.path}"`;
29232
29260
  }
29233
29261
  try {
29234
29262
  const { stdout, stderr } = await execFileAsync(binaryPath, args, {
29263
+ cwd,
29235
29264
  timeout: options.timeout * 1e3,
29236
29265
  // Convert seconds to milliseconds
29237
29266
  maxBuffer: 50 * 1024 * 1024
@@ -29285,13 +29314,15 @@ Search results: ${resultCount} matches, ${tokenCount} tokens`;
29285
29314
  if (error2.code === "ETIMEDOUT" || error2.killed) {
29286
29315
  const timeoutMessage = `Search operation timed out after ${options.timeout} seconds.
29287
29316
  Binary: ${binaryPath}
29288
- Args: ${args.join(" ")}`;
29317
+ Args: ${args.join(" ")}
29318
+ Cwd: ${cwd}`;
29289
29319
  console.error(timeoutMessage);
29290
29320
  throw new Error(timeoutMessage);
29291
29321
  }
29292
29322
  const errorMessage = `Error executing search command: ${error2.message}
29293
29323
  Binary: ${binaryPath}
29294
- Args: ${args.join(" ")}`;
29324
+ Args: ${args.join(" ")}
29325
+ Cwd: ${cwd}`;
29295
29326
  throw new Error(errorMessage);
29296
29327
  }
29297
29328
  }
@@ -29302,6 +29333,7 @@ var init_search = __esm({
29302
29333
  import_child_process2 = require("child_process");
29303
29334
  import_util4 = require("util");
29304
29335
  init_utils2();
29336
+ init_path_validation();
29305
29337
  execFileAsync = (0, import_util4.promisify)(import_child_process2.execFile);
29306
29338
  SEARCH_FLAG_MAP = {
29307
29339
  filesOnly: "--files-only",
@@ -29339,8 +29371,10 @@ async function query(options) {
29339
29371
  cliArgs.push("--format", "json");
29340
29372
  }
29341
29373
  cliArgs.push(escapeString(options.pattern), escapeString(options.path));
29374
+ const cwd = await validateCwdPath(options.cwd);
29342
29375
  if (process.env.DEBUG === "1") {
29343
29376
  let logMessage = `Query: pattern="${options.pattern}" path="${options.path}"`;
29377
+ if (options.cwd) logMessage += ` cwd="${options.cwd}"`;
29344
29378
  if (options.language) logMessage += ` language=${options.language}`;
29345
29379
  if (options.maxResults) logMessage += ` maxResults=${options.maxResults}`;
29346
29380
  if (options.allowTests) logMessage += " allowTests=true";
@@ -29348,7 +29382,7 @@ async function query(options) {
29348
29382
  }
29349
29383
  const command = `${binaryPath} query ${cliArgs.join(" ")}`;
29350
29384
  try {
29351
- const { stdout, stderr } = await execAsync(command);
29385
+ const { stdout, stderr } = await execAsync(command, { cwd });
29352
29386
  if (stderr) {
29353
29387
  console.error(`stderr: ${stderr}`);
29354
29388
  }
@@ -29373,7 +29407,8 @@ async function query(options) {
29373
29407
  return stdout;
29374
29408
  } catch (error2) {
29375
29409
  const errorMessage = `Error executing query command: ${error2.message}
29376
- Command: ${command}`;
29410
+ Command: ${command}
29411
+ Cwd: ${cwd}`;
29377
29412
  throw new Error(errorMessage);
29378
29413
  }
29379
29414
  }
@@ -29384,6 +29419,7 @@ var init_query = __esm({
29384
29419
  import_child_process3 = require("child_process");
29385
29420
  import_util5 = require("util");
29386
29421
  init_utils2();
29422
+ init_path_validation();
29387
29423
  execAsync = (0, import_util5.promisify)(import_child_process3.exec);
29388
29424
  QUERY_FLAG_MAP = {
29389
29425
  language: "--language",
@@ -29418,6 +29454,7 @@ async function extract(options) {
29418
29454
  cliArgs.push(escapeString(file));
29419
29455
  }
29420
29456
  }
29457
+ const cwd = await validateCwdPath(options.cwd);
29421
29458
  if (process.env.DEBUG === "1") {
29422
29459
  let logMessage = `
29423
29460
  Extract:`;
@@ -29426,6 +29463,7 @@ Extract:`;
29426
29463
  }
29427
29464
  if (options.inputFile) logMessage += ` inputFile="${options.inputFile}"`;
29428
29465
  if (options.content) logMessage += ` content=(${typeof options.content === "string" ? options.content.length : options.content.byteLength} bytes)`;
29466
+ if (options.cwd) logMessage += ` cwd="${cwd}"`;
29429
29467
  if (options.allowTests) logMessage += " allowTests=true";
29430
29468
  if (options.contextLines) logMessage += ` contextLines=${options.contextLines}`;
29431
29469
  if (options.format) logMessage += ` format=${options.format}`;
@@ -29433,25 +29471,27 @@ Extract:`;
29433
29471
  console.error(logMessage);
29434
29472
  }
29435
29473
  if (hasContent) {
29436
- return extractWithStdin(binaryPath, cliArgs, options.content, options);
29474
+ return extractWithStdin(binaryPath, cliArgs, options.content, options, cwd);
29437
29475
  }
29438
29476
  const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
29439
29477
  try {
29440
- const { stdout, stderr } = await execAsync2(command);
29478
+ const { stdout, stderr } = await execAsync2(command, { cwd });
29441
29479
  if (stderr) {
29442
29480
  console.error(`stderr: ${stderr}`);
29443
29481
  }
29444
29482
  return processExtractOutput(stdout, options);
29445
29483
  } catch (error2) {
29446
29484
  const errorMessage = `Error executing extract command: ${error2.message}
29447
- Command: ${command}`;
29485
+ Command: ${command}
29486
+ Cwd: ${cwd}`;
29448
29487
  throw new Error(errorMessage);
29449
29488
  }
29450
29489
  }
29451
- function extractWithStdin(binaryPath, cliArgs, content, options) {
29490
+ function extractWithStdin(binaryPath, cliArgs, content, options, cwd) {
29452
29491
  return new Promise((resolve5, reject2) => {
29453
29492
  const childProcess = (0, import_child_process4.spawn)(binaryPath, ["extract", ...cliArgs], {
29454
- stdio: ["pipe", "pipe", "pipe"]
29493
+ stdio: ["pipe", "pipe", "pipe"],
29494
+ cwd
29455
29495
  });
29456
29496
  let stdout = "";
29457
29497
  let stderr = "";
@@ -29542,6 +29582,7 @@ var init_extract = __esm({
29542
29582
  import_child_process4 = require("child_process");
29543
29583
  import_util6 = require("util");
29544
29584
  init_utils2();
29585
+ init_path_validation();
29545
29586
  execAsync2 = (0, import_util6.promisify)(import_child_process4.exec);
29546
29587
  EXTRACT_FLAG_MAP = {
29547
29588
  allowTests: "--allow-tests",
@@ -29573,7 +29614,7 @@ async function delegate({
29573
29614
  maxIterations = 30,
29574
29615
  tracer = null,
29575
29616
  parentSessionId = null,
29576
- path: path8 = null,
29617
+ path: path9 = null,
29577
29618
  provider = null,
29578
29619
  model = null
29579
29620
  }) {
@@ -29613,7 +29654,7 @@ async function delegate({
29613
29654
  maxIterations: remainingIterations,
29614
29655
  debug,
29615
29656
  tracer,
29616
- path: path8,
29657
+ path: path9,
29617
29658
  // Inherit from parent
29618
29659
  provider,
29619
29660
  // Inherit from parent
@@ -30232,8 +30273,8 @@ var init_parseUtil = __esm({
30232
30273
  init_errors4();
30233
30274
  init_en();
30234
30275
  makeIssue = (params) => {
30235
- const { data: data2, path: path8, errorMaps, issueData } = params;
30236
- const fullPath = [...path8, ...issueData.path || []];
30276
+ const { data: data2, path: path9, errorMaps, issueData } = params;
30277
+ const fullPath = [...path9, ...issueData.path || []];
30237
30278
  const fullIssue = {
30238
30279
  ...issueData,
30239
30280
  path: fullPath
@@ -30541,11 +30582,11 @@ var init_types = __esm({
30541
30582
  init_parseUtil();
30542
30583
  init_util2();
30543
30584
  ParseInputLazyPath = class {
30544
- constructor(parent, value, path8, key) {
30585
+ constructor(parent, value, path9, key) {
30545
30586
  this._cachedPath = [];
30546
30587
  this.parent = parent;
30547
30588
  this.data = value;
30548
- this._path = path8;
30589
+ this._path = path9;
30549
30590
  this._key = key;
30550
30591
  }
30551
30592
  get path() {
@@ -34368,15 +34409,15 @@ var init_vercel = __esm({
34368
34409
  name: "search",
34369
34410
  description: searchDescription,
34370
34411
  inputSchema: searchSchema,
34371
- execute: async ({ query: searchQuery, path: path8, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
34412
+ execute: async ({ query: searchQuery, path: path9, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
34372
34413
  try {
34373
34414
  const effectiveMaxTokens = paramMaxTokens || maxTokens;
34374
- let searchPath = path8 || options.defaultPath || ".";
34375
- if ((searchPath === "." || searchPath === "./") && options.defaultPath) {
34415
+ let searchPath = path9 || options.cwd || ".";
34416
+ if ((searchPath === "." || searchPath === "./") && options.cwd) {
34376
34417
  if (debug) {
34377
- console.error(`Using default path "${options.defaultPath}" instead of "${searchPath}"`);
34418
+ console.error(`Using cwd "${options.cwd}" instead of "${searchPath}"`);
34378
34419
  }
34379
- searchPath = options.defaultPath;
34420
+ searchPath = options.cwd;
34380
34421
  }
34381
34422
  if (debug) {
34382
34423
  console.error(`Executing search with query: "${searchQuery}", path: "${searchPath}", exact: ${exact ? "true" : "false"}, language: ${language || "all"}, session: ${sessionId || "none"}`);
@@ -34384,7 +34425,9 @@ var init_vercel = __esm({
34384
34425
  const searchOptions = {
34385
34426
  query: searchQuery,
34386
34427
  path: searchPath,
34387
- allowTests: allow_tests,
34428
+ cwd: options.cwd,
34429
+ // Working directory for resolving relative paths
34430
+ allowTests: allow_tests ?? true,
34388
34431
  exact,
34389
34432
  json: false,
34390
34433
  maxTokens: effectiveMaxTokens,
@@ -34411,14 +34454,14 @@ var init_vercel = __esm({
34411
34454
  name: "query",
34412
34455
  description: queryDescription,
34413
34456
  inputSchema: querySchema,
34414
- execute: async ({ pattern, path: path8, language, allow_tests }) => {
34457
+ execute: async ({ pattern, path: path9, language, allow_tests }) => {
34415
34458
  try {
34416
- let queryPath = path8 || options.defaultPath || ".";
34417
- if ((queryPath === "." || queryPath === "./") && options.defaultPath) {
34459
+ let queryPath = path9 || options.cwd || ".";
34460
+ if ((queryPath === "." || queryPath === "./") && options.cwd) {
34418
34461
  if (debug) {
34419
- console.error(`Using default path "${options.defaultPath}" instead of "${queryPath}"`);
34462
+ console.error(`Using cwd "${options.cwd}" instead of "${queryPath}"`);
34420
34463
  }
34421
- queryPath = options.defaultPath;
34464
+ queryPath = options.cwd;
34422
34465
  }
34423
34466
  if (debug) {
34424
34467
  console.error(`Executing query with pattern: "${pattern}", path: "${queryPath}", language: ${language || "auto"}`);
@@ -34426,8 +34469,10 @@ var init_vercel = __esm({
34426
34469
  const results = await query({
34427
34470
  pattern,
34428
34471
  path: queryPath,
34472
+ cwd: options.cwd,
34473
+ // Working directory for resolving relative paths
34429
34474
  language,
34430
- allow_tests,
34475
+ allowTests: allow_tests ?? true,
34431
34476
  json: false
34432
34477
  });
34433
34478
  return results;
@@ -34446,22 +34491,16 @@ var init_vercel = __esm({
34446
34491
  inputSchema: extractSchema,
34447
34492
  execute: async ({ targets, input_content, line, end_line, allow_tests, context_lines, format: format2 }) => {
34448
34493
  try {
34449
- let extractPath = options.defaultPath || ".";
34450
- if ((extractPath === "." || extractPath === "./") && options.defaultPath) {
34451
- if (debug) {
34452
- console.error(`Using default path "${options.defaultPath}" instead of "${extractPath}"`);
34453
- }
34454
- extractPath = options.defaultPath;
34455
- }
34494
+ const effectiveCwd = options.cwd || ".";
34456
34495
  if (debug) {
34457
34496
  if (targets) {
34458
- console.error(`Executing extract with targets: "${targets}", path: "${extractPath}", context lines: ${context_lines || 10}`);
34497
+ console.error(`Executing extract with targets: "${targets}", cwd: "${effectiveCwd}", context lines: ${context_lines || 10}`);
34459
34498
  } else if (input_content) {
34460
- console.error(`Executing extract with input content, path: "${extractPath}", context lines: ${context_lines || 10}`);
34499
+ console.error(`Executing extract with input content, cwd: "${effectiveCwd}", context lines: ${context_lines || 10}`);
34461
34500
  }
34462
34501
  }
34463
34502
  let tempFilePath = null;
34464
- let extractOptions = { path: extractPath };
34503
+ let extractOptions = { cwd: effectiveCwd };
34465
34504
  if (input_content) {
34466
34505
  const { writeFileSync: writeFileSync2, unlinkSync } = await import("fs");
34467
34506
  const { join: join3 } = await import("path");
@@ -34478,7 +34517,8 @@ var init_vercel = __esm({
34478
34517
  }
34479
34518
  extractOptions = {
34480
34519
  inputFile: tempFilePath,
34481
- allowTests: allow_tests,
34520
+ cwd: effectiveCwd,
34521
+ allowTests: allow_tests ?? true,
34482
34522
  contextLines: context_lines,
34483
34523
  format: effectiveFormat
34484
34524
  };
@@ -34490,7 +34530,8 @@ var init_vercel = __esm({
34490
34530
  }
34491
34531
  extractOptions = {
34492
34532
  files,
34493
- allowTests: allow_tests,
34533
+ cwd: effectiveCwd,
34534
+ allowTests: allow_tests ?? true,
34494
34535
  contextLines: context_lines,
34495
34536
  format: effectiveFormat
34496
34537
  };
@@ -34518,12 +34559,12 @@ var init_vercel = __esm({
34518
34559
  });
34519
34560
  };
34520
34561
  delegateTool = (options = {}) => {
34521
- const { debug = false, timeout = 300, defaultPath, allowedFolders } = options;
34562
+ const { debug = false, timeout = 300, cwd, allowedFolders } = options;
34522
34563
  return (0, import_ai.tool)({
34523
34564
  name: "delegate",
34524
34565
  description: delegateDescription,
34525
34566
  inputSchema: delegateSchema,
34526
- execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path8, provider, model, tracer }) => {
34567
+ execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path9, provider, model, tracer }) => {
34527
34568
  if (!task || typeof task !== "string") {
34528
34569
  throw new Error("Task parameter is required and must be a non-empty string");
34529
34570
  }
@@ -34539,7 +34580,7 @@ var init_vercel = __esm({
34539
34580
  if (parentSessionId !== void 0 && parentSessionId !== null && typeof parentSessionId !== "string") {
34540
34581
  throw new TypeError("parentSessionId must be a string, null, or undefined");
34541
34582
  }
34542
- if (path8 !== void 0 && path8 !== null && typeof path8 !== "string") {
34583
+ if (path9 !== void 0 && path9 !== null && typeof path9 !== "string") {
34543
34584
  throw new TypeError("path must be a string, null, or undefined");
34544
34585
  }
34545
34586
  if (provider !== void 0 && provider !== null && typeof provider !== "string") {
@@ -34548,13 +34589,13 @@ var init_vercel = __esm({
34548
34589
  if (model !== void 0 && model !== null && typeof model !== "string") {
34549
34590
  throw new TypeError("model must be a string, null, or undefined");
34550
34591
  }
34551
- const effectivePath = path8 || defaultPath || allowedFolders && allowedFolders[0];
34592
+ const effectivePath = path9 || cwd || allowedFolders && allowedFolders[0];
34552
34593
  if (debug) {
34553
34594
  console.error(`Executing delegate with task: "${task.substring(0, 100)}${task.length > 100 ? "..." : ""}"`);
34554
34595
  if (parentSessionId) {
34555
34596
  console.error(`Parent session: ${parentSessionId}`);
34556
34597
  }
34557
- if (effectivePath && effectivePath !== path8) {
34598
+ if (effectivePath && effectivePath !== path9) {
34558
34599
  console.error(`Using inherited path: ${effectivePath}`);
34559
34600
  }
34560
34601
  }
@@ -35411,8 +35452,8 @@ async function executeBashCommand(command, options = {}) {
35411
35452
  } = options;
35412
35453
  let cwd = workingDirectory;
35413
35454
  try {
35414
- cwd = (0, import_path4.resolve)(cwd);
35415
- if (!(0, import_fs3.existsSync)(cwd)) {
35455
+ cwd = (0, import_path5.resolve)(cwd);
35456
+ if (!(0, import_fs4.existsSync)(cwd)) {
35416
35457
  throw new Error(`Working directory does not exist: ${cwd}`);
35417
35458
  }
35418
35459
  } catch (error2) {
@@ -35624,7 +35665,7 @@ function validateExecutionOptions(options = {}) {
35624
35665
  if (options.workingDirectory) {
35625
35666
  if (typeof options.workingDirectory !== "string") {
35626
35667
  errors.push("workingDirectory must be a string");
35627
- } else if (!(0, import_fs3.existsSync)(options.workingDirectory)) {
35668
+ } else if (!(0, import_fs4.existsSync)(options.workingDirectory)) {
35628
35669
  errors.push(`workingDirectory does not exist: ${options.workingDirectory}`);
35629
35670
  }
35630
35671
  }
@@ -35637,31 +35678,31 @@ function validateExecutionOptions(options = {}) {
35637
35678
  warnings
35638
35679
  };
35639
35680
  }
35640
- var import_child_process6, import_path4, import_fs3;
35681
+ var import_child_process6, import_path5, import_fs4;
35641
35682
  var init_bashExecutor = __esm({
35642
35683
  "src/agent/bashExecutor.js"() {
35643
35684
  "use strict";
35644
35685
  import_child_process6 = require("child_process");
35645
- import_path4 = require("path");
35646
- import_fs3 = require("fs");
35686
+ import_path5 = require("path");
35687
+ import_fs4 = require("fs");
35647
35688
  init_bashCommandUtils();
35648
35689
  }
35649
35690
  });
35650
35691
 
35651
35692
  // src/tools/bash.js
35652
- var import_ai2, import_path5, bashTool;
35693
+ var import_ai2, import_path6, bashTool;
35653
35694
  var init_bash = __esm({
35654
35695
  "src/tools/bash.js"() {
35655
35696
  "use strict";
35656
35697
  import_ai2 = require("ai");
35657
- import_path5 = require("path");
35698
+ import_path6 = require("path");
35658
35699
  init_bashPermissions();
35659
35700
  init_bashExecutor();
35660
35701
  bashTool = (options = {}) => {
35661
35702
  const {
35662
35703
  bashConfig = {},
35663
35704
  debug = false,
35664
- defaultPath,
35705
+ cwd,
35665
35706
  allowedFolders = []
35666
35707
  } = options;
35667
35708
  const permissionChecker = new BashPermissionChecker({
@@ -35675,8 +35716,8 @@ var init_bash = __esm({
35675
35716
  if (bashConfig.workingDirectory) {
35676
35717
  return bashConfig.workingDirectory;
35677
35718
  }
35678
- if (defaultPath) {
35679
- return defaultPath;
35719
+ if (cwd) {
35720
+ return cwd;
35680
35721
  }
35681
35722
  if (allowedFolders && allowedFolders.length > 0) {
35682
35723
  return allowedFolders[0];
@@ -35764,9 +35805,9 @@ For code exploration, try these safe alternatives:
35764
35805
  }
35765
35806
  const workingDir = workingDirectory || getDefaultWorkingDirectory();
35766
35807
  if (allowedFolders && allowedFolders.length > 0) {
35767
- const resolvedWorkingDir = (0, import_path5.resolve)(workingDir);
35808
+ const resolvedWorkingDir = (0, import_path6.resolve)(workingDir);
35768
35809
  const isAllowed = allowedFolders.some((folder) => {
35769
- const resolvedFolder = (0, import_path5.resolve)(folder);
35810
+ const resolvedFolder = (0, import_path6.resolve)(folder);
35770
35811
  return resolvedWorkingDir.startsWith(resolvedFolder);
35771
35812
  });
35772
35813
  if (!isAllowed) {
@@ -35822,33 +35863,33 @@ Command failed with exit code ${result.exitCode}`;
35822
35863
  // src/tools/edit.js
35823
35864
  function isPathAllowed(filePath, allowedFolders) {
35824
35865
  if (!allowedFolders || allowedFolders.length === 0) {
35825
- const resolvedPath3 = (0, import_path6.resolve)(filePath);
35826
- const cwd = (0, import_path6.resolve)(process.cwd());
35827
- return resolvedPath3 === cwd || resolvedPath3.startsWith(cwd + import_path6.sep);
35866
+ const resolvedPath3 = (0, import_path7.resolve)(filePath);
35867
+ const cwd = (0, import_path7.resolve)(process.cwd());
35868
+ return resolvedPath3 === cwd || resolvedPath3.startsWith(cwd + import_path7.sep);
35828
35869
  }
35829
- const resolvedPath2 = (0, import_path6.resolve)(filePath);
35870
+ const resolvedPath2 = (0, import_path7.resolve)(filePath);
35830
35871
  return allowedFolders.some((folder) => {
35831
- const allowedPath = (0, import_path6.resolve)(folder);
35832
- return resolvedPath2 === allowedPath || resolvedPath2.startsWith(allowedPath + import_path6.sep);
35872
+ const allowedPath = (0, import_path7.resolve)(folder);
35873
+ return resolvedPath2 === allowedPath || resolvedPath2.startsWith(allowedPath + import_path7.sep);
35833
35874
  });
35834
35875
  }
35835
35876
  function parseFileToolOptions(options = {}) {
35836
35877
  return {
35837
35878
  debug: options.debug || false,
35838
35879
  allowedFolders: options.allowedFolders || [],
35839
- defaultPath: options.defaultPath
35880
+ cwd: options.cwd
35840
35881
  };
35841
35882
  }
35842
- var import_ai3, import_fs4, import_path6, import_fs5, editTool, createTool, editDescription, createDescription, editToolDefinition, createToolDefinition;
35883
+ var import_ai3, import_fs5, import_path7, import_fs6, editTool, createTool, editDescription, createDescription, editToolDefinition, createToolDefinition;
35843
35884
  var init_edit = __esm({
35844
35885
  "src/tools/edit.js"() {
35845
35886
  "use strict";
35846
35887
  import_ai3 = require("ai");
35847
- import_fs4 = require("fs");
35848
- import_path6 = require("path");
35849
35888
  import_fs5 = require("fs");
35889
+ import_path7 = require("path");
35890
+ import_fs6 = require("fs");
35850
35891
  editTool = (options = {}) => {
35851
- const { debug, allowedFolders, defaultPath } = parseFileToolOptions(options);
35892
+ const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
35852
35893
  return (0, import_ai3.tool)({
35853
35894
  name: "edit",
35854
35895
  description: `Edit files using exact string replacement (Claude Code style).
@@ -35899,17 +35940,17 @@ Important:
35899
35940
  if (new_string === void 0 || new_string === null || typeof new_string !== "string") {
35900
35941
  return `Error editing file: Invalid new_string - must be a string`;
35901
35942
  }
35902
- const resolvedPath2 = (0, import_path6.isAbsolute)(file_path) ? file_path : (0, import_path6.resolve)(defaultPath || process.cwd(), file_path);
35943
+ const resolvedPath2 = (0, import_path7.isAbsolute)(file_path) ? file_path : (0, import_path7.resolve)(cwd || process.cwd(), file_path);
35903
35944
  if (debug) {
35904
35945
  console.error(`[Edit] Attempting to edit file: ${resolvedPath2}`);
35905
35946
  }
35906
35947
  if (!isPathAllowed(resolvedPath2, allowedFolders)) {
35907
35948
  return `Error editing file: Permission denied - ${file_path} is outside allowed directories`;
35908
35949
  }
35909
- if (!(0, import_fs5.existsSync)(resolvedPath2)) {
35950
+ if (!(0, import_fs6.existsSync)(resolvedPath2)) {
35910
35951
  return `Error editing file: File not found - ${file_path}`;
35911
35952
  }
35912
- const content = await import_fs4.promises.readFile(resolvedPath2, "utf-8");
35953
+ const content = await import_fs5.promises.readFile(resolvedPath2, "utf-8");
35913
35954
  if (!content.includes(old_string)) {
35914
35955
  return `Error editing file: String not found - the specified old_string was not found in ${file_path}`;
35915
35956
  }
@@ -35926,7 +35967,7 @@ Important:
35926
35967
  if (newContent === content) {
35927
35968
  return `Error editing file: No changes made - old_string and new_string might be the same`;
35928
35969
  }
35929
- await import_fs4.promises.writeFile(resolvedPath2, newContent, "utf-8");
35970
+ await import_fs5.promises.writeFile(resolvedPath2, newContent, "utf-8");
35930
35971
  const replacedCount = replace_all ? occurrences : 1;
35931
35972
  if (debug) {
35932
35973
  console.error(`[Edit] Successfully edited ${resolvedPath2}, replaced ${replacedCount} occurrence(s)`);
@@ -35940,7 +35981,7 @@ Important:
35940
35981
  });
35941
35982
  };
35942
35983
  createTool = (options = {}) => {
35943
- const { debug, allowedFolders, defaultPath } = parseFileToolOptions(options);
35984
+ const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
35944
35985
  return (0, import_ai3.tool)({
35945
35986
  name: "create",
35946
35987
  description: `Create new files with specified content.
@@ -35983,20 +36024,20 @@ Important:
35983
36024
  if (content === void 0 || content === null || typeof content !== "string") {
35984
36025
  return `Error creating file: Invalid content - must be a string`;
35985
36026
  }
35986
- const resolvedPath2 = (0, import_path6.isAbsolute)(file_path) ? file_path : (0, import_path6.resolve)(defaultPath || process.cwd(), file_path);
36027
+ const resolvedPath2 = (0, import_path7.isAbsolute)(file_path) ? file_path : (0, import_path7.resolve)(cwd || process.cwd(), file_path);
35987
36028
  if (debug) {
35988
36029
  console.error(`[Create] Attempting to create file: ${resolvedPath2}`);
35989
36030
  }
35990
36031
  if (!isPathAllowed(resolvedPath2, allowedFolders)) {
35991
36032
  return `Error creating file: Permission denied - ${file_path} is outside allowed directories`;
35992
36033
  }
35993
- if ((0, import_fs5.existsSync)(resolvedPath2) && !overwrite) {
36034
+ if ((0, import_fs6.existsSync)(resolvedPath2) && !overwrite) {
35994
36035
  return `Error creating file: File already exists - ${file_path}. Use overwrite: true to replace it.`;
35995
36036
  }
35996
- const dir = (0, import_path6.dirname)(resolvedPath2);
35997
- await import_fs4.promises.mkdir(dir, { recursive: true });
35998
- await import_fs4.promises.writeFile(resolvedPath2, content, "utf-8");
35999
- const action = (0, import_fs5.existsSync)(resolvedPath2) && overwrite ? "overwrote" : "created";
36037
+ const dir = (0, import_path7.dirname)(resolvedPath2);
36038
+ await import_fs5.promises.mkdir(dir, { recursive: true });
36039
+ await import_fs5.promises.writeFile(resolvedPath2, content, "utf-8");
36040
+ const action = (0, import_fs6.existsSync)(resolvedPath2) && overwrite ? "overwrote" : "created";
36000
36041
  const bytes = Buffer.byteLength(content, "utf-8");
36001
36042
  if (debug) {
36002
36043
  console.error(`[Create] Successfully ${action} ${resolvedPath2}`);
@@ -36271,10 +36312,10 @@ async function listFilesByLevel(options) {
36271
36312
  maxFiles = 100,
36272
36313
  respectGitignore = true
36273
36314
  } = options;
36274
- if (!import_fs6.default.existsSync(directory)) {
36315
+ if (!import_fs7.default.existsSync(directory)) {
36275
36316
  throw new Error(`Directory does not exist: ${directory}`);
36276
36317
  }
36277
- const gitDirExists = import_fs6.default.existsSync(import_path7.default.join(directory, ".git"));
36318
+ const gitDirExists = import_fs7.default.existsSync(import_path8.default.join(directory, ".git"));
36278
36319
  if (gitDirExists && respectGitignore) {
36279
36320
  try {
36280
36321
  return await listFilesUsingGit(directory, maxFiles);
@@ -36289,8 +36330,8 @@ async function listFilesUsingGit(directory, maxFiles) {
36289
36330
  const { stdout } = await execAsync3("git ls-files", { cwd: directory });
36290
36331
  const files = stdout.split("\n").filter(Boolean);
36291
36332
  const sortedFiles = files.sort((a4, b4) => {
36292
- const depthA = a4.split(import_path7.default.sep).length;
36293
- const depthB = b4.split(import_path7.default.sep).length;
36333
+ const depthA = a4.split(import_path8.default.sep).length;
36334
+ const depthB = b4.split(import_path8.default.sep).length;
36294
36335
  return depthA - depthB;
36295
36336
  });
36296
36337
  return sortedFiles.slice(0, maxFiles);
@@ -36305,25 +36346,25 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
36305
36346
  while (queue.length > 0 && result.length < maxFiles) {
36306
36347
  const { dir, level } = queue.shift();
36307
36348
  try {
36308
- const entries = import_fs6.default.readdirSync(dir, { withFileTypes: true });
36349
+ const entries = import_fs7.default.readdirSync(dir, { withFileTypes: true });
36309
36350
  const files = entries.filter((entry) => {
36310
- const fullPath = import_path7.default.join(dir, entry.name);
36351
+ const fullPath = import_path8.default.join(dir, entry.name);
36311
36352
  return getEntryTypeSync(entry, fullPath).isFile;
36312
36353
  });
36313
36354
  for (const file of files) {
36314
36355
  if (result.length >= maxFiles) break;
36315
- const filePath = import_path7.default.join(dir, file.name);
36316
- const relativePath = import_path7.default.relative(directory, filePath);
36356
+ const filePath = import_path8.default.join(dir, file.name);
36357
+ const relativePath = import_path8.default.relative(directory, filePath);
36317
36358
  if (shouldIgnore(relativePath, ignorePatterns)) continue;
36318
36359
  result.push(relativePath);
36319
36360
  }
36320
36361
  const dirs = entries.filter((entry) => {
36321
- const fullPath = import_path7.default.join(dir, entry.name);
36362
+ const fullPath = import_path8.default.join(dir, entry.name);
36322
36363
  return getEntryTypeSync(entry, fullPath).isDirectory;
36323
36364
  });
36324
36365
  for (const subdir of dirs) {
36325
- const subdirPath = import_path7.default.join(dir, subdir.name);
36326
- const relativeSubdirPath = import_path7.default.relative(directory, subdirPath);
36366
+ const subdirPath = import_path8.default.join(dir, subdir.name);
36367
+ const relativeSubdirPath = import_path8.default.relative(directory, subdirPath);
36327
36368
  if (shouldIgnore(relativeSubdirPath, ignorePatterns)) continue;
36328
36369
  if (subdir.name === "node_modules" || subdir.name === ".git") continue;
36329
36370
  queue.push({ dir: subdirPath, level: level + 1 });
@@ -36335,12 +36376,12 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
36335
36376
  return result;
36336
36377
  }
36337
36378
  function loadGitignorePatterns(directory) {
36338
- const gitignorePath = import_path7.default.join(directory, ".gitignore");
36339
- if (!import_fs6.default.existsSync(gitignorePath)) {
36379
+ const gitignorePath = import_path8.default.join(directory, ".gitignore");
36380
+ if (!import_fs7.default.existsSync(gitignorePath)) {
36340
36381
  return [];
36341
36382
  }
36342
36383
  try {
36343
- const content = import_fs6.default.readFileSync(gitignorePath, "utf8");
36384
+ const content = import_fs7.default.readFileSync(gitignorePath, "utf8");
36344
36385
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
36345
36386
  } catch (error2) {
36346
36387
  console.error(`Warning: Could not read .gitignore: ${error2.message}`);
@@ -36358,12 +36399,12 @@ function shouldIgnore(filePath, ignorePatterns) {
36358
36399
  }
36359
36400
  return false;
36360
36401
  }
36361
- var import_fs6, import_path7, import_util11, import_child_process7, execAsync3;
36402
+ var import_fs7, import_path8, import_util11, import_child_process7, execAsync3;
36362
36403
  var init_file_lister = __esm({
36363
36404
  "src/utils/file-lister.js"() {
36364
36405
  "use strict";
36365
- import_fs6 = __toESM(require("fs"), 1);
36366
- import_path7 = __toESM(require("path"), 1);
36406
+ import_fs7 = __toESM(require("fs"), 1);
36407
+ import_path8 = __toESM(require("path"), 1);
36367
36408
  import_util11 = require("util");
36368
36409
  import_child_process7 = require("child_process");
36369
36410
  init_symlink_utils();
@@ -36372,12 +36413,12 @@ var init_file_lister = __esm({
36372
36413
  });
36373
36414
 
36374
36415
  // src/agent/simpleTelemetry.js
36375
- var import_fs7, import_path8;
36416
+ var import_fs8, import_path9;
36376
36417
  var init_simpleTelemetry = __esm({
36377
36418
  "src/agent/simpleTelemetry.js"() {
36378
36419
  "use strict";
36379
- import_fs7 = require("fs");
36380
- import_path8 = require("path");
36420
+ import_fs8 = require("fs");
36421
+ import_path9 = require("path");
36381
36422
  }
36382
36423
  });
36383
36424
 
@@ -37226,7 +37267,7 @@ var init_escape = __esm({
37226
37267
  });
37227
37268
 
37228
37269
  // node_modules/minimatch/dist/esm/index.js
37229
- 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;
37270
+ 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;
37230
37271
  var init_esm = __esm({
37231
37272
  "node_modules/minimatch/dist/esm/index.js"() {
37232
37273
  import_brace_expansion = __toESM(require_brace_expansion(), 1);
@@ -37295,11 +37336,11 @@ var init_esm = __esm({
37295
37336
  return (f4) => f4.length === len && f4 !== "." && f4 !== "..";
37296
37337
  };
37297
37338
  defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
37298
- path5 = {
37339
+ path6 = {
37299
37340
  win32: { sep: "\\" },
37300
37341
  posix: { sep: "/" }
37301
37342
  };
37302
- sep2 = defaultPlatform === "win32" ? path5.win32.sep : path5.posix.sep;
37343
+ sep2 = defaultPlatform === "win32" ? path6.win32.sep : path6.posix.sep;
37303
37344
  minimatch.sep = sep2;
37304
37345
  GLOBSTAR = Symbol("globstar **");
37305
37346
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -40214,22 +40255,22 @@ var init_esm3 = __esm({
40214
40255
  });
40215
40256
 
40216
40257
  // node_modules/path-scurry/dist/esm/index.js
40217
- var import_node_path, import_node_url, import_fs8, 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;
40258
+ var import_node_path, import_node_url, import_fs9, 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;
40218
40259
  var init_esm4 = __esm({
40219
40260
  "node_modules/path-scurry/dist/esm/index.js"() {
40220
40261
  init_esm2();
40221
40262
  import_node_path = require("node:path");
40222
40263
  import_node_url = require("node:url");
40223
- import_fs8 = require("fs");
40264
+ import_fs9 = require("fs");
40224
40265
  actualFS = __toESM(require("node:fs"), 1);
40225
40266
  import_promises = require("node:fs/promises");
40226
40267
  init_esm3();
40227
- realpathSync = import_fs8.realpathSync.native;
40268
+ realpathSync = import_fs9.realpathSync.native;
40228
40269
  defaultFS = {
40229
- lstatSync: import_fs8.lstatSync,
40230
- readdir: import_fs8.readdir,
40231
- readdirSync: import_fs8.readdirSync,
40232
- readlinkSync: import_fs8.readlinkSync,
40270
+ lstatSync: import_fs9.lstatSync,
40271
+ readdir: import_fs9.readdir,
40272
+ readdirSync: import_fs9.readdirSync,
40273
+ readlinkSync: import_fs9.readlinkSync,
40233
40274
  realpathSync,
40234
40275
  promises: {
40235
40276
  lstat: import_promises.lstat,
@@ -40486,12 +40527,12 @@ var init_esm4 = __esm({
40486
40527
  /**
40487
40528
  * Get the Path object referenced by the string path, resolved from this Path
40488
40529
  */
40489
- resolve(path8) {
40490
- if (!path8) {
40530
+ resolve(path9) {
40531
+ if (!path9) {
40491
40532
  return this;
40492
40533
  }
40493
- const rootPath = this.getRootString(path8);
40494
- const dir = path8.substring(rootPath.length);
40534
+ const rootPath = this.getRootString(path9);
40535
+ const dir = path9.substring(rootPath.length);
40495
40536
  const dirParts = dir.split(this.splitSep);
40496
40537
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
40497
40538
  return result;
@@ -41243,8 +41284,8 @@ var init_esm4 = __esm({
41243
41284
  /**
41244
41285
  * @internal
41245
41286
  */
41246
- getRootString(path8) {
41247
- return import_node_path.win32.parse(path8).root;
41287
+ getRootString(path9) {
41288
+ return import_node_path.win32.parse(path9).root;
41248
41289
  }
41249
41290
  /**
41250
41291
  * @internal
@@ -41290,8 +41331,8 @@ var init_esm4 = __esm({
41290
41331
  /**
41291
41332
  * @internal
41292
41333
  */
41293
- getRootString(path8) {
41294
- return path8.startsWith("/") ? "/" : "";
41334
+ getRootString(path9) {
41335
+ return path9.startsWith("/") ? "/" : "";
41295
41336
  }
41296
41337
  /**
41297
41338
  * @internal
@@ -41340,8 +41381,8 @@ var init_esm4 = __esm({
41340
41381
  *
41341
41382
  * @internal
41342
41383
  */
41343
- constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs9 = defaultFS } = {}) {
41344
- this.#fs = fsFromOption(fs9);
41384
+ constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs10 = defaultFS } = {}) {
41385
+ this.#fs = fsFromOption(fs10);
41345
41386
  if (cwd instanceof URL || cwd.startsWith("file://")) {
41346
41387
  cwd = (0, import_node_url.fileURLToPath)(cwd);
41347
41388
  }
@@ -41380,11 +41421,11 @@ var init_esm4 = __esm({
41380
41421
  /**
41381
41422
  * Get the depth of a provided path, string, or the cwd
41382
41423
  */
41383
- depth(path8 = this.cwd) {
41384
- if (typeof path8 === "string") {
41385
- path8 = this.cwd.resolve(path8);
41424
+ depth(path9 = this.cwd) {
41425
+ if (typeof path9 === "string") {
41426
+ path9 = this.cwd.resolve(path9);
41386
41427
  }
41387
- return path8.depth();
41428
+ return path9.depth();
41388
41429
  }
41389
41430
  /**
41390
41431
  * Return the cache of child entries. Exposed so subclasses can create
@@ -41871,9 +41912,9 @@ var init_esm4 = __esm({
41871
41912
  process2();
41872
41913
  return results;
41873
41914
  }
41874
- chdir(path8 = this.cwd) {
41915
+ chdir(path9 = this.cwd) {
41875
41916
  const oldCwd = this.cwd;
41876
- this.cwd = typeof path8 === "string" ? this.cwd.resolve(path8) : path8;
41917
+ this.cwd = typeof path9 === "string" ? this.cwd.resolve(path9) : path9;
41877
41918
  this.cwd[setAsCwd](oldCwd);
41878
41919
  }
41879
41920
  };
@@ -41899,8 +41940,8 @@ var init_esm4 = __esm({
41899
41940
  /**
41900
41941
  * @internal
41901
41942
  */
41902
- newRoot(fs9) {
41903
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
41943
+ newRoot(fs10) {
41944
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
41904
41945
  }
41905
41946
  /**
41906
41947
  * Return true if the provided path string is an absolute path
@@ -41928,8 +41969,8 @@ var init_esm4 = __esm({
41928
41969
  /**
41929
41970
  * @internal
41930
41971
  */
41931
- newRoot(fs9) {
41932
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs9 });
41972
+ newRoot(fs10) {
41973
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
41933
41974
  }
41934
41975
  /**
41935
41976
  * Return true if the provided path string is an absolute path
@@ -42248,8 +42289,8 @@ var init_processor = __esm({
42248
42289
  }
42249
42290
  // match, absolute, ifdir
42250
42291
  entries() {
42251
- return [...this.store.entries()].map(([path8, n4]) => [
42252
- path8,
42292
+ return [...this.store.entries()].map(([path9, n4]) => [
42293
+ path9,
42253
42294
  !!(n4 & 2),
42254
42295
  !!(n4 & 1)
42255
42296
  ]);
@@ -42462,9 +42503,9 @@ var init_walker = __esm({
42462
42503
  signal;
42463
42504
  maxDepth;
42464
42505
  includeChildMatches;
42465
- constructor(patterns, path8, opts) {
42506
+ constructor(patterns, path9, opts) {
42466
42507
  this.patterns = patterns;
42467
- this.path = path8;
42508
+ this.path = path9;
42468
42509
  this.opts = opts;
42469
42510
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
42470
42511
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -42483,11 +42524,11 @@ var init_walker = __esm({
42483
42524
  });
42484
42525
  }
42485
42526
  }
42486
- #ignored(path8) {
42487
- return this.seen.has(path8) || !!this.#ignore?.ignored?.(path8);
42527
+ #ignored(path9) {
42528
+ return this.seen.has(path9) || !!this.#ignore?.ignored?.(path9);
42488
42529
  }
42489
- #childrenIgnored(path8) {
42490
- return !!this.#ignore?.childrenIgnored?.(path8);
42530
+ #childrenIgnored(path9) {
42531
+ return !!this.#ignore?.childrenIgnored?.(path9);
42491
42532
  }
42492
42533
  // backpressure mechanism
42493
42534
  pause() {
@@ -42702,8 +42743,8 @@ var init_walker = __esm({
42702
42743
  };
42703
42744
  GlobWalker = class extends GlobUtil {
42704
42745
  matches = /* @__PURE__ */ new Set();
42705
- constructor(patterns, path8, opts) {
42706
- super(patterns, path8, opts);
42746
+ constructor(patterns, path9, opts) {
42747
+ super(patterns, path9, opts);
42707
42748
  }
42708
42749
  matchEmit(e4) {
42709
42750
  this.matches.add(e4);
@@ -42740,8 +42781,8 @@ var init_walker = __esm({
42740
42781
  };
42741
42782
  GlobStream = class extends GlobUtil {
42742
42783
  results;
42743
- constructor(patterns, path8, opts) {
42744
- super(patterns, path8, opts);
42784
+ constructor(patterns, path9, opts) {
42785
+ super(patterns, path9, opts);
42745
42786
  this.results = new Minipass({
42746
42787
  signal: this.signal,
42747
42788
  objectMode: true
@@ -43138,7 +43179,7 @@ function createWrappedTools(baseTools) {
43138
43179
  }
43139
43180
  return wrappedTools;
43140
43181
  }
43141
- var import_child_process8, import_util12, import_crypto3, import_events, import_fs9, import_fs10, import_path9, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
43182
+ var import_child_process8, import_util12, import_crypto3, import_events, import_fs10, import_fs11, import_path10, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
43142
43183
  var init_probeTool = __esm({
43143
43184
  "src/agent/probeTool.js"() {
43144
43185
  "use strict";
@@ -43147,9 +43188,9 @@ var init_probeTool = __esm({
43147
43188
  import_util12 = require("util");
43148
43189
  import_crypto3 = require("crypto");
43149
43190
  import_events = require("events");
43150
- import_fs9 = __toESM(require("fs"), 1);
43151
- import_fs10 = require("fs");
43152
- import_path9 = __toESM(require("path"), 1);
43191
+ import_fs10 = __toESM(require("fs"), 1);
43192
+ import_fs11 = require("fs");
43193
+ import_path10 = __toESM(require("path"), 1);
43153
43194
  init_esm5();
43154
43195
  init_symlink_utils();
43155
43196
  toolCallEmitter = new import_events.EventEmitter();
@@ -43238,17 +43279,17 @@ var init_probeTool = __esm({
43238
43279
  execute: async (params) => {
43239
43280
  const { directory = ".", workingDirectory } = params;
43240
43281
  const baseCwd = workingDirectory || process.cwd();
43241
- const secureBaseDir = import_path9.default.resolve(baseCwd);
43282
+ const secureBaseDir = import_path10.default.resolve(baseCwd);
43242
43283
  const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
43243
43284
  let targetDir;
43244
- if (import_path9.default.isAbsolute(directory)) {
43245
- targetDir = import_path9.default.resolve(directory);
43246
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path9.default.sep) && targetDir !== secureBaseDir) {
43285
+ if (import_path10.default.isAbsolute(directory)) {
43286
+ targetDir = import_path10.default.resolve(directory);
43287
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path10.default.sep) && targetDir !== secureBaseDir) {
43247
43288
  throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
43248
43289
  }
43249
43290
  } else {
43250
- targetDir = import_path9.default.resolve(secureBaseDir, directory);
43251
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path9.default.sep) && targetDir !== secureBaseDir) {
43291
+ targetDir = import_path10.default.resolve(secureBaseDir, directory);
43292
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path10.default.sep) && targetDir !== secureBaseDir) {
43252
43293
  throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
43253
43294
  }
43254
43295
  }
@@ -43257,7 +43298,7 @@ var init_probeTool = __esm({
43257
43298
  console.log(`[DEBUG] Listing files in directory: ${targetDir}`);
43258
43299
  }
43259
43300
  try {
43260
- const files = await import_fs10.promises.readdir(targetDir, { withFileTypes: true });
43301
+ const files = await import_fs11.promises.readdir(targetDir, { withFileTypes: true });
43261
43302
  const formatSize = (size) => {
43262
43303
  if (size < 1024) return `${size}B`;
43263
43304
  if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)}K`;
@@ -43265,7 +43306,7 @@ var init_probeTool = __esm({
43265
43306
  return `${(size / (1024 * 1024 * 1024)).toFixed(1)}G`;
43266
43307
  };
43267
43308
  const entries = await Promise.all(files.map(async (file) => {
43268
- const fullPath = import_path9.default.join(targetDir, file.name);
43309
+ const fullPath = import_path10.default.join(targetDir, file.name);
43269
43310
  const entryType = await getEntryType(file, fullPath);
43270
43311
  return {
43271
43312
  name: file.name,
@@ -43302,17 +43343,17 @@ var init_probeTool = __esm({
43302
43343
  throw new Error("Pattern is required for file search");
43303
43344
  }
43304
43345
  const baseCwd = workingDirectory || process.cwd();
43305
- const secureBaseDir = import_path9.default.resolve(baseCwd);
43346
+ const secureBaseDir = import_path10.default.resolve(baseCwd);
43306
43347
  const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
43307
43348
  let targetDir;
43308
- if (import_path9.default.isAbsolute(directory)) {
43309
- targetDir = import_path9.default.resolve(directory);
43310
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path9.default.sep) && targetDir !== secureBaseDir) {
43349
+ if (import_path10.default.isAbsolute(directory)) {
43350
+ targetDir = import_path10.default.resolve(directory);
43351
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path10.default.sep) && targetDir !== secureBaseDir) {
43311
43352
  throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
43312
43353
  }
43313
43354
  } else {
43314
- targetDir = import_path9.default.resolve(secureBaseDir, directory);
43315
- if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path9.default.sep) && targetDir !== secureBaseDir) {
43355
+ targetDir = import_path10.default.resolve(secureBaseDir, directory);
43356
+ if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + import_path10.default.sep) && targetDir !== secureBaseDir) {
43316
43357
  throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
43317
43358
  }
43318
43359
  }
@@ -45440,11 +45481,11 @@ var init_toKey = __esm({
45440
45481
  });
45441
45482
 
45442
45483
  // node_modules/lodash-es/_baseGet.js
45443
- function baseGet(object, path8) {
45444
- path8 = castPath_default(path8, object);
45445
- var index = 0, length = path8.length;
45484
+ function baseGet(object, path9) {
45485
+ path9 = castPath_default(path9, object);
45486
+ var index = 0, length = path9.length;
45446
45487
  while (object != null && index < length) {
45447
- object = object[toKey_default(path8[index++])];
45488
+ object = object[toKey_default(path9[index++])];
45448
45489
  }
45449
45490
  return index && index == length ? object : void 0;
45450
45491
  }
@@ -45458,8 +45499,8 @@ var init_baseGet = __esm({
45458
45499
  });
45459
45500
 
45460
45501
  // node_modules/lodash-es/get.js
45461
- function get2(object, path8, defaultValue) {
45462
- var result = object == null ? void 0 : baseGet_default(object, path8);
45502
+ function get2(object, path9, defaultValue) {
45503
+ var result = object == null ? void 0 : baseGet_default(object, path9);
45463
45504
  return result === void 0 ? defaultValue : result;
45464
45505
  }
45465
45506
  var get_default;
@@ -46822,11 +46863,11 @@ var init_baseHasIn = __esm({
46822
46863
  });
46823
46864
 
46824
46865
  // node_modules/lodash-es/_hasPath.js
46825
- function hasPath(object, path8, hasFunc) {
46826
- path8 = castPath_default(path8, object);
46827
- var index = -1, length = path8.length, result = false;
46866
+ function hasPath(object, path9, hasFunc) {
46867
+ path9 = castPath_default(path9, object);
46868
+ var index = -1, length = path9.length, result = false;
46828
46869
  while (++index < length) {
46829
- var key = toKey_default(path8[index]);
46870
+ var key = toKey_default(path9[index]);
46830
46871
  if (!(result = object != null && hasFunc(object, key))) {
46831
46872
  break;
46832
46873
  }
@@ -46852,8 +46893,8 @@ var init_hasPath = __esm({
46852
46893
  });
46853
46894
 
46854
46895
  // node_modules/lodash-es/hasIn.js
46855
- function hasIn(object, path8) {
46856
- return object != null && hasPath_default(object, path8, baseHasIn_default);
46896
+ function hasIn(object, path9) {
46897
+ return object != null && hasPath_default(object, path9, baseHasIn_default);
46857
46898
  }
46858
46899
  var hasIn_default;
46859
46900
  var init_hasIn = __esm({
@@ -46865,13 +46906,13 @@ var init_hasIn = __esm({
46865
46906
  });
46866
46907
 
46867
46908
  // node_modules/lodash-es/_baseMatchesProperty.js
46868
- function baseMatchesProperty(path8, srcValue) {
46869
- if (isKey_default(path8) && isStrictComparable_default(srcValue)) {
46870
- return matchesStrictComparable_default(toKey_default(path8), srcValue);
46909
+ function baseMatchesProperty(path9, srcValue) {
46910
+ if (isKey_default(path9) && isStrictComparable_default(srcValue)) {
46911
+ return matchesStrictComparable_default(toKey_default(path9), srcValue);
46871
46912
  }
46872
46913
  return function(object) {
46873
- var objValue = get_default(object, path8);
46874
- return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path8) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
46914
+ var objValue = get_default(object, path9);
46915
+ return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path9) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
46875
46916
  };
46876
46917
  }
46877
46918
  var COMPARE_PARTIAL_FLAG6, COMPARE_UNORDERED_FLAG4, baseMatchesProperty_default;
@@ -46904,9 +46945,9 @@ var init_baseProperty = __esm({
46904
46945
  });
46905
46946
 
46906
46947
  // node_modules/lodash-es/_basePropertyDeep.js
46907
- function basePropertyDeep(path8) {
46948
+ function basePropertyDeep(path9) {
46908
46949
  return function(object) {
46909
- return baseGet_default(object, path8);
46950
+ return baseGet_default(object, path9);
46910
46951
  };
46911
46952
  }
46912
46953
  var basePropertyDeep_default;
@@ -46918,8 +46959,8 @@ var init_basePropertyDeep = __esm({
46918
46959
  });
46919
46960
 
46920
46961
  // node_modules/lodash-es/property.js
46921
- function property(path8) {
46922
- return isKey_default(path8) ? baseProperty_default(toKey_default(path8)) : basePropertyDeep_default(path8);
46962
+ function property(path9) {
46963
+ return isKey_default(path9) ? baseProperty_default(toKey_default(path9)) : basePropertyDeep_default(path9);
46923
46964
  }
46924
46965
  var property_default;
46925
46966
  var init_property = __esm({
@@ -47538,8 +47579,8 @@ var init_baseHas = __esm({
47538
47579
  });
47539
47580
 
47540
47581
  // node_modules/lodash-es/has.js
47541
- function has(object, path8) {
47542
- return object != null && hasPath_default(object, path8, baseHas_default);
47582
+ function has(object, path9) {
47583
+ return object != null && hasPath_default(object, path9, baseHas_default);
47543
47584
  }
47544
47585
  var has_default;
47545
47586
  var init_has = __esm({
@@ -47745,14 +47786,14 @@ var init_negate = __esm({
47745
47786
  });
47746
47787
 
47747
47788
  // node_modules/lodash-es/_baseSet.js
47748
- function baseSet(object, path8, value, customizer) {
47789
+ function baseSet(object, path9, value, customizer) {
47749
47790
  if (!isObject_default(object)) {
47750
47791
  return object;
47751
47792
  }
47752
- path8 = castPath_default(path8, object);
47753
- var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
47793
+ path9 = castPath_default(path9, object);
47794
+ var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
47754
47795
  while (nested != null && ++index < length) {
47755
- var key = toKey_default(path8[index]), newValue = value;
47796
+ var key = toKey_default(path9[index]), newValue = value;
47756
47797
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
47757
47798
  return object;
47758
47799
  }
@@ -47760,7 +47801,7 @@ function baseSet(object, path8, value, customizer) {
47760
47801
  var objValue = nested[key];
47761
47802
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
47762
47803
  if (newValue === void 0) {
47763
- newValue = isObject_default(objValue) ? objValue : isIndex_default(path8[index + 1]) ? [] : {};
47804
+ newValue = isObject_default(objValue) ? objValue : isIndex_default(path9[index + 1]) ? [] : {};
47764
47805
  }
47765
47806
  }
47766
47807
  assignValue_default(nested, key, newValue);
@@ -47784,9 +47825,9 @@ var init_baseSet = __esm({
47784
47825
  function basePickBy(object, paths, predicate) {
47785
47826
  var index = -1, length = paths.length, result = {};
47786
47827
  while (++index < length) {
47787
- var path8 = paths[index], value = baseGet_default(object, path8);
47788
- if (predicate(value, path8)) {
47789
- baseSet_default(result, castPath_default(path8, object), value);
47828
+ var path9 = paths[index], value = baseGet_default(object, path9);
47829
+ if (predicate(value, path9)) {
47830
+ baseSet_default(result, castPath_default(path9, object), value);
47790
47831
  }
47791
47832
  }
47792
47833
  return result;
@@ -47810,8 +47851,8 @@ function pickBy(object, predicate) {
47810
47851
  return [prop];
47811
47852
  });
47812
47853
  predicate = baseIteratee_default(predicate);
47813
- return basePickBy_default(object, props, function(value, path8) {
47814
- return predicate(value, path8[0]);
47854
+ return basePickBy_default(object, props, function(value, path9) {
47855
+ return predicate(value, path9[0]);
47815
47856
  });
47816
47857
  }
47817
47858
  var pickBy_default;
@@ -50524,12 +50565,12 @@ function assignCategoriesMapProp(tokenTypes) {
50524
50565
  singleAssignCategoriesToksMap([], currTokType);
50525
50566
  });
50526
50567
  }
50527
- function singleAssignCategoriesToksMap(path8, nextNode) {
50528
- forEach_default(path8, (pathNode) => {
50568
+ function singleAssignCategoriesToksMap(path9, nextNode) {
50569
+ forEach_default(path9, (pathNode) => {
50529
50570
  nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;
50530
50571
  });
50531
50572
  forEach_default(nextNode.CATEGORIES, (nextCategory) => {
50532
- const newPath = path8.concat(nextNode);
50573
+ const newPath = path9.concat(nextNode);
50533
50574
  if (!includes_default(newPath, nextCategory)) {
50534
50575
  singleAssignCategoriesToksMap(newPath, nextCategory);
50535
50576
  }
@@ -51699,10 +51740,10 @@ var init_interpreter = __esm({
51699
51740
  init_rest();
51700
51741
  init_api2();
51701
51742
  AbstractNextPossibleTokensWalker = class extends RestWalker {
51702
- constructor(topProd, path8) {
51743
+ constructor(topProd, path9) {
51703
51744
  super();
51704
51745
  this.topProd = topProd;
51705
- this.path = path8;
51746
+ this.path = path9;
51706
51747
  this.possibleTokTypes = [];
51707
51748
  this.nextProductionName = "";
51708
51749
  this.nextProductionOccurrence = 0;
@@ -51746,9 +51787,9 @@ var init_interpreter = __esm({
51746
51787
  }
51747
51788
  };
51748
51789
  NextAfterTokenWalker = class extends AbstractNextPossibleTokensWalker {
51749
- constructor(topProd, path8) {
51750
- super(topProd, path8);
51751
- this.path = path8;
51790
+ constructor(topProd, path9) {
51791
+ super(topProd, path9);
51792
+ this.path = path9;
51752
51793
  this.nextTerminalName = "";
51753
51794
  this.nextTerminalOccurrence = 0;
51754
51795
  this.nextTerminalName = this.path.lastTok.name;
@@ -51989,10 +52030,10 @@ function initializeArrayOfArrays(size) {
51989
52030
  }
51990
52031
  return result;
51991
52032
  }
51992
- function pathToHashKeys(path8) {
52033
+ function pathToHashKeys(path9) {
51993
52034
  let keys2 = [""];
51994
- for (let i4 = 0; i4 < path8.length; i4++) {
51995
- const tokType = path8[i4];
52035
+ for (let i4 = 0; i4 < path9.length; i4++) {
52036
+ const tokType = path9[i4];
51996
52037
  const longerKeys = [];
51997
52038
  for (let j4 = 0; j4 < keys2.length; j4++) {
51998
52039
  const currShorterKey = keys2[j4];
@@ -52295,7 +52336,7 @@ function validateRuleIsOverridden(ruleName, definedRulesNames, className) {
52295
52336
  }
52296
52337
  return errors;
52297
52338
  }
52298
- function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = []) {
52339
+ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path9 = []) {
52299
52340
  const errors = [];
52300
52341
  const nextNonTerminals = getFirstNoneTerminal(currRule.definition);
52301
52342
  if (isEmpty_default(nextNonTerminals)) {
@@ -52307,15 +52348,15 @@ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = [])
52307
52348
  errors.push({
52308
52349
  message: errMsgProvider.buildLeftRecursionError({
52309
52350
  topLevelRule: topRule,
52310
- leftRecursionPath: path8
52351
+ leftRecursionPath: path9
52311
52352
  }),
52312
52353
  type: ParserDefinitionErrorType.LEFT_RECURSION,
52313
52354
  ruleName
52314
52355
  });
52315
52356
  }
52316
- const validNextSteps = difference_default(nextNonTerminals, path8.concat([topRule]));
52357
+ const validNextSteps = difference_default(nextNonTerminals, path9.concat([topRule]));
52317
52358
  const errorsFromNextSteps = flatMap_default(validNextSteps, (currRefRule) => {
52318
- const newPath = clone_default(path8);
52359
+ const newPath = clone_default(path9);
52319
52360
  newPath.push(currRefRule);
52320
52361
  return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);
52321
52362
  });
@@ -64919,11 +64960,11 @@ var require_baseGet = __commonJS({
64919
64960
  "node_modules/lodash/_baseGet.js"(exports2, module2) {
64920
64961
  var castPath2 = require_castPath();
64921
64962
  var toKey2 = require_toKey();
64922
- function baseGet2(object, path8) {
64923
- path8 = castPath2(path8, object);
64924
- var index = 0, length = path8.length;
64963
+ function baseGet2(object, path9) {
64964
+ path9 = castPath2(path9, object);
64965
+ var index = 0, length = path9.length;
64925
64966
  while (object != null && index < length) {
64926
- object = object[toKey2(path8[index++])];
64967
+ object = object[toKey2(path9[index++])];
64927
64968
  }
64928
64969
  return index && index == length ? object : void 0;
64929
64970
  }
@@ -64935,8 +64976,8 @@ var require_baseGet = __commonJS({
64935
64976
  var require_get = __commonJS({
64936
64977
  "node_modules/lodash/get.js"(exports2, module2) {
64937
64978
  var baseGet2 = require_baseGet();
64938
- function get3(object, path8, defaultValue) {
64939
- var result = object == null ? void 0 : baseGet2(object, path8);
64979
+ function get3(object, path9, defaultValue) {
64980
+ var result = object == null ? void 0 : baseGet2(object, path9);
64940
64981
  return result === void 0 ? defaultValue : result;
64941
64982
  }
64942
64983
  module2.exports = get3;
@@ -64962,11 +65003,11 @@ var require_hasPath = __commonJS({
64962
65003
  var isIndex2 = require_isIndex();
64963
65004
  var isLength2 = require_isLength();
64964
65005
  var toKey2 = require_toKey();
64965
- function hasPath2(object, path8, hasFunc) {
64966
- path8 = castPath2(path8, object);
64967
- var index = -1, length = path8.length, result = false;
65006
+ function hasPath2(object, path9, hasFunc) {
65007
+ path9 = castPath2(path9, object);
65008
+ var index = -1, length = path9.length, result = false;
64968
65009
  while (++index < length) {
64969
- var key = toKey2(path8[index]);
65010
+ var key = toKey2(path9[index]);
64970
65011
  if (!(result = object != null && hasFunc(object, key))) {
64971
65012
  break;
64972
65013
  }
@@ -64987,8 +65028,8 @@ var require_hasIn = __commonJS({
64987
65028
  "node_modules/lodash/hasIn.js"(exports2, module2) {
64988
65029
  var baseHasIn2 = require_baseHasIn();
64989
65030
  var hasPath2 = require_hasPath();
64990
- function hasIn2(object, path8) {
64991
- return object != null && hasPath2(object, path8, baseHasIn2);
65031
+ function hasIn2(object, path9) {
65032
+ return object != null && hasPath2(object, path9, baseHasIn2);
64992
65033
  }
64993
65034
  module2.exports = hasIn2;
64994
65035
  }
@@ -65006,13 +65047,13 @@ var require_baseMatchesProperty = __commonJS({
65006
65047
  var toKey2 = require_toKey();
65007
65048
  var COMPARE_PARTIAL_FLAG7 = 1;
65008
65049
  var COMPARE_UNORDERED_FLAG5 = 2;
65009
- function baseMatchesProperty2(path8, srcValue) {
65010
- if (isKey2(path8) && isStrictComparable2(srcValue)) {
65011
- return matchesStrictComparable2(toKey2(path8), srcValue);
65050
+ function baseMatchesProperty2(path9, srcValue) {
65051
+ if (isKey2(path9) && isStrictComparable2(srcValue)) {
65052
+ return matchesStrictComparable2(toKey2(path9), srcValue);
65012
65053
  }
65013
65054
  return function(object) {
65014
- var objValue = get3(object, path8);
65015
- return objValue === void 0 && objValue === srcValue ? hasIn2(object, path8) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
65055
+ var objValue = get3(object, path9);
65056
+ return objValue === void 0 && objValue === srcValue ? hasIn2(object, path9) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
65016
65057
  };
65017
65058
  }
65018
65059
  module2.exports = baseMatchesProperty2;
@@ -65035,9 +65076,9 @@ var require_baseProperty = __commonJS({
65035
65076
  var require_basePropertyDeep = __commonJS({
65036
65077
  "node_modules/lodash/_basePropertyDeep.js"(exports2, module2) {
65037
65078
  var baseGet2 = require_baseGet();
65038
- function basePropertyDeep2(path8) {
65079
+ function basePropertyDeep2(path9) {
65039
65080
  return function(object) {
65040
- return baseGet2(object, path8);
65081
+ return baseGet2(object, path9);
65041
65082
  };
65042
65083
  }
65043
65084
  module2.exports = basePropertyDeep2;
@@ -65051,8 +65092,8 @@ var require_property = __commonJS({
65051
65092
  var basePropertyDeep2 = require_basePropertyDeep();
65052
65093
  var isKey2 = require_isKey();
65053
65094
  var toKey2 = require_toKey();
65054
- function property2(path8) {
65055
- return isKey2(path8) ? baseProperty2(toKey2(path8)) : basePropertyDeep2(path8);
65095
+ function property2(path9) {
65096
+ return isKey2(path9) ? baseProperty2(toKey2(path9)) : basePropertyDeep2(path9);
65056
65097
  }
65057
65098
  module2.exports = property2;
65058
65099
  }
@@ -65114,8 +65155,8 @@ var require_has = __commonJS({
65114
65155
  "node_modules/lodash/has.js"(exports2, module2) {
65115
65156
  var baseHas2 = require_baseHas();
65116
65157
  var hasPath2 = require_hasPath();
65117
- function has2(object, path8) {
65118
- return object != null && hasPath2(object, path8, baseHas2);
65158
+ function has2(object, path9) {
65159
+ return object != null && hasPath2(object, path9, baseHas2);
65119
65160
  }
65120
65161
  module2.exports = has2;
65121
65162
  }
@@ -67389,14 +67430,14 @@ var require_baseSet = __commonJS({
67389
67430
  var isIndex2 = require_isIndex();
67390
67431
  var isObject2 = require_isObject();
67391
67432
  var toKey2 = require_toKey();
67392
- function baseSet2(object, path8, value, customizer) {
67433
+ function baseSet2(object, path9, value, customizer) {
67393
67434
  if (!isObject2(object)) {
67394
67435
  return object;
67395
67436
  }
67396
- path8 = castPath2(path8, object);
67397
- var index = -1, length = path8.length, lastIndex = length - 1, nested = object;
67437
+ path9 = castPath2(path9, object);
67438
+ var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
67398
67439
  while (nested != null && ++index < length) {
67399
- var key = toKey2(path8[index]), newValue = value;
67440
+ var key = toKey2(path9[index]), newValue = value;
67400
67441
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
67401
67442
  return object;
67402
67443
  }
@@ -67404,7 +67445,7 @@ var require_baseSet = __commonJS({
67404
67445
  var objValue = nested[key];
67405
67446
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
67406
67447
  if (newValue === void 0) {
67407
- newValue = isObject2(objValue) ? objValue : isIndex2(path8[index + 1]) ? [] : {};
67448
+ newValue = isObject2(objValue) ? objValue : isIndex2(path9[index + 1]) ? [] : {};
67408
67449
  }
67409
67450
  }
67410
67451
  assignValue2(nested, key, newValue);
@@ -67425,9 +67466,9 @@ var require_basePickBy = __commonJS({
67425
67466
  function basePickBy2(object, paths, predicate) {
67426
67467
  var index = -1, length = paths.length, result = {};
67427
67468
  while (++index < length) {
67428
- var path8 = paths[index], value = baseGet2(object, path8);
67429
- if (predicate(value, path8)) {
67430
- baseSet2(result, castPath2(path8, object), value);
67469
+ var path9 = paths[index], value = baseGet2(object, path9);
67470
+ if (predicate(value, path9)) {
67471
+ baseSet2(result, castPath2(path9, object), value);
67431
67472
  }
67432
67473
  }
67433
67474
  return result;
@@ -67442,8 +67483,8 @@ var require_basePick = __commonJS({
67442
67483
  var basePickBy2 = require_basePickBy();
67443
67484
  var hasIn2 = require_hasIn();
67444
67485
  function basePick(object, paths) {
67445
- return basePickBy2(object, paths, function(value, path8) {
67446
- return hasIn2(object, path8);
67486
+ return basePickBy2(object, paths, function(value, path9) {
67487
+ return hasIn2(object, path9);
67447
67488
  });
67448
67489
  }
67449
67490
  module2.exports = basePick;
@@ -68497,15 +68538,15 @@ var require_parent_dummy_chains = __commonJS({
68497
68538
  var node = g4.node(v4);
68498
68539
  var edgeObj = node.edgeObj;
68499
68540
  var pathData = findPath(g4, postorderNums, edgeObj.v, edgeObj.w);
68500
- var path8 = pathData.path;
68541
+ var path9 = pathData.path;
68501
68542
  var lca = pathData.lca;
68502
68543
  var pathIdx = 0;
68503
- var pathV = path8[pathIdx];
68544
+ var pathV = path9[pathIdx];
68504
68545
  var ascending = true;
68505
68546
  while (v4 !== edgeObj.w) {
68506
68547
  node = g4.node(v4);
68507
68548
  if (ascending) {
68508
- while ((pathV = path8[pathIdx]) !== lca && g4.node(pathV).maxRank < node.rank) {
68549
+ while ((pathV = path9[pathIdx]) !== lca && g4.node(pathV).maxRank < node.rank) {
68509
68550
  pathIdx++;
68510
68551
  }
68511
68552
  if (pathV === lca) {
@@ -68513,10 +68554,10 @@ var require_parent_dummy_chains = __commonJS({
68513
68554
  }
68514
68555
  }
68515
68556
  if (!ascending) {
68516
- while (pathIdx < path8.length - 1 && g4.node(pathV = path8[pathIdx + 1]).minRank <= node.rank) {
68557
+ while (pathIdx < path9.length - 1 && g4.node(pathV = path9[pathIdx + 1]).minRank <= node.rank) {
68517
68558
  pathIdx++;
68518
68559
  }
68519
- pathV = path8[pathIdx];
68560
+ pathV = path9[pathIdx];
68520
68561
  }
68521
68562
  g4.setParent(v4, pathV);
68522
68563
  v4 = g4.successors(v4)[0];
@@ -70689,8 +70730,8 @@ var init_svg_generator = __esm({
70689
70730
  elements.push(this.generateNodeWithPad(node, padX, padY));
70690
70731
  }
70691
70732
  for (const edge of layout.edges) {
70692
- const { path: path8, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
70693
- elements.push(path8);
70733
+ const { path: path9, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
70734
+ elements.push(path9);
70694
70735
  if (overlay)
70695
70736
  overlays.push(overlay);
70696
70737
  }
@@ -77006,8 +77047,8 @@ var require_utils = __commonJS({
77006
77047
  }
77007
77048
  return ind;
77008
77049
  }
77009
- function removeDotSegments(path8) {
77010
- let input = path8;
77050
+ function removeDotSegments(path9) {
77051
+ let input = path9;
77011
77052
  const output = [];
77012
77053
  let nextSlash = -1;
77013
77054
  let len = 0;
@@ -77206,8 +77247,8 @@ var require_schemes = __commonJS({
77206
77247
  wsComponent.secure = void 0;
77207
77248
  }
77208
77249
  if (wsComponent.resourceName) {
77209
- const [path8, query2] = wsComponent.resourceName.split("?");
77210
- wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
77250
+ const [path9, query2] = wsComponent.resourceName.split("?");
77251
+ wsComponent.path = path9 && path9 !== "/" ? path9 : void 0;
77211
77252
  wsComponent.query = query2;
77212
77253
  wsComponent.resourceName = void 0;
77213
77254
  }
@@ -80550,7 +80591,7 @@ function validateJsonResponse(response, options = {}) {
80550
80591
  }
80551
80592
  if (!valid) {
80552
80593
  const formattedErrors = validate2.errors.map((err) => {
80553
- const path8 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
80594
+ const path9 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
80554
80595
  let message = "";
80555
80596
  let suggestion = "";
80556
80597
  if (err.keyword === "additionalProperties") {
@@ -80588,7 +80629,7 @@ function validateJsonResponse(response, options = {}) {
80588
80629
  message = err.message;
80589
80630
  suggestion = "";
80590
80631
  }
80591
- const location = path8 ? `at '${path8}'` : "at root";
80632
+ const location = path9 ? `at '${path9}'` : "at root";
80592
80633
  return suggestion ? `${location}: ${message} \u2192 ${suggestion}` : `${location}: ${message}`;
80593
80634
  });
80594
80635
  const errorSummary = formattedErrors.join("\n ");
@@ -80911,7 +80952,7 @@ function extractMermaidFromJson(response) {
80911
80952
  }
80912
80953
  const diagrams = [];
80913
80954
  const jsonPaths = [];
80914
- function searchObject(obj, path8 = []) {
80955
+ function searchObject(obj, path9 = []) {
80915
80956
  if (typeof obj === "string") {
80916
80957
  const mermaidPattern = /```mermaid([^\n`]*?)(?:\n|\\n)([\s\S]*?)```/gi;
80917
80958
  let match2;
@@ -80925,14 +80966,14 @@ function extractMermaidFromJson(response) {
80925
80966
  endIndex: match2.index + match2[0].length,
80926
80967
  attributes,
80927
80968
  isInJson: true,
80928
- jsonPath: path8.join(".")
80969
+ jsonPath: path9.join(".")
80929
80970
  });
80930
- jsonPaths.push(path8.join("."));
80971
+ jsonPaths.push(path9.join("."));
80931
80972
  }
80932
80973
  } else if (Array.isArray(obj)) {
80933
- obj.forEach((item, index) => searchObject(item, [...path8, `[${index}]`]));
80974
+ obj.forEach((item, index) => searchObject(item, [...path9, `[${index}]`]));
80934
80975
  } else if (obj && typeof obj === "object") {
80935
- Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path8, key]));
80976
+ Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path9, key]));
80936
80977
  }
80937
80978
  }
80938
80979
  searchObject(parsedJson);
@@ -81189,7 +81230,7 @@ async function tryMaidAutoFix(diagramContent, options = {}) {
81189
81230
  }
81190
81231
  }
81191
81232
  async function validateAndFixMermaidResponse(response, options = {}) {
81192
- const { schema, debug, path: path8, provider, model, tracer } = options;
81233
+ const { schema, debug, path: path9, provider, model, tracer } = options;
81193
81234
  const startTime = Date.now();
81194
81235
  if (debug) {
81195
81236
  console.log(`[DEBUG] Mermaid validation: Starting maid-based validation for response (${response.length} chars)`);
@@ -81346,7 +81387,7 @@ ${maidResult.fixed}
81346
81387
  }
81347
81388
  const aiFixingStart = Date.now();
81348
81389
  const mermaidFixer = new MermaidFixingAgent({
81349
- path: path8,
81390
+ path: path9,
81350
81391
  provider,
81351
81392
  model,
81352
81393
  debug,
@@ -81588,8 +81629,8 @@ Schema Validation Errors:
81588
81629
  ${validationResult.errorSummary}`;
81589
81630
  } else if (validationResult.schemaErrors && validationResult.schemaErrors.length > 0) {
81590
81631
  const errors = validationResult.schemaErrors.map((err) => {
81591
- const path8 = err.instancePath || "(root)";
81592
- return ` ${path8}: ${err.message}`;
81632
+ const path9 = err.instancePath || "(root)";
81633
+ return ` ${path9}: ${err.message}`;
81593
81634
  }).join("\n");
81594
81635
  schemaErrorDetails = `
81595
81636
 
@@ -81949,11 +81990,11 @@ function loadMCPConfigurationFromPath(configPath) {
81949
81990
  if (!configPath) {
81950
81991
  throw new Error("Config path is required");
81951
81992
  }
81952
- if (!(0, import_fs11.existsSync)(configPath)) {
81993
+ if (!(0, import_fs12.existsSync)(configPath)) {
81953
81994
  throw new Error(`MCP configuration file not found: ${configPath}`);
81954
81995
  }
81955
81996
  try {
81956
- const content = (0, import_fs11.readFileSync)(configPath, "utf8");
81997
+ const content = (0, import_fs12.readFileSync)(configPath, "utf8");
81957
81998
  const config = JSON.parse(content);
81958
81999
  if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
81959
82000
  console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
@@ -81968,19 +82009,19 @@ function loadMCPConfiguration() {
81968
82009
  // Environment variable path
81969
82010
  process.env.MCP_CONFIG_PATH,
81970
82011
  // Local project paths
81971
- (0, import_path10.join)(process.cwd(), ".mcp", "config.json"),
81972
- (0, import_path10.join)(process.cwd(), "mcp.config.json"),
82012
+ (0, import_path11.join)(process.cwd(), ".mcp", "config.json"),
82013
+ (0, import_path11.join)(process.cwd(), "mcp.config.json"),
81973
82014
  // Home directory paths
81974
- (0, import_path10.join)((0, import_os3.homedir)(), ".config", "probe", "mcp.json"),
81975
- (0, import_path10.join)((0, import_os3.homedir)(), ".mcp", "config.json"),
82015
+ (0, import_path11.join)((0, import_os3.homedir)(), ".config", "probe", "mcp.json"),
82016
+ (0, import_path11.join)((0, import_os3.homedir)(), ".mcp", "config.json"),
81976
82017
  // Claude-style config location
81977
- (0, import_path10.join)((0, import_os3.homedir)(), "Library", "Application Support", "Claude", "mcp_config.json")
82018
+ (0, import_path11.join)((0, import_os3.homedir)(), "Library", "Application Support", "Claude", "mcp_config.json")
81978
82019
  ].filter(Boolean);
81979
82020
  let config = null;
81980
82021
  for (const configPath of configPaths) {
81981
- if ((0, import_fs11.existsSync)(configPath)) {
82022
+ if ((0, import_fs12.existsSync)(configPath)) {
81982
82023
  try {
81983
- const content = (0, import_fs11.readFileSync)(configPath, "utf8");
82024
+ const content = (0, import_fs12.readFileSync)(configPath, "utf8");
81984
82025
  config = JSON.parse(content);
81985
82026
  if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
81986
82027
  console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
@@ -82076,22 +82117,22 @@ function parseEnabledServers(config) {
82076
82117
  }
82077
82118
  return servers;
82078
82119
  }
82079
- var import_fs11, import_path10, import_os3, import_url4, __filename4, __dirname4, DEFAULT_CONFIG;
82120
+ var import_fs12, import_path11, import_os3, import_url4, __filename4, __dirname4, DEFAULT_CONFIG;
82080
82121
  var init_config = __esm({
82081
82122
  "src/agent/mcp/config.js"() {
82082
82123
  "use strict";
82083
- import_fs11 = require("fs");
82084
- import_path10 = require("path");
82124
+ import_fs12 = require("fs");
82125
+ import_path11 = require("path");
82085
82126
  import_os3 = require("os");
82086
82127
  import_url4 = require("url");
82087
82128
  __filename4 = (0, import_url4.fileURLToPath)("file:///");
82088
- __dirname4 = (0, import_path10.dirname)(__filename4);
82129
+ __dirname4 = (0, import_path11.dirname)(__filename4);
82089
82130
  DEFAULT_CONFIG = {
82090
82131
  mcpServers: {
82091
82132
  // Example probe server configuration
82092
82133
  "probe-local": {
82093
82134
  command: "node",
82094
- args: [(0, import_path10.join)(__dirname4, "../../../examples/chat/mcpServer.js")],
82135
+ args: [(0, import_path11.join)(__dirname4, "../../../examples/chat/mcpServer.js")],
82095
82136
  transport: "stdio",
82096
82137
  enabled: false
82097
82138
  },
@@ -84211,12 +84252,12 @@ async function createEnhancedClaudeCLIEngine(options = {}) {
84211
84252
  console.log("[DEBUG] Built-in MCP server started");
84212
84253
  console.log("[DEBUG] MCP URL:", `http://${host}:${port}/mcp`);
84213
84254
  }
84214
- mcpConfigPath = import_path11.default.join(import_os4.default.tmpdir(), `probe-mcp-${session.id}.json`);
84255
+ mcpConfigPath = import_path12.default.join(import_os4.default.tmpdir(), `probe-mcp-${session.id}.json`);
84215
84256
  const mcpConfig = {
84216
84257
  mcpServers: {
84217
84258
  probe: {
84218
84259
  command: "node",
84219
- args: [import_path11.default.join(process.cwd(), "mcp-probe-server.js")],
84260
+ args: [import_path12.default.join(process.cwd(), "mcp-probe-server.js")],
84220
84261
  env: {
84221
84262
  PROBE_WORKSPACE: process.cwd(),
84222
84263
  DEBUG: debug ? "true" : "false"
@@ -84585,14 +84626,14 @@ function combinePrompts(systemPrompt, customPrompt, agent) {
84585
84626
  }
84586
84627
  return systemPrompt || "";
84587
84628
  }
84588
- var import_child_process9, import_crypto6, import_promises2, import_path11, import_os4, import_events3;
84629
+ var import_child_process9, import_crypto6, import_promises2, import_path12, import_os4, import_events3;
84589
84630
  var init_enhanced_claude_code = __esm({
84590
84631
  "src/agent/engines/enhanced-claude-code.js"() {
84591
84632
  "use strict";
84592
84633
  import_child_process9 = require("child_process");
84593
84634
  import_crypto6 = require("crypto");
84594
84635
  import_promises2 = __toESM(require("fs/promises"), 1);
84595
- import_path11 = __toESM(require("path"), 1);
84636
+ import_path12 = __toESM(require("path"), 1);
84596
84637
  import_os4 = __toESM(require("os"), 1);
84597
84638
  import_events3 = require("events");
84598
84639
  init_built_in_server();
@@ -84950,7 +84991,7 @@ __export(ProbeAgent_exports, {
84950
84991
  ProbeAgent: () => ProbeAgent
84951
84992
  });
84952
84993
  module.exports = __toCommonJS(ProbeAgent_exports);
84953
- var import_dotenv2, import_anthropic2, import_openai2, import_google2, import_ai5, import_crypto8, import_events4, import_fs12, import_promises3, import_path12, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, MAX_IMAGE_FILE_SIZE, ProbeAgent;
84994
+ var import_dotenv2, import_anthropic2, import_openai2, import_google2, import_ai5, import_crypto8, import_events4, import_fs13, import_promises3, import_path13, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, MAX_IMAGE_FILE_SIZE, ProbeAgent;
84954
84995
  var init_ProbeAgent = __esm({
84955
84996
  "src/agent/ProbeAgent.js"() {
84956
84997
  import_dotenv2 = __toESM(require_main(), 1);
@@ -84961,9 +85002,9 @@ var init_ProbeAgent = __esm({
84961
85002
  import_ai5 = require("ai");
84962
85003
  import_crypto8 = require("crypto");
84963
85004
  import_events4 = require("events");
84964
- import_fs12 = require("fs");
85005
+ import_fs13 = require("fs");
84965
85006
  import_promises3 = require("fs/promises");
84966
- import_path12 = require("path");
85007
+ import_path13 = require("path");
84967
85008
  init_tokenCounter();
84968
85009
  init_InMemoryStorageAdapter();
84969
85010
  init_HookManager();
@@ -85002,6 +85043,7 @@ var init_ProbeAgent = __esm({
85002
85043
  * @param {boolean} [options.allowEdit=false] - Allow the use of the 'implement' tool
85003
85044
  * @param {boolean} [options.enableDelegate=false] - Enable the delegate tool for task distribution to subagents
85004
85045
  * @param {string} [options.path] - Search directory path
85046
+ * @param {string} [options.cwd] - Working directory for resolving relative paths (independent of allowedFolders)
85005
85047
  * @param {string} [options.provider] - Force specific AI provider
85006
85048
  * @param {string} [options.model] - Override model name
85007
85049
  * @param {boolean} [options.debug] - Enable debug mode
@@ -85030,6 +85072,7 @@ var init_ProbeAgent = __esm({
85030
85072
  * @param {Array<Object>} [options.fallback.providers] - List of provider configurations for custom fallback
85031
85073
  * @param {boolean} [options.fallback.stopOnSuccess=true] - Stop on first success
85032
85074
  * @param {number} [options.fallback.maxTotalAttempts=10] - Maximum total attempts across all providers
85075
+ * @param {string} [options.completionPrompt] - Custom prompt to run after attempt_completion for validation/review (runs before mermaid/JSON validation)
85033
85076
  */
85034
85077
  constructor(options = {}) {
85035
85078
  this.sessionId = options.sessionId || (0, import_crypto8.randomUUID)();
@@ -85051,6 +85094,7 @@ var init_ProbeAgent = __esm({
85051
85094
  this.maxIterations = options.maxIterations || null;
85052
85095
  this.disableMermaidValidation = !!options.disableMermaidValidation;
85053
85096
  this.disableJsonValidation = !!options.disableJsonValidation;
85097
+ this.completionPrompt = options.completionPrompt || null;
85054
85098
  const effectiveAllowedTools = options.disableTools ? [] : options.allowedTools;
85055
85099
  this.allowedTools = this._parseAllowedTools(effectiveAllowedTools);
85056
85100
  this.storageAdapter = options.storageAdapter || new InMemoryStorageAdapter();
@@ -85069,6 +85113,7 @@ var init_ProbeAgent = __esm({
85069
85113
  } else {
85070
85114
  this.allowedFolders = [process.cwd()];
85071
85115
  }
85116
+ this.cwd = options.cwd || null;
85072
85117
  this.clientApiProvider = options.provider || null;
85073
85118
  this.clientApiModel = options.model || null;
85074
85119
  this.clientApiKey = null;
@@ -85247,7 +85292,8 @@ var init_ProbeAgent = __esm({
85247
85292
  const configOptions = {
85248
85293
  sessionId: this.sessionId,
85249
85294
  debug: this.debug,
85250
- defaultPath: this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd(),
85295
+ // Use explicit cwd if set, otherwise fall back to first allowed folder
85296
+ cwd: this.cwd || (this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd()),
85251
85297
  allowedFolders: this.allowedFolders,
85252
85298
  outline: this.outline,
85253
85299
  allowEdit: this.allowEdit,
@@ -85285,7 +85331,7 @@ var init_ProbeAgent = __esm({
85285
85331
  if (!imagePath) {
85286
85332
  throw new Error("Image path is required");
85287
85333
  }
85288
- const filename = (0, import_path12.basename)(imagePath);
85334
+ const filename = (0, import_path13.basename)(imagePath);
85289
85335
  const extension = filename.toLowerCase().split(".").pop();
85290
85336
  if (!extension || !SUPPORTED_IMAGE_EXTENSIONS.includes(extension)) {
85291
85337
  throw new Error(`Invalid or unsupported image extension: ${extension}. Supported formats: ${SUPPORTED_IMAGE_EXTENSIONS.join(", ")}`);
@@ -85840,7 +85886,7 @@ var init_ProbeAgent = __esm({
85840
85886
  let resolvedPath2 = imagePath;
85841
85887
  if (!imagePath.includes("/") && !imagePath.includes("\\")) {
85842
85888
  for (const dir of listFilesDirectories) {
85843
- const potentialPath = (0, import_path12.resolve)(dir, imagePath);
85889
+ const potentialPath = (0, import_path13.resolve)(dir, imagePath);
85844
85890
  const loaded = await this.loadImageIfValid(potentialPath);
85845
85891
  if (loaded) {
85846
85892
  if (this.debug) {
@@ -85865,7 +85911,7 @@ var init_ProbeAgent = __esm({
85865
85911
  let match2;
85866
85912
  while ((match2 = fileHeaderPattern.exec(content)) !== null) {
85867
85913
  const filePath = match2[1].trim();
85868
- const dir = (0, import_path12.dirname)(filePath);
85914
+ const dir = (0, import_path13.dirname)(filePath);
85869
85915
  if (dir && dir !== ".") {
85870
85916
  directories.push(dir);
85871
85917
  if (this.debug) {
@@ -85910,17 +85956,17 @@ var init_ProbeAgent = __esm({
85910
85956
  const allowedDirs = this.allowedFolders && this.allowedFolders.length > 0 ? this.allowedFolders : [process.cwd()];
85911
85957
  let absolutePath;
85912
85958
  let isPathAllowed2 = false;
85913
- if ((0, import_path12.isAbsolute)(imagePath)) {
85914
- absolutePath = (0, import_path12.normalize)((0, import_path12.resolve)(imagePath));
85959
+ if ((0, import_path13.isAbsolute)(imagePath)) {
85960
+ absolutePath = (0, import_path13.normalize)((0, import_path13.resolve)(imagePath));
85915
85961
  isPathAllowed2 = allowedDirs.some((dir) => {
85916
- const normalizedDir = (0, import_path12.normalize)((0, import_path12.resolve)(dir));
85917
- return absolutePath === normalizedDir || absolutePath.startsWith(normalizedDir + import_path12.sep);
85962
+ const normalizedDir = (0, import_path13.normalize)((0, import_path13.resolve)(dir));
85963
+ return absolutePath === normalizedDir || absolutePath.startsWith(normalizedDir + import_path13.sep);
85918
85964
  });
85919
85965
  } else {
85920
85966
  for (const dir of allowedDirs) {
85921
- const normalizedDir = (0, import_path12.normalize)((0, import_path12.resolve)(dir));
85922
- const resolvedPath2 = (0, import_path12.normalize)((0, import_path12.resolve)(dir, imagePath));
85923
- if (resolvedPath2 === normalizedDir || resolvedPath2.startsWith(normalizedDir + import_path12.sep)) {
85967
+ const normalizedDir = (0, import_path13.normalize)((0, import_path13.resolve)(dir));
85968
+ const resolvedPath2 = (0, import_path13.normalize)((0, import_path13.resolve)(dir, imagePath));
85969
+ if (resolvedPath2 === normalizedDir || resolvedPath2.startsWith(normalizedDir + import_path13.sep)) {
85924
85970
  absolutePath = resolvedPath2;
85925
85971
  isPathAllowed2 = true;
85926
85972
  break;
@@ -87098,6 +87144,46 @@ IMPORTANT: When using <attempt_complete>, this must be the ONLY content in your
87098
87144
  } catch (error2) {
87099
87145
  console.error(`[ERROR] Failed to save messages to storage:`, error2);
87100
87146
  }
87147
+ if (completionAttempted && this.completionPrompt && !options._completionPromptProcessed) {
87148
+ if (this.debug) {
87149
+ console.log("[DEBUG] Running completion prompt for post-completion validation/review...");
87150
+ }
87151
+ try {
87152
+ if (this.tracer) {
87153
+ this.tracer.recordEvent("completion_prompt.started", {
87154
+ "completion_prompt.original_result_length": finalResult?.length || 0
87155
+ });
87156
+ }
87157
+ const completionPromptMessage = `${this.completionPrompt}
87158
+
87159
+ Here is the result to review:
87160
+ <result>
87161
+ ${finalResult}
87162
+ </result>
87163
+
87164
+ After reviewing, provide your final answer using attempt_completion.`;
87165
+ const completionResult = await this.answer(completionPromptMessage, [], {
87166
+ ...options,
87167
+ _completionPromptProcessed: true
87168
+ });
87169
+ finalResult = completionResult;
87170
+ if (this.debug) {
87171
+ console.log(`[DEBUG] Completion prompt finished. New result length: ${finalResult?.length || 0}`);
87172
+ }
87173
+ if (this.tracer) {
87174
+ this.tracer.recordEvent("completion_prompt.completed", {
87175
+ "completion_prompt.final_result_length": finalResult?.length || 0
87176
+ });
87177
+ }
87178
+ } catch (error2) {
87179
+ console.error("[ERROR] Completion prompt failed:", error2);
87180
+ if (this.tracer) {
87181
+ this.tracer.recordEvent("completion_prompt.error", {
87182
+ "completion_prompt.error": error2.message
87183
+ });
87184
+ }
87185
+ }
87186
+ }
87101
87187
  const reachedMaxIterations = currentIteration >= maxIterations && !completionAttempted;
87102
87188
  if (options.schema && !options._schemaFormatted && !completionAttempted && !reachedMaxIterations) {
87103
87189
  if (this.debug) {
@@ -87564,6 +87650,8 @@ Convert your previous response content into actual JSON data that follows this s
87564
87650
  path: this.allowedFolders[0],
87565
87651
  // Use first allowed folder as primary path
87566
87652
  allowedFolders: [...this.allowedFolders],
87653
+ cwd: this.cwd,
87654
+ // Preserve explicit working directory
87567
87655
  provider: this.clientApiProvider,
87568
87656
  model: this.clientApiModel,
87569
87657
  debug: this.debug,
@@ -87572,6 +87660,7 @@ Convert your previous response content into actual JSON data that follows this s
87572
87660
  maxIterations: this.maxIterations,
87573
87661
  disableMermaidValidation: this.disableMermaidValidation,
87574
87662
  disableJsonValidation: this.disableJsonValidation,
87663
+ completionPrompt: this.completionPrompt,
87575
87664
  allowedTools: allowedToolsArray,
87576
87665
  enableMcp: !!this.mcpBridge,
87577
87666
  mcpConfig: this.mcpConfig,