@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.
- package/README.md +1 -1
- package/dist/safe-bash/chunks/{chunk-WHURJBET.js → chunk-2MUJ7RLZ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-CTUHLNJM.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-D4PHJK4T.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-O6356Z27.js → chunk-H7MMJS26.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-KHJGUF2W.js} +14 -0
- package/dist/safe-bash/chunks/{chunk-FJZNUUOQ.js → chunk-VUVKC6HV.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-X5ZCECM6.js} +2 -2
- package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-HO7WDPHZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
- package/dist/safe-bash/command-chunks/{chunk-WVWWRMFD.js → chunk-3KROFHBT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
- package/dist/safe-bash/command-chunks/{chunk-IFUNAM4D.js → chunk-5L62A5RO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
- package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-6F7QJMJ3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-DREUDEQG.js → chunk-AT6ZSOE6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-BUKYQBXO.js → chunk-BJ6DGYJA.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-NSEUBSOD.js → chunk-CXMOCPPH.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
- package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3JS4FOLB.js → chunk-HETU7MYN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
- package/dist/safe-bash/command-chunks/{chunk-Z47EO74H.js → chunk-MYKK3Q5G.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GZOUGVVV.js → chunk-OYZ534IK.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
- package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
- package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-UJOO6DKY.js} +20 -9
- package/dist/safe-bash/command-chunks/{chunk-TFZEYNMX.js → chunk-VQLFJCG7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-BIXN77VL.js → chunk-VUG324ER.js} +10 -0
- package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
- package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
- package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-XNHSCU6I.js} +7 -3
- package/dist/safe-bash/commands/basic.js +148 -48
- package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
- package/dist/safe-bash/commands/cmp.d.ts +2 -3
- package/dist/safe-bash/commands/cmp.js +2 -689
- package/dist/safe-bash/commands/docx/index.browser.js +3 -46
- package/dist/safe-bash/commands/docx/index.d.ts +2 -24
- package/dist/safe-bash/commands/docx/index.js +2 -41
- package/dist/safe-bash/commands/docx/io.d.ts +1 -14
- package/dist/safe-bash/commands/docx/io.js +1 -15
- package/dist/safe-bash/commands/llm/index.browser.js +3 -3
- package/dist/safe-bash/commands/network/index.browser.js +3 -3
- package/dist/safe-bash/commands/node/index.browser.js +3 -3
- package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
- package/dist/safe-bash/commands/pptx/index.js +2 -152
- package/dist/safe-bash/commands/printf-float.d.ts +1 -0
- package/dist/safe-bash/commands/printf-float.js +48 -38
- package/dist/safe-bash/commands/printf-format.js +9 -6
- package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
- package/dist/safe-bash/commands/printf-quote.js +62 -0
- package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
- package/dist/safe-bash/commands/printf-wide.js +41 -0
- package/dist/safe-bash/commands/python/index.browser.js +2 -2
- package/dist/safe-bash/commands/truncate.d.ts +2 -3
- package/dist/safe-bash/commands/truncate.js +2 -686
- package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
- package/dist/safe-bash/contracts/diagnostics.js +2 -0
- package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
- package/dist/safe-bash/contracts/runtime-control.js +2 -0
- package/dist/safe-bash/core.browser.d.ts +1 -1
- package/dist/safe-bash/core.browser.js +2651 -4871
- package/dist/safe-bash/core.d.ts +10 -0
- package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
- package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
- package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
- package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
- package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
- package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
- package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
- package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
- package/dist/safe-bash/optional-host.browser.js +9 -1
- package/dist/safe-bash/optional-host.d.ts +3 -1
- package/dist/safe-bash/optional-host.js +3 -1
- package/dist/safe-bash/shell/runtime.js +10 -6
- package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
- package/dist/safe-bash-checksum-engine/index.js +14 -2
- package/dist/safe-bash-command-bzip2/index.js +2 -1
- package/dist/safe-bash-command-cmp/index.d.ts +10 -0
- package/dist/safe-bash-command-cmp/index.js +796 -0
- package/dist/safe-bash-command-cmp/options.d.ts +12 -0
- package/dist/safe-bash-command-cmp/options.js +42 -0
- package/dist/safe-bash-command-csvcut/index.js +11 -8
- package/dist/safe-bash-command-csvgrep/index.js +35 -7
- package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
- package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
- package/dist/safe-bash-command-csvkit/index.js +80 -324
- package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
- package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
- package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
- package/dist/safe-bash-command-diff3/index.js +3 -0
- package/dist/safe-bash-command-docx/LICENSE +21 -0
- package/dist/safe-bash-command-docx/index.d.ts +30 -0
- package/dist/safe-bash-command-docx/index.js +67 -0
- package/dist/safe-bash-command-docx/io.d.ts +14 -0
- package/dist/safe-bash-command-docx/io.js +26 -0
- package/dist/safe-bash-command-envsubst/index.js +34 -3
- package/dist/safe-bash-command-exiftool/index.js +3 -0
- package/dist/safe-bash-command-ffmpeg/index.js +1102 -1088
- package/dist/safe-bash-command-fold/family.js +1 -1
- package/dist/safe-bash-command-fold/index.js +1 -1
- package/dist/safe-bash-command-htmlq/index.js +5 -0
- package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
- package/dist/safe-bash-command-imagemagick/index.js +669 -271
- package/dist/safe-bash-command-mmdc/index.js +48 -10
- package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
- package/dist/safe-bash-command-op/index.js +19 -14
- package/dist/safe-bash-command-pandoc/command.js +1 -1
- package/dist/safe-bash-command-pandoc/index.js +1 -1
- package/dist/safe-bash-command-pdfimages/index.d.ts +7 -1
- package/dist/safe-bash-command-pdfimages/index.js +63 -33
- package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
- package/dist/safe-bash-command-pdfinfo/index.js +370 -161
- package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
- package/dist/safe-bash-command-pdftk/index.js +114 -45
- package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
- package/dist/safe-bash-command-pdftoppm/index.js +179 -109
- package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
- package/dist/safe-bash-command-pdftotext/index.js +90 -27
- package/dist/safe-bash-command-pptx/LICENSE +21 -0
- package/dist/safe-bash-command-pptx/index.d.ts +33 -0
- package/dist/safe-bash-command-pptx/index.js +168 -0
- package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
- package/dist/safe-bash-command-qpdf/index.js +80 -29
- package/dist/safe-bash-command-sha512sum/index.js +12 -475
- package/dist/safe-bash-command-sips/index.d.ts +9 -5
- package/dist/safe-bash-command-sips/index.js +63 -44
- package/dist/safe-bash-command-soffice/index.d.ts +9 -3
- package/dist/safe-bash-command-soffice/index.js +65 -24
- package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
- package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/index.js +851 -352
- package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
- package/dist/safe-bash-command-timeout/index.js +3 -3
- package/dist/safe-bash-command-truncate/index.d.ts +8 -3
- package/dist/safe-bash-command-truncate/index.js +790 -272
- package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
- package/dist/safe-bash-command-truncate/sync.js +60 -0
- package/dist/safe-bash-command-wkhtmltopdf/index.js +92 -38
- package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
- package/dist/safe-bash-command-xxd/index.js +78 -20
- package/dist/safe-bash-command-xz/command.d.ts +4 -0
- package/dist/safe-bash-command-xz/index.d.ts +1 -1
- package/dist/safe-bash-command-xz/index.js +1 -1
- package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +6 -6
- package/dist/safe-bash-compression-engine/index.js +5 -5
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/stream.js +5 -5
- package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
- package/dist/safe-bash-contracts/command.js +3 -3
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +9 -9
- package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
- package/dist/safe-bash-contracts/filesystem-output.js +8 -8
- package/dist/safe-bash-contracts/index.js +21 -19
- package/dist/safe-bash-contracts/io.d.ts +12 -0
- package/dist/safe-bash-contracts/io.js +4 -1
- package/dist/safe-bash-contracts/output.js +3 -2
- package/dist/safe-bash-contracts/runtime-control.js +2 -2
- package/dist/safe-bash-contracts/signals.js +1 -1
- package/dist/safe-bash-contracts/yield.d.ts +1 -0
- package/dist/safe-bash-contracts/yield.js +3 -1
- package/dist/safe-bash-csv-engine/index.d.ts +10 -1
- package/dist/safe-bash-csv-engine/index.js +78 -6
- package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
- package/dist/safe-bash-io-engine/gnu-information.js +1 -1
- package/dist/safe-bash-io-engine/internal.d.ts +1 -1
- package/dist/safe-bash-io-engine/internal.js +2 -2
- package/dist/safe-bash-mcp/index.browser.d.ts +875 -0
- package/dist/safe-bash-mcp/index.browser.js +8740 -0
- package/dist/safe-bash-mcp/index.js +32 -31
- package/dist/safe-bash-query-engine/capture.js +3 -3
- package/dist/safe-bash-query-engine/delpaths.js +3 -3
- package/dist/safe-bash-query-engine/formats.js +2 -2
- package/dist/safe-bash-query-engine/index.js +12 -12
- package/dist/safe-bash-query-engine/indices.js +3 -3
- package/dist/safe-bash-query-engine/input.js +1 -1
- package/dist/safe-bash-query-engine/interpreter.js +10 -10
- package/dist/safe-bash-query-engine/query-core.js +12 -12
- package/dist/safe-bash-query-engine/regex.js +3 -3
- package/dist/safe-bash-query-engine/splits.js +4 -4
- package/dist/safe-bash-query-engine/values.js +2 -2
- package/package.json +9 -3
- package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
- package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
- package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2VTMZTV3.js} +0 -0
- 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/
|
|
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]" ||
|
|
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-
|
|
4
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
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-
|
|
4
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
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-
|
|
4
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
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-
|
|
14
|
-
import "../safe-bash/command-chunks/chunk-
|
|
15
|
-
import "../safe-bash/command-chunks/chunk-
|
|
16
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
4
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
6
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
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-
|
|
14
|
-
import "../safe-bash/command-chunks/chunk-
|
|
15
|
-
import "../safe-bash/command-chunks/chunk-
|
|
16
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
6
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
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-
|
|
4
|
-
import "../safe-bash/command-chunks/chunk-
|
|
5
|
-
import "../safe-bash/command-chunks/chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
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.
|
|
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":
|
|
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.
|
|
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
|
-
}
|