just-bash 2.9.6 → 2.9.8
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/dist/Bash.d.ts +5 -0
- package/dist/bin/chunks/{bash-RJTQJAKW.js → bash-WB6O736J.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-OIKCUTTB.js → chunks/chunk-RDZMRK5M.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-GELILQAH.js → chunks/flag-coverage-SFRIE2LL.js} +1 -1
- package/dist/bin/chunks/worker.js +8 -4
- package/dist/bin/just-bash.js +3 -3
- package/dist/bin/shell/chunks/{bash-RJTQJAKW.js → bash-WB6O736J.js} +1 -1
- package/dist/bin/{chunks/chunk-OIKCUTTB.js → shell/chunks/chunk-RDZMRK5M.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-GELILQAH.js → shell/chunks/flag-coverage-SFRIE2LL.js} +1 -1
- package/dist/bin/shell/shell.js +3 -3
- package/dist/bundle/browser.js +3 -3
- package/dist/bundle/chunks/{bash-OVBCDR7G.js → bash-DYXMG247.js} +1 -1
- package/dist/bundle/chunks/{chunk-HXILPMCG.js → chunk-JP44OYZS.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-5KOYWCUN.js → flag-coverage-MX32DFGQ.js} +1 -1
- package/dist/bundle/chunks/worker.js +8 -4
- package/dist/bundle/index.js +3 -3
- package/dist/types.d.ts +5 -0
- package/package.json +1 -1
package/dist/Bash.d.ts
CHANGED
|
@@ -150,6 +150,11 @@ export interface ExecOptions {
|
|
|
150
150
|
* Default: false
|
|
151
151
|
*/
|
|
152
152
|
rawScript?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Standard input to pass to the script.
|
|
155
|
+
* This will be available to commands via stdin (e.g., for `bash -c 'cat'`).
|
|
156
|
+
*/
|
|
157
|
+
stdin?: string;
|
|
153
158
|
}
|
|
154
159
|
export declare class Bash {
|
|
155
160
|
readonly fs: IFileSystem;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-RDZMRK5M.js";import"./chunk-4PRVMER6.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{a as bashCommand,c as flagsForFuzzing,b as shCommand,d as shFlagsForFuzzing};
|
|
@@ -3,4 +3,4 @@ import{c as u}from"./chunk-4PRVMER6.js";import{a as l,b as h}from"./chunk-GTNBSM
|
|
|
3
3
|
`,exitCode:127}}}},C={name:"sh",async execute(t,e){if(h(t))return l({...d,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let r=t[1],s=t[2]||"sh",c=t.slice(3);return i(r,s,c,e)}if(t.length===0)return e.stdin?.trim()?i(e.stdin,"sh",[],e):{stdout:"",stderr:"",exitCode:0};let n=t[0],o=t.slice(1);try{let r=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(r);return i(s,n,o,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
|
|
4
4
|
`,exitCode:127}}}};async function i(t,e,n,o){if(!o.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
|
|
5
5
|
`,exitCode:1};let r=u(o.exportedEnv||{},{0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")});n.forEach((a,m)=>{r[String(m+1)]=a});let s=t;if(s.startsWith("#!")){let a=s.indexOf(`
|
|
6
|
-
`);a!==-1&&(s=s.slice(a+1))}return await o.exec(s,{env:r,cwd:o.cwd})}var b={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},P={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"};export{y as a,C as b,b as c,P as d};
|
|
6
|
+
`);a!==-1&&(s=s.slice(a+1))}return await o.exec(s,{env:r,cwd:o.cwd,stdin:o.stdin})}var b={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},P={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"};export{y as a,C as b,b as c,P as d};
|
package/dist/bin/{shell/chunks/flag-coverage-GELILQAH.js → chunks/flag-coverage-SFRIE2LL.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as yr}from"./chunk-EFX3F2HZ.js";import{b as Ar}from"./chunk-CHB75QIN.js";import{b as $r}from"./chunk-MNNOATCV.js";import"./chunk-GZHFXDDO.js";import"./chunk-QSDVMMYI.js";import{b as Sr}from"./chunk-PDVXLMUU.js";import{b as wr}from"./chunk-XKPFI566.js";import{b as xr}from"./chunk-KLMOJKL4.js";import{b as vr}from"./chunk-TIDZOIPX.js";import{b as kr}from"./chunk-6VUEI2GS.js";import{b as qr}from"./chunk-BYDV4VEF.js";import{b as Cr}from"./chunk-JLX6YWGA.js";import{b as br}from"./chunk-FLPVVSN5.js";import{d as Ir,e as Mr,f as jr}from"./chunk-DAGNL3F2.js";import{b as tr}from"./chunk-P7UCWJ33.js";import{b as lr}from"./chunk-N73TVRMN.js";import{b as ur}from"./chunk-THALLNXT.js";import{b as pr}from"./chunk-2SIXTZCJ.js";import{b as er}from"./chunk-3Y32LPNT.js";import{b as dr}from"./chunk-7BORMNPQ.js";import{b as cr}from"./chunk-N43DJTSI.js";import"./chunk-OBI37ZY4.js";import{b as hr}from"./chunk-N5OTVT4F.js";import{c as or,d as ar}from"./chunk-MAVV76T4.js";import{b as sr}from"./chunk-JTF74J6E.js";import{c as ir,d as gr}from"./chunk-
|
|
2
|
+
import{b as yr}from"./chunk-EFX3F2HZ.js";import{b as Ar}from"./chunk-CHB75QIN.js";import{b as $r}from"./chunk-MNNOATCV.js";import"./chunk-GZHFXDDO.js";import"./chunk-QSDVMMYI.js";import{b as Sr}from"./chunk-PDVXLMUU.js";import{b as wr}from"./chunk-XKPFI566.js";import{b as xr}from"./chunk-KLMOJKL4.js";import{b as vr}from"./chunk-TIDZOIPX.js";import{b as kr}from"./chunk-6VUEI2GS.js";import{b as qr}from"./chunk-BYDV4VEF.js";import{b as Cr}from"./chunk-JLX6YWGA.js";import{b as br}from"./chunk-FLPVVSN5.js";import{d as Ir,e as Mr,f as jr}from"./chunk-DAGNL3F2.js";import{b as tr}from"./chunk-P7UCWJ33.js";import{b as lr}from"./chunk-N73TVRMN.js";import{b as ur}from"./chunk-THALLNXT.js";import{b as pr}from"./chunk-2SIXTZCJ.js";import{b as er}from"./chunk-3Y32LPNT.js";import{b as dr}from"./chunk-7BORMNPQ.js";import{b as cr}from"./chunk-N43DJTSI.js";import"./chunk-OBI37ZY4.js";import{b as hr}from"./chunk-N5OTVT4F.js";import{c as or,d as ar}from"./chunk-MAVV76T4.js";import{b as sr}from"./chunk-JTF74J6E.js";import{c as ir,d as gr}from"./chunk-RDZMRK5M.js";import{b as mr}from"./chunk-QEBPVWVB.js";import"./chunk-A4442AOC.js";import"./chunk-UYBH3FNE.js";import{b as Fr}from"./chunk-BARKRZDC.js";import{b as zr}from"./chunk-P6GNZPVW.js";import{b as fr}from"./chunk-IY3BUFJK.js";import{b as nr}from"./chunk-NFZDITRV.js";import{b as R}from"./chunk-PQNTKMH3.js";import{b as U}from"./chunk-PPBQJBC2.js";import{b as V}from"./chunk-NSUMEERA.js";import{b as W}from"./chunk-4PS5JJDT.js";import{c as X,d as Y}from"./chunk-W2FKF3MM.js";import{c as Z,d as _}from"./chunk-3MBAUIBB.js";import{b as N}from"./chunk-RT7TRQVZ.js";import{b as rr}from"./chunk-JXC25GVQ.js";import{b as G}from"./chunk-RJSAGJQJ.js";import{b as H}from"./chunk-YEKSVVRC.js";import{b as J}from"./chunk-26NO42TF.js";import{b as K}from"./chunk-QXB5WI2V.js";import{b as L}from"./chunk-LMK6G2HH.js";import{b as O}from"./chunk-ZKC5HQYO.js";import{b as P}from"./chunk-ROJPSS6N.js";import{b as Q}from"./chunk-7ECKLAVW.js";import{b as y}from"./chunk-NEQEZ32M.js";import{b as A}from"./chunk-ZA4HUKJ3.js";import{b as $}from"./chunk-5U7Q4GUC.js";import{b as S}from"./chunk-JQBC3FXE.js";import{b as T}from"./chunk-BDSRLH5T.js";import{b as B}from"./chunk-5G2VOPPJ.js";import{b as D}from"./chunk-SGA7Y45Z.js";import{b as E}from"./chunk-EUXCM6C4.js";import{b as w}from"./chunk-YLE2OYY6.js";import{b as x}from"./chunk-S7OHMN3F.js";import{b as v}from"./chunk-XAL6VWGA.js";import{d as k,e as q,f as C}from"./chunk-WT2HWDDA.js";import"./chunk-GIFF636B.js";import{b}from"./chunk-Q4QFIAHB.js";import"./chunk-G43H2WGH.js";import{b as I}from"./chunk-FEBB4TFH.js";import{b as M}from"./chunk-K7XSYP4L.js";import{b as j}from"./chunk-THLAHQXV.js";import{b as t}from"./chunk-YYQ22ZRL.js";import{b as l}from"./chunk-PS4LOXE5.js";import{b as u}from"./chunk-VNER2XXL.js";import{b as p}from"./chunk-4E3LY6YK.js";import{b as e}from"./chunk-5VFN7VVJ.js";import{b as d}from"./chunk-TEFXEYX3.js";import{b as c}from"./chunk-D2GFNFUN.js";import{b as h}from"./chunk-SXRVLCZ4.js";import"./chunk-FSZWFMB4.js";import"./chunk-4PRVMER6.js";import"./chunk-SE4C7FJY.js";import{b as i}from"./chunk-LJKIWB5F.js";import{b as g}from"./chunk-K47SEEPI.js";import"./chunk-5WFYIUU2.js";import{b as m}from"./chunk-X2I3PJTX.js";import"./chunk-D5WP4CKS.js";import"./chunk-K5IXNHO5.js";import{b as F}from"./chunk-4P5OA25Z.js";import"./chunk-OBH7XN5N.js";import{b as z}from"./chunk-KWLLB7S3.js";import{b as f}from"./chunk-EJQKHROT.js";import"./chunk-JBABAK44.js";import{b as n}from"./chunk-ITA43A73.js";import"./chunk-4VDEBYW7.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
|
|
@@ -6,6 +6,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
// src/commands/python3/worker.ts
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { dirname } from "node:path";
|
|
9
11
|
import { parentPort, workerData } from "node:worker_threads";
|
|
10
12
|
import { loadPyodide } from "pyodide";
|
|
11
13
|
|
|
@@ -208,9 +210,9 @@ var IS_BROWSER = typeof __BROWSER__ !== "undefined" && __BROWSER__;
|
|
|
208
210
|
var AsyncLocalStorageClass = null;
|
|
209
211
|
if (!IS_BROWSER) {
|
|
210
212
|
try {
|
|
211
|
-
const { createRequire } = await import("node:module");
|
|
212
|
-
const
|
|
213
|
-
const asyncHooks =
|
|
213
|
+
const { createRequire: createRequire2 } = await import("node:module");
|
|
214
|
+
const require3 = createRequire2(import.meta.url);
|
|
215
|
+
const asyncHooks = require3("node:async_hooks");
|
|
214
216
|
AsyncLocalStorageClass = asyncHooks.AsyncLocalStorage;
|
|
215
217
|
} catch (e) {
|
|
216
218
|
console.debug(
|
|
@@ -1314,6 +1316,8 @@ var SyncFsBackend = class {
|
|
|
1314
1316
|
// src/commands/python3/worker.ts
|
|
1315
1317
|
var pyodideInstance = null;
|
|
1316
1318
|
var pyodideLoading = null;
|
|
1319
|
+
var require2 = createRequire(import.meta.url);
|
|
1320
|
+
var pyodideIndexURL = `${dirname(require2.resolve("pyodide/pyodide.mjs"))}/`;
|
|
1317
1321
|
async function getPyodide() {
|
|
1318
1322
|
if (pyodideInstance) {
|
|
1319
1323
|
return pyodideInstance;
|
|
@@ -1321,7 +1325,7 @@ async function getPyodide() {
|
|
|
1321
1325
|
if (pyodideLoading) {
|
|
1322
1326
|
return pyodideLoading;
|
|
1323
1327
|
}
|
|
1324
|
-
pyodideLoading = loadPyodide();
|
|
1328
|
+
pyodideLoading = loadPyodide({ indexURL: pyodideIndexURL });
|
|
1325
1329
|
pyodideInstance = await pyodideLoading;
|
|
1326
1330
|
return pyodideInstance;
|
|
1327
1331
|
}
|
package/dist/bin/just-bash.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B as ln,C as cn,D as re,E as De,F as K,G as me,H as ht,I as un,J as T,K as fn,L as dn,M as we,N as Gt,O as pt,P as z,a as Qs,b as Js,c as en,d as ft,e as q,f as W,g as ye,h as Y,i as ge,j as Ce,k as jt,l as dt,m as tn,n as Ht,o as sn,p as fe,q as Se,r as nn,s as rn,t as Ut,u as qt,v as Pe,w as on,x as an,y as pe,z as Zt}from"./chunks/chunk-LS25HZNJ.js";import{a as _e,b as he}from"./chunks/chunk-4PRVMER6.js";import{a as Ze}from"./chunks/chunk-SE4C7FJY.js";import{a as le,b as ce,c as ne,d as ue,e as Xs,f as V,g as xe,h as lt,i as ct,j as Ys,k as ee,l as Ae,m as ut,n as de}from"./chunks/chunk-K5IXNHO5.js";import"./chunks/chunk-OBH7XN5N.js";import{a as Ee}from"./chunks/chunk-4VDEBYW7.js";import{a as at}from"./chunks/chunk-KGOUQS5A.js";import{resolve as Br}from"node:path";var Le=[{name:"echo",load:async()=>(await import("./chunks/echo-2MUAOGUE.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-3J7U3HHI.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-TZC5BRAY.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-ZXYOL67L.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-6OKMS3KO.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-5KLM4EA6.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DWKSZGOQ.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-5QIBTLJG.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XH2ZB7WT.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-OY7X62QC.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-5TCJXDGY.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-4O2C4V42.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-6VBAPL3Y.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-YNOUXNUY.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YMNRW3F3.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-V537TDFR.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-ZIV3TFVG.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-XH7E4E2C.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-3R5G2XL4.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-WNL6TIIN.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-PWEGD656.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-NZSEYCI6.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-FZWFZEN5.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-R3F3Z5DX.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-HDHQDWRG.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-3UVLMQ2K.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-GDDRKGRB.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-UHEPS2UL.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-XH3L75DR.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-XSVNTAWH.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-26XPP5KB.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-OYZ7KOYR.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-XXKZCWY5.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-NOZ7FFXW.js")).split},{name:"column",load:async()=>(await import("./chunks/column-XGV32UPN.js")).column},{name:"join",load:async()=>(await import("./chunks/join-Y4Q5WVVE.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-HK2SYCAR.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-K777TRNA.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-KBUKWB2E.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-5FAOMLBL.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-HEKABARE.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-66BNA4IN.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-UUKG55YW.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-YWPEV2QC.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-DP5UZP52.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-DP5UZP52.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KRGKPFOI.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-RJTQJAKW.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-RJTQJAKW.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-CXQ33VMW.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-YXBFJFHG.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-LE7GMFZD.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-6VDN5QZ5.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-PICQVS6Q.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-RS7REDYT.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-4C3A4THJ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-V7KBLSQ7.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-MLHUWFYI.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-NCLXV2S3.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BHNJ5ALF.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-HJJ3NJ5L.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-D5YKS5NV.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-WVZA3MCP.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-JF5TTAKQ.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-67WZ6OMV.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-TZBNTR4K.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-WY6RKE32.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-E7PN2UWC.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-52FBC34W.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Le.push({name:"tar",load:async()=>(await import("./chunks/tar-7B5KH3QG.js")).tarCommand}),Le.push({name:"yq",load:async()=>(await import("./chunks/yq-WUJ5JNDT.js")).yqCommand}),Le.push({name:"xan",load:async()=>(await import("./chunks/xan-FMSZPFX4.js")).xanCommand}),Le.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-4SEIR46P.js")).sqlite3Command}));var Kt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Kt.push({name:"python3",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).python3Command}),Kt.push({name:"python",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).pythonCommand}));var Zr=[{name:"curl",load:async()=>(await import("./chunks/curl-RWQO3SBN.js")).curlCommand}],hn=new Map;function Xt(e){return{name:e.name,async execute(t,s){let n=hn.get(e.name);if(n||(n=await e.load(),hn.set(e.name,n)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:r}=await import("./chunks/flag-coverage-GELILQAH.js");r(s.coverage,e.name,t)}return n.execute(t,s)}}}function pn(e){return(e?Le.filter(s=>e.includes(s.name)):Le).map(Xt)}function mn(){return Zr.map(Xt)}function yn(){return Kt.map(Xt)}function gn(e){return"load"in e&&typeof e.load=="function"}function wn(e){let t=null;return{name:e.name,async execute(s,n){return t||(t=await e.load()),t.execute(s,n)}}}var Gr=new TextEncoder,Kr=new TextDecoder;function Fe(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)s[n/2]=parseInt(e.slice(n,n+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,r=>r.charCodeAt(0));let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}return Gr.encode(e)}function mt(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let n="";for(let r=0;r<e.length;r+=s){let i=e.subarray(r,r+s);n+=String.fromCharCode(...i)}return n}return Kr.decode(e)}function ke(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var yt=new TextEncoder;function Xr(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function te(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Ge=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,n]of Object.entries(t))Xr(n)?this.writeFileSync(s,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(s,n)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let n=s.split("/").filter(i=>i&&i!=="."),r=[];for(let i of n)i===".."?r.pop():r.push(i);return`/${r.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.lastIndexOf("/");return n===0?"/":s.slice(0,n)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,n,r){te(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=ke(n),a=Fe(s,o);this.data.set(i,{type:"file",content:a,mode:r?.mode??420,mtime:r?.mtime??new Date})}async readFile(t,s){let n=await this.readFileBuffer(t),r=ke(s);return mt(n,r)}async readFileBuffer(t){te(t,"open");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content instanceof Uint8Array?n.content:yt.encode(n.content)}async writeFile(t,s,n){this.writeFileSync(t,s,n)}async appendFile(t,s,n){te(t,"append");let r=this.normalizePath(t),i=this.data.get(r);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=ke(n),a=Fe(s,o);if(i?.type==="file"){let c=i.content instanceof Uint8Array?i.content:yt.encode(i.content),l=new Uint8Array(c.length+a.length);l.set(c),l.set(a,c.length),this.data.set(r,{type:"file",content:l,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,n)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){te(t,"stat");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}async lstat(t){te(t,"lstat");let s=this.resolveIntermediateSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=this.dirname(t);return this.normalizePath(n==="/"?`/${s}`:`${n}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/");if(n.length<=1)return s;let r="",i=new Set;for(let o=0;o<n.length-1;o++){let a=n[o];r=`${r}/${a}`;let c=this.data.get(r),l=0,u=40;for(;c&&c.type==="symlink"&&l<u;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(r),r=this.resolveSymlink(r,c.target),c=this.data.get(r),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/"),r="",i=new Set;for(let o of n){r=`${r}/${o}`;let a=this.data.get(r),c=0,l=40;for(;a&&a.type==="symlink"&&c<l;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(r),r=this.resolveSymlink(r,a.target),a=this.data.get(r),c++}if(c>=l)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return r}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){te(t,"mkdir");let n=this.normalizePath(t);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let r=this.dirname(n);if(r!=="/"&&!this.data.has(r))if(s?.recursive)this.mkdirSync(r,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(n=>n.name)}async readdirWithFileTypes(t){te(t,"scandir");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Set;for(;n&&n.type==="symlink";){if(r.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);r.add(s),s=this.resolveSymlink(s,n.target),n=this.data.get(s)}if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,c]of this.data.entries())if(a!==s&&a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(t,s){te(t,"rm");let n=this.normalizePath(t),r=this.data.get(n);if(!r){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(r.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(a,s)}}}this.data.delete(n)}async cp(t,s,n){te(t,"cp"),te(s,"cp");let r=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let c of a){let l=r==="/"?`/${c}`:`${r}/${c}`,u=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(l,u,n)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(n)}async chmod(t,s){te(t,"chmod");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);r.mode=s}async symlink(t,s){te(s,"symlink");let n=this.normalizePath(s);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){te(t,"link"),te(s,"link");let n=this.normalizePath(t),r=this.normalizePath(s),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(r))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){te(t,"readlink");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return n.target}async realpath(t){te(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,n){te(t,"utimes");let r=this.normalizePath(t),i=this.resolvePathWithSymlinks(r),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=n}};function Yr(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Qr(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function Jr(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function ei(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Qs}
|
|
2
|
+
import{B as ln,C as cn,D as re,E as De,F as K,G as me,H as ht,I as un,J as T,K as fn,L as dn,M as we,N as Gt,O as pt,P as z,a as Qs,b as Js,c as en,d as ft,e as q,f as W,g as ye,h as Y,i as ge,j as Ce,k as jt,l as dt,m as tn,n as Ht,o as sn,p as fe,q as Se,r as nn,s as rn,t as Ut,u as qt,v as Pe,w as on,x as an,y as pe,z as Zt}from"./chunks/chunk-LS25HZNJ.js";import{a as _e,b as he}from"./chunks/chunk-4PRVMER6.js";import{a as Ze}from"./chunks/chunk-SE4C7FJY.js";import{a as le,b as ce,c as ne,d as ue,e as Xs,f as V,g as xe,h as lt,i as ct,j as Ys,k as ee,l as Ae,m as ut,n as de}from"./chunks/chunk-K5IXNHO5.js";import"./chunks/chunk-OBH7XN5N.js";import{a as Ee}from"./chunks/chunk-4VDEBYW7.js";import{a as at}from"./chunks/chunk-KGOUQS5A.js";import{resolve as Br}from"node:path";var Le=[{name:"echo",load:async()=>(await import("./chunks/echo-2MUAOGUE.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-3J7U3HHI.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-TZC5BRAY.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-ZXYOL67L.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-6OKMS3KO.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-5KLM4EA6.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DWKSZGOQ.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-5QIBTLJG.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XH2ZB7WT.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-OY7X62QC.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-5TCJXDGY.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-4O2C4V42.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-6VBAPL3Y.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-YNOUXNUY.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YMNRW3F3.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-V537TDFR.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-ZIV3TFVG.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-XH7E4E2C.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-3R5G2XL4.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-WNL6TIIN.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-PWEGD656.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-NZSEYCI6.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-FZWFZEN5.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-R3F3Z5DX.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-HDHQDWRG.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-3UVLMQ2K.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-GDDRKGRB.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-UHEPS2UL.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-XH3L75DR.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-XSVNTAWH.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-26XPP5KB.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-OYZ7KOYR.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-XXKZCWY5.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-NOZ7FFXW.js")).split},{name:"column",load:async()=>(await import("./chunks/column-XGV32UPN.js")).column},{name:"join",load:async()=>(await import("./chunks/join-Y4Q5WVVE.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-HK2SYCAR.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-K777TRNA.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-KBUKWB2E.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-5FAOMLBL.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-HEKABARE.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-66BNA4IN.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-UUKG55YW.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-YWPEV2QC.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-DP5UZP52.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-DP5UZP52.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KRGKPFOI.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-WB6O736J.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-WB6O736J.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-CXQ33VMW.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-YXBFJFHG.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-LE7GMFZD.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-6VDN5QZ5.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-PICQVS6Q.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-RS7REDYT.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-4C3A4THJ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-V7KBLSQ7.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-MLHUWFYI.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-NCLXV2S3.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BHNJ5ALF.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-HJJ3NJ5L.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-D5YKS5NV.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-WVZA3MCP.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-JF5TTAKQ.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-67WZ6OMV.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-TZBNTR4K.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-WY6RKE32.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-E7PN2UWC.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-52FBC34W.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Le.push({name:"tar",load:async()=>(await import("./chunks/tar-7B5KH3QG.js")).tarCommand}),Le.push({name:"yq",load:async()=>(await import("./chunks/yq-WUJ5JNDT.js")).yqCommand}),Le.push({name:"xan",load:async()=>(await import("./chunks/xan-FMSZPFX4.js")).xanCommand}),Le.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-4SEIR46P.js")).sqlite3Command}));var Kt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Kt.push({name:"python3",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).python3Command}),Kt.push({name:"python",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).pythonCommand}));var Zr=[{name:"curl",load:async()=>(await import("./chunks/curl-RWQO3SBN.js")).curlCommand}],hn=new Map;function Xt(e){return{name:e.name,async execute(t,s){let n=hn.get(e.name);if(n||(n=await e.load(),hn.set(e.name,n)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:r}=await import("./chunks/flag-coverage-SFRIE2LL.js");r(s.coverage,e.name,t)}return n.execute(t,s)}}}function pn(e){return(e?Le.filter(s=>e.includes(s.name)):Le).map(Xt)}function mn(){return Zr.map(Xt)}function yn(){return Kt.map(Xt)}function gn(e){return"load"in e&&typeof e.load=="function"}function wn(e){let t=null;return{name:e.name,async execute(s,n){return t||(t=await e.load()),t.execute(s,n)}}}var Gr=new TextEncoder,Kr=new TextDecoder;function Fe(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)s[n/2]=parseInt(e.slice(n,n+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,r=>r.charCodeAt(0));let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}return Gr.encode(e)}function mt(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let n="";for(let r=0;r<e.length;r+=s){let i=e.subarray(r,r+s);n+=String.fromCharCode(...i)}return n}return Kr.decode(e)}function ke(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var yt=new TextEncoder;function Xr(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function te(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Ge=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,n]of Object.entries(t))Xr(n)?this.writeFileSync(s,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(s,n)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let n=s.split("/").filter(i=>i&&i!=="."),r=[];for(let i of n)i===".."?r.pop():r.push(i);return`/${r.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.lastIndexOf("/");return n===0?"/":s.slice(0,n)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,n,r){te(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=ke(n),a=Fe(s,o);this.data.set(i,{type:"file",content:a,mode:r?.mode??420,mtime:r?.mtime??new Date})}async readFile(t,s){let n=await this.readFileBuffer(t),r=ke(s);return mt(n,r)}async readFileBuffer(t){te(t,"open");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content instanceof Uint8Array?n.content:yt.encode(n.content)}async writeFile(t,s,n){this.writeFileSync(t,s,n)}async appendFile(t,s,n){te(t,"append");let r=this.normalizePath(t),i=this.data.get(r);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=ke(n),a=Fe(s,o);if(i?.type==="file"){let c=i.content instanceof Uint8Array?i.content:yt.encode(i.content),l=new Uint8Array(c.length+a.length);l.set(c),l.set(a,c.length),this.data.set(r,{type:"file",content:l,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,n)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){te(t,"stat");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}async lstat(t){te(t,"lstat");let s=this.resolveIntermediateSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=this.dirname(t);return this.normalizePath(n==="/"?`/${s}`:`${n}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/");if(n.length<=1)return s;let r="",i=new Set;for(let o=0;o<n.length-1;o++){let a=n[o];r=`${r}/${a}`;let c=this.data.get(r),l=0,u=40;for(;c&&c.type==="symlink"&&l<u;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(r),r=this.resolveSymlink(r,c.target),c=this.data.get(r),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/"),r="",i=new Set;for(let o of n){r=`${r}/${o}`;let a=this.data.get(r),c=0,l=40;for(;a&&a.type==="symlink"&&c<l;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(r),r=this.resolveSymlink(r,a.target),a=this.data.get(r),c++}if(c>=l)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return r}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){te(t,"mkdir");let n=this.normalizePath(t);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let r=this.dirname(n);if(r!=="/"&&!this.data.has(r))if(s?.recursive)this.mkdirSync(r,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(n=>n.name)}async readdirWithFileTypes(t){te(t,"scandir");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Set;for(;n&&n.type==="symlink";){if(r.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);r.add(s),s=this.resolveSymlink(s,n.target),n=this.data.get(s)}if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,c]of this.data.entries())if(a!==s&&a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(t,s){te(t,"rm");let n=this.normalizePath(t),r=this.data.get(n);if(!r){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(r.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(a,s)}}}this.data.delete(n)}async cp(t,s,n){te(t,"cp"),te(s,"cp");let r=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let c of a){let l=r==="/"?`/${c}`:`${r}/${c}`,u=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(l,u,n)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(n)}async chmod(t,s){te(t,"chmod");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);r.mode=s}async symlink(t,s){te(s,"symlink");let n=this.normalizePath(s);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){te(t,"link"),te(s,"link");let n=this.normalizePath(t),r=this.normalizePath(s),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(r))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){te(t,"readlink");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return n.target}async realpath(t){te(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,n){te(t,"utimes");let r=this.normalizePath(t),i=this.resolvePathWithSymlinks(r),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=n}};function Yr(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Qr(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function Jr(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function ei(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Qs}
|
|
3
3
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
4
4
|
`),e.writeFileSync("/proc/self/status",Js()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function vn(e,t){Yr(e)&&(Qr(e,t),Jr(e),ei(e))}var ti=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],si=["braceexpand","hashall","interactive-comments"];function Yt(e){let t=[],s=[...si.map(n=>({name:n,enabled:!0})),...ti.map(n=>({name:n,enabled:e[n]}))].sort((n,r)=>n.name.localeCompare(r.name));for(let n of s)n.enabled&&t.push(n.name);return t.join(":")}function Me(e){e.state.env.set("SHELLOPTS",Yt(e.state.options))}var ni=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function Qt(e){let t=[];for(let s of ni)e[s]&&t.push(s);return t.join(":")}function Jt(e){e.state.env.set("BASHOPTS",Qt(e.state.shoptOptions))}var ri="BASH_ALIAS_";function bn(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function En(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Sn(e,t){return e.env.get(`${ri}${t}`)}function es(e,t,s){if(!t.name||!bn(t.name))return t;let n=En(t.name);if(!n)return t;let r=Sn(e,n);if(!r||s.has(n))return t;try{s.add(n);let i=new W,o=r,a=r.endsWith(" ");if(!a)for(let f of t.args){let d=An(f);o+=` ${d}`}let c;try{c=i.parse(o)}catch(f){if(f instanceof ft)throw f;return t}if(c.statements.length!==1||c.statements[0].pipelines.length!==1||c.statements[0].pipelines[0].commands.length!==1)return $n(t,r);let l=c.statements[0].pipelines[0].commands[0];if(l.type!=="SimpleCommand")return $n(t,r);let u={...l,assignments:[...t.assignments,...l.assignments],redirections:[...l.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(bn(f)){let d=En(f);if(d&&Sn(e,d)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=es(e,h,s);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw s.delete(n),i}}function $n(e,t){let s=t;for(let o of e.args){let a=An(o);s+=` ${a}`}let n=new W,r=n.parseWordFromString("eval",!1,!1),i=n.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:r,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function An(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(n=>n.type==="Literal"?n.value:`$${n.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function _n(e,t){let s=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!n||!s.endsWith(")"))return null;let r=n[1],i=[],o=!1,a="",c=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let d=f.indexOf("=(");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let d=f.split(/(\s+)/);for(let h of d)/^\s+$/.test(h)?(a||c)&&(i.push(a),a="",c=!1):h&&(a+=h)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=dt({type:"Word",parts:[u]});else{(a||c)&&(i.push(a),a="",c=!1);let d=await we(e,{type:"Word",parts:[u]});i.push(...d.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(c=!0);let f=await T(e,{type:"Word",parts:[u]});a+=f}(a||c)&&i.push(a);let l=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${r}=(${l.join(" ")})`}async function Cn(e,t){let s=-1,n=-1,r=!1;for(let p=0;p<t.parts.length;p++){let g=t.parts[p];if(g.type==="Literal"){let $=g.value.indexOf("+=");if($!==-1){let P=g.value.slice(0,$);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)){s=p,n=$,r=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(P)){s=p,n=$,r=!0;break}}let v=g.value.indexOf("=");if(v!==-1&&(v===0||g.value[v-1]!=="+")){let P=g.value.slice(0,v);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(P)){s=p,n=v;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=r?2:1,c=o.value.slice(0,n),l=o.value.slice(n+a),u=t.parts.slice(s+1),f="";for(let p of i)f+=await T(e,{type:"Word",parts:[p]});f+=c;let d={type:"Word",parts:l!==""?[{type:"Literal",value:l},...u]:u},h=d.parts.length>0?await T(e,d):"";return`${f}${r?"+=":"="}${h}`}var ii=["tar","yq","xan","sqlite3","python3","python"];function Pn(e){return ii.includes(e)}var L=Object.freeze({stdout:"",stderr:"",exitCode:0});function F(e=""){return{stdout:e,stderr:"",exitCode:0}}function A(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function C(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function U(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function $e(e,t,s="",n=""){throw new ee(e,t,s,n)}function ts(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ae;return L}if(t.length>1)throw new V(1,"",`bash: break: too many arguments
|
|
5
5
|
`);let s=1;if(t.length>0){let n=Number.parseInt(t[0],10);if(Number.isNaN(n)||n<1)throw new V(128,"",`bash: break: ${t[0]}: numeric argument required
|
|
@@ -634,7 +634,7 @@ ${e} ()
|
|
|
634
634
|
`),r=e.includes(" "),i=e.includes("\\"),o=e.includes("'");if(s||n||r||i){let c="";for(let l of e){let u=l.charCodeAt(0);l===`
|
|
635
635
|
`?c+="\\n":l===" "?c+="\\t":l==="\\"?c+="\\\\":l==="'"?c+="'":l==='"'?c+='"':u<32||u===127?u<256?c+=`\\x${u.toString(16).padStart(2,"0")}`:c+=`\\u${u.toString(16).padStart(4,"0")}`:c+=l}return`$'${c}'`}return o?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function Nr(e,t,s){if(!e.state.options.xtrace)return"";let n=await kr(e),r=[t,...s],i=ro(r);return`${n}${i}
|
|
636
636
|
`}async function Or(e,t,s){return e.state.options.xtrace?`${await kr(e)}${t}=${s}
|
|
637
|
-
`:""}async function xr(e,t,s){let n=t.timed?performance.now():0,r="",i=L,o=0,a=[],c=t.commands.length>1,l=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let d=t.commands[f],h=f===t.commands.length-1;c&&(e.state.lastArg="");let
|
|
637
|
+
`:""}async function xr(e,t,s){let n=t.timed?performance.now():0,r="",i=L,o=0,a=[],c=t.commands.length>1,l=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let d=t.commands[f],h=f===t.commands.length-1,m=f===0;c&&(e.state.lastArg="",m||(e.state.groupStdin=void 0));let g=c&&(!h||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,$;try{$=await s(d,r)}catch(v){if(v instanceof lt)$={stdout:v.stdout,stderr:v.stderr,exitCode:1};else if(v instanceof V&&t.commands.length>1)$={stdout:v.stdout,stderr:v.stderr,exitCode:v.exitCode};else if(v instanceof ue&&t.commands.length>1)$={stdout:v.stdout,stderr:v.stderr,exitCode:v.exitCode};else throw g&&(e.state.env=g),v}g&&(e.state.env=g),a.push($.exitCode),$.exitCode!==0&&(o=$.exitCode),h?i=$:t.pipeStderr?.[f]??!1?(r=$.stderr+$.stdout,i={stdout:"",stderr:"",exitCode:$.exitCode}):(r=$.stdout,i={stdout:"",stderr:$.stderr,exitCode:$.exitCode})}if(t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let f of e.state.env.keys())f.startsWith("PIPESTATUS_")&&e.state.env.delete(f);for(let f=0;f<a.length;f++)e.state.env.set(`PIPESTATUS_${f}`,String(a[f]));e.state.env.set("PIPESTATUS__length",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let d=(performance.now()-n)/1e3,h=Math.floor(d/60),m=d%60,p;t.timePosix?p=`real ${d.toFixed(2)}
|
|
638
638
|
user 0.00
|
|
639
639
|
sys 0.00
|
|
640
640
|
`:p=`
|
|
@@ -676,7 +676,7 @@ This is a defense-in-depth measure and indicates a bug in just-bash. Please repo
|
|
|
676
676
|
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",n],["OLDPWD",n],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=Fr({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=Zs(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,this.state={env:r,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,bashPid:process.pid,nextVirtualPid:process.pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",Yt(this.state.options)),this.state.env.set("BASHOPTS",Qt(this.state.shoptOptions)),vn(s,this.useDefaultLayout),n!=="/"&&s instanceof Ge)try{s.mkdirSync(n,{recursive:!0})}catch{}for(let i of pn(t.commands))this.registerCommand(i);if(t.network)for(let i of mn())this.registerCommand(i);if(t.python)for(let i of yn())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)gn(i)?this.registerCommand(wn(i)):this.registerCommand(i)}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let n=`#!/bin/bash
|
|
677
677
|
# Built-in command: ${t.name}
|
|
678
678
|
`;try{s.writeFileSync(`/bin/${t.name}`,n)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,n)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
679
|
-
`,exitCode:1,env:he(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:he(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let n=s?.cwd??this.state.cwd,r,i=n;if(s?.cwd)if(s.env&&"PWD"in s.env)r=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{r=await this.fs.realpath(n),i=r}catch{r=n}else r=n;let o=new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);r!==void 0&&o.set("PWD",r);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable},c=t;s?.rawScript||(c=Po(t));let u=(this.defenseInDepthConfig?zt.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let d=ye(c),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new tt(h,a).executeScript(d);return this.logResult(p)};return u?await u.run(f):await f()}catch(f){if(f instanceof V)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:he(this.state.env,s?.env)});if(f instanceof de)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:he(this.state.env,s?.env)});if(f instanceof xe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:he(this.state.env,s?.env)});if(f instanceof ee)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:ee.EXIT_CODE,env:he(this.state.env,s?.env)});if(f instanceof se)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
679
|
+
`,exitCode:1,env:he(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:he(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let n=s?.cwd??this.state.cwd,r,i=n;if(s?.cwd)if(s.env&&"PWD"in s.env)r=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{r=await this.fs.realpath(n),i=r}catch{r=n}else r=n;let o=new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);r!==void 0&&o.set("PWD",r);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:s?.stdin},c=t;s?.rawScript||(c=Po(t));let u=(this.defenseInDepthConfig?zt.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let d=ye(c),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new tt(h,a).executeScript(d);return this.logResult(p)};return u?await u.run(f):await f()}catch(f){if(f instanceof V)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:he(this.state.env,s?.env)});if(f instanceof de)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:he(this.state.env,s?.env)});if(f instanceof xe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:he(this.state.env,s?.env)});if(f instanceof ee)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:ee.EXIT_CODE,env:he(this.state.env,s?.env)});if(f instanceof se)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
680
680
|
`,exitCode:1,env:he(this.state.env,s?.env)});if(f.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${f.message}
|
|
681
681
|
`,exitCode:2,env:he(this.state.env,s?.env)});if(f instanceof en)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
682
682
|
`,exitCode:2,env:he(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-RDZMRK5M.js";import"./chunk-4PRVMER6.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{a as bashCommand,c as flagsForFuzzing,b as shCommand,d as shFlagsForFuzzing};
|
|
@@ -3,4 +3,4 @@ import{c as u}from"./chunk-4PRVMER6.js";import{a as l,b as h}from"./chunk-GTNBSM
|
|
|
3
3
|
`,exitCode:127}}}},C={name:"sh",async execute(t,e){if(h(t))return l({...d,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let r=t[1],s=t[2]||"sh",c=t.slice(3);return i(r,s,c,e)}if(t.length===0)return e.stdin?.trim()?i(e.stdin,"sh",[],e):{stdout:"",stderr:"",exitCode:0};let n=t[0],o=t.slice(1);try{let r=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(r);return i(s,n,o,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
|
|
4
4
|
`,exitCode:127}}}};async function i(t,e,n,o){if(!o.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
|
|
5
5
|
`,exitCode:1};let r=u(o.exportedEnv||{},{0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")});n.forEach((a,m)=>{r[String(m+1)]=a});let s=t;if(s.startsWith("#!")){let a=s.indexOf(`
|
|
6
|
-
`);a!==-1&&(s=s.slice(a+1))}return await o.exec(s,{env:r,cwd:o.cwd})}var b={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},P={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"};export{y as a,C as b,b as c,P as d};
|
|
6
|
+
`);a!==-1&&(s=s.slice(a+1))}return await o.exec(s,{env:r,cwd:o.cwd,stdin:o.stdin})}var b={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},P={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"};export{y as a,C as b,b as c,P as d};
|
package/dist/bin/{chunks/flag-coverage-GELILQAH.js → shell/chunks/flag-coverage-SFRIE2LL.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as yr}from"./chunk-EFX3F2HZ.js";import{b as Ar}from"./chunk-CHB75QIN.js";import{b as $r}from"./chunk-MNNOATCV.js";import"./chunk-GZHFXDDO.js";import"./chunk-QSDVMMYI.js";import{b as Sr}from"./chunk-PDVXLMUU.js";import{b as wr}from"./chunk-XKPFI566.js";import{b as xr}from"./chunk-KLMOJKL4.js";import{b as vr}from"./chunk-TIDZOIPX.js";import{b as kr}from"./chunk-6VUEI2GS.js";import{b as qr}from"./chunk-BYDV4VEF.js";import{b as Cr}from"./chunk-JLX6YWGA.js";import{b as br}from"./chunk-FLPVVSN5.js";import{d as Ir,e as Mr,f as jr}from"./chunk-DAGNL3F2.js";import{b as tr}from"./chunk-P7UCWJ33.js";import{b as lr}from"./chunk-N73TVRMN.js";import{b as ur}from"./chunk-THALLNXT.js";import{b as pr}from"./chunk-2SIXTZCJ.js";import{b as er}from"./chunk-3Y32LPNT.js";import{b as dr}from"./chunk-7BORMNPQ.js";import{b as cr}from"./chunk-N43DJTSI.js";import"./chunk-OBI37ZY4.js";import{b as hr}from"./chunk-N5OTVT4F.js";import{c as or,d as ar}from"./chunk-MAVV76T4.js";import{b as sr}from"./chunk-JTF74J6E.js";import{c as ir,d as gr}from"./chunk-
|
|
2
|
+
import{b as yr}from"./chunk-EFX3F2HZ.js";import{b as Ar}from"./chunk-CHB75QIN.js";import{b as $r}from"./chunk-MNNOATCV.js";import"./chunk-GZHFXDDO.js";import"./chunk-QSDVMMYI.js";import{b as Sr}from"./chunk-PDVXLMUU.js";import{b as wr}from"./chunk-XKPFI566.js";import{b as xr}from"./chunk-KLMOJKL4.js";import{b as vr}from"./chunk-TIDZOIPX.js";import{b as kr}from"./chunk-6VUEI2GS.js";import{b as qr}from"./chunk-BYDV4VEF.js";import{b as Cr}from"./chunk-JLX6YWGA.js";import{b as br}from"./chunk-FLPVVSN5.js";import{d as Ir,e as Mr,f as jr}from"./chunk-DAGNL3F2.js";import{b as tr}from"./chunk-P7UCWJ33.js";import{b as lr}from"./chunk-N73TVRMN.js";import{b as ur}from"./chunk-THALLNXT.js";import{b as pr}from"./chunk-2SIXTZCJ.js";import{b as er}from"./chunk-3Y32LPNT.js";import{b as dr}from"./chunk-7BORMNPQ.js";import{b as cr}from"./chunk-N43DJTSI.js";import"./chunk-OBI37ZY4.js";import{b as hr}from"./chunk-N5OTVT4F.js";import{c as or,d as ar}from"./chunk-MAVV76T4.js";import{b as sr}from"./chunk-JTF74J6E.js";import{c as ir,d as gr}from"./chunk-RDZMRK5M.js";import{b as mr}from"./chunk-QEBPVWVB.js";import"./chunk-A4442AOC.js";import"./chunk-UYBH3FNE.js";import{b as Fr}from"./chunk-BARKRZDC.js";import{b as zr}from"./chunk-P6GNZPVW.js";import{b as fr}from"./chunk-IY3BUFJK.js";import{b as nr}from"./chunk-NFZDITRV.js";import{b as R}from"./chunk-PQNTKMH3.js";import{b as U}from"./chunk-PPBQJBC2.js";import{b as V}from"./chunk-NSUMEERA.js";import{b as W}from"./chunk-4PS5JJDT.js";import{c as X,d as Y}from"./chunk-W2FKF3MM.js";import{c as Z,d as _}from"./chunk-3MBAUIBB.js";import{b as N}from"./chunk-RT7TRQVZ.js";import{b as rr}from"./chunk-JXC25GVQ.js";import{b as G}from"./chunk-RJSAGJQJ.js";import{b as H}from"./chunk-YEKSVVRC.js";import{b as J}from"./chunk-26NO42TF.js";import{b as K}from"./chunk-QXB5WI2V.js";import{b as L}from"./chunk-LMK6G2HH.js";import{b as O}from"./chunk-ZKC5HQYO.js";import{b as P}from"./chunk-ROJPSS6N.js";import{b as Q}from"./chunk-7ECKLAVW.js";import{b as y}from"./chunk-NEQEZ32M.js";import{b as A}from"./chunk-ZA4HUKJ3.js";import{b as $}from"./chunk-5U7Q4GUC.js";import{b as S}from"./chunk-JQBC3FXE.js";import{b as T}from"./chunk-BDSRLH5T.js";import{b as B}from"./chunk-5G2VOPPJ.js";import{b as D}from"./chunk-SGA7Y45Z.js";import{b as E}from"./chunk-EUXCM6C4.js";import{b as w}from"./chunk-YLE2OYY6.js";import{b as x}from"./chunk-S7OHMN3F.js";import{b as v}from"./chunk-XAL6VWGA.js";import{d as k,e as q,f as C}from"./chunk-WT2HWDDA.js";import"./chunk-GIFF636B.js";import{b}from"./chunk-Q4QFIAHB.js";import"./chunk-G43H2WGH.js";import{b as I}from"./chunk-FEBB4TFH.js";import{b as M}from"./chunk-K7XSYP4L.js";import{b as j}from"./chunk-THLAHQXV.js";import{b as t}from"./chunk-YYQ22ZRL.js";import{b as l}from"./chunk-PS4LOXE5.js";import{b as u}from"./chunk-VNER2XXL.js";import{b as p}from"./chunk-4E3LY6YK.js";import{b as e}from"./chunk-5VFN7VVJ.js";import{b as d}from"./chunk-TEFXEYX3.js";import{b as c}from"./chunk-D2GFNFUN.js";import{b as h}from"./chunk-SXRVLCZ4.js";import"./chunk-FSZWFMB4.js";import"./chunk-4PRVMER6.js";import"./chunk-SE4C7FJY.js";import{b as i}from"./chunk-LJKIWB5F.js";import{b as g}from"./chunk-K47SEEPI.js";import"./chunk-5WFYIUU2.js";import{b as m}from"./chunk-X2I3PJTX.js";import"./chunk-D5WP4CKS.js";import"./chunk-K5IXNHO5.js";import{b as F}from"./chunk-4P5OA25Z.js";import"./chunk-OBH7XN5N.js";import{b as z}from"./chunk-KWLLB7S3.js";import{b as f}from"./chunk-EJQKHROT.js";import"./chunk-JBABAK44.js";import{b as n}from"./chunk-ITA43A73.js";import"./chunk-4VDEBYW7.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
|
package/dist/bin/shell/shell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B as un,C as fn,D as ie,E as Te,F as K,G as ge,H as ht,I as dn,J as T,K as hn,L as pn,M as be,N as Kt,O as pt,P as z,a as en,b as tn,c as sn,d as ft,e as q,f as W,g as we,h as Q,i as ve,j as Pe,k as Ht,l as dt,m as nn,n as Ut,o as rn,p as de,q as Se,r as on,s as an,t as qt,u as Zt,v as ke,w as ln,x as cn,y as ye,z as Gt}from"./chunks/chunk-LS25HZNJ.js";import{a as Ce,b as me}from"./chunks/chunk-4PRVMER6.js";import{a as Ze}from"./chunks/chunk-SE4C7FJY.js";import{a as ce,b as ue,c as re,d as fe,e as Qs,f as V,g as De,h as lt,i as ct,j as Js,k as te,l as _e,m as ut,n as he}from"./chunks/chunk-K5IXNHO5.js";import"./chunks/chunk-OBH7XN5N.js";import{a as pe}from"./chunks/chunk-4VDEBYW7.js";import{a as at}from"./chunks/chunk-KGOUQS5A.js";import*as Hr from"node:fs";import*as Ur from"node:readline";var Me=[{name:"echo",load:async()=>(await import("./chunks/echo-2MUAOGUE.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-3J7U3HHI.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-TZC5BRAY.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-ZXYOL67L.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-6OKMS3KO.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-5KLM4EA6.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DWKSZGOQ.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-5QIBTLJG.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XH2ZB7WT.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-OY7X62QC.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-5TCJXDGY.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-4O2C4V42.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-6VBAPL3Y.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-YNOUXNUY.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YMNRW3F3.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-V537TDFR.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-ZIV3TFVG.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-XH7E4E2C.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-3R5G2XL4.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-WNL6TIIN.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-PWEGD656.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-NZSEYCI6.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-FZWFZEN5.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-R3F3Z5DX.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-HDHQDWRG.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-3UVLMQ2K.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-GDDRKGRB.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-UHEPS2UL.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-XH3L75DR.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-XSVNTAWH.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-26XPP5KB.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-OYZ7KOYR.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-XXKZCWY5.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-NOZ7FFXW.js")).split},{name:"column",load:async()=>(await import("./chunks/column-XGV32UPN.js")).column},{name:"join",load:async()=>(await import("./chunks/join-Y4Q5WVVE.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-HK2SYCAR.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-K777TRNA.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-KBUKWB2E.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-5FAOMLBL.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-HEKABARE.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-66BNA4IN.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-UUKG55YW.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-YWPEV2QC.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-DP5UZP52.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-DP5UZP52.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KRGKPFOI.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-RJTQJAKW.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-RJTQJAKW.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-CXQ33VMW.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-YXBFJFHG.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-LE7GMFZD.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-6VDN5QZ5.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-PICQVS6Q.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-RS7REDYT.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-4C3A4THJ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-V7KBLSQ7.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-MLHUWFYI.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-NCLXV2S3.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BHNJ5ALF.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-HJJ3NJ5L.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-D5YKS5NV.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-WVZA3MCP.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-JF5TTAKQ.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-67WZ6OMV.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-TZBNTR4K.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-WY6RKE32.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-E7PN2UWC.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-52FBC34W.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Me.push({name:"tar",load:async()=>(await import("./chunks/tar-7B5KH3QG.js")).tarCommand}),Me.push({name:"yq",load:async()=>(await import("./chunks/yq-WUJ5JNDT.js")).yqCommand}),Me.push({name:"xan",load:async()=>(await import("./chunks/xan-FMSZPFX4.js")).xanCommand}),Me.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-4SEIR46P.js")).sqlite3Command}));var Xt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Xt.push({name:"python3",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).python3Command}),Xt.push({name:"python",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).pythonCommand}));var Kr=[{name:"curl",load:async()=>(await import("./chunks/curl-RWQO3SBN.js")).curlCommand}],mn=new Map;function Yt(e){return{name:e.name,async execute(t,s){let n=mn.get(e.name);if(n||(n=await e.load(),mn.set(e.name,n)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:r}=await import("./chunks/flag-coverage-GELILQAH.js");r(s.coverage,e.name,t)}return n.execute(t,s)}}}function yn(e){return(e?Me.filter(s=>e.includes(s.name)):Me).map(Yt)}function gn(){return Kr.map(Yt)}function wn(){return Xt.map(Yt)}function vn(e){return"load"in e&&typeof e.load=="function"}function bn(e){let t=null;return{name:e.name,async execute(s,n){return t||(t=await e.load()),t.execute(s,n)}}}var Xr=new TextEncoder,Yr=new TextDecoder;function Fe(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)s[n/2]=parseInt(e.slice(n,n+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,r=>r.charCodeAt(0));let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}return Xr.encode(e)}function mt(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let n="";for(let r=0;r<e.length;r+=s){let i=e.subarray(r,r+s);n+=String.fromCharCode(...i)}return n}return Yr.decode(e)}function Ne(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var yt=new TextEncoder;function Qr(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function se(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Ge=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,n]of Object.entries(t))Qr(n)?this.writeFileSync(s,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(s,n)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let n=s.split("/").filter(i=>i&&i!=="."),r=[];for(let i of n)i===".."?r.pop():r.push(i);return`/${r.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.lastIndexOf("/");return n===0?"/":s.slice(0,n)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,n,r){se(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Ne(n),a=Fe(s,o);this.data.set(i,{type:"file",content:a,mode:r?.mode??420,mtime:r?.mtime??new Date})}async readFile(t,s){let n=await this.readFileBuffer(t),r=Ne(s);return mt(n,r)}async readFileBuffer(t){se(t,"open");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content instanceof Uint8Array?n.content:yt.encode(n.content)}async writeFile(t,s,n){this.writeFileSync(t,s,n)}async appendFile(t,s,n){se(t,"append");let r=this.normalizePath(t),i=this.data.get(r);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=Ne(n),a=Fe(s,o);if(i?.type==="file"){let c=i.content instanceof Uint8Array?i.content:yt.encode(i.content),l=new Uint8Array(c.length+a.length);l.set(c),l.set(a,c.length),this.data.set(r,{type:"file",content:l,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,n)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){se(t,"stat");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}async lstat(t){se(t,"lstat");let s=this.resolveIntermediateSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=this.dirname(t);return this.normalizePath(n==="/"?`/${s}`:`${n}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/");if(n.length<=1)return s;let r="",i=new Set;for(let o=0;o<n.length-1;o++){let a=n[o];r=`${r}/${a}`;let c=this.data.get(r),l=0,u=40;for(;c&&c.type==="symlink"&&l<u;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(r),r=this.resolveSymlink(r,c.target),c=this.data.get(r),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/"),r="",i=new Set;for(let o of n){r=`${r}/${o}`;let a=this.data.get(r),c=0,l=40;for(;a&&a.type==="symlink"&&c<l;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(r),r=this.resolveSymlink(r,a.target),a=this.data.get(r),c++}if(c>=l)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return r}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){se(t,"mkdir");let n=this.normalizePath(t);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let r=this.dirname(n);if(r!=="/"&&!this.data.has(r))if(s?.recursive)this.mkdirSync(r,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(n=>n.name)}async readdirWithFileTypes(t){se(t,"scandir");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Set;for(;n&&n.type==="symlink";){if(r.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);r.add(s),s=this.resolveSymlink(s,n.target),n=this.data.get(s)}if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,c]of this.data.entries())if(a!==s&&a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(t,s){se(t,"rm");let n=this.normalizePath(t),r=this.data.get(n);if(!r){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(r.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(a,s)}}}this.data.delete(n)}async cp(t,s,n){se(t,"cp"),se(s,"cp");let r=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let c of a){let l=r==="/"?`/${c}`:`${r}/${c}`,u=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(l,u,n)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(n)}async chmod(t,s){se(t,"chmod");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);r.mode=s}async symlink(t,s){se(s,"symlink");let n=this.normalizePath(s);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){se(t,"link"),se(s,"link");let n=this.normalizePath(t),r=this.normalizePath(s),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(r))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){se(t,"readlink");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return n.target}async realpath(t){se(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,n){se(t,"utimes");let r=this.normalizePath(t),i=this.resolvePathWithSymlinks(r),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=n}};function Jr(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function ei(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function ti(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function si(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${en}
|
|
2
|
+
import{B as un,C as fn,D as ie,E as Te,F as K,G as ge,H as ht,I as dn,J as T,K as hn,L as pn,M as be,N as Kt,O as pt,P as z,a as en,b as tn,c as sn,d as ft,e as q,f as W,g as we,h as Q,i as ve,j as Pe,k as Ht,l as dt,m as nn,n as Ut,o as rn,p as de,q as Se,r as on,s as an,t as qt,u as Zt,v as ke,w as ln,x as cn,y as ye,z as Gt}from"./chunks/chunk-LS25HZNJ.js";import{a as Ce,b as me}from"./chunks/chunk-4PRVMER6.js";import{a as Ze}from"./chunks/chunk-SE4C7FJY.js";import{a as ce,b as ue,c as re,d as fe,e as Qs,f as V,g as De,h as lt,i as ct,j as Js,k as te,l as _e,m as ut,n as he}from"./chunks/chunk-K5IXNHO5.js";import"./chunks/chunk-OBH7XN5N.js";import{a as pe}from"./chunks/chunk-4VDEBYW7.js";import{a as at}from"./chunks/chunk-KGOUQS5A.js";import*as Hr from"node:fs";import*as Ur from"node:readline";var Me=[{name:"echo",load:async()=>(await import("./chunks/echo-2MUAOGUE.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-3J7U3HHI.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-TZC5BRAY.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-ZXYOL67L.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-6OKMS3KO.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-5KLM4EA6.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DWKSZGOQ.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-5QIBTLJG.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XH2ZB7WT.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-OY7X62QC.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-5TCJXDGY.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-4O2C4V42.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-6VBAPL3Y.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-YNOUXNUY.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YMNRW3F3.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-V537TDFR.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-ZIV3TFVG.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-XH7E4E2C.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-FRIPZKKT.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-3R5G2XL4.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-WNL6TIIN.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-PWEGD656.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-NZSEYCI6.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-FZWFZEN5.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-R3F3Z5DX.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-HDHQDWRG.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-3UVLMQ2K.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-GDDRKGRB.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-UHEPS2UL.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-XH3L75DR.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-XSVNTAWH.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-26XPP5KB.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-OYZ7KOYR.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-XXKZCWY5.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-NOZ7FFXW.js")).split},{name:"column",load:async()=>(await import("./chunks/column-XGV32UPN.js")).column},{name:"join",load:async()=>(await import("./chunks/join-Y4Q5WVVE.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-HK2SYCAR.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-K777TRNA.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-KBUKWB2E.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-5FAOMLBL.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-HEKABARE.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-66BNA4IN.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-EVLPSWFF.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-3GODYSFD.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-UUKG55YW.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-YWPEV2QC.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-DP5UZP52.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-DP5UZP52.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KRGKPFOI.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-WB6O736J.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-WB6O736J.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-CXQ33VMW.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-YXBFJFHG.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-LE7GMFZD.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-6VDN5QZ5.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-PICQVS6Q.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-RS7REDYT.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-4C3A4THJ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-V7KBLSQ7.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-MLHUWFYI.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-NCLXV2S3.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BHNJ5ALF.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-HJJ3NJ5L.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-D5YKS5NV.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-WVZA3MCP.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-JF5TTAKQ.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-67WZ6OMV.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-TZBNTR4K.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-WY6RKE32.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-E7PN2UWC.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-52FBC34W.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-EENEW6WQ.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Me.push({name:"tar",load:async()=>(await import("./chunks/tar-7B5KH3QG.js")).tarCommand}),Me.push({name:"yq",load:async()=>(await import("./chunks/yq-WUJ5JNDT.js")).yqCommand}),Me.push({name:"xan",load:async()=>(await import("./chunks/xan-FMSZPFX4.js")).xanCommand}),Me.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-4SEIR46P.js")).sqlite3Command}));var Xt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Xt.push({name:"python3",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).python3Command}),Xt.push({name:"python",load:async()=>(await import("./chunks/python3-ZWX5SFJ3.js")).pythonCommand}));var Kr=[{name:"curl",load:async()=>(await import("./chunks/curl-RWQO3SBN.js")).curlCommand}],mn=new Map;function Yt(e){return{name:e.name,async execute(t,s){let n=mn.get(e.name);if(n||(n=await e.load(),mn.set(e.name,n)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:r}=await import("./chunks/flag-coverage-SFRIE2LL.js");r(s.coverage,e.name,t)}return n.execute(t,s)}}}function yn(e){return(e?Me.filter(s=>e.includes(s.name)):Me).map(Yt)}function gn(){return Kr.map(Yt)}function wn(){return Xt.map(Yt)}function vn(e){return"load"in e&&typeof e.load=="function"}function bn(e){let t=null;return{name:e.name,async execute(s,n){return t||(t=await e.load()),t.execute(s,n)}}}var Xr=new TextEncoder,Yr=new TextDecoder;function Fe(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)s[n/2]=parseInt(e.slice(n,n+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,r=>r.charCodeAt(0));let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}return Xr.encode(e)}function mt(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let n="";for(let r=0;r<e.length;r+=s){let i=e.subarray(r,r+s);n+=String.fromCharCode(...i)}return n}return Yr.decode(e)}function Ne(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var yt=new TextEncoder;function Qr(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function se(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Ge=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,n]of Object.entries(t))Qr(n)?this.writeFileSync(s,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(s,n)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let n=s.split("/").filter(i=>i&&i!=="."),r=[];for(let i of n)i===".."?r.pop():r.push(i);return`/${r.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.lastIndexOf("/");return n===0?"/":s.slice(0,n)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,n,r){se(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Ne(n),a=Fe(s,o);this.data.set(i,{type:"file",content:a,mode:r?.mode??420,mtime:r?.mtime??new Date})}async readFile(t,s){let n=await this.readFileBuffer(t),r=Ne(s);return mt(n,r)}async readFileBuffer(t){se(t,"open");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content instanceof Uint8Array?n.content:yt.encode(n.content)}async writeFile(t,s,n){this.writeFileSync(t,s,n)}async appendFile(t,s,n){se(t,"append");let r=this.normalizePath(t),i=this.data.get(r);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=Ne(n),a=Fe(s,o);if(i?.type==="file"){let c=i.content instanceof Uint8Array?i.content:yt.encode(i.content),l=new Uint8Array(c.length+a.length);l.set(c),l.set(a,c.length),this.data.set(r,{type:"file",content:l,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,n)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){se(t,"stat");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}async lstat(t){se(t,"lstat");let s=this.resolveIntermediateSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};let r=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=yt.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=this.dirname(t);return this.normalizePath(n==="/"?`/${s}`:`${n}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/");if(n.length<=1)return s;let r="",i=new Set;for(let o=0;o<n.length-1;o++){let a=n[o];r=`${r}/${a}`;let c=this.data.get(r),l=0,u=40;for(;c&&c.type==="symlink"&&l<u;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(r),r=this.resolveSymlink(r,c.target),c=this.data.get(r),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/"),r="",i=new Set;for(let o of n){r=`${r}/${o}`;let a=this.data.get(r),c=0,l=40;for(;a&&a.type==="symlink"&&c<l;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(r),r=this.resolveSymlink(r,a.target),a=this.data.get(r),c++}if(c>=l)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return r}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){se(t,"mkdir");let n=this.normalizePath(t);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let r=this.dirname(n);if(r!=="/"&&!this.data.has(r))if(s?.recursive)this.mkdirSync(r,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(n=>n.name)}async readdirWithFileTypes(t){se(t,"scandir");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Set;for(;n&&n.type==="symlink";){if(r.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);r.add(s),s=this.resolveSymlink(s,n.target),n=this.data.get(s)}if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,c]of this.data.entries())if(a!==s&&a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(t,s){se(t,"rm");let n=this.normalizePath(t),r=this.data.get(n);if(!r){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(r.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(a,s)}}}this.data.delete(n)}async cp(t,s,n){se(t,"cp"),se(s,"cp");let r=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let c of a){let l=r==="/"?`/${c}`:`${r}/${c}`,u=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(l,u,n)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(n)}async chmod(t,s){se(t,"chmod");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);r.mode=s}async symlink(t,s){se(s,"symlink");let n=this.normalizePath(s);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){se(t,"link"),se(s,"link");let n=this.normalizePath(t),r=this.normalizePath(s),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(r))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){se(t,"readlink");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return n.target}async realpath(t){se(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,n){se(t,"utimes");let r=this.normalizePath(t),i=this.resolvePathWithSymlinks(r),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=n}};function Jr(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function ei(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function ti(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function si(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${en}
|
|
3
3
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
4
4
|
`),e.writeFileSync("/proc/self/status",tn()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function En(e,t){Jr(e)&&(ei(e,t),ti(e),si(e))}var ni=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],ri=["braceexpand","hashall","interactive-comments"];function Qt(e){let t=[],s=[...ri.map(n=>({name:n,enabled:!0})),...ni.map(n=>({name:n,enabled:e[n]}))].sort((n,r)=>n.name.localeCompare(r.name));for(let n of s)n.enabled&&t.push(n.name);return t.join(":")}function We(e){e.state.env.set("SHELLOPTS",Qt(e.state.options))}var ii=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function Jt(e){let t=[];for(let s of ii)e[s]&&t.push(s);return t.join(":")}function es(e){e.state.env.set("BASHOPTS",Jt(e.state.shoptOptions))}var oi="BASH_ALIAS_";function $n(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Sn(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function An(e,t){return e.env.get(`${oi}${t}`)}function ts(e,t,s){if(!t.name||!$n(t.name))return t;let n=Sn(t.name);if(!n)return t;let r=An(e,n);if(!r||s.has(n))return t;try{s.add(n);let i=new W,o=r,a=r.endsWith(" ");if(!a)for(let f of t.args){let d=Cn(f);o+=` ${d}`}let c;try{c=i.parse(o)}catch(f){if(f instanceof ft)throw f;return t}if(c.statements.length!==1||c.statements[0].pipelines.length!==1||c.statements[0].pipelines[0].commands.length!==1)return _n(t,r);let l=c.statements[0].pipelines[0].commands[0];if(l.type!=="SimpleCommand")return _n(t,r);let u={...l,assignments:[...t.assignments,...l.assignments],redirections:[...l.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if($n(f)){let d=Sn(f);if(d&&An(e,d)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=ts(e,h,s);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw s.delete(n),i}}function _n(e,t){let s=t;for(let o of e.args){let a=Cn(o);s+=` ${a}`}let n=new W,r=n.parseWordFromString("eval",!1,!1),i=n.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:r,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Cn(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(n=>n.type==="Literal"?n.value:`$${n.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function Pn(e,t){let s=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!n||!s.endsWith(")"))return null;let r=n[1],i=[],o=!1,a="",c=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let d=f.indexOf("=(");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let d=f.split(/(\s+)/);for(let h of d)/^\s+$/.test(h)?(a||c)&&(i.push(a),a="",c=!1):h&&(a+=h)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=dt({type:"Word",parts:[u]});else{(a||c)&&(i.push(a),a="",c=!1);let d=await be(e,{type:"Word",parts:[u]});i.push(...d.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(c=!0);let f=await T(e,{type:"Word",parts:[u]});a+=f}(a||c)&&i.push(a);let l=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${r}=(${l.join(" ")})`}async function kn(e,t){let s=-1,n=-1,r=!1;for(let p=0;p<t.parts.length;p++){let g=t.parts[p];if(g.type==="Literal"){let S=g.value.indexOf("+=");if(S!==-1){let P=g.value.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)){s=p,n=S,r=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(P)){s=p,n=S,r=!0;break}}let v=g.value.indexOf("=");if(v!==-1&&(v===0||g.value[v-1]!=="+")){let P=g.value.slice(0,v);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(P)){s=p,n=v;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=r?2:1,c=o.value.slice(0,n),l=o.value.slice(n+a),u=t.parts.slice(s+1),f="";for(let p of i)f+=await T(e,{type:"Word",parts:[p]});f+=c;let d={type:"Word",parts:l!==""?[{type:"Literal",value:l},...u]:u},h=d.parts.length>0?await T(e,d):"";return`${f}${r?"+=":"="}${h}`}var ai=["tar","yq","xan","sqlite3","python3","python"];function Nn(e){return ai.includes(e)}var L=Object.freeze({stdout:"",stderr:"",exitCode:0});function M(e=""){return{stdout:e,stderr:"",exitCode:0}}function A(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function C(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function U(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Ae(e,t,s="",n=""){throw new te(e,t,s,n)}function ss(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new _e;return L}if(t.length>1)throw new V(1,"",`bash: break: too many arguments
|
|
5
5
|
`);let s=1;if(t.length>0){let n=Number.parseInt(t[0],10);if(Number.isNaN(n)||n<1)throw new V(128,"",`bash: break: ${t[0]}: numeric argument required
|
|
@@ -634,7 +634,7 @@ ${e} ()
|
|
|
634
634
|
`),r=e.includes(" "),i=e.includes("\\"),o=e.includes("'");if(s||n||r||i){let c="";for(let l of e){let u=l.charCodeAt(0);l===`
|
|
635
635
|
`?c+="\\n":l===" "?c+="\\t":l==="\\"?c+="\\\\":l==="'"?c+="'":l==='"'?c+='"':u<32||u===127?u<256?c+=`\\x${u.toString(16).padStart(2,"0")}`:c+=`\\u${u.toString(16).padStart(4,"0")}`:c+=l}return`$'${c}'`}return o?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function xr(e,t,s){if(!e.state.options.xtrace)return"";let n=await Or(e),r=[t,...s],i=oo(r);return`${n}${i}
|
|
636
636
|
`}async function Dr(e,t,s){return e.state.options.xtrace?`${await Or(e)}${t}=${s}
|
|
637
|
-
`:""}async function Tr(e,t,s){let n=t.timed?performance.now():0,r="",i=L,o=0,a=[],c=t.commands.length>1,l=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let d=t.commands[f],h=f===t.commands.length-1;c&&(e.state.lastArg="");let
|
|
637
|
+
`:""}async function Tr(e,t,s){let n=t.timed?performance.now():0,r="",i=L,o=0,a=[],c=t.commands.length>1,l=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let d=t.commands[f],h=f===t.commands.length-1,m=f===0;c&&(e.state.lastArg="",m||(e.state.groupStdin=void 0));let g=c&&(!h||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,S;try{S=await s(d,r)}catch(v){if(v instanceof lt)S={stdout:v.stdout,stderr:v.stderr,exitCode:1};else if(v instanceof V&&t.commands.length>1)S={stdout:v.stdout,stderr:v.stderr,exitCode:v.exitCode};else if(v instanceof fe&&t.commands.length>1)S={stdout:v.stdout,stderr:v.stderr,exitCode:v.exitCode};else throw g&&(e.state.env=g),v}g&&(e.state.env=g),a.push(S.exitCode),S.exitCode!==0&&(o=S.exitCode),h?i=S:t.pipeStderr?.[f]??!1?(r=S.stderr+S.stdout,i={stdout:"",stderr:"",exitCode:S.exitCode}):(r=S.stdout,i={stdout:"",stderr:S.stderr,exitCode:S.exitCode})}if(t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let f of e.state.env.keys())f.startsWith("PIPESTATUS_")&&e.state.env.delete(f);for(let f=0;f<a.length;f++)e.state.env.set(`PIPESTATUS_${f}`,String(a[f]));e.state.env.set("PIPESTATUS__length",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let d=(performance.now()-n)/1e3,h=Math.floor(d/60),m=d%60,p;t.timePosix?p=`real ${d.toFixed(2)}
|
|
638
638
|
user 0.00
|
|
639
639
|
sys 0.00
|
|
640
640
|
`:p=`
|
|
@@ -676,7 +676,7 @@ This is a defense-in-depth measure and indicates a bug in just-bash. Please repo
|
|
|
676
676
|
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",n],["OLDPWD",n],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=Wr({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=Gs(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,this.state={env:r,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,bashPid:process.pid,nextVirtualPid:process.pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",Qt(this.state.options)),this.state.env.set("BASHOPTS",Jt(this.state.shoptOptions)),En(s,this.useDefaultLayout),n!=="/"&&s instanceof Ge)try{s.mkdirSync(n,{recursive:!0})}catch{}for(let i of yn(t.commands))this.registerCommand(i);if(t.network)for(let i of gn())this.registerCommand(i);if(t.python)for(let i of wn())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)vn(i)?this.registerCommand(bn(i)):this.registerCommand(i)}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let n=`#!/bin/bash
|
|
677
677
|
# Built-in command: ${t.name}
|
|
678
678
|
`;try{s.writeFileSync(`/bin/${t.name}`,n)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,n)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
679
|
-
`,exitCode:1,env:me(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:me(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let n=s?.cwd??this.state.cwd,r,i=n;if(s?.cwd)if(s.env&&"PWD"in s.env)r=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{r=await this.fs.realpath(n),i=r}catch{r=n}else r=n;let o=new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);r!==void 0&&o.set("PWD",r);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable},c=t;s?.rawScript||(c=No(t));let u=(this.defenseInDepthConfig?zt.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let d=we(c),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new tt(h,a).executeScript(d);return this.logResult(p)};return u?await u.run(f):await f()}catch(f){if(f instanceof V)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:me(this.state.env,s?.env)});if(f instanceof he)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:me(this.state.env,s?.env)});if(f instanceof De)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:me(this.state.env,s?.env)});if(f instanceof te)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:te.EXIT_CODE,env:me(this.state.env,s?.env)});if(f instanceof ne)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
679
|
+
`,exitCode:1,env:me(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:me(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let n=s?.cwd??this.state.cwd,r,i=n;if(s?.cwd)if(s.env&&"PWD"in s.env)r=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{r=await this.fs.realpath(n),i=r}catch{r=n}else r=n;let o=new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);r!==void 0&&o.set("PWD",r);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:s?.stdin},c=t;s?.rawScript||(c=No(t));let u=(this.defenseInDepthConfig?zt.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let d=we(c),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new tt(h,a).executeScript(d);return this.logResult(p)};return u?await u.run(f):await f()}catch(f){if(f instanceof V)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:me(this.state.env,s?.env)});if(f instanceof he)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:me(this.state.env,s?.env)});if(f instanceof De)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:me(this.state.env,s?.env)});if(f instanceof te)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:te.EXIT_CODE,env:me(this.state.env,s?.env)});if(f instanceof ne)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
680
680
|
`,exitCode:1,env:me(this.state.env,s?.env)});if(f.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${f.message}
|
|
681
681
|
`,exitCode:2,env:me(this.state.env,s?.env)});if(f instanceof sn)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
682
682
|
`,exitCode:2,env:me(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
package/dist/bundle/browser.js
CHANGED
|
@@ -541,7 +541,7 @@ ${a} director${a===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"
|
|
|
541
541
|
`),t.exec?t.exec(b,{cwd:t.cwd}):{stdout:`${b}
|
|
542
542
|
`,stderr:"",exitCode:0}},y=async w=>{if(i!==null&&i>1)for(let b=0;b<w.length;b+=i){let x=w.slice(b,b+i),S=await Promise.all(x.map(g));for(let O of S)p+=O.stdout,h+=O.stderr,O.exitCode!==0&&(m=O.exitCode)}else for(let b of w){let x=await g(b);p+=x.stdout,h+=x.stderr,x.exitCode!==0&&(m=x.exitCode)}};if(n!==null){let w=f.map(b=>u.map(x=>x.replaceAll(n,b)));await y(w)}else if(s!==null){let w=[];for(let b=0;b<f.length;b+=s){let x=f.slice(b,b+s);w.push([...u,...x])}await y(w)}else{let w=[...u,...f],b=await g(w);p+=b.stdout,h+=b.stderr,m=b.exitCode}return{stdout:p,stderr:h,exitCode:m}}},v9={name:"xargs",flags:[{flag:"-I",type:"value",valueHint:"string"},{flag:"-d",type:"value",valueHint:"delimiter"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-0",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-r",type:"boolean"}],stdinType:"text"}});var Ra={};Q(Ra,{falseCommand:()=>O9,falseFlagsForFuzzing:()=>$9,flagsForFuzzing:()=>R9,trueCommand:()=>I9});var I9,O9,R9,$9,$a=I(()=>{"use strict";I9={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},O9={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}},R9={name:"true",flags:[]},$9={name:"false",flags:[]}});var lh={};Q(lh,{clearCommand:()=>P9,flagsForFuzzing:()=>D9});var T9,P9,D9,ch=I(()=>{"use strict";se();T9={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},P9={name:"clear",async execute(e,t){return U(e)?M(T9):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}},D9={name:"clear",flags:[]}});var Ta={};Q(Ta,{bashCommand:()=>_9,flagsForFuzzing:()=>F9,shCommand:()=>L9,shFlagsForFuzzing:()=>M9});async function Ar(e,t,n,r){if(!r.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
|
|
543
543
|
`,exitCode:1};let s=Js(r.exportedEnv||{},{0:t,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")});n.forEach((a,l)=>{s[String(l+1)]=a});let i=e;if(i.startsWith("#!")){let a=i.indexOf(`
|
|
544
|
-
`);a!==-1&&(i=i.slice(a+1))}return await r.exec(i,{env:s,cwd:r.cwd})}var uh,_9,L9,F9,M9,Pa=I(()=>{"use strict";On();se();uh={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},_9={name:"bash",async execute(e,t){if(U(e))return M(uh);if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"bash",o=e.slice(3);return Ar(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?Ar(t.stdin,"bash",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return Ar(i,n,r,t)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
|
|
544
|
+
`);a!==-1&&(i=i.slice(a+1))}return await r.exec(i,{env:s,cwd:r.cwd,stdin:r.stdin})}var uh,_9,L9,F9,M9,Pa=I(()=>{"use strict";On();se();uh={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},_9={name:"bash",async execute(e,t){if(U(e))return M(uh);if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"bash",o=e.slice(3);return Ar(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?Ar(t.stdin,"bash",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return Ar(i,n,r,t)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
|
|
545
545
|
`,exitCode:127}}}},L9={name:"sh",async execute(e,t){if(U(e))return M({...uh,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"sh",o=e.slice(3);return Ar(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?Ar(t.stdin,"sh",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return Ar(i,n,r,t)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
|
|
546
546
|
`,exitCode:127}}}};F9={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},M9={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function Ie(e){return!fh.has(e)}function Pe(e,t,n){Ie(t)&&(e[t]=n)}function un(e,t){return Object.hasOwn(e,t)}function Ze(e){return Object.assign(Object.create(null),e)}function Da(...e){return Object.assign(Object.create(null),...e)}var fh,WN,En=I(()=>{"use strict";fh=new Set(["__proto__","constructor","prototype"]),WN=new Set([...fh,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function _a(e,t,n,r,s,i,o,a,l,c){switch(t){case"sort":return Array.isArray(e)?[[...e].sort(o)]:[null];case"sort_by":return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((f,p)=>{let h=s(f,n[0],r)[0],m=s(p,n[0],r)[0];return o(h,m)})];case"bsearch":{if(!Array.isArray(e)){let f=e===null?"null":typeof e=="object"?"object":typeof e;throw new Error(`${f} (${JSON.stringify(e)}) cannot be searched from`)}return n.length===0?[null]:s(e,n[0],r).map(f=>{let p=0,h=e.length;for(;p<h;){let m=p+h>>>1;o(e[m],f)<0?p=m+1:h=m}return p<e.length&&o(e[p],f)===0?p:-p-1})}case"unique_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let p of e){let h=s(p,n[0],r)[0],m=JSON.stringify(h);u.has(m)||u.set(m,{item:p,key:h})}let f=[...u.values()];return f.sort((p,h)=>o(p.key,h.key)),[f.map(p=>p.item)]}case"group_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let f of e){let p=JSON.stringify(s(f,n[0],r)[0]);u.has(p)||u.set(p,[]),u.get(p)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)>0?u:f)]:[null];case"max_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let p=s(u,n[0],r)[0],h=s(f,n[0],r)[0];return o(p,h)>0?u:f})];case"min":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)<0?u:f)]:[null];case"min_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let p=s(u,n[0],r)[0],h=s(f,n[0],r)[0];return o(p,h)<0?u:f})];case"add":{let u=f=>{let p=f.filter(h=>h!==null);return p.length===0?null:p.every(h=>typeof h=="number")?p.reduce((h,m)=>h+m,0):p.every(h=>typeof h=="string")?p.join(""):p.every(h=>Array.isArray(h))?p.flat():p.every(h=>h&&typeof h=="object"&&!Array.isArray(h))?Js(...p):null};if(n.length>=1){let f=s(e,n[0],r);return[u(f)]}return Array.isArray(e)?[u(e)]:[null]}case"any":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(s(f,n[1],r).some(a))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(e)?[e.some(u=>a(s(u,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(a)]:[!1]}case"all":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(!s(f,n[1],r).some(a))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(e)?[e.every(u=>a(s(u,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(a)]:[!0]}case"select":return n.length===0?[e]:s(e,n[0],r).some(a)?[e]:[];case"map":return n.length===0||!Array.isArray(e)?[null]:[e.flatMap(f=>s(f,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(e))return[e.flatMap(u=>s(u,n[0],r))];if(e&&typeof e=="object"){let u=Object.create(null);for(let[f,p]of Object.entries(e)){if(!Ie(f))continue;let h=s(p,n[0],r);h.length>0&&Pe(u,f,h[0])}return[u]}return[null]}case"has":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(e)&&typeof f=="number"?[f>=0&&f<e.length]:e&&typeof e=="object"&&typeof f=="string"?[un(e,f)]:[!1]}case"in":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(f)&&typeof e=="number"?[e>=0&&e<f.length]:f&&typeof f=="object"&&typeof e=="string"?[un(f,e)]:[!1]}case"contains":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(e,u[0])]}case"inside":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(u[0],e)]}default:return null}}var ph=I(()=>{"use strict";On();En()});function La(e,t,n,r,s,i,o,a){switch(t){case"first":if(n.length>0)try{let l=i(e,n[0],r);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof a)throw l;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case"last":if(n.length>0){let l=s(e,n[0],r);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case"nth":{if(n.length<1)return[null];let l=s(e,n[0],r);if(n.length>1){for(let u of l)if(u<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(e,n[1],r)}catch(u){if(u instanceof a)throw u;c=[]}return l.flatMap(u=>{let f=u;return f<c.length?[c[f]]:[]})}return Array.isArray(e)?l.flatMap(c=>{let u=c;if(u<0)throw new Error("nth doesn't support negative indices");return u<e.length?[e[u]]:[null]}):[null]}case"range":{if(n.length===0)return[];let l=s(e,n[0],r);if(n.length===1){let p=[];for(let h of l){let m=h;for(let d=0;d<m;d++)p.push(d)}return p}let c=s(e,n[1],r);if(n.length===2){let p=[];for(let h of l)for(let m of c){let d=h,g=m;for(let y=d;y<g;y++)p.push(y)}return p}let u=s(e,n[2],r),f=[];for(let p of l)for(let h of c)for(let m of u){let d=p,g=h,y=m;if(y!==0)if(y>0)for(let w=d;w<g;w+=y)f.push(w);else for(let w=d;w>g;w+=y)f.push(w)}return f}case"limit":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(e,n[1],r)}catch(p){if(p instanceof a)throw p;f=[]}return f.slice(0,u)});case"isempty":{if(n.length<1)return[!0];try{return[i(e,n[0],r).length===0]}catch(l){if(l instanceof a)throw l;return[!0]}}case"isvalid":{if(n.length<1)return[!0];try{return[s(e,n[0],r).length>0]}catch(l){if(l instanceof a)throw l;return[!1]}}case"skip":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("skip doesn't support negative count");return s(e,n[1],r).slice(u)});case"until":{if(n.length<2)return[e];let l=e,c=r.limits.maxIterations;for(let u=0;u<c;u++){if(s(l,n[0],r).some(o))return[l];let p=s(l,n[1],r);if(p.length===0)return[l];l=p[0]}throw new a(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u&&s(c,n[0],r).some(o);f++){l.push(c);let h=s(c,n[1],r);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new a(`jq while: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(n.length===0)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u;f++){l.push(c);let p=s(c,n[0],r);if(p.length===0)break;c=p[0]}if(l.length>=u)throw new a(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var hh=I(()=>{"use strict"});function Fa(e,t,n,r,s){switch(t){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof e!="number")return[null];let i=new Date(e*1e3),o=i.getUTCFullYear(),a=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),p=i.getUTCDay(),h=Date.UTC(o,0,1),m=Math.floor((i.getTime()-h)/(1440*60*1e3));return[[o,a,l,c,u,f,p,m]]}case"mktime":{if(!Array.isArray(e))throw new Error("mktime requires parsed datetime inputs");let[i,o,a,l=0,c=0,u=0]=e;if(typeof i!="number"||typeof o!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,o,a??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strftime/1 requires a string format");let a;if(typeof e=="number")a=new Date(e*1e3);else if(Array.isArray(e)){let[p,h,m,d=0,g=0,y=0]=e;if(typeof p!="number"||typeof h!="number")throw new Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(p,h,m??1,d??0,g??0,y??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(p,h=2)=>String(p).padStart(h,"0");return[o.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,u(a.getUTCMonth()+1)).replace(/%d/g,u(a.getUTCDate())).replace(/%H/g,u(a.getUTCHours())).replace(/%M/g,u(a.getUTCMinutes())).replace(/%S/g,u(a.getUTCSeconds())).replace(/%A/g,l[a.getUTCDay()]).replace(/%B/g,c[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(n.length===0)return[null];if(typeof e!="string")throw new Error("strptime/1 requires a string input");let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strptime/1 requires a string format");if(o==="%Y-%m-%dT%H:%M:%SZ"){let l=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(l){let[,c,u,f,p,h,m]=l.map(Number),d=new Date(Date.UTC(c,u-1,f,p,h,m)),g=d.getUTCDay(),y=Date.UTC(c,0,1),w=Math.floor((d.getTime()-y)/(1440*60*1e3));return[[c,u-1,f,p,h,m,g,w]]}}let a=new Date(e);if(!Number.isNaN(a.getTime())){let l=a.getUTCFullYear(),c=a.getUTCMonth(),u=a.getUTCDate(),f=a.getUTCHours(),p=a.getUTCMinutes(),h=a.getUTCSeconds(),m=a.getUTCDay(),d=Date.UTC(l,0,1),g=Math.floor((a.getTime()-d)/(1440*60*1e3));return[[l,c,u,f,p,h,m,g]]}throw new Error(`Cannot parse date: ${e}`)}case"fromdate":{if(typeof e!="string")throw new Error("fromdate requires a string input");let i=new Date(e);if(Number.isNaN(i.getTime()))throw new Error(`date "${e}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof e!="number")throw new Error("todate requires a number input");return[new Date(e*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}var dh=I(()=>{"use strict"});function Zt(e){return e!==!1&&e!==null}function Sr(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ls(e,t){return typeof e=="number"&&typeof t=="number"?e-t:typeof e=="string"&&typeof t=="string"?e.localeCompare(t):0}function Ma(e,t){let n=Ze(e);for(let r of Object.keys(t))Ie(r)&&(un(n,r)&&n[r]&&typeof n[r]=="object"&&!Array.isArray(n[r])&&t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])?Pe(n,r,Ma(n[r],t[r])):Pe(n,r,t[r]));return n}function Cr(e,t=3e3){let n=0,r=e;for(;n<t;)if(Array.isArray(r)){if(r.length===0)return n+1;r=r[0],n++}else if(r!==null&&typeof r=="object"){let s=Object.keys(r);if(s.length===0)return n+1;r=r[s[0]],n++}else return n;return n}function di(e,t){let n=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,r=n(e),s=n(t);if(r!==s)return r-s;if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="string"&&typeof t=="string")return e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return(e?1:0)-(t?1:0);if(Array.isArray(e)&&Array.isArray(t)){for(let i=0;i<Math.min(e.length,t.length);i++){let o=di(e[i],t[i]);if(o!==0)return o}return e.length-t.length}if(e&&t&&typeof e=="object"&&typeof t=="object"){let i=e,o=t,a=Object.keys(i).sort(),l=Object.keys(o).sort();for(let c=0;c<Math.min(a.length,l.length);c++){let u=a[c].localeCompare(l[c]);if(u!==0)return u}if(a.length!==l.length)return a.length-l.length;for(let c of a){let u=di(i[c],o[c]);if(u!==0)return u}}return 0}function mi(e,t){if(Sr(e,t))return!0;if(typeof e=="string"&&typeof t=="string")return e.includes(t);if(Array.isArray(e)&&Array.isArray(t))return t.every(n=>e.some(r=>mi(r,n)));if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let n=e,r=t;return Object.keys(r).every(s=>un(n,s)&&mi(n[s],r[s]))}return!1}var gi=I(()=>{"use strict";En()});function Ua(e,t,n){switch(t){case"@base64":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"utf-8").toString("base64")]:[btoa(e)]:[null];case"@base64d":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"base64").toString("utf-8")]:[atob(e)]:[null];case"@uri":return typeof e=="string"?[encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof e=="string"?[decodeURIComponent(e)]:[null];case"@csv":return Array.isArray(e)?[e.map(s=>{if(s===null)return"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="number")return String(s);let i=String(s);return i.includes(",")||i.includes('"')||i.includes(`
|
|
547
547
|
`)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(e)?[e.map(r=>String(r??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let r=n??U9;return Cr(e,r+1)>r?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")]:[null];case"@sh":return typeof e=="string"?[`'${e.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof e=="string"?[e]:e==null?[""]:[String(e)];default:return null}}var U9,mh=I(()=>{"use strict";gi();U9=2e3});function Wa(e,t,n,r,s,i){switch(t){case"index":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){if(a===""&&e==="")return null;let l=e.indexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let c=0;c<=e.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(e[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=e.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){let l=e.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let l=e.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(e[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=e.length-1;l>=0;l--)if(i(e[l],a))return l;return null}return null});case"indices":return n.length===0?[[]]:s(e,n[0],r).map(a=>{let l=[];if(typeof e=="string"&&typeof a=="string"){let c=e.indexOf(a);for(;c!==-1;)l.push(c),c=e.indexOf(a,c+1)}else if(Array.isArray(e))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=e.length;u++)l.push(u);else for(let u=0;u<=e.length-c;u++){let f=!0;for(let p=0;p<c;p++)if(!i(e[u+p],a[p])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<e.length;c++)i(e[c],a)&&l.push(c);return l});default:return null}}var gh=I(()=>{"use strict"});function Ba(e,t,n,r,s){switch(t){case"fabs":case"abs":return typeof e=="number"?[Math.abs(e)]:typeof e=="string"?[e]:[null];case"exp10":return typeof e=="number"?[10**e]:[null];case"exp2":return typeof e=="number"?[2**e]:[null];case"pow":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.hypot(e,i)]}case"fma":{if(typeof e!="number"||n.length<2)return[null];let i=s(e,n[0],r)[0],o=s(e,n[1],r)[0];return[e*i+o]}case"copysign":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.sign(i)*Math.abs(e)]}case"drem":case"remainder":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e-Math.round(e/i)*i]}case"fdim":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(0,e-i)]}case"fmax":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(e,i)]}case"fmin":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.min(e,i)]}case"ldexp":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"scalbn":case"scalbln":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"nearbyint":return typeof e=="number"?[Math.round(e)]:[null];case"logb":return typeof e=="number"?[Math.floor(Math.log2(Math.abs(e)))]:[null];case"significand":if(typeof e=="number"){let i=Math.floor(Math.log2(Math.abs(e)));return[e/2**i]}return[null];case"frexp":if(typeof e=="number"){if(e===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**i,i]]}return[null];case"modf":if(typeof e=="number"){let i=Math.trunc(e);return[[e-i,i]]}return[null];default:return null}}var yh=I(()=>{"use strict"});function za(e,t,n,r,s,i,o,a){switch(t){case"recurse":{if(n.length===0){let h=[],m=d=>{if(h.push(d),Array.isArray(d))for(let g of d)m(g);else if(d&&typeof d=="object")for(let g of Object.keys(d))m(d[g])};return m(e),h}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,p=h=>{if(f++>u||c&&!s(h,c,r).some(i))return;l.push(h);let m=s(h,n[0],r);for(let d of m)d!=null&&p(d)};return p(e),l}case"recurse_down":return a(e,"recurse",n,r);case"walk":{if(n.length===0)return[e];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let h=Object.create(null);for(let[m,d]of Object.entries(u))Ie(m)&&Pe(h,m,c(d));f=h}else f=u;return s(f,n[0],r)[0]};return[c(e)]}case"transpose":{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let l=Math.max(...e.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(e.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(n.length>0){let f=s(e,n[0],r)[0];if(!Array.isArray(e)||f<0)return[];if(f===0)return[[]];let p=[],h=(m,d)=>{if(d===f){p.push([...m]);return}for(let g of e)m.push(g),h(m,d+1),m.pop()};return h([],0),p}if(!Array.isArray(e))return[];if(e.length===0)return[[]];for(let u of e)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===e.length){l.push([...f]);return}let p=e[u];for(let h of p)f.push(h),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let l=r.currentPath;if(l.length===0)return[];let c=n.length>0?s(e,n[0],r)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[e];let f=l.slice(0,u);return[o(r.root,f)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let l=r.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var wh=I(()=>{"use strict";En()});function Ha(e,t,n,r,s){switch(t){case"keys":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e)]:[null];case"length":return typeof e=="string"?[e.length]:Array.isArray(e)?[e.length]:e&&typeof e=="object"?[Object.keys(e).length]:e===null?[0]:typeof e=="number"?[Math.abs(e)]:[null];case"utf8bytelength":{if(typeof e=="string")return[new TextEncoder().encode(e).length];let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":return e&&typeof e=="object"&&!Array.isArray(e)?[Object.entries(e).map(([i,o])=>({key:i,value:o}))]:[null];case"from_entries":if(Array.isArray(e)){let i=Object.create(null);for(let o of e)if(o&&typeof o=="object"){let a=o,l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;if(l!==void 0){let u=String(l);Ie(u)&&Pe(i,u,c)}}return[i]}return[null];case"with_entries":{if(n.length===0)return[e];if(e&&typeof e=="object"&&!Array.isArray(e)){let o=Object.entries(e).map(([l,c])=>({key:l,value:c})).flatMap(l=>s(l,n[0],r)),a=Object.create(null);for(let l of o)if(l&&typeof l=="object"){let c=l,u=c.key??c.name??c.k,f=c.value??c.v;if(u!==void 0){let p=String(u);Ie(p)&&Pe(a,p,f)}}return[a]}return[null]}case"reverse":return Array.isArray(e)?[[...e].reverse()]:typeof e=="string"?[e.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(e)?(n.length>0?s(e,n[0],r):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return e.flat(a)}):[null];case"unique":if(Array.isArray(e)){let i=new Set,o=[];for(let a of e){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??W9;return Cr(e,i+1)>i?[null]:[JSON.stringify(e)]}case"fromjson":{if(typeof e=="string"){let i=e.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(e)]}catch{throw new Error(`Invalid JSON: ${e}`)}}return[e]}case"tostring":return typeof e=="string"?[e]:[JSON.stringify(e)];case"tonumber":if(typeof e=="number")return[e];if(typeof e=="string"){let i=Number(e);if(Number.isNaN(i))throw new Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof e} cannot be parsed as a number`);case"toboolean":{if(typeof e=="boolean")return[e];if(typeof e=="string"){if(e==="true")return[!0];if(e==="false")return[!1];throw new Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,Object.create(null)]);else for(let u of c)o(a[u],[...l,u])}};return o(e,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[e];let i=s(e,n[0],r),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:{});let u=o;for(let p=0;p<l.length-1;p++){let h=l[p],m=l[p+1];if(Array.isArray(u)&&typeof h=="number"){for(;u.length<=h;)u.push(null);u[h]===null&&(u[h]=typeof m=="number"?[]:{}),u=u[h]}else if(u&&typeof u=="object"&&!Array.isArray(u)){let d=String(h);if(!Ie(d))continue;let g=u;(g[d]===null||g[d]===void 0)&&Pe(g,d,typeof m=="number"?[]:{}),u=g[d]}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else if(u&&typeof u=="object"&&!Array.isArray(u)){let p=String(f);Ie(p)&&Pe(u,p,c)}}return[o]}case"truncate_stream":{let i=typeof e=="number"?Math.floor(e):0;if(n.length===0)return[];let o=[],a=s(e,n[0],r);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var W9,bh=I(()=>{"use strict";En();gi();W9=2e3});function ja(e,t,n,r,s,i,o,a,l,c){switch(t){case"getpath":{if(n.length===0)return[null];let u=s(e,n[0],r),f=[];for(let p of u){let h=p,m=e;for(let d of h){if(m==null){m=null;break}if(Array.isArray(m)&&typeof d=="number")m=m[d];else if(typeof m=="object"&&typeof d=="string"){let g=m;if(!Object.hasOwn(g,d)){m=null;break}m=g[d]}else{m=null;break}}f.push(m)}return f}case"setpath":{if(n.length<2)return[null];let f=s(e,n[0],r)[0],h=s(e,n[1],r)[0];return[o(e,f,h)]}case"delpaths":{if(n.length===0)return[e];let f=s(e,n[0],r)[0],p=e;for(let h of f.sort((m,d)=>d.length-m.length))p=a(p,h);return[p]}case"path":{if(n.length===0)return[[]];let u=[];return c(e,n[0],r,[],u),u}case"del":return n.length===0?[e]:[l(e,n[0],r)];case"pick":{if(n.length===0)return[null];let u=[];for(let p of n)c(e,p,r,[],u);let f=null;for(let p of u){for(let m of p)if(typeof m=="number"&&m<0)throw new Error("Out of bounds negative array index");let h=e;for(let m of p){if(h==null)break;if(Array.isArray(h)&&typeof m=="number")h=h[m];else if(typeof h=="object"&&typeof m=="string"){let d=h;if(!Object.hasOwn(d,m)){h=null;break}h=d[m]}else{h=null;break}}f=o(f,p,h)}return[f]}case"paths":{let u=[],f=(p,h)=>{if(p&&typeof p=="object")if(Array.isArray(p))for(let m=0;m<p.length;m++)u.push([...h,m]),f(p[m],[...h,m]);else for(let m of Object.keys(p))u.push([...h,m]),f(p[m],[...h,m])};return f(e,[]),n.length>0?u.filter(p=>{let h=e;for(let d of p)if(Array.isArray(h)&&typeof d=="number")h=h[d];else if(h&&typeof h=="object"&&typeof d=="string"){let g=h;if(!Object.hasOwn(g,d))return!1;h=g[d]}else return!1;return s(h,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(p,h)=>{if(p===null||typeof p!="object")u.push(h);else if(Array.isArray(p))for(let m=0;m<p.length;m++)f(p[m],[...h,m]);else for(let m of Object.keys(p))f(p[m],[...h,m])};return f(e,[]),u}default:return null}}var xh=I(()=>{"use strict"});function Ga(e,t,n,r,s,i){switch(t){case"IN":{if(n.length===0)return[!1];if(n.length===1){let c=s(e,n[0],r);for(let u of c)if(i(e,u))return[!0];return[!1]}let o=s(e,n[0],r),a=s(e,n[1],r),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(n.length===0)return[{}];if(n.length===1){let l=s(e,n[0],r),c=Object.create(null);for(let u of l){let f=String(u);Ie(f)&&Pe(c,f,u)}return[c]}if(n.length===2){let l=s(e,n[0],r),c=Object.create(null);for(let u of l){let f=s(u,n[1],r);if(f.length>0){let p=String(f[0]);Ie(p)&&Pe(c,p,u)}}return[c]}let o=s(e,n[0],r),a=Object.create(null);for(let l of o){let c=s(l,n[1],r),u=s(l,n[2],r);if(c.length>0&&u.length>0){let f=String(c[0]);Ie(f)&&Pe(a,f,u[0])}}return[a]}case"JOIN":{if(n.length<2)return[null];let o=s(e,n[0],r)[0];if(!o||typeof o!="object"||Array.isArray(o))return[null];let a=o;if(!Array.isArray(e))return[null];let l=[];for(let c of e){let u=s(c,n[1],r),f=u.length>0?String(u[0]):"",p=un(a,f)?a[f]:null;l.push([c,p])}return[l]}default:return null}}var Eh=I(()=>{"use strict";En()});function Va(e,t,n,r,s){switch(t){case"join":{if(!Array.isArray(e))return[null];let i=n.length>0?s(e,n[0],r):[""];for(let o of e)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>e.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);return[e.split(o)]}case"splits":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"g";return V(o,a.includes("g")?a:`${a}g`).split(e)}catch{return[]}}case"scan":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[...V(o,a.includes("g")?a:`${a}g`).matchAll(e)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[V(o,a).test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=V(o,`${a}d`).exec(e);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,p)=>({offset:u?.[p+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=V(o,a).match(e);return!c||!c.groups?[{}]:[c.groups]}catch{return[null]}}case"sub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"";return[V(a,c).replace(e,l)]}catch{return[e]}}case"gsub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[V(a,u).replace(e,l)]}catch{return[e]}}case"ascii_downcase":return typeof e=="string"?[e.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof e=="string"?[e.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return[e.startsWith(o)?e.slice(o.length):e]}case"rtrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return o===""?[e]:[e.endsWith(o)?e.slice(0,-o.length):e]}case"trimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);if(o==="")return[e];let a=e;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof e=="string")return[e.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof e=="string")return[e.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof e=="string")return[e.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.startsWith(String(i[0]))]}case"endswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.endsWith(String(i[0]))]}case"ascii":return typeof e=="string"&&e.length>0?[e.charCodeAt(0)]:[null];case"explode":return typeof e=="string"?[Array.from(e).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(e))throw new Error("implode input must be an array");return[e.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var Ah=I(()=>{"use strict";Fe()});function qa(e,t){switch(t){case"type":return e===null?["null"]:Array.isArray(e)?["array"]:typeof e=="boolean"?["boolean"]:typeof e=="number"?["number"]:typeof e=="string"?["string"]:typeof e=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof e=="number"&&!Number.isFinite(e)];case"isnan":return[typeof e=="number"&&Number.isNaN(e)];case"isnormal":return[typeof e=="number"&&Number.isFinite(e)&&e!==0];case"isfinite":return[typeof e=="number"&&Number.isFinite(e)];case"numbers":return typeof e=="number"?[e]:[];case"strings":return typeof e=="string"?[e]:[];case"booleans":return typeof e=="boolean"?[e]:[];case"nulls":return e===null?[e]:[];case"arrays":return Array.isArray(e)?[e]:[];case"objects":return e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"iterables":return Array.isArray(e)||e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"scalars":return!Array.isArray(e)&&!(e&&typeof e=="object")?[e]:[];case"values":return e===null?[]:[e];case"not":return e===!1||e===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var Sh=I(()=>{"use strict"});var Ch=I(()=>{"use strict";ph();hh();dh();mh();gh();yh();wh();bh();xh();Eh();Ah();Sh()});function yi(e,t,n){if(t.length===0)return n;let[r,...s]=t;if(typeof r=="number"){if(e&&typeof e=="object"&&!Array.isArray(e))throw new Error("Cannot index object with number");if(r>536870911)throw new Error("Array index too large");if(r<0)throw new Error("Out of bounds negative array index");let l=Array.isArray(e)?[...e]:[];for(;l.length<=r;)l.push(null);return l[r]=yi(l[r],s,n),l}if(Array.isArray(e))throw new Error("Cannot index array with string");if(!Ie(r))return e??Object.create(null);let i=e&&typeof e=="object"&&!Array.isArray(e)?Ze(e):Object.create(null),o=Object.hasOwn(i,r)?i[r]:void 0;return Pe(i,r,yi(o,s,n)),i}function wi(e,t){if(t.length===0)return null;if(t.length===1){let s=t[0];if(Array.isArray(e)&&typeof s=="number"){let i=[...e];return i.splice(s,1),i}if(e&&typeof e=="object"&&!Array.isArray(e)){let i=String(s);if(!Ie(i))return e;let o=Ze(e);return delete o[i],o}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n=="number"){let s=[...e];return s[n]=wi(s[n],r),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s=String(n);if(!Ie(s))return e;let i=Ze(e);return Object.hasOwn(i,s)&&Pe(i,s,wi(i[s],r)),i}return e}var Nh=I(()=>{"use strict";En()});function H9(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??B9,maxDepth:e?.limits?.maxDepth??Ih},env:e?.env,coverage:e?.coverage}}function Ei(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels,coverage:e.coverage}}function cs(e,t,n){switch(t.type){case"var":return Ei(e,t.name,n);case"array":{if(!Array.isArray(n))return null;let r=e;for(let s=0;s<t.elements.length;s++){let i=t.elements[s],o=s<n.length?n[s]:null,a=cs(r,i,o);if(a===null)return null;r=a}return r}case"object":{if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,s=e;for(let i of t.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=G(n,i.key,e);if(c.length===0)return null;o=String(c[0])}let a=un(r,o)?r[o]:null;i.keyVar&&(s=Ei(s,i.keyVar,a));let l=cs(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function j9(e,t){let n=e;for(let r of t)if(n&&typeof n=="object")if(Array.isArray(n))if(typeof r=="number")n=n[r];else return;else{let s=n;if(typeof r=="string"&&Object.hasOwn(s,r))n=s[r];else return}else return;return n}function $n(e){if(e.type==="Identity")return[];if(e.type==="Field"){let t=e.base?$n(e.base):[];return t===null?null:[...t,e.name]}if(e.type==="Index"&&e.index.type==="Literal"){let t=e.base?$n(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n=="number"||typeof n=="string"?[...t,n]:null}if(e.type==="Pipe"){let t=$n(e.left);return t===null?null:Za(t,e.right)}if(e.type==="Call"){if(e.name==="parent"||e.name==="root")return null;if(e.name==="first"&&e.args.length===0)return[0];if(e.name==="last"&&e.args.length===0)return[-1]}return null}function Za(e,t){if(t.type==="Call"){if(t.name==="parent"){let n=1;if(t.args.length>0&&t.args[0].type==="Literal"){let r=t.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let r=-n-1;return e.slice(0,Math.min(r,e.length))}}if(t.name==="root")return[]}if(t.type==="Field"){let n=$n(t);if(n!==null)return[...e,...n]}if(t.type==="Index"&&t.index.type==="Literal"){let n=$n(t);if(n!==null)return[...e,...n]}if(t.type==="Pipe"){let n=Za(e,t.left);return n===null?null:Za(n,t.right)}return t.type==="Identity"?e:null}function kh(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...G(e,t.left,n))}catch(s){if(s instanceof te)throw s;if(r.length>0)return r;throw new Error("evaluation failed")}try{r.push(...G(e,t.right,n))}catch(s){if(s instanceof te)throw s;return r}return r}return G(e,t,n)}function G(e,t,n){let r=n&&"vars"in n?n:H9(n);switch(r.root===void 0&&(r={...r,root:e,currentPath:[]}),r.coverage?.hit(`jq:node:${t.type}`),t.type){case"Identity":return[e];case"Field":return(t.base?G(e,t.base,r):[e]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i;if(!Object.hasOwn(a,t.name))return[null];let l=a[t.name];return[l===void 0?null:l]}if(i===null)return[null];let o=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${o} with string "${t.name}"`)});case"Index":return(t.base?G(e,t.base,r):[e]).flatMap(i=>G(i,t.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let l=i;return Object.hasOwn(l,a)?[l[a]]:[null]}return[null]}));case"Slice":return(t.base?G(e,t.base,r):[e]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=t.start?G(e,t.start,r):[0],l=t.end?G(e,t.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=c,p=u,h=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),m=Number.isNaN(p)?o:Number.isInteger(p)?p:Math.ceil(p),d=vh(h,o),g=vh(m,o);return Array.isArray(i),i.slice(d,g)}))});case"Iterate":return(t.base?G(e,t.base,r):[e]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=G(e,t.left,r),i=$n(t.left),o=[];for(let a of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};o.push(...G(a,t.right,l))}else o.push(...G(a,t.right,r))}catch(l){throw l instanceof Nr?l.withPrependedResults(o):l}return o}case"Comma":{let s=G(e,t.left,r),i=G(e,t.right,r);return[...s,...i]}case"Literal":return[t.value];case"Array":return t.elements?[G(e,t.elements,r)]:[[]];case"Object":{let s=[Object.create(null)];for(let i of t.entries){let o=typeof i.key=="string"?[i.key]:G(e,i.key,r),a=G(e,i.value,r),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}if(!Ie(u)){for(let f of a)l.push(Ze(c));continue}for(let f of a){let p=Ze(c);Pe(p,u,f),l.push(p)}}s.length=0,s.push(...l)}return s}case"Paren":return G(e,t.expr,r);case"BinaryOp":return q9(e,t.op,t.left,t.right,r);case"UnaryOp":return G(e,t.operand,r).map(i=>{if(t.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return t.op==="not"?!Zt(i):null});case"Cond":return G(e,t.cond,r).flatMap(i=>{if(Zt(i))return G(e,t.then,r);for(let o of t.elifs)if(G(e,o.cond,r).some(Zt))return G(e,o.then,r);return t.else?G(e,t.else,r):[e]});case"Try":try{return G(e,t.body,r)}catch(s){if(t.catch){let i=s instanceof xi?s.value:s instanceof Error?s.message:String(s);return G(i,t.catch,r)}return[]}case"Call":return Oh(e,t.name,t.args,r);case"VarBind":return G(e,t.value,r).flatMap(i=>{let o=null,a=[];t.pattern?a.push(t.pattern):t.name&&a.push({type:"var",name:t.name}),t.alternatives&&a.push(...t.alternatives);for(let l of a)if(o=cs(r,l,i),o!==null)break;return o===null?[]:G(e,t.body,o)});case"VarRef":{if(t.name==="$ENV")return[r.env?xt(r.env):Object.create(null)];let s=r.vars.get(t.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(e),s}case"Optional":try{return G(e,t.expr,r)}catch{return[]}case"StringInterp":return[t.parts.map(i=>typeof i=="string"?i:G(e,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[G9(e,t.path,t.op,t.value,r)];case"Reduce":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],o=r.limits.maxDepth??Ih;for(let a of s){let l;if(t.pattern){if(l=cs(r,t.pattern,a),l===null)continue}else l=Ei(r,t.varName,a);if(i=G(i,t.update,l)[0],Cr(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],o=[];for(let a of s)try{let l;if(t.pattern){if(l=cs(r,t.pattern,a),l===null)continue}else l=Ei(r,t.varName,a);if(i=G(i,t.update,l)[0],t.extract){let c=G(i,t.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof Nr?l.withPrependedResults(o):l}return o}case"Label":try{return G(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(s){if(s instanceof Nr&&s.label===t.name)return s.partialResults;throw s}case"Break":throw new Nr(t.name);case"Def":{let s=new Map(r.funcs??[]),i=`${t.name}/${t.params.length}`;s.set(i,{params:t.params,body:t.funcBody,closure:new Map(r.funcs??[])});let o={...r,funcs:s};return G(e,t.body,o)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function vh(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function G9(e,t,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return G(l,r,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?Da(l,c):c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(!Ie(c.name))return l;if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let p=Ze(f),h=Object.hasOwn(p,c.name)?p[c.name]:void 0;return Pe(p,c.name,u(h)),p}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f=Ze(l),p=Object.hasOwn(f,c.name)?f[c.name]:void 0;return Pe(f,c.name,u(p)),f}return l}case"Index":{let p=G(e,c.index,s)[0];if(typeof p=="number"&&Number.isNaN(p))throw new Error("Cannot set array element at NaN index");if(typeof p=="number"&&!Number.isInteger(p)&&(p=Math.trunc(p)),c.base)return o(l,c.base,h=>{if(typeof p=="number"&&Array.isArray(h)){let m=[...h],d=p<0?m.length+p:p;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(typeof p=="string"&&h&&typeof h=="object"&&!Array.isArray(h)){if(!Ie(p))return h;let m=Ze(h),d=Object.hasOwn(m,p)?m[p]:void 0;return Pe(m,p,u(d)),m}return h});if(typeof p=="number"){if(p>536870911)throw new Error("Array index too large");if(p<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let m=[...l],d=p<0?m.length+p:p;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(l==null){let m=[];for(;m.length<=p;)m.push(null);return m[p]=u(null),m}return l}if(typeof p=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!Ie(p))return l;let h=Ze(l),m=Object.hasOwn(h,p)?h[p]:void 0;return Pe(h,p,u(m)),h}return l}case"Iterate":{let f=p=>{if(Array.isArray(p))return p.map(h=>u(h));if(p&&typeof p=="object"){let h=Object.create(null);for(let[m,d]of Object.entries(p))Ie(m)&&Pe(h,m,u(d));return h}return p};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,p=>p);return o(f,c.right,u)}default:return u(l)}}return o(e,t,l=>{if(n==="|=")return i(l,l);let c=G(e,r,s);return i(l,c[0]??null)})}function V9(e,t,n){function r(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(!Ie(o.name))return i;if(o.base){let l=G(i,o.base,n)[0],c=r(l,{type:"Field",name:o.name},a);return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l=Ze(i);return Pe(l,o.name,a),l}return i}case"Index":{if(o.base){let u=G(i,o.base,n)[0],f=r(u,{type:"Index",index:o.index},a);return r(i,o.base,f)}let c=G(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u=Ze(i);return Pe(u,c,a),u}return i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(!Ie(o.name))return i;if(o.base){let l=G(i,o.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(o.name))return i;let l=Ze(i);return delete l[o.name],l}return i}case"Index":{if(o.base){let u=G(i,o.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return r(i,o.base,f)}let c=G(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u=Ze(i);return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let u=function(h,m,d){switch(m.type){case"Identity":return d;case"Field":{if(!Ie(m.name))return h;if(h&&typeof h=="object"&&!Array.isArray(h)){let g=Ze(h);return Pe(g,m.name,d),g}return h}case"Index":{let y=G(e,m.index,n)[0];if(typeof y=="number"&&Array.isArray(h)){let w=[...h],b=y<0?w.length+y:y;return b>=0&&b<w.length&&(w[b]=d),w}if(typeof y=="string"&&h&&typeof h=="object"&&!Array.isArray(h)){if(!Ie(y))return h;let w=Ze(h);return Pe(w,y,d),w}return h}case"Pipe":{let g=G(h,m.left,n)[0],y=u(g,m.right,d);return u(h,m.left,y)}default:return h}};var a=u;let l=o.left,c=o.right,f=G(i,l,n)[0];if(f==null)return i;let p=s(f,c);return u(i,l,p)}default:return i}}return s(e,t)}function q9(e,t,n,r,s){if(t==="and")return G(e,n,s).flatMap(l=>Zt(l)?G(e,r,s).map(u=>Zt(u)):[!1]);if(t==="or")return G(e,n,s).flatMap(l=>Zt(l)?[!0]:G(e,r,s).map(u=>Zt(u)));if(t==="//"){let l=G(e,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:G(e,r,s)}let i=G(e,n,s),o=G(e,r,s);return i.flatMap(a=>o.map(l=>{switch(t){case"+":return a===null?l:l===null?a:typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?Da(a,l):null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":return typeof a=="number"&&typeof l=="number"?a*l:typeof a=="string"&&typeof l=="number"?a.repeat(l):a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?Ma(a,l):null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return Sr(a,l);case"!=":return!Sr(a,l);case"<":return ls(a,l)<0;case"<=":return ls(a,l)<=0;case">":return ls(a,l)>0;case">=":return ls(a,l)>=0;default:return null}}))}function Oh(e,t,n,r){let s=z9.get(t);if(s)return typeof e=="number"?[s(e)]:[null];let i=Ba(e,t,n,r,G);if(i!==null)return i;let o=Va(e,t,n,r,G);if(o!==null)return o;let a=Fa(e,t,n,r,G);if(a!==null)return a;let l=Ua(e,t,r.limits.maxDepth);if(l!==null)return l;let c=qa(e,t);if(c!==null)return c;let u=Ha(e,t,n,r,G);if(u!==null)return u;let f=_a(e,t,n,r,G,kh,di,Zt,mi,te);if(f!==null)return f;let p=ja(e,t,n,r,G,Zt,yi,wi,V9,bi);if(p!==null)return p;let h=Wa(e,t,n,r,G,Sr);if(h!==null)return h;let m=La(e,t,n,r,G,kh,Zt,te);if(m!==null)return m;let d=za(e,t,n,r,G,Zt,j9,Oh);if(d!==null)return d;let g=Ga(e,t,n,r,G,Sr);if(g!==null)return g;switch(t){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let y=n.length>0?G(e,n[0],r)[0]:e;throw new xi(y)}case"env":return[r.env?xt(r.env):Object.create(null)];case"debug":return[e];case"input_line_number":return[1];default:{let y=`${t}/${n.length}`,w=r.funcs?.get(y);if(w){let b=w.closure??r.funcs??new Map,x=new Map(b);x.set(y,w);for(let O=0;O<w.params.length;O++){let R=w.params[O],F=n[O];if(F){let $=G(e,F,r),z;if($.length===0)z={type:"Call",name:"empty",args:[]};else if($.length===1)z={type:"Literal",value:$[0]};else{z={type:"Literal",value:$[$.length-1]};for(let k=$.length-2;k>=0;k--)z={type:"Comma",left:{type:"Literal",value:$[k]},right:z}}x.set(`${R}/0`,{params:[],body:z})}}let S={...r,funcs:x};return G(e,w.body,S)}throw new Error(`Unknown function: ${t}`)}}}function bi(e,t,n,r,s){if(t.type==="Comma"){let a=t;bi(e,a.left,n,r,s),bi(e,a.right,n,r,s);return}let i=$n(t);if(i!==null){s.push([...r,...i]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let a=0;a<e.length;a++)s.push([...r,a]);else if(e&&typeof e=="object")for(let a of Object.keys(e))s.push([...r,a]);return}if(t.type==="Recurse"){let a=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(e,[]);return}if(t.type==="Pipe"){let a=$n(t.left);if(a!==null){let l=G(e,t.left,n);for(let c of l)bi(c,t.right,n,[...r,...a],s);return}}G(e,t,n).length>0&&s.push(r)}var Nr,xi,B9,Ih,z9,Rh=I(()=>{"use strict";On();ye();Ch();Nh();En();gi();Nr=class e extends Error{label;partialResults;constructor(t,n=[]){super(`break ${t}`),this.label=t,this.partialResults=n,this.name="BreakError"}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},xi=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},B9=1e4,Ih=2e3,z9=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function Th(e){let t=[],n=0,r=(c=0)=>e[n+c],s=()=>e[n++],i=()=>n>=e.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
|
|
@@ -1418,7 +1418,7 @@ ${e} ()
|
|
|
1418
1418
|
`),s=e.includes(" "),i=e.includes("\\"),o=e.includes("'");if(n||r||s||i){let l="";for(let c of e){let u=c.charCodeAt(0);c===`
|
|
1419
1419
|
`?l+="\\n":c===" "?l+="\\t":c==="\\"?l+="\\\\":c==="'"?l+="'":c==='"'?l+='"':u<32||u===127?u<256?l+=`\\x${u.toString(16).padStart(2,"0")}`:l+=`\\u${u.toString(16).padStart(4,"0")}`:l+=c}return`$'${l}'`}return o?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function mg(e,t,n){if(!e.state.options.xtrace)return"";let r=await dg(e),s=[t,...n],i=FE(s);return`${r}${i}
|
|
1420
1420
|
`}async function gg(e,t,n){return e.state.options.xtrace?`${await dg(e)}${t}=${n}
|
|
1421
|
-
`:""}ye();async function yg(e,t,n){let r=t.timed?performance.now():0,s="",i=de,o=0,a=[],l=t.commands.length>1,c=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let p=t.commands[f],h=f===t.commands.length-1;l&&(e.state.lastArg="");let
|
|
1421
|
+
`:""}ye();async function yg(e,t,n){let r=t.timed?performance.now():0,s="",i=de,o=0,a=[],l=t.commands.length>1,c=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let p=t.commands[f],h=f===t.commands.length-1,m=f===0;l&&(e.state.lastArg="",m||(e.state.groupStdin=void 0));let g=l&&(!h||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,y;try{y=await n(p,s)}catch(w){if(w instanceof wt)y={stdout:w.stdout,stderr:w.stderr,exitCode:1};else if(w instanceof pe&&t.commands.length>1)y={stdout:w.stdout,stderr:w.stderr,exitCode:w.exitCode};else if(w instanceof kt&&t.commands.length>1)y={stdout:w.stdout,stderr:w.stderr,exitCode:w.exitCode};else throw g&&(e.state.env=g),w}g&&(e.state.env=g),a.push(y.exitCode),y.exitCode!==0&&(o=y.exitCode),h?i=y:t.pipeStderr?.[f]??!1?(s=y.stderr+y.stdout,i={stdout:"",stderr:"",exitCode:y.exitCode}):(s=y.stdout,i={stdout:"",stderr:y.stderr,exitCode:y.exitCode})}if(t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let f of e.state.env.keys())f.startsWith("PIPESTATUS_")&&e.state.env.delete(f);for(let f=0;f<a.length;f++)e.state.env.set(`PIPESTATUS_${f}`,String(a[f]));e.state.env.set("PIPESTATUS__length",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let p=(performance.now()-r)/1e3,h=Math.floor(p/60),m=p%60,d;t.timePosix?d=`real ${p.toFixed(2)}
|
|
1422
1422
|
user 0.00
|
|
1423
1423
|
sys 0.00
|
|
1424
1424
|
`:d=`
|
|
@@ -1460,7 +1460,7 @@ This is a defense-in-depth measure and indicates a bug in just-bash. Please repo
|
|
|
1460
1460
|
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=Sg({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=su(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,bashPid:process.pid,nextVirtualPid:process.pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",bl(this.state.options)),this.state.env.set("BASHOPTS",xl(this.state.shoptOptions)),W0(n,this.useDefaultLayout),r!=="/"&&n instanceof Jn)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let i of $0(t.commands))this.registerCommand(i);if(t.network)for(let i of T0())this.registerCommand(i);if(t.python)for(let i of P0())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)D0(i)?this.registerCommand(_0(i)):this.registerCommand(i)}registerCommand(t){this.commands.set(t.name,t);let n=this.fs;if(typeof n.writeFileSync=="function"){let r=`#!/bin/bash
|
|
1461
1461
|
# Built-in command: ${t.name}
|
|
1462
1462
|
`;try{n.writeFileSync(`/bin/${t.name}`,r)}catch{}try{n.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t}async exec(t,n){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
1463
|
-
`,exitCode:1,env:Jt(this.state.env,n?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:Jt(this.state.env,n?.env)};this.logger?.info("exec",{command:t});let r=n?.cwd??this.state.cwd,s,i=r;if(n?.cwd)if(n.env&&"PWD"in n.env)s=n.env.PWD;else if(n?.env&&!("PWD"in n.env))try{s=await this.fs.realpath(r),i=s}catch{s=r}else s=r;let o=new Map(this.state.env);if(n?.env)for(let[f,p]of Object.entries(n.env))o.set(f,p);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable},l=t;n?.rawScript||(l=iA(t));let u=(this.defenseInDepthConfig?Oo.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let p=hn(l),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},d=await new $s(h,a).executeScript(p);return this.logResult(d)};return u?await u.run(f):await f()}catch(f){if(f instanceof pe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Jt(this.state.env,n?.env)});if(f instanceof Ut)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Jt(this.state.env,n?.env)});if(f instanceof $e)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Jt(this.state.env,n?.env)});if(f instanceof te)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:te.EXIT_CODE,env:Jt(this.state.env,n?.env)});if(f instanceof mt)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
1463
|
+
`,exitCode:1,env:Jt(this.state.env,n?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:Jt(this.state.env,n?.env)};this.logger?.info("exec",{command:t});let r=n?.cwd??this.state.cwd,s,i=r;if(n?.cwd)if(n.env&&"PWD"in n.env)s=n.env.PWD;else if(n?.env&&!("PWD"in n.env))try{s=await this.fs.realpath(r),i=s}catch{s=r}else s=r;let o=new Map(this.state.env);if(n?.env)for(let[f,p]of Object.entries(n.env))o.set(f,p);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:n?.stdin},l=t;n?.rawScript||(l=iA(t));let u=(this.defenseInDepthConfig?Oo.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let p=hn(l),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},d=await new $s(h,a).executeScript(p);return this.logResult(d)};return u?await u.run(f):await f()}catch(f){if(f instanceof pe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Jt(this.state.env,n?.env)});if(f instanceof Ut)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Jt(this.state.env,n?.env)});if(f instanceof $e)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Jt(this.state.env,n?.env)});if(f instanceof te)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:te.EXIT_CODE,env:Jt(this.state.env,n?.env)});if(f instanceof mt)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
1464
1464
|
`,exitCode:1,env:Jt(this.state.env,n?.env)});if(f.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${f.message}
|
|
1465
1465
|
`,exitCode:2,env:Jt(this.state.env,n?.env)});if(f instanceof Tn)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
1466
1466
|
`,exitCode:2,env:Jt(this.state.env,n?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-
|
|
1
|
+
import{a,b,c,d}from"./chunk-JP44OYZS.js";import"./chunk-OJDRYQWQ.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as bashCommand,c as flagsForFuzzing,b as shCommand,d as shFlagsForFuzzing};
|
|
@@ -2,4 +2,4 @@ import{c as u}from"./chunk-OJDRYQWQ.js";import{a as l,b as h}from"./chunk-74CEPO
|
|
|
2
2
|
`,exitCode:127}}}},C={name:"sh",async execute(t,e){if(h(t))return l({...d,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let r=t[1],s=t[2]||"sh",c=t.slice(3);return i(r,s,c,e)}if(t.length===0)return e.stdin?.trim()?i(e.stdin,"sh",[],e):{stdout:"",stderr:"",exitCode:0};let n=t[0],o=t.slice(1);try{let r=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(r);return i(s,n,o,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
|
|
3
3
|
`,exitCode:127}}}};async function i(t,e,n,o){if(!o.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
|
|
4
4
|
`,exitCode:1};let r=u(o.exportedEnv||{},{0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")});n.forEach((a,m)=>{r[String(m+1)]=a});let s=t;if(s.startsWith("#!")){let a=s.indexOf(`
|
|
5
|
-
`);a!==-1&&(s=s.slice(a+1))}return await o.exec(s,{env:r,cwd:o.cwd})}var b={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},P={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"};export{y as a,C as b,b as c,P as d};
|
|
5
|
+
`);a!==-1&&(s=s.slice(a+1))}return await o.exec(s,{env:r,cwd:o.cwd,stdin:o.stdin})}var b={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},P={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"};export{y as a,C as b,b as c,P as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as yr}from"./chunk-VZWXH2PZ.js";import{b as Ar}from"./chunk-XMDVFEVC.js";import{b as $r}from"./chunk-JI3KJ32H.js";import"./chunk-F55TLFGB.js";import"./chunk-SYMJJMQ4.js";import{b as Sr}from"./chunk-HDZ4QEVJ.js";import{b as wr}from"./chunk-MDLLFABN.js";import{b as xr}from"./chunk-ZKLK6C7H.js";import{b as vr}from"./chunk-UYGR3CFC.js";import{b as kr}from"./chunk-NQOQ2Q77.js";import{b as qr}from"./chunk-4HHKTUW3.js";import{b as Cr}from"./chunk-HJQJAYMS.js";import{b as br}from"./chunk-PP6PSHAB.js";import{d as Ir,e as Mr,f as jr}from"./chunk-DZ33S2U7.js";import{b as tr}from"./chunk-XNL7YAHW.js";import{b as lr}from"./chunk-CSBFBYLD.js";import{b as ur}from"./chunk-A7A2DBEE.js";import{b as pr}from"./chunk-U7QI5ZS5.js";import{b as er}from"./chunk-APT7OOP2.js";import{b as dr}from"./chunk-XKQRETAK.js";import{b as cr}from"./chunk-5V6VZH6T.js";import"./chunk-EIZGF4BS.js";import{b as hr}from"./chunk-CR5AFCPT.js";import{c as or,d as ar}from"./chunk-R6QSAL5T.js";import{b as sr}from"./chunk-LL3S3NLB.js";import{c as ir,d as gr}from"./chunk-
|
|
1
|
+
import{b as yr}from"./chunk-VZWXH2PZ.js";import{b as Ar}from"./chunk-XMDVFEVC.js";import{b as $r}from"./chunk-JI3KJ32H.js";import"./chunk-F55TLFGB.js";import"./chunk-SYMJJMQ4.js";import{b as Sr}from"./chunk-HDZ4QEVJ.js";import{b as wr}from"./chunk-MDLLFABN.js";import{b as xr}from"./chunk-ZKLK6C7H.js";import{b as vr}from"./chunk-UYGR3CFC.js";import{b as kr}from"./chunk-NQOQ2Q77.js";import{b as qr}from"./chunk-4HHKTUW3.js";import{b as Cr}from"./chunk-HJQJAYMS.js";import{b as br}from"./chunk-PP6PSHAB.js";import{d as Ir,e as Mr,f as jr}from"./chunk-DZ33S2U7.js";import{b as tr}from"./chunk-XNL7YAHW.js";import{b as lr}from"./chunk-CSBFBYLD.js";import{b as ur}from"./chunk-A7A2DBEE.js";import{b as pr}from"./chunk-U7QI5ZS5.js";import{b as er}from"./chunk-APT7OOP2.js";import{b as dr}from"./chunk-XKQRETAK.js";import{b as cr}from"./chunk-5V6VZH6T.js";import"./chunk-EIZGF4BS.js";import{b as hr}from"./chunk-CR5AFCPT.js";import{c as or,d as ar}from"./chunk-R6QSAL5T.js";import{b as sr}from"./chunk-LL3S3NLB.js";import{c as ir,d as gr}from"./chunk-JP44OYZS.js";import{b as mr}from"./chunk-2OCD45J4.js";import"./chunk-FRDGR5VK.js";import"./chunk-7MKBHGLS.js";import{b as Fr}from"./chunk-IBFD7QQD.js";import{b as zr}from"./chunk-TLSUDHID.js";import{b as fr}from"./chunk-OCK72LWW.js";import{b as nr}from"./chunk-WMLBQOWO.js";import{b as R}from"./chunk-ALLTKNUZ.js";import{b as U}from"./chunk-4Q4SM6WR.js";import{b as V}from"./chunk-XVDPCNWR.js";import{b as W}from"./chunk-K3PAWJ7V.js";import{c as X,d as Y}from"./chunk-OGDTSM2Q.js";import{c as Z,d as _}from"./chunk-VOBGTVA6.js";import{b as N}from"./chunk-NCNPKYJZ.js";import{b as rr}from"./chunk-SXR3EI72.js";import{b as G}from"./chunk-VJFXDYWH.js";import{b as H}from"./chunk-PYSFUGCK.js";import{b as J}from"./chunk-VYOJP4TV.js";import{b as K}from"./chunk-KTGH7NTP.js";import{b as L}from"./chunk-LWEGUNWT.js";import{b as O}from"./chunk-A7ICOL4V.js";import{b as P}from"./chunk-55VFSPNA.js";import{b as Q}from"./chunk-YYB54I7F.js";import{b as y}from"./chunk-7C6RBHP3.js";import{b as A}from"./chunk-Z7JVV2SM.js";import{b as $}from"./chunk-6NY2AP72.js";import{b as S}from"./chunk-JVPRLUMK.js";import{b as T}from"./chunk-X6JMGGW2.js";import{b as B}from"./chunk-QCDB2VPH.js";import{b as D}from"./chunk-F23WWYKW.js";import{b as E}from"./chunk-D4J545R4.js";import{b as w}from"./chunk-DCAAORBQ.js";import{b as x}from"./chunk-GXVXFKBA.js";import{b as v}from"./chunk-OFJTSXN6.js";import{d as k,e as q,f as C}from"./chunk-S6BBC45K.js";import"./chunk-IJXFPKNC.js";import{b}from"./chunk-QOENL5UZ.js";import"./chunk-VLGZJRPG.js";import{b as I}from"./chunk-WACZHM4L.js";import{b as M}from"./chunk-3KWUDRIP.js";import{b as j}from"./chunk-KAEMRWOH.js";import{b as t}from"./chunk-27LMNKBP.js";import{b as l}from"./chunk-NUYSJFDK.js";import{b as u}from"./chunk-A4JSPFCI.js";import{b as p}from"./chunk-SL4FN3A5.js";import{b as e}from"./chunk-GZ2N3SXD.js";import{b as d}from"./chunk-A4HU7SVR.js";import{b as c}from"./chunk-IKZ5LEGB.js";import{b as h}from"./chunk-64BAICW3.js";import"./chunk-HDQ56CKY.js";import"./chunk-OJDRYQWQ.js";import"./chunk-YNYSPYQ5.js";import{b as i}from"./chunk-GCTKCWKD.js";import{b as g}from"./chunk-7DBA735O.js";import"./chunk-7L36YK2X.js";import{b as m}from"./chunk-L4KW73FJ.js";import"./chunk-EEXR5ZDP.js";import"./chunk-PSW6BMXW.js";import{b as F}from"./chunk-KY5VPZXG.js";import"./chunk-NUFRM6SI.js";import{b as z}from"./chunk-XZ3MZS57.js";import{b as f}from"./chunk-OCS6LSEM.js";import"./chunk-HWKDQ44K.js";import{b as n}from"./chunk-OCLXQMOG.js";import"./chunk-44UOCSGV.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
|
|
@@ -6,6 +6,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
// src/commands/python3/worker.ts
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { dirname } from "node:path";
|
|
9
11
|
import { parentPort, workerData } from "node:worker_threads";
|
|
10
12
|
import { loadPyodide } from "pyodide";
|
|
11
13
|
|
|
@@ -208,9 +210,9 @@ var IS_BROWSER = typeof __BROWSER__ !== "undefined" && __BROWSER__;
|
|
|
208
210
|
var AsyncLocalStorageClass = null;
|
|
209
211
|
if (!IS_BROWSER) {
|
|
210
212
|
try {
|
|
211
|
-
const { createRequire } = await import("node:module");
|
|
212
|
-
const
|
|
213
|
-
const asyncHooks =
|
|
213
|
+
const { createRequire: createRequire2 } = await import("node:module");
|
|
214
|
+
const require3 = createRequire2(import.meta.url);
|
|
215
|
+
const asyncHooks = require3("node:async_hooks");
|
|
214
216
|
AsyncLocalStorageClass = asyncHooks.AsyncLocalStorage;
|
|
215
217
|
} catch (e) {
|
|
216
218
|
console.debug(
|
|
@@ -1314,6 +1316,8 @@ var SyncFsBackend = class {
|
|
|
1314
1316
|
// src/commands/python3/worker.ts
|
|
1315
1317
|
var pyodideInstance = null;
|
|
1316
1318
|
var pyodideLoading = null;
|
|
1319
|
+
var require2 = createRequire(import.meta.url);
|
|
1320
|
+
var pyodideIndexURL = `${dirname(require2.resolve("pyodide/pyodide.mjs"))}/`;
|
|
1317
1321
|
async function getPyodide() {
|
|
1318
1322
|
if (pyodideInstance) {
|
|
1319
1323
|
return pyodideInstance;
|
|
@@ -1321,7 +1325,7 @@ async function getPyodide() {
|
|
|
1321
1325
|
if (pyodideLoading) {
|
|
1322
1326
|
return pyodideLoading;
|
|
1323
1327
|
}
|
|
1324
|
-
pyodideLoading = loadPyodide();
|
|
1328
|
+
pyodideLoading = loadPyodide({ indexURL: pyodideIndexURL });
|
|
1325
1329
|
pyodideInstance = await pyodideLoading;
|
|
1326
1330
|
return pyodideInstance;
|
|
1327
1331
|
}
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as mr,C as yr,D as oe,E as Me,F as X,G as we,H as vt,I as gr,J as T,K as wr,L as vr,M as Ee,N as ss,O as bt,P as B,a as or,b as ar,c as lr,d as gt,e as Z,f as W,g as ve,h as Q,i as be,j as Oe,k as Yt,l as wt,m as cr,n as Qt,o as ur,p as he,q as Ae,r as fr,s as dr,t as Jt,u as es,v as De,w as hr,x as pr,y as ge,z as ts}from"./chunks/chunk-UJXASUXJ.js";import{a as Ne,b as ye}from"./chunks/chunk-OJDRYQWQ.js";import{a as rt}from"./chunks/chunk-YNYSPYQ5.js";import{a as ue,b as fe,c as ie,d as de,e as nr,f as z,g as Re,h as pt,i as mt,j as ir,k as se,l as xe,m as yt,n as me}from"./chunks/chunk-PSW6BMXW.js";import"./chunks/chunk-NUFRM6SI.js";import{a as Pe}from"./chunks/chunk-44UOCSGV.js";import{a as st}from"./chunks/chunk-DXB73IDG.js";var Fe=[{name:"echo",load:async()=>(await import("./chunks/echo-O45JWWI2.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-C2OBLGHA.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-KGN6BDCY.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-OTONBH2E.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-QWGXDWUS.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-XTQXT7RK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DX2IJOQ4.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-KPTLPKPH.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XOYR4ABJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-Z6MORUFL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-YAIFIHCT.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-MIKE3OIT.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-D4OZ7N27.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-IEQO24KU.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-HT2B6D2J.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-S5ULNTJU.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-TQB3VNOX.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-74KBZFAX.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-ORQK4GVH.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-RXIECPPB.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-BDPR2JPZ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-T7TNLWXL.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-ZXE4O5XB.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-5SLSESQG.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-LO6YYY5P.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-7N6AFSDS.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-RYO2EDCA.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-XOSYPP45.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-U5YJDM32.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-LDSORVYE.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-DTNXU4LQ.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-RGTMIGZM.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7PLOGTPD.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-EZOC5IIZ.js")).split},{name:"column",load:async()=>(await import("./chunks/column-WLPMMSTS.js")).column},{name:"join",load:async()=>(await import("./chunks/join-GG2LDHE5.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-O7VXZDCO.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-74OP3M7S.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-AA2KJYZQ.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-LEMTZZFS.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-LYXBS7DC.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-DM4QX4XA.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-S547XMN7.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-S547XMN7.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-J4QRNGRO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-OGI2NN6J.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-5CZ5X4YR.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-OVBCDR7G.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-OVBCDR7G.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-OJYNICKX.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-A3SGWC34.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-HJF2MPDN.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-FT2P5UCQ.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-JHK4I472.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-5UJUQXOE.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-BPT76IHZ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-RN5ZUASB.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-3572LAOT.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-INMIK4DX.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-VJPNLNU6.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-PI32XWXY.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-ZIGAJ4YS.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-TFCECAGV.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-T2NGLTSG.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-NCIYTMAT.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-T7YAU2Y6.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-BK6HG2DE.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-DGKU3D2X.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-VJEF2UR5.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Fe.push({name:"tar",load:async()=>(await import("./chunks/tar-K7K7BL55.js")).tarCommand}),Fe.push({name:"yq",load:async()=>(await import("./chunks/yq-FD5F3WOJ.js")).yqCommand}),Fe.push({name:"xan",load:async()=>(await import("./chunks/xan-Z6KVJKEE.js")).xanCommand}),Fe.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-Z2IGWYCE.js")).sqlite3Command}));var Et=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Et.push({name:"python3",load:async()=>(await import("./chunks/python3-SKZGHYDO.js")).python3Command}),Et.push({name:"python",load:async()=>(await import("./chunks/python3-SKZGHYDO.js")).pythonCommand}));var Er=[{name:"curl",load:async()=>(await import("./chunks/curl-6L7YZUIH.js")).curlCommand}],br=new Map;function rs(e){return{name:e.name,async execute(t,s){let r=br.get(e.name);if(r||(r=await e.load(),br.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-5KOYWCUN.js");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function ei(){return Fe.map(e=>e.name)}function ti(){return Er.map(e=>e.name)}function $r(e){return(e?Fe.filter(s=>e.includes(s.name)):Fe).map(rs)}function Sr(){return Er.map(rs)}function si(){return Et.map(e=>e.name)}function Pr(){return Et.map(rs)}function Ar(e){return"load"in e&&typeof e.load=="function"}function ri(e,t){return{name:e,execute:t}}function _r(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var ni=new TextEncoder,ii=new TextDecoder;function _e(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return ni.encode(e)}function Ve(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let r="";for(let n=0;n<e.length;n+=s){let i=e.subarray(n,n+s);r+=String.fromCharCode(...i)}return r}return ii.decode(e)}function pe(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var $t=new TextEncoder;function oi(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function re(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var ke=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))oi(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){re(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=pe(r),a=_e(s,o);this.data.set(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t,s){let r=await this.readFileBuffer(t),n=pe(s);return Ve(r,n)}async readFileBuffer(t){re(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return r.content instanceof Uint8Array?r.content:$t.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){re(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=pe(r),a=_e(s,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:$t.encode(i.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(n,{type:"file",content:c,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){re(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=$t.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){re(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let n=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=$t.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){re(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){re(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){re(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){re(t,"cp"),re(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let c=n==="/"?`/${l}`:`${n}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){re(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){re(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){re(t,"link"),re(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){re(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){re(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){re(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function ai(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function li(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function ci(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function ui(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${or}
|
|
1
|
+
import{B as mr,C as yr,D as oe,E as Me,F as X,G as we,H as vt,I as gr,J as T,K as wr,L as vr,M as Ee,N as ss,O as bt,P as B,a as or,b as ar,c as lr,d as gt,e as Z,f as W,g as ve,h as Q,i as be,j as Oe,k as Yt,l as wt,m as cr,n as Qt,o as ur,p as he,q as Ae,r as fr,s as dr,t as Jt,u as es,v as De,w as hr,x as pr,y as ge,z as ts}from"./chunks/chunk-UJXASUXJ.js";import{a as Ne,b as ye}from"./chunks/chunk-OJDRYQWQ.js";import{a as rt}from"./chunks/chunk-YNYSPYQ5.js";import{a as ue,b as fe,c as ie,d as de,e as nr,f as z,g as Re,h as pt,i as mt,j as ir,k as se,l as xe,m as yt,n as me}from"./chunks/chunk-PSW6BMXW.js";import"./chunks/chunk-NUFRM6SI.js";import{a as Pe}from"./chunks/chunk-44UOCSGV.js";import{a as st}from"./chunks/chunk-DXB73IDG.js";var Fe=[{name:"echo",load:async()=>(await import("./chunks/echo-O45JWWI2.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-C2OBLGHA.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-KGN6BDCY.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-OTONBH2E.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-QWGXDWUS.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-XTQXT7RK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DX2IJOQ4.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-KPTLPKPH.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XOYR4ABJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-Z6MORUFL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-YAIFIHCT.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-MIKE3OIT.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-D4OZ7N27.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-IEQO24KU.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-HT2B6D2J.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-S5ULNTJU.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-TQB3VNOX.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-74KBZFAX.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-ORQK4GVH.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-RXIECPPB.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-BDPR2JPZ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-T7TNLWXL.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-ZXE4O5XB.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-5SLSESQG.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-LO6YYY5P.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-7N6AFSDS.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-RYO2EDCA.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-XOSYPP45.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-U5YJDM32.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-LDSORVYE.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-DTNXU4LQ.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-RGTMIGZM.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7PLOGTPD.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-EZOC5IIZ.js")).split},{name:"column",load:async()=>(await import("./chunks/column-WLPMMSTS.js")).column},{name:"join",load:async()=>(await import("./chunks/join-GG2LDHE5.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-O7VXZDCO.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-74OP3M7S.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-AA2KJYZQ.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-LEMTZZFS.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-LYXBS7DC.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-DM4QX4XA.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-S547XMN7.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-S547XMN7.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-J4QRNGRO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-OGI2NN6J.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-5CZ5X4YR.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-DYXMG247.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-DYXMG247.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-OJYNICKX.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-A3SGWC34.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-HJF2MPDN.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-FT2P5UCQ.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-JHK4I472.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-5UJUQXOE.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-BPT76IHZ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-RN5ZUASB.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-3572LAOT.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-INMIK4DX.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-VJPNLNU6.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-PI32XWXY.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-ZIGAJ4YS.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-TFCECAGV.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-T2NGLTSG.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-NCIYTMAT.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-T7YAU2Y6.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-BK6HG2DE.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-DGKU3D2X.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-VJEF2UR5.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Fe.push({name:"tar",load:async()=>(await import("./chunks/tar-K7K7BL55.js")).tarCommand}),Fe.push({name:"yq",load:async()=>(await import("./chunks/yq-FD5F3WOJ.js")).yqCommand}),Fe.push({name:"xan",load:async()=>(await import("./chunks/xan-Z6KVJKEE.js")).xanCommand}),Fe.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-Z2IGWYCE.js")).sqlite3Command}));var Et=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Et.push({name:"python3",load:async()=>(await import("./chunks/python3-SKZGHYDO.js")).python3Command}),Et.push({name:"python",load:async()=>(await import("./chunks/python3-SKZGHYDO.js")).pythonCommand}));var Er=[{name:"curl",load:async()=>(await import("./chunks/curl-6L7YZUIH.js")).curlCommand}],br=new Map;function rs(e){return{name:e.name,async execute(t,s){let r=br.get(e.name);if(r||(r=await e.load(),br.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-MX32DFGQ.js");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function ei(){return Fe.map(e=>e.name)}function ti(){return Er.map(e=>e.name)}function $r(e){return(e?Fe.filter(s=>e.includes(s.name)):Fe).map(rs)}function Sr(){return Er.map(rs)}function si(){return Et.map(e=>e.name)}function Pr(){return Et.map(rs)}function Ar(e){return"load"in e&&typeof e.load=="function"}function ri(e,t){return{name:e,execute:t}}function _r(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var ni=new TextEncoder,ii=new TextDecoder;function _e(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return ni.encode(e)}function Ve(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let r="";for(let n=0;n<e.length;n+=s){let i=e.subarray(n,n+s);r+=String.fromCharCode(...i)}return r}return ii.decode(e)}function pe(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var $t=new TextEncoder;function oi(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function re(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var ke=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))oi(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){re(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=pe(r),a=_e(s,o);this.data.set(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t,s){let r=await this.readFileBuffer(t),n=pe(s);return Ve(r,n)}async readFileBuffer(t){re(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return r.content instanceof Uint8Array?r.content:$t.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){re(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=pe(r),a=_e(s,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:$t.encode(i.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(n,{type:"file",content:c,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){re(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=$t.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){re(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let n=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=$t.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){re(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){re(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){re(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){re(t,"cp"),re(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let c=n==="/"?`/${l}`:`${n}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){re(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){re(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){re(t,"link"),re(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){re(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){re(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){re(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function ai(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function li(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function ci(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function ui(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${or}
|
|
2
2
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
3
3
|
`),e.writeFileSync("/proc/self/status",ar()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function kr(e,t){ai(e)&&(li(e,t),ci(e),ui(e))}var fi=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],di=["braceexpand","hashall","interactive-comments"];function ns(e){let t=[],s=[...di.map(r=>({name:r,enabled:!0})),...fi.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(":")}function Be(e){e.state.env.set("SHELLOPTS",ns(e.state.options))}var hi=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function is(e){let t=[];for(let s of hi)e[s]&&t.push(s);return t.join(":")}function os(e){e.state.env.set("BASHOPTS",is(e.state.shoptOptions))}var pi="BASH_ALIAS_";function Cr(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function xr(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Nr(e,t){return e.env.get(`${pi}${t}`)}function as(e,t,s){if(!t.name||!Cr(t.name))return t;let r=xr(t.name);if(!r)return t;let n=Nr(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new W,o=n,a=n.endsWith(" ");if(!a)for(let f of t.args){let d=Dr(f);o+=` ${d}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof gt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Or(t,n);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Or(t,n);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(Cr(f)){let d=xr(f);if(d&&Nr(e,d)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=as(e,h,s);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw s.delete(r),i}}function Or(e,t){let s=t;for(let o of e.args){let a=Dr(o);s+=` ${a}`}let r=new W,n=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Dr(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function Tr(e,t){let s=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!s.endsWith(")"))return null;let n=r[1],i=[],o=!1,a="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let d=f.indexOf("=(");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let d=f.split(/(\s+)/);for(let h of d)/^\s+$/.test(h)?(a||l)&&(i.push(a),a="",l=!1):h&&(a+=h)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=wt({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let d=await Ee(e,{type:"Word",parts:[u]});i.push(...d.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await T(e,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${n}=(${c.join(" ")})`}async function Ir(e,t){let s=-1,r=-1,n=!1;for(let p=0;p<t.parts.length;p++){let g=t.parts[p];if(g.type==="Literal"){let S=g.value.indexOf("+=");if(S!==-1){let k=g.value.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)){s=p,r=S,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(k)){s=p,r=S,n=!0;break}}let v=g.value.indexOf("=");if(v!==-1&&(v===0||g.value[v-1]!=="+")){let k=g.value.slice(0,v);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(k)){s=p,r=v;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=n?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(s+1),f="";for(let p of i)f+=await T(e,{type:"Word",parts:[p]});f+=l;let d={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},h=d.parts.length>0?await T(e,d):"";return`${f}${n?"+=":"="}${h}`}var mi=["tar","yq","xan","sqlite3","python3","python"];function Rr(e){return mi.includes(e)}var M=Object.freeze({stdout:"",stderr:"",exitCode:0});function F(e=""){return{stdout:e,stderr:"",exitCode:0}}function P(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function _(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function q(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Ce(e,t,s="",r=""){throw new se(e,t,s,r)}function ls(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new xe;return M}if(t.length>1)throw new z(1,"",`bash: break: too many arguments
|
|
4
4
|
`);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new z(128,"",`bash: break: ${t[0]}: numeric argument required
|
|
@@ -633,7 +633,7 @@ ${e} ()
|
|
|
633
633
|
`),n=e.includes(" "),i=e.includes("\\"),o=e.includes("'");if(s||r||n||i){let l="";for(let c of e){let u=c.charCodeAt(0);c===`
|
|
634
634
|
`?l+="\\n":c===" "?l+="\\t":c==="\\"?l+="\\\\":c==="'"?l+="'":c==='"'?l+='"':u<32||u===127?u<256?l+=`\\x${u.toString(16).padStart(2,"0")}`:l+=`\\u${u.toString(16).padStart(4,"0")}`:l+=c}return`$'${l}'`}return o?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function Ln(e,t,s){if(!e.state.options.xtrace)return"";let r=await Fn(e),n=[t,...s],i=mo(n);return`${r}${i}
|
|
635
635
|
`}async function Wn(e,t,s){return e.state.options.xtrace?`${await Fn(e)}${t}=${s}
|
|
636
|
-
`:""}async function zn(e,t,s){let r=t.timed?performance.now():0,n="",i=M,o=0,a=[],l=t.commands.length>1,c=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let d=t.commands[f],h=f===t.commands.length-1;l&&(e.state.lastArg="");let
|
|
636
|
+
`:""}async function zn(e,t,s){let r=t.timed?performance.now():0,n="",i=M,o=0,a=[],l=t.commands.length>1,c=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let d=t.commands[f],h=f===t.commands.length-1,m=f===0;l&&(e.state.lastArg="",m||(e.state.groupStdin=void 0));let g=l&&(!h||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,S;try{S=await s(d,n)}catch(v){if(v instanceof pt)S={stdout:v.stdout,stderr:v.stderr,exitCode:1};else if(v instanceof z&&t.commands.length>1)S={stdout:v.stdout,stderr:v.stderr,exitCode:v.exitCode};else if(v instanceof de&&t.commands.length>1)S={stdout:v.stdout,stderr:v.stderr,exitCode:v.exitCode};else throw g&&(e.state.env=g),v}g&&(e.state.env=g),a.push(S.exitCode),S.exitCode!==0&&(o=S.exitCode),h?i=S:t.pipeStderr?.[f]??!1?(n=S.stderr+S.stdout,i={stdout:"",stderr:"",exitCode:S.exitCode}):(n=S.stdout,i={stdout:"",stderr:S.stderr,exitCode:S.exitCode})}if(t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let f of e.state.env.keys())f.startsWith("PIPESTATUS_")&&e.state.env.delete(f);for(let f=0;f<a.length;f++)e.state.env.set(`PIPESTATUS_${f}`,String(a[f]));e.state.env.set("PIPESTATUS__length",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let d=(performance.now()-r)/1e3,h=Math.floor(d/60),m=d%60,p;t.timePosix?p=`real ${d.toFixed(2)}
|
|
637
637
|
user 0.00
|
|
638
638
|
sys 0.00
|
|
639
639
|
`:p=`
|
|
@@ -675,7 +675,7 @@ This is a defense-in-depth measure and indicates a bug in just-bash. Please repo
|
|
|
675
675
|
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=qn({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=er(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,this.state={env:n,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,bashPid:process.pid,nextVirtualPid:process.pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",ns(this.state.options)),this.state.env.set("BASHOPTS",is(this.state.shoptOptions)),kr(s,this.useDefaultLayout),r!=="/"&&s instanceof ke)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let i of $r(t.commands))this.registerCommand(i);if(t.network)for(let i of Sr())this.registerCommand(i);if(t.python)for(let i of Pr())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)Ar(i)?this.registerCommand(_r(i)):this.registerCommand(i)}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let r=`#!/bin/bash
|
|
676
676
|
# Built-in command: ${t.name}
|
|
677
677
|
`;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
678
|
-
`,exitCode:1,env:ye(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:ye(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let r=s?.cwd??this.state.cwd,n,i=r;if(s?.cwd)if(s.env&&"PWD"in s.env)n=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{n=await this.fs.realpath(r),i=n}catch{n=r}else n=r;let o=new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);n!==void 0&&o.set("PWD",n);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable},l=t;s?.rawScript||(l=Fo(t));let u=(this.defenseInDepthConfig?Ye.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let d=ve(l),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new ut(h,a).executeScript(d);return this.logResult(p)};return u?await u.run(f):await f()}catch(f){if(f instanceof z)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ye(this.state.env,s?.env)});if(f instanceof me)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ye(this.state.env,s?.env)});if(f instanceof Re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:ye(this.state.env,s?.env)});if(f instanceof se)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:se.EXIT_CODE,env:ye(this.state.env,s?.env)});if(f instanceof J)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
678
|
+
`,exitCode:1,env:ye(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:ye(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let r=s?.cwd??this.state.cwd,n,i=r;if(s?.cwd)if(s.env&&"PWD"in s.env)n=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{n=await this.fs.realpath(r),i=n}catch{n=r}else n=r;let o=new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);n!==void 0&&o.set("PWD",n);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:s?.stdin},l=t;s?.rawScript||(l=Fo(t));let u=(this.defenseInDepthConfig?Ye.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let d=ve(l),h={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new ut(h,a).executeScript(d);return this.logResult(p)};return u?await u.run(f):await f()}catch(f){if(f instanceof z)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ye(this.state.env,s?.env)});if(f instanceof me)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ye(this.state.env,s?.env)});if(f instanceof Re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:ye(this.state.env,s?.env)});if(f instanceof se)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:se.EXIT_CODE,env:ye(this.state.env,s?.env)});if(f instanceof J)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
679
679
|
`,exitCode:1,env:ye(this.state.env,s?.env)});if(f.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${f.message}
|
|
680
680
|
`,exitCode:2,env:ye(this.state.env,s?.env)});if(f instanceof lr)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
681
681
|
`,exitCode:2,env:ye(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
package/dist/types.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ export interface CommandExecOptions {
|
|
|
29
29
|
* Always pass `ctx.cwd` from the calling command's context.
|
|
30
30
|
*/
|
|
31
31
|
cwd: string;
|
|
32
|
+
/**
|
|
33
|
+
* Standard input to pass to the subcommand.
|
|
34
|
+
* Optional - if not provided, stdin will be empty.
|
|
35
|
+
*/
|
|
36
|
+
stdin?: string;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Context provided to commands during execution.
|