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
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as F,b as M}from"./chunk-N6KA6G3Q.js";import"./chunk-4OALHZXB.js";import"./chunk-D64U2VGQ.js";import"./chunk-QZNF3Y3J.js";import{a as k,b as T}from"./chunk-OOJCYVYF.js";import{a as C}from"./chunk-4PRVMER6.js";import{b}from"./chunk-YU6OGPZR.js";import{a as p}from"./chunk-SYG3IW7P.js";import{b as j}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import{AsyncLocalStorage as L}from"node:async_hooks";import{randomBytes as R}from"node:crypto";import{fileURLToPath as U}from"node:url";import{Worker as I}from"node:worker_threads";var J=1e4,D=6e4,W=new L,A=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
|
|
3
|
+
|
|
4
|
+
Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
|
|
5
|
+
|
|
6
|
+
Options:
|
|
7
|
+
-c CODE Execute inline code
|
|
8
|
+
-m, --module Enable ES module mode (import/export)
|
|
9
|
+
--strip-types Strip TypeScript type annotations
|
|
10
|
+
--version, -V Show version
|
|
11
|
+
--help Show this help
|
|
12
|
+
|
|
13
|
+
Examples:
|
|
14
|
+
js-exec -c "console.log(1 + 2)"
|
|
15
|
+
js-exec script.js
|
|
16
|
+
js-exec app.ts
|
|
17
|
+
echo 'console.log("hello")' | js-exec
|
|
18
|
+
|
|
19
|
+
File Extension Auto-Detection:
|
|
20
|
+
.js script mode (module mode if top-level await detected)
|
|
21
|
+
.mjs ES module mode
|
|
22
|
+
.ts, .mts ES module mode + TypeScript stripping
|
|
23
|
+
|
|
24
|
+
Node.js Compatibility:
|
|
25
|
+
Code written for Node.js largely works here. Both require and import
|
|
26
|
+
are supported, the node: prefix works, and standard globals like process,
|
|
27
|
+
console, and fetch are available. All I/O is synchronous.
|
|
28
|
+
|
|
29
|
+
Available modules:
|
|
30
|
+
fs, path, child_process, process, console,
|
|
31
|
+
os, url, assert, util, events, buffer, stream,
|
|
32
|
+
string_decoder, querystring
|
|
33
|
+
|
|
34
|
+
fs (global, require('fs'), or import from 'node:fs'):
|
|
35
|
+
readFileSync, writeFileSync, appendFileSync, copyFileSync, renameSync
|
|
36
|
+
readdirSync, mkdirSync, rmSync, unlinkSync, rmdirSync
|
|
37
|
+
statSync, lstatSync, existsSync, realpathSync, chmodSync
|
|
38
|
+
symlinkSync, readlinkSync, readFileBuffer
|
|
39
|
+
fs.promises.readFile, fs.promises.writeFile, fs.promises.access, ...
|
|
40
|
+
|
|
41
|
+
path: join, resolve, dirname, basename, extname, normalize,
|
|
42
|
+
relative, isAbsolute, parse, format, sep, delimiter
|
|
43
|
+
|
|
44
|
+
child_process:
|
|
45
|
+
execSync(cmd) throws on non-zero exit, returns stdout
|
|
46
|
+
spawnSync(cmd, args) returns { stdout, stderr, status }
|
|
47
|
+
|
|
48
|
+
process (also global): argv, cwd(), exit(), env, platform, arch,
|
|
49
|
+
version, versions
|
|
50
|
+
|
|
51
|
+
os: platform(), arch(), homedir(), tmpdir(), type(), hostname(),
|
|
52
|
+
EOL, cpus(), endianness()
|
|
53
|
+
|
|
54
|
+
url: URL, URLSearchParams, parse(), format()
|
|
55
|
+
|
|
56
|
+
assert: ok(), equal(), strictEqual(), deepEqual(), throws(),
|
|
57
|
+
doesNotThrow(), fail()
|
|
58
|
+
|
|
59
|
+
util: format(), inspect(), promisify(), types, inherits()
|
|
60
|
+
|
|
61
|
+
events: EventEmitter (on, once, emit, off, removeListener, ...)
|
|
62
|
+
|
|
63
|
+
buffer: Buffer.from(), Buffer.alloc(), Buffer.concat(),
|
|
64
|
+
Buffer.isBuffer(), toString(), slice(), equals()
|
|
65
|
+
|
|
66
|
+
stream: Readable, Writable, Duplex, Transform, PassThrough, pipeline
|
|
67
|
+
|
|
68
|
+
string_decoder: StringDecoder (write, end)
|
|
69
|
+
|
|
70
|
+
querystring: parse(), stringify(), escape(), unescape()
|
|
71
|
+
|
|
72
|
+
Other Globals:
|
|
73
|
+
console log (stdout), error/warn (stderr)
|
|
74
|
+
fetch(url, opts) HTTP; returns Promise<Response> (Web Fetch API)
|
|
75
|
+
URL, URLSearchParams, Headers, Request, Response
|
|
76
|
+
Buffer Buffer.from(), Buffer.alloc(), etc.
|
|
77
|
+
|
|
78
|
+
Not Available:
|
|
79
|
+
http, https, net, tls, crypto, zlib, dns, cluster, worker_threads,
|
|
80
|
+
vm, v8, readline, and other Node.js built-in modules that require
|
|
81
|
+
native bindings. Use fetch() for HTTP requests.
|
|
82
|
+
|
|
83
|
+
Limits:
|
|
84
|
+
Memory: 64 MB per execution
|
|
85
|
+
Timeout: 10 s (60 s with network; configurable via maxJsTimeoutMs)
|
|
86
|
+
Engine: QuickJS (compiled to WebAssembly)
|
|
87
|
+
`;function N(t){let e={code:null,scriptFile:null,showVersion:!1,scriptArgs:[],isModule:!1,stripTypes:!1};if(t.length===0)return e;for(let r=0;r<t.length;r++){let s=t[r];if(s==="-m"||s==="--module"){e.isModule=!0;continue}if(s==="--strip-types"){e.stripTypes=!0;continue}if(s==="-c")return r+1>=t.length?{stdout:"",stderr:`js-exec: option requires an argument -- 'c'
|
|
88
|
+
`,exitCode:2}:(e.code=t[r+1],e.scriptArgs=t.slice(r+2),e);if(s==="--version"||s==="-V")return e.showVersion=!0,e;if(s.startsWith("-")&&s!=="-"&&s!=="--")return{stdout:"",stderr:`js-exec: unrecognized option '${s}'
|
|
89
|
+
`,exitCode:2};if(s==="--")return r+1<t.length&&(e.scriptFile=t[r+1],e.scriptArgs=t.slice(r+2)),e;if(!s.startsWith("-"))return e.scriptFile=s,e.scriptArgs=t.slice(r+1),e}return e}var i=null,w=null,c=[],o=null,H=U(new URL("./worker.js",import.meta.url));function m(){for(;c.length>0&&c[0].canceled;)c.shift();if(o||c.length===0)return;let t=c.shift();if(!t)return;o=t,z().postMessage(o.input)}function $(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let r=t;return typeof r.protocolToken!="string"||r.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:typeof r.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:r.success?{success:!0}:{success:!1,error:typeof r.error=="string"&&r.error.length>0?r.error:"Worker execution failed"}}function z(){if(w&&(T(w),w=null),i)return i;let t=b.runTrusted(()=>new I(H));return i=t,t.on("message",e=>{if(i===t){if(o){let r=$(e,o.input.protocolToken);o.resolve(r),o=null}c.length>0?m():V()}}),t.on("error",e=>{if(i===t){o&&(o.resolve({success:!1,error:p(e.message)}),o=null);for(let r of c)r.resolve({success:!1,error:"Worker crashed"});c.length=0,i=null}}),t.on("exit",()=>{i===t&&(i=null,o&&(o.resolve({success:!1,error:"Worker exited unexpectedly"}),o=null),c.length>0&&m())}),t}function V(){w=k(()=>{i&&!o&&c.length===0&&(i.terminate(),i=null)},5e3)}async function Q(t,e,r,s=[],n,u,a){return W.getStore()?{stdout:"",stderr:`js-exec: recursive invocation is not supported
|
|
90
|
+
`,exitCode:1}:G(t,e,r,s,n,u,a)}async function G(t,e,r,s=[],n,u,a){let h=F(),d=e.exec,S=d?(l,O)=>W.run(!0,()=>d(l,O)):void 0,P=new M(h,e.fs,e.cwd,"js-exec",e.fetch,e.limits?.maxOutputSize??0,S),v=e.limits?.maxJsTimeoutMs??J,y=e.fetch?Math.max(v,D):v,B={protocolToken:R(16).toString("hex"),sharedBuffer:h,jsCode:t,cwd:e.cwd,env:C(e.env),args:s,scriptPath:r,bootstrapCode:n,isModule:u,stripTypes:a,timeoutMs:y},E,_=new Promise(l=>{E=l}),f={input:B,resolve:()=>{}},q=k(()=>{if(o===f){let l=i;l&&(i=null,l.terminate()),o=null,m()}else f.canceled=!0,o||m();f.resolve({success:!1,error:`Execution timeout: exceeded ${y}ms limit`})},y);f.resolve=l=>{T(q),E(l)},c.push(f),m();let[x,g]=await Promise.all([P.run(y),_.catch(l=>({success:!1,error:p(l.message)}))]);return!g.success&&g.error?{stdout:x.stdout,stderr:`${x.stderr}js-exec: ${p(g.error)}
|
|
91
|
+
`,exitCode:x.exitCode||1}:x}var le={name:"js-exec",async execute(t,e){if(j(t))return{stdout:A,stderr:"",exitCode:0};let r=N(t);if("exitCode"in r)return r;if(r.showVersion)return{stdout:`QuickJS (quickjs-emscripten)
|
|
92
|
+
`,stderr:"",exitCode:0};let s,n;if(r.code!==null)s=r.code,n="-c";else if(r.scriptFile!==null){let d=e.fs.resolvePath(e.cwd,r.scriptFile);if(!await e.fs.exists(d))return{stdout:"",stderr:`js-exec: can't open file '${r.scriptFile}': No such file or directory
|
|
93
|
+
`,exitCode:2};try{s=await e.fs.readFile(d),n=d}catch(S){return{stdout:"",stderr:`js-exec: can't open file '${r.scriptFile}': ${p(S.message)}
|
|
94
|
+
`,exitCode:2}}}else if(e.stdin.trim())s=e.stdin,n="<stdin>";else return{stdout:"",stderr:`js-exec: no input provided (use -c CODE or provide a script file)
|
|
95
|
+
`,exitCode:2};let u=r.isModule,a=r.stripTypes;n&&n!=="-c"&&n!=="<stdin>"&&((n.endsWith(".mjs")||n.endsWith(".mts")||n.endsWith(".ts"))&&(u=!0),(n.endsWith(".ts")||n.endsWith(".mts"))&&(a=!0)),!u&&/\bawait\s+[\w([`]/.test(s)&&(u=!0);let h=e.jsBootstrapCode;return Q(s,e,n,r.scriptArgs,h,u,a)}},ue={name:"node",async execute(){return{stdout:"",stderr:`node: this sandbox uses js-exec instead of node
|
|
96
|
+
|
|
97
|
+
${A}`,exitCode:1}}};export{le as jsExecCommand,ue as nodeStubCommand};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as M,b as D}from"./chunk-N6KA6G3Q.js";import"./chunk-4OALHZXB.js";import"./chunk-D64U2VGQ.js";import"./chunk-QZNF3Y3J.js";import{a as C,b as v}from"./chunk-OOJCYVYF.js";import{a as b}from"./chunk-4PRVMER6.js";import{c as h}from"./chunk-MO4RPBN2.js";import{b as k}from"./chunk-YU6OGPZR.js";import{a as c}from"./chunk-SYG3IW7P.js";import{a as T,b as P}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import{randomBytes as F}from"node:crypto";import{fileURLToPath as W}from"node:url";import{Worker as $}from"node:worker_threads";var Q=1e4,R=6e4,U={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 I(r){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(r.length===0)return e;let t=r.findIndex(o=>!o.startsWith("-")||o==="-"||o==="--");for(let o=0;o<(t===-1?r.length:t);o++){let s=r[o];if(s==="-c")return o+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
|
|
3
|
+
`,exitCode:2}:(e.code=r[o+1],e.scriptArgs=r.slice(o+2),e);if(s==="-m")return o+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
|
|
4
|
+
`,exitCode:2}:(e.module=r[o+1],e.scriptArgs=r.slice(o+2),e);if(s==="--version"||s==="-V")return e.showVersion=!0,e;if(s.startsWith("-")&&s!=="-")return{stdout:"",stderr:`python3: unrecognized option '${s}'
|
|
5
|
+
`,exitCode:2}}if(t!==-1){let o=r[t];o==="--"?t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)):(e.scriptFile=o,e.scriptArgs=r.slice(t+1))}return e}var w=new WeakMap;function L(r){let e=w.get(r);return e||(e={executionQueue:[],isExecuting:!1},w.set(r,e)),e}function oe(){w=new WeakMap}var H=W(new URL("./worker.js",import.meta.url));function N(){return F(16).toString("hex")}function z(r,e){if(!r||typeof r!="object")return{success:!1,error:"Malformed worker response"};let t=r;return typeof t.protocolToken!="string"||t.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:t.type==="security-violation"?{success:!1,error:`Security violation: ${typeof t.violation?.type=="string"?t.violation.type:"unknown"}`}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function a(r){if(r.isExecuting||r.executionQueue.length===0)return;for(;r.executionQueue.length>0&&r.executionQueue[0].canceled;)r.executionQueue.shift();if(r.executionQueue.length===0)return;let e=r.executionQueue.shift();if(!e)return;r.isExecuting=!0;let t;try{t=k.runTrusted(()=>new $(H,{workerData:e.input}))}catch(n){let i=n instanceof Error?n.message:String(n);e.resolve({success:!1,error:c(i)}),r.isExecuting=!1,a(r);return}e.workerRef&&(e.workerRef.current=t);let o=h(e.requireDefenseContext,"python3","worker message callback",n=>{e.resolve(z(n,e.input.protocolToken)),r.isExecuting=!1,t.terminate(),a(r)}),s=h(e.requireDefenseContext,"python3","worker error callback",n=>{e.resolve({success:!1,error:c(n.message)}),r.isExecuting=!1,a(r)}),p=h(e.requireDefenseContext,"python3","worker exit callback",()=>{r.isExecuting&&(e.resolve({success:!1,error:"Worker exited unexpectedly"}),r.isExecuting=!1,a(r))}),f=n=>{try{o(n)}catch(i){let m=i instanceof Error?i.message:String(i);e.resolve({success:!1,error:c(m)}),r.isExecuting=!1,t.terminate(),a(r)}},l=n=>{try{s(n)}catch(i){let m=i instanceof Error?i.message:String(i);e.resolve({success:!1,error:c(m)}),r.isExecuting=!1,a(r)}},y=()=>{try{p()}catch(n){let i=n instanceof Error?n.message:String(n);e.resolve({success:!1,error:c(i)}),r.isExecuting=!1,a(r)}};t.on("message",f),t.on("error",l),t.on("exit",y)}async function B(r,e,t,o=[]){let s=M(),p=new D(s,e.fs,e.cwd,"python3",e.fetch,e.limits?.maxOutputSize??0),f=e.limits?.maxPythonTimeoutMs??Q,l=e.fetch?Math.max(f,R):f,y=L(e.fs),n={protocolToken:N(),sharedBuffer:s,pythonCode:r,cwd:e.cwd,env:b(e.env),args:o,scriptPath:t,timeoutMs:l},i={current:null},m=new Promise(u=>{let E={input:n,resolve:()=>{},workerRef:i,requireDefenseContext:e.requireDefenseContext},_=h(e.requireDefenseContext,"python3","worker timeout callback",()=>{i.current?i.current.terminate():E.canceled=!0,u({success:!1,error:`Execution timeout: exceeded ${l}ms limit`})}),O=C(()=>{try{_()}catch(d){let A=d instanceof Error?d.message:String(d);u({success:!1,error:c(A)})}},l);E.resolve=d=>{v(O),u(d)},y.executionQueue.push(E),a(y)}),[g,x]=await Promise.all([p.run(l).catch(u=>({stdout:"",stderr:`python3: bridge error: ${c(u.message)}
|
|
6
|
+
`,exitCode:1})),m.catch(u=>({success:!1,error:c(u.message)}))]);if(!x.success&&x.error){let u=c(x.error);return{stdout:g.stdout,stderr:`${g.stderr}python3: ${u}
|
|
7
|
+
`,exitCode:g.exitCode||1}}return g}var V={name:"python3",async execute(r,e){if(P(r))return T(U);let t=I(r);if("exitCode"in t)return t;if(t.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
|
|
8
|
+
`,stderr:"",exitCode:0};let o,s;if(t.code!==null)o=t.code,s="-c";else if(t.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(t.module))return{stdout:"",stderr:`python3: No module named '${t.module.slice(0,200)}'
|
|
9
|
+
`,exitCode:1};o=`import runpy; runpy.run_module('${t.module}', run_name='__main__')`,s=t.module}else if(t.scriptFile!==null){let p=e.fs.resolvePath(e.cwd,t.scriptFile);if(!await e.fs.exists(p))return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': [Errno 2] No such file or directory
|
|
10
|
+
`,exitCode:2};try{o=await e.fs.readFile(p),s=t.scriptFile}catch(f){let l=c(f.message);return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': ${l}
|
|
11
|
+
`,exitCode:2}}}else if(e.stdin.trim())o=e.stdin,s="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
|
|
12
|
+
`,exitCode:2};return B(o,e,s,t.scriptArgs)}},se={name:"python",async execute(r,e){return V.execute(r,e)}};export{oe as _resetExecutionQueue,V as python3Command,se as pythonCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-3YMCKZTY.js";import"./chunk-4OALHZXB.js";import"./chunk-QZNF3Y3J.js";import"./chunk-4PRVMER6.js";import"./chunk-SYG3IW7P.js";import"./chunk-KGOUQS5A.js";export{b as flagsForFuzzing,a as timeCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-DOXYBGNA.js";import"./chunk-YTIURC67.js";import"./chunk-4OALHZXB.js";import"./chunk-OOJCYVYF.js";import"./chunk-YU6OGPZR.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{b as flagsForFuzzing,a as timeoutCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-B3RU2PUI.js";import"./chunk-GZHFXDDO.js";import"./chunk-QSDVMMYI.js";import"./chunk-ZO5PSLKR.js";import"./chunk-V7ZOPVQS.js";import"./chunk-4PRVMER6.js";import"./chunk-MO4RPBN2.js";import"./chunk-YU6OGPZR.js";import"./chunk-SE4C7FJY.js";import"./chunk-5WFYIUU2.js";import"./chunk-6KZRLMG3.js";import"./chunk-OBH7XN5N.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{b as flagsForFuzzing,a as xanCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-LGF54XJQ.js";import"./chunk-QSDVMMYI.js";import"./chunk-ZO5PSLKR.js";import"./chunk-V7ZOPVQS.js";import"./chunk-4PRVMER6.js";import"./chunk-MO4RPBN2.js";import"./chunk-YU6OGPZR.js";import"./chunk-SE4C7FJY.js";import"./chunk-6KZRLMG3.js";import"./chunk-SYG3IW7P.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{b as flagsForFuzzing,a as yqCommand};
|