@poe-platform/safe-bash 0.1.787 → 0.1.789

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.
Files changed (199) hide show
  1. package/README.md +1 -1
  2. package/dist/safe-bash/chunks/{chunk-WHURJBET.js → chunk-2MUJ7RLZ.js} +1 -1
  3. package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-CTUHLNJM.js} +2 -2
  4. package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-D4PHJK4T.js} +1 -1
  5. package/dist/safe-bash/chunks/{chunk-O6356Z27.js → chunk-H7MMJS26.js} +2 -2
  6. package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-KHJGUF2W.js} +14 -0
  7. package/dist/safe-bash/chunks/{chunk-FJZNUUOQ.js → chunk-VUVKC6HV.js} +1 -1
  8. package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-X5ZCECM6.js} +2 -2
  9. package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-HO7WDPHZ.js} +2 -2
  10. package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
  11. package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
  12. package/dist/safe-bash/command-chunks/{chunk-WVWWRMFD.js → chunk-3KROFHBT.js} +1 -1
  13. package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
  14. package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
  15. package/dist/safe-bash/command-chunks/{chunk-IFUNAM4D.js → chunk-5L62A5RO.js} +1 -1
  16. package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
  17. package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-6F7QJMJ3.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-DREUDEQG.js → chunk-AT6ZSOE6.js} +3 -3
  20. package/dist/safe-bash/command-chunks/{chunk-BUKYQBXO.js → chunk-BJ6DGYJA.js} +12 -12
  21. package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-NSEUBSOD.js → chunk-CXMOCPPH.js} +2 -2
  23. package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
  25. package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
  26. package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
  28. package/dist/safe-bash/command-chunks/{chunk-3JS4FOLB.js → chunk-HETU7MYN.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
  30. package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
  31. package/dist/safe-bash/command-chunks/{chunk-Z47EO74H.js → chunk-MYKK3Q5G.js} +1 -1
  32. package/dist/safe-bash/command-chunks/{chunk-GZOUGVVV.js → chunk-OYZ534IK.js} +1 -1
  33. package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
  34. package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
  35. package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-UJOO6DKY.js} +20 -9
  36. package/dist/safe-bash/command-chunks/{chunk-TFZEYNMX.js → chunk-VQLFJCG7.js} +1 -1
  37. package/dist/safe-bash/command-chunks/{chunk-BIXN77VL.js → chunk-VUG324ER.js} +10 -0
  38. package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
  39. package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
  40. package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-XNHSCU6I.js} +7 -3
  41. package/dist/safe-bash/commands/basic.js +148 -48
  42. package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
  43. package/dist/safe-bash/commands/cmp.d.ts +2 -3
  44. package/dist/safe-bash/commands/cmp.js +2 -689
  45. package/dist/safe-bash/commands/docx/index.browser.js +3 -46
  46. package/dist/safe-bash/commands/docx/index.d.ts +2 -24
  47. package/dist/safe-bash/commands/docx/index.js +2 -41
  48. package/dist/safe-bash/commands/docx/io.d.ts +1 -14
  49. package/dist/safe-bash/commands/docx/io.js +1 -15
  50. package/dist/safe-bash/commands/llm/index.browser.js +3 -3
  51. package/dist/safe-bash/commands/network/index.browser.js +3 -3
  52. package/dist/safe-bash/commands/node/index.browser.js +3 -3
  53. package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
  54. package/dist/safe-bash/commands/pptx/index.js +2 -152
  55. package/dist/safe-bash/commands/printf-float.d.ts +1 -0
  56. package/dist/safe-bash/commands/printf-float.js +48 -38
  57. package/dist/safe-bash/commands/printf-format.js +9 -6
  58. package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
  59. package/dist/safe-bash/commands/printf-quote.js +62 -0
  60. package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
  61. package/dist/safe-bash/commands/printf-wide.js +41 -0
  62. package/dist/safe-bash/commands/python/index.browser.js +2 -2
  63. package/dist/safe-bash/commands/truncate.d.ts +2 -3
  64. package/dist/safe-bash/commands/truncate.js +2 -686
  65. package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
  66. package/dist/safe-bash/contracts/diagnostics.js +2 -0
  67. package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
  68. package/dist/safe-bash/contracts/runtime-control.js +2 -0
  69. package/dist/safe-bash/core.browser.d.ts +1 -1
  70. package/dist/safe-bash/core.browser.js +2651 -4871
  71. package/dist/safe-bash/core.d.ts +10 -0
  72. package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
  73. package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
  74. package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
  75. package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
  76. package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
  77. package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
  78. package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
  79. package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
  80. package/dist/safe-bash/optional-host.browser.js +9 -1
  81. package/dist/safe-bash/optional-host.d.ts +3 -1
  82. package/dist/safe-bash/optional-host.js +3 -1
  83. package/dist/safe-bash/shell/runtime.js +10 -6
  84. package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
  85. package/dist/safe-bash-checksum-engine/index.js +14 -2
  86. package/dist/safe-bash-command-bzip2/index.js +2 -1
  87. package/dist/safe-bash-command-cmp/index.d.ts +10 -0
  88. package/dist/safe-bash-command-cmp/index.js +796 -0
  89. package/dist/safe-bash-command-cmp/options.d.ts +12 -0
  90. package/dist/safe-bash-command-cmp/options.js +42 -0
  91. package/dist/safe-bash-command-csvcut/index.js +11 -8
  92. package/dist/safe-bash-command-csvgrep/index.js +35 -7
  93. package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
  94. package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
  95. package/dist/safe-bash-command-csvkit/index.js +80 -324
  96. package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
  97. package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
  98. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  99. package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
  100. package/dist/safe-bash-command-diff3/index.js +3 -0
  101. package/dist/safe-bash-command-docx/LICENSE +21 -0
  102. package/dist/safe-bash-command-docx/index.d.ts +30 -0
  103. package/dist/safe-bash-command-docx/index.js +67 -0
  104. package/dist/safe-bash-command-docx/io.d.ts +14 -0
  105. package/dist/safe-bash-command-docx/io.js +26 -0
  106. package/dist/safe-bash-command-envsubst/index.js +34 -3
  107. package/dist/safe-bash-command-exiftool/index.js +3 -0
  108. package/dist/safe-bash-command-ffmpeg/index.js +1102 -1088
  109. package/dist/safe-bash-command-fold/family.js +1 -1
  110. package/dist/safe-bash-command-fold/index.js +1 -1
  111. package/dist/safe-bash-command-htmlq/index.js +5 -0
  112. package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
  113. package/dist/safe-bash-command-imagemagick/index.js +669 -271
  114. package/dist/safe-bash-command-mmdc/index.js +48 -10
  115. package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
  116. package/dist/safe-bash-command-op/index.js +19 -14
  117. package/dist/safe-bash-command-pandoc/command.js +1 -1
  118. package/dist/safe-bash-command-pandoc/index.js +1 -1
  119. package/dist/safe-bash-command-pdfimages/index.d.ts +7 -1
  120. package/dist/safe-bash-command-pdfimages/index.js +63 -33
  121. package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
  122. package/dist/safe-bash-command-pdfinfo/index.js +370 -161
  123. package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
  124. package/dist/safe-bash-command-pdftk/index.js +114 -45
  125. package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
  126. package/dist/safe-bash-command-pdftoppm/index.js +179 -109
  127. package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
  128. package/dist/safe-bash-command-pdftotext/index.js +90 -27
  129. package/dist/safe-bash-command-pptx/LICENSE +21 -0
  130. package/dist/safe-bash-command-pptx/index.d.ts +33 -0
  131. package/dist/safe-bash-command-pptx/index.js +168 -0
  132. package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
  133. package/dist/safe-bash-command-qpdf/index.js +80 -29
  134. package/dist/safe-bash-command-sha512sum/index.js +12 -475
  135. package/dist/safe-bash-command-sips/index.d.ts +9 -5
  136. package/dist/safe-bash-command-sips/index.js +63 -44
  137. package/dist/safe-bash-command-soffice/index.d.ts +9 -3
  138. package/dist/safe-bash-command-soffice/index.js +65 -24
  139. package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
  140. package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
  141. package/dist/safe-bash-command-sqlite3/index.js +851 -352
  142. package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
  143. package/dist/safe-bash-command-timeout/index.js +3 -3
  144. package/dist/safe-bash-command-truncate/index.d.ts +8 -3
  145. package/dist/safe-bash-command-truncate/index.js +790 -272
  146. package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
  147. package/dist/safe-bash-command-truncate/sync.js +60 -0
  148. package/dist/safe-bash-command-wkhtmltopdf/index.js +92 -38
  149. package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
  150. package/dist/safe-bash-command-xxd/index.js +78 -20
  151. package/dist/safe-bash-command-xz/command.d.ts +4 -0
  152. package/dist/safe-bash-command-xz/index.d.ts +1 -1
  153. package/dist/safe-bash-command-xz/index.js +1 -1
  154. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  155. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  156. package/dist/safe-bash-compression-engine/files.js +6 -6
  157. package/dist/safe-bash-compression-engine/index.js +5 -5
  158. package/dist/safe-bash-compression-engine/operand.js +6 -6
  159. package/dist/safe-bash-compression-engine/stream.js +5 -5
  160. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  161. package/dist/safe-bash-contracts/command.js +3 -3
  162. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  163. package/dist/safe-bash-contracts/escaping.js +9 -9
  164. package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
  165. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  166. package/dist/safe-bash-contracts/index.js +21 -19
  167. package/dist/safe-bash-contracts/io.d.ts +12 -0
  168. package/dist/safe-bash-contracts/io.js +4 -1
  169. package/dist/safe-bash-contracts/output.js +3 -2
  170. package/dist/safe-bash-contracts/runtime-control.js +2 -2
  171. package/dist/safe-bash-contracts/signals.js +1 -1
  172. package/dist/safe-bash-contracts/yield.d.ts +1 -0
  173. package/dist/safe-bash-contracts/yield.js +3 -1
  174. package/dist/safe-bash-csv-engine/index.d.ts +10 -1
  175. package/dist/safe-bash-csv-engine/index.js +78 -6
  176. package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
  177. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
  178. package/dist/safe-bash-io-engine/gnu-information.js +1 -1
  179. package/dist/safe-bash-io-engine/internal.d.ts +1 -1
  180. package/dist/safe-bash-io-engine/internal.js +2 -2
  181. package/dist/safe-bash-mcp/index.browser.d.ts +875 -0
  182. package/dist/safe-bash-mcp/index.browser.js +8740 -0
  183. package/dist/safe-bash-mcp/index.js +32 -31
  184. package/dist/safe-bash-query-engine/capture.js +3 -3
  185. package/dist/safe-bash-query-engine/delpaths.js +3 -3
  186. package/dist/safe-bash-query-engine/formats.js +2 -2
  187. package/dist/safe-bash-query-engine/index.js +12 -12
  188. package/dist/safe-bash-query-engine/indices.js +3 -3
  189. package/dist/safe-bash-query-engine/input.js +1 -1
  190. package/dist/safe-bash-query-engine/interpreter.js +10 -10
  191. package/dist/safe-bash-query-engine/query-core.js +12 -12
  192. package/dist/safe-bash-query-engine/regex.js +3 -3
  193. package/dist/safe-bash-query-engine/splits.js +4 -4
  194. package/dist/safe-bash-query-engine/values.js +2 -2
  195. package/package.json +9 -3
  196. package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
  197. package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
  198. package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2VTMZTV3.js} +0 -0
  199. package/dist/safe-bash/command-chunks/{chunk-DEH3CMGL.js → chunk-QJ3ONEBI.js} +3 -3
@@ -211,22 +211,8 @@ function getOwnEntry(record3, key2) {
211
211
  return Object.prototype.hasOwnProperty.call(record3, key2) ? record3[key2] : void 0;
212
212
  }
213
213
 
214
- // ../mcp-oauth/dist/client/loopback-authorization.js
214
+ // ../mcp-oauth/dist/client/authorization-error.js
215
215
  var authorizationErrorBrand = /* @__PURE__ */ Symbol.for("poe-platform.mcp-oauth.OAuthAuthorizationError");
216
- var oauthCallbackParameters = ["code", "state", "iss", "error", "error_description", "error_uri"];
217
- function snapshotLoopbackAuthorizationOptions(options) {
218
- return {
219
- ...options,
220
- openBrowser: options.openBrowser?.bind(options),
221
- readLine: options.readLine?.bind(options),
222
- createServer: options.createServer?.bind(options),
223
- callbackPath: options.callbackPath,
224
- redirectUri: options.redirectUri,
225
- signal: options.signal,
226
- timeoutMs: options.timeoutMs,
227
- landingPage: options.landingPage === void 0 ? void 0 : { ...options.landingPage, title: options.landingPage.title, body: options.landingPage.body }
228
- };
229
- }
230
216
  var OAuthAuthorizationError = class extends Error {
231
217
  error;
232
218
  errorDescription;
@@ -242,6 +228,22 @@ var OAuthAuthorizationError = class extends Error {
242
228
  Object.defineProperty(this, authorizationErrorBrand, { value: true });
243
229
  }
244
230
  };
231
+
232
+ // ../mcp-oauth/dist/client/loopback-authorization.js
233
+ var oauthCallbackParameters = ["code", "state", "iss", "error", "error_description", "error_uri"];
234
+ function snapshotLoopbackAuthorizationOptions(options) {
235
+ return {
236
+ ...options,
237
+ openBrowser: options.openBrowser?.bind(options),
238
+ readLine: options.readLine?.bind(options),
239
+ createServer: options.createServer?.bind(options),
240
+ callbackPath: options.callbackPath,
241
+ redirectUri: options.redirectUri,
242
+ signal: options.signal,
243
+ timeoutMs: options.timeoutMs,
244
+ landingPage: options.landingPage === void 0 ? void 0 : { ...options.landingPage, title: options.landingPage.title, body: options.landingPage.body }
245
+ };
246
+ }
245
247
  async function createLoopbackAuthorizationSession(options = {}) {
246
248
  options = snapshotLoopbackAuthorizationOptions(options);
247
249
  options.signal?.throwIfAborted();
@@ -2867,7 +2869,6 @@ import path32 from "node:path";
2867
2869
  import { isIP as isIP2 } from "node:net";
2868
2870
  import { URL as URL22 } from "node:url";
2869
2871
  import crypto32 from "node:crypto";
2870
- import { isIP as isIP22 } from "node:net";
2871
2872
  var __defProp = Object.defineProperty;
2872
2873
  var __getOwnPropNames = Object.getOwnPropertyNames;
2873
2874
  var __esm = (fn, res, err) => function __init() {
@@ -6430,20 +6431,6 @@ function getOwnEntry7(record22, key2) {
6430
6431
  return Object.prototype.hasOwnProperty.call(record22, key2) ? record22[key2] : void 0;
6431
6432
  }
6432
6433
  var authorizationErrorBrand2 = /* @__PURE__ */ Symbol.for("poe-platform.mcp-oauth.OAuthAuthorizationError");
6433
- var oauthCallbackParameters2 = ["code", "state", "iss", "error", "error_description", "error_uri"];
6434
- function snapshotLoopbackAuthorizationOptions2(options) {
6435
- return {
6436
- ...options,
6437
- openBrowser: options.openBrowser?.bind(options),
6438
- readLine: options.readLine?.bind(options),
6439
- createServer: options.createServer?.bind(options),
6440
- callbackPath: options.callbackPath,
6441
- redirectUri: options.redirectUri,
6442
- signal: options.signal,
6443
- timeoutMs: options.timeoutMs,
6444
- landingPage: options.landingPage === void 0 ? void 0 : { ...options.landingPage, title: options.landingPage.title, body: options.landingPage.body }
6445
- };
6446
- }
6447
6434
  var OAuthAuthorizationError2 = class extends Error {
6448
6435
  error;
6449
6436
  errorDescription;
@@ -6459,6 +6446,20 @@ var OAuthAuthorizationError2 = class extends Error {
6459
6446
  Object.defineProperty(this, authorizationErrorBrand2, { value: true });
6460
6447
  }
6461
6448
  };
6449
+ var oauthCallbackParameters2 = ["code", "state", "iss", "error", "error_description", "error_uri"];
6450
+ function snapshotLoopbackAuthorizationOptions2(options) {
6451
+ return {
6452
+ ...options,
6453
+ openBrowser: options.openBrowser?.bind(options),
6454
+ readLine: options.readLine?.bind(options),
6455
+ createServer: options.createServer?.bind(options),
6456
+ callbackPath: options.callbackPath,
6457
+ redirectUri: options.redirectUri,
6458
+ signal: options.signal,
6459
+ timeoutMs: options.timeoutMs,
6460
+ landingPage: options.landingPage === void 0 ? void 0 : { ...options.landingPage, title: options.landingPage.title, body: options.landingPage.body }
6461
+ };
6462
+ }
6462
6463
  async function createLoopbackAuthorizationSession2(options = {}) {
6463
6464
  options = snapshotLoopbackAuthorizationOptions2(options);
6464
6465
  options.signal?.throwIfAborted();
@@ -9140,7 +9141,7 @@ function normalizeHostname22(hostname22) {
9140
9141
  }
9141
9142
  function isLoopbackHostname22(hostname22) {
9142
9143
  const normalizedHostname = normalizeHostname22(hostname22);
9143
- return normalizedHostname === "localhost" || normalizedHostname === "::1" || normalizedHostname === "[::1]" || isIP22(normalizedHostname) === 4 && normalizedHostname.startsWith("127.");
9144
+ return normalizedHostname === "localhost" || normalizedHostname === "::1" || normalizedHostname === "[::1]" || normalizedHostname.startsWith("127.") && normalizedHostname.split(".").length === 4 && normalizedHostname.split(".").every((part) => part.length > 0 && [...part].every((char) => char >= "0" && char <= "9") && Number(part) <= 255);
9144
9145
  }
9145
9146
  function assertSecureUrl22(url, label) {
9146
9147
  if (url.username !== "" || url.password !== "" || url.href.includes("#")) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  capture
3
- } from "../safe-bash/command-chunks/chunk-GZOUGVVV.js";
4
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
3
+ } from "../safe-bash/command-chunks/chunk-OYZ534IK.js";
4
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
5
5
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
6
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
6
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
7
7
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
8
8
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
9
9
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  delpaths
3
- } from "../safe-bash/command-chunks/chunk-TFZEYNMX.js";
4
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
3
+ } from "../safe-bash/command-chunks/chunk-VQLFJCG7.js";
4
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
5
5
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
6
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
6
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
7
7
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
8
8
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
9
9
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  formatValue
3
- } from "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
4
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
3
+ } from "../safe-bash/command-chunks/chunk-HETU7MYN.js";
4
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
5
5
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
6
6
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
7
7
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  YqValueFailure,
3
3
  createYqQuerySession
4
- } from "../safe-bash/command-chunks/chunk-DREUDEQG.js";
5
- import "../safe-bash/command-chunks/chunk-BUKYQBXO.js";
6
- import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
7
- import "../safe-bash/command-chunks/chunk-NSEUBSOD.js";
8
- import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
9
- import "../safe-bash/command-chunks/chunk-TFZEYNMX.js";
10
- import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
11
- import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
4
+ } from "../safe-bash/command-chunks/chunk-AT6ZSOE6.js";
12
5
  import "../safe-bash/command-chunks/chunk-JUMF6JDJ.js";
13
- import "../safe-bash/command-chunks/chunk-GZOUGVVV.js";
14
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
15
- import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
16
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
6
+ import "../safe-bash/command-chunks/chunk-BJ6DGYJA.js";
7
+ import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
8
+ import "../safe-bash/command-chunks/chunk-CXMOCPPH.js";
9
+ import "../safe-bash/command-chunks/chunk-3KROFHBT.js";
17
10
  import "../safe-bash/command-chunks/chunk-SNXWY3KV.js";
11
+ import "../safe-bash/command-chunks/chunk-VQLFJCG7.js";
12
+ import "../safe-bash/command-chunks/chunk-HETU7MYN.js";
13
+ import "../safe-bash/command-chunks/chunk-MYKK3Q5G.js";
14
+ import "../safe-bash/command-chunks/chunk-OYZ534IK.js";
15
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
16
+ import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
17
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
18
18
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
19
19
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
20
20
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  indices
3
- } from "../safe-bash/command-chunks/chunk-Z47EO74H.js";
4
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
3
+ } from "../safe-bash/command-chunks/chunk-MYKK3Q5G.js";
4
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
5
5
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
6
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
6
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
7
7
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
8
8
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
9
9
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -14,7 +14,7 @@ import {
14
14
  tryProcessFlatSelectProjectChunkSync,
15
15
  tryStringifyCompactSync,
16
16
  tryWriteCompactSync
17
- } from "../safe-bash/command-chunks/chunk-BIXN77VL.js";
17
+ } from "../safe-bash/command-chunks/chunk-VUG324ER.js";
18
18
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
19
19
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
20
20
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  Interpreter
3
- } from "../safe-bash/command-chunks/chunk-BUKYQBXO.js";
3
+ } from "../safe-bash/command-chunks/chunk-BJ6DGYJA.js";
4
4
  import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
5
- import "../safe-bash/command-chunks/chunk-NSEUBSOD.js";
6
- import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
7
- import "../safe-bash/command-chunks/chunk-TFZEYNMX.js";
8
- import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
9
- import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
10
- import "../safe-bash/command-chunks/chunk-GZOUGVVV.js";
11
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
12
- import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
13
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
5
+ import "../safe-bash/command-chunks/chunk-CXMOCPPH.js";
6
+ import "../safe-bash/command-chunks/chunk-3KROFHBT.js";
14
7
  import "../safe-bash/command-chunks/chunk-SNXWY3KV.js";
8
+ import "../safe-bash/command-chunks/chunk-VQLFJCG7.js";
9
+ import "../safe-bash/command-chunks/chunk-HETU7MYN.js";
10
+ import "../safe-bash/command-chunks/chunk-MYKK3Q5G.js";
11
+ import "../safe-bash/command-chunks/chunk-OYZ534IK.js";
12
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
13
+ import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
14
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
15
15
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
16
16
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
17
17
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  YqValueFailure,
3
3
  createYqQuerySession
4
- } from "../safe-bash/command-chunks/chunk-DREUDEQG.js";
5
- import "../safe-bash/command-chunks/chunk-BUKYQBXO.js";
6
- import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
7
- import "../safe-bash/command-chunks/chunk-NSEUBSOD.js";
8
- import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
9
- import "../safe-bash/command-chunks/chunk-TFZEYNMX.js";
10
- import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
11
- import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
4
+ } from "../safe-bash/command-chunks/chunk-AT6ZSOE6.js";
12
5
  import "../safe-bash/command-chunks/chunk-JUMF6JDJ.js";
13
- import "../safe-bash/command-chunks/chunk-GZOUGVVV.js";
14
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
15
- import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
16
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
6
+ import "../safe-bash/command-chunks/chunk-BJ6DGYJA.js";
7
+ import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
8
+ import "../safe-bash/command-chunks/chunk-CXMOCPPH.js";
9
+ import "../safe-bash/command-chunks/chunk-3KROFHBT.js";
17
10
  import "../safe-bash/command-chunks/chunk-SNXWY3KV.js";
11
+ import "../safe-bash/command-chunks/chunk-VQLFJCG7.js";
12
+ import "../safe-bash/command-chunks/chunk-HETU7MYN.js";
13
+ import "../safe-bash/command-chunks/chunk-MYKK3Q5G.js";
14
+ import "../safe-bash/command-chunks/chunk-OYZ534IK.js";
15
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
16
+ import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
17
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
18
18
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
19
19
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
20
20
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -2,10 +2,10 @@ import {
2
2
  regexError,
3
3
  scanRegex,
4
4
  substituteRegex
5
- } from "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
6
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
5
+ } from "../safe-bash/command-chunks/chunk-3KROFHBT.js";
6
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
7
7
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
8
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
8
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
9
9
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
10
10
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
11
11
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  splitRegex
3
- } from "../safe-bash/command-chunks/chunk-NSEUBSOD.js";
4
- import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
5
- import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
3
+ } from "../safe-bash/command-chunks/chunk-CXMOCPPH.js";
4
+ import "../safe-bash/command-chunks/chunk-3KROFHBT.js";
5
+ import "../safe-bash/command-chunks/chunk-5L62A5RO.js";
6
6
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
7
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
7
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
8
8
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
9
9
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
10
10
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
@@ -14,9 +14,9 @@ import {
14
14
  stringCompare,
15
15
  stringCompareMaybeSync,
16
16
  type
17
- } from "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
17
+ } from "../safe-bash/command-chunks/chunk-5L62A5RO.js";
18
18
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
19
- import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
19
+ import "../safe-bash/command-chunks/chunk-VUG324ER.js";
20
20
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
21
21
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
22
22
  import "../safe-bash/command-chunks/chunk-W3UCANZ3.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.787",
3
+ "version": "0.1.789",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,7 +41,13 @@
41
41
  "import": "./dist/safe-bash-command-ssconvert/commands.js"
42
42
  },
43
43
  "./mcp": {
44
- "types": "./dist/safe-bash-mcp/index.d.ts",
44
+ "types": {
45
+ "workerd": "./dist/safe-bash-mcp/index.browser.d.ts",
46
+ "browser": "./dist/safe-bash-mcp/index.browser.d.ts",
47
+ "default": "./dist/safe-bash-mcp/index.d.ts"
48
+ },
49
+ "workerd": "./dist/safe-bash-mcp/index.browser.js",
50
+ "browser": "./dist/safe-bash-mcp/index.browser.js",
45
51
  "import": "./dist/safe-bash-mcp/index.js"
46
52
  },
47
53
  "./playwright/cloudflare": {
@@ -841,7 +847,7 @@
841
847
  "access": "public"
842
848
  },
843
849
  "dependencies": {
844
- "@poe-platform/safe-fs": "0.1.787",
850
+ "@poe-platform/safe-fs": "0.1.789",
845
851
  "pdf-lib": "1.17.1",
846
852
  "@noble/hashes": "2.4.0",
847
853
  "pako": "3.0.1",
@@ -1,95 +0,0 @@
1
- import { InputError, observe } from "./io.js";
2
- import { integerMaximum, quote } from "./options.js";
3
- import { yieldTurn } from "@poe-platform/safe-bash/contracts/yield";
4
- function displayByte(byte) {
5
- const high = byte >= 128;
6
- const value = high ? byte - 128 : byte;
7
- return `${high ? "M-" : ""}${value < 32 ? `^${String.fromCharCode(value + 64)}` : value === 127 ? "^?" : String.fromCharCode(value)}`;
8
- }
9
- function remaining(input, skip) {
10
- if (input.stat?.type !== "file" || !Number.isSafeInteger(input.stat.size) || input.stat.size < 0)
11
- return undefined;
12
- const size = BigInt(input.stat.size);
13
- return skip < size ? size - skip : 0n;
14
- }
15
- export async function compare(session, args) {
16
- const left = await session.open(args.files[0]);
17
- if (args.files[0] === args.files[1] && (args.files[0] === "-" || args.skips[0] === args.skips[1] && args.skips[0] <= integerMaximum))
18
- return 0;
19
- const right = await session.open(args.files[1]);
20
- if (left.path !== undefined && right.path !== undefined && args.skips[0] === args.skips[1] && args.skips[0] <= integerMaximum
21
- && session.context.fs.compareEntry && await observe(() => session.context.fs.compareEntry(left.path, session.context.fs, right.path, { signal: session.signal }), session.signal) === "same")
22
- return 0;
23
- const sizes = [remaining(left, args.skips[0]), remaining(right, args.skips[1])];
24
- if (args.mode === "silent" && sizes[0] !== undefined && sizes[1] !== undefined && sizes[0] !== sizes[1]
25
- && (sizes[0] < sizes[1] ? sizes[0] : sizes[1]) < args.count)
26
- return 1;
27
- const comparisonBlockBytes = session.comparisonBlockBytes ?? left.stat?.ioBlockSize ?? 65536;
28
- if (!Number.isSafeInteger(comparisonBlockBytes) || comparisonBlockBytes < 1) {
29
- throw new InputError(left.name, new Error("invalid preferred I/O block size"), false);
30
- }
31
- let maximum = args.count;
32
- for (const size of sizes)
33
- if (size !== undefined && size < maximum)
34
- maximum = size;
35
- const width = maximum.toString().length;
36
- const inputs = [left, right];
37
- const cursors = inputs.map((input, index) => session.cursor(input, args.skips[index]));
38
- for (let index = 0; index < 2; index++) {
39
- const skip = args.skips[index];
40
- if (skip > integerMaximum && inputs[index].stat?.type !== "file")
41
- throw new InputError(inputs[index].name, new Error("Value too large to be stored in data type"), false);
42
- if (inputs[index].path === undefined || session.context.fs.readStream && (inputs[index].stat?.type !== "file" || inputs[index].stat.size < 0))
43
- await cursors[index].skip(skip);
44
- if (inputs[index].stat?.type === "directory")
45
- await cursors[index].available();
46
- }
47
- let compared = 0n, line = 1n, atLineStart = true, work = 0;
48
- while (true) {
49
- const remaining = args.count - compared;
50
- const requested = Number(remaining < BigInt(comparisonBlockBytes) ? remaining : BigInt(comparisonBlockBytes));
51
- const first = await cursors[0].block(requested), second = await cursors[1].block(requested);
52
- const count = Math.min(first.length, second.length);
53
- let different = false, output = "";
54
- for (let offset = 0; offset < count; offset++) {
55
- const byteLeft = first[offset], byteRight = second[offset];
56
- compared++;
57
- if (byteLeft !== byteRight) {
58
- different = true;
59
- if (args.mode === "silent")
60
- return 1;
61
- const octalLeft = byteLeft.toString(8).padStart(3, " "), octalRight = byteRight.toString(8).padStart(3, " ");
62
- if (args.mode === "first") {
63
- await session.output(`${left.name} ${right.name} differ: ${args.printBytes ? "byte" : "char"} ${compared}, line ${line}${args.printBytes ? ` is ${octalLeft} ${displayByte(byteLeft)} ${octalRight} ${displayByte(byteRight)}` : ""}\n`);
64
- return 1;
65
- }
66
- output += `${compared.toString().padStart(width, " ")} ${octalLeft} ${args.printBytes ? `${displayByte(byteLeft).padEnd(4, " ")} ` : ""}${octalRight}${args.printBytes ? ` ${displayByte(byteRight)}` : ""}\n`;
67
- if (output.length >= 16384) {
68
- await session.output(output);
69
- output = "";
70
- }
71
- }
72
- if (byteLeft === 10)
73
- line++;
74
- atLineStart = byteLeft === 10;
75
- }
76
- if (output)
77
- await session.output(output);
78
- if (first.length !== second.length) {
79
- if (args.mode !== "silent") {
80
- const name = first.length < second.length ? left.name : right.name;
81
- const extra = compared === 0n ? "which is empty" : args.mode === "all" ? `after byte ${compared}`
82
- : `after byte ${compared}, ${atLineStart ? "line" : "in line"} ${atLineStart ? line - 1n : line}`;
83
- await session.output(`cmp: EOF on ${quote(name)} ${extra}\n`, true);
84
- }
85
- return 1;
86
- }
87
- if (first.length !== comparisonBlockBytes)
88
- return different ? 1 : 0;
89
- work += count;
90
- if (work >= 65536) {
91
- await yieldTurn(session.signal);
92
- work = 0;
93
- }
94
- }
95
- }
@@ -1,218 +0,0 @@
1
- import { FsError, readBytes, resolvePath, writeBytes } from "@poe-platform/safe-bash/contracts";
2
- import { integerMaximum, pathQuote } from "./options.js";
3
- import { yieldTurn } from "@poe-platform/safe-bash/contracts/yield";
4
- export async function observe(operation, signal) {
5
- signal.throwIfAborted();
6
- return new Promise((resolve, reject) => {
7
- const abort = () => { signal.removeEventListener("abort", abort); reject(signal.reason); };
8
- signal.addEventListener("abort", abort, { once: true });
9
- Promise.resolve().then(() => { signal.throwIfAborted(); return operation(); }).then(value => {
10
- signal.removeEventListener("abort", abort);
11
- resolve(value);
12
- }, error => {
13
- signal.removeEventListener("abort", abort);
14
- reject(error);
15
- });
16
- });
17
- }
18
- export class InputError extends Error {
19
- operand;
20
- reason;
21
- opening;
22
- constructor(operand, reason, opening) {
23
- super("cmp input failure");
24
- this.operand = operand;
25
- this.reason = reason;
26
- this.opening = opening;
27
- }
28
- }
29
- const errnoMessages = {
30
- ENOENT: "No such file or directory", EACCES: "Permission denied", EPERM: "Operation not permitted",
31
- EISDIR: "Is a directory", ENOTDIR: "Not a directory", EIO: "Input/output error", EBADF: "Bad file descriptor",
32
- ELOOP: "Too many levels of symbolic links", ENAMETOOLONG: "File name too long", ENOSPC: "No space left on device",
33
- EMFILE: "Too many open files", ENFILE: "Too many open files in system", EPIPE: "Broken pipe",
34
- EOVERFLOW: "Value too large to be stored in data type", ENOTSUP: "Operation not supported", EFBIG: "File too large",
35
- };
36
- export function errorText(error) {
37
- if (error instanceof FsError)
38
- return errnoMessages[error.code] ?? error.message;
39
- return error instanceof Error ? error.message : String(error);
40
- }
41
- export class Cursor {
42
- operand;
43
- signal;
44
- maxChunkBytes;
45
- reader;
46
- chunk = new Uint8Array();
47
- offset = 0;
48
- done = false;
49
- closed;
50
- returned;
51
- untilYield = 65536;
52
- constructor(operand, source, signal, maxChunkBytes) {
53
- this.operand = operand;
54
- this.signal = signal;
55
- this.maxChunkBytes = maxChunkBytes;
56
- this.reader = readBytes({
57
- [Symbol.asyncIterator]: () => {
58
- const iterator = source[Symbol.asyncIterator]();
59
- return {
60
- next: () => iterator.next(),
61
- return: () => {
62
- this.returned ??= Promise.resolve().then(() => iterator.return ? iterator.return() : { value: undefined, done: true });
63
- return this.returned;
64
- },
65
- };
66
- },
67
- }, signal);
68
- }
69
- async available() {
70
- try {
71
- this.signal.throwIfAborted();
72
- while (!this.done && this.offset === this.chunk.length) {
73
- if (this.untilYield <= 0) {
74
- await yieldTurn(this.signal);
75
- this.untilYield = 65536;
76
- }
77
- const next = await this.reader.next();
78
- this.done = Boolean(next.done);
79
- if (next.done) {
80
- this.chunk = new Uint8Array();
81
- this.offset = 0;
82
- break;
83
- }
84
- if (next.value.byteLength > this.maxChunkBytes)
85
- throw new Error("input chunk bytes limit exceeded");
86
- this.untilYield -= Math.max(64, next.value.byteLength);
87
- this.chunk = new Uint8Array(next.value);
88
- this.offset = 0;
89
- }
90
- return this.chunk.subarray(this.offset);
91
- }
92
- catch (error) {
93
- this.signal.throwIfAborted();
94
- throw new InputError(this.operand, error, false);
95
- }
96
- }
97
- consume(count) { this.offset += count; }
98
- async block(count) {
99
- const bytes = new Uint8Array(count);
100
- let size = 0;
101
- while (size < count) {
102
- const chunk = await this.available();
103
- if (!chunk.length)
104
- break;
105
- const length = Math.min(count - size, chunk.length);
106
- bytes.set(chunk.subarray(0, length), size);
107
- this.consume(length);
108
- size += length;
109
- }
110
- return bytes.subarray(0, size);
111
- }
112
- async skip(count) {
113
- while (count > 0n) {
114
- const chunk = await this.available();
115
- if (!chunk.length)
116
- break;
117
- const amount = Number(count < BigInt(chunk.length) ? count : BigInt(chunk.length));
118
- this.consume(amount);
119
- count -= BigInt(amount);
120
- }
121
- }
122
- close() {
123
- this.closed ??= (async () => {
124
- try {
125
- await this.reader.return(undefined);
126
- await this.returned;
127
- }
128
- catch (error) {
129
- throw new InputError(this.operand, error, false);
130
- }
131
- finally {
132
- this.chunk = new Uint8Array();
133
- }
134
- })();
135
- return this.closed;
136
- }
137
- }
138
- export class Session {
139
- context;
140
- limits;
141
- comparisonBlockBytes;
142
- controller = new AbortController();
143
- signal;
144
- cursors = [];
145
- closed;
146
- constructor(context, limits, comparisonBlockBytes) {
147
- this.context = context;
148
- this.limits = limits;
149
- this.comparisonBlockBytes = comparisonBlockBytes;
150
- this.signal = AbortSignal.any([context.signal, this.controller.signal]);
151
- context.registerCleanup?.(() => this.close());
152
- }
153
- async open(name) {
154
- this.signal.throwIfAborted();
155
- if (name === "-")
156
- return { name };
157
- try {
158
- if (!name)
159
- throw new FsError("ENOENT");
160
- const path = resolvePath(this.context.cwd, name);
161
- const stat = await observe(() => this.context.fs.stat(path, { signal: this.signal }), this.signal);
162
- this.signal.throwIfAborted();
163
- await observe(() => this.context.fs.access(path, 4, { signal: this.signal }), this.signal);
164
- this.signal.throwIfAborted();
165
- return { name, path, stat };
166
- }
167
- catch (error) {
168
- this.signal.throwIfAborted();
169
- throw new InputError(name, error, true);
170
- }
171
- }
172
- cursor(input, skip) {
173
- this.signal.throwIfAborted();
174
- const { context, signal, limits } = this;
175
- const source = input.path === undefined ? context.stdin : (async function* () {
176
- if (input.stat?.type === "directory")
177
- throw new FsError("EISDIR");
178
- if (skip > integerMaximum && input.stat?.type === "file")
179
- return;
180
- if (context.fs.readStream) {
181
- const start = input.stat?.type === "file" && input.stat.size >= 0 ? Number(skip < BigInt(Number.MAX_SAFE_INTEGER) ? skip : BigInt(Number.MAX_SAFE_INTEGER)) : 0;
182
- yield* context.fs.readStream(input.path, { signal, start, chunkSize: Math.min(65536, limits.maxChunkBytes) });
183
- }
184
- else {
185
- if (!input.stat || !Number.isSafeInteger(input.stat.size) || input.stat.size < 0 || input.stat.size > limits.maxFallbackBytes) {
186
- throw new Error("bounded comparison requires readStream or a file within maxFallbackBytes");
187
- }
188
- const bytes = await observe(() => context.fs.readFile(input.path, { signal, ...(Number.isFinite(limits.maxFallbackBytes) ? { maxBytes: limits.maxFallbackBytes } : {}) }), signal);
189
- if (bytes.length > limits.maxFallbackBytes)
190
- throw new Error("input fallback bytes limit exceeded");
191
- for (let offset = Number(skip < BigInt(bytes.length) ? skip : BigInt(bytes.length)); offset < bytes.length; offset += limits.maxChunkBytes)
192
- yield bytes.subarray(offset, offset + limits.maxChunkBytes);
193
- }
194
- })();
195
- const cursor = new Cursor(input.name, source, signal, limits.maxChunkBytes);
196
- this.cursors.push(cursor);
197
- return cursor;
198
- }
199
- async output(text, stderr = false) {
200
- await writeBytes(stderr ? this.context.stderr : this.context.stdout, new TextEncoder().encode(text), this.signal);
201
- }
202
- close(cancel = true) {
203
- if (!this.closed) {
204
- this.closed = Promise.resolve().then(async () => {
205
- const results = await Promise.allSettled(this.cursors.map(cursor => cursor.close()));
206
- const failure = results.find(result => result.status === "rejected");
207
- if (failure?.status === "rejected")
208
- throw failure.reason;
209
- });
210
- if (cancel)
211
- this.controller.abort(new Error("cmp invocation closed"));
212
- }
213
- return this.closed;
214
- }
215
- }
216
- export function inputDiagnostic(error) {
217
- return `cmp: ${pathQuote(error.operand)}: ${errorText(error.reason)}\n`;
218
- }