just-bash 2.12.8 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -3
- package/dist/AGENTS.md +1 -1
- package/dist/Bash.d.ts +17 -0
- package/dist/bin/chunks/{awk2-J2PNSA7C.js → awk2-VTJMI54B.js} +1 -1
- package/dist/bin/chunks/chunk-3YMCKZTY.js +14 -0
- package/dist/bin/chunks/{chunk-O5B6WWQQ.js → chunk-A3HQTYHR.js} +1 -1
- package/dist/bin/chunks/chunk-AAW7UMPO.js +9 -0
- package/dist/bin/chunks/{chunk-2V53PP6G.js → chunk-B3RU2PUI.js} +27 -27
- package/dist/bin/chunks/chunk-CQG2HEAL.js +5 -0
- package/dist/bin/chunks/chunk-DOXYBGNA.js +12 -0
- package/dist/bin/{shell/chunks/chunk-YAEF6X2N.js → chunks/chunk-GR23MPTT.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-35JD7YEM.js → chunks/chunk-HJEHIH4P.js} +13 -13
- package/dist/bin/chunks/{chunk-UG4GMDQL.js → chunk-LGF54XJQ.js} +1 -1
- package/dist/bin/chunks/chunk-N6KA6G3Q.js +11 -0
- package/dist/bin/chunks/{chunk-2BC3N3L2.js → chunk-ORUYSLP4.js} +4 -4
- package/dist/bin/chunks/{chunk-REGSV3X5.js → chunk-SDLWFYVT.js} +1 -1
- package/dist/bin/chunks/{chunk-STOAUD75.js → chunk-THNL3XFF.js} +8 -8
- package/dist/bin/chunks/{chunk-ZJGIBTWD.js → chunk-V7ZOPVQS.js} +1 -1
- package/dist/bin/chunks/{chunk-ZYQQ6B7B.js → chunk-ZO5PSLKR.js} +2 -2
- package/dist/bin/{shell/chunks/curl-3GMIPMCI.js → chunks/curl-B64SIJOD.js} +1 -1
- package/dist/bin/chunks/env-NTPN5QYM.js +2 -0
- package/dist/bin/{shell/chunks/expansion-JBCP2CHQ.js → chunks/expansion-2RO5M3QC.js} +1 -1
- package/dist/bin/{shell/chunks/find-MTLF23HX.js → chunks/find-GAYRV4IF.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-CFWN3JJN.js → chunks/flag-coverage-IRM4GISL.js} +1 -1
- package/dist/bin/{shell/chunks/help-4H52JYYC.js → chunks/help-DVG4AAGE.js} +1 -1
- package/dist/bin/{shell/chunks/jq-JFXEKNLN.js → chunks/jq-V7FYGIKO.js} +1 -1
- package/dist/bin/chunks/js-exec-YGYYZEEQ.js +97 -0
- package/dist/bin/chunks/js-exec-worker.js +4368 -0
- package/dist/bin/chunks/python3-EIXZW3LO.js +12 -0
- package/dist/bin/chunks/rg-C6KMBFNG.js +2 -0
- package/dist/bin/{shell/chunks/time-GZSHCM77.js → chunks/time-VSKBXRQH.js} +1 -1
- package/dist/bin/chunks/{timeout-JJWIFL7W.js → timeout-Z24MNWOP.js} +1 -1
- package/dist/bin/chunks/worker.js +87 -33
- package/dist/bin/chunks/{xan-M6MLWZCU.js → xan-MOZFJGMY.js} +1 -1
- package/dist/bin/chunks/xargs-SCYIFXOW.js +2 -0
- package/dist/bin/chunks/{yq-YWUQUXJJ.js → yq-JJLSDDST.js} +1 -1
- package/dist/bin/just-bash.js +158 -157
- package/dist/bin/shell/chunks/{awk2-J2PNSA7C.js → awk2-VTJMI54B.js} +1 -1
- package/dist/bin/shell/chunks/chunk-3YMCKZTY.js +14 -0
- package/dist/bin/shell/chunks/{chunk-O5B6WWQQ.js → chunk-A3HQTYHR.js} +1 -1
- package/dist/bin/shell/chunks/chunk-AAW7UMPO.js +9 -0
- package/dist/bin/shell/chunks/{chunk-2V53PP6G.js → chunk-B3RU2PUI.js} +27 -27
- package/dist/bin/shell/chunks/chunk-CQG2HEAL.js +5 -0
- package/dist/bin/shell/chunks/chunk-DOXYBGNA.js +12 -0
- package/dist/bin/{chunks/chunk-YAEF6X2N.js → shell/chunks/chunk-GR23MPTT.js} +1 -1
- package/dist/bin/{chunks/chunk-35JD7YEM.js → shell/chunks/chunk-HJEHIH4P.js} +13 -13
- package/dist/bin/shell/chunks/{chunk-UG4GMDQL.js → chunk-LGF54XJQ.js} +1 -1
- package/dist/bin/shell/chunks/chunk-N6KA6G3Q.js +11 -0
- package/dist/bin/shell/chunks/{chunk-2BC3N3L2.js → chunk-ORUYSLP4.js} +4 -4
- package/dist/bin/shell/chunks/{chunk-REGSV3X5.js → chunk-SDLWFYVT.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-STOAUD75.js → chunk-THNL3XFF.js} +8 -8
- package/dist/bin/shell/chunks/{chunk-ZJGIBTWD.js → chunk-V7ZOPVQS.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-ZYQQ6B7B.js → chunk-ZO5PSLKR.js} +2 -2
- package/dist/bin/{chunks/curl-3GMIPMCI.js → shell/chunks/curl-B64SIJOD.js} +1 -1
- package/dist/bin/shell/chunks/env-NTPN5QYM.js +2 -0
- package/dist/bin/{chunks/expansion-JBCP2CHQ.js → shell/chunks/expansion-2RO5M3QC.js} +1 -1
- package/dist/bin/{chunks/find-MTLF23HX.js → shell/chunks/find-GAYRV4IF.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-CFWN3JJN.js → shell/chunks/flag-coverage-IRM4GISL.js} +1 -1
- package/dist/bin/{chunks/help-4H52JYYC.js → shell/chunks/help-DVG4AAGE.js} +1 -1
- package/dist/bin/{chunks/jq-JFXEKNLN.js → shell/chunks/jq-V7FYGIKO.js} +1 -1
- package/dist/bin/shell/chunks/js-exec-VYG74FQ3.js +97 -0
- package/dist/bin/shell/chunks/python3-WO3WFGMS.js +12 -0
- package/dist/bin/shell/chunks/rg-C6KMBFNG.js +2 -0
- package/dist/bin/{chunks/time-GZSHCM77.js → shell/chunks/time-VSKBXRQH.js} +1 -1
- package/dist/bin/shell/chunks/{timeout-JJWIFL7W.js → timeout-Z24MNWOP.js} +1 -1
- package/dist/bin/shell/chunks/{xan-M6MLWZCU.js → xan-MOZFJGMY.js} +1 -1
- package/dist/bin/shell/chunks/xargs-SCYIFXOW.js +2 -0
- package/dist/bin/shell/chunks/{yq-YWUQUXJJ.js → yq-JJLSDDST.js} +1 -1
- package/dist/bin/shell/shell.js +164 -164
- package/dist/bundle/browser.js +534 -534
- package/dist/bundle/chunks/{awk2-FUVZGMX2.js → awk2-POPGKRAI.js} +1 -1
- package/dist/bundle/chunks/{chunk-DZZS6SJP.js → chunk-7TSDKFEO.js} +1 -1
- package/dist/bundle/chunks/{chunk-D4QDMGEB.js → chunk-BBXLRYSX.js} +2 -2
- package/dist/bundle/chunks/{chunk-TRD56HID.js → chunk-FEIOJCZD.js} +1 -1
- package/dist/bundle/chunks/chunk-JCMONG3T.js +13 -0
- package/dist/bundle/chunks/{chunk-D2FZX7A2.js → chunk-LPQPILI2.js} +8 -8
- package/dist/bundle/chunks/chunk-MJWMXCEJ.js +10 -0
- package/dist/bundle/chunks/{chunk-2GOYXRRP.js → chunk-MLXIYONF.js} +4 -4
- package/dist/bundle/chunks/chunk-NAERJDUW.js +8 -0
- package/dist/bundle/chunks/{chunk-OKEHYWBE.js → chunk-NYQYO467.js} +13 -13
- package/dist/bundle/chunks/{chunk-JKLUDNMU.js → chunk-O2DBFL6Z.js} +1 -1
- package/dist/bundle/chunks/{chunk-JDMQDJYE.js → chunk-OARHFVLG.js} +1 -1
- package/dist/bundle/chunks/{chunk-AKVMAONP.js → chunk-RUF7WQ7U.js} +1 -1
- package/dist/bundle/chunks/chunk-TOMNU26N.js +4 -0
- package/dist/bundle/chunks/{chunk-ZLJ5TCLC.js → chunk-UNYNJIFU.js} +27 -27
- package/dist/bundle/chunks/chunk-YTNYSM6T.js +11 -0
- package/dist/bundle/chunks/{curl-KM2ZAUR6.js → curl-FCIO57JJ.js} +1 -1
- package/dist/bundle/chunks/env-5EPCWSXR.js +1 -0
- package/dist/bundle/chunks/{expansion-XG7G47TX.js → expansion-ENLSRCXJ.js} +1 -1
- package/dist/bundle/chunks/{find-DOIVMX6X.js → find-TPUOAIUQ.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-VML3BMJT.js → flag-coverage-SPT2DN2I.js} +1 -1
- package/dist/bundle/chunks/{help-IA5CMGR4.js → help-VVWX7SA5.js} +1 -1
- package/dist/bundle/chunks/{jq-SSCW4AAA.js → jq-DIRZBOTX.js} +1 -1
- package/dist/bundle/chunks/js-exec-R2LSP7M4.js +96 -0
- package/dist/bundle/chunks/js-exec-worker.js +4368 -0
- package/dist/bundle/chunks/python3-DH2SBOI3.js +11 -0
- package/dist/bundle/chunks/rg-FOQSCCX3.js +1 -0
- package/dist/bundle/chunks/{time-XL42Z4U5.js → time-FABCOJJU.js} +1 -1
- package/dist/bundle/chunks/{timeout-QCU4INQT.js → timeout-VRKMCG72.js} +1 -1
- package/dist/bundle/chunks/worker.js +87 -33
- package/dist/bundle/chunks/{xan-K7XYDHFV.js → xan-BXDXYEIB.js} +1 -1
- package/dist/bundle/chunks/xargs-I6EZUCYF.js +1 -0
- package/dist/bundle/chunks/{yq-WTK3HUOR.js → yq-XMVSIL6Z.js} +1 -1
- package/dist/bundle/index.cjs +956 -857
- package/dist/bundle/index.js +145 -145
- package/dist/commands/js-exec/fetch-polyfill.d.ts +6 -0
- package/dist/commands/js-exec/js-exec.d.ts +11 -0
- package/dist/commands/js-exec/module-shims.d.ts +29 -0
- package/dist/commands/js-exec/path-polyfill.d.ts +6 -0
- package/dist/commands/js-exec/worker.d.ts +30 -0
- package/dist/commands/python3/worker.d.ts +1 -0
- package/dist/commands/query-engine/safe-object.d.ts +11 -0
- package/dist/commands/registry.d.ts +13 -2
- package/dist/commands/{python3/fs-bridge-handler.d.ts → worker-bridge/bridge-handler.d.ts} +25 -8
- package/dist/commands/{python3 → worker-bridge}/protocol.d.ts +6 -3
- package/dist/commands/{python3/sync-fs-backend.d.ts → worker-bridge/sync-backend.d.ts} +25 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/interpreter/interpreter.d.ts +3 -0
- package/dist/interpreter/types.d.ts +8 -0
- package/dist/limits.d.ts +3 -1
- package/dist/types.d.ts +12 -0
- package/package.json +12 -11
- package/dist/bin/chunks/chunk-47HZU3SY.js +0 -5
- package/dist/bin/chunks/chunk-CZFRRDQC.js +0 -12
- package/dist/bin/chunks/chunk-N4EU64Y4.js +0 -9
- package/dist/bin/chunks/chunk-VIYJJTN2.js +0 -14
- package/dist/bin/chunks/env-HOVBNLUR.js +0 -2
- package/dist/bin/chunks/python3-KI2FQWSN.js +0 -17
- package/dist/bin/chunks/rg-34GE6REQ.js +0 -2
- package/dist/bin/chunks/xargs-GBL6PZ2K.js +0 -2
- package/dist/bin/shell/chunks/chunk-47HZU3SY.js +0 -5
- package/dist/bin/shell/chunks/chunk-CZFRRDQC.js +0 -12
- package/dist/bin/shell/chunks/chunk-N4EU64Y4.js +0 -9
- package/dist/bin/shell/chunks/chunk-VIYJJTN2.js +0 -14
- package/dist/bin/shell/chunks/env-HOVBNLUR.js +0 -2
- package/dist/bin/shell/chunks/python3-E5X6WBBU.js +0 -17
- package/dist/bin/shell/chunks/rg-34GE6REQ.js +0 -2
- package/dist/bin/shell/chunks/xargs-GBL6PZ2K.js +0 -2
- package/dist/bundle/chunks/chunk-3RA5L262.js +0 -8
- package/dist/bundle/chunks/chunk-EX62JIX3.js +0 -13
- package/dist/bundle/chunks/chunk-WECLUBEQ.js +0 -11
- package/dist/bundle/chunks/chunk-ZSJYNBAF.js +0 -4
- package/dist/bundle/chunks/env-XZY4LKEO.js +0 -1
- package/dist/bundle/chunks/python3-2OHR6PZU.js +0 -16
- package/dist/bundle/chunks/rg-RAICUFGG.js +0 -1
- package/dist/bundle/chunks/xargs-2BBAQDTC.js +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as g}from"./chunk-4OALHZXB.js";import{c as u}from"./chunk-QZNF3Y3J.js";import{a as h}from"./chunk-4PRVMER6.js";import{a as f}from"./chunk-SYG3IW7P.js";var v={name:"time",async execute(r,s){let a="%e %M",o=null,c=!1,p=!1,t=0;for(;t<r.length;){let e=r[t];if(e==="-f"||e==="--format"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-f'
|
|
3
|
-
`,exitCode:1};a=r[t],t++}else if(e==="-o"||e==="--output"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-o'
|
|
4
|
-
`,exitCode:1};o=r[t],t++}else if(e==="-a"||e==="--append")c=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
|
|
5
|
-
Elapsed (wall clock) time: %e seconds
|
|
6
|
-
Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")p=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let d=r.slice(t);if(d.length===0)return{stdout:"",stderr:"",exitCode:0};let w=u(),C=g(d),F=d.join(" "),i;try{if(!s.exec)return{stdout:"",stderr:`time: exec not available
|
|
7
|
-
`,exitCode:1};i=await s.exec(C,{env:h(s.env),cwd:s.cwd,stdin:s.stdin,signal:s.signal})}catch(e){i={stdout:"",stderr:`time: ${f(e.message)}
|
|
8
|
-
`,exitCode:127}}let m=(u()-w)/1e3,n;if(p?n=`real ${m.toFixed(2)}
|
|
9
|
-
user 0.00
|
|
10
|
-
sys 0.00
|
|
11
|
-
`:(n=a.replace(/%e/g,m.toFixed(2)).replace(/%E/g,x(m)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,F),n.endsWith(`
|
|
12
|
-
`)||(n+=`
|
|
13
|
-
`)),o)try{let e=s.fs.resolvePath(s.cwd,o);if(c&&await s.fs.exists(e)){let l=await s.fs.readFile(e);await s.fs.writeFile(e,l+n)}else await s.fs.writeFile(e,n)}catch(e){let l=f(e.message);return{stdout:i.stdout,stderr:i.stderr+`time: cannot write to '${o}': ${l}
|
|
14
|
-
`,exitCode:i.exitCode}}else i={...i,stderr:i.stderr+n};return i}};function x(r){let s=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return s>0?`${s}:${a.toString().padStart(2,"0")}:${o.toFixed(2).padStart(5,"0")}`:`${a}:${o.toFixed(2).padStart(5,"0")}`}var T={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{v as a,T as b};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import"./chunk-MY5PY2PL.js";import{a as M,b as c}from"./chunk-QZNF3Y3J.js";import{a as P,b as U}from"./chunk-OOJCYVYF.js";import{a as N}from"./chunk-4PRVMER6.js";import{c as y}from"./chunk-MO4RPBN2.js";import{b as I}from"./chunk-YU6OGPZR.js";import{a as l}from"./chunk-SYG3IW7P.js";import{a as L,b as k}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import{randomBytes as H}from"node:crypto";import{fileURLToPath as W}from"node:url";import{Worker as z}from"node:worker_threads";var u={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200},a={PENDING:0,READY:1,SUCCESS:2,ERROR:3},E={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,TIMEOUT:8,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10},i={OP_CODE:0,STATUS:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,PATH_BUFFER:32,DATA_BUFFER:4128},w={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:1048576,TOTAL:1052704},F={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},p={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function V(){return new M(w.TOTAL)}var A=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return c.load(this.int32View,i.OP_CODE/4)}setOpCode(t){c.store(this.int32View,i.OP_CODE/4,t)}getStatus(){return c.load(this.int32View,i.STATUS/4)}setStatus(t){c.store(this.int32View,i.STATUS/4,t)}getPathLength(){return c.load(this.int32View,i.PATH_LENGTH/4)}setPathLength(t){c.store(this.int32View,i.PATH_LENGTH/4,t)}getDataLength(){return c.load(this.int32View,i.DATA_LENGTH/4)}setDataLength(t){c.store(this.int32View,i.DATA_LENGTH/4,t)}getResultLength(){return c.load(this.int32View,i.RESULT_LENGTH/4)}setResultLength(t){c.store(this.int32View,i.RESULT_LENGTH/4,t)}getErrorCode(){return c.load(this.int32View,i.ERROR_CODE/4)}setErrorCode(t){c.store(this.int32View,i.ERROR_CODE/4,t)}getFlags(){return c.load(this.int32View,i.FLAGS/4)}setFlags(t){c.store(this.int32View,i.FLAGS/4,t)}getMode(){return c.load(this.int32View,i.MODE/4)}setMode(t){c.store(this.int32View,i.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(i.PATH_BUFFER,i.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>w.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${w.PATH_BUFFER}`);this.uint8View.set(e,i.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setData(t){if(t.length>w.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${w.DATA_BUFFER}`);this.uint8View.set(t,i.DATA_BUFFER),this.setDataLength(t.length)}getDataAsString(){let t=this.getData();return new TextDecoder().decode(t)}setDataFromString(t){let e=new TextEncoder().encode(t);this.setData(e)}getResult(){let t=this.getResultLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setResult(t){if(t.length>w.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${w.DATA_BUFFER}`);this.uint8View.set(t,i.DATA_BUFFER),this.setResultLength(t.length)}getResultAsString(){let t=this.getResult();return new TextDecoder().decode(t)}setResultFromString(t){let e=new TextEncoder().encode(t);this.setResult(e)}encodeStat(t){this.uint8View[i.DATA_BUFFER+p.IS_FILE]=t.isFile?1:0,this.uint8View[i.DATA_BUFFER+p.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[i.DATA_BUFFER+p.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(i.DATA_BUFFER+p.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(i.DATA_BUFFER+p.SIZE,e,!0),this.dataView.setFloat64(i.DATA_BUFFER+p.MTIME,t.mtime.getTime(),!0),this.setResultLength(p.TOTAL)}decodeStat(){return{isFile:this.uint8View[i.DATA_BUFFER+p.IS_FILE]===1,isDirectory:this.uint8View[i.DATA_BUFFER+p.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[i.DATA_BUFFER+p.IS_SYMLINK]===1,mode:this.dataView.getInt32(i.DATA_BUFFER+p.MODE,!0),size:this.dataView.getFloat64(i.DATA_BUFFER+p.SIZE,!0),mtime:new Date(this.dataView.getFloat64(i.DATA_BUFFER+p.MTIME,!0))}}waitForReady(t){return c.wait(this.int32View,i.STATUS/4,a.PENDING,t)}waitForReadyAsync(t){return c.waitAsync(this.int32View,i.STATUS/4,a.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let s=this.getStatus();if(s===a.READY)return!0;let r=Date.now()-e;if(r>=t)return!1;let n=t-r,m=c.waitAsync(this.int32View,i.STATUS/4,s,n);if(m.async&&await m.value==="timed-out")return!1}}waitForResult(t){return c.wait(this.int32View,i.STATUS/4,a.READY,t)}notify(){return c.notify(this.int32View,i.STATUS/4)}reset(){this.setOpCode(u.NOOP),this.setStatus(a.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(E.NONE),this.setFlags(F.NONE),this.setMode(0)}};var x=class{fs;cwd;secureFetch;maxOutputSize;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;constructor(t,e,s,r=void 0,n=0){this.fs=e,this.cwd=s,this.secureFetch=r,this.maxOutputSize=n,this.protocol=new A(t)}async run(t){this.running=!0;let e=Date.now();for(;this.running;){let s=Date.now()-e;if(s>=t){this.output.stderr+=`
|
|
3
|
-
python3: execution timeout exceeded
|
|
4
|
-
`,this.output.exitCode=124;break}let r=t-s;if(!await this.protocol.waitUntilReady(r)){this.output.stderr+=`
|
|
5
|
-
python3: execution timeout exceeded
|
|
6
|
-
`,this.output.exitCode=124;break}let m=this.protocol.getOpCode();await this.handleOperation(m),this.protocol.notify()}return this.output}stop(){this.running=!1}async handleOperation(t){try{switch(t){case u.READ_FILE:await this.handleReadFile();break;case u.WRITE_FILE:await this.handleWriteFile();break;case u.STAT:await this.handleStat();break;case u.LSTAT:await this.handleLstat();break;case u.READDIR:await this.handleReaddir();break;case u.MKDIR:await this.handleMkdir();break;case u.RM:await this.handleRm();break;case u.EXISTS:await this.handleExists();break;case u.APPEND_FILE:await this.handleAppendFile();break;case u.SYMLINK:await this.handleSymlink();break;case u.READLINK:await this.handleReadlink();break;case u.CHMOD:await this.handleChmod();break;case u.REALPATH:await this.handleRealpath();break;case u.WRITE_STDOUT:this.handleWriteStdout();break;case u.WRITE_STDERR:this.handleWriteStderr();break;case u.EXIT:this.handleExit();break;case u.HTTP_REQUEST:await this.handleHttpRequest();break;default:this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setStatus(a.ERROR)}}catch(e){this.setErrorFromException(e)}}resolvePath(t){return this.fs.resolvePath(this.cwd,t)}async handleReadFile(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readFileBuffer(t);this.protocol.setResult(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleWriteFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.writeFile(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleStat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.stat(t);this.protocol.encodeStat(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleLstat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.lstat(t);this.protocol.encodeStat(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleReaddir(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readdir(t);this.protocol.setResultFromString(JSON.stringify(e)),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleMkdir(){let t=this.resolvePath(this.protocol.getPath()),s=(this.protocol.getFlags()&F.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:s}),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=(e&F.RECURSIVE)!==0,r=(e&F.FORCE)!==0;try{await this.fs.rm(t,{recursive:s,force:r}),this.protocol.setStatus(a.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleExists(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.exists(t);this.protocol.setResult(new Uint8Array([e?1:0])),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleAppendFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.appendFile(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleSymlink(){let t=this.protocol.getPath(),e=this.protocol.getDataAsString(),s=this.resolvePath(t);try{await this.fs.symlink(e,s),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleReadlink(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readlink(t);this.protocol.setResultFromString(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleChmod(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getMode();try{await this.fs.chmod(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRealpath(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.realpath(t);this.protocol.setResultFromString(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}handleWriteStdout(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(a.ERROR);return}this.protocol.setStatus(a.SUCCESS)}handleWriteStderr(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stderr",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(a.ERROR);return}this.protocol.setStatus(a.SUCCESS)}handleExit(){let t=this.protocol.getFlags();this.outputLimitExceeded?this.output.exitCode===0&&(this.output.exitCode=1):this.output.exitCode=t,this.protocol.setStatus(a.SUCCESS),this.running=!1}tryAppendOutput(t,e){return this.outputLimitExceeded?!1:this.maxOutputSize<=0?(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0):this.output.stdout.length+this.output.stderr.length+e.length>this.maxOutputSize?!1:(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0)}appendOutputLimitError(){if(this.maxOutputSize<=0)return;let t=`python3: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
|
|
7
|
-
`,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let r=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(r>0)if(this.output.stdout.length>=r)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-r);else{let n=r-this.output.stdout.length;this.output.stdout="",n>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-n)}this.output.stderr+=e}async handleHttpRequest(){if(!this.secureFetch){this.protocol.setErrorCode(E.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(a.ERROR);return}let t=this.protocol.getPath(),e=this.protocol.getDataAsString();try{let s=e?JSON.parse(e):{},r=await this.secureFetch(t,{method:s.method,headers:s.headers,body:s.body}),n=JSON.stringify({status:r.status,statusText:r.statusText,headers:r.headers,body:r.body,url:r.url});this.protocol.setResultFromString(n),this.protocol.setStatus(a.SUCCESS)}catch(s){let r=l(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(E.NETWORK_ERROR),this.protocol.setResultFromString(r),this.protocol.setStatus(a.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),s=l(e),r=E.IO_ERROR,n=e.toLowerCase();n.includes("no such file")||n.includes("not found")||n.includes("enoent")?r=E.NOT_FOUND:n.includes("is a directory")||n.includes("eisdir")?r=E.IS_DIRECTORY:n.includes("not a directory")||n.includes("enotdir")?r=E.NOT_DIRECTORY:n.includes("already exists")||n.includes("eexist")?r=E.EXISTS:(n.includes("permission")||n.includes("eperm")||n.includes("eacces"))&&(r=E.PERMISSION_DENIED),this.protocol.setErrorCode(r),this.protocol.setResultFromString(s),this.protocol.setStatus(a.ERROR)}};var G=3e4,$={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};function Y(o){let t={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(o.length===0)return t;let e=o.findIndex(s=>!s.startsWith("-")||s==="-"||s==="--");for(let s=0;s<(e===-1?o.length:e);s++){let r=o[s];if(r==="-c")return s+1>=o.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
|
|
8
|
-
`,exitCode:2}:(t.code=o[s+1],t.scriptArgs=o.slice(s+2),t);if(r==="-m")return s+1>=o.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
|
|
9
|
-
`,exitCode:2}:(t.module=o[s+1],t.scriptArgs=o.slice(s+2),t);if(r==="--version"||r==="-V")return t.showVersion=!0,t;if(r.startsWith("-")&&r!=="-")return{stdout:"",stderr:`python3: unrecognized option '${r}'
|
|
10
|
-
`,exitCode:2}}if(e!==-1){let s=o[e];s==="--"?e+1<o.length&&(t.scriptFile=o[e+1],t.scriptArgs=o.slice(e+2)):(t.scriptFile=s,t.scriptArgs=o.slice(e+1))}return t}var _=new WeakMap;function K(o){let t=_.get(o);return t||(t={executionQueue:[],isExecuting:!1},_.set(o,t)),t}function Rt(){_=new WeakMap}var Q=W(new URL("./worker.js",import.meta.url));function X(){return H(16).toString("hex")}function Z(o,t){if(!o||typeof o!="object")return{success:!1,error:"Malformed worker response"};let e=o;return typeof e.protocolToken!="string"||e.protocolToken!==t?{success:!1,error:"Malformed worker response: invalid protocol token"}:e.type==="security-violation"?{success:!1,error:`Security violation: ${typeof e.violation?.type=="string"?e.violation.type:"unknown"}`}:typeof e.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:e.success?{success:!0}:{success:!1,error:typeof e.error=="string"&&e.error.length>0?e.error:"Worker execution failed"}}function f(o){if(o.isExecuting||o.executionQueue.length===0)return;for(;o.executionQueue.length>0&&o.executionQueue[0].canceled;)o.executionQueue.shift();if(o.executionQueue.length===0)return;let t=o.executionQueue.shift();if(!t)return;o.isExecuting=!0;let e;try{e=I.runTrusted(()=>new z(Q,{workerData:t.input}))}catch(h){let d=h instanceof Error?h.message:String(h);t.resolve({success:!1,error:l(d)}),o.isExecuting=!1,f(o);return}t.workerRef&&(t.workerRef.current=e);let s=y(t.requireDefenseContext,"python3","worker message callback",h=>{t.resolve(Z(h,t.input.protocolToken)),o.isExecuting=!1,e.terminate(),f(o)}),r=y(t.requireDefenseContext,"python3","worker error callback",h=>{t.resolve({success:!1,error:l(h.message)}),o.isExecuting=!1,f(o)}),n=y(t.requireDefenseContext,"python3","worker exit callback",()=>{o.isExecuting&&(t.resolve({success:!1,error:"Worker exited unexpectedly"}),o.isExecuting=!1,f(o))}),m=h=>{try{s(h)}catch(d){let g=d instanceof Error?d.message:String(d);t.resolve({success:!1,error:l(g)}),o.isExecuting=!1,e.terminate(),f(o)}},S=h=>{try{r(h)}catch(d){let g=d instanceof Error?d.message:String(d);t.resolve({success:!1,error:l(g)}),o.isExecuting=!1,f(o)}},D=()=>{try{n()}catch(h){let d=h instanceof Error?h.message:String(h);t.resolve({success:!1,error:l(d)}),o.isExecuting=!1,f(o)}};e.on("message",m),e.on("error",S),e.on("exit",D)}async function J(o,t,e,s=[]){let r=V(),n=new x(r,t.fs,t.cwd,t.fetch,t.limits?.maxOutputSize??0),m=t.limits?.maxPythonTimeoutMs??G,S=K(t.fs),D={protocolToken:X(),sharedBuffer:r,pythonCode:o,cwd:t.cwd,env:N(t.env),args:s,scriptPath:e},h={current:null},d=new Promise(R=>{let C={input:D,resolve:()=>{},workerRef:h,requireDefenseContext:t.requireDefenseContext},b=y(t.requireDefenseContext,"python3","worker timeout callback",()=>{h.current?h.current.terminate():C.canceled=!0,R({success:!1,error:`Execution timeout: exceeded ${m}ms limit`})}),v=P(()=>{try{b()}catch(T){let B=T instanceof Error?T.message:String(T);R({success:!1,error:l(B)})}},m);C.resolve=T=>{U(v),R(T)},S.executionQueue.push(C),f(S)}),[g,O]=await Promise.all([n.run(m).catch(R=>({stdout:"",stderr:`python3: bridge error: ${l(R.message)}
|
|
11
|
-
`,exitCode:1})),d.catch(R=>({success:!1,error:l(R.message)}))]);if(!O.success&&O.error){let R=l(O.error);return{stdout:g.stdout,stderr:`${g.stderr}python3: ${R}
|
|
12
|
-
`,exitCode:g.exitCode||1}}return g}var j={name:"python3",async execute(o,t){if(k(o))return L($);let e=Y(o);if("exitCode"in e)return e;if(e.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
|
|
13
|
-
`,stderr:"",exitCode:0};let s,r;if(e.code!==null)s=e.code,r="-c";else if(e.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(e.module))return{stdout:"",stderr:`python3: No module named '${e.module.slice(0,200)}'
|
|
14
|
-
`,exitCode:1};s=`import runpy; runpy.run_module('${e.module}', run_name='__main__')`,r=e.module}else if(e.scriptFile!==null){let n=t.fs.resolvePath(t.cwd,e.scriptFile);if(!await t.fs.exists(n))return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': [Errno 2] No such file or directory
|
|
15
|
-
`,exitCode:2};try{s=await t.fs.readFile(n),r=e.scriptFile}catch(m){let S=l(m.message);return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': ${S}
|
|
16
|
-
`,exitCode:2}}}else if(t.stdin.trim())s=t.stdin,r="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
|
|
17
|
-
`,exitCode:2};return J(s,t,r,e.scriptArgs)}},gt={name:"python",async execute(o,t){return j.execute(o,t)}};export{Rt as _resetExecutionQueue,j as python3Command,gt as pythonCommand};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as A,b as I,c as b}from"./chunk-GTNBSMZR.js";var $={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},N={name:"xargs",async execute(l,i){if(I(l))return A($);let m=null,g=null,c=null,o=null,h=!1,x=!1,y=!1,s=0;for(let e=0;e<l.length;e++){let t=l[e];if(t==="-I"&&e+1<l.length)m=l[++e],s=e+1;else if(t==="-d"&&e+1<l.length)g=l[++e].replace(/\\n/g,`
|
|
3
|
-
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),s=e+1;else if(t==="-n"&&e+1<l.length)c=parseInt(l[++e],10),s=e+1;else if(t==="-P"&&e+1<l.length)o=parseInt(l[++e],10),s=e+1;else if(t==="-0"||t==="--null")h=!0,s=e+1;else if(t==="-t"||t==="--verbose")x=!0,s=e+1;else if(t==="-r"||t==="--no-run-if-empty")y=!0,s=e+1;else{if(t.startsWith("--"))return b("xargs",t);if(t.startsWith("-")&&t.length>1){for(let n of t.slice(1))if(!"0tr".includes(n))return b("xargs",`-${n}`);t.includes("0")&&(h=!0),t.includes("t")&&(x=!0),t.includes("r")&&(y=!0),s=e+1}else if(!t.startsWith("-")){s=e;break}}}let a=l.slice(s);a.length===0&&a.push("echo");let r;if(h?r=i.stdin.split("\0").filter(e=>e.length>0):g!==null?r=i.stdin.replace(/\n$/,"").split(g).filter(t=>t.length>0):r=i.stdin.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),r.length===0)return y?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",u="",f=0,v=e=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(e)?`"${e.replace(/([\\"`$])/g,"\\$1")}"`:e,C=async e=>{let t=e.map(v).join(" ");return x&&(u+=`${t}
|
|
4
|
-
`),i.exec?i.exec(t,{cwd:i.cwd,signal:i.signal}):{stdout:`${t}
|
|
5
|
-
`,stderr:"",exitCode:0}},w=async e=>{if(o!==null&&o>1)for(let t=0;t<e.length;t+=o){let n=e.slice(t,t+o),M=await Promise.all(n.map(C));for(let p of M)d+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}else for(let t of e){let n=await C(t);d+=n.stdout,u+=n.stderr,n.exitCode!==0&&(f=n.exitCode)}};if(m!==null){let e=r.map(t=>a.map(n=>n.replaceAll(m,t)));await w(e)}else if(c!==null){let e=[];for(let t=0;t<r.length;t+=c){let n=r.slice(t,t+c);e.push([...a,...n])}await w(e)}else{let e=[...a,...r],t=await C(e);d+=t.stdout,u+=t.stderr,f=t.exitCode}return{stdout:d,stderr:u,exitCode:f}}},P={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"};export{N as a,P as b};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as x}from"./chunk-YTIURC67.js";import{a as O}from"./chunk-4OALHZXB.js";import{a as c,b as p}from"./chunk-OOJCYVYF.js";import{a as h,b as A,c as l}from"./chunk-GTNBSMZR.js";var y={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
|
|
3
|
-
|
|
4
|
-
DURATION is a number with optional suffix:
|
|
5
|
-
s - seconds (default)
|
|
6
|
-
m - minutes
|
|
7
|
-
h - hours
|
|
8
|
-
d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]},D={name:"timeout",async execute(s,n){if(A(s))return h(y);let i=0;for(let e=0;e<s.length;e++){let t=s[e];if(t==="--preserve-status")i=e+1;else if(t==="--foreground")i=e+1;else if(t==="-k"||t==="--kill-after")e++,i=e+1;else if(t.startsWith("--kill-after="))i=e+1;else if(t==="-s"||t==="--signal")e++,i=e+1;else if(t.startsWith("--signal="))i=e+1;else{if(t.startsWith("--")&&t!=="--")return l("timeout",t);if(t.startsWith("-")&&t.length>1&&t!=="--")if(t.startsWith("-k"))i=e+1;else if(t.startsWith("-s"))i=e+1;else return l("timeout",t);else{i=e;break}}}let r=s.slice(i);if(r.length===0)return{stdout:"",stderr:`timeout: missing operand
|
|
9
|
-
`,exitCode:1};let u=r[0],m=x(u);if(m===null)return{stdout:"",stderr:`timeout: invalid time interval '${u}'
|
|
10
|
-
`,exitCode:1};let d=r.slice(1);if(d.length===0)return{stdout:"",stderr:`timeout: missing operand
|
|
11
|
-
`,exitCode:1};if(!n.exec)return{stdout:"",stderr:`timeout: exec not available
|
|
12
|
-
`,exitCode:1};let v=O(d),f=new AbortController,o;try{let e=new Promise(a=>{o=c(()=>{f.abort(),a({timedOut:!0})},m)}),t=n.exec(v,{cwd:n.cwd,signal:f.signal,stdin:n.stdin}).then(a=>({timedOut:!1,result:a})),g=await Promise.race([e,t]);return g.timedOut?{stdout:"",stderr:"",exitCode:124}:g.result}finally{o!==void 0&&p(o)}}},I={name:"timeout",flags:[{flag:"-k",type:"value",valueHint:"string"},{flag:"-s",type:"value",valueHint:"string"},{flag:"--preserve-status",type:"boolean"},{flag:"--foreground",type:"boolean"}],needsArgs:!0,minArgs:2};export{D as a,I as b};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as v}from"./chunk-4OALHZXB.js";import{a as d}from"./chunk-4PRVMER6.js";import{a as c,b as m,c as f}from"./chunk-GTNBSMZR.js";var y={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},N={name:"env",async execute(o,i){if(m(o))return c(y);let a=!1,r=[],u=new Map,t=-1;for(let n=0;n<o.length;n++){let e=o[n];if(e==="-i"||e==="--ignore-environment")a=!0;else if(e==="-u"&&n+1<o.length)r.push(o[++n]);else if(e.startsWith("-u"))r.push(e.slice(2));else if(e.startsWith("--unset="))r.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return f("env",e);if(e.startsWith("-")&&e!=="-"){for(let l of e.slice(1))if(l!=="i"&&l!=="u")return f("env",`-${l}`);e.includes("i")&&(a=!0)}else if(e.includes("=")&&t===-1){let l=e.indexOf("="),g=e.slice(0,l),x=e.slice(l+1);u.set(g,x)}else{t=n;break}}}let s;if(a)s=new Map(u);else{s=new Map(i.env);for(let n of r)s.delete(n);for(let[n,e]of u)s.set(n,e)}if(t===-1){let n=[];for(let[e,l]of s)n.push(`${e}=${l}`);return{stdout:n.join(`
|
|
3
|
-
`)+(n.length>0?`
|
|
4
|
-
`:""),stderr:"",exitCode:0}}if(!i.exec)return{stdout:"",stderr:`env: command execution not supported in this context
|
|
5
|
-
`,exitCode:1};let p=o.slice(t),h=v(["command",...p]);return i.exec(h,{cwd:i.cwd,env:d(s),replaceEnv:!0,stdin:i.stdin,signal:i.signal})}},A={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},C={name:"printenv",async execute(o,i){if(m(o))return c(A);let a=o.filter(t=>!t.startsWith("-"));if(a.length===0){let t=[];for(let[s,p]of i.env)t.push(`${s}=${p}`);return{stdout:t.join(`
|
|
6
|
-
`)+(t.length>0?`
|
|
7
|
-
`:""),stderr:"",exitCode:0}}let r=[],u=0;for(let t of a){let s=i.env.get(t);s!==void 0?r.push(s):u=1}return{stdout:r.join(`
|
|
8
|
-
`)+(r.length>0?`
|
|
9
|
-
`:""),stderr:"",exitCode:u}}},O={name:"env",flags:[{flag:"-i",type:"boolean"},{flag:"-u",type:"value",valueHint:"string"}]},F={name:"printenv",flags:[]};export{N as a,C as b,O as c,F as d};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as g}from"./chunk-4OALHZXB.js";import{c as u}from"./chunk-QZNF3Y3J.js";import{a as h}from"./chunk-4PRVMER6.js";import{a as f}from"./chunk-SYG3IW7P.js";var v={name:"time",async execute(r,s){let a="%e %M",o=null,c=!1,p=!1,t=0;for(;t<r.length;){let e=r[t];if(e==="-f"||e==="--format"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-f'
|
|
3
|
-
`,exitCode:1};a=r[t],t++}else if(e==="-o"||e==="--output"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-o'
|
|
4
|
-
`,exitCode:1};o=r[t],t++}else if(e==="-a"||e==="--append")c=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
|
|
5
|
-
Elapsed (wall clock) time: %e seconds
|
|
6
|
-
Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")p=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let d=r.slice(t);if(d.length===0)return{stdout:"",stderr:"",exitCode:0};let w=u(),C=g(d),F=d.join(" "),i;try{if(!s.exec)return{stdout:"",stderr:`time: exec not available
|
|
7
|
-
`,exitCode:1};i=await s.exec(C,{env:h(s.env),cwd:s.cwd,stdin:s.stdin,signal:s.signal})}catch(e){i={stdout:"",stderr:`time: ${f(e.message)}
|
|
8
|
-
`,exitCode:127}}let m=(u()-w)/1e3,n;if(p?n=`real ${m.toFixed(2)}
|
|
9
|
-
user 0.00
|
|
10
|
-
sys 0.00
|
|
11
|
-
`:(n=a.replace(/%e/g,m.toFixed(2)).replace(/%E/g,x(m)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,F),n.endsWith(`
|
|
12
|
-
`)||(n+=`
|
|
13
|
-
`)),o)try{let e=s.fs.resolvePath(s.cwd,o);if(c&&await s.fs.exists(e)){let l=await s.fs.readFile(e);await s.fs.writeFile(e,l+n)}else await s.fs.writeFile(e,n)}catch(e){let l=f(e.message);return{stdout:i.stdout,stderr:i.stderr+`time: cannot write to '${o}': ${l}
|
|
14
|
-
`,exitCode:i.exitCode}}else i={...i,stderr:i.stderr+n};return i}};function x(r){let s=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return s>0?`${s}:${a.toString().padStart(2,"0")}:${o.toFixed(2).padStart(5,"0")}`:`${a}:${o.toFixed(2).padStart(5,"0")}`}var T={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{v as a,T as b};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import"./chunk-D64U2VGQ.js";import{a as M,b as c}from"./chunk-QZNF3Y3J.js";import{a as P,b as U}from"./chunk-OOJCYVYF.js";import{a as N}from"./chunk-4PRVMER6.js";import{c as y}from"./chunk-MO4RPBN2.js";import{b as I}from"./chunk-YU6OGPZR.js";import{a as l}from"./chunk-SYG3IW7P.js";import{a as L,b as k}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import{randomBytes as H}from"node:crypto";import{fileURLToPath as W}from"node:url";import{Worker as z}from"node:worker_threads";var u={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200},a={PENDING:0,READY:1,SUCCESS:2,ERROR:3},E={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,TIMEOUT:8,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10},i={OP_CODE:0,STATUS:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,PATH_BUFFER:32,DATA_BUFFER:4128},w={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:1048576,TOTAL:1052704},F={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},p={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function V(){return new M(w.TOTAL)}var A=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return c.load(this.int32View,i.OP_CODE/4)}setOpCode(t){c.store(this.int32View,i.OP_CODE/4,t)}getStatus(){return c.load(this.int32View,i.STATUS/4)}setStatus(t){c.store(this.int32View,i.STATUS/4,t)}getPathLength(){return c.load(this.int32View,i.PATH_LENGTH/4)}setPathLength(t){c.store(this.int32View,i.PATH_LENGTH/4,t)}getDataLength(){return c.load(this.int32View,i.DATA_LENGTH/4)}setDataLength(t){c.store(this.int32View,i.DATA_LENGTH/4,t)}getResultLength(){return c.load(this.int32View,i.RESULT_LENGTH/4)}setResultLength(t){c.store(this.int32View,i.RESULT_LENGTH/4,t)}getErrorCode(){return c.load(this.int32View,i.ERROR_CODE/4)}setErrorCode(t){c.store(this.int32View,i.ERROR_CODE/4,t)}getFlags(){return c.load(this.int32View,i.FLAGS/4)}setFlags(t){c.store(this.int32View,i.FLAGS/4,t)}getMode(){return c.load(this.int32View,i.MODE/4)}setMode(t){c.store(this.int32View,i.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(i.PATH_BUFFER,i.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>w.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${w.PATH_BUFFER}`);this.uint8View.set(e,i.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setData(t){if(t.length>w.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${w.DATA_BUFFER}`);this.uint8View.set(t,i.DATA_BUFFER),this.setDataLength(t.length)}getDataAsString(){let t=this.getData();return new TextDecoder().decode(t)}setDataFromString(t){let e=new TextEncoder().encode(t);this.setData(e)}getResult(){let t=this.getResultLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setResult(t){if(t.length>w.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${w.DATA_BUFFER}`);this.uint8View.set(t,i.DATA_BUFFER),this.setResultLength(t.length)}getResultAsString(){let t=this.getResult();return new TextDecoder().decode(t)}setResultFromString(t){let e=new TextEncoder().encode(t);this.setResult(e)}encodeStat(t){this.uint8View[i.DATA_BUFFER+p.IS_FILE]=t.isFile?1:0,this.uint8View[i.DATA_BUFFER+p.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[i.DATA_BUFFER+p.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(i.DATA_BUFFER+p.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(i.DATA_BUFFER+p.SIZE,e,!0),this.dataView.setFloat64(i.DATA_BUFFER+p.MTIME,t.mtime.getTime(),!0),this.setResultLength(p.TOTAL)}decodeStat(){return{isFile:this.uint8View[i.DATA_BUFFER+p.IS_FILE]===1,isDirectory:this.uint8View[i.DATA_BUFFER+p.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[i.DATA_BUFFER+p.IS_SYMLINK]===1,mode:this.dataView.getInt32(i.DATA_BUFFER+p.MODE,!0),size:this.dataView.getFloat64(i.DATA_BUFFER+p.SIZE,!0),mtime:new Date(this.dataView.getFloat64(i.DATA_BUFFER+p.MTIME,!0))}}waitForReady(t){return c.wait(this.int32View,i.STATUS/4,a.PENDING,t)}waitForReadyAsync(t){return c.waitAsync(this.int32View,i.STATUS/4,a.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let s=this.getStatus();if(s===a.READY)return!0;let r=Date.now()-e;if(r>=t)return!1;let n=t-r,m=c.waitAsync(this.int32View,i.STATUS/4,s,n);if(m.async&&await m.value==="timed-out")return!1}}waitForResult(t){return c.wait(this.int32View,i.STATUS/4,a.READY,t)}notify(){return c.notify(this.int32View,i.STATUS/4)}reset(){this.setOpCode(u.NOOP),this.setStatus(a.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(E.NONE),this.setFlags(F.NONE),this.setMode(0)}};var x=class{fs;cwd;secureFetch;maxOutputSize;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;constructor(t,e,s,r=void 0,n=0){this.fs=e,this.cwd=s,this.secureFetch=r,this.maxOutputSize=n,this.protocol=new A(t)}async run(t){this.running=!0;let e=Date.now();for(;this.running;){let s=Date.now()-e;if(s>=t){this.output.stderr+=`
|
|
3
|
-
python3: execution timeout exceeded
|
|
4
|
-
`,this.output.exitCode=124;break}let r=t-s;if(!await this.protocol.waitUntilReady(r)){this.output.stderr+=`
|
|
5
|
-
python3: execution timeout exceeded
|
|
6
|
-
`,this.output.exitCode=124;break}let m=this.protocol.getOpCode();await this.handleOperation(m),this.protocol.notify()}return this.output}stop(){this.running=!1}async handleOperation(t){try{switch(t){case u.READ_FILE:await this.handleReadFile();break;case u.WRITE_FILE:await this.handleWriteFile();break;case u.STAT:await this.handleStat();break;case u.LSTAT:await this.handleLstat();break;case u.READDIR:await this.handleReaddir();break;case u.MKDIR:await this.handleMkdir();break;case u.RM:await this.handleRm();break;case u.EXISTS:await this.handleExists();break;case u.APPEND_FILE:await this.handleAppendFile();break;case u.SYMLINK:await this.handleSymlink();break;case u.READLINK:await this.handleReadlink();break;case u.CHMOD:await this.handleChmod();break;case u.REALPATH:await this.handleRealpath();break;case u.WRITE_STDOUT:this.handleWriteStdout();break;case u.WRITE_STDERR:this.handleWriteStderr();break;case u.EXIT:this.handleExit();break;case u.HTTP_REQUEST:await this.handleHttpRequest();break;default:this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setStatus(a.ERROR)}}catch(e){this.setErrorFromException(e)}}resolvePath(t){return this.fs.resolvePath(this.cwd,t)}async handleReadFile(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readFileBuffer(t);this.protocol.setResult(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleWriteFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.writeFile(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleStat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.stat(t);this.protocol.encodeStat(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleLstat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.lstat(t);this.protocol.encodeStat(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleReaddir(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readdir(t);this.protocol.setResultFromString(JSON.stringify(e)),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleMkdir(){let t=this.resolvePath(this.protocol.getPath()),s=(this.protocol.getFlags()&F.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:s}),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=(e&F.RECURSIVE)!==0,r=(e&F.FORCE)!==0;try{await this.fs.rm(t,{recursive:s,force:r}),this.protocol.setStatus(a.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleExists(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.exists(t);this.protocol.setResult(new Uint8Array([e?1:0])),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleAppendFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.appendFile(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleSymlink(){let t=this.protocol.getPath(),e=this.protocol.getDataAsString(),s=this.resolvePath(t);try{await this.fs.symlink(e,s),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleReadlink(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readlink(t);this.protocol.setResultFromString(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleChmod(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getMode();try{await this.fs.chmod(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRealpath(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.realpath(t);this.protocol.setResultFromString(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}handleWriteStdout(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(a.ERROR);return}this.protocol.setStatus(a.SUCCESS)}handleWriteStderr(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stderr",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(a.ERROR);return}this.protocol.setStatus(a.SUCCESS)}handleExit(){let t=this.protocol.getFlags();this.outputLimitExceeded?this.output.exitCode===0&&(this.output.exitCode=1):this.output.exitCode=t,this.protocol.setStatus(a.SUCCESS),this.running=!1}tryAppendOutput(t,e){return this.outputLimitExceeded?!1:this.maxOutputSize<=0?(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0):this.output.stdout.length+this.output.stderr.length+e.length>this.maxOutputSize?!1:(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0)}appendOutputLimitError(){if(this.maxOutputSize<=0)return;let t=`python3: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
|
|
7
|
-
`,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let r=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(r>0)if(this.output.stdout.length>=r)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-r);else{let n=r-this.output.stdout.length;this.output.stdout="",n>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-n)}this.output.stderr+=e}async handleHttpRequest(){if(!this.secureFetch){this.protocol.setErrorCode(E.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(a.ERROR);return}let t=this.protocol.getPath(),e=this.protocol.getDataAsString();try{let s=e?JSON.parse(e):{},r=await this.secureFetch(t,{method:s.method,headers:s.headers,body:s.body}),n=JSON.stringify({status:r.status,statusText:r.statusText,headers:r.headers,body:r.body,url:r.url});this.protocol.setResultFromString(n),this.protocol.setStatus(a.SUCCESS)}catch(s){let r=l(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(E.NETWORK_ERROR),this.protocol.setResultFromString(r),this.protocol.setStatus(a.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),s=l(e),r=E.IO_ERROR,n=e.toLowerCase();n.includes("no such file")||n.includes("not found")||n.includes("enoent")?r=E.NOT_FOUND:n.includes("is a directory")||n.includes("eisdir")?r=E.IS_DIRECTORY:n.includes("not a directory")||n.includes("enotdir")?r=E.NOT_DIRECTORY:n.includes("already exists")||n.includes("eexist")?r=E.EXISTS:(n.includes("permission")||n.includes("eperm")||n.includes("eacces"))&&(r=E.PERMISSION_DENIED),this.protocol.setErrorCode(r),this.protocol.setResultFromString(s),this.protocol.setStatus(a.ERROR)}};var G=3e4,$={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};function Y(o){let t={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(o.length===0)return t;let e=o.findIndex(s=>!s.startsWith("-")||s==="-"||s==="--");for(let s=0;s<(e===-1?o.length:e);s++){let r=o[s];if(r==="-c")return s+1>=o.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
|
|
8
|
-
`,exitCode:2}:(t.code=o[s+1],t.scriptArgs=o.slice(s+2),t);if(r==="-m")return s+1>=o.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
|
|
9
|
-
`,exitCode:2}:(t.module=o[s+1],t.scriptArgs=o.slice(s+2),t);if(r==="--version"||r==="-V")return t.showVersion=!0,t;if(r.startsWith("-")&&r!=="-")return{stdout:"",stderr:`python3: unrecognized option '${r}'
|
|
10
|
-
`,exitCode:2}}if(e!==-1){let s=o[e];s==="--"?e+1<o.length&&(t.scriptFile=o[e+1],t.scriptArgs=o.slice(e+2)):(t.scriptFile=s,t.scriptArgs=o.slice(e+1))}return t}var _=new WeakMap;function K(o){let t=_.get(o);return t||(t={executionQueue:[],isExecuting:!1},_.set(o,t)),t}function Rt(){_=new WeakMap}var Q=W(new URL("./worker.js",import.meta.url));function X(){return H(16).toString("hex")}function Z(o,t){if(!o||typeof o!="object")return{success:!1,error:"Malformed worker response"};let e=o;return typeof e.protocolToken!="string"||e.protocolToken!==t?{success:!1,error:"Malformed worker response: invalid protocol token"}:e.type==="security-violation"?{success:!1,error:`Security violation: ${typeof e.violation?.type=="string"?e.violation.type:"unknown"}`}:typeof e.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:e.success?{success:!0}:{success:!1,error:typeof e.error=="string"&&e.error.length>0?e.error:"Worker execution failed"}}function f(o){if(o.isExecuting||o.executionQueue.length===0)return;for(;o.executionQueue.length>0&&o.executionQueue[0].canceled;)o.executionQueue.shift();if(o.executionQueue.length===0)return;let t=o.executionQueue.shift();if(!t)return;o.isExecuting=!0;let e;try{e=I.runTrusted(()=>new z(Q,{workerData:t.input}))}catch(h){let d=h instanceof Error?h.message:String(h);t.resolve({success:!1,error:l(d)}),o.isExecuting=!1,f(o);return}t.workerRef&&(t.workerRef.current=e);let s=y(t.requireDefenseContext,"python3","worker message callback",h=>{t.resolve(Z(h,t.input.protocolToken)),o.isExecuting=!1,e.terminate(),f(o)}),r=y(t.requireDefenseContext,"python3","worker error callback",h=>{t.resolve({success:!1,error:l(h.message)}),o.isExecuting=!1,f(o)}),n=y(t.requireDefenseContext,"python3","worker exit callback",()=>{o.isExecuting&&(t.resolve({success:!1,error:"Worker exited unexpectedly"}),o.isExecuting=!1,f(o))}),m=h=>{try{s(h)}catch(d){let g=d instanceof Error?d.message:String(d);t.resolve({success:!1,error:l(g)}),o.isExecuting=!1,e.terminate(),f(o)}},S=h=>{try{r(h)}catch(d){let g=d instanceof Error?d.message:String(d);t.resolve({success:!1,error:l(g)}),o.isExecuting=!1,f(o)}},D=()=>{try{n()}catch(h){let d=h instanceof Error?h.message:String(h);t.resolve({success:!1,error:l(d)}),o.isExecuting=!1,f(o)}};e.on("message",m),e.on("error",S),e.on("exit",D)}async function J(o,t,e,s=[]){let r=V(),n=new x(r,t.fs,t.cwd,t.fetch,t.limits?.maxOutputSize??0),m=t.limits?.maxPythonTimeoutMs??G,S=K(t.fs),D={protocolToken:X(),sharedBuffer:r,pythonCode:o,cwd:t.cwd,env:N(t.env),args:s,scriptPath:e},h={current:null},d=new Promise(R=>{let C={input:D,resolve:()=>{},workerRef:h,requireDefenseContext:t.requireDefenseContext},b=y(t.requireDefenseContext,"python3","worker timeout callback",()=>{h.current?h.current.terminate():C.canceled=!0,R({success:!1,error:`Execution timeout: exceeded ${m}ms limit`})}),v=P(()=>{try{b()}catch(T){let B=T instanceof Error?T.message:String(T);R({success:!1,error:l(B)})}},m);C.resolve=T=>{U(v),R(T)},S.executionQueue.push(C),f(S)}),[g,O]=await Promise.all([n.run(m).catch(R=>({stdout:"",stderr:`python3: bridge error: ${l(R.message)}
|
|
11
|
-
`,exitCode:1})),d.catch(R=>({success:!1,error:l(R.message)}))]);if(!O.success&&O.error){let R=l(O.error);return{stdout:g.stdout,stderr:`${g.stderr}python3: ${R}
|
|
12
|
-
`,exitCode:g.exitCode||1}}return g}var j={name:"python3",async execute(o,t){if(k(o))return L($);let e=Y(o);if("exitCode"in e)return e;if(e.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
|
|
13
|
-
`,stderr:"",exitCode:0};let s,r;if(e.code!==null)s=e.code,r="-c";else if(e.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(e.module))return{stdout:"",stderr:`python3: No module named '${e.module.slice(0,200)}'
|
|
14
|
-
`,exitCode:1};s=`import runpy; runpy.run_module('${e.module}', run_name='__main__')`,r=e.module}else if(e.scriptFile!==null){let n=t.fs.resolvePath(t.cwd,e.scriptFile);if(!await t.fs.exists(n))return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': [Errno 2] No such file or directory
|
|
15
|
-
`,exitCode:2};try{s=await t.fs.readFile(n),r=e.scriptFile}catch(m){let S=l(m.message);return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': ${S}
|
|
16
|
-
`,exitCode:2}}}else if(t.stdin.trim())s=t.stdin,r="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
|
|
17
|
-
`,exitCode:2};return J(s,t,r,e.scriptArgs)}},gt={name:"python",async execute(o,t){return j.execute(o,t)}};export{Rt as _resetExecutionQueue,j as python3Command,gt as pythonCommand};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{a as v}from"./chunk-IPJHKYVM.js";import{a as d}from"./chunk-OJDRYQWQ.js";import{a as c,b as m,c as f}from"./chunk-74CEPOFO.js";var y={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},N={name:"env",async execute(o,i){if(m(o))return c(y);let a=!1,r=[],u=new Map,t=-1;for(let n=0;n<o.length;n++){let e=o[n];if(e==="-i"||e==="--ignore-environment")a=!0;else if(e==="-u"&&n+1<o.length)r.push(o[++n]);else if(e.startsWith("-u"))r.push(e.slice(2));else if(e.startsWith("--unset="))r.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return f("env",e);if(e.startsWith("-")&&e!=="-"){for(let l of e.slice(1))if(l!=="i"&&l!=="u")return f("env",`-${l}`);e.includes("i")&&(a=!0)}else if(e.includes("=")&&t===-1){let l=e.indexOf("="),g=e.slice(0,l),x=e.slice(l+1);u.set(g,x)}else{t=n;break}}}let s;if(a)s=new Map(u);else{s=new Map(i.env);for(let n of r)s.delete(n);for(let[n,e]of u)s.set(n,e)}if(t===-1){let n=[];for(let[e,l]of s)n.push(`${e}=${l}`);return{stdout:n.join(`
|
|
2
|
-
`)+(n.length>0?`
|
|
3
|
-
`:""),stderr:"",exitCode:0}}if(!i.exec)return{stdout:"",stderr:`env: command execution not supported in this context
|
|
4
|
-
`,exitCode:1};let p=o.slice(t),h=v(["command",...p]);return i.exec(h,{cwd:i.cwd,env:d(s),replaceEnv:!0,stdin:i.stdin,signal:i.signal})}},A={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},C={name:"printenv",async execute(o,i){if(m(o))return c(A);let a=o.filter(t=>!t.startsWith("-"));if(a.length===0){let t=[];for(let[s,p]of i.env)t.push(`${s}=${p}`);return{stdout:t.join(`
|
|
5
|
-
`)+(t.length>0?`
|
|
6
|
-
`:""),stderr:"",exitCode:0}}let r=[],u=0;for(let t of a){let s=i.env.get(t);s!==void 0?r.push(s):u=1}return{stdout:r.join(`
|
|
7
|
-
`)+(r.length>0?`
|
|
8
|
-
`:""),stderr:"",exitCode:u}}},O={name:"env",flags:[{flag:"-i",type:"boolean"},{flag:"-u",type:"value",valueHint:"string"}]},F={name:"printenv",flags:[]};export{N as a,C as b,O as c,F as d};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{c as u}from"./chunk-RH6GWZAJ.js";import{a as g}from"./chunk-IPJHKYVM.js";import{a as h}from"./chunk-OJDRYQWQ.js";import{a as f}from"./chunk-CCNMISUL.js";var v={name:"time",async execute(r,s){let a="%e %M",o=null,c=!1,p=!1,t=0;for(;t<r.length;){let e=r[t];if(e==="-f"||e==="--format"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-f'
|
|
2
|
-
`,exitCode:1};a=r[t],t++}else if(e==="-o"||e==="--output"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-o'
|
|
3
|
-
`,exitCode:1};o=r[t],t++}else if(e==="-a"||e==="--append")c=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
|
|
4
|
-
Elapsed (wall clock) time: %e seconds
|
|
5
|
-
Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")p=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let d=r.slice(t);if(d.length===0)return{stdout:"",stderr:"",exitCode:0};let w=u(),C=g(d),F=d.join(" "),i;try{if(!s.exec)return{stdout:"",stderr:`time: exec not available
|
|
6
|
-
`,exitCode:1};i=await s.exec(C,{env:h(s.env),cwd:s.cwd,stdin:s.stdin,signal:s.signal})}catch(e){i={stdout:"",stderr:`time: ${f(e.message)}
|
|
7
|
-
`,exitCode:127}}let m=(u()-w)/1e3,n;if(p?n=`real ${m.toFixed(2)}
|
|
8
|
-
user 0.00
|
|
9
|
-
sys 0.00
|
|
10
|
-
`:(n=a.replace(/%e/g,m.toFixed(2)).replace(/%E/g,x(m)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,F),n.endsWith(`
|
|
11
|
-
`)||(n+=`
|
|
12
|
-
`)),o)try{let e=s.fs.resolvePath(s.cwd,o);if(c&&await s.fs.exists(e)){let l=await s.fs.readFile(e);await s.fs.writeFile(e,l+n)}else await s.fs.writeFile(e,n)}catch(e){let l=f(e.message);return{stdout:i.stdout,stderr:i.stderr+`time: cannot write to '${o}': ${l}
|
|
13
|
-
`,exitCode:i.exitCode}}else i={...i,stderr:i.stderr+n};return i}};function x(r){let s=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return s>0?`${s}:${a.toString().padStart(2,"0")}:${o.toFixed(2).padStart(5,"0")}`:`${a}:${o.toFixed(2).padStart(5,"0")}`}var T={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{v as a,T as b};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{a as x}from"./chunk-3ZUFRYJ4.js";import{a as c,b as p}from"./chunk-A5O5YHGN.js";import{a as O}from"./chunk-IPJHKYVM.js";import{a as h,b as A,c as l}from"./chunk-74CEPOFO.js";var y={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
|
|
2
|
-
|
|
3
|
-
DURATION is a number with optional suffix:
|
|
4
|
-
s - seconds (default)
|
|
5
|
-
m - minutes
|
|
6
|
-
h - hours
|
|
7
|
-
d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]},D={name:"timeout",async execute(s,n){if(A(s))return h(y);let i=0;for(let e=0;e<s.length;e++){let t=s[e];if(t==="--preserve-status")i=e+1;else if(t==="--foreground")i=e+1;else if(t==="-k"||t==="--kill-after")e++,i=e+1;else if(t.startsWith("--kill-after="))i=e+1;else if(t==="-s"||t==="--signal")e++,i=e+1;else if(t.startsWith("--signal="))i=e+1;else{if(t.startsWith("--")&&t!=="--")return l("timeout",t);if(t.startsWith("-")&&t.length>1&&t!=="--")if(t.startsWith("-k"))i=e+1;else if(t.startsWith("-s"))i=e+1;else return l("timeout",t);else{i=e;break}}}let r=s.slice(i);if(r.length===0)return{stdout:"",stderr:`timeout: missing operand
|
|
8
|
-
`,exitCode:1};let u=r[0],m=x(u);if(m===null)return{stdout:"",stderr:`timeout: invalid time interval '${u}'
|
|
9
|
-
`,exitCode:1};let d=r.slice(1);if(d.length===0)return{stdout:"",stderr:`timeout: missing operand
|
|
10
|
-
`,exitCode:1};if(!n.exec)return{stdout:"",stderr:`timeout: exec not available
|
|
11
|
-
`,exitCode:1};let v=O(d),f=new AbortController,o;try{let e=new Promise(a=>{o=c(()=>{f.abort(),a({timedOut:!0})},m)}),t=n.exec(v,{cwd:n.cwd,signal:f.signal,stdin:n.stdin}).then(a=>({timedOut:!1,result:a})),g=await Promise.race([e,t]);return g.timedOut?{stdout:"",stderr:"",exitCode:124}:g.result}finally{o!==void 0&&p(o)}}},I={name:"timeout",flags:[{flag:"-k",type:"value",valueHint:"string"},{flag:"-s",type:"value",valueHint:"string"},{flag:"--preserve-status",type:"boolean"},{flag:"--foreground",type:"boolean"}],needsArgs:!0,minArgs:2};export{D as a,I as b};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as A,b as I,c as b}from"./chunk-74CEPOFO.js";var $={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},N={name:"xargs",async execute(l,i){if(I(l))return A($);let m=null,g=null,c=null,o=null,h=!1,x=!1,y=!1,s=0;for(let e=0;e<l.length;e++){let t=l[e];if(t==="-I"&&e+1<l.length)m=l[++e],s=e+1;else if(t==="-d"&&e+1<l.length)g=l[++e].replace(/\\n/g,`
|
|
2
|
-
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),s=e+1;else if(t==="-n"&&e+1<l.length)c=parseInt(l[++e],10),s=e+1;else if(t==="-P"&&e+1<l.length)o=parseInt(l[++e],10),s=e+1;else if(t==="-0"||t==="--null")h=!0,s=e+1;else if(t==="-t"||t==="--verbose")x=!0,s=e+1;else if(t==="-r"||t==="--no-run-if-empty")y=!0,s=e+1;else{if(t.startsWith("--"))return b("xargs",t);if(t.startsWith("-")&&t.length>1){for(let n of t.slice(1))if(!"0tr".includes(n))return b("xargs",`-${n}`);t.includes("0")&&(h=!0),t.includes("t")&&(x=!0),t.includes("r")&&(y=!0),s=e+1}else if(!t.startsWith("-")){s=e;break}}}let a=l.slice(s);a.length===0&&a.push("echo");let r;if(h?r=i.stdin.split("\0").filter(e=>e.length>0):g!==null?r=i.stdin.replace(/\n$/,"").split(g).filter(t=>t.length>0):r=i.stdin.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),r.length===0)return y?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",u="",f=0,v=e=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(e)?`"${e.replace(/([\\"`$])/g,"\\$1")}"`:e,C=async e=>{let t=e.map(v).join(" ");return x&&(u+=`${t}
|
|
3
|
-
`),i.exec?i.exec(t,{cwd:i.cwd,signal:i.signal}):{stdout:`${t}
|
|
4
|
-
`,stderr:"",exitCode:0}},w=async e=>{if(o!==null&&o>1)for(let t=0;t<e.length;t+=o){let n=e.slice(t,t+o),M=await Promise.all(n.map(C));for(let p of M)d+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}else for(let t of e){let n=await C(t);d+=n.stdout,u+=n.stderr,n.exitCode!==0&&(f=n.exitCode)}};if(m!==null){let e=r.map(t=>a.map(n=>n.replaceAll(m,t)));await w(e)}else if(c!==null){let e=[];for(let t=0;t<r.length;t+=c){let n=r.slice(t,t+c);e.push([...a,...n])}await w(e)}else{let e=[...a,...r],t=await C(e);d+=t.stdout,u+=t.stderr,f=t.exitCode}return{stdout:d,stderr:u,exitCode:f}}},P={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"};export{N as a,P as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-3RA5L262.js";import"./chunk-IPJHKYVM.js";import"./chunk-OJDRYQWQ.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as envCommand,c as flagsForFuzzing,b as printenvCommand,d as printenvFlagsForFuzzing};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import"./chunk-XHM67O4N.js";import{a as M,b as c}from"./chunk-RH6GWZAJ.js";import{a as P,b as U}from"./chunk-A5O5YHGN.js";import{a as N}from"./chunk-OJDRYQWQ.js";import{c as y}from"./chunk-24IMIIXA.js";import{b as I}from"./chunk-5QMZ5MUS.js";import{a as l}from"./chunk-CCNMISUL.js";import{a as L,b as k}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import{randomBytes as H}from"node:crypto";import{fileURLToPath as W}from"node:url";import{Worker as z}from"node:worker_threads";var u={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200},a={PENDING:0,READY:1,SUCCESS:2,ERROR:3},E={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,TIMEOUT:8,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10},i={OP_CODE:0,STATUS:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,PATH_BUFFER:32,DATA_BUFFER:4128},w={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:1048576,TOTAL:1052704},F={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},p={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function V(){return new M(w.TOTAL)}var A=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return c.load(this.int32View,i.OP_CODE/4)}setOpCode(t){c.store(this.int32View,i.OP_CODE/4,t)}getStatus(){return c.load(this.int32View,i.STATUS/4)}setStatus(t){c.store(this.int32View,i.STATUS/4,t)}getPathLength(){return c.load(this.int32View,i.PATH_LENGTH/4)}setPathLength(t){c.store(this.int32View,i.PATH_LENGTH/4,t)}getDataLength(){return c.load(this.int32View,i.DATA_LENGTH/4)}setDataLength(t){c.store(this.int32View,i.DATA_LENGTH/4,t)}getResultLength(){return c.load(this.int32View,i.RESULT_LENGTH/4)}setResultLength(t){c.store(this.int32View,i.RESULT_LENGTH/4,t)}getErrorCode(){return c.load(this.int32View,i.ERROR_CODE/4)}setErrorCode(t){c.store(this.int32View,i.ERROR_CODE/4,t)}getFlags(){return c.load(this.int32View,i.FLAGS/4)}setFlags(t){c.store(this.int32View,i.FLAGS/4,t)}getMode(){return c.load(this.int32View,i.MODE/4)}setMode(t){c.store(this.int32View,i.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(i.PATH_BUFFER,i.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>w.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${w.PATH_BUFFER}`);this.uint8View.set(e,i.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setData(t){if(t.length>w.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${w.DATA_BUFFER}`);this.uint8View.set(t,i.DATA_BUFFER),this.setDataLength(t.length)}getDataAsString(){let t=this.getData();return new TextDecoder().decode(t)}setDataFromString(t){let e=new TextEncoder().encode(t);this.setData(e)}getResult(){let t=this.getResultLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setResult(t){if(t.length>w.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${w.DATA_BUFFER}`);this.uint8View.set(t,i.DATA_BUFFER),this.setResultLength(t.length)}getResultAsString(){let t=this.getResult();return new TextDecoder().decode(t)}setResultFromString(t){let e=new TextEncoder().encode(t);this.setResult(e)}encodeStat(t){this.uint8View[i.DATA_BUFFER+p.IS_FILE]=t.isFile?1:0,this.uint8View[i.DATA_BUFFER+p.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[i.DATA_BUFFER+p.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(i.DATA_BUFFER+p.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(i.DATA_BUFFER+p.SIZE,e,!0),this.dataView.setFloat64(i.DATA_BUFFER+p.MTIME,t.mtime.getTime(),!0),this.setResultLength(p.TOTAL)}decodeStat(){return{isFile:this.uint8View[i.DATA_BUFFER+p.IS_FILE]===1,isDirectory:this.uint8View[i.DATA_BUFFER+p.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[i.DATA_BUFFER+p.IS_SYMLINK]===1,mode:this.dataView.getInt32(i.DATA_BUFFER+p.MODE,!0),size:this.dataView.getFloat64(i.DATA_BUFFER+p.SIZE,!0),mtime:new Date(this.dataView.getFloat64(i.DATA_BUFFER+p.MTIME,!0))}}waitForReady(t){return c.wait(this.int32View,i.STATUS/4,a.PENDING,t)}waitForReadyAsync(t){return c.waitAsync(this.int32View,i.STATUS/4,a.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let s=this.getStatus();if(s===a.READY)return!0;let r=Date.now()-e;if(r>=t)return!1;let n=t-r,m=c.waitAsync(this.int32View,i.STATUS/4,s,n);if(m.async&&await m.value==="timed-out")return!1}}waitForResult(t){return c.wait(this.int32View,i.STATUS/4,a.READY,t)}notify(){return c.notify(this.int32View,i.STATUS/4)}reset(){this.setOpCode(u.NOOP),this.setStatus(a.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(E.NONE),this.setFlags(F.NONE),this.setMode(0)}};var x=class{fs;cwd;secureFetch;maxOutputSize;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;constructor(t,e,s,r=void 0,n=0){this.fs=e,this.cwd=s,this.secureFetch=r,this.maxOutputSize=n,this.protocol=new A(t)}async run(t){this.running=!0;let e=Date.now();for(;this.running;){let s=Date.now()-e;if(s>=t){this.output.stderr+=`
|
|
2
|
-
python3: execution timeout exceeded
|
|
3
|
-
`,this.output.exitCode=124;break}let r=t-s;if(!await this.protocol.waitUntilReady(r)){this.output.stderr+=`
|
|
4
|
-
python3: execution timeout exceeded
|
|
5
|
-
`,this.output.exitCode=124;break}let m=this.protocol.getOpCode();await this.handleOperation(m),this.protocol.notify()}return this.output}stop(){this.running=!1}async handleOperation(t){try{switch(t){case u.READ_FILE:await this.handleReadFile();break;case u.WRITE_FILE:await this.handleWriteFile();break;case u.STAT:await this.handleStat();break;case u.LSTAT:await this.handleLstat();break;case u.READDIR:await this.handleReaddir();break;case u.MKDIR:await this.handleMkdir();break;case u.RM:await this.handleRm();break;case u.EXISTS:await this.handleExists();break;case u.APPEND_FILE:await this.handleAppendFile();break;case u.SYMLINK:await this.handleSymlink();break;case u.READLINK:await this.handleReadlink();break;case u.CHMOD:await this.handleChmod();break;case u.REALPATH:await this.handleRealpath();break;case u.WRITE_STDOUT:this.handleWriteStdout();break;case u.WRITE_STDERR:this.handleWriteStderr();break;case u.EXIT:this.handleExit();break;case u.HTTP_REQUEST:await this.handleHttpRequest();break;default:this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setStatus(a.ERROR)}}catch(e){this.setErrorFromException(e)}}resolvePath(t){return this.fs.resolvePath(this.cwd,t)}async handleReadFile(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readFileBuffer(t);this.protocol.setResult(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleWriteFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.writeFile(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleStat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.stat(t);this.protocol.encodeStat(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleLstat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.lstat(t);this.protocol.encodeStat(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleReaddir(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readdir(t);this.protocol.setResultFromString(JSON.stringify(e)),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleMkdir(){let t=this.resolvePath(this.protocol.getPath()),s=(this.protocol.getFlags()&F.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:s}),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=(e&F.RECURSIVE)!==0,r=(e&F.FORCE)!==0;try{await this.fs.rm(t,{recursive:s,force:r}),this.protocol.setStatus(a.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleExists(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.exists(t);this.protocol.setResult(new Uint8Array([e?1:0])),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleAppendFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.appendFile(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleSymlink(){let t=this.protocol.getPath(),e=this.protocol.getDataAsString(),s=this.resolvePath(t);try{await this.fs.symlink(e,s),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleReadlink(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readlink(t);this.protocol.setResultFromString(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleChmod(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getMode();try{await this.fs.chmod(t,e),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRealpath(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.realpath(t);this.protocol.setResultFromString(e),this.protocol.setStatus(a.SUCCESS)}catch(e){this.setErrorFromException(e)}}handleWriteStdout(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(a.ERROR);return}this.protocol.setStatus(a.SUCCESS)}handleWriteStderr(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stderr",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(E.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(a.ERROR);return}this.protocol.setStatus(a.SUCCESS)}handleExit(){let t=this.protocol.getFlags();this.outputLimitExceeded?this.output.exitCode===0&&(this.output.exitCode=1):this.output.exitCode=t,this.protocol.setStatus(a.SUCCESS),this.running=!1}tryAppendOutput(t,e){return this.outputLimitExceeded?!1:this.maxOutputSize<=0?(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0):this.output.stdout.length+this.output.stderr.length+e.length>this.maxOutputSize?!1:(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0)}appendOutputLimitError(){if(this.maxOutputSize<=0)return;let t=`python3: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
|
|
6
|
-
`,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let r=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(r>0)if(this.output.stdout.length>=r)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-r);else{let n=r-this.output.stdout.length;this.output.stdout="",n>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-n)}this.output.stderr+=e}async handleHttpRequest(){if(!this.secureFetch){this.protocol.setErrorCode(E.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(a.ERROR);return}let t=this.protocol.getPath(),e=this.protocol.getDataAsString();try{let s=e?JSON.parse(e):{},r=await this.secureFetch(t,{method:s.method,headers:s.headers,body:s.body}),n=JSON.stringify({status:r.status,statusText:r.statusText,headers:r.headers,body:r.body,url:r.url});this.protocol.setResultFromString(n),this.protocol.setStatus(a.SUCCESS)}catch(s){let r=l(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(E.NETWORK_ERROR),this.protocol.setResultFromString(r),this.protocol.setStatus(a.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),s=l(e),r=E.IO_ERROR,n=e.toLowerCase();n.includes("no such file")||n.includes("not found")||n.includes("enoent")?r=E.NOT_FOUND:n.includes("is a directory")||n.includes("eisdir")?r=E.IS_DIRECTORY:n.includes("not a directory")||n.includes("enotdir")?r=E.NOT_DIRECTORY:n.includes("already exists")||n.includes("eexist")?r=E.EXISTS:(n.includes("permission")||n.includes("eperm")||n.includes("eacces"))&&(r=E.PERMISSION_DENIED),this.protocol.setErrorCode(r),this.protocol.setResultFromString(s),this.protocol.setStatus(a.ERROR)}};var G=3e4,$={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};function Y(o){let t={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(o.length===0)return t;let e=o.findIndex(s=>!s.startsWith("-")||s==="-"||s==="--");for(let s=0;s<(e===-1?o.length:e);s++){let r=o[s];if(r==="-c")return s+1>=o.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
|
|
7
|
-
`,exitCode:2}:(t.code=o[s+1],t.scriptArgs=o.slice(s+2),t);if(r==="-m")return s+1>=o.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
|
|
8
|
-
`,exitCode:2}:(t.module=o[s+1],t.scriptArgs=o.slice(s+2),t);if(r==="--version"||r==="-V")return t.showVersion=!0,t;if(r.startsWith("-")&&r!=="-")return{stdout:"",stderr:`python3: unrecognized option '${r}'
|
|
9
|
-
`,exitCode:2}}if(e!==-1){let s=o[e];s==="--"?e+1<o.length&&(t.scriptFile=o[e+1],t.scriptArgs=o.slice(e+2)):(t.scriptFile=s,t.scriptArgs=o.slice(e+1))}return t}var _=new WeakMap;function K(o){let t=_.get(o);return t||(t={executionQueue:[],isExecuting:!1},_.set(o,t)),t}function Rt(){_=new WeakMap}var Q=W(new URL("./worker.js",import.meta.url));function X(){return H(16).toString("hex")}function Z(o,t){if(!o||typeof o!="object")return{success:!1,error:"Malformed worker response"};let e=o;return typeof e.protocolToken!="string"||e.protocolToken!==t?{success:!1,error:"Malformed worker response: invalid protocol token"}:e.type==="security-violation"?{success:!1,error:`Security violation: ${typeof e.violation?.type=="string"?e.violation.type:"unknown"}`}:typeof e.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:e.success?{success:!0}:{success:!1,error:typeof e.error=="string"&&e.error.length>0?e.error:"Worker execution failed"}}function f(o){if(o.isExecuting||o.executionQueue.length===0)return;for(;o.executionQueue.length>0&&o.executionQueue[0].canceled;)o.executionQueue.shift();if(o.executionQueue.length===0)return;let t=o.executionQueue.shift();if(!t)return;o.isExecuting=!0;let e;try{e=I.runTrusted(()=>new z(Q,{workerData:t.input}))}catch(h){let d=h instanceof Error?h.message:String(h);t.resolve({success:!1,error:l(d)}),o.isExecuting=!1,f(o);return}t.workerRef&&(t.workerRef.current=e);let s=y(t.requireDefenseContext,"python3","worker message callback",h=>{t.resolve(Z(h,t.input.protocolToken)),o.isExecuting=!1,e.terminate(),f(o)}),r=y(t.requireDefenseContext,"python3","worker error callback",h=>{t.resolve({success:!1,error:l(h.message)}),o.isExecuting=!1,f(o)}),n=y(t.requireDefenseContext,"python3","worker exit callback",()=>{o.isExecuting&&(t.resolve({success:!1,error:"Worker exited unexpectedly"}),o.isExecuting=!1,f(o))}),m=h=>{try{s(h)}catch(d){let g=d instanceof Error?d.message:String(d);t.resolve({success:!1,error:l(g)}),o.isExecuting=!1,e.terminate(),f(o)}},S=h=>{try{r(h)}catch(d){let g=d instanceof Error?d.message:String(d);t.resolve({success:!1,error:l(g)}),o.isExecuting=!1,f(o)}},D=()=>{try{n()}catch(h){let d=h instanceof Error?h.message:String(h);t.resolve({success:!1,error:l(d)}),o.isExecuting=!1,f(o)}};e.on("message",m),e.on("error",S),e.on("exit",D)}async function J(o,t,e,s=[]){let r=V(),n=new x(r,t.fs,t.cwd,t.fetch,t.limits?.maxOutputSize??0),m=t.limits?.maxPythonTimeoutMs??G,S=K(t.fs),D={protocolToken:X(),sharedBuffer:r,pythonCode:o,cwd:t.cwd,env:N(t.env),args:s,scriptPath:e},h={current:null},d=new Promise(R=>{let C={input:D,resolve:()=>{},workerRef:h,requireDefenseContext:t.requireDefenseContext},b=y(t.requireDefenseContext,"python3","worker timeout callback",()=>{h.current?h.current.terminate():C.canceled=!0,R({success:!1,error:`Execution timeout: exceeded ${m}ms limit`})}),v=P(()=>{try{b()}catch(T){let B=T instanceof Error?T.message:String(T);R({success:!1,error:l(B)})}},m);C.resolve=T=>{U(v),R(T)},S.executionQueue.push(C),f(S)}),[g,O]=await Promise.all([n.run(m).catch(R=>({stdout:"",stderr:`python3: bridge error: ${l(R.message)}
|
|
10
|
-
`,exitCode:1})),d.catch(R=>({success:!1,error:l(R.message)}))]);if(!O.success&&O.error){let R=l(O.error);return{stdout:g.stdout,stderr:`${g.stderr}python3: ${R}
|
|
11
|
-
`,exitCode:g.exitCode||1}}return g}var j={name:"python3",async execute(o,t){if(k(o))return L($);let e=Y(o);if("exitCode"in e)return e;if(e.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
|
|
12
|
-
`,stderr:"",exitCode:0};let s,r;if(e.code!==null)s=e.code,r="-c";else if(e.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(e.module))return{stdout:"",stderr:`python3: No module named '${e.module.slice(0,200)}'
|
|
13
|
-
`,exitCode:1};s=`import runpy; runpy.run_module('${e.module}', run_name='__main__')`,r=e.module}else if(e.scriptFile!==null){let n=t.fs.resolvePath(t.cwd,e.scriptFile);if(!await t.fs.exists(n))return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': [Errno 2] No such file or directory
|
|
14
|
-
`,exitCode:2};try{s=await t.fs.readFile(n),r=e.scriptFile}catch(m){let S=l(m.message);return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': ${S}
|
|
15
|
-
`,exitCode:2}}}else if(t.stdin.trim())s=t.stdin,r="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
|
|
16
|
-
`,exitCode:2};return J(s,t,r,e.scriptArgs)}},gt={name:"python",async execute(o,t){return j.execute(o,t)}};export{Rt as _resetExecutionQueue,j as python3Command,gt as pythonCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-OKEHYWBE.js";import"./chunk-VLGZJRPG.js";import"./chunk-IPJHKYVM.js";import"./chunk-YNYSPYQ5.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{b as flagsForFuzzing,a as rgCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-ZSJYNBAF.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{b as flagsForFuzzing,a as xargsCommand};
|