@probelabs/probe 0.6.0-rc105 → 0.6.0-rc106

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.
@@ -2184,7 +2184,7 @@ var require_headStream = __commonJS({
2184
2184
  if ((0, stream_type_check_1.isReadableStream)(stream)) {
2185
2185
  return (0, headStream_browser_1.headStream)(stream, bytes);
2186
2186
  }
2187
- return new Promise((resolve2, reject) => {
2187
+ return new Promise((resolve4, reject) => {
2188
2188
  const collector = new Collector();
2189
2189
  collector.limit = bytes;
2190
2190
  stream.pipe(collector);
@@ -2195,7 +2195,7 @@ var require_headStream = __commonJS({
2195
2195
  collector.on("error", reject);
2196
2196
  collector.on("finish", function() {
2197
2197
  const bytes2 = new Uint8Array(Buffer.concat(this.buffers));
2198
- resolve2(bytes2);
2198
+ resolve4(bytes2);
2199
2199
  });
2200
2200
  });
2201
2201
  };
@@ -2453,21 +2453,21 @@ var require_dist_cjs15 = __commonJS({
2453
2453
  let sendBody = true;
2454
2454
  if (expect === "100-continue") {
2455
2455
  sendBody = await Promise.race([
2456
- new Promise((resolve2) => {
2457
- timeoutId = Number(timing.setTimeout(() => resolve2(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
2456
+ new Promise((resolve4) => {
2457
+ timeoutId = Number(timing.setTimeout(() => resolve4(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
2458
2458
  }),
2459
- new Promise((resolve2) => {
2459
+ new Promise((resolve4) => {
2460
2460
  httpRequest.on("continue", () => {
2461
2461
  timing.clearTimeout(timeoutId);
2462
- resolve2(true);
2462
+ resolve4(true);
2463
2463
  });
2464
2464
  httpRequest.on("response", () => {
2465
2465
  timing.clearTimeout(timeoutId);
2466
- resolve2(false);
2466
+ resolve4(false);
2467
2467
  });
2468
2468
  httpRequest.on("error", () => {
2469
2469
  timing.clearTimeout(timeoutId);
2470
- resolve2(false);
2470
+ resolve4(false);
2471
2471
  });
2472
2472
  })
2473
2473
  ]);
@@ -2503,13 +2503,13 @@ var require_dist_cjs15 = __commonJS({
2503
2503
  constructor(options) {
2504
2504
  this.socketWarningTimestamp = 0;
2505
2505
  this.metadata = { handlerProtocol: "http/1.1" };
2506
- this.configProvider = new Promise((resolve2, reject) => {
2506
+ this.configProvider = new Promise((resolve4, reject) => {
2507
2507
  if (typeof options === "function") {
2508
2508
  options().then((_options) => {
2509
- resolve2(this.resolveDefaultConfig(_options));
2509
+ resolve4(this.resolveDefaultConfig(_options));
2510
2510
  }).catch(reject);
2511
2511
  } else {
2512
- resolve2(this.resolveDefaultConfig(options));
2512
+ resolve4(this.resolveDefaultConfig(options));
2513
2513
  }
2514
2514
  });
2515
2515
  }
@@ -2593,7 +2593,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2593
2593
  return new Promise((_resolve, _reject) => {
2594
2594
  let writeRequestBodyPromise = void 0;
2595
2595
  const timeouts = [];
2596
- const resolve2 = /* @__PURE__ */ __name(async (arg) => {
2596
+ const resolve4 = /* @__PURE__ */ __name(async (arg) => {
2597
2597
  await writeRequestBodyPromise;
2598
2598
  timeouts.forEach(timing.clearTimeout);
2599
2599
  _resolve(arg);
@@ -2663,7 +2663,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2663
2663
  headers: getTransformedHeaders(res.headers),
2664
2664
  body: res
2665
2665
  });
2666
- resolve2({ response: httpResponse });
2666
+ resolve4({ response: httpResponse });
2667
2667
  });
2668
2668
  req.on("error", (err) => {
2669
2669
  if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
@@ -2852,13 +2852,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2852
2852
  constructor(options) {
2853
2853
  this.metadata = { handlerProtocol: "h2" };
2854
2854
  this.connectionManager = new NodeHttp2ConnectionManager({});
2855
- this.configProvider = new Promise((resolve2, reject) => {
2855
+ this.configProvider = new Promise((resolve4, reject) => {
2856
2856
  if (typeof options === "function") {
2857
2857
  options().then((opts) => {
2858
- resolve2(opts || {});
2858
+ resolve4(opts || {});
2859
2859
  }).catch(reject);
2860
2860
  } else {
2861
- resolve2(options || {});
2861
+ resolve4(options || {});
2862
2862
  }
2863
2863
  });
2864
2864
  }
@@ -2891,7 +2891,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2891
2891
  return new Promise((_resolve, _reject) => {
2892
2892
  let fulfilled = false;
2893
2893
  let writeRequestBodyPromise = void 0;
2894
- const resolve2 = /* @__PURE__ */ __name(async (arg) => {
2894
+ const resolve4 = /* @__PURE__ */ __name(async (arg) => {
2895
2895
  await writeRequestBodyPromise;
2896
2896
  _resolve(arg);
2897
2897
  }, "resolve");
@@ -2947,7 +2947,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
2947
2947
  body: req
2948
2948
  });
2949
2949
  fulfilled = true;
2950
- resolve2({ response: httpResponse });
2950
+ resolve4({ response: httpResponse });
2951
2951
  if (disableConcurrentStreams) {
2952
2952
  session.close();
2953
2953
  this.connectionManager.deleteSession(authority, session);
@@ -3036,7 +3036,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3036
3036
  if (isReadableStreamInstance(stream)) {
3037
3037
  return collectReadableStream(stream);
3038
3038
  }
3039
- return new Promise((resolve2, reject) => {
3039
+ return new Promise((resolve4, reject) => {
3040
3040
  const collector = new Collector();
3041
3041
  stream.pipe(collector);
3042
3042
  stream.on("error", (err) => {
@@ -3046,7 +3046,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3046
3046
  collector.on("error", reject);
3047
3047
  collector.on("finish", function() {
3048
3048
  const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
3049
- resolve2(bytes);
3049
+ resolve4(bytes);
3050
3050
  });
3051
3051
  });
3052
3052
  }, "streamCollector");
@@ -3111,7 +3111,7 @@ var require_dist_cjs16 = __commonJS({
3111
3111
  }
3112
3112
  __name(createRequest, "createRequest");
3113
3113
  function requestTimeout(timeoutInMs = 0) {
3114
- return new Promise((resolve2, reject) => {
3114
+ return new Promise((resolve4, reject) => {
3115
3115
  if (timeoutInMs) {
3116
3116
  setTimeout(() => {
3117
3117
  const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
@@ -3238,7 +3238,7 @@ var require_dist_cjs16 = __commonJS({
3238
3238
  ];
3239
3239
  if (abortSignal) {
3240
3240
  raceOfPromises.push(
3241
- new Promise((resolve2, reject) => {
3241
+ new Promise((resolve4, reject) => {
3242
3242
  const onAbort = /* @__PURE__ */ __name(() => {
3243
3243
  const abortError = new Error("Request aborted");
3244
3244
  abortError.name = "AbortError";
@@ -3306,7 +3306,7 @@ var require_dist_cjs16 = __commonJS({
3306
3306
  }
3307
3307
  __name(collectStream, "collectStream");
3308
3308
  function readToBase64(blob) {
3309
- return new Promise((resolve2, reject) => {
3309
+ return new Promise((resolve4, reject) => {
3310
3310
  const reader = new FileReader();
3311
3311
  reader.onloadend = () => {
3312
3312
  if (reader.readyState !== 2) {
@@ -3315,7 +3315,7 @@ var require_dist_cjs16 = __commonJS({
3315
3315
  const result = reader.result ?? "";
3316
3316
  const commaIndex = result.indexOf(",");
3317
3317
  const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
3318
- resolve2(result.substring(dataOffset));
3318
+ resolve4(result.substring(dataOffset));
3319
3319
  };
3320
3320
  reader.onabort = () => reject(new Error("Read aborted"));
3321
3321
  reader.onerror = () => reject(reader.error);
@@ -3802,9 +3802,10 @@ var TypeRegistry;
3802
3802
  var init_TypeRegistry = __esm({
3803
3803
  "node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js"() {
3804
3804
  TypeRegistry = class _TypeRegistry {
3805
- constructor(namespace, schemas = /* @__PURE__ */ new Map()) {
3805
+ constructor(namespace, schemas = /* @__PURE__ */ new Map(), exceptions = /* @__PURE__ */ new Map()) {
3806
3806
  this.namespace = namespace;
3807
3807
  this.schemas = schemas;
3808
+ this.exceptions = exceptions;
3808
3809
  }
3809
3810
  static for(namespace) {
3810
3811
  if (!_TypeRegistry.registries.has(namespace)) {
@@ -3814,8 +3815,7 @@ var init_TypeRegistry = __esm({
3814
3815
  }
3815
3816
  register(shapeId, schema) {
3816
3817
  const qualifiedName = this.normalizeShapeId(shapeId);
3817
- const registry = _TypeRegistry.for(this.getNamespace(shapeId));
3818
- registry.schemas.set(qualifiedName, schema);
3818
+ this.schemas.set(qualifiedName, schema);
3819
3819
  }
3820
3820
  getSchema(shapeId) {
3821
3821
  const id = this.normalizeShapeId(shapeId);
@@ -3824,6 +3824,12 @@ var init_TypeRegistry = __esm({
3824
3824
  }
3825
3825
  return this.schemas.get(id);
3826
3826
  }
3827
+ registerError(errorSchema, ctor) {
3828
+ this.exceptions.set(errorSchema, ctor);
3829
+ }
3830
+ getErrorCtor(errorSchema) {
3831
+ return this.exceptions.get(errorSchema);
3832
+ }
3827
3833
  getBaseException() {
3828
3834
  for (const [id, schema] of this.schemas.entries()) {
3829
3835
  if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
@@ -3835,9 +3841,9 @@ var init_TypeRegistry = __esm({
3835
3841
  find(predicate) {
3836
3842
  return [...this.schemas.values()].find(predicate);
3837
3843
  }
3838
- destroy() {
3839
- _TypeRegistry.registries.delete(this.namespace);
3844
+ clear() {
3840
3845
  this.schemas.clear();
3846
+ this.exceptions.clear();
3841
3847
  }
3842
3848
  normalizeShapeId(shapeId) {
3843
3849
  if (shapeId.includes("#")) {
@@ -3985,7 +3991,7 @@ var init_ErrorSchema = __esm({
3985
3991
  traits,
3986
3992
  memberNames,
3987
3993
  memberList,
3988
- ctor
3994
+ ctor: null
3989
3995
  });
3990
3996
  }
3991
3997
  });
@@ -4954,11 +4960,11 @@ function __metadata(metadataKey, metadataValue) {
4954
4960
  }
4955
4961
  function __awaiter(thisArg, _arguments, P, generator) {
4956
4962
  function adopt(value) {
4957
- return value instanceof P ? value : new P(function(resolve2) {
4958
- resolve2(value);
4963
+ return value instanceof P ? value : new P(function(resolve4) {
4964
+ resolve4(value);
4959
4965
  });
4960
4966
  }
4961
- return new (P || (P = Promise))(function(resolve2, reject) {
4967
+ return new (P || (P = Promise))(function(resolve4, reject) {
4962
4968
  function fulfilled(value) {
4963
4969
  try {
4964
4970
  step(generator.next(value));
@@ -4974,7 +4980,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
4974
4980
  }
4975
4981
  }
4976
4982
  function step(result) {
4977
- result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
4983
+ result.done ? resolve4(result.value) : adopt(result.value).then(fulfilled, rejected);
4978
4984
  }
4979
4985
  step((generator = generator.apply(thisArg, _arguments || [])).next());
4980
4986
  });
@@ -5165,14 +5171,14 @@ function __asyncValues(o3) {
5165
5171
  }, i3);
5166
5172
  function verb(n3) {
5167
5173
  i3[n3] = o3[n3] && function(v3) {
5168
- return new Promise(function(resolve2, reject) {
5169
- v3 = o3[n3](v3), settle(resolve2, reject, v3.done, v3.value);
5174
+ return new Promise(function(resolve4, reject) {
5175
+ v3 = o3[n3](v3), settle(resolve4, reject, v3.done, v3.value);
5170
5176
  });
5171
5177
  };
5172
5178
  }
5173
- function settle(resolve2, reject, d3, v3) {
5179
+ function settle(resolve4, reject, d3, v3) {
5174
5180
  Promise.resolve(v3).then(function(v4) {
5175
- resolve2({ value: v4, done: d3 });
5181
+ resolve4({ value: v4, done: d3 });
5176
5182
  }, reject);
5177
5183
  }
5178
5184
  }
@@ -10143,16 +10149,18 @@ var init_SmithyRpcV2CborProtocol = __esm({
10143
10149
  if (dataObject.Message) {
10144
10150
  dataObject.message = dataObject.Message;
10145
10151
  }
10146
- const baseExceptionSchema = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
10152
+ const synthetic = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
10153
+ const baseExceptionSchema = synthetic.getBaseException();
10147
10154
  if (baseExceptionSchema) {
10148
- const ErrorCtor = baseExceptionSchema.ctor;
10149
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
10155
+ const ErrorCtor2 = synthetic.getErrorCtor(baseExceptionSchema);
10156
+ throw Object.assign(new ErrorCtor2({ name: errorName }), errorMetadata, dataObject);
10150
10157
  }
10151
10158
  throw Object.assign(new Error(errorName), errorMetadata, dataObject);
10152
10159
  }
10153
10160
  const ns = NormalizedSchema.of(errorSchema);
10161
+ const ErrorCtor = registry.getErrorCtor(errorSchema);
10154
10162
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
10155
- const exception = new errorSchema.ctor(message);
10163
+ const exception = new ErrorCtor(message);
10156
10164
  const output = {};
10157
10165
  for (const [name14, member] of ns.structIterator()) {
10158
10166
  output[name14] = this.deserializer.readValue(member, dataObject[name14]);
@@ -15818,7 +15826,7 @@ var require_dist_cjs37 = __commonJS({
15818
15826
  );
15819
15827
  }
15820
15828
  waitForReady(socket, connectionTimeout) {
15821
- return new Promise((resolve2, reject) => {
15829
+ return new Promise((resolve4, reject) => {
15822
15830
  const timeout = setTimeout(() => {
15823
15831
  this.removeNotUsableSockets(socket.url);
15824
15832
  reject({
@@ -15829,7 +15837,7 @@ var require_dist_cjs37 = __commonJS({
15829
15837
  }, connectionTimeout);
15830
15838
  socket.onopen = () => {
15831
15839
  clearTimeout(timeout);
15832
- resolve2();
15840
+ resolve4();
15833
15841
  };
15834
15842
  });
15835
15843
  }
@@ -15838,10 +15846,10 @@ var require_dist_cjs37 = __commonJS({
15838
15846
  let socketErrorOccurred = false;
15839
15847
  let reject = /* @__PURE__ */ __name(() => {
15840
15848
  }, "reject");
15841
- let resolve2 = /* @__PURE__ */ __name(() => {
15849
+ let resolve4 = /* @__PURE__ */ __name(() => {
15842
15850
  }, "resolve");
15843
15851
  socket.onmessage = (event) => {
15844
- resolve2({
15852
+ resolve4({
15845
15853
  done: false,
15846
15854
  value: new Uint8Array(event.data)
15847
15855
  });
@@ -15857,7 +15865,7 @@ var require_dist_cjs37 = __commonJS({
15857
15865
  if (streamError) {
15858
15866
  reject(streamError);
15859
15867
  } else {
15860
- resolve2({
15868
+ resolve4({
15861
15869
  done: true,
15862
15870
  value: void 0
15863
15871
  // unchecked because done=true.
@@ -15868,7 +15876,7 @@ var require_dist_cjs37 = __commonJS({
15868
15876
  [Symbol.asyncIterator]: () => ({
15869
15877
  next: /* @__PURE__ */ __name(() => {
15870
15878
  return new Promise((_resolve, _reject) => {
15871
- resolve2 = _resolve;
15879
+ resolve4 = _resolve;
15872
15880
  reject = _reject;
15873
15881
  });
15874
15882
  }, "next")
@@ -16391,13 +16399,13 @@ var require_dist_cjs42 = __commonJS({
16391
16399
  ...data2.default && { default: data2.default }
16392
16400
  }
16393
16401
  ), "getConfigData");
16394
- var import_path9 = require("path");
16402
+ var import_path11 = require("path");
16395
16403
  var import_getHomeDir = require_getHomeDir();
16396
16404
  var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
16397
- var getConfigFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CONFIG_PATH] || (0, import_path9.join)((0, import_getHomeDir.getHomeDir)(), ".aws", "config"), "getConfigFilepath");
16405
+ var getConfigFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CONFIG_PATH] || (0, import_path11.join)((0, import_getHomeDir.getHomeDir)(), ".aws", "config"), "getConfigFilepath");
16398
16406
  var import_getHomeDir2 = require_getHomeDir();
16399
16407
  var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
16400
- var getCredentialsFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CREDENTIALS_PATH] || (0, import_path9.join)((0, import_getHomeDir2.getHomeDir)(), ".aws", "credentials"), "getCredentialsFilepath");
16408
+ var getCredentialsFilepath = /* @__PURE__ */ __name(() => process.env[ENV_CREDENTIALS_PATH] || (0, import_path11.join)((0, import_getHomeDir2.getHomeDir)(), ".aws", "credentials"), "getCredentialsFilepath");
16401
16409
  var import_getHomeDir3 = require_getHomeDir();
16402
16410
  var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
16403
16411
  var profileNameBlockList = ["__proto__", "profile __proto__"];
@@ -16455,11 +16463,11 @@ var require_dist_cjs42 = __commonJS({
16455
16463
  const relativeHomeDirPrefix = "~/";
16456
16464
  let resolvedFilepath = filepath;
16457
16465
  if (filepath.startsWith(relativeHomeDirPrefix)) {
16458
- resolvedFilepath = (0, import_path9.join)(homeDir, filepath.slice(2));
16466
+ resolvedFilepath = (0, import_path11.join)(homeDir, filepath.slice(2));
16459
16467
  }
16460
16468
  let resolvedConfigFilepath = configFilepath;
16461
16469
  if (configFilepath.startsWith(relativeHomeDirPrefix)) {
16462
- resolvedConfigFilepath = (0, import_path9.join)(homeDir, configFilepath.slice(2));
16470
+ resolvedConfigFilepath = (0, import_path11.join)(homeDir, configFilepath.slice(2));
16463
16471
  }
16464
16472
  const parsedFiles = await Promise.all([
16465
16473
  (0, import_slurpFile.slurpFile)(resolvedConfigFilepath, {
@@ -17114,7 +17122,7 @@ var require_dist_cjs46 = __commonJS({
17114
17122
  this.refillTokenBucket();
17115
17123
  if (amount > this.currentCapacity) {
17116
17124
  const delay = (amount - this.currentCapacity) / this.fillRate * 1e3;
17117
- await new Promise((resolve2) => _DefaultRateLimiter.setTimeoutFn(resolve2, delay));
17125
+ await new Promise((resolve4) => _DefaultRateLimiter.setTimeoutFn(resolve4, delay));
17118
17126
  }
17119
17127
  this.currentCapacity = this.currentCapacity - amount;
17120
17128
  }
@@ -17505,7 +17513,7 @@ var require_dist_cjs47 = __commonJS({
17505
17513
  const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
17506
17514
  const delay = Math.max(delayFromResponse || 0, delayFromDecider);
17507
17515
  totalDelay += delay;
17508
- await new Promise((resolve2) => setTimeout(resolve2, delay));
17516
+ await new Promise((resolve4) => setTimeout(resolve4, delay));
17509
17517
  continue;
17510
17518
  }
17511
17519
  if (!err.$metadata) {
@@ -17665,7 +17673,7 @@ var require_dist_cjs47 = __commonJS({
17665
17673
  attempts = retryToken.getRetryCount();
17666
17674
  const delay = retryToken.getRetryDelay();
17667
17675
  totalRetryDelay += delay;
17668
- await new Promise((resolve2) => setTimeout(resolve2, delay));
17676
+ await new Promise((resolve4) => setTimeout(resolve4, delay));
17669
17677
  }
17670
17678
  }
17671
17679
  } else {
@@ -18008,7 +18016,7 @@ var require_dist_cjs49 = __commonJS({
18008
18016
  var import_buffer = require("buffer");
18009
18017
  var import_http = require("http");
18010
18018
  function httpRequest(options) {
18011
- return new Promise((resolve2, reject) => {
18019
+ return new Promise((resolve4, reject) => {
18012
18020
  const req = (0, import_http.request)({
18013
18021
  method: "GET",
18014
18022
  ...options,
@@ -18037,7 +18045,7 @@ var require_dist_cjs49 = __commonJS({
18037
18045
  chunks.push(chunk);
18038
18046
  });
18039
18047
  res.on("end", () => {
18040
- resolve2(import_buffer.Buffer.concat(chunks));
18048
+ resolve4(import_buffer.Buffer.concat(chunks));
18041
18049
  req.destroy();
18042
18050
  });
18043
18051
  });
@@ -18472,7 +18480,7 @@ var require_retry_wrapper = __commonJS({
18472
18480
  try {
18473
18481
  return await toRetry();
18474
18482
  } catch (e3) {
18475
- await new Promise((resolve2) => setTimeout(resolve2, delayMs));
18483
+ await new Promise((resolve4) => setTimeout(resolve4, delayMs));
18476
18484
  }
18477
18485
  }
18478
18486
  return await toRetry();
@@ -18916,7 +18924,7 @@ var require_dist_cjs53 = __commonJS({
18916
18924
  calculateBodyLength: () => calculateBodyLength3
18917
18925
  });
18918
18926
  module2.exports = __toCommonJS2(index_exports);
18919
- var import_fs7 = require("fs");
18927
+ var import_fs8 = require("fs");
18920
18928
  var calculateBodyLength3 = /* @__PURE__ */ __name((body) => {
18921
18929
  if (!body) {
18922
18930
  return 0;
@@ -18930,9 +18938,9 @@ var require_dist_cjs53 = __commonJS({
18930
18938
  } else if (typeof body.start === "number" && typeof body.end === "number") {
18931
18939
  return body.end + 1 - body.start;
18932
18940
  } else if (typeof body.path === "string" || Buffer.isBuffer(body.path)) {
18933
- return (0, import_fs7.lstatSync)(body.path).size;
18941
+ return (0, import_fs8.lstatSync)(body.path).size;
18934
18942
  } else if (typeof body.fd === "number") {
18935
- return (0, import_fs7.fstatSync)(body.fd).size;
18943
+ return (0, import_fs8.fstatSync)(body.fd).size;
18936
18944
  }
18937
18945
  throw new Error(`Body Length computation failed for ${body}`);
18938
18946
  }, "calculateBodyLength");
@@ -20970,8 +20978,8 @@ var require_dist_cjs57 = __commonJS({
20970
20978
  }
20971
20979
  }, "validateTokenKey");
20972
20980
  var import_shared_ini_file_loader = require_dist_cjs42();
20973
- var import_fs7 = require("fs");
20974
- var { writeFile } = import_fs7.promises;
20981
+ var import_fs8 = require("fs");
20982
+ var { writeFile } = import_fs8.promises;
20975
20983
  var writeSSOTokenToFile = /* @__PURE__ */ __name((id, ssoToken) => {
20976
20984
  const tokenFilepath = (0, import_shared_ini_file_loader.getSSOTokenFilepath)(id);
20977
20985
  const tokenString = JSON.stringify(ssoToken, null, 2);
@@ -22613,7 +22621,7 @@ var require_dist_cjs59 = __commonJS({
22613
22621
  module2.exports = __toCommonJS2(index_exports);
22614
22622
  var import_property_provider2 = require_dist_cjs24();
22615
22623
  var import_shared_ini_file_loader = require_dist_cjs42();
22616
- var import_child_process8 = require("child_process");
22624
+ var import_child_process9 = require("child_process");
22617
22625
  var import_util7 = require("util");
22618
22626
  var import_client7 = (init_client(), __toCommonJS(client_exports));
22619
22627
  var getValidatedProcessCredentials = /* @__PURE__ */ __name((profileName, data2, profiles) => {
@@ -22650,7 +22658,7 @@ var require_dist_cjs59 = __commonJS({
22650
22658
  if (profiles[profileName]) {
22651
22659
  const credentialProcess = profile["credential_process"];
22652
22660
  if (credentialProcess !== void 0) {
22653
- const execPromise = (0, import_util7.promisify)(import_shared_ini_file_loader.externalDataInterceptor?.getTokenRecord?.().exec ?? import_child_process8.exec);
22661
+ const execPromise = (0, import_util7.promisify)(import_shared_ini_file_loader.externalDataInterceptor?.getTokenRecord?.().exec ?? import_child_process9.exec);
22654
22662
  try {
22655
22663
  const { stdout } = await execPromise(credentialProcess);
22656
22664
  let data2;
@@ -23389,7 +23397,7 @@ var require_dist_cjs64 = __commonJS({
23389
23397
  streamEnded = true;
23390
23398
  });
23391
23399
  while (!generationEnded) {
23392
- const value = await new Promise((resolve2) => setTimeout(() => resolve2(records.shift()), 0));
23400
+ const value = await new Promise((resolve4) => setTimeout(() => resolve4(records.shift()), 0));
23393
23401
  if (value) {
23394
23402
  yield value;
23395
23403
  }
@@ -26766,16 +26774,16 @@ function prepareTools(mode) {
26766
26774
  }
26767
26775
  const toolWarnings = [];
26768
26776
  const bedrockTools = [];
26769
- for (const tool2 of tools2) {
26770
- if (tool2.type === "provider-defined") {
26771
- toolWarnings.push({ type: "unsupported-tool", tool: tool2 });
26777
+ for (const tool3 of tools2) {
26778
+ if (tool3.type === "provider-defined") {
26779
+ toolWarnings.push({ type: "unsupported-tool", tool: tool3 });
26772
26780
  } else {
26773
26781
  bedrockTools.push({
26774
26782
  toolSpec: {
26775
- name: tool2.name,
26776
- description: tool2.description,
26783
+ name: tool3.name,
26784
+ description: tool3.description,
26777
26785
  inputSchema: {
26778
- json: tool2.parameters
26786
+ json: tool3.parameters
26779
26787
  }
26780
26788
  }
26781
26789
  });
@@ -28938,7 +28946,7 @@ function createMessagePreview(message, charsPerSide = 200) {
28938
28946
  const end = message.substring(message.length - charsPerSide);
28939
28947
  return `${start}...${end}`;
28940
28948
  }
28941
- var import_zod, searchSchema, querySchema, extractSchema, delegateSchema, attemptCompletionSchema, searchToolDefinition, queryToolDefinition, extractToolDefinition, attemptCompletionToolDefinition, searchDescription, queryDescription, extractDescription, delegateDescription, DEFAULT_VALID_TOOLS;
28949
+ var import_zod, searchSchema, querySchema, extractSchema, delegateSchema, bashSchema, attemptCompletionSchema, searchToolDefinition, queryToolDefinition, extractToolDefinition, attemptCompletionToolDefinition, searchDescription, queryDescription, extractDescription, delegateDescription, DEFAULT_VALID_TOOLS;
28942
28950
  var init_common2 = __esm({
28943
28951
  "src/tools/common.js"() {
28944
28952
  "use strict";
@@ -28970,6 +28978,12 @@ var init_common2 = __esm({
28970
28978
  delegateSchema = import_zod.z.object({
28971
28979
  task: import_zod.z.string().describe("The task to delegate to a subagent. Be specific about what needs to be accomplished.")
28972
28980
  });
28981
+ bashSchema = import_zod.z.object({
28982
+ command: import_zod.z.string().describe("The bash command to execute"),
28983
+ workingDirectory: import_zod.z.string().optional().describe("Directory to execute the command in (optional)"),
28984
+ timeout: import_zod.z.number().optional().describe("Command timeout in milliseconds (optional)"),
28985
+ env: import_zod.z.record(import_zod.z.string()).optional().describe("Additional environment variables (optional)")
28986
+ });
28973
28987
  attemptCompletionSchema = {
28974
28988
  // Custom validation that requires result parameter but allows direct XML response
28975
28989
  safeParse: (params) => {
@@ -29230,7 +29244,7 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
29230
29244
  console.error(`[DELEGATE] Using binary at: ${binaryPath}`);
29231
29245
  console.error(`[DELEGATE] Command args: ${args.join(" ")}`);
29232
29246
  }
29233
- return new Promise((resolve2, reject) => {
29247
+ return new Promise((resolve4, reject) => {
29234
29248
  const delegationSpan = tracer ? tracer.createDelegationSpan(sessionId, task) : null;
29235
29249
  const process2 = (0, import_child_process5.spawn)(binaryPath, args, {
29236
29250
  stdio: ["pipe", "pipe", "pipe"],
@@ -29295,7 +29309,7 @@ async function delegate({ task, timeout = 300, debug = false, currentIteration =
29295
29309
  delegationSpan.end();
29296
29310
  }
29297
29311
  }
29298
- resolve2(response);
29312
+ resolve4(response);
29299
29313
  } else {
29300
29314
  const errorMessage = stderr.trim() || `Delegate process failed with exit code ${code}`;
29301
29315
  if (debug) {
@@ -29491,10 +29505,10 @@ var init_vercel = __esm({
29491
29505
  let extractOptions = { path: extractPath };
29492
29506
  if (input_content) {
29493
29507
  const { writeFileSync: writeFileSync2, unlinkSync } = await import("fs");
29494
- const { join: join2 } = await import("path");
29508
+ const { join: join3 } = await import("path");
29495
29509
  const { tmpdir } = await import("os");
29496
29510
  const { randomUUID: randomUUID5 } = await import("crypto");
29497
- tempFilePath = join2(tmpdir(), `probe-extract-${randomUUID5()}.txt`);
29511
+ tempFilePath = join3(tmpdir(), `probe-extract-${randomUUID5()}.txt`);
29498
29512
  writeFileSync2(tempFilePath, input_content);
29499
29513
  if (debug) {
29500
29514
  console.error(`Created temporary file for input content: ${tempFilePath}`);
@@ -29571,6 +29585,1248 @@ var init_vercel = __esm({
29571
29585
  }
29572
29586
  });
29573
29587
 
29588
+ // src/agent/bashDefaults.js
29589
+ var DEFAULT_ALLOW_PATTERNS, DEFAULT_DENY_PATTERNS;
29590
+ var init_bashDefaults = __esm({
29591
+ "src/agent/bashDefaults.js"() {
29592
+ "use strict";
29593
+ DEFAULT_ALLOW_PATTERNS = [
29594
+ // Basic navigation and listing
29595
+ "ls",
29596
+ "dir",
29597
+ "pwd",
29598
+ "cd",
29599
+ "cd:*",
29600
+ // File reading commands
29601
+ "cat",
29602
+ "cat:*",
29603
+ "head",
29604
+ "head:*",
29605
+ "tail",
29606
+ "tail:*",
29607
+ "less",
29608
+ "more",
29609
+ "view",
29610
+ // File information and metadata
29611
+ "file",
29612
+ "file:*",
29613
+ "stat",
29614
+ "stat:*",
29615
+ "wc",
29616
+ "wc:*",
29617
+ "du",
29618
+ "du:*",
29619
+ "df",
29620
+ "df:*",
29621
+ "realpath",
29622
+ "realpath:*",
29623
+ // Search and find commands (read-only) - find restricted to safe operations
29624
+ "find",
29625
+ "find:-name:*",
29626
+ "find:-type:*",
29627
+ "find:-size:*",
29628
+ "find:-mtime:*",
29629
+ "find:-newer:*",
29630
+ "find:-path:*",
29631
+ "find:-iname:*",
29632
+ "find:-maxdepth:*",
29633
+ "find:-mindepth:*",
29634
+ "find:-print",
29635
+ "grep",
29636
+ "grep:*",
29637
+ "egrep",
29638
+ "egrep:*",
29639
+ "fgrep",
29640
+ "fgrep:*",
29641
+ "rg",
29642
+ "rg:*",
29643
+ "ag",
29644
+ "ag:*",
29645
+ "ack",
29646
+ "ack:*",
29647
+ "which",
29648
+ "which:*",
29649
+ "whereis",
29650
+ "whereis:*",
29651
+ "locate",
29652
+ "locate:*",
29653
+ "type",
29654
+ "type:*",
29655
+ "command",
29656
+ "command:*",
29657
+ // Tree and structure visualization
29658
+ "tree",
29659
+ "tree:*",
29660
+ // Git read-only operations
29661
+ "git:status",
29662
+ "git:log",
29663
+ "git:log:*",
29664
+ "git:diff",
29665
+ "git:diff:*",
29666
+ "git:show",
29667
+ "git:show:*",
29668
+ "git:branch",
29669
+ "git:branch:*",
29670
+ "git:tag",
29671
+ "git:tag:*",
29672
+ "git:describe",
29673
+ "git:describe:*",
29674
+ "git:remote",
29675
+ "git:remote:*",
29676
+ "git:config:*",
29677
+ "git:blame",
29678
+ "git:blame:*",
29679
+ "git:shortlog",
29680
+ "git:reflog",
29681
+ "git:ls-files",
29682
+ "git:ls-tree",
29683
+ "git:rev-parse",
29684
+ "git:rev-list",
29685
+ "git:--version",
29686
+ "git:help",
29687
+ "git:help:*",
29688
+ // Package managers (information only)
29689
+ "npm:list",
29690
+ "npm:ls",
29691
+ "npm:view",
29692
+ "npm:info",
29693
+ "npm:show",
29694
+ "npm:outdated",
29695
+ "npm:audit",
29696
+ "npm:--version",
29697
+ "yarn:list",
29698
+ "yarn:info",
29699
+ "yarn:--version",
29700
+ "pnpm:list",
29701
+ "pnpm:--version",
29702
+ "pip:list",
29703
+ "pip:show",
29704
+ "pip:--version",
29705
+ "pip3:list",
29706
+ "pip3:show",
29707
+ "pip3:--version",
29708
+ "gem:list",
29709
+ "gem:--version",
29710
+ "bundle:list",
29711
+ "bundle:show",
29712
+ "bundle:--version",
29713
+ "composer:show",
29714
+ "composer:--version",
29715
+ // Language and runtime versions
29716
+ "node:--version",
29717
+ "node:-v",
29718
+ "python:--version",
29719
+ "python:-V",
29720
+ "python3:--version",
29721
+ "python3:-V",
29722
+ "ruby:--version",
29723
+ "ruby:-v",
29724
+ "go:version",
29725
+ "go:env",
29726
+ "go:list",
29727
+ "go:mod:graph",
29728
+ "rustc:--version",
29729
+ "cargo:--version",
29730
+ "cargo:tree",
29731
+ "cargo:metadata",
29732
+ "java:--version",
29733
+ "java:-version",
29734
+ "javac:--version",
29735
+ "mvn:--version",
29736
+ "gradle:--version",
29737
+ "php:--version",
29738
+ "dotnet:--version",
29739
+ "dotnet:list",
29740
+ // Database client versions (connection info only)
29741
+ "psql:--version",
29742
+ "mysql:--version",
29743
+ "redis-cli:--version",
29744
+ "mongo:--version",
29745
+ "sqlite3:--version",
29746
+ // System information
29747
+ "uname",
29748
+ "uname:*",
29749
+ "hostname",
29750
+ "whoami",
29751
+ "id",
29752
+ "groups",
29753
+ "date",
29754
+ "cal",
29755
+ "uptime",
29756
+ "w",
29757
+ "users",
29758
+ "sleep",
29759
+ "sleep:*",
29760
+ // Environment and shell
29761
+ "env",
29762
+ "printenv",
29763
+ "echo",
29764
+ "echo:*",
29765
+ "printf",
29766
+ "printf:*",
29767
+ "export",
29768
+ "export:*",
29769
+ "set",
29770
+ "unset",
29771
+ // Process information (read-only)
29772
+ "ps",
29773
+ "ps:*",
29774
+ "pgrep",
29775
+ "pgrep:*",
29776
+ "jobs",
29777
+ "top:-n:1",
29778
+ // Network information (read-only)
29779
+ "ifconfig",
29780
+ "ip:addr",
29781
+ "ip:link",
29782
+ "hostname:-I",
29783
+ "ping:-c:*",
29784
+ "traceroute",
29785
+ "nslookup",
29786
+ "dig",
29787
+ // Text processing and utilities (awk removed - too powerful)
29788
+ "sed:-n:*",
29789
+ "cut",
29790
+ "cut:*",
29791
+ "sort",
29792
+ "sort:*",
29793
+ "uniq",
29794
+ "uniq:*",
29795
+ "tr",
29796
+ "tr:*",
29797
+ "column",
29798
+ "column:*",
29799
+ "paste",
29800
+ "paste:*",
29801
+ "join",
29802
+ "join:*",
29803
+ "comm",
29804
+ "comm:*",
29805
+ "diff",
29806
+ "diff:*",
29807
+ "cmp",
29808
+ "cmp:*",
29809
+ "patch:--dry-run:*",
29810
+ // Hashing and encoding (read-only)
29811
+ "md5sum",
29812
+ "md5sum:*",
29813
+ "sha1sum",
29814
+ "sha1sum:*",
29815
+ "sha256sum",
29816
+ "sha256sum:*",
29817
+ "base64",
29818
+ "base64:-d",
29819
+ "od",
29820
+ "od:*",
29821
+ "hexdump",
29822
+ "hexdump:*",
29823
+ // Archive and compression (list/view only)
29824
+ "tar:-tf:*",
29825
+ "tar:-tzf:*",
29826
+ "unzip:-l:*",
29827
+ "zip:-l:*",
29828
+ "gzip:-l:*",
29829
+ "gunzip:-l:*",
29830
+ // Help and documentation
29831
+ "man",
29832
+ "man:*",
29833
+ "--help",
29834
+ "help",
29835
+ "info",
29836
+ "info:*",
29837
+ "whatis",
29838
+ "whatis:*",
29839
+ "apropos",
29840
+ "apropos:*",
29841
+ // Make (dry run and info)
29842
+ "make:-n",
29843
+ "make:--dry-run",
29844
+ "make:-p",
29845
+ "make:--print-data-base",
29846
+ // Docker (read-only operations)
29847
+ "docker:ps",
29848
+ "docker:images",
29849
+ "docker:version",
29850
+ "docker:info",
29851
+ "docker:logs:*",
29852
+ "docker:inspect:*",
29853
+ // Test runners (list/info only)
29854
+ "jest:--listTests",
29855
+ "mocha:--help",
29856
+ "pytest:--collect-only"
29857
+ ];
29858
+ DEFAULT_DENY_PATTERNS = [
29859
+ // Dangerous file operations
29860
+ "rm:-rf",
29861
+ "rm:-f:/",
29862
+ "rm:/",
29863
+ "rm:-rf:*",
29864
+ "rmdir",
29865
+ "chmod:777",
29866
+ "chmod:-R:777",
29867
+ "chown",
29868
+ "chgrp",
29869
+ "dd",
29870
+ "dd:*",
29871
+ "shred",
29872
+ "shred:*",
29873
+ // Dangerous find operations that can execute arbitrary commands
29874
+ "find:-exec:*",
29875
+ "find:*:-exec:*",
29876
+ "find:-execdir:*",
29877
+ "find:*:-execdir:*",
29878
+ "find:-ok:*",
29879
+ "find:*:-ok:*",
29880
+ "find:-okdir:*",
29881
+ "find:*:-okdir:*",
29882
+ // Powerful scripting tools that can execute arbitrary commands
29883
+ "awk",
29884
+ "awk:*",
29885
+ "perl",
29886
+ "perl:*",
29887
+ "python:-c:*",
29888
+ "node:-e:*",
29889
+ // System administration and modification
29890
+ "sudo:*",
29891
+ "su",
29892
+ "su:*",
29893
+ "passwd",
29894
+ "adduser",
29895
+ "useradd",
29896
+ "userdel",
29897
+ "usermod",
29898
+ "groupadd",
29899
+ "groupdel",
29900
+ "visudo",
29901
+ // Package installation and removal
29902
+ "npm:install",
29903
+ "npm:i",
29904
+ "npm:uninstall",
29905
+ "npm:publish",
29906
+ "npm:unpublish",
29907
+ "npm:link",
29908
+ "npm:update",
29909
+ "yarn:install",
29910
+ "yarn:add",
29911
+ "yarn:remove",
29912
+ "yarn:upgrade",
29913
+ "pnpm:install",
29914
+ "pnpm:add",
29915
+ "pnpm:remove",
29916
+ "pip:install",
29917
+ "pip:uninstall",
29918
+ "pip:upgrade",
29919
+ "pip3:install",
29920
+ "pip3:uninstall",
29921
+ "pip3:upgrade",
29922
+ "gem:install",
29923
+ "gem:uninstall",
29924
+ "gem:update",
29925
+ "bundle:install",
29926
+ "bundle:update",
29927
+ "composer:install",
29928
+ "composer:update",
29929
+ "composer:remove",
29930
+ "apt:*",
29931
+ "apt-get:*",
29932
+ "yum:*",
29933
+ "dnf:*",
29934
+ "zypper:*",
29935
+ "brew:install",
29936
+ "brew:uninstall",
29937
+ "brew:upgrade",
29938
+ "conda:install",
29939
+ "conda:remove",
29940
+ "conda:update",
29941
+ // Service and system control
29942
+ "systemctl:*",
29943
+ "service:*",
29944
+ "chkconfig:*",
29945
+ "initctl:*",
29946
+ "upstart:*",
29947
+ // Network operations that could be dangerous
29948
+ "curl:-d:*",
29949
+ "curl:--data:*",
29950
+ "curl:-X:POST:*",
29951
+ "curl:-X:PUT:*",
29952
+ "wget:-O:/",
29953
+ "wget:--post-data:*",
29954
+ "ssh",
29955
+ "ssh:*",
29956
+ "scp",
29957
+ "scp:*",
29958
+ "sftp",
29959
+ "sftp:*",
29960
+ "rsync:*",
29961
+ "nc",
29962
+ "nc:*",
29963
+ "netcat",
29964
+ "netcat:*",
29965
+ "telnet",
29966
+ "telnet:*",
29967
+ "ftp",
29968
+ "ftp:*",
29969
+ // Process control and termination
29970
+ "kill",
29971
+ "kill:*",
29972
+ "killall",
29973
+ "killall:*",
29974
+ "pkill",
29975
+ "pkill:*",
29976
+ "nohup:*",
29977
+ "disown:*",
29978
+ // System control and shutdown
29979
+ "shutdown",
29980
+ "shutdown:*",
29981
+ "reboot",
29982
+ "halt",
29983
+ "poweroff",
29984
+ "init",
29985
+ "telinit",
29986
+ // Kernel and module operations
29987
+ "insmod",
29988
+ "insmod:*",
29989
+ "rmmod",
29990
+ "rmmod:*",
29991
+ "modprobe",
29992
+ "modprobe:*",
29993
+ "sysctl:-w:*",
29994
+ // Dangerous git operations
29995
+ "git:push",
29996
+ "git:push:*",
29997
+ "git:force",
29998
+ "git:reset:--hard:*",
29999
+ "git:clean:-fd",
30000
+ "git:rm:*",
30001
+ "git:commit",
30002
+ "git:merge",
30003
+ "git:rebase",
30004
+ "git:cherry-pick",
30005
+ "git:stash:drop",
30006
+ // File system mounting and partitioning
30007
+ "mount",
30008
+ "mount:*",
30009
+ "umount",
30010
+ "umount:*",
30011
+ "fdisk",
30012
+ "fdisk:*",
30013
+ "parted",
30014
+ "parted:*",
30015
+ "mkfs",
30016
+ "mkfs:*",
30017
+ "fsck",
30018
+ "fsck:*",
30019
+ // Cron and scheduling
30020
+ "crontab",
30021
+ "crontab:*",
30022
+ "at",
30023
+ "at:*",
30024
+ "batch",
30025
+ "batch:*",
30026
+ // Compression with potential overwrite
30027
+ "tar:-xf:*",
30028
+ "unzip",
30029
+ "unzip:*",
30030
+ "gzip:*",
30031
+ "gunzip:*",
30032
+ // Build and compilation that might modify files
30033
+ "make",
30034
+ "make:install",
30035
+ "make:clean",
30036
+ "cargo:build",
30037
+ "cargo:install",
30038
+ "npm:run:build",
30039
+ "yarn:build",
30040
+ "mvn:install",
30041
+ "gradle:build",
30042
+ // Docker operations that could modify state
30043
+ "docker:run",
30044
+ "docker:run:*",
30045
+ "docker:exec",
30046
+ "docker:exec:*",
30047
+ "docker:build",
30048
+ "docker:build:*",
30049
+ "docker:pull",
30050
+ "docker:push",
30051
+ "docker:rm",
30052
+ "docker:rmi",
30053
+ "docker:stop",
30054
+ "docker:start",
30055
+ // Database operations
30056
+ "mysql:-e:DROP",
30057
+ "psql:-c:DROP",
30058
+ "redis-cli:FLUSHALL",
30059
+ "mongo:--eval:*",
30060
+ // Text editors that could modify files
30061
+ "vi",
30062
+ "vi:*",
30063
+ "vim",
30064
+ "vim:*",
30065
+ "nano",
30066
+ "nano:*",
30067
+ "emacs",
30068
+ "emacs:*",
30069
+ "sed:-i:*",
30070
+ "perl:-i:*",
30071
+ // Potentially dangerous utilities
30072
+ "eval",
30073
+ "eval:*",
30074
+ "exec",
30075
+ "exec:*",
30076
+ "source",
30077
+ "source:*",
30078
+ "bash:-c:*",
30079
+ "sh:-c:*",
30080
+ "zsh:-c:*"
30081
+ ];
30082
+ }
30083
+ });
30084
+
30085
+ // src/agent/bashCommandUtils.js
30086
+ function parseSimpleCommand(command) {
30087
+ if (!command || typeof command !== "string") {
30088
+ return {
30089
+ success: false,
30090
+ error: "Command must be a non-empty string",
30091
+ command: null,
30092
+ args: [],
30093
+ isComplex: false
30094
+ };
30095
+ }
30096
+ const trimmed = command.trim();
30097
+ if (!trimmed) {
30098
+ return {
30099
+ success: false,
30100
+ error: "Command cannot be empty",
30101
+ command: null,
30102
+ args: [],
30103
+ isComplex: false
30104
+ };
30105
+ }
30106
+ const complexPatterns = [
30107
+ /\|/,
30108
+ // Pipes
30109
+ /&&/,
30110
+ // Logical AND
30111
+ /\|\|/,
30112
+ // Logical OR
30113
+ /(?<!\\);/,
30114
+ // Command separator (but not escaped \;)
30115
+ /&$/,
30116
+ // Background execution
30117
+ /\$\(/,
30118
+ // Command substitution $()
30119
+ /`/,
30120
+ // Command substitution ``
30121
+ />/,
30122
+ // Redirection >
30123
+ /</,
30124
+ // Redirection <
30125
+ /\*\*/,
30126
+ // Glob patterns (potentially dangerous)
30127
+ /^\s*\{.*,.*\}|\{.*\.\.\.*\}/
30128
+ // Brace expansion like {a,b} or {1..10} (but not find {} placeholders)
30129
+ ];
30130
+ for (const pattern of complexPatterns) {
30131
+ if (pattern.test(trimmed)) {
30132
+ return {
30133
+ success: false,
30134
+ error: "Complex shell commands with pipes, operators, or redirections are not supported for security reasons",
30135
+ command: null,
30136
+ args: [],
30137
+ isComplex: true,
30138
+ detected: pattern.toString()
30139
+ };
30140
+ }
30141
+ }
30142
+ const args = [];
30143
+ let current = "";
30144
+ let inQuotes = false;
30145
+ let quoteChar = "";
30146
+ let escaped = false;
30147
+ for (let i3 = 0; i3 < trimmed.length; i3++) {
30148
+ const char = trimmed[i3];
30149
+ const nextChar = i3 + 1 < trimmed.length ? trimmed[i3 + 1] : "";
30150
+ if (escaped) {
30151
+ current += char;
30152
+ escaped = false;
30153
+ continue;
30154
+ }
30155
+ if (char === "\\" && !inQuotes) {
30156
+ escaped = true;
30157
+ continue;
30158
+ }
30159
+ if (!inQuotes && (char === '"' || char === "'")) {
30160
+ inQuotes = true;
30161
+ quoteChar = char;
30162
+ } else if (inQuotes && char === quoteChar) {
30163
+ inQuotes = false;
30164
+ quoteChar = "";
30165
+ } else if (!inQuotes && char === " ") {
30166
+ if (current.trim()) {
30167
+ args.push(current.trim());
30168
+ current = "";
30169
+ }
30170
+ } else {
30171
+ current += char;
30172
+ }
30173
+ }
30174
+ if (current.trim()) {
30175
+ args.push(current.trim());
30176
+ }
30177
+ if (inQuotes) {
30178
+ return {
30179
+ success: false,
30180
+ error: `Unclosed quote in command: ${quoteChar}`,
30181
+ command: null,
30182
+ args: [],
30183
+ isComplex: false
30184
+ };
30185
+ }
30186
+ if (args.length === 0) {
30187
+ return {
30188
+ success: false,
30189
+ error: "No command found after parsing",
30190
+ command: null,
30191
+ args: [],
30192
+ isComplex: false
30193
+ };
30194
+ }
30195
+ const [baseCommand, ...commandArgs] = args;
30196
+ return {
30197
+ success: true,
30198
+ error: null,
30199
+ command: baseCommand,
30200
+ args: commandArgs,
30201
+ fullArgs: args,
30202
+ isComplex: false,
30203
+ original: command
30204
+ };
30205
+ }
30206
+ function isComplexCommand(command) {
30207
+ const result = parseSimpleCommand(command);
30208
+ return result.isComplex;
30209
+ }
30210
+ function parseCommand(command) {
30211
+ const result = parseSimpleCommand(command);
30212
+ if (!result.success) {
30213
+ return {
30214
+ command: "",
30215
+ args: [],
30216
+ error: result.error,
30217
+ isComplex: result.isComplex
30218
+ };
30219
+ }
30220
+ return {
30221
+ command: result.command,
30222
+ args: result.args,
30223
+ error: null,
30224
+ isComplex: result.isComplex
30225
+ };
30226
+ }
30227
+ function parseCommandForExecution(command) {
30228
+ const result = parseSimpleCommand(command);
30229
+ if (!result.success) {
30230
+ return null;
30231
+ }
30232
+ return result.fullArgs;
30233
+ }
30234
+ var init_bashCommandUtils = __esm({
30235
+ "src/agent/bashCommandUtils.js"() {
30236
+ "use strict";
30237
+ }
30238
+ });
30239
+
30240
+ // src/agent/bashPermissions.js
30241
+ function matchesPattern(parsedCommand, pattern) {
30242
+ if (!parsedCommand || !pattern) return false;
30243
+ const { command, args } = parsedCommand;
30244
+ if (!command) return false;
30245
+ const patternParts = pattern.split(":");
30246
+ const commandName = patternParts[0];
30247
+ if (commandName === "*") {
30248
+ return true;
30249
+ } else if (commandName !== command) {
30250
+ return false;
30251
+ }
30252
+ if (patternParts.length === 1) {
30253
+ return true;
30254
+ }
30255
+ for (let i3 = 1; i3 < patternParts.length; i3++) {
30256
+ const patternArg = patternParts[i3];
30257
+ const argIndex = i3 - 1;
30258
+ if (patternArg === "*") {
30259
+ continue;
30260
+ }
30261
+ if (argIndex >= args.length) {
30262
+ return false;
30263
+ }
30264
+ const actualArg = args[argIndex];
30265
+ if (patternArg !== actualArg) {
30266
+ return false;
30267
+ }
30268
+ }
30269
+ return true;
30270
+ }
30271
+ function matchesAnyPattern(parsedCommand, patterns) {
30272
+ if (!patterns || patterns.length === 0) return false;
30273
+ return patterns.some((pattern) => matchesPattern(parsedCommand, pattern));
30274
+ }
30275
+ var BashPermissionChecker;
30276
+ var init_bashPermissions = __esm({
30277
+ "src/agent/bashPermissions.js"() {
30278
+ "use strict";
30279
+ init_bashDefaults();
30280
+ init_bashCommandUtils();
30281
+ BashPermissionChecker = class {
30282
+ /**
30283
+ * Create a permission checker
30284
+ * @param {Object} config - Configuration options
30285
+ * @param {string[]} [config.allow] - Additional allow patterns
30286
+ * @param {string[]} [config.deny] - Additional deny patterns
30287
+ * @param {boolean} [config.disableDefaultAllow] - Disable default allow list
30288
+ * @param {boolean} [config.disableDefaultDeny] - Disable default deny list
30289
+ * @param {boolean} [config.debug] - Enable debug logging
30290
+ */
30291
+ constructor(config = {}) {
30292
+ this.debug = config.debug || false;
30293
+ this.allowPatterns = [];
30294
+ if (!config.disableDefaultAllow) {
30295
+ this.allowPatterns.push(...DEFAULT_ALLOW_PATTERNS);
30296
+ if (this.debug) {
30297
+ console.log(`[BashPermissions] Added ${DEFAULT_ALLOW_PATTERNS.length} default allow patterns`);
30298
+ }
30299
+ }
30300
+ if (config.allow && Array.isArray(config.allow)) {
30301
+ this.allowPatterns.push(...config.allow);
30302
+ if (this.debug) {
30303
+ console.log(`[BashPermissions] Added ${config.allow.length} custom allow patterns:`, config.allow);
30304
+ }
30305
+ }
30306
+ this.denyPatterns = [];
30307
+ if (!config.disableDefaultDeny) {
30308
+ this.denyPatterns.push(...DEFAULT_DENY_PATTERNS);
30309
+ if (this.debug) {
30310
+ console.log(`[BashPermissions] Added ${DEFAULT_DENY_PATTERNS.length} default deny patterns`);
30311
+ }
30312
+ }
30313
+ if (config.deny && Array.isArray(config.deny)) {
30314
+ this.denyPatterns.push(...config.deny);
30315
+ if (this.debug) {
30316
+ console.log(`[BashPermissions] Added ${config.deny.length} custom deny patterns:`, config.deny);
30317
+ }
30318
+ }
30319
+ if (this.debug) {
30320
+ console.log(`[BashPermissions] Total patterns - Allow: ${this.allowPatterns.length}, Deny: ${this.denyPatterns.length}`);
30321
+ }
30322
+ }
30323
+ /**
30324
+ * Check if a simple command is allowed (rejects complex commands for security)
30325
+ * @param {string} command - Command to check
30326
+ * @returns {Object} Permission result
30327
+ */
30328
+ check(command) {
30329
+ if (!command || typeof command !== "string") {
30330
+ return {
30331
+ allowed: false,
30332
+ reason: "Invalid or empty command",
30333
+ command
30334
+ };
30335
+ }
30336
+ if (isComplexCommand(command)) {
30337
+ return {
30338
+ allowed: false,
30339
+ reason: "Complex shell commands with pipes, operators, or redirections are not supported for security reasons",
30340
+ command,
30341
+ isComplex: true
30342
+ };
30343
+ }
30344
+ const parsed = parseCommand(command);
30345
+ if (parsed.error) {
30346
+ return {
30347
+ allowed: false,
30348
+ reason: parsed.error,
30349
+ command
30350
+ };
30351
+ }
30352
+ if (!parsed.command) {
30353
+ return {
30354
+ allowed: false,
30355
+ reason: "No valid command found",
30356
+ command
30357
+ };
30358
+ }
30359
+ if (this.debug) {
30360
+ console.log(`[BashPermissions] Checking simple command: "${command}"`);
30361
+ console.log(`[BashPermissions] Parsed: ${parsed.command} with args: [${parsed.args.join(", ")}]`);
30362
+ }
30363
+ if (matchesAnyPattern(parsed, this.denyPatterns)) {
30364
+ const matchedPatterns = this.denyPatterns.filter((pattern) => matchesPattern(parsed, pattern));
30365
+ return {
30366
+ allowed: false,
30367
+ reason: `Command matches deny pattern: ${matchedPatterns[0]}`,
30368
+ command,
30369
+ parsed,
30370
+ matchedPatterns
30371
+ };
30372
+ }
30373
+ if (this.allowPatterns.length > 0) {
30374
+ if (!matchesAnyPattern(parsed, this.allowPatterns)) {
30375
+ return {
30376
+ allowed: false,
30377
+ reason: "Command not in allow list",
30378
+ command,
30379
+ parsed
30380
+ };
30381
+ }
30382
+ }
30383
+ const result = {
30384
+ allowed: true,
30385
+ command,
30386
+ parsed,
30387
+ isComplex: false
30388
+ };
30389
+ if (this.debug) {
30390
+ console.log(`[BashPermissions] ALLOWED - command passed all checks`);
30391
+ }
30392
+ return result;
30393
+ }
30394
+ /**
30395
+ * Get configuration summary
30396
+ * @returns {Object} Configuration info
30397
+ */
30398
+ getConfig() {
30399
+ return {
30400
+ allowPatterns: this.allowPatterns.length,
30401
+ denyPatterns: this.denyPatterns.length,
30402
+ totalPatterns: this.allowPatterns.length + this.denyPatterns.length
30403
+ };
30404
+ }
30405
+ };
30406
+ }
30407
+ });
30408
+
30409
+ // src/agent/bashExecutor.js
30410
+ async function executeBashCommand(command, options = {}) {
30411
+ const {
30412
+ workingDirectory = process.cwd(),
30413
+ timeout = 12e4,
30414
+ // 2 minutes default
30415
+ env = {},
30416
+ maxBuffer = 10 * 1024 * 1024,
30417
+ // 10MB
30418
+ debug = false
30419
+ } = options;
30420
+ let cwd = workingDirectory;
30421
+ try {
30422
+ cwd = (0, import_path4.resolve)(cwd);
30423
+ if (!(0, import_fs.existsSync)(cwd)) {
30424
+ throw new Error(`Working directory does not exist: ${cwd}`);
30425
+ }
30426
+ } catch (error2) {
30427
+ return {
30428
+ success: false,
30429
+ error: `Invalid working directory: ${error2.message}`,
30430
+ stdout: "",
30431
+ stderr: "",
30432
+ exitCode: 1,
30433
+ command,
30434
+ workingDirectory: cwd,
30435
+ duration: 0
30436
+ };
30437
+ }
30438
+ const startTime = Date.now();
30439
+ if (debug) {
30440
+ console.log(`[BashExecutor] Executing command: "${command}"`);
30441
+ console.log(`[BashExecutor] Working directory: "${cwd}"`);
30442
+ console.log(`[BashExecutor] Timeout: ${timeout}ms`);
30443
+ }
30444
+ return new Promise((resolve4, reject) => {
30445
+ const processEnv = {
30446
+ ...process.env,
30447
+ ...env
30448
+ };
30449
+ const args = parseCommandForExecution(command);
30450
+ if (!args || args.length === 0) {
30451
+ resolve4({
30452
+ success: false,
30453
+ error: "Failed to parse command",
30454
+ stdout: "",
30455
+ stderr: "",
30456
+ exitCode: 1,
30457
+ command,
30458
+ workingDirectory: cwd,
30459
+ duration: Date.now() - startTime
30460
+ });
30461
+ return;
30462
+ }
30463
+ const [cmd, ...cmdArgs] = args;
30464
+ const child = (0, import_child_process6.spawn)(cmd, cmdArgs, {
30465
+ cwd,
30466
+ env: processEnv,
30467
+ stdio: ["ignore", "pipe", "pipe"],
30468
+ // stdin ignored, capture stdout/stderr
30469
+ shell: false,
30470
+ // For security
30471
+ windowsHide: true
30472
+ });
30473
+ let stdout = "";
30474
+ let stderr = "";
30475
+ let killed = false;
30476
+ let timeoutHandle;
30477
+ if (timeout > 0) {
30478
+ timeoutHandle = setTimeout(() => {
30479
+ if (!killed) {
30480
+ killed = true;
30481
+ child.kill("SIGTERM");
30482
+ setTimeout(() => {
30483
+ if (child.exitCode === null) {
30484
+ child.kill("SIGKILL");
30485
+ }
30486
+ }, 5e3);
30487
+ }
30488
+ }, timeout);
30489
+ }
30490
+ child.stdout.on("data", (data2) => {
30491
+ const chunk = data2.toString();
30492
+ if (stdout.length + chunk.length <= maxBuffer) {
30493
+ stdout += chunk;
30494
+ } else {
30495
+ if (!killed) {
30496
+ killed = true;
30497
+ child.kill("SIGTERM");
30498
+ }
30499
+ }
30500
+ });
30501
+ child.stderr.on("data", (data2) => {
30502
+ const chunk = data2.toString();
30503
+ if (stderr.length + chunk.length <= maxBuffer) {
30504
+ stderr += chunk;
30505
+ } else {
30506
+ if (!killed) {
30507
+ killed = true;
30508
+ child.kill("SIGTERM");
30509
+ }
30510
+ }
30511
+ });
30512
+ child.on("close", (code, signal) => {
30513
+ if (timeoutHandle) {
30514
+ clearTimeout(timeoutHandle);
30515
+ }
30516
+ const duration = Date.now() - startTime;
30517
+ if (debug) {
30518
+ console.log(`[BashExecutor] Command completed - Code: ${code}, Signal: ${signal}, Duration: ${duration}ms`);
30519
+ console.log(`[BashExecutor] Stdout length: ${stdout.length}, Stderr length: ${stderr.length}`);
30520
+ }
30521
+ let success = true;
30522
+ let error2 = "";
30523
+ if (killed) {
30524
+ success = false;
30525
+ if (stdout.length + stderr.length > maxBuffer) {
30526
+ error2 = `Command output exceeded maximum buffer size (${maxBuffer} bytes)`;
30527
+ } else {
30528
+ error2 = `Command timed out after ${timeout}ms`;
30529
+ }
30530
+ } else if (code !== 0) {
30531
+ success = false;
30532
+ error2 = `Command exited with code ${code}`;
30533
+ }
30534
+ resolve4({
30535
+ success,
30536
+ error: error2,
30537
+ stdout: stdout.trim(),
30538
+ stderr: stderr.trim(),
30539
+ exitCode: code,
30540
+ signal,
30541
+ command,
30542
+ workingDirectory: cwd,
30543
+ duration,
30544
+ killed
30545
+ });
30546
+ });
30547
+ child.on("error", (error2) => {
30548
+ if (timeoutHandle) {
30549
+ clearTimeout(timeoutHandle);
30550
+ }
30551
+ if (debug) {
30552
+ console.log(`[BashExecutor] Spawn error:`, error2);
30553
+ }
30554
+ resolve4({
30555
+ success: false,
30556
+ error: `Failed to execute command: ${error2.message}`,
30557
+ stdout: "",
30558
+ stderr: "",
30559
+ exitCode: 1,
30560
+ command,
30561
+ workingDirectory: cwd,
30562
+ duration: Date.now() - startTime
30563
+ });
30564
+ });
30565
+ });
30566
+ }
30567
+ function formatExecutionResult(result, includeMetadata = false) {
30568
+ if (!result) {
30569
+ return "No result available";
30570
+ }
30571
+ let output = "";
30572
+ if (includeMetadata) {
30573
+ output += `Command: ${result.command}
30574
+ `;
30575
+ output += `Working directory: ${result.workingDirectory}
30576
+ `;
30577
+ output += `Duration: ${result.duration}ms
30578
+ `;
30579
+ output += `Exit Code: ${result.exitCode}
30580
+ `;
30581
+ if (result.signal) {
30582
+ output += `Signal: ${result.signal}
30583
+ `;
30584
+ }
30585
+ output += "\n";
30586
+ }
30587
+ if (result.stdout) {
30588
+ if (includeMetadata) {
30589
+ output += "--- STDOUT ---\n";
30590
+ }
30591
+ output += result.stdout;
30592
+ if (includeMetadata && result.stderr) {
30593
+ output += "\n";
30594
+ }
30595
+ }
30596
+ if (result.stderr) {
30597
+ if (includeMetadata) {
30598
+ if (result.stdout) output += "\n";
30599
+ output += "--- STDERR ---\n";
30600
+ } else if (result.stdout) {
30601
+ output += "\n--- STDERR ---\n";
30602
+ }
30603
+ output += result.stderr;
30604
+ }
30605
+ if (!result.success && result.error && !result.stderr) {
30606
+ if (output) output += "\n";
30607
+ output += `Error: ${result.error}`;
30608
+ }
30609
+ if (!result.success && result.exitCode !== void 0 && result.exitCode !== 0) {
30610
+ if (output) output += "\n";
30611
+ output += `Exit code: ${result.exitCode}`;
30612
+ }
30613
+ return output || (result.success ? "Command completed successfully (no output)" : "Command failed (no output)");
30614
+ }
30615
+ function validateExecutionOptions(options = {}) {
30616
+ const errors = [];
30617
+ const warnings = [];
30618
+ if (options.timeout !== void 0) {
30619
+ if (typeof options.timeout !== "number" || options.timeout < 0) {
30620
+ errors.push("timeout must be a non-negative number");
30621
+ } else if (options.timeout > 6e5) {
30622
+ warnings.push("timeout is very high (>10 minutes)");
30623
+ }
30624
+ }
30625
+ if (options.maxBuffer !== void 0) {
30626
+ if (typeof options.maxBuffer !== "number" || options.maxBuffer < 1024) {
30627
+ errors.push("maxBuffer must be at least 1024 bytes");
30628
+ } else if (options.maxBuffer > 100 * 1024 * 1024) {
30629
+ warnings.push("maxBuffer is very high (>100MB)");
30630
+ }
30631
+ }
30632
+ if (options.workingDirectory) {
30633
+ if (typeof options.workingDirectory !== "string") {
30634
+ errors.push("workingDirectory must be a string");
30635
+ } else if (!(0, import_fs.existsSync)(options.workingDirectory)) {
30636
+ errors.push(`workingDirectory does not exist: ${options.workingDirectory}`);
30637
+ }
30638
+ }
30639
+ if (options.env && typeof options.env !== "object") {
30640
+ errors.push("env must be an object");
30641
+ }
30642
+ return {
30643
+ valid: errors.length === 0,
30644
+ errors,
30645
+ warnings
30646
+ };
30647
+ }
30648
+ var import_child_process6, import_path4, import_fs;
30649
+ var init_bashExecutor = __esm({
30650
+ "src/agent/bashExecutor.js"() {
30651
+ "use strict";
30652
+ import_child_process6 = require("child_process");
30653
+ import_path4 = require("path");
30654
+ import_fs = require("fs");
30655
+ init_bashCommandUtils();
30656
+ }
30657
+ });
30658
+
30659
+ // src/tools/bash.js
30660
+ var import_ai2, import_path5, bashTool;
30661
+ var init_bash = __esm({
30662
+ "src/tools/bash.js"() {
30663
+ "use strict";
30664
+ import_ai2 = require("ai");
30665
+ import_path5 = require("path");
30666
+ init_bashPermissions();
30667
+ init_bashExecutor();
30668
+ bashTool = (options = {}) => {
30669
+ const {
30670
+ bashConfig = {},
30671
+ debug = false,
30672
+ defaultPath,
30673
+ allowedFolders = []
30674
+ } = options;
30675
+ const permissionChecker = new BashPermissionChecker({
30676
+ allow: bashConfig.allow,
30677
+ deny: bashConfig.deny,
30678
+ disableDefaultAllow: bashConfig.disableDefaultAllow,
30679
+ disableDefaultDeny: bashConfig.disableDefaultDeny,
30680
+ debug
30681
+ });
30682
+ const getDefaultWorkingDirectory = () => {
30683
+ if (bashConfig.workingDirectory) {
30684
+ return bashConfig.workingDirectory;
30685
+ }
30686
+ if (defaultPath) {
30687
+ return defaultPath;
30688
+ }
30689
+ if (allowedFolders && allowedFolders.length > 0) {
30690
+ return allowedFolders[0];
30691
+ }
30692
+ return process.cwd();
30693
+ };
30694
+ return (0, import_ai2.tool)({
30695
+ name: "bash",
30696
+ description: `Execute bash commands for system exploration and development tasks.
30697
+
30698
+ Security: This tool has built-in security with allow/deny lists. By default, only safe read-only commands are allowed for code exploration.
30699
+
30700
+ Parameters:
30701
+ - command: (required) The bash command to execute
30702
+ - workingDirectory: (optional) Directory to execute command in
30703
+ - timeout: (optional) Command timeout in milliseconds
30704
+ - env: (optional) Additional environment variables
30705
+
30706
+ Examples of allowed commands by default:
30707
+ - File exploration: ls, cat, head, tail, find, grep
30708
+ - Git operations: git status, git log, git diff, git show
30709
+ - Package info: npm list, pip list, cargo --version
30710
+ - System info: whoami, pwd, uname, date
30711
+
30712
+ Dangerous commands are blocked by default (rm -rf, sudo, npm install, etc.)`,
30713
+ inputSchema: {
30714
+ type: "object",
30715
+ properties: {
30716
+ command: {
30717
+ type: "string",
30718
+ description: "The bash command to execute"
30719
+ },
30720
+ workingDirectory: {
30721
+ type: "string",
30722
+ description: "Directory to execute the command in (optional)"
30723
+ },
30724
+ timeout: {
30725
+ type: "number",
30726
+ description: "Command timeout in milliseconds (optional)",
30727
+ minimum: 1e3,
30728
+ maximum: 6e5
30729
+ },
30730
+ env: {
30731
+ type: "object",
30732
+ description: "Additional environment variables (optional)",
30733
+ additionalProperties: {
30734
+ type: "string"
30735
+ }
30736
+ }
30737
+ },
30738
+ required: ["command"],
30739
+ additionalProperties: false
30740
+ },
30741
+ execute: async ({ command, workingDirectory, timeout, env }) => {
30742
+ try {
30743
+ if (command === null || command === void 0 || typeof command !== "string") {
30744
+ return "Error: Command is required and must be a string";
30745
+ }
30746
+ if (command.trim().length === 0) {
30747
+ return "Error: Command cannot be empty";
30748
+ }
30749
+ const permissionResult = permissionChecker.check(command.trim());
30750
+ if (!permissionResult.allowed) {
30751
+ if (debug) {
30752
+ console.log(`[BashTool] Permission denied for command: "${command}"`);
30753
+ console.log(`[BashTool] Reason: ${permissionResult.reason}`);
30754
+ }
30755
+ return `Permission denied: ${permissionResult.reason}
30756
+
30757
+ This command is not allowed by the current security policy.
30758
+
30759
+ Common reasons:
30760
+ 1. The command is in the deny list (potentially dangerous)
30761
+ 2. The command is not in the allow list (not a recognized safe command)
30762
+
30763
+ If you believe this command should be allowed, you can:
30764
+ - Use the --bash-allow option to add specific patterns
30765
+ - Use the --no-default-bash-deny flag to remove default restrictions (not recommended)
30766
+
30767
+ For code exploration, try these safe alternatives:
30768
+ - ls, cat, head, tail for file operations
30769
+ - find, grep, rg for searching
30770
+ - git status, git log, git show for git operations
30771
+ - npm list, pip list for package information`;
30772
+ }
30773
+ const workingDir = workingDirectory || getDefaultWorkingDirectory();
30774
+ if (allowedFolders && allowedFolders.length > 0) {
30775
+ const resolvedWorkingDir = (0, import_path5.resolve)(workingDir);
30776
+ const isAllowed = allowedFolders.some((folder) => {
30777
+ const resolvedFolder = (0, import_path5.resolve)(folder);
30778
+ return resolvedWorkingDir.startsWith(resolvedFolder);
30779
+ });
30780
+ if (!isAllowed) {
30781
+ return `Error: Working directory "${workingDir}" is not within allowed folders: ${allowedFolders.join(", ")}`;
30782
+ }
30783
+ }
30784
+ const executionOptions = {
30785
+ workingDirectory: workingDir,
30786
+ timeout: timeout || bashConfig.timeout || 12e4,
30787
+ env: { ...bashConfig.env, ...env },
30788
+ maxBuffer: bashConfig.maxBuffer,
30789
+ debug
30790
+ };
30791
+ const validation = validateExecutionOptions(executionOptions);
30792
+ if (!validation.valid) {
30793
+ return `Error: Invalid execution options: ${validation.errors.join(", ")}`;
30794
+ }
30795
+ if (validation.warnings.length > 0 && debug) {
30796
+ console.log("[BashTool] Warnings:", validation.warnings);
30797
+ }
30798
+ if (debug) {
30799
+ console.log(`[BashTool] Executing command: "${command}"`);
30800
+ console.log(`[BashTool] Working directory: "${workingDir}"`);
30801
+ console.log(`[BashTool] Timeout: ${executionOptions.timeout}ms`);
30802
+ }
30803
+ const result = await executeBashCommand(command.trim(), executionOptions);
30804
+ if (debug) {
30805
+ console.log(`[BashTool] Command completed - Success: ${result.success}, Duration: ${result.duration}ms`);
30806
+ }
30807
+ const formattedResult = formatExecutionResult(result, debug);
30808
+ if (!result.success) {
30809
+ let errorInfo = `
30810
+
30811
+ Command failed with exit code ${result.exitCode}`;
30812
+ if (result.killed) {
30813
+ errorInfo += ` (${result.error})`;
30814
+ }
30815
+ return formattedResult + errorInfo;
30816
+ }
30817
+ return formattedResult;
30818
+ } catch (error2) {
30819
+ if (debug) {
30820
+ console.error("[BashTool] Execution error:", error2);
30821
+ }
30822
+ return `Error executing bash command: ${error2.message}`;
30823
+ }
30824
+ }
30825
+ });
30826
+ };
30827
+ }
30828
+ });
30829
+
29574
30830
  // src/tools/langchain.js
29575
30831
  var init_langchain = __esm({
29576
30832
  "src/tools/langchain.js"() {
@@ -29719,16 +30975,19 @@ var init_tools = __esm({
29719
30975
  "src/tools/index.js"() {
29720
30976
  "use strict";
29721
30977
  init_vercel();
30978
+ init_bash();
29722
30979
  init_langchain();
29723
30980
  init_common2();
29724
30981
  init_system_message();
29725
30982
  init_vercel();
30983
+ init_bash();
29726
30984
  init_system_message();
29727
30985
  tools = {
29728
30986
  searchTool: searchTool(),
29729
30987
  queryTool: queryTool(),
29730
30988
  extractTool: extractTool(),
29731
30989
  delegateTool: delegateTool(),
30990
+ bashTool: bashTool(),
29732
30991
  DEFAULT_SYSTEM_MESSAGE
29733
30992
  };
29734
30993
  }
@@ -29741,10 +31000,10 @@ async function listFilesByLevel(options) {
29741
31000
  maxFiles = 100,
29742
31001
  respectGitignore = true
29743
31002
  } = options;
29744
- if (!import_fs.default.existsSync(directory)) {
31003
+ if (!import_fs2.default.existsSync(directory)) {
29745
31004
  throw new Error(`Directory does not exist: ${directory}`);
29746
31005
  }
29747
- const gitDirExists = import_fs.default.existsSync(import_path4.default.join(directory, ".git"));
31006
+ const gitDirExists = import_fs2.default.existsSync(import_path6.default.join(directory, ".git"));
29748
31007
  if (gitDirExists && respectGitignore) {
29749
31008
  try {
29750
31009
  return await listFilesUsingGit(directory, maxFiles);
@@ -29759,8 +31018,8 @@ async function listFilesUsingGit(directory, maxFiles) {
29759
31018
  const { stdout } = await execAsync4("git ls-files", { cwd: directory });
29760
31019
  const files = stdout.split("\n").filter(Boolean);
29761
31020
  const sortedFiles = files.sort((a3, b3) => {
29762
- const depthA = a3.split(import_path4.default.sep).length;
29763
- const depthB = b3.split(import_path4.default.sep).length;
31021
+ const depthA = a3.split(import_path6.default.sep).length;
31022
+ const depthB = b3.split(import_path6.default.sep).length;
29764
31023
  return depthA - depthB;
29765
31024
  });
29766
31025
  return sortedFiles.slice(0, maxFiles);
@@ -29775,19 +31034,19 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
29775
31034
  while (queue.length > 0 && result.length < maxFiles) {
29776
31035
  const { dir, level } = queue.shift();
29777
31036
  try {
29778
- const entries = import_fs.default.readdirSync(dir, { withFileTypes: true });
31037
+ const entries = import_fs2.default.readdirSync(dir, { withFileTypes: true });
29779
31038
  const files = entries.filter((entry) => entry.isFile());
29780
31039
  for (const file of files) {
29781
31040
  if (result.length >= maxFiles) break;
29782
- const filePath = import_path4.default.join(dir, file.name);
29783
- const relativePath = import_path4.default.relative(directory, filePath);
31041
+ const filePath = import_path6.default.join(dir, file.name);
31042
+ const relativePath = import_path6.default.relative(directory, filePath);
29784
31043
  if (shouldIgnore(relativePath, ignorePatterns)) continue;
29785
31044
  result.push(relativePath);
29786
31045
  }
29787
31046
  const dirs = entries.filter((entry) => entry.isDirectory());
29788
31047
  for (const subdir of dirs) {
29789
- const subdirPath = import_path4.default.join(dir, subdir.name);
29790
- const relativeSubdirPath = import_path4.default.relative(directory, subdirPath);
31048
+ const subdirPath = import_path6.default.join(dir, subdir.name);
31049
+ const relativeSubdirPath = import_path6.default.relative(directory, subdirPath);
29791
31050
  if (shouldIgnore(relativeSubdirPath, ignorePatterns)) continue;
29792
31051
  if (subdir.name === "node_modules" || subdir.name === ".git") continue;
29793
31052
  queue.push({ dir: subdirPath, level: level + 1 });
@@ -29799,12 +31058,12 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
29799
31058
  return result;
29800
31059
  }
29801
31060
  function loadGitignorePatterns(directory) {
29802
- const gitignorePath = import_path4.default.join(directory, ".gitignore");
29803
- if (!import_fs.default.existsSync(gitignorePath)) {
31061
+ const gitignorePath = import_path6.default.join(directory, ".gitignore");
31062
+ if (!import_fs2.default.existsSync(gitignorePath)) {
29804
31063
  return [];
29805
31064
  }
29806
31065
  try {
29807
- const content = import_fs.default.readFileSync(gitignorePath, "utf8");
31066
+ const content = import_fs2.default.readFileSync(gitignorePath, "utf8");
29808
31067
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
29809
31068
  } catch (error2) {
29810
31069
  console.error(`Warning: Could not read .gitignore: ${error2.message}`);
@@ -29822,25 +31081,25 @@ function shouldIgnore(filePath, ignorePatterns) {
29822
31081
  }
29823
31082
  return false;
29824
31083
  }
29825
- var import_fs, import_path4, import_util5, import_child_process6, execAsync4;
31084
+ var import_fs2, import_path6, import_util5, import_child_process7, execAsync4;
29826
31085
  var init_file_lister = __esm({
29827
31086
  "src/utils/file-lister.js"() {
29828
31087
  "use strict";
29829
- import_fs = __toESM(require("fs"), 1);
29830
- import_path4 = __toESM(require("path"), 1);
31088
+ import_fs2 = __toESM(require("fs"), 1);
31089
+ import_path6 = __toESM(require("path"), 1);
29831
31090
  import_util5 = require("util");
29832
- import_child_process6 = require("child_process");
29833
- execAsync4 = (0, import_util5.promisify)(import_child_process6.exec);
31091
+ import_child_process7 = require("child_process");
31092
+ execAsync4 = (0, import_util5.promisify)(import_child_process7.exec);
29834
31093
  }
29835
31094
  });
29836
31095
 
29837
31096
  // src/agent/simpleTelemetry.js
29838
- var import_fs2, import_path5;
31097
+ var import_fs3, import_path7;
29839
31098
  var init_simpleTelemetry = __esm({
29840
31099
  "src/agent/simpleTelemetry.js"() {
29841
31100
  "use strict";
29842
- import_fs2 = require("fs");
29843
- import_path5 = require("path");
31101
+ import_fs3 = require("fs");
31102
+ import_path7 = require("path");
29844
31103
  }
29845
31104
  });
29846
31105
 
@@ -29858,6 +31117,7 @@ var init_index = __esm({
29858
31117
  init_system_message();
29859
31118
  init_common2();
29860
31119
  init_vercel();
31120
+ init_bash();
29861
31121
  init_ProbeAgent();
29862
31122
  init_simpleTelemetry();
29863
31123
  }
@@ -29906,8 +31166,8 @@ function checkAttemptCompleteRecovery(cleanedXmlString, validTools = []) {
29906
31166
  function hasOtherToolTags(xmlString, validTools = []) {
29907
31167
  const defaultTools = ["search", "query", "extract", "listFiles", "searchFiles", "implement", "attempt_completion"];
29908
31168
  const toolsToCheck = validTools.length > 0 ? validTools : defaultTools;
29909
- for (const tool2 of toolsToCheck) {
29910
- if (tool2 !== "attempt_completion" && xmlString.includes(`<${tool2}`)) {
31169
+ for (const tool3 of toolsToCheck) {
31170
+ if (tool3 !== "attempt_completion" && xmlString.includes(`<${tool3}`)) {
29911
31171
  return true;
29912
31172
  }
29913
31173
  }
@@ -29935,12 +31195,16 @@ var init_xmlParsingUtils = __esm({
29935
31195
 
29936
31196
  // src/agent/tools.js
29937
31197
  function createTools(configOptions) {
29938
- return {
31198
+ const tools2 = {
29939
31199
  searchTool: searchTool(configOptions),
29940
31200
  queryTool: queryTool(configOptions),
29941
31201
  extractTool: extractTool(configOptions),
29942
31202
  delegateTool: delegateTool(configOptions)
29943
31203
  };
31204
+ if (configOptions.enableBash) {
31205
+ tools2.bashTool = bashTool(configOptions);
31206
+ }
31207
+ return tools2;
29944
31208
  }
29945
31209
  function parseXmlToolCallWithThinking(xmlString, validTools) {
29946
31210
  const { cleanedXmlString, recoveryResult } = processXmlWithThinkingAndRecovery(xmlString, validTools);
@@ -30084,26 +31348,33 @@ function createWrappedTools(baseTools) {
30084
31348
  baseTools.delegateTool.execute
30085
31349
  );
30086
31350
  }
31351
+ if (baseTools.bashTool) {
31352
+ wrappedTools.bashToolInstance = wrapToolWithEmitter(
31353
+ baseTools.bashTool,
31354
+ "bash",
31355
+ baseTools.bashTool.execute
31356
+ );
31357
+ }
30087
31358
  return wrappedTools;
30088
31359
  }
30089
- var import_child_process7, import_util6, import_crypto4, import_events, import_fs3, import_fs4, import_path6, import_glob, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
31360
+ var import_child_process8, import_util6, import_crypto4, import_events, import_fs4, import_fs5, import_path8, import_glob, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
30090
31361
  var init_probeTool = __esm({
30091
31362
  "src/agent/probeTool.js"() {
30092
31363
  "use strict";
30093
31364
  init_index();
30094
- import_child_process7 = require("child_process");
31365
+ import_child_process8 = require("child_process");
30095
31366
  import_util6 = require("util");
30096
31367
  import_crypto4 = require("crypto");
30097
31368
  import_events = require("events");
30098
- import_fs3 = __toESM(require("fs"), 1);
30099
- import_fs4 = require("fs");
30100
- import_path6 = __toESM(require("path"), 1);
31369
+ import_fs4 = __toESM(require("fs"), 1);
31370
+ import_fs5 = require("fs");
31371
+ import_path8 = __toESM(require("path"), 1);
30101
31372
  import_glob = require("glob");
30102
31373
  toolCallEmitter = new import_events.EventEmitter();
30103
31374
  activeToolExecutions = /* @__PURE__ */ new Map();
30104
- wrapToolWithEmitter = (tool2, toolName, baseExecute) => {
31375
+ wrapToolWithEmitter = (tool3, toolName, baseExecute) => {
30105
31376
  return {
30106
- ...tool2,
31377
+ ...tool3,
30107
31378
  // Spread schema, description etc.
30108
31379
  execute: async (params) => {
30109
31380
  const debug = process.env.DEBUG === "1";
@@ -30185,9 +31456,9 @@ var init_probeTool = __esm({
30185
31456
  execute: async (params) => {
30186
31457
  const { directory = ".", workingDirectory } = params;
30187
31458
  const baseCwd = workingDirectory || process.cwd();
30188
- const secureBaseDir = import_path6.default.resolve(baseCwd);
30189
- const targetDir = import_path6.default.resolve(secureBaseDir, directory);
30190
- if (!targetDir.startsWith(secureBaseDir + import_path6.default.sep) && targetDir !== secureBaseDir) {
31459
+ const secureBaseDir = import_path8.default.resolve(baseCwd);
31460
+ const targetDir = import_path8.default.resolve(secureBaseDir, directory);
31461
+ if (!targetDir.startsWith(secureBaseDir + import_path8.default.sep) && targetDir !== secureBaseDir) {
30191
31462
  throw new Error("Path traversal attempt detected. Access denied.");
30192
31463
  }
30193
31464
  try {
@@ -30210,9 +31481,9 @@ var init_probeTool = __esm({
30210
31481
  throw new Error("Pattern is required for file search");
30211
31482
  }
30212
31483
  const baseCwd = workingDirectory || process.cwd();
30213
- const secureBaseDir = import_path6.default.resolve(baseCwd);
30214
- const targetDir = import_path6.default.resolve(secureBaseDir, directory);
30215
- if (!targetDir.startsWith(secureBaseDir + import_path6.default.sep) && targetDir !== secureBaseDir) {
31484
+ const secureBaseDir = import_path8.default.resolve(baseCwd);
31485
+ const targetDir = import_path8.default.resolve(secureBaseDir, directory);
31486
+ if (!targetDir.startsWith(secureBaseDir + import_path8.default.sep) && targetDir !== secureBaseDir) {
30216
31487
  throw new Error("Path traversal attempt detected. Access denied.");
30217
31488
  }
30218
31489
  try {
@@ -30244,7 +31515,7 @@ function createMockProvider() {
30244
31515
  provider: "mock",
30245
31516
  // Mock the doGenerate method used by Vercel AI SDK
30246
31517
  doGenerate: async ({ messages, tools: tools2 }) => {
30247
- await new Promise((resolve2) => setTimeout(resolve2, 10));
31518
+ await new Promise((resolve4) => setTimeout(resolve4, 10));
30248
31519
  return {
30249
31520
  text: "This is a mock response for testing",
30250
31521
  toolCalls: [],
@@ -30819,7 +32090,7 @@ ${decodedContent}
30819
32090
  }
30820
32091
  if (needsQuoting(content)) {
30821
32092
  wasFixed = true;
30822
- const safeContent = content.replace(/"/g, "'");
32093
+ const safeContent = content.replace(/"/g, "&quot;").replace(/'/g, "&#39;");
30823
32094
  return `["${safeContent}"]`;
30824
32095
  }
30825
32096
  return match;
@@ -30832,7 +32103,7 @@ ${decodedContent}
30832
32103
  }
30833
32104
  if (needsQuoting(content)) {
30834
32105
  wasFixed = true;
30835
- const safeContent = content.replace(/"/g, "'");
32106
+ const safeContent = content.replace(/"/g, "&quot;").replace(/'/g, "&#39;");
30836
32107
  return `{"${safeContent}"}`;
30837
32108
  }
30838
32109
  return match;
@@ -31002,7 +32273,7 @@ ${fixedContent}
31002
32273
  }
31003
32274
  if (needsQuoting(content)) {
31004
32275
  wasFixed = true;
31005
- const safeContent = content.replace(/"/g, "'");
32276
+ const safeContent = content.replace(/"/g, "&quot;").replace(/'/g, "&#39;");
31006
32277
  return `["${safeContent}"]`;
31007
32278
  }
31008
32279
  return match;
@@ -31015,7 +32286,7 @@ ${fixedContent}
31015
32286
  }
31016
32287
  if (needsQuoting(content)) {
31017
32288
  wasFixed = true;
31018
- const safeContent = content.replace(/"/g, "'");
32289
+ const safeContent = content.replace(/"/g, "&quot;").replace(/'/g, "&#39;");
31019
32290
  return `{"${safeContent}"}`;
31020
32291
  }
31021
32292
  return match;
@@ -31415,11 +32686,11 @@ function loadMCPConfigurationFromPath(configPath) {
31415
32686
  if (!configPath) {
31416
32687
  throw new Error("Config path is required");
31417
32688
  }
31418
- if (!(0, import_fs5.existsSync)(configPath)) {
32689
+ if (!(0, import_fs6.existsSync)(configPath)) {
31419
32690
  throw new Error(`MCP configuration file not found: ${configPath}`);
31420
32691
  }
31421
32692
  try {
31422
- const content = (0, import_fs5.readFileSync)(configPath, "utf8");
32693
+ const content = (0, import_fs6.readFileSync)(configPath, "utf8");
31423
32694
  const config = JSON.parse(content);
31424
32695
  if (process.env.DEBUG === "1") {
31425
32696
  console.error(`[MCP] Loaded configuration from: ${configPath}`);
@@ -31434,19 +32705,19 @@ function loadMCPConfiguration() {
31434
32705
  // Environment variable path
31435
32706
  process.env.MCP_CONFIG_PATH,
31436
32707
  // Local project paths
31437
- (0, import_path7.join)(process.cwd(), ".mcp", "config.json"),
31438
- (0, import_path7.join)(process.cwd(), "mcp.config.json"),
32708
+ (0, import_path9.join)(process.cwd(), ".mcp", "config.json"),
32709
+ (0, import_path9.join)(process.cwd(), "mcp.config.json"),
31439
32710
  // Home directory paths
31440
- (0, import_path7.join)((0, import_os3.homedir)(), ".config", "probe", "mcp.json"),
31441
- (0, import_path7.join)((0, import_os3.homedir)(), ".mcp", "config.json"),
32711
+ (0, import_path9.join)((0, import_os3.homedir)(), ".config", "probe", "mcp.json"),
32712
+ (0, import_path9.join)((0, import_os3.homedir)(), ".mcp", "config.json"),
31442
32713
  // Claude-style config location
31443
- (0, import_path7.join)((0, import_os3.homedir)(), "Library", "Application Support", "Claude", "mcp_config.json")
32714
+ (0, import_path9.join)((0, import_os3.homedir)(), "Library", "Application Support", "Claude", "mcp_config.json")
31444
32715
  ].filter(Boolean);
31445
32716
  let config = null;
31446
32717
  for (const configPath of configPaths) {
31447
- if ((0, import_fs5.existsSync)(configPath)) {
32718
+ if ((0, import_fs6.existsSync)(configPath)) {
31448
32719
  try {
31449
- const content = (0, import_fs5.readFileSync)(configPath, "utf8");
32720
+ const content = (0, import_fs6.readFileSync)(configPath, "utf8");
31450
32721
  config = JSON.parse(content);
31451
32722
  if (process.env.DEBUG === "1") {
31452
32723
  console.error(`[MCP] Loaded configuration from: ${configPath}`);
@@ -31542,22 +32813,22 @@ function parseEnabledServers(config) {
31542
32813
  }
31543
32814
  return servers;
31544
32815
  }
31545
- var import_fs5, import_path7, import_os3, import_url4, __filename4, __dirname4, DEFAULT_CONFIG;
32816
+ var import_fs6, import_path9, import_os3, import_url4, __filename4, __dirname4, DEFAULT_CONFIG;
31546
32817
  var init_config = __esm({
31547
32818
  "src/agent/mcp/config.js"() {
31548
32819
  "use strict";
31549
- import_fs5 = require("fs");
31550
- import_path7 = require("path");
32820
+ import_fs6 = require("fs");
32821
+ import_path9 = require("path");
31551
32822
  import_os3 = require("os");
31552
32823
  import_url4 = require("url");
31553
32824
  __filename4 = (0, import_url4.fileURLToPath)("file:///");
31554
- __dirname4 = (0, import_path7.dirname)(__filename4);
32825
+ __dirname4 = (0, import_path9.dirname)(__filename4);
31555
32826
  DEFAULT_CONFIG = {
31556
32827
  mcpServers: {
31557
32828
  // Example probe server configuration
31558
32829
  "probe-local": {
31559
32830
  command: "node",
31560
- args: [(0, import_path7.join)(__dirname4, "../../../examples/chat/mcpServer.js")],
32831
+ args: [(0, import_path9.join)(__dirname4, "../../../examples/chat/mcpServer.js")],
31561
32832
  transport: "stdio",
31562
32833
  enabled: false
31563
32834
  },
@@ -31714,12 +32985,12 @@ var init_client2 = __esm({
31714
32985
  });
31715
32986
  const toolsResponse = await client.listTools();
31716
32987
  if (toolsResponse && toolsResponse.tools) {
31717
- for (const tool2 of toolsResponse.tools) {
31718
- const qualifiedName = `${name14}_${tool2.name}`;
32988
+ for (const tool3 of toolsResponse.tools) {
32989
+ const qualifiedName = `${name14}_${tool3.name}`;
31719
32990
  this.tools.set(qualifiedName, {
31720
- ...tool2,
32991
+ ...tool3,
31721
32992
  serverName: name14,
31722
- originalName: tool2.name
32993
+ originalName: tool3.name
31723
32994
  });
31724
32995
  if (this.debug) {
31725
32996
  console.error(`[MCP] Registered tool: ${qualifiedName}`);
@@ -31741,20 +33012,20 @@ var init_client2 = __esm({
31741
33012
  * @param {Object} args - Tool arguments
31742
33013
  */
31743
33014
  async callTool(toolName, args) {
31744
- const tool2 = this.tools.get(toolName);
31745
- if (!tool2) {
33015
+ const tool3 = this.tools.get(toolName);
33016
+ if (!tool3) {
31746
33017
  throw new Error(`Unknown tool: ${toolName}`);
31747
33018
  }
31748
- const clientInfo = this.clients.get(tool2.serverName);
33019
+ const clientInfo = this.clients.get(tool3.serverName);
31749
33020
  if (!clientInfo) {
31750
- throw new Error(`Server ${tool2.serverName} not connected`);
33021
+ throw new Error(`Server ${tool3.serverName} not connected`);
31751
33022
  }
31752
33023
  try {
31753
33024
  if (this.debug) {
31754
33025
  console.error(`[MCP] Calling ${toolName} with args:`, args);
31755
33026
  }
31756
33027
  const result = await clientInfo.client.callTool({
31757
- name: tool2.originalName,
33028
+ name: tool3.originalName,
31758
33029
  arguments: args
31759
33030
  });
31760
33031
  return result;
@@ -31769,11 +33040,11 @@ var init_client2 = __esm({
31769
33040
  */
31770
33041
  getTools() {
31771
33042
  const tools2 = {};
31772
- for (const [name14, tool2] of this.tools.entries()) {
33043
+ for (const [name14, tool3] of this.tools.entries()) {
31773
33044
  tools2[name14] = {
31774
- description: tool2.description,
31775
- inputSchema: tool2.inputSchema,
31776
- serverName: tool2.serverName
33045
+ description: tool3.description,
33046
+ inputSchema: tool3.inputSchema,
33047
+ serverName: tool3.serverName
31777
33048
  };
31778
33049
  }
31779
33050
  return tools2;
@@ -31784,10 +33055,10 @@ var init_client2 = __esm({
31784
33055
  */
31785
33056
  getVercelTools() {
31786
33057
  const tools2 = {};
31787
- for (const [name14, tool2] of this.tools.entries()) {
33058
+ for (const [name14, tool3] of this.tools.entries()) {
31788
33059
  tools2[name14] = {
31789
- description: tool2.description,
31790
- inputSchema: tool2.inputSchema,
33060
+ description: tool3.description,
33061
+ inputSchema: tool3.inputSchema,
31791
33062
  execute: async (args) => {
31792
33063
  const result = await this.callTool(name14, args);
31793
33064
  if (result.content && result.content[0]) {
@@ -31824,9 +33095,9 @@ var init_client2 = __esm({
31824
33095
  });
31825
33096
 
31826
33097
  // src/agent/mcp/xmlBridge.js
31827
- function mcpToolToXmlDefinition(name14, tool2) {
31828
- const description = tool2.description || "MCP tool";
31829
- const inputSchema = tool2.inputSchema || tool2.parameters || {};
33098
+ function mcpToolToXmlDefinition(name14, tool3) {
33099
+ const description = tool3.description || "MCP tool";
33100
+ const inputSchema = tool3.inputSchema || tool3.parameters || {};
31830
33101
  let paramDocs = "";
31831
33102
  if (inputSchema.properties) {
31832
33103
  paramDocs = "\n\nParameters (provide as JSON object):";
@@ -31986,8 +33257,8 @@ var init_xmlBridge = __esm({
31986
33257
  const result = await this.mcpManager.initialize(mcpConfigs);
31987
33258
  const vercelTools = this.mcpManager.getVercelTools();
31988
33259
  this.mcpTools = vercelTools;
31989
- for (const [name14, tool2] of Object.entries(vercelTools)) {
31990
- this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14, tool2);
33260
+ for (const [name14, tool3] of Object.entries(vercelTools)) {
33261
+ this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14, tool3);
31991
33262
  }
31992
33263
  if (this.debug) {
31993
33264
  console.error(`[MCP] Loaded ${Object.keys(vercelTools).length} MCP tools from ${result.connected} server(s)`);
@@ -32024,12 +33295,12 @@ var init_xmlBridge = __esm({
32024
33295
  if (this.debug) {
32025
33296
  console.error(`[MCP] Executing MCP tool: ${toolName} with params:`, params);
32026
33297
  }
32027
- const tool2 = this.mcpTools[toolName];
32028
- if (!tool2) {
33298
+ const tool3 = this.mcpTools[toolName];
33299
+ if (!tool3) {
32029
33300
  throw new Error(`Unknown MCP tool: ${toolName}`);
32030
33301
  }
32031
33302
  try {
32032
- const result = await tool2.execute(params);
33303
+ const result = await tool3.execute(params);
32033
33304
  return {
32034
33305
  success: true,
32035
33306
  toolName,
@@ -32082,19 +33353,19 @@ __export(ProbeAgent_exports, {
32082
33353
  ProbeAgent: () => ProbeAgent
32083
33354
  });
32084
33355
  module.exports = __toCommonJS(ProbeAgent_exports);
32085
- var import_anthropic, import_openai, import_google, import_ai2, import_crypto5, import_events2, import_fs6, import_promises, import_path8, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, SUPPORTED_IMAGE_EXTENSIONS, MAX_IMAGE_FILE_SIZE, ProbeAgent;
33356
+ var import_anthropic, import_openai, import_google, import_ai3, import_crypto5, import_events2, import_fs7, import_promises, import_path10, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, SUPPORTED_IMAGE_EXTENSIONS, MAX_IMAGE_FILE_SIZE, ProbeAgent;
32086
33357
  var init_ProbeAgent = __esm({
32087
33358
  "src/agent/ProbeAgent.js"() {
32088
33359
  import_anthropic = require("@ai-sdk/anthropic");
32089
33360
  import_openai = require("@ai-sdk/openai");
32090
33361
  import_google = require("@ai-sdk/google");
32091
33362
  init_dist3();
32092
- import_ai2 = require("ai");
33363
+ import_ai3 = require("ai");
32093
33364
  import_crypto5 = require("crypto");
32094
33365
  import_events2 = require("events");
32095
- import_fs6 = require("fs");
33366
+ import_fs7 = require("fs");
32096
33367
  import_promises = require("fs/promises");
32097
- import_path8 = require("path");
33368
+ import_path10 = require("path");
32098
33369
  init_tokenCounter();
32099
33370
  init_tools2();
32100
33371
  init_common2();
@@ -32138,6 +33409,8 @@ var init_ProbeAgent = __esm({
32138
33409
  this.outline = !!options.outline;
32139
33410
  this.maxResponseTokens = options.maxResponseTokens || parseInt(process.env.MAX_RESPONSE_TOKENS || "0", 10) || null;
32140
33411
  this.disableMermaidValidation = !!options.disableMermaidValidation;
33412
+ this.enableBash = !!options.enableBash;
33413
+ this.bashConfig = options.bashConfig || {};
32141
33414
  if (options.allowedFolders && Array.isArray(options.allowedFolders)) {
32142
33415
  this.allowedFolders = options.allowedFolders;
32143
33416
  } else if (options.path) {
@@ -32181,7 +33454,9 @@ var init_ProbeAgent = __esm({
32181
33454
  debug: this.debug,
32182
33455
  defaultPath: this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd(),
32183
33456
  allowedFolders: this.allowedFolders,
32184
- outline: this.outline
33457
+ outline: this.outline,
33458
+ enableBash: this.enableBash,
33459
+ bashConfig: this.bashConfig
32185
33460
  };
32186
33461
  const baseTools = createTools(configOptions);
32187
33462
  const wrappedTools = createWrappedTools(baseTools);
@@ -32193,6 +33468,9 @@ var init_ProbeAgent = __esm({
32193
33468
  listFiles: listFilesToolInstance,
32194
33469
  searchFiles: searchFilesToolInstance
32195
33470
  };
33471
+ if (this.enableBash && wrappedTools.bashToolInstance) {
33472
+ this.toolImplementations.bash = wrappedTools.bashToolInstance;
33473
+ }
32196
33474
  this.wrappedTools = wrappedTools;
32197
33475
  }
32198
33476
  /**
@@ -32379,13 +33657,13 @@ var init_ProbeAgent = __esm({
32379
33657
  const allowedDirs = this.allowedFolders && this.allowedFolders.length > 0 ? this.allowedFolders : [process.cwd()];
32380
33658
  let absolutePath;
32381
33659
  let isPathAllowed = false;
32382
- if ((0, import_path8.isAbsolute)(imagePath)) {
33660
+ if ((0, import_path10.isAbsolute)(imagePath)) {
32383
33661
  absolutePath = imagePath;
32384
- isPathAllowed = allowedDirs.some((dir) => absolutePath.startsWith((0, import_path8.resolve)(dir)));
33662
+ isPathAllowed = allowedDirs.some((dir) => absolutePath.startsWith((0, import_path10.resolve)(dir)));
32385
33663
  } else {
32386
33664
  for (const dir of allowedDirs) {
32387
- const resolvedPath3 = (0, import_path8.resolve)(dir, imagePath);
32388
- if (resolvedPath3.startsWith((0, import_path8.resolve)(dir))) {
33665
+ const resolvedPath3 = (0, import_path10.resolve)(dir, imagePath);
33666
+ if (resolvedPath3.startsWith((0, import_path10.resolve)(dir))) {
32389
33667
  absolutePath = resolvedPath3;
32390
33668
  isPathAllowed = true;
32391
33669
  break;
@@ -32880,7 +34158,7 @@ You are working with a repository located at: ${searchDirectory}
32880
34158
  try {
32881
34159
  const executeAIRequest = async () => {
32882
34160
  const messagesForAI = this.prepareMessagesWithImages(currentMessages);
32883
- const result = await (0, import_ai2.streamText)({
34161
+ const result = await (0, import_ai3.streamText)({
32884
34162
  model: this.provider(this.model),
32885
34163
  messages: messagesForAI,
32886
34164
  maxTokens: maxResponseTokens,