@poe-platform/safe-bash 0.1.60 → 0.1.61

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.
@@ -41,7 +41,7 @@ var require_base64_js = __commonJS({
41
41
  "node_modules/base64-js/index.js"(exports) {
42
42
  "use strict";
43
43
  init_platform();
44
- exports.byteLength = byteLength;
44
+ exports.byteLength = byteLength2;
45
45
  exports.toByteArray = toByteArray;
46
46
  exports.fromByteArray = fromByteArray;
47
47
  var lookup = [];
@@ -66,7 +66,7 @@ var require_base64_js = __commonJS({
66
66
  var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
67
67
  return [validLen, placeHoldersLen];
68
68
  }
69
- function byteLength(b64) {
69
+ function byteLength2(b64) {
70
70
  var lens = getLens(b64);
71
71
  var validLen = lens[0];
72
72
  var placeHoldersLen = lens[1];
@@ -366,7 +366,7 @@ var require_buffer = __commonJS({
366
366
  if (!Buffer3.isEncoding(encoding)) {
367
367
  throw new TypeError("Unknown encoding: " + encoding);
368
368
  }
369
- const length = byteLength(string, encoding) | 0;
369
+ const length = byteLength2(string, encoding) | 0;
370
370
  let buf = createBuffer(length);
371
371
  const actual = buf.write(string, encoding);
372
372
  if (actual !== length) {
@@ -374,11 +374,11 @@ var require_buffer = __commonJS({
374
374
  }
375
375
  return buf;
376
376
  }
377
- function fromArrayLike(array) {
378
- const length = array.length < 0 ? 0 : checked(array.length) | 0;
377
+ function fromArrayLike(array2) {
378
+ const length = array2.length < 0 ? 0 : checked(array2.length) | 0;
379
379
  const buf = createBuffer(length);
380
380
  for (let i = 0; i < length; i += 1) {
381
- buf[i] = array[i] & 255;
381
+ buf[i] = array2[i] & 255;
382
382
  }
383
383
  return buf;
384
384
  }
@@ -389,20 +389,20 @@ var require_buffer = __commonJS({
389
389
  }
390
390
  return fromArrayLike(arrayView);
391
391
  }
392
- function fromArrayBuffer(array, byteOffset, length) {
393
- if (byteOffset < 0 || array.byteLength < byteOffset) {
392
+ function fromArrayBuffer(array2, byteOffset2, length) {
393
+ if (byteOffset2 < 0 || array2.byteLength < byteOffset2) {
394
394
  throw new RangeError('"offset" is outside of buffer bounds');
395
395
  }
396
- if (array.byteLength < byteOffset + (length || 0)) {
396
+ if (array2.byteLength < byteOffset2 + (length || 0)) {
397
397
  throw new RangeError('"length" is outside of buffer bounds');
398
398
  }
399
399
  let buf;
400
- if (byteOffset === void 0 && length === void 0) {
401
- buf = new Uint8Array(array);
400
+ if (byteOffset2 === void 0 && length === void 0) {
401
+ buf = new Uint8Array(array2);
402
402
  } else if (length === void 0) {
403
- buf = new Uint8Array(array, byteOffset);
403
+ buf = new Uint8Array(array2, byteOffset2);
404
404
  } else {
405
- buf = new Uint8Array(array, byteOffset, length);
405
+ buf = new Uint8Array(array2, byteOffset2, length);
406
406
  }
407
407
  Object.setPrototypeOf(buf, Buffer3.prototype);
408
408
  return buf;
@@ -520,7 +520,7 @@ var require_buffer = __commonJS({
520
520
  }
521
521
  return buffer;
522
522
  };
523
- function byteLength(string, encoding) {
523
+ function byteLength2(string, encoding) {
524
524
  if (Buffer3.isBuffer(string)) {
525
525
  return string.length;
526
526
  }
@@ -563,7 +563,7 @@ var require_buffer = __commonJS({
563
563
  }
564
564
  }
565
565
  }
566
- Buffer3.byteLength = byteLength;
566
+ Buffer3.byteLength = byteLength2;
567
567
  function slowToString(encoding, start, end) {
568
568
  let loweredCase = false;
569
569
  if (start === void 0 || start < 0) {
@@ -726,26 +726,26 @@ var require_buffer = __commonJS({
726
726
  if (y < x) return 1;
727
727
  return 0;
728
728
  };
729
- function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
729
+ function bidirectionalIndexOf(buffer, val, byteOffset2, encoding, dir) {
730
730
  if (buffer.length === 0) return -1;
731
- if (typeof byteOffset === "string") {
732
- encoding = byteOffset;
733
- byteOffset = 0;
734
- } else if (byteOffset > 2147483647) {
735
- byteOffset = 2147483647;
736
- } else if (byteOffset < -2147483648) {
737
- byteOffset = -2147483648;
738
- }
739
- byteOffset = +byteOffset;
740
- if (numberIsNaN(byteOffset)) {
741
- byteOffset = dir ? 0 : buffer.length - 1;
742
- }
743
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
744
- if (byteOffset >= buffer.length) {
731
+ if (typeof byteOffset2 === "string") {
732
+ encoding = byteOffset2;
733
+ byteOffset2 = 0;
734
+ } else if (byteOffset2 > 2147483647) {
735
+ byteOffset2 = 2147483647;
736
+ } else if (byteOffset2 < -2147483648) {
737
+ byteOffset2 = -2147483648;
738
+ }
739
+ byteOffset2 = +byteOffset2;
740
+ if (numberIsNaN(byteOffset2)) {
741
+ byteOffset2 = dir ? 0 : buffer.length - 1;
742
+ }
743
+ if (byteOffset2 < 0) byteOffset2 = buffer.length + byteOffset2;
744
+ if (byteOffset2 >= buffer.length) {
745
745
  if (dir) return -1;
746
- else byteOffset = buffer.length - 1;
747
- } else if (byteOffset < 0) {
748
- if (dir) byteOffset = 0;
746
+ else byteOffset2 = buffer.length - 1;
747
+ } else if (byteOffset2 < 0) {
748
+ if (dir) byteOffset2 = 0;
749
749
  else return -1;
750
750
  }
751
751
  if (typeof val === "string") {
@@ -755,21 +755,21 @@ var require_buffer = __commonJS({
755
755
  if (val.length === 0) {
756
756
  return -1;
757
757
  }
758
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
758
+ return arrayIndexOf(buffer, val, byteOffset2, encoding, dir);
759
759
  } else if (typeof val === "number") {
760
760
  val = val & 255;
761
761
  if (typeof Uint8Array.prototype.indexOf === "function") {
762
762
  if (dir) {
763
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
763
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset2);
764
764
  } else {
765
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
765
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset2);
766
766
  }
767
767
  }
768
- return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
768
+ return arrayIndexOf(buffer, [val], byteOffset2, encoding, dir);
769
769
  }
770
770
  throw new TypeError("val must be string, number or Buffer");
771
771
  }
772
- function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
772
+ function arrayIndexOf(arr, val, byteOffset2, encoding, dir) {
773
773
  let indexSize = 1;
774
774
  let arrLength = arr.length;
775
775
  let valLength = val.length;
@@ -782,7 +782,7 @@ var require_buffer = __commonJS({
782
782
  indexSize = 2;
783
783
  arrLength /= 2;
784
784
  valLength /= 2;
785
- byteOffset /= 2;
785
+ byteOffset2 /= 2;
786
786
  }
787
787
  }
788
788
  function read(buf, i2) {
@@ -795,7 +795,7 @@ var require_buffer = __commonJS({
795
795
  let i;
796
796
  if (dir) {
797
797
  let foundIndex = -1;
798
- for (i = byteOffset; i < arrLength; i++) {
798
+ for (i = byteOffset2; i < arrLength; i++) {
799
799
  if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
800
800
  if (foundIndex === -1) foundIndex = i;
801
801
  if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
@@ -805,8 +805,8 @@ var require_buffer = __commonJS({
805
805
  }
806
806
  }
807
807
  } else {
808
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
809
- for (i = byteOffset; i >= 0; i--) {
808
+ if (byteOffset2 + valLength > arrLength) byteOffset2 = arrLength - valLength;
809
+ for (i = byteOffset2; i >= 0; i--) {
810
810
  let found = true;
811
811
  for (let j = 0; j < valLength; j++) {
812
812
  if (read(arr, i + j) !== read(val, j)) {
@@ -819,14 +819,14 @@ var require_buffer = __commonJS({
819
819
  }
820
820
  return -1;
821
821
  }
822
- Buffer3.prototype.includes = function includes(val, byteOffset, encoding) {
823
- return this.indexOf(val, byteOffset, encoding) !== -1;
822
+ Buffer3.prototype.includes = function includes(val, byteOffset2, encoding) {
823
+ return this.indexOf(val, byteOffset2, encoding) !== -1;
824
824
  };
825
- Buffer3.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
826
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
825
+ Buffer3.prototype.indexOf = function indexOf(val, byteOffset2, encoding) {
826
+ return bidirectionalIndexOf(this, val, byteOffset2, encoding, true);
827
827
  };
828
- Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
829
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
828
+ Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset2, encoding) {
829
+ return bidirectionalIndexOf(this, val, byteOffset2, encoding, false);
830
830
  };
831
831
  function hexWrite(buf, string, offset, length) {
832
832
  offset = Number(offset) || 0;
@@ -1066,28 +1066,28 @@ var require_buffer = __commonJS({
1066
1066
  if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
1067
1067
  if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
1068
1068
  }
1069
- Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1069
+ Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength3, noAssert) {
1070
1070
  offset = offset >>> 0;
1071
- byteLength2 = byteLength2 >>> 0;
1072
- if (!noAssert) checkOffset(offset, byteLength2, this.length);
1071
+ byteLength3 = byteLength3 >>> 0;
1072
+ if (!noAssert) checkOffset(offset, byteLength3, this.length);
1073
1073
  let val = this[offset];
1074
1074
  let mul = 1;
1075
1075
  let i = 0;
1076
- while (++i < byteLength2 && (mul *= 256)) {
1076
+ while (++i < byteLength3 && (mul *= 256)) {
1077
1077
  val += this[offset + i] * mul;
1078
1078
  }
1079
1079
  return val;
1080
1080
  };
1081
- Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1081
+ Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength3, noAssert) {
1082
1082
  offset = offset >>> 0;
1083
- byteLength2 = byteLength2 >>> 0;
1083
+ byteLength3 = byteLength3 >>> 0;
1084
1084
  if (!noAssert) {
1085
- checkOffset(offset, byteLength2, this.length);
1085
+ checkOffset(offset, byteLength3, this.length);
1086
1086
  }
1087
- let val = this[offset + --byteLength2];
1087
+ let val = this[offset + --byteLength3];
1088
1088
  let mul = 1;
1089
- while (byteLength2 > 0 && (mul *= 256)) {
1090
- val += this[offset + --byteLength2] * mul;
1089
+ while (byteLength3 > 0 && (mul *= 256)) {
1090
+ val += this[offset + --byteLength3] * mul;
1091
1091
  }
1092
1092
  return val;
1093
1093
  };
@@ -1140,32 +1140,32 @@ var require_buffer = __commonJS({
1140
1140
  const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1141
1141
  return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1142
1142
  });
1143
- Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1143
+ Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength3, noAssert) {
1144
1144
  offset = offset >>> 0;
1145
- byteLength2 = byteLength2 >>> 0;
1146
- if (!noAssert) checkOffset(offset, byteLength2, this.length);
1145
+ byteLength3 = byteLength3 >>> 0;
1146
+ if (!noAssert) checkOffset(offset, byteLength3, this.length);
1147
1147
  let val = this[offset];
1148
1148
  let mul = 1;
1149
1149
  let i = 0;
1150
- while (++i < byteLength2 && (mul *= 256)) {
1150
+ while (++i < byteLength3 && (mul *= 256)) {
1151
1151
  val += this[offset + i] * mul;
1152
1152
  }
1153
1153
  mul *= 128;
1154
- if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1154
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
1155
1155
  return val;
1156
1156
  };
1157
- Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1157
+ Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength3, noAssert) {
1158
1158
  offset = offset >>> 0;
1159
- byteLength2 = byteLength2 >>> 0;
1160
- if (!noAssert) checkOffset(offset, byteLength2, this.length);
1161
- let i = byteLength2;
1159
+ byteLength3 = byteLength3 >>> 0;
1160
+ if (!noAssert) checkOffset(offset, byteLength3, this.length);
1161
+ let i = byteLength3;
1162
1162
  let mul = 1;
1163
1163
  let val = this[offset + --i];
1164
1164
  while (i > 0 && (mul *= 256)) {
1165
1165
  val += this[offset + --i] * mul;
1166
1166
  }
1167
1167
  mul *= 128;
1168
- if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1168
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
1169
1169
  return val;
1170
1170
  };
1171
1171
  Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
@@ -1244,37 +1244,37 @@ var require_buffer = __commonJS({
1244
1244
  if (value2 > max || value2 < min) throw new RangeError('"value" argument is out of bounds');
1245
1245
  if (offset + ext > buf.length) throw new RangeError("Index out of range");
1246
1246
  }
1247
- Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value2, offset, byteLength2, noAssert) {
1247
+ Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value2, offset, byteLength3, noAssert) {
1248
1248
  value2 = +value2;
1249
1249
  offset = offset >>> 0;
1250
- byteLength2 = byteLength2 >>> 0;
1250
+ byteLength3 = byteLength3 >>> 0;
1251
1251
  if (!noAssert) {
1252
- const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1253
- checkInt(this, value2, offset, byteLength2, maxBytes, 0);
1252
+ const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
1253
+ checkInt(this, value2, offset, byteLength3, maxBytes, 0);
1254
1254
  }
1255
1255
  let mul = 1;
1256
1256
  let i = 0;
1257
1257
  this[offset] = value2 & 255;
1258
- while (++i < byteLength2 && (mul *= 256)) {
1258
+ while (++i < byteLength3 && (mul *= 256)) {
1259
1259
  this[offset + i] = value2 / mul & 255;
1260
1260
  }
1261
- return offset + byteLength2;
1261
+ return offset + byteLength3;
1262
1262
  };
1263
- Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value2, offset, byteLength2, noAssert) {
1263
+ Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value2, offset, byteLength3, noAssert) {
1264
1264
  value2 = +value2;
1265
1265
  offset = offset >>> 0;
1266
- byteLength2 = byteLength2 >>> 0;
1266
+ byteLength3 = byteLength3 >>> 0;
1267
1267
  if (!noAssert) {
1268
- const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1269
- checkInt(this, value2, offset, byteLength2, maxBytes, 0);
1268
+ const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
1269
+ checkInt(this, value2, offset, byteLength3, maxBytes, 0);
1270
1270
  }
1271
- let i = byteLength2 - 1;
1271
+ let i = byteLength3 - 1;
1272
1272
  let mul = 1;
1273
1273
  this[offset + i] = value2 & 255;
1274
1274
  while (--i >= 0 && (mul *= 256)) {
1275
1275
  this[offset + i] = value2 / mul & 255;
1276
1276
  }
1277
- return offset + byteLength2;
1277
+ return offset + byteLength3;
1278
1278
  };
1279
1279
  Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value2, offset, noAssert) {
1280
1280
  value2 = +value2;
@@ -1365,33 +1365,33 @@ var require_buffer = __commonJS({
1365
1365
  Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value2, offset = 0) {
1366
1366
  return wrtBigUInt64BE(this, value2, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1367
1367
  });
1368
- Buffer3.prototype.writeIntLE = function writeIntLE(value2, offset, byteLength2, noAssert) {
1368
+ Buffer3.prototype.writeIntLE = function writeIntLE(value2, offset, byteLength3, noAssert) {
1369
1369
  value2 = +value2;
1370
1370
  offset = offset >>> 0;
1371
1371
  if (!noAssert) {
1372
- const limit = Math.pow(2, 8 * byteLength2 - 1);
1373
- checkInt(this, value2, offset, byteLength2, limit - 1, -limit);
1372
+ const limit = Math.pow(2, 8 * byteLength3 - 1);
1373
+ checkInt(this, value2, offset, byteLength3, limit - 1, -limit);
1374
1374
  }
1375
1375
  let i = 0;
1376
1376
  let mul = 1;
1377
1377
  let sub = 0;
1378
1378
  this[offset] = value2 & 255;
1379
- while (++i < byteLength2 && (mul *= 256)) {
1379
+ while (++i < byteLength3 && (mul *= 256)) {
1380
1380
  if (value2 < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1381
1381
  sub = 1;
1382
1382
  }
1383
1383
  this[offset + i] = (value2 / mul >> 0) - sub & 255;
1384
1384
  }
1385
- return offset + byteLength2;
1385
+ return offset + byteLength3;
1386
1386
  };
1387
- Buffer3.prototype.writeIntBE = function writeIntBE(value2, offset, byteLength2, noAssert) {
1387
+ Buffer3.prototype.writeIntBE = function writeIntBE(value2, offset, byteLength3, noAssert) {
1388
1388
  value2 = +value2;
1389
1389
  offset = offset >>> 0;
1390
1390
  if (!noAssert) {
1391
- const limit = Math.pow(2, 8 * byteLength2 - 1);
1392
- checkInt(this, value2, offset, byteLength2, limit - 1, -limit);
1391
+ const limit = Math.pow(2, 8 * byteLength3 - 1);
1392
+ checkInt(this, value2, offset, byteLength3, limit - 1, -limit);
1393
1393
  }
1394
- let i = byteLength2 - 1;
1394
+ let i = byteLength3 - 1;
1395
1395
  let mul = 1;
1396
1396
  let sub = 0;
1397
1397
  this[offset + i] = value2 & 255;
@@ -1401,7 +1401,7 @@ var require_buffer = __commonJS({
1401
1401
  }
1402
1402
  this[offset + i] = (value2 / mul >> 0) - sub & 255;
1403
1403
  }
1404
- return offset + byteLength2;
1404
+ return offset + byteLength3;
1405
1405
  };
1406
1406
  Buffer3.prototype.writeInt8 = function writeInt8(value2, offset, noAssert) {
1407
1407
  value2 = +value2;
@@ -1646,28 +1646,28 @@ var require_buffer = __commonJS({
1646
1646
  }
1647
1647
  return `${val.slice(0, i)}${res}`;
1648
1648
  }
1649
- function checkBounds(buf, offset, byteLength2) {
1649
+ function checkBounds(buf, offset, byteLength3) {
1650
1650
  validateNumber(offset, "offset");
1651
- if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
1652
- boundsError(offset, buf.length - (byteLength2 + 1));
1651
+ if (buf[offset] === void 0 || buf[offset + byteLength3] === void 0) {
1652
+ boundsError(offset, buf.length - (byteLength3 + 1));
1653
1653
  }
1654
1654
  }
1655
- function checkIntBI(value2, min, max, buf, offset, byteLength2) {
1655
+ function checkIntBI(value2, min, max, buf, offset, byteLength3) {
1656
1656
  if (value2 > max || value2 < min) {
1657
1657
  const n = typeof min === "bigint" ? "n" : "";
1658
1658
  let range;
1659
- if (byteLength2 > 3) {
1659
+ if (byteLength3 > 3) {
1660
1660
  if (min === 0 || min === BigInt(0)) {
1661
- range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1661
+ range = `>= 0${n} and < 2${n} ** ${(byteLength3 + 1) * 8}${n}`;
1662
1662
  } else {
1663
- range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
1663
+ range = `>= -(2${n} ** ${(byteLength3 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength3 + 1) * 8 - 1}${n}`;
1664
1664
  }
1665
1665
  } else {
1666
1666
  range = `>= ${min}${n} and <= ${max}${n}`;
1667
1667
  }
1668
1668
  throw new errors.ERR_OUT_OF_RANGE("value", range, value2);
1669
1669
  }
1670
- checkBounds(buf, offset, byteLength2);
1670
+ checkBounds(buf, offset, byteLength3);
1671
1671
  }
1672
1672
  function validateNumber(value2, name2) {
1673
1673
  if (typeof value2 !== "number") {
@@ -2179,18 +2179,18 @@ var CommandRegistry = class {
2179
2179
  constructor(commands = []) {
2180
2180
  for (const command2 of commands) this.register(command2);
2181
2181
  }
2182
- register(command2, options2 = {}) {
2183
- const { name: name2, execute: execute2 } = command2;
2182
+ register(command2, options3 = {}) {
2183
+ const { name: name2, execute: execute3 } = command2;
2184
2184
  if (typeof name2 !== "string" || !name2 || /[\s/\0]/u.test(name2)) {
2185
2185
  throw new TypeError("Command names must be nonempty and contain no whitespace, slash, or NUL");
2186
2186
  }
2187
- if (typeof execute2 !== "function") {
2187
+ if (typeof execute3 !== "function") {
2188
2188
  throw new TypeError("Command execute must be a function");
2189
2189
  }
2190
- if (this.#commands.has(name2) && !options2.replace) {
2190
+ if (this.#commands.has(name2) && !options3.replace) {
2191
2191
  throw new Error(`Command already registered: ${name2}`);
2192
2192
  }
2193
- this.#commands.set(name2, Object.freeze({ ...command2, name: name2, execute: execute2 }));
2193
+ this.#commands.set(name2, Object.freeze({ ...command2, name: name2, execute: execute3 }));
2194
2194
  return this;
2195
2195
  }
2196
2196
  get(name2) {
@@ -2273,9 +2273,9 @@ init_platform();
2273
2273
  import { collectBytes, readBytes } from "@poe-platform/safe-fs/core";
2274
2274
  import { collectBytes as collectBytes2, readBytes as readBytes2, toByteSource } from "@poe-platform/safe-fs/core";
2275
2275
  var outputFailure = /* @__PURE__ */ Symbol("output failure");
2276
- function createBytePipe(options2 = {}) {
2277
- const highWaterMark = options2.highWaterMark ?? 64 * 1024;
2278
- const signal = options2.signal;
2276
+ function createBytePipe(options3 = {}) {
2277
+ const highWaterMark = options3.highWaterMark ?? 64 * 1024;
2278
+ const signal = options3.signal;
2279
2279
  if (!Number.isSafeInteger(highWaterMark) || highWaterMark < 1) {
2280
2280
  throw new RangeError("highWaterMark must be a positive safe integer");
2281
2281
  }
@@ -2390,8 +2390,8 @@ async function pipeBytes(source, sink, signal) {
2390
2390
  }
2391
2391
  signal?.throwIfAborted();
2392
2392
  }
2393
- async function collectText(source, options2) {
2394
- return new TextDecoder().decode(await collectBytes(source, options2));
2393
+ async function collectText(source, options3) {
2394
+ return new TextDecoder().decode(await collectBytes(source, options3));
2395
2395
  }
2396
2396
  async function abortable(operation, signal) {
2397
2397
  signal?.throwIfAborted();
@@ -3117,23 +3117,23 @@ function compareCopyIdentity(left, right) {
3117
3117
  if (!left || !right || !complete(left) || !complete(right)) return "unknown";
3118
3118
  return left.identityScope === right.identityScope && left.dev === right.dev && left.ino === right.ino ? "same" : "distinct";
3119
3119
  }
3120
- async function compareObservedEntries(fs, path, stat, peer, peerPath, peerStat, options2 = {}) {
3121
- options2.signal?.throwIfAborted();
3120
+ async function compareObservedEntries(fs, path, stat, peer, peerPath, peerStat, options3 = {}) {
3121
+ options3.signal?.throwIfAborted();
3122
3122
  const identity = compareCopyIdentity(stat, peerStat);
3123
3123
  if (identity !== "unknown") return identity;
3124
3124
  let result = "unknown";
3125
3125
  const operands = fs === peer ? [[fs, path, peer, peerPath]] : [[fs, path, peer, peerPath], [peer, peerPath, fs, path]];
3126
3126
  for (const [owner, ownPath, other, otherPath] of operands) {
3127
- options2.signal?.throwIfAborted();
3127
+ options3.signal?.throwIfAborted();
3128
3128
  if (!owner.compareEntry) continue;
3129
3129
  let answer;
3130
3130
  try {
3131
- answer = await owner.compareEntry(ownPath, other, otherPath, options2);
3131
+ answer = await owner.compareEntry(ownPath, other, otherPath, options3);
3132
3132
  } catch (error) {
3133
- options2.signal?.throwIfAborted();
3133
+ options3.signal?.throwIfAborted();
3134
3134
  throw error;
3135
3135
  }
3136
- options2.signal?.throwIfAborted();
3136
+ options3.signal?.throwIfAborted();
3137
3137
  if (answer !== "same" && answer !== "distinct" && answer !== "unknown") {
3138
3138
  throw new FsError("EIO", { path, dest: peerPath, message: "invalid entry comparison answer" });
3139
3139
  }
@@ -4761,15 +4761,15 @@ function textCommands() {
4761
4761
  if (numericKey && numericKeyFlags.has("n") && !["b", "f"].some((flag) => numericKeyFlags.has(flag)) && !parsed.flags.has("c")) {
4762
4762
  const keyedNumericValues = /* @__PURE__ */ new Map();
4763
4763
  let retainedKeyBytes = 0;
4764
- const keyedNumericValue = (record3) => {
4765
- const cached = keyedNumericValues.get(record3);
4764
+ const keyedNumericValue = (record4) => {
4765
+ const cached = keyedNumericValues.get(record4);
4766
4766
  if (cached !== void 0) return cached;
4767
4767
  context.signal.throwIfAborted();
4768
- const bytes2 = keyBytes(record3, numericKey, separator, false);
4768
+ const bytes2 = keyBytes(record4, numericKey, separator, false);
4769
4769
  const charge2 = 6 * bytes2.length + 2;
4770
4770
  if (keyedNumericValues.size >= 16384 || charge2 > 1048576 - retainedKeyBytes) return parseNumeric(bytes2);
4771
4771
  const parsedValue = parseNumeric(bytes2);
4772
- keyedNumericValues.set(record3, parsedValue);
4772
+ keyedNumericValues.set(record4, parsedValue);
4773
4773
  retainedKeyBytes += charge2;
4774
4774
  return parsedValue;
4775
4775
  };
@@ -4815,13 +4815,13 @@ function textCommands() {
4815
4815
  let previous;
4816
4816
  let buffer = new Uint8Array(64 * 1024);
4817
4817
  let used = 0;
4818
- for (const record3 of records) {
4818
+ for (const record4 of records) {
4819
4819
  context.signal.throwIfAborted();
4820
- if (parsed.flags.has("u") && previous !== void 0 && keyCompare(previous, record3) === 0) continue;
4820
+ if (parsed.flags.has("u") && previous !== void 0 && keyCompare(previous, record4) === 0) continue;
4821
4821
  let offset = 0;
4822
- while (offset < record3.length) {
4823
- const length = Math.min(record3.length - offset, buffer.length - used);
4824
- buffer.set(record3.subarray(offset, offset + length), used);
4822
+ while (offset < record4.length) {
4823
+ const length = Math.min(record4.length - offset, buffer.length - used);
4824
+ buffer.set(record4.subarray(offset, offset + length), used);
4825
4825
  offset += length;
4826
4826
  used += length;
4827
4827
  if (used === buffer.length) {
@@ -4836,7 +4836,7 @@ function textCommands() {
4836
4836
  buffer = new Uint8Array(64 * 1024);
4837
4837
  used = 0;
4838
4838
  }
4839
- previous = record3;
4839
+ previous = record4;
4840
4840
  }
4841
4841
  if (used) yield buffer.subarray(0, used);
4842
4842
  })();
@@ -4867,19 +4867,19 @@ function textCommands() {
4867
4867
  let previousKey;
4868
4868
  let count2 = 0;
4869
4869
  const selected = () => (!parsed.flags.has("d") || count2 > 1) && (!parsed.flags.has("u") || count2 === 1);
4870
- const record3 = () => concatenate([...parsed.flags.has("c") ? [encoder2.encode(`${String(count2).padStart(7)} `)] : [], previous, Uint8Array.of(delimiter)]);
4870
+ const record4 = () => concatenate([...parsed.flags.has("c") ? [encoder2.encode(`${String(count2).padStart(7)} `)] : [], previous, Uint8Array.of(delimiter)]);
4871
4871
  for await (const line of lines(input(context, parsed.operands[0]), delimiter)) {
4872
4872
  context.signal.throwIfAborted();
4873
4873
  const currentKey = key(line.bytes);
4874
4874
  if (previousKey && compareBytes(previousKey, currentKey) === 0) count2++;
4875
4875
  else {
4876
- if (previous !== void 0 && selected()) yield record3();
4876
+ if (previous !== void 0 && selected()) yield record4();
4877
4877
  previous = line.bytes;
4878
4878
  previousKey = currentKey;
4879
4879
  count2 = 1;
4880
4880
  }
4881
4881
  }
4882
- if (previous !== void 0 && selected()) yield record3();
4882
+ if (previous !== void 0 && selected()) yield record4();
4883
4883
  })();
4884
4884
  if (parsed.operands[1] !== void 0 && parsed.operands[0] !== "-" && pathOf(context, parsed.operands[0]) === pathOf(context, parsed.operands[1])) throw new UsageError("input and output must be different files");
4885
4885
  await emitRecords(context, records, parsed.operands[1]);
@@ -4912,9 +4912,9 @@ function textCommands() {
4912
4912
  context.signal.throwIfAborted();
4913
4913
  let bytes2;
4914
4914
  if (mode === "f") {
4915
- const record3 = import_buffer.Buffer.from(line.bytes.buffer, line.bytes.byteOffset, line.bytes.byteLength);
4915
+ const record4 = import_buffer.Buffer.from(line.bytes.buffer, line.bytes.byteOffset, line.bytes.byteLength);
4916
4916
  const separator = import_buffer.Buffer.from(delimiter);
4917
- let boundary = record3.indexOf(separator);
4917
+ let boundary = record4.indexOf(separator);
4918
4918
  if (boundary < 0) {
4919
4919
  if (parsed.flags.has("s")) continue;
4920
4920
  bytes2 = line.bytes;
@@ -4927,12 +4927,12 @@ function textCommands() {
4927
4927
  while (true) {
4928
4928
  if (selected(field++)) {
4929
4929
  if (emitted) pieces.push(joiner);
4930
- pieces.push(record3.subarray(start, boundary < 0 ? record3.length : boundary));
4930
+ pieces.push(record4.subarray(start, boundary < 0 ? record4.length : boundary));
4931
4931
  emitted = true;
4932
4932
  }
4933
4933
  if (boundary < 0) break;
4934
4934
  start = boundary + separator.length;
4935
- boundary = record3.indexOf(separator, start);
4935
+ boundary = record4.indexOf(separator, start);
4936
4936
  }
4937
4937
  bytes2 = concatenate(pieces);
4938
4938
  }
@@ -6316,7 +6316,7 @@ var Parser = class {
6316
6316
  this.advance();
6317
6317
  let nodes = 0;
6318
6318
  const grouped = /* @__PURE__ */ new WeakSet();
6319
- const admit = () => {
6319
+ const admit2 = () => {
6320
6320
  if (nodes >= 4096) this.error("Conditional syntax exceeds 4096 nodes");
6321
6321
  nodes++;
6322
6322
  };
@@ -6327,7 +6327,7 @@ var Parser = class {
6327
6327
  const primary = (depth) => {
6328
6328
  if (depth > 64) this.error("Conditional syntax nesting exceeds 64");
6329
6329
  if (this.is("!")) {
6330
- admit();
6330
+ admit2();
6331
6331
  this.advance();
6332
6332
  const expression2 = primary(depth + 1);
6333
6333
  return expression2.kind === "not" && !grouped.has(expression2) ? expression2.operand : { kind: "not", operand: expression2 };
@@ -6339,7 +6339,7 @@ var Parser = class {
6339
6339
  grouped.add(expression2);
6340
6340
  return expression2;
6341
6341
  }
6342
- admit();
6342
+ admit2();
6343
6343
  const first = operand();
6344
6344
  if (conditionalBinary.has(this.current.value)) {
6345
6345
  const operator = this.current.value;
@@ -6354,7 +6354,7 @@ var Parser = class {
6354
6354
  const conjunction = (depth) => {
6355
6355
  let expression2 = primary(depth);
6356
6356
  while (this.is("&&")) {
6357
- admit();
6357
+ admit2();
6358
6358
  this.advance();
6359
6359
  expression2 = { kind: "and", left: expression2, right: primary(depth) };
6360
6360
  }
@@ -6363,7 +6363,7 @@ var Parser = class {
6363
6363
  const disjunction = (depth) => {
6364
6364
  let expression2 = conjunction(depth);
6365
6365
  while (this.is("||")) {
6366
- admit();
6366
+ admit2();
6367
6367
  this.advance();
6368
6368
  expression2 = { kind: "or", left: expression2, right: conjunction(depth) };
6369
6369
  }
@@ -6528,18 +6528,18 @@ var Parser = class {
6528
6528
  return script;
6529
6529
  }
6530
6530
  redirect() {
6531
- let descriptor;
6531
+ let descriptor2;
6532
6532
  if (this.current.kind === "word" && /^\d+$/u.test(this.current.value)) {
6533
6533
  const next = this.peek();
6534
- if (/^(?:>|>>|<|<<|<<-|<<<|>&|<&|>\|)$/u.test(next.value) && this.current.end === next.offset) descriptor = Number(this.advance().value);
6534
+ if (/^(?:>|>>|<|<<|<<-|<<<|>&|<&|>\|)$/u.test(next.value) && this.current.end === next.offset) descriptor2 = Number(this.advance().value);
6535
6535
  }
6536
6536
  if (!/^(?:>|>>|<|<<|<<-|<<<|>&|<&|>\||&>)$/u.test(this.current.value) || this.current.kind !== "operator") return void 0;
6537
6537
  const operator = this.advance().value;
6538
- descriptor ??= operator.startsWith("<") ? 0 : 1;
6539
- if (!Number.isSafeInteger(descriptor) || descriptor > 255) this.error("File descriptor must be between 0 and 255");
6538
+ descriptor2 ??= operator.startsWith("<") ? 0 : 1;
6539
+ if (!Number.isSafeInteger(descriptor2) || descriptor2 > 255) this.error("File descriptor must be between 0 and 255");
6540
6540
  if (!this.current.word) this.error("Expected redirect target");
6541
6541
  const target = this.advance();
6542
- return { descriptor, operator, target: target.word, line: this.lexer.lineAt(Math.max(target.offset, target.end - 1)), ...(operator === "<&" || operator === ">&") && this.lexer.source[target.end - 1] === "-" ? { move: true } : {}, ...target.document ? { document: target.document } : {} };
6542
+ return { descriptor: descriptor2, operator, target: target.word, line: this.lexer.lineAt(Math.max(target.offset, target.end - 1)), ...(operator === "<&" || operator === ">&") && this.lexer.source[target.end - 1] === "-" ? { move: true } : {}, ...target.document ? { document: target.document } : {} };
6543
6543
  }
6544
6544
  };
6545
6545
  function parseShell(source, depth = 0) {
@@ -6588,13 +6588,13 @@ init_platform();
6588
6588
  // packages/safe-bash/src/shell/value-state.ts
6589
6589
  init_platform();
6590
6590
  var ValueArena = class {
6591
- constructor(maximumBytes, maximumSlots, checkpoint, fail = (limit) => {
6591
+ constructor(maximumBytes, maximumSlots, checkpoint, fail2 = (limit) => {
6592
6592
  throw new ShellLimitError(limit);
6593
6593
  }) {
6594
6594
  this.maximumBytes = maximumBytes;
6595
6595
  this.maximumSlots = maximumSlots;
6596
6596
  this.checkpoint = checkpoint;
6597
- this.fail = fail;
6597
+ this.fail = fail2;
6598
6598
  }
6599
6599
  maximumBytes;
6600
6600
  maximumSlots;
@@ -6624,25 +6624,25 @@ var ValueArena = class {
6624
6624
  if (!Number.isSafeInteger(bytes2) || bytes2 < 0 || !Number.isSafeInteger(slots) || slots < 0) throw new RangeError("Invalid shell value allocation");
6625
6625
  if (bytes2 > this.maximumBytes - this.#bytes) this.fail("maxExpansionBytes");
6626
6626
  if (slots > this.maximumSlots - this.#slots) this.fail("maxExpansionFields");
6627
- const record3 = { bytes: bytes2, slots, references: 1 };
6627
+ const record4 = { bytes: bytes2, slots, references: 1 };
6628
6628
  this.#bytes += bytes2;
6629
6629
  this.#slots += slots;
6630
- this.#records.add(record3);
6631
- return record3;
6630
+ this.#records.add(record4);
6631
+ return record4;
6632
6632
  }
6633
- commit(record3, object) {
6633
+ commit(record4, object) {
6634
6634
  this.assertOpen();
6635
- if (!this.#records.has(record3) || record3.object || this.#objects.has(object)) throw new Error("Shell value reservation is not fresh");
6636
- record3.object = object;
6637
- this.#objects.set(object, record3);
6638
- }
6639
- release(record3) {
6640
- if (!this.#records.has(record3)) return;
6641
- if (--record3.references) return;
6642
- this.#records.delete(record3);
6643
- if (record3.object) this.#objects.delete(record3.object);
6644
- this.#bytes -= record3.bytes;
6645
- this.#slots -= record3.slots;
6635
+ if (!this.#records.has(record4) || record4.object || this.#objects.has(object)) throw new Error("Shell value reservation is not fresh");
6636
+ record4.object = object;
6637
+ this.#objects.set(object, record4);
6638
+ }
6639
+ release(record4) {
6640
+ if (!this.#records.has(record4)) return;
6641
+ if (--record4.references) return;
6642
+ this.#records.delete(record4);
6643
+ if (record4.object) this.#objects.delete(record4.object);
6644
+ this.#bytes -= record4.bytes;
6645
+ this.#slots -= record4.slots;
6646
6646
  }
6647
6647
  hold(value2) {
6648
6648
  this.assertOpen();
@@ -6685,7 +6685,7 @@ var ValueArena = class {
6685
6685
  }
6686
6686
  close() {
6687
6687
  this.#closed = true;
6688
- for (const record3 of this.#records) if (record3.object) this.#objects.delete(record3.object);
6688
+ for (const record4 of this.#records) if (record4.object) this.#objects.delete(record4.object);
6689
6689
  this.#records.clear();
6690
6690
  this.#bytes = 0;
6691
6691
  this.#slots = 0;
@@ -6707,19 +6707,19 @@ var ValueScope = class {
6707
6707
  reserve(bytes2, slots) {
6708
6708
  this.assertOpen();
6709
6709
  this.#enrollment ??= this.arena.allocate(64, 1);
6710
- const record3 = this.arena.allocate(bytes2, slots);
6710
+ const record4 = this.arena.allocate(bytes2, slots);
6711
6711
  let released = false;
6712
6712
  const release = () => {
6713
6713
  if (released) return;
6714
6714
  released = true;
6715
6715
  this.#releases.delete(release);
6716
- this.arena.release(record3);
6716
+ this.arena.release(record4);
6717
6717
  };
6718
6718
  this.#releases.add(release);
6719
6719
  return { commit: (value2) => {
6720
6720
  this.assertOpen();
6721
6721
  if (released) throw new Error("Shell value reservation is released");
6722
- this.arena.commit(record3, value2);
6722
+ this.arena.commit(record4, value2);
6723
6723
  }, release };
6724
6724
  }
6725
6725
  hold(value2) {
@@ -6887,28 +6887,28 @@ function positionalTemplate(source, checkpoint) {
6887
6887
  }
6888
6888
  return found;
6889
6889
  }
6890
- function positionalValue(name2, options2) {
6890
+ function positionalValue(name2, options3) {
6891
6891
  let index = 0;
6892
6892
  let outside = false;
6893
6893
  for (let position = 0; position < name2.length; position++) {
6894
- if (position % 128 === 0) options2.checkpoint();
6894
+ if (position % 128 === 0) options3.checkpoint();
6895
6895
  const next = name2.charCodeAt(position) - 48;
6896
- if (index > Math.floor((options2.positional.length - next) / 10)) outside = true;
6896
+ if (index > Math.floor((options3.positional.length - next) / 10)) outside = true;
6897
6897
  if (!outside) index = index * 10 + next;
6898
6898
  }
6899
- return outside ? void 0 : index === 0 ? options2.arg0 : options2.positional[index - 1];
6899
+ return outside ? void 0 : index === 0 ? options3.arg0 : options3.positional[index - 1];
6900
6900
  }
6901
- function evaluatePositionalArithmetic(program, options2, evaluate) {
6901
+ function evaluatePositionalArithmetic(program, options3, evaluate) {
6902
6902
  const source = program.source;
6903
6903
  if (!source.includes("$")) return evaluate(program);
6904
- options2.checkpoint();
6905
- if (!positionalTemplate(source, options2.checkpoint)) return evaluate(program);
6906
- const header = options2.owner?.reserve({ metadata: 128, allocatedSlots: 2, work: source.length * 2 + 8 });
6904
+ options3.checkpoint();
6905
+ if (!positionalTemplate(source, options3.checkpoint)) return evaluate(program);
6906
+ const header = options3.owner?.reserve({ metadata: 128, allocatedSlots: 2, work: source.length * 2 + 8 });
6907
6907
  const admissions = [];
6908
6908
  const chunks = [];
6909
6909
  let bytes2 = 0;
6910
6910
  const reserve = (payload) => {
6911
- const admission = options2.owner?.reserve({ payload, metadata: 64, allocatedSlots: 2, work: 4 });
6911
+ const admission = options3.owner?.reserve({ payload, metadata: 64, allocatedSlots: 2, work: 4 });
6912
6912
  if (admission) admissions.push(admission);
6913
6913
  };
6914
6914
  const length = (text, start, end, maximum) => {
@@ -6916,7 +6916,7 @@ function evaluatePositionalArithmetic(program, options2, evaluate) {
6916
6916
  let nextCheckpoint = start;
6917
6917
  for (let position = start; position < end; ) {
6918
6918
  if (position >= nextCheckpoint) {
6919
- options2.checkpoint();
6919
+ options3.checkpoint();
6920
6920
  nextCheckpoint = position + 128;
6921
6921
  }
6922
6922
  const code = text.charCodeAt(position++);
@@ -6926,14 +6926,14 @@ function evaluatePositionalArithmetic(program, options2, evaluate) {
6926
6926
  size += 4;
6927
6927
  position++;
6928
6928
  } else size += 3;
6929
- if (size > maximum) options2.limit();
6929
+ if (size > maximum) options3.limit();
6930
6930
  }
6931
- options2.owner?.reserve({ work: end - start }).release();
6931
+ options3.owner?.reserve({ work: end - start }).release();
6932
6932
  return size;
6933
6933
  };
6934
6934
  const literal = (start, end) => {
6935
6935
  if (start === end) return;
6936
- const size = length(source, start, end, options2.maximumBytes - bytes2);
6936
+ const size = length(source, start, end, options3.maximumBytes - bytes2);
6937
6937
  reserve(size);
6938
6938
  chunks.push(source.slice(start, end));
6939
6939
  bytes2 += size;
@@ -6943,7 +6943,7 @@ function evaluatePositionalArithmetic(program, options2, evaluate) {
6943
6943
  let nextCheckpoint = 0;
6944
6944
  for (let position = 0; position < source.length; ) {
6945
6945
  if (position >= nextCheckpoint) {
6946
- options2.checkpoint();
6946
+ options3.checkpoint();
6947
6947
  nextCheckpoint = position + 128;
6948
6948
  }
6949
6949
  if (source[position] !== "$") {
@@ -6956,17 +6956,17 @@ function evaluatePositionalArithmetic(program, options2, evaluate) {
6956
6956
  let nameEnd = nameStart + 1;
6957
6957
  if (braced) while (digit(source, nameEnd)) {
6958
6958
  if (nameEnd >= nextCheckpoint) {
6959
- options2.checkpoint();
6959
+ options3.checkpoint();
6960
6960
  nextCheckpoint = nameEnd + 128;
6961
6961
  }
6962
6962
  nameEnd++;
6963
6963
  }
6964
6964
  reserve(nameEnd - nameStart);
6965
6965
  const name2 = source.slice(nameStart, nameEnd);
6966
- const value2 = positionalValue(name2, options2);
6967
- options2.requireParameter(name2, value2);
6966
+ const value2 = positionalValue(name2, options3);
6967
+ options3.requireParameter(name2, value2);
6968
6968
  const text = value2 ?? "";
6969
- const size = length(text, 0, text.length, options2.maximumBytes - bytes2);
6969
+ const size = length(text, 0, text.length, options3.maximumBytes - bytes2);
6970
6970
  reserve(size);
6971
6971
  chunks.push(text);
6972
6972
  bytes2 += size;
@@ -6974,10 +6974,10 @@ function evaluatePositionalArithmetic(program, options2, evaluate) {
6974
6974
  start = position;
6975
6975
  }
6976
6976
  literal(start, source.length);
6977
- options2.checkpoint();
6977
+ options3.checkpoint();
6978
6978
  reserve(bytes2);
6979
6979
  const expanded = chunks.join("");
6980
- options2.checkpoint();
6980
+ options3.checkpoint();
6981
6981
  return evaluate(prepareArithmetic(expanded));
6982
6982
  } finally {
6983
6983
  for (let position = admissions.length - 1; position >= 0; position--) admissions[position].release();
@@ -7511,7 +7511,7 @@ async function* argumentsFrom(source, signal, delimiter, replacement = false) {
7511
7511
  if (quote || escaped) throw new UsageError(quote ? "unmatched quote in input" : "trailing backslash in input");
7512
7512
  if (active) yield current;
7513
7513
  }
7514
- function executionCommands(execute2) {
7514
+ function executionCommands(execute3) {
7515
7515
  return [
7516
7516
  define("env", async (context) => {
7517
7517
  const argumentValues = getCommandArguments(context);
@@ -7562,7 +7562,7 @@ function executionCommands(execute2) {
7562
7562
  stderr: context.stderr,
7563
7563
  ...context.stdinIsDefault === void 0 ? {} : { stdinIsDefault: context.stdinIsDefault }
7564
7564
  });
7565
- return execute2({ ...context, command: parsed.operands[offset], args: childArguments.args, argumentValues: childArguments, env: childEnv, cwd });
7565
+ return execute3({ ...context, command: parsed.operands[offset], args: childArguments.args, argumentValues: childArguments, env: childEnv, cwd });
7566
7566
  }
7567
7567
  for (const name2 of names) await output(context, `${name2}=${env[name2]}${parsed.flags.has("0") ? "\0" : "\n"}`);
7568
7568
  return { exitCode: 0 };
@@ -7602,7 +7602,7 @@ function executionCommands(execute2) {
7602
7602
  const size = encoder2.encode(command2).length + 1 + childArguments.values.reduce((sum, argument) => sum + shellValueByteLength(argument) + 1, 0);
7603
7603
  if (size > maxBytes) throw new UsageError("expanded arguments exceed command size limit");
7604
7604
  if (parsed.flags.has("t")) await writeBytes(context.stderr, encoder2.encode([command2, ...args].map((argument) => /^[A-Za-z0-9_./-]+$/u.test(argument) ? argument : `'${argument.replaceAll("'", "'\\''")}'`).join(" ") + "\n"), context.signal);
7605
- const result = await execute2({ ...context, command: command2, args, argumentValues: childArguments, stdin: emptyInput(), stdinIsDefault: true, env: { ...context.env } });
7605
+ const result = await execute3({ ...context, command: command2, args, argumentValues: childArguments, stdin: emptyInput(), stdinIsDefault: true, env: { ...context.env } });
7606
7606
  executed = true;
7607
7607
  if (result.exitCode === 255) {
7608
7608
  status = 124;
@@ -7759,9 +7759,9 @@ async function validateString(value2, work, optstring = false) {
7759
7759
  else work.addBytes(3);
7760
7760
  }
7761
7761
  }
7762
- async function scanGetopts(state, optstring, args, options2) {
7763
- if (!record2(options2) || typeof options2.reportErrors !== "boolean") throw new GetoptsError("INVALID_INPUT", "Getopts requires explicit diagnostic policy and work controls");
7764
- const work = new ScanWork(options2.work);
7762
+ async function scanGetopts(state, optstring, args, options3) {
7763
+ if (!record2(options3) || typeof options3.reportErrors !== "boolean") throw new GetoptsError("INVALID_INPUT", "Getopts requires explicit diagnostic policy and work controls");
7764
+ const work = new ScanWork(options3.work);
7765
7765
  const original = cloneGetoptsState(state);
7766
7766
  if (!Array.isArray(args)) throw new GetoptsError("INVALID_INPUT", "Getopts requires an argument array");
7767
7767
  if (args.length > work.maxArguments) throw new GetoptsError("ARGUMENT_LIMIT", "Getopts argument limit exceeded");
@@ -7816,7 +7816,7 @@ async function scanGetopts(state, optstring, args, options2) {
7816
7816
  active = attached ? { argument: active.argument, offset } : void 0;
7817
7817
  if (!attached) index++;
7818
7818
  if (specification[code] === -1) {
7819
- return finish("unknown-option", "?", silent ? { kind: "set", value: option } : { kind: "unset" }, !silent && options2.reportErrors ? { kind: "unknown-option", option } : null);
7819
+ return finish("unknown-option", "?", silent ? { kind: "set", value: option } : { kind: "unset" }, !silent && options3.reportErrors ? { kind: "unknown-option", option } : null);
7820
7820
  }
7821
7821
  if (specification[code] === 1) {
7822
7822
  if (attached) {
@@ -7829,7 +7829,7 @@ async function scanGetopts(state, optstring, args, options2) {
7829
7829
  index++;
7830
7830
  return finish("option", option, { kind: "set", value: value2 }, null);
7831
7831
  }
7832
- return finish("missing-argument", silent ? ":" : "?", silent ? { kind: "set", value: option } : { kind: "unset" }, !silent && options2.reportErrors ? { kind: "missing-argument", option } : null);
7832
+ return finish("missing-argument", silent ? ":" : "?", silent ? { kind: "set", value: option } : { kind: "unset" }, !silent && options3.reportErrors ? { kind: "missing-argument", option } : null);
7833
7833
  }
7834
7834
  return finish("option", option, { kind: "unset" }, null);
7835
7835
  }
@@ -8168,17 +8168,17 @@ function throwLocalActivationFailure(state) {
8168
8168
  const failure = localActivationFailure(state);
8169
8169
  if (failure.failed) throw failure.reason;
8170
8170
  }
8171
- function prepareChildCancellation(parent, options2, snapshot, controls) {
8171
+ function prepareChildCancellation(parent, options3, snapshot, controls) {
8172
8172
  const parentState = requireLink(parent);
8173
8173
  throwAdmissionFailure(parentState);
8174
8174
  let localSignal;
8175
- if (options2 !== void 0) {
8176
- if (options2 === null || typeof options2 !== "object" && typeof options2 !== "function") {
8175
+ if (options3 !== void 0) {
8176
+ if (options3 === null || typeof options3 !== "object" && typeof options3 !== "function") {
8177
8177
  return stagedFailure(parentState, new TypeError("Cancellation options must be an object or function"));
8178
8178
  }
8179
8179
  let candidate;
8180
8180
  try {
8181
- candidate = options2.signal;
8181
+ candidate = options3.signal;
8182
8182
  } catch (error) {
8183
8183
  return stagedFailure(parentState, error);
8184
8184
  }
@@ -9143,10 +9143,10 @@ var StateMonitor = class {
9143
9143
  monitor.finish(tickets, name2);
9144
9144
  return result;
9145
9145
  },
9146
- defineProperty(target, key, descriptor) {
9146
+ defineProperty(target, key, descriptor2) {
9147
9147
  const name2 = named ? String(key) : void 0;
9148
9148
  const tickets = monitor.mutation(name2);
9149
- const result = Reflect.defineProperty(target, key, descriptor);
9149
+ const result = Reflect.defineProperty(target, key, descriptor2);
9150
9150
  if (result) monitor.changedValue(target, field, key);
9151
9151
  monitor.finish(tickets, name2);
9152
9152
  return result;
@@ -10172,7 +10172,7 @@ var typedSavedVariables = /* @__PURE__ */ new WeakMap();
10172
10172
  var valueScope = /* @__PURE__ */ Symbol("shell value allocation scope");
10173
10173
  var invokedValues = /* @__PURE__ */ new WeakMap();
10174
10174
  function isolateIO(io) {
10175
- return { ...io, ...io.descriptors ? { descriptors: new Map([...io.descriptors].map(([number, descriptor]) => [number, { ...descriptor }])) } : {} };
10175
+ return { ...io, ...io.descriptors ? { descriptors: new Map([...io.descriptors].map(([number, descriptor2]) => [number, { ...descriptor2 }])) } : {} };
10176
10176
  }
10177
10177
  function activeIO(io) {
10178
10178
  const input3 = io.descriptors?.get(0);
@@ -10650,11 +10650,11 @@ var DirectoryStackWork = class {
10650
10650
  await writeText(this.stdout, text);
10651
10651
  this.signal.throwIfAborted();
10652
10652
  }
10653
- async display(cwd, entries, options2, home) {
10653
+ async display(cwd, entries, options3, home) {
10654
10654
  await this.scan(cwd, "path");
10655
- const homeBytes = !options2.long && home !== void 0 ? await this.scan(home, "HOME") : 0;
10656
- const start = options2.index ?? 0;
10657
- const end = options2.index ?? entries.length;
10655
+ const homeBytes = !options3.long && home !== void 0 ? await this.scan(home, "HOME") : 0;
10656
+ const start = options3.index ?? 0;
10657
+ const end = options3.index ?? entries.length;
10658
10658
  for (let index = start; index <= end; index++) {
10659
10659
  await this.charge(1);
10660
10660
  let entry = index === 0 ? cwd : entries[index - 1];
@@ -10672,12 +10672,12 @@ var DirectoryStackWork = class {
10672
10672
  if (entry.length === home.length || entry[home.length] === "/") entry = `~${entry.slice(home.length)}`;
10673
10673
  }
10674
10674
  }
10675
- if (index !== start && !options2.lines && !options2.verbose) await this.emit(" ");
10676
- if (options2.verbose) await this.emit(`${String(index).padStart(2, " ")} `);
10675
+ if (index !== start && !options3.lines && !options3.verbose) await this.emit(" ");
10676
+ if (options3.verbose) await this.emit(`${String(index).padStart(2, " ")} `);
10677
10677
  await this.emit(entry);
10678
- if (options2.lines || options2.verbose) await this.emit("\n");
10678
+ if (options3.lines || options3.verbose) await this.emit("\n");
10679
10679
  }
10680
- if (!options2.lines && !options2.verbose) await this.emit("\n");
10680
+ if (!options3.lines && !options3.verbose) await this.emit("\n");
10681
10681
  await this.flushOutput();
10682
10682
  }
10683
10683
  };
@@ -10735,34 +10735,34 @@ var RuntimeCancellationState = class {
10735
10735
  }
10736
10736
  bind(promise, boundary) {
10737
10737
  if (this.#closed) throw new Error("Cancellation outcome admission is closed");
10738
- const record3 = { promise, boundary, finalized: false, consumed: false };
10739
- this.#records.add(record3);
10740
- return record3;
10738
+ const record4 = { promise, boundary, finalized: false, consumed: false };
10739
+ this.#records.add(record4);
10740
+ return record4;
10741
10741
  }
10742
- finalize(record3, selection) {
10743
- if (record3.consumed || !this.#records.has(record3)) return;
10744
- record3.selection = selection;
10745
- record3.finalized = true;
10742
+ finalize(record4, selection) {
10743
+ if (record4.consumed || !this.#records.has(record4)) return;
10744
+ record4.selection = selection;
10745
+ record4.finalized = true;
10746
10746
  }
10747
10747
  consume(rawReturn, capturedReason) {
10748
- for (const record3 of this.#records) {
10749
- if (record3.promise !== rawReturn) continue;
10750
- record3.consumed = true;
10751
- this.#records.delete(record3);
10752
- const selection = record3.selection;
10753
- if (!record3.finalized || selection?.outcome.kind !== "throw" || !Object.is(selection.outcome.reason, capturedReason)) return void 0;
10748
+ for (const record4 of this.#records) {
10749
+ if (record4.promise !== rawReturn) continue;
10750
+ record4.consumed = true;
10751
+ this.#records.delete(record4);
10752
+ const selection = record4.selection;
10753
+ if (!record4.finalized || selection?.outcome.kind !== "throw" || !Object.is(selection.outcome.reason, capturedReason)) return void 0;
10754
10754
  return selection.report;
10755
10755
  }
10756
10756
  return void 0;
10757
10757
  }
10758
- discard(record3) {
10759
- if (!record3) return;
10760
- record3.consumed = true;
10761
- this.#records.delete(record3);
10758
+ discard(record4) {
10759
+ if (!record4) return;
10760
+ record4.consumed = true;
10761
+ this.#records.delete(record4);
10762
10762
  }
10763
10763
  close() {
10764
10764
  this.#closed = true;
10765
- for (const record3 of this.#records) record3.consumed = true;
10765
+ for (const record4 of this.#records) record4.consumed = true;
10766
10766
  this.#records.clear();
10767
10767
  this.#diagnostics = /* @__PURE__ */ new WeakMap();
10768
10768
  }
@@ -10816,7 +10816,7 @@ var InvocationCancellationOwner = class {
10816
10816
  throw error;
10817
10817
  }
10818
10818
  }
10819
- capture(execute2, frame) {
10819
+ capture(execute3, frame) {
10820
10820
  return new Promise((resolve) => {
10821
10821
  let settled = false;
10822
10822
  let raw;
@@ -10838,7 +10838,7 @@ var InvocationCancellationOwner = class {
10838
10838
  });
10839
10839
  };
10840
10840
  try {
10841
- raw = Promise.resolve(execute2());
10841
+ raw = Promise.resolve(execute3());
10842
10842
  } catch (reason) {
10843
10843
  settle({ kind: "throw", reason });
10844
10844
  return;
@@ -11076,13 +11076,13 @@ var Runtime = class _Runtime {
11076
11076
  }
11077
11077
  );
11078
11078
  }
11079
- invokeChild(options2, state, parent, validate, execute2) {
11079
+ invokeChild(options3, state, parent, validate, execute3) {
11080
11080
  const publicPromise = Promise.resolve().then(async () => {
11081
11081
  if (!this.cancellation.deliverySignal.aborted) parent.assertOpen();
11082
11082
  const childDepth = this.cancellationDepth + 1;
11083
11083
  const prepared = prepareChildCancellation(
11084
11084
  this.cancellation,
11085
- options2,
11085
+ options3,
11086
11086
  this.cancellationAdmission(childDepth)
11087
11087
  );
11088
11088
  this.cancellationOwner?.assertAdmissionOpen();
@@ -11122,7 +11122,7 @@ var Runtime = class _Runtime {
11122
11122
  frame
11123
11123
  );
11124
11124
  let captured;
11125
- const executeChild = () => execute2(runtime, scope);
11125
+ const executeChild = () => execute3(runtime, scope);
11126
11126
  if (owner) captured = await owner.capture(executeChild, frame);
11127
11127
  else {
11128
11128
  try {
@@ -11271,8 +11271,8 @@ var Runtime = class _Runtime {
11271
11271
  if (!typedSavedVariables.has(saved)) await this.prepareVariable(state, name2, saved);
11272
11272
  await owner.ledger.checkpoint(this.signal);
11273
11273
  }
11274
- for (const frame of stateMonitor(state).overlayFrames()) for (const [name2, record3] of frame) {
11275
- const saved = record3;
11274
+ for (const frame of stateMonitor(state).overlayFrames()) for (const [name2, record4] of frame) {
11275
+ const saved = record4;
11276
11276
  if (!saved.superseded && !typedSavedVariables.has(saved)) await this.prepareVariable(state, name2, saved, true);
11277
11277
  await owner.ledger.checkpoint(this.signal);
11278
11278
  }
@@ -11801,7 +11801,7 @@ var Runtime = class _Runtime {
11801
11801
  let io = originalIO;
11802
11802
  let diagnosticFailure;
11803
11803
  try {
11804
- const execute2 = async () => {
11804
+ const execute3 = async () => {
11805
11805
  if (command2.kind === "function") {
11806
11806
  if (state.profile === "sh" && specialBuiltinNames.has(command2.name)) {
11807
11807
  await this.diagnostic(io, `\`${command2.name}': is a special builtin`);
@@ -11954,7 +11954,7 @@ var Runtime = class _Runtime {
11954
11954
  }
11955
11955
  return status2;
11956
11956
  };
11957
- const status = await execute2();
11957
+ const status = await execute3();
11958
11958
  await finishOutputs(status);
11959
11959
  return status;
11960
11960
  } catch (caught) {
@@ -12068,8 +12068,8 @@ var Runtime = class _Runtime {
12068
12068
  if (io.stdout === closedSink) descriptors.delete(1);
12069
12069
  if (io.stderr === closedSink) descriptors.delete(2);
12070
12070
  const currentIO = () => {
12071
- const descriptor = descriptors.get(0)?.closed ? void 0 : descriptors.get(0);
12072
- const stdinIsDefault = descriptor?.input ? descriptor.stdinIsDefault : false;
12071
+ const descriptor2 = descriptors.get(0)?.closed ? void 0 : descriptors.get(0);
12072
+ const stdinIsDefault = descriptor2?.input ? descriptor2.stdinIsDefault : false;
12073
12073
  return {
12074
12074
  [invocationScope]: io[invocationScope],
12075
12075
  ...io.execution === void 0 ? {} : { execution: io.execution },
@@ -12078,7 +12078,7 @@ var Runtime = class _Runtime {
12078
12078
  ...io.scriptName === void 0 ? {} : { scriptName: io.scriptName },
12079
12079
  ...io.substitutionDiagnosticLine === void 0 ? {} : { substitutionDiagnosticLine: io.substitutionDiagnosticLine },
12080
12080
  ...io.substitutionDiagnosticLines === void 0 ? {} : { substitutionDiagnosticLines: io.substitutionDiagnosticLines },
12081
- stdin: descriptor?.input ?? closedSource,
12081
+ stdin: descriptor2?.input ?? closedSource,
12082
12082
  ...stdinIsDefault === void 0 ? {} : { stdinIsDefault },
12083
12083
  stdout: descriptors.get(1)?.closed ? closedSink : descriptors.get(1)?.output ?? closedSink,
12084
12084
  stderr: descriptors.get(2)?.closed ? closedSink : descriptors.get(2)?.output ?? closedSink,
@@ -12120,20 +12120,20 @@ var Runtime = class _Runtime {
12120
12120
  const move = target.endsWith("-");
12121
12121
  if (move && !redirect.move) throw new Error(`${target}: ambiguous redirect`);
12122
12122
  const sourceDescriptor = Number(move ? target.slice(0, -1) : target);
12123
- const descriptor = descriptors.get(sourceDescriptor);
12124
- if (!descriptor || descriptor.closed || !move && (redirect.operator === "<&" ? !descriptor.input : !descriptor.output)) throw new Error(`${move ? sourceDescriptor : target}: Bad file descriptor`);
12125
- descriptors.set(redirect.descriptor, { ...descriptor });
12123
+ const descriptor2 = descriptors.get(sourceDescriptor);
12124
+ if (!descriptor2 || descriptor2.closed || !move && (redirect.operator === "<&" ? !descriptor2.input : !descriptor2.output)) throw new Error(`${move ? sourceDescriptor : target}: Bad file descriptor`);
12125
+ descriptors.set(redirect.descriptor, { ...descriptor2 });
12126
12126
  if (move && sourceDescriptor !== redirect.descriptor) {
12127
12127
  descriptors.delete(sourceDescriptor);
12128
- if (persistMoves && !replaced.has(sourceDescriptor)) descriptor.closed = true;
12128
+ if (persistMoves && !replaced.has(sourceDescriptor)) descriptor2.closed = true;
12129
12129
  }
12130
12130
  }
12131
12131
  } else {
12132
12132
  const path = resolvePath(state.cwd, target);
12133
- const options2 = { signal: this.signal };
12133
+ const options3 = { signal: this.signal };
12134
12134
  if (redirect.operator === "<") {
12135
- await interruptible(this.fs.access(path, 4, options2), this.signal);
12136
- const stat = await interruptible(this.fs.stat(path, options2), this.signal);
12135
+ await interruptible(this.fs.access(path, 4, options3), this.signal);
12136
+ const stat = await interruptible(this.fs.stat(path, options3), this.signal);
12137
12137
  if (stat.type === "directory" && !fileShortcut) throw new Error(`${target}: Is a directory`);
12138
12138
  const source = stat.type === "directory" ? toByteSource("") : await fileInput(this.fs, path, this.budget.limits.maxInputBytes, this.signal);
12139
12139
  const input3 = new ShellInput(source, this.budget, this.signal);
@@ -12141,7 +12141,7 @@ var Runtime = class _Runtime {
12141
12141
  descriptors.set(redirect.descriptor, { input: input3, stdinIsDefault: false });
12142
12142
  } else {
12143
12143
  const append = redirect.operator === ">>";
12144
- const capabilities = await this.fs.capabilitiesFor?.(path, options2) ?? this.fs.capabilities;
12144
+ const capabilities = await this.fs.capabilitiesFor?.(path, options3) ?? this.fs.capabilities;
12145
12145
  const random = capabilities.randomAccessWrite === true;
12146
12146
  let file;
12147
12147
  await this.fileOperation(path, async () => {
@@ -12154,8 +12154,8 @@ var Runtime = class _Runtime {
12154
12154
  let offset = 0;
12155
12155
  const incremental = async () => {
12156
12156
  await this.fileOperation(path, async () => {
12157
- if (append) await this.fs.appendFile(path, new Uint8Array(), options2);
12158
- else await this.fs.writeFile(path, new Uint8Array(), { ...options2, flag: "w" });
12157
+ if (append) await this.fs.appendFile(path, new Uint8Array(), options3);
12158
+ else await this.fs.writeFile(path, new Uint8Array(), { ...options3, flag: "w" });
12159
12159
  if (!append) file.data = new Uint8Array();
12160
12160
  });
12161
12161
  return { write: (chunk) => {
@@ -12166,7 +12166,7 @@ var Runtime = class _Runtime {
12166
12166
  let atEOF = false;
12167
12167
  if (!append && current && offset === current.length && capabilities.append === true && capabilities.stat !== false) {
12168
12168
  try {
12169
- atEOF = (await interruptible(this.fs.stat(path, options2), this.signal)).size === offset;
12169
+ atEOF = (await interruptible(this.fs.stat(path, options3), this.signal)).size === offset;
12170
12170
  } catch {
12171
12171
  this.signal.throwIfAborted();
12172
12172
  }
@@ -12174,13 +12174,13 @@ var Runtime = class _Runtime {
12174
12174
  }
12175
12175
  if (append || atEOF) {
12176
12176
  const bytes2 = current ? appendOutputBytes(current, copy2) : void 0;
12177
- await this.fs.appendFile(path, copy2, options2);
12177
+ await this.fs.appendFile(path, copy2, options3);
12178
12178
  file.data = bytes2;
12179
12179
  } else {
12180
12180
  const bytes2 = new Uint8Array(Math.max(current?.length ?? 0, offset + copy2.length));
12181
12181
  if (current) bytes2.set(current);
12182
12182
  bytes2.set(copy2, offset);
12183
- await this.fs.writeFile(path, bytes2, options2);
12183
+ await this.fs.writeFile(path, bytes2, options3);
12184
12184
  file.data = bytes2;
12185
12185
  }
12186
12186
  if (!append) offset += copy2.length;
@@ -12449,8 +12449,8 @@ var Runtime = class _Runtime {
12449
12449
  fs: this.fs,
12450
12450
  signal: this.commandSignal,
12451
12451
  registerCleanup: (cleanup) => scope.register(cleanup),
12452
- invoke: (name3, args, options2) => {
12453
- const invocation = this.invoke(name3, args, options2, context, state, scope);
12452
+ invoke: (name3, args, options3) => {
12453
+ const invocation = this.invoke(name3, args, options3, context, state, scope);
12454
12454
  void invocation.catch(() => void 0);
12455
12455
  return invocation;
12456
12456
  }
@@ -12466,7 +12466,7 @@ var Runtime = class _Runtime {
12466
12466
  });
12467
12467
  return this.observeRuntimeReturn(raw, runtimeFrame, () => downstream);
12468
12468
  });
12469
- const execute2 = composeMiddleware(middleware, (forwarded) => scope.run(async () => {
12469
+ const execute3 = composeMiddleware(middleware, (forwarded) => scope.run(async () => {
12470
12470
  scope.assertOpen();
12471
12471
  const forwardedValues = getCommandArguments(forwarded);
12472
12472
  const admitted = forwardedValues === argumentValues ? argumentValues : this.admitArguments(forwardedValues.values, allocation);
@@ -12679,7 +12679,7 @@ var Runtime = class _Runtime {
12679
12679
  }
12680
12680
  }));
12681
12681
  try {
12682
- return validateExitCode((await interruptible(execute2(context), this.signal)).exitCode);
12682
+ return validateExitCode((await interruptible(execute3(context), this.signal)).exitCode);
12683
12683
  } catch (error) {
12684
12684
  if (builtinFailure && error === builtinFailure.error) throw new ExecutionFailure(error, io, builtinFailure.diagnostic);
12685
12685
  if (runtimeFrame.report && Object.is(runtimeFrame.report.origin.signal.reason, error) && this.outcomeFrame) {
@@ -12813,10 +12813,10 @@ ${functionDisplay(name2, state.functions.get(name2))}`;
12813
12813
  const target = component === void 0 ? name2 : `${component || "."}${component?.endsWith("/") ? "" : "/"}${name2}`;
12814
12814
  const resolved = resolvePath(state.cwd, target);
12815
12815
  try {
12816
- const options2 = { signal: this.signal };
12817
- if ((await interruptible(this.fs.stat(resolved, options2), this.signal)).type !== "file") continue;
12816
+ const options3 = { signal: this.signal };
12817
+ if ((await interruptible(this.fs.stat(resolved, options3), this.signal)).type !== "file") continue;
12818
12818
  if (this.fs.capabilities.permissions !== true) throw new CommandFailure(`${target}: execution permissions are not supported by this filesystem`, 126);
12819
- await interruptible(this.fs.access(resolved, ACCESS_MODES.X_OK, options2), this.signal);
12819
+ await interruptible(this.fs.access(resolved, ACCESS_MODES.X_OK, options3), this.signal);
12820
12820
  matches.push(target);
12821
12821
  if (!all) return matches;
12822
12822
  } catch (error) {
@@ -13040,8 +13040,8 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13040
13040
  stderr: this.budget.sink(incoming.stderr, runtime.signal),
13041
13041
  signal: this.commandSignal,
13042
13042
  registerCleanup: (cleanup) => scope.register(cleanup),
13043
- invoke: (name2, args, options2) => {
13044
- const invocation = invocationOverride.current ? invocationOverride.current(name2, args, options2) : runtime.invoke(name2, args, options2, context, child, scope);
13043
+ invoke: (name2, args, options3) => {
13044
+ const invocation = invocationOverride.current ? invocationOverride.current(name2, args, options3) : runtime.invoke(name2, args, options3, context, child, scope);
13045
13045
  void invocation.catch(() => void 0);
13046
13046
  return invocation;
13047
13047
  }
@@ -13061,7 +13061,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13061
13061
  });
13062
13062
  return runtime.observeRuntimeReturn(raw, runtimeFrame, () => downstream);
13063
13063
  });
13064
- const execute2 = composeMiddleware(middleware, async () => {
13064
+ const execute3 = composeMiddleware(middleware, async () => {
13065
13065
  scope.assertOpen();
13066
13066
  const forwardedValues = getCommandArguments(context);
13067
13067
  const admitted = forwardedValues === argumentValues ? argumentValues : runtime.admitArguments(forwardedValues.values, allocation);
@@ -13072,7 +13072,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13072
13072
  return await runtime.observeRuntimeReturn(raw, runtimeFrame);
13073
13073
  });
13074
13074
  try {
13075
- const result = await interruptible(execute2(context), runtime.signal);
13075
+ const result = await interruptible(execute3(context), runtime.signal);
13076
13076
  runtime.signal.throwIfAborted();
13077
13077
  return validateExitCode(result.exitCode);
13078
13078
  } catch (error) {
@@ -13085,8 +13085,8 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13085
13085
  if (ownsScope) await scope.close();
13086
13086
  }
13087
13087
  }
13088
- shebangTarget(context, state, io, command2, args, options2, target, loadedSource) {
13089
- return this.invokeChild(options2, state, io[invocationScope], () => {
13088
+ shebangTarget(context, state, io, command2, args, options3, target, loadedSource) {
13089
+ return this.invokeChild(options3, state, io[invocationScope], () => {
13090
13090
  this.signal.throwIfAborted();
13091
13091
  io[invocationScope].assertOpen();
13092
13092
  if (typeof command2 !== "string" || command2.includes("\0") || !Array.isArray(args) || args.some((argument) => typeof argument !== "string" || argument.includes("\0"))) {
@@ -13097,14 +13097,14 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13097
13097
  for (const argument of [command2, ...args]) {
13098
13098
  if (import_buffer.Buffer.byteLength(argument) > this.budget.limits.maxExpansionBytes) this.budget.fail("maxExpansionBytes");
13099
13099
  }
13100
- }, (runtime, scope) => runtime.shebangTargetScoped(context, state, io, command2, args, options2, target, loadedSource, scope));
13100
+ }, (runtime, scope) => runtime.shebangTargetScoped(context, state, io, command2, args, options3, target, loadedSource, scope));
13101
13101
  }
13102
- async shebangTargetScoped(context, state, io, command2, args, options2, target, loadedSource, scope) {
13102
+ async shebangTargetScoped(context, state, io, command2, args, options3, target, loadedSource, scope) {
13103
13103
  const reserved = command2 === "bash" || command2 === "sh";
13104
13104
  const direct = command2.includes("/");
13105
13105
  const definition = this.commands.get(command2);
13106
13106
  const child = await this.shebangState(context, state);
13107
- child.cwd = resolvePath(context.cwd, options2.cwd ?? ".");
13107
+ child.cwd = resolvePath(context.cwd, options3.cwd ?? ".");
13108
13108
  if (!reserved) {
13109
13109
  if (child.depth >= this.budget.limits.maxSubstitutionDepth) this.budget.fail("maxSubstitutionDepth");
13110
13110
  child.depth++;
@@ -13113,18 +13113,18 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13113
13113
  child.sourceDepth = 0;
13114
13114
  child.locals = [];
13115
13115
  }
13116
- const stdinIsDefault = options2.stdin === void 0 ? context.stdinIsDefault : options2.stdinIsDefault ?? false;
13117
- const argumentValues = getCommandArguments({ args, ...options2.argumentValues ? { argumentValues: options2.argumentValues } : {} });
13116
+ const stdinIsDefault = options3.stdin === void 0 ? context.stdinIsDefault : options3.stdinIsDefault ?? false;
13117
+ const argumentValues = getCommandArguments({ args, ...options3.argumentValues ? { argumentValues: options3.argumentValues } : {} });
13118
13118
  const selected = {
13119
13119
  ...context,
13120
13120
  command: command2,
13121
13121
  args: argumentValues.args,
13122
13122
  argumentValues,
13123
13123
  cwd: child.cwd,
13124
- env: options2.replaceEnv ? { ...options2.env } : { ...context.env, ...options2.env, PWD: child.cwd },
13125
- stdin: options2.stdin ?? context.stdin,
13126
- stdout: options2.stdout ?? context.stdout,
13127
- stderr: options2.stderr ?? context.stderr,
13124
+ env: options3.replaceEnv ? { ...options3.env } : { ...context.env, ...options3.env, PWD: child.cwd },
13125
+ stdin: options3.stdin ?? context.stdin,
13126
+ stdout: options3.stdout ?? context.stdout,
13127
+ stderr: options3.stderr ?? context.stderr,
13128
13128
  ...stdinIsDefault === void 0 ? {} : { stdinIsDefault }
13129
13129
  };
13130
13130
  const exitCode = await this.shebangStage(selected, child, io, async (runtime, forwarded, state2, childIO) => {
@@ -13140,7 +13140,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13140
13140
  await writeText(forwarded.stderr, `env: ${command2}: command not found
13141
13141
  `);
13142
13142
  return { exitCode: 127 };
13143
- }, void 0, options2.stdin !== context.stdin ? options2.stdin : void 0, scope);
13143
+ }, void 0, options3.stdin !== context.stdin ? options3.stdin : void 0, scope);
13144
13144
  return { exitCode };
13145
13145
  }
13146
13146
  async envShebang(context, state, io, optionalArgument, target, args, loadedSource) {
@@ -13161,8 +13161,8 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13161
13161
  let failureReport;
13162
13162
  const result = await interruptible(Promise.resolve(definition.execute({
13163
13163
  ...forwarded,
13164
- invoke: (command2, arguments_, options2) => {
13165
- const raw = forwarded.invoke(command2, arguments_, options2);
13164
+ invoke: (command2, arguments_, options3) => {
13165
+ const raw = forwarded.invoke(command2, arguments_, options3);
13166
13166
  return raw.catch((error) => {
13167
13167
  failed = true;
13168
13168
  failure = error;
@@ -13177,7 +13177,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13177
13177
  throw failure;
13178
13178
  }
13179
13179
  return { exitCode: validateExitCode(result.exitCode) };
13180
- }, (runtime, forwarded, child, childIO) => (command2, arguments_, options2 = {}) => runtime.shebangTarget(forwarded, child, childIO, command2, arguments_, options2, target, loadedSource));
13180
+ }, (runtime, forwarded, child, childIO) => (command2, arguments_, options3 = {}) => runtime.shebangTarget(forwarded, child, childIO, command2, arguments_, options3, target, loadedSource));
13181
13181
  }
13182
13182
  async scriptFile(context, state, io, target, args, direct, errexit = false, loadedSource) {
13183
13183
  if (target === "") throw new CommandFailure(`${context.command}: : No such file or directory`, 127);
@@ -13189,14 +13189,14 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13189
13189
  try {
13190
13190
  if (loadedSource?.path === path) source = loadedSource.source;
13191
13191
  else {
13192
- const options2 = { signal: this.signal };
13193
- const stat = await interruptible(this.fs.stat(path, options2), this.signal);
13192
+ const options3 = { signal: this.signal };
13193
+ const stat = await interruptible(this.fs.stat(path, options3), this.signal);
13194
13194
  if (stat.type !== "file") throw new CommandFailure(`${target}: ${stat.type === "directory" ? "Is a directory" : "not a regular file"}`, 126);
13195
13195
  if (direct && this.fs.capabilities.permissions !== true) throw new CommandFailure(`${target}: execution permissions are not supported by this filesystem`, 126);
13196
- await interruptible(this.fs.access(path, ACCESS_MODES.R_OK | (direct ? ACCESS_MODES.X_OK : 0), options2), this.signal);
13196
+ await interruptible(this.fs.access(path, ACCESS_MODES.R_OK | (direct ? ACCESS_MODES.X_OK : 0), options3), this.signal);
13197
13197
  const maxBytes = this.budget.limits.maxSourceBytes - this.budget.sourceBytes;
13198
13198
  if (stat.size > maxBytes) this.budget.fail("maxSourceBytes");
13199
- const bytes2 = await interruptible(this.fs.readFile(path, { ...options2, maxBytes }), this.signal);
13199
+ const bytes2 = await interruptible(this.fs.readFile(path, { ...options3, maxBytes }), this.signal);
13200
13200
  this.budget.source(bytes2.byteLength);
13201
13201
  source = this.sourceText(bytes2, target);
13202
13202
  }
@@ -13323,7 +13323,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13323
13323
  let target = filename;
13324
13324
  let source;
13325
13325
  try {
13326
- const options2 = { signal: this.signal };
13326
+ const options3 = { signal: this.signal };
13327
13327
  if (filename && !filename.includes("/") && state.variables.PATH) {
13328
13328
  if (import_buffer.Buffer.byteLength(state.variables.PATH) > this.budget.limits.maxExpansionBytes) this.budget.fail("maxExpansionBytes");
13329
13329
  const components = state.variables.PATH.split(":");
@@ -13334,8 +13334,8 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13334
13334
  const candidate = `${component || "."}${component.endsWith("/") ? "" : "/"}${filename}`;
13335
13335
  const path2 = resolvePath(state.cwd, candidate);
13336
13336
  try {
13337
- if ((await interruptible(this.fs.stat(path2, options2), this.signal)).type !== "file") continue;
13338
- await interruptible(this.fs.access(path2, ACCESS_MODES.R_OK, options2), this.signal);
13337
+ if ((await interruptible(this.fs.stat(path2, options3), this.signal)).type !== "file") continue;
13338
+ await interruptible(this.fs.access(path2, ACCESS_MODES.R_OK, options3), this.signal);
13339
13339
  target = candidate;
13340
13340
  found = true;
13341
13341
  break;
@@ -13348,13 +13348,13 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13348
13348
  }
13349
13349
  if (!filename) throw new CommandFailure(": No such file or directory", 1);
13350
13350
  const path = resolvePath(state.cwd, target);
13351
- const stat = await interruptible(this.fs.stat(path, options2), this.signal);
13351
+ const stat = await interruptible(this.fs.stat(path, options3), this.signal);
13352
13352
  if (stat.type === "directory") throw new CommandFailure(`${context.command}: ${target}: is a directory`, 1);
13353
13353
  if (stat.type !== "file") throw new CommandFailure(`${target}: not a regular file`, 1);
13354
- await interruptible(this.fs.access(path, ACCESS_MODES.R_OK, options2), this.signal);
13354
+ await interruptible(this.fs.access(path, ACCESS_MODES.R_OK, options3), this.signal);
13355
13355
  const maxBytes = this.budget.limits.maxSourceBytes - this.budget.sourceBytes;
13356
13356
  if (stat.size > maxBytes) this.budget.fail("maxSourceBytes");
13357
- const bytes2 = await interruptible(this.fs.readFile(path, { ...options2, maxBytes }), this.signal);
13357
+ const bytes2 = await interruptible(this.fs.readFile(path, { ...options3, maxBytes }), this.signal);
13358
13358
  this.budget.source(bytes2.byteLength);
13359
13359
  source = this.sourceText(bytes2, target);
13360
13360
  } catch (error) {
@@ -13419,22 +13419,22 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13419
13419
  }
13420
13420
  }
13421
13421
  }
13422
- invoke(name2, args, options2 = {}, context, state, parent) {
13423
- return this.invokeChild(options2, state, parent, () => {
13422
+ invoke(name2, args, options3 = {}, context, state, parent) {
13423
+ return this.invokeChild(options3, state, parent, () => {
13424
13424
  if (typeof name2 !== "string" || name2.includes("\0") || !Array.isArray(args) || args.some((arg) => typeof arg !== "string" || arg.includes("\0"))) {
13425
13425
  throw new TypeError("invoke requires a command and literal string arguments without NUL");
13426
13426
  }
13427
13427
  if (state.depth >= this.budget.limits.maxSubstitutionDepth) this.budget.fail("maxSubstitutionDepth");
13428
- }, (runtime, scope) => runtime.invokeScoped(name2, args, options2, context, state, scope));
13428
+ }, (runtime, scope) => runtime.invokeScoped(name2, args, options3, context, state, scope));
13429
13429
  }
13430
- async invokeScoped(name2, args, options2, context, state, scope) {
13430
+ async invokeScoped(name2, args, options3, context, state, scope) {
13431
13431
  this.signal.throwIfAborted();
13432
13432
  const allocation = this.budget.values.scope();
13433
13433
  scope.register(() => allocation.close());
13434
- const carrier = this.admitArguments(getCommandArguments({ args, ...options2.argumentValues ? { argumentValues: options2.argumentValues } : {} }).values, allocation);
13434
+ const carrier = this.admitArguments(getCommandArguments({ args, ...options3.argumentValues ? { argumentValues: options3.argumentValues } : {} }).values, allocation);
13435
13435
  const child = await cloneState(state, this.signal);
13436
- child.cwd = resolvePath(context.cwd, options2.cwd ?? ".");
13437
- const env = options2.replaceEnv ? { ...options2.env } : { ...context.env, ...options2.env, PWD: child.cwd };
13436
+ child.cwd = resolvePath(context.cwd, options3.cwd ?? ".");
13437
+ const env = options3.replaceEnv ? { ...options3.env } : { ...context.env, ...options3.env, PWD: child.cwd };
13438
13438
  if (guestArrays(child) || Object.keys(env).some((key) => arrayStore(child)?.get(key))) await this.indexedEnvironment(child, env);
13439
13439
  else {
13440
13440
  for (const key of child.exported) delete child.variables[key];
@@ -13450,15 +13450,15 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13450
13450
  child.functionDepth = 0;
13451
13451
  child.sourceDepth = 0;
13452
13452
  child.locals = [];
13453
- const input3 = options2.stdin === void 0 ? void 0 : new ShellInput(options2.stdin, this.budget, this.signal);
13454
- const stdinIsDefault = options2.stdin === void 0 ? context.stdinIsDefault : options2.stdinIsDefault ?? false;
13453
+ const input3 = options3.stdin === void 0 ? void 0 : new ShellInput(options3.stdin, this.budget, this.signal);
13454
+ const stdinIsDefault = options3.stdin === void 0 ? context.stdinIsDefault : options3.stdinIsDefault ?? false;
13455
13455
  const io = {
13456
13456
  ...context,
13457
13457
  [invocationScope]: scope,
13458
13458
  stdin: input3 ?? context.stdin,
13459
13459
  ...stdinIsDefault === void 0 ? {} : { stdinIsDefault },
13460
- stdout: options2.stdout ? this.budget.sink(options2.stdout, this.signal) : context.stdout,
13461
- stderr: options2.stderr ? this.budget.sink(options2.stderr, this.signal) : context.stderr
13460
+ stdout: options3.stdout ? this.budget.sink(options3.stdout, this.signal) : context.stdout,
13461
+ stderr: options3.stderr ? this.budget.sink(options3.stderr, this.signal) : context.stderr
13462
13462
  };
13463
13463
  const command2 = {
13464
13464
  kind: "simple",
@@ -13506,8 +13506,8 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13506
13506
  else if (flag === "o" && position === option.length - 1) {
13507
13507
  const name2 = args[index + 1];
13508
13508
  if (name2 === void 0) {
13509
- const options2 = [["errexit", !!state.errexit], ["nounset", !!state.nounset], ["pipefail", state.pipefail]];
13510
- for (const [name3, active] of options2) await writeText(stdout, enabled ? `${name3} ${active ? "on" : "off"}
13509
+ const options3 = [["errexit", !!state.errexit], ["nounset", !!state.nounset], ["pipefail", state.pipefail]];
13510
+ for (const [name3, active] of options3) await writeText(stdout, enabled ? `${name3} ${active ? "on" : "off"}
13511
13511
  ` : `set ${active ? "-" : "+"}o ${name3}
13512
13512
  `);
13513
13513
  } else {
@@ -13538,7 +13538,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13538
13538
  async letBuiltin(context, state) {
13539
13539
  this.signal.throwIfAborted();
13540
13540
  const { maxExpansionBytes: bytes2, maxExpansionFields: fields } = this.budget.limits;
13541
- const admit = (value3) => {
13541
+ const admit2 = (value3) => {
13542
13542
  if (typeof value3 !== "string" || value3.includes("\0")) throw new CommandFailure("let: arguments must be strings without NUL", 2);
13543
13543
  if (value3.length > bytes2 || import_buffer.Buffer.byteLength(value3) > bytes2) this.budget.fail("maxExpansionBytes");
13544
13544
  };
@@ -13550,10 +13550,10 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13550
13550
  const { args } = context;
13551
13551
  if (!Array.isArray(args)) throw new CommandFailure("let: argument array required", 2);
13552
13552
  if (args.length + 1 > fields) this.budget.fail("maxExpansionFields");
13553
- admit(context.command);
13553
+ admit2(context.command);
13554
13554
  for (let index = 0; index < args.length; index++) {
13555
13555
  this.signal.throwIfAborted();
13556
- admit(args[index]);
13556
+ admit2(args[index]);
13557
13557
  if ((index + 1) % 128 === 0) await checkpoint();
13558
13558
  }
13559
13559
  if (args[0] === "--help") throw new CommandFailure("let: --help: unsupported option", 2);
@@ -13582,7 +13582,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13582
13582
  async getoptsBuiltin(context, state) {
13583
13583
  this.signal.throwIfAborted();
13584
13584
  const { maxExpansionBytes: bytes2, maxExpansionFields: fields } = this.budget.limits;
13585
- const admit = (value2) => {
13585
+ const admit2 = (value2) => {
13586
13586
  if (typeof value2 !== "string") throw new CommandFailure("getopts: arguments must be strings without NUL", 2);
13587
13587
  if (value2.length > bytes2 || import_buffer.Buffer.byteLength(value2) > bytes2) this.budget.fail("maxExpansionBytes");
13588
13588
  if (value2.includes("\0")) throw new CommandFailure("getopts: arguments must be strings without NUL", 2);
@@ -13594,10 +13594,10 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13594
13594
  };
13595
13595
  if (!Array.isArray(context.args)) throw new CommandFailure("getopts: argument array required", 2);
13596
13596
  if (context.args.length + 1 > fields) this.budget.fail("maxExpansionFields");
13597
- admit(context.command);
13597
+ admit2(context.command);
13598
13598
  for (let index = 0; index < context.args.length; index++) {
13599
13599
  this.signal.throwIfAborted();
13600
- admit(context.args[index]);
13600
+ admit2(context.args[index]);
13601
13601
  if ((index + 1) % 128 === 0) await checkpoint();
13602
13602
  }
13603
13603
  const offset = context.args[0] === "--" ? 1 : 0;
@@ -13616,7 +13616,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13616
13616
  if (args.length > fields) this.budget.fail("maxExpansionFields");
13617
13617
  for (let index = 0; index < args.length; index++) {
13618
13618
  this.signal.throwIfAborted();
13619
- admit(args[index]);
13619
+ admit2(args[index]);
13620
13620
  if ((index + 1) % 128 === 0) await checkpoint();
13621
13621
  }
13622
13622
  const maxBytes = saturatedProduct(bytes2, saturatedSum(args.length, 1));
@@ -13977,14 +13977,14 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
13977
13977
  const declarationArgs = [...args];
13978
13978
  let indexedLocal = false;
13979
13979
  if (command2 === "local") {
13980
- const options2 = localDeclarationOptions(declarationArgs, this.signal);
13981
- if (options2.error !== void 0) {
13982
- await writeText(stderr, `local: ${options2.error}: unsupported option
13980
+ const options3 = localDeclarationOptions(declarationArgs, this.signal);
13981
+ if (options3.error !== void 0) {
13982
+ await writeText(stderr, `local: ${options3.error}: unsupported option
13983
13983
  `);
13984
13984
  return 2;
13985
13985
  }
13986
- indexedLocal = options2.indexed;
13987
- declarationArgs.splice(0, options2.offset);
13986
+ indexedLocal = options3.indexed;
13987
+ declarationArgs.splice(0, options3.offset);
13988
13988
  if (indexedLocal && declarationArgs.length === 0) {
13989
13989
  await writeText(stderr, "local: -a requires a variable name\n");
13990
13990
  return 2;
@@ -15179,15 +15179,15 @@ var ShellInput = class _ShellInput {
15179
15179
  return bytes2;
15180
15180
  });
15181
15181
  }
15182
- line(raw, options2) {
15183
- return this.#cursor.consume(this.signal, () => options2 ? this.readBounded(raw, options2) : this.readLine(raw));
15182
+ line(raw, options3) {
15183
+ return this.#cursor.consume(this.signal, () => options3 ? this.readBounded(raw, options3) : this.readLine(raw));
15184
15184
  }
15185
- async readBounded(raw, options2) {
15185
+ async readBounded(raw, options3) {
15186
15186
  const text = new ReadText();
15187
15187
  let characters = 0;
15188
15188
  const escaped = /* @__PURE__ */ new Set();
15189
15189
  const decoder3 = new TextDecoder("utf-8", { fatal: true });
15190
- const delimiter = options2.delimiter ?? 10;
15190
+ const delimiter = options3.delimiter ?? 10;
15191
15191
  let chunk = new Uint8Array();
15192
15192
  let offset = 0;
15193
15193
  let length = 0;
@@ -15195,7 +15195,7 @@ var ShellInput = class _ShellInput {
15195
15195
  let escapedCharacter = false;
15196
15196
  let units = 0;
15197
15197
  let pulls = 0;
15198
- let terminated = options2.count === 0;
15198
+ let terminated = options3.count === 0;
15199
15199
  try {
15200
15200
  while (!terminated) {
15201
15201
  if (offset === chunk.length) {
@@ -15209,7 +15209,7 @@ var ShellInput = class _ShellInput {
15209
15209
  if (!chunk.length) continue;
15210
15210
  }
15211
15211
  const byte = chunk[offset++];
15212
- if (!options2.exact && !escaping && byte === delimiter) {
15212
+ if (!options3.exact && !escaping && byte === delimiter) {
15213
15213
  terminated = true;
15214
15214
  break;
15215
15215
  }
@@ -15239,8 +15239,8 @@ var ShellInput = class _ShellInput {
15239
15239
  characters++;
15240
15240
  decodedCharacters++;
15241
15241
  }
15242
- units += options2.byteCount ? 1 : decodedCharacters;
15243
- if (units === options2.count) terminated = true;
15242
+ units += options3.byteCount ? 1 : decodedCharacters;
15243
+ if (units === options3.count) terminated = true;
15244
15244
  }
15245
15245
  decoder3.decode();
15246
15246
  return { value: text.finish(), escaped, terminated };
@@ -15350,7 +15350,7 @@ var RootInvocationCancellationOwner = class {
15350
15350
  assertAdmissionOpen() {
15351
15351
  if (!this.#admissionOpen) throw new Error("Root cancellation admission is closed");
15352
15352
  }
15353
- capture(execute2) {
15353
+ capture(execute3) {
15354
15354
  return new Promise((resolve) => {
15355
15355
  let settled = false;
15356
15356
  let raw;
@@ -15372,7 +15372,7 @@ var RootInvocationCancellationOwner = class {
15372
15372
  });
15373
15373
  };
15374
15374
  try {
15375
- raw = Promise.resolve(execute2());
15375
+ raw = Promise.resolve(execute3());
15376
15376
  } catch (reason) {
15377
15377
  settle({ kind: "throw", reason });
15378
15378
  return;
@@ -15413,12 +15413,12 @@ var Shell = class {
15413
15413
  #disposed = false;
15414
15414
  #disposal;
15415
15415
  #active = /* @__PURE__ */ new Set();
15416
- constructor(options2) {
15417
- if (!options2?.fs) throw new TypeError("Shell requires an explicit filesystem");
15418
- warnIfHostProcessEnv(options2.env);
15419
- resolveLimits(options2.limits);
15420
- this.#options = { ...options2, cwd: resolvePath("/", options2.cwd ?? "/"), env: { ...options2.env }, limits: { ...options2.limits } };
15421
- this.commands = options2.commands ?? new CommandRegistry();
15416
+ constructor(options3) {
15417
+ if (!options3?.fs) throw new TypeError("Shell requires an explicit filesystem");
15418
+ warnIfHostProcessEnv(options3.env);
15419
+ resolveLimits(options3.limits);
15420
+ this.#options = { ...options3, cwd: resolvePath("/", options3.cwd ?? "/"), env: { ...options3.env }, limits: { ...options3.limits } };
15421
+ this.commands = options3.commands ?? new CommandRegistry();
15422
15422
  }
15423
15423
  use(middleware) {
15424
15424
  if (this.#disposed) throw new Error("Shell is disposed");
@@ -15431,17 +15431,17 @@ var Shell = class {
15431
15431
  if (!middleware || typeof middleware.setup !== "function") throw new TypeError("Expected middleware or shell plugin");
15432
15432
  this.#ready = this.#ready.then(async () => {
15433
15433
  let active = true;
15434
- const admit = () => {
15434
+ const admit2 = () => {
15435
15435
  if (this.#disposed && !active) throw new Error("Shell is disposed");
15436
15436
  };
15437
15437
  const host = {
15438
15438
  commands: this.commands,
15439
15439
  use: (middleware2) => {
15440
- admit();
15440
+ admit2();
15441
15441
  this.#install(middleware2);
15442
15442
  },
15443
15443
  registerFileSystem: (scheme, factory) => {
15444
- admit();
15444
+ admit2();
15445
15445
  this.#registerFileSystem(scheme, factory);
15446
15446
  }
15447
15447
  };
@@ -15455,9 +15455,9 @@ var Shell = class {
15455
15455
  void this.#ready.catch(() => void 0);
15456
15456
  }
15457
15457
  }
15458
- register(command2, options2) {
15458
+ register(command2, options3) {
15459
15459
  if (this.#disposed) throw new Error("Shell is disposed");
15460
- this.commands.register(command2, options2);
15460
+ this.commands.register(command2, options3);
15461
15461
  return this;
15462
15462
  }
15463
15463
  registerFileSystem(scheme, factory) {
@@ -15469,23 +15469,23 @@ var Shell = class {
15469
15469
  if (this.#filesystems.has(scheme)) throw new Error(`Filesystem already registered: ${scheme}`);
15470
15470
  this.#filesystems.set(scheme, factory);
15471
15471
  }
15472
- async createFileSystem(scheme, options2 = {}) {
15472
+ async createFileSystem(scheme, options3 = {}) {
15473
15473
  if (this.#disposed) throw new Error("Shell is disposed");
15474
15474
  await this.#ready;
15475
15475
  const factory = this.#filesystems.get(scheme);
15476
15476
  if (!factory) throw new Error(`Unknown filesystem scheme: ${scheme}`);
15477
- return factory(options2);
15477
+ return factory(options3);
15478
15478
  }
15479
- async exec(source, options2 = {}) {
15479
+ async exec(source, options3 = {}) {
15480
15480
  if (this.#disposed) throw new Error("Shell is disposed");
15481
- warnIfHostProcessEnv(options2.env);
15482
- const budget = new Budget(resolveLimits(this.#options.limits, options2.limits), options2.signal);
15483
- const scope = new InvocationScope(options2.signal);
15481
+ warnIfHostProcessEnv(options3.env);
15482
+ const budget = new Budget(resolveLimits(this.#options.limits, options3.limits), options3.signal);
15483
+ const scope = new InvocationScope(options3.signal);
15484
15484
  const cancellationState = new RuntimeCancellationState();
15485
15485
  const owner = new RootInvocationCancellationOwner(scope);
15486
15486
  const boundary = createRootCancellationLink({
15487
15487
  admission: Runtime.rootCancellationAdmission(budget),
15488
- callerSignal: options2.signal,
15488
+ callerSignal: options3.signal,
15489
15489
  controls: [{ role: "budget-control", signal: budget.controller.signal }]
15490
15490
  });
15491
15491
  try {
@@ -15500,7 +15500,7 @@ var Shell = class {
15500
15500
  this.#active.add(active);
15501
15501
  let captured;
15502
15502
  try {
15503
- captured = await owner.capture(() => this.#execute(source, options2, scope, budget, boundary, cancellationState, owner));
15503
+ captured = await owner.capture(() => this.#execute(source, options3, scope, budget, boundary, cancellationState, owner));
15504
15504
  } finally {
15505
15505
  budget.close();
15506
15506
  await scope.close();
@@ -15512,7 +15512,7 @@ var Shell = class {
15512
15512
  throwCleanupFailures(scope.failures);
15513
15513
  return selection.outcome.value;
15514
15514
  }
15515
- async #execute(source, options2, scope, budget, cancellation, cancellationState, owner) {
15515
+ async #execute(source, options3, scope, budget, cancellation, cancellationState, owner) {
15516
15516
  if (typeof source !== "string") throw new TypeError("Shell source must be a string");
15517
15517
  if (import_buffer.Buffer.byteLength(source) > budget.limits.maxSourceBytes) throw new ShellLimitError("maxSourceBytes");
15518
15518
  budget.source(import_buffer.Buffer.byteLength(source));
@@ -15536,20 +15536,20 @@ var Shell = class {
15536
15536
  const io = {
15537
15537
  [invocationScope]: scope,
15538
15538
  stdin: toByteSource(""),
15539
- stdinIsDefault: options2.stdin === void 0,
15540
- stdout: sink(stdout, options2.stdout),
15541
- stderr: sink(stderr, options2.stderr)
15539
+ stdinIsDefault: options3.stdin === void 0,
15540
+ stdout: sink(stdout, options3.stdout),
15541
+ stderr: sink(stderr, options3.stderr)
15542
15542
  };
15543
15543
  let exitCode;
15544
15544
  let failed = false;
15545
15545
  try {
15546
15546
  try {
15547
- let unit = parseShellUnit(source, 0, byteLocale({ ...this.#options.env, ...options2.env }));
15548
- stdin = new ShellInput(typeof options2.stdin === "string" || options2.stdin instanceof Uint8Array ? toByteSource(options2.stdin) : options2.stdin ?? toByteSource(""), budget);
15547
+ let unit = parseShellUnit(source, 0, byteLocale({ ...this.#options.env, ...options3.env }));
15548
+ stdin = new ShellInput(typeof options3.stdin === "string" || options3.stdin instanceof Uint8Array ? toByteSource(options3.stdin) : options3.stdin ?? toByteSource(""), budget);
15549
15549
  io.stdin = stdin;
15550
15550
  await interruptible(this.#ready, budget.signal);
15551
- const cwd = resolvePath("/", options2.cwd ?? this.#options.cwd ?? "/");
15552
- const variables = Object.assign(/* @__PURE__ */ Object.create(null), this.#options.env, options2.env, { PWD: cwd });
15551
+ const cwd = resolvePath("/", options3.cwd ?? this.#options.cwd ?? "/");
15552
+ const variables = Object.assign(/* @__PURE__ */ Object.create(null), this.#options.env, options3.env, { PWD: cwd });
15553
15553
  for (const [name2, value2] of Object.entries(variables)) {
15554
15554
  if (name2.includes("\0") || name2.includes("=") || typeof value2 !== "string" || value2.includes("\0")) throw new TypeError("Invalid environment entry");
15555
15555
  }
@@ -15576,7 +15576,7 @@ var Shell = class {
15576
15576
  };
15577
15577
  const admission = Runtime.rootCancellationAdmission(budget);
15578
15578
  const runtime = new Runtime(
15579
- options2.fs ?? this.#options.fs,
15579
+ options3.fs ?? this.#options.fs,
15580
15580
  this.commands,
15581
15581
  [...this.#middleware],
15582
15582
  budget,
@@ -15762,8 +15762,8 @@ function requestBody(source, signal) {
15762
15762
  }
15763
15763
  });
15764
15764
  }
15765
- function createFetchTransport(options2 = {}) {
15766
- const fetchRequest = options2.fetch ?? globalThis.fetch;
15765
+ function createFetchTransport(options3 = {}) {
15766
+ const fetchRequest = options3.fetch ?? globalThis.fetch;
15767
15767
  if (typeof fetchRequest !== "function") throw new TypeError("Fetch is unavailable");
15768
15768
  return async (input3) => {
15769
15769
  input3.signal.throwIfAborted();
@@ -15830,7 +15830,7 @@ function privateHostname(input3) {
15830
15830
  const [first, second] = octets;
15831
15831
  return first === 10 || first === 127 || first === 0 || first === 169 && second === 254 || first === 192 && second === 168 || first === 172 && second >= 16 && second <= 31;
15832
15832
  }
15833
- function createOriginAuthorizer(allowlist = "*", options2 = {}) {
15833
+ function createOriginAuthorizer(allowlist = "*", options3 = {}) {
15834
15834
  const origins = /* @__PURE__ */ new Set();
15835
15835
  const hosts = /* @__PURE__ */ new Set();
15836
15836
  for (const entry of allowlist === "*" ? [] : allowlist) {
@@ -15850,7 +15850,7 @@ function createOriginAuthorizer(allowlist = "*", options2 = {}) {
15850
15850
  return (request) => {
15851
15851
  const url = new URL(request.url);
15852
15852
  const hostname = url.hostname.toLowerCase().replace(/\.$/u, "");
15853
- if (options2.denyPrivateNetworks && privateHostname(hostname)) return false;
15853
+ if (options3.denyPrivateNetworks && privateHostname(hostname)) return false;
15854
15854
  return allowlist === "*" || origins.has(url.origin) || hosts.has(hostname);
15855
15855
  };
15856
15856
  }
@@ -15900,25 +15900,25 @@ var ExprMatchError = class extends Error {
15900
15900
  function exactObject(value2, keys) {
15901
15901
  return value2 !== null && typeof value2 === "object" && !Array.isArray(value2) && Object.keys(value2).length === keys.length && keys.every((key) => Object.hasOwn(value2, key));
15902
15902
  }
15903
- function validateExprInput(descriptor, rows, signal) {
15903
+ function validateExprInput(descriptor2, rows, signal) {
15904
15904
  signal.throwIfAborted();
15905
15905
  const invalid = () => {
15906
15906
  throw new RegexExecutionError("PROTOCOL", "invalid expr request");
15907
15907
  };
15908
- if (!exactObject(descriptor, ["kind", "pattern", "profile", "limits"]) || descriptor.kind !== "expr-match" || !(descriptor.pattern instanceof Uint8Array) || !["byte", "utf8-scalar"].includes(descriptor.profile)) invalid();
15908
+ if (!exactObject(descriptor2, ["kind", "pattern", "profile", "limits"]) || descriptor2.kind !== "expr-match" || !(descriptor2.pattern instanceof Uint8Array) || !["byte", "utf8-scalar"].includes(descriptor2.profile)) invalid();
15909
15909
  const keys = Object.keys(exprMatchCeilings);
15910
- if (!exactObject(descriptor.limits, keys)) invalid();
15910
+ if (!exactObject(descriptor2.limits, keys)) invalid();
15911
15911
  for (const key of keys) {
15912
- if (!Number.isSafeInteger(descriptor.limits[key]) || descriptor.limits[key] < 1 || descriptor.limits[key] > exprMatchCeilings[key]) invalid();
15912
+ if (!Number.isSafeInteger(descriptor2.limits[key]) || descriptor2.limits[key] < 1 || descriptor2.limits[key] > exprMatchCeilings[key]) invalid();
15913
15913
  }
15914
15914
  if (!Array.isArray(rows) || rows.length !== 1) invalid();
15915
15915
  const row = rows[0];
15916
15916
  if (!exactObject(row, ["bytes", "all", "terminated"]) || !(row.bytes instanceof Uint8Array) || row.all !== false || row.terminated !== false) invalid();
15917
- if (descriptor.pattern.length > descriptor.limits.maxPatternBytes || row.bytes.length > descriptor.limits.maxSubjectBytes) {
15917
+ if (descriptor2.pattern.length > descriptor2.limits.maxPatternBytes || row.bytes.length > descriptor2.limits.maxSubjectBytes) {
15918
15918
  throw new ExprMatchError("limit", "regex input bytes limit exceeded");
15919
15919
  }
15920
15920
  }
15921
- function validateExprReply(value2, id, descriptor, subject, signal) {
15921
+ function validateExprReply(value2, id, descriptor2, subject, signal) {
15922
15922
  signal.throwIfAborted();
15923
15923
  const invalid = () => {
15924
15924
  throw new RegexExecutionError("PROTOCOL", "invalid expr reply");
@@ -15932,13 +15932,13 @@ function validateExprReply(value2, id, descriptor, subject, signal) {
15932
15932
  }
15933
15933
  if (!exactObject(reply, ["id", "operation", "result"])) return invalid();
15934
15934
  const result = reply.result;
15935
- if (!exactObject(result, ["offsetUnit", "matched", "hasCapture", "overall", "capture", "steps"]) || result.offsetUnit !== "byte" || typeof result.matched !== "boolean" || typeof result.hasCapture !== "boolean" || !Number.isSafeInteger(result.steps) || result.steps < 1 || result.steps > descriptor.limits.maxSteps) return invalid();
15935
+ if (!exactObject(result, ["offsetUnit", "matched", "hasCapture", "overall", "capture", "steps"]) || result.offsetUnit !== "byte" || typeof result.matched !== "boolean" || typeof result.hasCapture !== "boolean" || !Number.isSafeInteger(result.steps) || result.steps < 1 || result.steps > descriptor2.limits.maxSteps) return invalid();
15936
15936
  const span = (value3) => {
15937
15937
  if (value3 === null) return null;
15938
15938
  if (!exactObject(value3, ["start", "end"]) || !Number.isSafeInteger(value3.start) || !Number.isSafeInteger(value3.end)) return invalid();
15939
15939
  const start = value3.start, end = value3.end;
15940
15940
  if (start < 0 || end < start || end > subject.length) return invalid();
15941
- if (descriptor.profile === "utf8-scalar") {
15941
+ if (descriptor2.profile === "utf8-scalar") {
15942
15942
  for (const offset of [start, end]) if (offset < subject.length && subject[offset] >= 128 && subject[offset] <= 191) return invalid();
15943
15943
  }
15944
15944
  return { start, end };
@@ -15947,8 +15947,8 @@ function validateExprReply(value2, id, descriptor, subject, signal) {
15947
15947
  if (result.matched !== (overall !== null) || overall && overall.start !== 0 || capture && (!result.hasCapture || !overall || capture.start < overall.start || capture.end > overall.end)) return invalid();
15948
15948
  return { offsetUnit: "byte", matched: result.matched, hasCapture: result.hasCapture, overall, capture, steps: result.steps };
15949
15949
  }
15950
- function policy(options2) {
15951
- const result = { ...defaults, ...options2 };
15950
+ function policy(options3) {
15951
+ const result = { ...defaults, ...options3 };
15952
15952
  for (const key of Object.keys(defaults)) {
15953
15953
  const minimum = key === "maxQueuedRequests" || key === "maxQueuedBytes" ? 0 : 1;
15954
15954
  if (!Number.isSafeInteger(result[key]) || result[key] < minimum) throw new RangeError(`regex ${key} must be a safe integer >= ${minimum}`);
@@ -15958,9 +15958,9 @@ function policy(options2) {
15958
15958
  }
15959
15959
  return Object.freeze(result);
15960
15960
  }
15961
- function inputBytes(descriptor, rows, signal) {
15962
- let total = 128 + (descriptor.kind === "glob" ? descriptor.globOptions.length * 32 : 0);
15963
- for (const pattern of descriptor.patterns) {
15961
+ function inputBytes(descriptor2, rows, signal) {
15962
+ let total = 128 + (descriptor2.kind === "glob" ? descriptor2.globOptions.length * 32 : 0);
15963
+ for (const pattern of descriptor2.patterns) {
15964
15964
  signal.throwIfAborted();
15965
15965
  total += 16 + pattern.length * 2;
15966
15966
  if (!Number.isSafeInteger(total)) throw new RegexExecutionError("QUEUE_EXHAUSTED", "input accounting overflow");
@@ -16005,7 +16005,7 @@ async function awaitRetirements(retirements) {
16005
16005
  if (failures.length === 1) throw failures[0];
16006
16006
  if (failures.length > 1) throw new AggregateError(failures, "regex retirement failed");
16007
16007
  }
16008
- async function withRegexSession(context, executor, execute2) {
16008
+ async function withRegexSession(context, executor, execute3) {
16009
16009
  context.signal.throwIfAborted();
16010
16010
  let session;
16011
16011
  let closing;
@@ -16023,7 +16023,7 @@ async function withRegexSession(context, executor, execute2) {
16023
16023
  context.signal.throwIfAborted();
16024
16024
  if (closing) throw new RegexExecutionError("CLOSED", "invocation is closed");
16025
16025
  session = executor.open(context.signal);
16026
- outcome = { result: await execute2(session) };
16026
+ outcome = { result: await execute3(session) };
16027
16027
  } catch (error) {
16028
16028
  outcome = { error };
16029
16029
  }
@@ -16115,10 +16115,10 @@ var Slot = class {
16115
16115
  }
16116
16116
  };
16117
16117
  var RegexExecutor = class {
16118
- constructor(provider, options2 = defaults) {
16118
+ constructor(provider, options3 = defaults) {
16119
16119
  this.provider = provider;
16120
16120
  if (!provider || typeof provider.createWorker !== "function") throw new TypeError("a bounded regex provider is required");
16121
- this.options = policy(options2);
16121
+ this.options = policy(options3);
16122
16122
  }
16123
16123
  provider;
16124
16124
  options;
@@ -16153,21 +16153,21 @@ var RegexExecutor = class {
16153
16153
  this.slots.delete(slot);
16154
16154
  this.pump();
16155
16155
  }
16156
- request(descriptor, rows, signal, retirements = /* @__PURE__ */ new Set()) {
16156
+ request(descriptor2, rows, signal, retirements = /* @__PURE__ */ new Set()) {
16157
16157
  signal.throwIfAborted();
16158
16158
  if (this.disposed) return Promise.reject(new RegexExecutionError("CLOSED", "executor is disposed"));
16159
- if (descriptor.kind === "expr-match") validateExprInput(descriptor, rows, signal);
16160
- const bytes2 = descriptor.kind === "expr-match" ? 256 + descriptor.pattern.length + rows[0].bytes.length : inputBytes(descriptor, rows, signal);
16159
+ if (descriptor2.kind === "expr-match") validateExprInput(descriptor2, rows, signal);
16160
+ const bytes2 = descriptor2.kind === "expr-match" ? 256 + descriptor2.pattern.length + rows[0].bytes.length : inputBytes(descriptor2, rows, signal);
16161
16161
  const available = this.queue.length === 0 && ([...this.slots].some((slot) => !slot.busy && !slot.retired) || this.slots.size < this.options.maxWorkers);
16162
16162
  if (!available && (this.queue.length >= this.options.maxQueuedRequests || bytes2 > this.options.maxQueuedBytes - this.queuedBytes)) return Promise.reject(new RegexExecutionError("QUEUE_EXHAUSTED", "queued request count or input byte limit exceeded"));
16163
- const ownedDescriptor = descriptor.kind === "expr-match" ? { ...descriptor, pattern: Uint8Array.from(descriptor.pattern), limits: { ...descriptor.limits } } : { ...descriptor, patterns: descriptor.patterns.map((pattern) => {
16163
+ const ownedDescriptor = descriptor2.kind === "expr-match" ? { ...descriptor2, pattern: Uint8Array.from(descriptor2.pattern), limits: { ...descriptor2.limits } } : { ...descriptor2, patterns: descriptor2.patterns.map((pattern) => {
16164
16164
  signal.throwIfAborted();
16165
16165
  return pattern;
16166
16166
  }) };
16167
16167
  if (ownedDescriptor.kind === "glob") {
16168
- const globOptions = ownedDescriptor.globOptions.map((options2) => {
16168
+ const globOptions = ownedDescriptor.globOptions.map((options3) => {
16169
16169
  signal.throwIfAborted();
16170
- return { ...options2 };
16170
+ return { ...options3 };
16171
16171
  });
16172
16172
  Object.assign(ownedDescriptor, { globOptions });
16173
16173
  }
@@ -16285,18 +16285,18 @@ var RegexSession = class {
16285
16285
  retirements = /* @__PURE__ */ new Set();
16286
16286
  controller = new AbortController();
16287
16287
  requestSignal;
16288
- run(descriptor, rows) {
16288
+ run(descriptor2, rows) {
16289
16289
  this.signal.throwIfAborted();
16290
16290
  if (this.closed) throw new RegexExecutionError("CLOSED", "invocation is closed");
16291
- const result = this.executor.request(descriptor, rows, this.requestSignal, this.retirements);
16291
+ const result = this.executor.request(descriptor2, rows, this.requestSignal, this.retirements);
16292
16292
  this.pending.add(result);
16293
16293
  void result.then(() => this.pending.delete(result), () => this.pending.delete(result));
16294
16294
  return result;
16295
16295
  }
16296
- matchExpr(descriptor, subject) {
16296
+ matchExpr(descriptor2, subject) {
16297
16297
  this.signal.throwIfAborted();
16298
16298
  if (this.closed) throw new RegexExecutionError("CLOSED", "invocation is closed");
16299
- const result = this.executor.request(descriptor, [{ bytes: subject, all: false, terminated: false }], this.requestSignal, this.retirements);
16299
+ const result = this.executor.request(descriptor2, [{ bytes: subject, all: false, terminated: false }], this.requestSignal, this.retirements);
16300
16300
  this.pending.add(result);
16301
16301
  void result.then(() => this.pending.delete(result), () => this.pending.delete(result));
16302
16302
  return result;
@@ -16429,10 +16429,10 @@ async function* requiredFileInput(context, requirements, mode, file, maxBytes) {
16429
16429
  var ProgramError = class extends Error {
16430
16430
  };
16431
16431
  var Budget3 = class {
16432
- constructor(context, options2) {
16432
+ constructor(context, options3) {
16433
16433
  this.context = context;
16434
- this.remaining = options2.maxSteps ?? 5e6;
16435
- this.maxBufferBytes = options2.maxBufferBytes ?? 32 * 1024 * 1024;
16434
+ this.remaining = options3.maxSteps ?? 5e6;
16435
+ this.maxBufferBytes = options3.maxBufferBytes ?? 32 * 1024 * 1024;
16436
16436
  for (const value2 of [this.remaining, this.maxBufferBytes]) {
16437
16437
  if (!Number.isSafeInteger(value2) || value2 < 1) throw new ProgramError("limits must be positive safe integers");
16438
16438
  }
@@ -17049,10 +17049,10 @@ async function execute(program, context, files, quiet, budget) {
17049
17049
  following = void 0;
17050
17050
  return next;
17051
17051
  };
17052
- const prepareRecord = async (record3) => {
17053
- if (record3.terminated || files.length < 2) return record3;
17052
+ const prepareRecord = async (record4) => {
17053
+ if (record4.terminated || files.length < 2) return record4;
17054
17054
  const next = await peekNext();
17055
- return !next.done && next.value.fileIndex !== record3.fileIndex ? { ...record3, terminated: true } : record3;
17055
+ return !next.done && next.value.fileIndex !== record4.fileIndex ? { ...record4, terminated: true } : record4;
17056
17056
  };
17057
17057
  let number = 0;
17058
17058
  let hold = "";
@@ -17067,8 +17067,8 @@ async function execute(program, context, files, quiet, budget) {
17067
17067
  while (!current.done) {
17068
17068
  budget.step();
17069
17069
  number++;
17070
- let record3 = await prepareRecord(current.value);
17071
- let pattern = record3.text;
17070
+ let record4 = await prepareRecord(current.value);
17071
+ let pattern = record4.text;
17072
17072
  const appended = [];
17073
17073
  let appendedSize = 0;
17074
17074
  const append = (item) => {
@@ -17080,7 +17080,7 @@ async function execute(program, context, files, quiet, budget) {
17080
17080
  let deleted = false;
17081
17081
  let quit = false;
17082
17082
  let status = 0;
17083
- const print = () => write(context, pattern + (record3.terminated ? "\n" : ""));
17083
+ const print = () => write(context, pattern + (record4.terminated ? "\n" : ""));
17084
17084
  const flush = async () => {
17085
17085
  await assertPathRequirements(context, sedRequirements, ["script-read"], appended.flatMap((item) => item.file === void 0 ? [] : [item.file]));
17086
17086
  if (!quiet && !deleted) await print();
@@ -17141,7 +17141,7 @@ async function execute(program, context, files, quiet, budget) {
17141
17141
  break;
17142
17142
  case "P": {
17143
17143
  const end = pattern.indexOf("\n");
17144
- await write(context, end < 0 ? pattern + (record3.terminated ? "\n" : "") : pattern.slice(0, end + 1));
17144
+ await write(context, end < 0 ? pattern + (record4.terminated ? "\n" : "") : pattern.slice(0, end + 1));
17145
17145
  break;
17146
17146
  }
17147
17147
  case "=":
@@ -17255,9 +17255,9 @@ async function execute(program, context, files, quiet, budget) {
17255
17255
  if (instruction.kind === "N") await flush();
17256
17256
  return { status: 0, quit: false };
17257
17257
  }
17258
- record3 = await prepareRecord(next.value);
17258
+ record4 = await prepareRecord(next.value);
17259
17259
  number++;
17260
- pattern = instruction.kind === "N" ? budget.check(pattern + "\n" + record3.text) : record3.text;
17260
+ pattern = instruction.kind === "N" ? budget.check(pattern + "\n" + record4.text) : record4.text;
17261
17261
  substituted = false;
17262
17262
  break;
17263
17263
  }
@@ -17273,9 +17273,9 @@ async function execute(program, context, files, quiet, budget) {
17273
17273
  await source.return(void 0);
17274
17274
  }
17275
17275
  }
17276
- function sedCommand(options2 = {}) {
17276
+ function sedCommand(options3 = {}) {
17277
17277
  const definition = command("sed", async (context) => {
17278
- const budget = new Budget3(context, options2);
17278
+ const budget = new Budget3(context, options3);
17279
17279
  const sources = [];
17280
17280
  const files = [];
17281
17281
  let quiet = false;
@@ -17386,7 +17386,7 @@ function createGrepCommands(executor) {
17386
17386
  const patterns2 = [];
17387
17387
  let patternCount = 0;
17388
17388
  let patternBytes = 0;
17389
- const admit = (chunk, atStart) => {
17389
+ const admit2 = (chunk, atStart) => {
17390
17390
  context.signal.throwIfAborted();
17391
17391
  const size = typeof chunk === "string" ? import_buffer.Buffer.byteLength(chunk) : chunk.length;
17392
17392
  if (size > bufferLimit - patternBytes) throw new UsageError(`pattern byte limit exceeded (${bufferLimit} bytes)`);
@@ -17401,7 +17401,7 @@ function createGrepCommands(executor) {
17401
17401
  return atStart;
17402
17402
  };
17403
17403
  const addArgument = async (pattern) => {
17404
- admit(pattern, true);
17404
+ admit2(pattern, true);
17405
17405
  if (pattern === "") {
17406
17406
  if (++patternCount > maxPatternCount) throw new UsageError(`pattern count limit exceeded (${maxPatternCount})`);
17407
17407
  patterns2.push("");
@@ -17412,7 +17412,7 @@ function createGrepCommands(executor) {
17412
17412
  async function* admitted(source) {
17413
17413
  let atStart = true;
17414
17414
  for await (const chunk of source) {
17415
- atStart = admit(chunk, atStart);
17415
+ atStart = admit2(chunk, atStart);
17416
17416
  yield chunk;
17417
17417
  }
17418
17418
  }
@@ -17423,7 +17423,7 @@ function createGrepCommands(executor) {
17423
17423
  }
17424
17424
  if (positionalPattern !== void 0) await addArgument(positionalPattern);
17425
17425
  if (parsed.flags.has("E") && parsed.flags.has("F")) throw new UsageError("conflicting matchers specified");
17426
- const descriptor = {
17426
+ const descriptor2 = {
17427
17427
  kind: "grep",
17428
17428
  patterns: patterns2,
17429
17429
  fixed: parsed.flags.has("F"),
@@ -17432,7 +17432,7 @@ function createGrepCommands(executor) {
17432
17432
  whole: parsed.flags.has("x"),
17433
17433
  word: parsed.flags.has("w")
17434
17434
  };
17435
- await session.run(descriptor, []);
17435
+ await session.run(descriptor2, []);
17436
17436
  const maxCount = value(parsed, "m") === void 0 ? Infinity : integer(value(parsed, "m"));
17437
17437
  const batchSize = Number.isFinite(maxCount) || parsed.flags.has("q") || parsed.flags.has("l") || parsed.flags.has("L") ? 1 : 128;
17438
17438
  const delimiter = parsed.flags.has("z") ? "\0" : "\n";
@@ -17447,7 +17447,7 @@ function createGrepCommands(executor) {
17447
17447
  const available = new AvailableRecords(parsed.flags.has("z") ? 0 : 10, bufferLimit);
17448
17448
  const source = name2 === "-" ? input(context) : requiredFileInput(context, grepRequirements, "file", name2, bufferLimit);
17449
17449
  records: if (maxCount > 0) for await (const batch of available.batches(lines(available.source(source), parsed.flags.has("z") ? 0 : 10), (line) => line.bytes.length, () => batchSize)) {
17450
- const results = await session.run(descriptor, batch.map((line) => ({ bytes: line.bytes, all: parsed.flags.has("o"), terminated: line.terminated })));
17450
+ const results = await session.run(descriptor2, batch.map((line) => ({ bytes: line.bytes, all: parsed.flags.has("o"), terminated: line.terminated })));
17451
17451
  for (let index = 0; index < batch.length; index++) {
17452
17452
  const line = batch[index];
17453
17453
  context.signal.throwIfAborted();
@@ -17867,13 +17867,13 @@ function pathFor(context, path) {
17867
17867
  var OutputClosed = class extends SearchError {
17868
17868
  };
17869
17869
  var Limits = class {
17870
- constructor(context, options2) {
17870
+ constructor(context, options3) {
17871
17871
  this.context = context;
17872
17872
  this.signal = AbortSignal.any([context.signal, this.stopped.signal]);
17873
- this.maxOutputBytes = options2.maxOutputBytes ?? 16 * 1024 * 1024;
17874
- this.maxLineBytes = options2.maxLineBytes ?? 1024 * 1024;
17875
- this.maxFileBytes = options2.maxFileBytes ?? 64 * 1024 * 1024;
17876
- this.maxFiles = options2.maxFiles ?? 1e5;
17873
+ this.maxOutputBytes = options3.maxOutputBytes ?? 16 * 1024 * 1024;
17874
+ this.maxLineBytes = options3.maxLineBytes ?? 1024 * 1024;
17875
+ this.maxFileBytes = options3.maxFileBytes ?? 64 * 1024 * 1024;
17876
+ this.maxFiles = options3.maxFiles ?? 1e5;
17877
17877
  for (const limit of [this.maxOutputBytes, this.maxLineBytes, this.maxFileBytes, this.maxFiles]) {
17878
17878
  if (!Number.isSafeInteger(limit) || limit < 1) throw new SearchError("search limits must be positive safe integers");
17879
17879
  }
@@ -18058,13 +18058,13 @@ async function matchGlobs(globs, candidates, session) {
18058
18058
  bytes2 += size;
18059
18059
  offset++;
18060
18060
  }
18061
- const descriptor = {
18061
+ const descriptor2 = {
18062
18062
  kind: "glob",
18063
18063
  patterns: batch.map((glob) => glob.source),
18064
18064
  globOptions: batch.map((glob) => ({ insensitive: glob.insensitive, literalUnclosedClass: glob.literalUnclosedClass }))
18065
18065
  };
18066
18066
  try {
18067
- results.push(...(await session.run(descriptor, rows)).map((result) => result.length > 0));
18067
+ results.push(...(await session.run(descriptor2, rows)).map((result) => result.length > 0));
18068
18068
  } catch (error) {
18069
18069
  if (error instanceof RegexExecutionError && error.code === "MATCH") throw new SearchError(error.message);
18070
18070
  throw error;
@@ -18263,10 +18263,10 @@ var Walker = class {
18263
18263
  };
18264
18264
 
18265
18265
  // packages/safe-bash/src/commands/search/rg-command.ts
18266
- function selectInput(context, args, options2) {
18266
+ function selectInput(context, args, options3) {
18267
18267
  if (args.paths.length) return { paths: args.paths, implicit: false };
18268
- if (args.mode === "files" || options2.defaultInput === "cwd" || args.patternFiles.includes("-")) return { paths: ["."], implicit: true };
18269
- const stdin = options2.defaultInput === "stdin" || context.stdinIsDefault === false;
18268
+ if (args.mode === "files" || options3.defaultInput === "cwd" || args.patternFiles.includes("-")) return { paths: ["."], implicit: true };
18269
+ const stdin = options3.defaultInput === "stdin" || context.stdinIsDefault === false;
18270
18270
  return { paths: stdin ? ["-"] : ["."], implicit: !stdin };
18271
18271
  }
18272
18272
  async function patterns(context, args) {
@@ -18388,7 +18388,7 @@ async function searchFile(context, args, limits, matcher, printer, target, stdin
18388
18388
  }
18389
18389
  return { found, stats: totals };
18390
18390
  }
18391
- function createRgCommand(executor, options2 = {}) {
18391
+ function createRgCommand(executor, options3 = {}) {
18392
18392
  return {
18393
18393
  name: "rg",
18394
18394
  filesystemRequirements: searchRequirements,
@@ -18399,12 +18399,12 @@ function createRgCommand(executor, options2 = {}) {
18399
18399
  let failed = false;
18400
18400
  let found = false;
18401
18401
  try {
18402
- const limits = new Limits(context, options2);
18402
+ const limits = new Limits(context, options3);
18403
18403
  args = parse2(context.args);
18404
18404
  if (args.mode !== "files" && args.patternFiles.includes("-") && args.paths.includes("-")) {
18405
18405
  throw new SearchError("cannot search stdin while also reading patterns from stdin");
18406
18406
  }
18407
- const selection = selectInput(context, args, options2);
18407
+ const selection = selectInput(context, args, options3);
18408
18408
  const report = async (error) => {
18409
18409
  context.signal.throwIfAborted();
18410
18410
  failed = true;
@@ -18454,16 +18454,16 @@ function createRgCommand(executor, options2 = {}) {
18454
18454
  }
18455
18455
 
18456
18456
  // packages/safe-bash/src/commands/search/portable.ts
18457
- function portableSearchCommands(options2) {
18458
- const executor = new RegexExecutor(options2.provider, options2.regex);
18459
- const commands = [...createGrepCommands(executor), createRgCommand(executor, options2.search), sedCommand(options2.sed)];
18457
+ function portableSearchCommands(options3) {
18458
+ const executor = new RegexExecutor(options3.provider, options3.regex);
18459
+ const commands = [...createGrepCommands(executor), createRgCommand(executor, options3.search), sedCommand(options3.sed)];
18460
18460
  return {
18461
18461
  name: "portable-search-commands",
18462
18462
  setup(host) {
18463
- if (!options2.replace) for (const command2 of commands) {
18463
+ if (!options3.replace) for (const command2 of commands) {
18464
18464
  if (host.commands.has(command2.name)) throw new Error(`Command already registered: ${command2.name}`);
18465
18465
  }
18466
- for (const command2 of commands) host.commands.register(command2, { replace: options2.replace ?? false });
18466
+ for (const command2 of commands) host.commands.register(command2, { replace: options3.replace ?? false });
18467
18467
  },
18468
18468
  dispose: () => executor.dispose()
18469
18469
  };
@@ -18472,6 +18472,281 @@ function portableSearchCommands(options2) {
18472
18472
  // packages/safe-bash/src/commands/regex-execution/public.ts
18473
18473
  init_platform();
18474
18474
 
18475
+ // packages/safe-bash/src/commands/regex-execution/bounded-provider.ts
18476
+ init_platform();
18477
+ var defaults2 = Object.freeze({
18478
+ maxWorkers: 2,
18479
+ maxPatterns: 32,
18480
+ maxPatternBytes: 8192,
18481
+ maxRows: 128,
18482
+ maxInputBytes: 65536,
18483
+ maxResultBytes: 2048,
18484
+ maxWork: 2e6,
18485
+ maxAllocationUnits: 1e6,
18486
+ maxStates: 65536
18487
+ });
18488
+ var ceilings = Object.freeze({
18489
+ maxWorkers: 32,
18490
+ maxPatterns: 128,
18491
+ maxPatternBytes: 65532,
18492
+ maxRows: 4096,
18493
+ maxInputBytes: 1048576,
18494
+ maxResultBytes: 65536,
18495
+ maxWork: 33554432,
18496
+ maxAllocationUnits: 4e6,
18497
+ maxStates: 65536
18498
+ });
18499
+ var typedArrayPrototype2 = Object.getPrototypeOf(Uint8Array.prototype);
18500
+ var byteLength = Object.getOwnPropertyDescriptor(typedArrayPrototype2, "byteLength").get;
18501
+ var byteOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype2, "byteOffset").get;
18502
+ var byteBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype2, "buffer").get;
18503
+ function fail(kind, message2) {
18504
+ throw new Error(`bounded regex ${kind}: ${message2}`);
18505
+ }
18506
+ function record3(value2, keys, optional = []) {
18507
+ if (value2 === null || typeof value2 !== "object" || Array.isArray(value2)) fail("protocol", "expected a data record");
18508
+ const ownKeys = Reflect.ownKeys(value2);
18509
+ if (ownKeys.length < keys.length || ownKeys.length > keys.length + optional.length || ownKeys.some((key) => typeof key !== "string" || !keys.includes(key) && !optional.includes(key))) fail("protocol", "unexpected data-record fields");
18510
+ for (const key of [...keys, ...optional]) {
18511
+ const property = Object.getOwnPropertyDescriptor(value2, key);
18512
+ if (property === void 0 ? keys.includes(key) : !("value" in property)) fail("protocol", "missing field or accessor");
18513
+ }
18514
+ }
18515
+ function array(value2, limit, label) {
18516
+ if (!Array.isArray(value2)) fail("protocol", `${label} must be an array`);
18517
+ if (value2.length > limit) fail("limit", `${label} count limit exceeded`);
18518
+ const keys = Reflect.ownKeys(value2);
18519
+ if (keys.length !== value2.length + 1) fail("protocol", `${label} must be a dense data array`);
18520
+ for (let index = 0; index < value2.length; index++) {
18521
+ const property = Object.getOwnPropertyDescriptor(value2, index);
18522
+ if (!property || !("value" in property)) fail("protocol", `${label} must be a dense data array`);
18523
+ }
18524
+ }
18525
+ function options2(input3) {
18526
+ const keys = Object.keys(defaults2);
18527
+ try {
18528
+ record3(input3, [], keys);
18529
+ } catch {
18530
+ throw new TypeError("bounded regex options require supported own data fields");
18531
+ }
18532
+ const result = { ...defaults2 };
18533
+ for (const key of keys) {
18534
+ if (!Object.hasOwn(input3, key)) continue;
18535
+ const value2 = input3[key];
18536
+ if (typeof value2 !== "number" || !Number.isSafeInteger(value2) || value2 < 1 || value2 > ceilings[key]) throw new RangeError(`bounded regex option ${key} is outside its limit`);
18537
+ result[key] = value2;
18538
+ }
18539
+ return Object.freeze(result);
18540
+ }
18541
+ function descriptor(value2, limits) {
18542
+ if (value2 === null || typeof value2 !== "object") fail("protocol", "invalid descriptor");
18543
+ const kind = Object.getOwnPropertyDescriptor(value2, "kind");
18544
+ if (!kind || !("value" in kind)) fail("protocol", "invalid descriptor kind");
18545
+ if (kind.value !== "grep" && kind.value !== "rg") fail("unsupported", "only grep and fixed rg selection descriptors are supported");
18546
+ const flags = kind.value === "grep" ? ["fixed", "extended", "insensitive", "whole", "word"] : ["fixed", "whole", "word", "nullData"];
18547
+ record3(value2, ["kind", "patterns", ...flags, ...kind.value === "rg" ? ["case"] : []]);
18548
+ for (const flag of flags) if (typeof value2[flag] !== "boolean") fail("protocol", `invalid ${flag} flag`);
18549
+ if (kind.value === "rg" && !["sensitive", "insensitive", "smart"].includes(value2.case)) fail("protocol", "invalid case flag");
18550
+ if (value2.word || kind.value === "grep" && value2.insensitive || kind.value === "rg" && value2.case !== "sensitive") fail("unsupported", "only case-sensitive, non-word selection is supported");
18551
+ if (kind.value === "rg" && !value2.fixed) fail("unsupported", "rg regex and Unicode modes are unsupported; use fixed ASCII patterns");
18552
+ array(value2.patterns, limits.maxPatterns, "pattern");
18553
+ let bytes2 = 0;
18554
+ for (let index = 0; index < value2.patterns.length; index++) {
18555
+ const pattern = value2.patterns[index];
18556
+ if (typeof pattern !== "string") fail("protocol", "patterns must be strings");
18557
+ if (pattern.length > limits.maxPatternBytes - bytes2) fail("limit", "aggregate pattern byte limit exceeded");
18558
+ bytes2 += pattern.length;
18559
+ }
18560
+ return value2;
18561
+ }
18562
+ function admit(input3, limits, signal) {
18563
+ record3(input3, ["id", "descriptor", "rows"]);
18564
+ const selected = descriptor(input3.descriptor, limits);
18565
+ array(input3.rows, limits.maxRows, "row");
18566
+ if (input3.rows.length > Math.floor(limits.maxResultBytes / 16)) fail("limit", "result byte limit exceeded");
18567
+ let bytes2 = 0;
18568
+ for (let index = 0; index < input3.rows.length; index++) {
18569
+ const row = input3.rows[index];
18570
+ record3(row, ["bytes", "all", "terminated"], ["directory", "ancestors"]);
18571
+ if (!(row.bytes instanceof Uint8Array) || typeof row.all !== "boolean" || typeof row.terminated !== "boolean" || Object.hasOwn(row, "directory") && typeof row.directory !== "boolean" || Object.hasOwn(row, "ancestors") && typeof row.ancestors !== "boolean") fail("protocol", "invalid row");
18572
+ if (Object.hasOwn(row, "directory") || Object.hasOwn(row, "ancestors")) fail("unsupported", "glob row flags are unsupported");
18573
+ if (row.all) fail("unsupported", "all-match enumeration is unsupported");
18574
+ const length = byteLength.call(row.bytes);
18575
+ if (length > limits.maxInputBytes - bytes2) fail("limit", "aggregate input byte limit exceeded");
18576
+ bytes2 += length;
18577
+ }
18578
+ const ledger = new EreLedger({ maxExpansionBytes: 1048576, maxExpansionFields: 8192 }, {
18579
+ patternBytes: limits.maxPatternBytes + 4,
18580
+ subjectBytes: limits.maxInputBytes,
18581
+ work: limits.maxWork,
18582
+ allocationUnits: limits.maxAllocationUnits,
18583
+ states: limits.maxStates
18584
+ });
18585
+ ledger.charge("allocationUnits", bytes2 + input3.rows.length * 12 + selected.patterns.length * 2 + 16, signal);
18586
+ const patterns2 = [];
18587
+ for (let index = 0; index < selected.patterns.length; index++) patterns2.push(selected.patterns[index]);
18588
+ const ownedDescriptor = selected.kind === "grep" ? { kind: "grep", patterns: patterns2, fixed: selected.fixed, extended: selected.extended, insensitive: selected.insensitive, whole: selected.whole, word: selected.word } : { kind: "rg", patterns: patterns2, fixed: selected.fixed, case: selected.case, whole: selected.whole, word: selected.word, nullData: selected.nullData };
18589
+ const rows = [];
18590
+ for (let index = 0; index < input3.rows.length; index++) {
18591
+ const row = input3.rows[index];
18592
+ const source = new Uint8Array(byteBuffer.call(row.bytes), byteOffset.call(row.bytes), byteLength.call(row.bytes));
18593
+ const copy2 = new Uint8Array(source.length);
18594
+ copy2.set(source);
18595
+ rows.push({ bytes: copy2, all: false, terminated: row.terminated });
18596
+ }
18597
+ return { id: input3.id, descriptor: ownedDescriptor, rows, ledger };
18598
+ }
18599
+ async function admitBre(pattern, ledger, signal) {
18600
+ let bracket = -1;
18601
+ let member = false;
18602
+ let namedClass = false;
18603
+ for (let index = 0; index < pattern.length; index++) {
18604
+ ledger.charge("work", 1, signal);
18605
+ await ledger.checkpoint(signal);
18606
+ const character = pattern[index];
18607
+ if ("\\()+?{}|".includes(character)) fail("unsupported", "BRE escapes, groups and interval/operator extensions are unsupported; use grep -E");
18608
+ if (bracket >= 0) {
18609
+ if (index === bracket + 1 && character === "^") continue;
18610
+ if (namedClass) {
18611
+ if (character === "]" && pattern[index - 1] === ":") namedClass = false;
18612
+ } else if (character === "]" && member) bracket = -1;
18613
+ else if (character === "[" && pattern[index + 1] === ":") namedClass = true;
18614
+ member = true;
18615
+ } else if (character === "[") {
18616
+ bracket = index;
18617
+ member = false;
18618
+ } else if (character === "^" && index !== 0 || character === "$" && index !== pattern.length - 1) {
18619
+ fail("unsupported", "BRE anchors are supported only at record boundaries");
18620
+ } else if (character === "*" && (index === 0 || index === 1 && pattern[0] === "^")) {
18621
+ fail("unsupported", "BRE leading literal star is unsupported; use fixed matching");
18622
+ }
18623
+ }
18624
+ }
18625
+ async function execute2(input3, signal) {
18626
+ const { descriptor: selected, rows, ledger } = input3;
18627
+ const programs2 = [];
18628
+ for (const pattern of selected.patterns) {
18629
+ if (selected.kind === "grep" && !selected.fixed && !selected.extended) await admitBre(pattern, ledger, signal);
18630
+ if (selected.kind === "rg" && !selected.nullData && pattern.includes("\n")) fail("unsupported", "rg multiline matching is unsupported");
18631
+ ledger.charge("allocationUnits", (selected.whole ? 3 : 1) * 3 + 2, signal);
18632
+ const fragments = selected.whole ? [{ text: "^(", literal: false }, { text: pattern, literal: selected.fixed }, { text: ")$", literal: false }] : [{ text: pattern, literal: selected.fixed }];
18633
+ programs2.push(await compileEre(fragments, ledger, signal));
18634
+ }
18635
+ const results = [];
18636
+ for (const row of rows) {
18637
+ ledger.charge("allocationUnits", row.bytes.length * 2 + 2, signal);
18638
+ const characters = [];
18639
+ for (const byte of row.bytes) {
18640
+ ledger.charge("work", 1, signal);
18641
+ if (byte === 0 || byte > 127) fail("unsupported", "subjects require non-NUL ASCII; Unicode and invalid UTF-8 are unsupported");
18642
+ characters.push(String.fromCharCode(byte));
18643
+ await ledger.checkpoint(signal);
18644
+ }
18645
+ const subject = characters.join("");
18646
+ let span;
18647
+ for (const program of programs2) {
18648
+ const match = await matchEre(program, subject, ledger, signal);
18649
+ if (!match.matched) continue;
18650
+ const candidate = match.captures[0];
18651
+ if (selected.kind === "grep") {
18652
+ span = candidate;
18653
+ break;
18654
+ }
18655
+ if (!span || candidate.start < span.start) span = candidate;
18656
+ }
18657
+ signal.throwIfAborted();
18658
+ results.push(span ? new Float64Array([span.start, span.end]) : new Float64Array());
18659
+ }
18660
+ return { id: input3.id, results };
18661
+ }
18662
+ var CooperativeWorker = class {
18663
+ constructor(limits, release) {
18664
+ this.limits = limits;
18665
+ this.release = release;
18666
+ queueMicrotask(() => {
18667
+ if (!this.#closing) this.emit({ ready: true });
18668
+ });
18669
+ }
18670
+ limits;
18671
+ release;
18672
+ #controller = new AbortController();
18673
+ #listeners = /* @__PURE__ */ new Map();
18674
+ #tasks = /* @__PURE__ */ new Set();
18675
+ #busy = false;
18676
+ #closing;
18677
+ on(event, listener) {
18678
+ if (this.#closing) return;
18679
+ let listeners = this.#listeners.get(event);
18680
+ if (!listeners) {
18681
+ listeners = /* @__PURE__ */ new Set();
18682
+ this.#listeners.set(event, listeners);
18683
+ }
18684
+ listeners.add(listener);
18685
+ }
18686
+ off(event, listener) {
18687
+ this.#listeners.get(event)?.delete(listener);
18688
+ }
18689
+ emit(value2) {
18690
+ for (const listener of this.#listeners.get("message") ?? []) listener(value2);
18691
+ }
18692
+ postMessage(input3) {
18693
+ if (this.#closing) throw new Error("bounded regex worker is closed");
18694
+ if (this.#busy) throw new Error("bounded regex worker is busy");
18695
+ const identity = input3 !== null && typeof input3 === "object" ? Object.getOwnPropertyDescriptor(input3, "id") : void 0;
18696
+ if (!identity || !("value" in identity) || !Number.isSafeInteger(identity.value) || identity.value < 1) fail("protocol", "invalid request identity");
18697
+ const id = identity.value;
18698
+ const submitted = Object.getOwnPropertyDescriptor(input3, "descriptor")?.value;
18699
+ const expression = submitted !== null && typeof submitted === "object" && Object.getOwnPropertyDescriptor(submitted, "kind")?.value === "expr-match";
18700
+ let owned;
18701
+ let failure;
18702
+ try {
18703
+ owned = admit(input3, this.limits, this.#controller.signal);
18704
+ } catch (error) {
18705
+ failure = error instanceof Error ? error.message.slice(0, 512) : "bounded regex protocol: request admission failed";
18706
+ }
18707
+ this.#busy = true;
18708
+ const task = Promise.resolve().then(async () => {
18709
+ let reply;
18710
+ try {
18711
+ this.#controller.signal.throwIfAborted();
18712
+ reply = owned ? await execute2(owned, this.#controller.signal) : { id, error: failure };
18713
+ } catch (error) {
18714
+ reply = { id, error: error instanceof Error ? error.message.slice(0, 512) : "bounded regex request failed" };
18715
+ }
18716
+ if (expression && "error" in reply) reply = { id, operation: "expr-match", category: "unsupported", error: reply.error };
18717
+ owned = void 0;
18718
+ this.#busy = false;
18719
+ if (!this.#closing) this.emit(reply);
18720
+ });
18721
+ this.#tasks.add(task);
18722
+ void task.then(() => this.#tasks.delete(task), () => this.#tasks.delete(task));
18723
+ }
18724
+ terminate() {
18725
+ if (!this.#closing) {
18726
+ this.#closing = Promise.allSettled([...this.#tasks]).then(() => {
18727
+ this.#listeners.clear();
18728
+ this.#tasks.clear();
18729
+ this.release();
18730
+ });
18731
+ this.#controller.abort(new Error("bounded regex worker terminated"));
18732
+ }
18733
+ return this.#closing;
18734
+ }
18735
+ };
18736
+ function createBoundedRegexProvider(input3 = {}) {
18737
+ const limits = options2(input3);
18738
+ let active = 0;
18739
+ return Object.freeze({
18740
+ createWorker() {
18741
+ if (active >= limits.maxWorkers) fail("limit", "worker count limit exceeded");
18742
+ active++;
18743
+ return new CooperativeWorker(limits, () => {
18744
+ active--;
18745
+ });
18746
+ }
18747
+ });
18748
+ }
18749
+
18475
18750
  // packages/safe-bash/src/browser.ts
18476
18751
  function createBrowserCommands() {
18477
18752
  return [
@@ -18482,17 +18757,17 @@ function createBrowserCommands() {
18482
18757
  ...textCommands()
18483
18758
  ];
18484
18759
  }
18485
- function browserCommands(options2 = {}) {
18760
+ function browserCommands(options3 = {}) {
18486
18761
  return {
18487
18762
  name: "browser-commands",
18488
18763
  setup(host) {
18489
18764
  const commands = createBrowserCommands();
18490
- if (!options2.replace) {
18765
+ if (!options3.replace) {
18491
18766
  for (const command2 of commands) {
18492
18767
  if (host.commands.has(command2.name)) throw new Error(`Command already registered: ${command2.name}`);
18493
18768
  }
18494
18769
  }
18495
- for (const command2 of commands) host.commands.register(command2, { replace: options2.replace ?? false });
18770
+ for (const command2 of commands) host.commands.register(command2, { replace: options3.replace ?? false });
18496
18771
  }
18497
18772
  };
18498
18773
  }
@@ -18523,6 +18798,7 @@ export {
18523
18798
  collectText,
18524
18799
  compileEre,
18525
18800
  composeMiddleware,
18801
+ createBoundedRegexProvider,
18526
18802
  createBrowserCommands,
18527
18803
  createBytePipe,
18528
18804
  createCommandArguments,