@jerryan/just-bash 3.8.0 → 3.9.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/CHANGELOG.md +14 -0
- package/README.md +5 -15
- package/dist/AGENTS.md +2 -2
- package/dist/Bash.d.ts +2 -4
- package/dist/bin/chunks/{chunk-7WBCA2BB.js → chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-MPFNZYEA.js → chunks/chunk-6JEDM6CZ.js} +1 -1
- package/dist/bin/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/chunks/chunk-GBKR5KTT.js +44 -0
- package/dist/bin/{shell/chunks/chunk-MF3GVFLC.js → chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/chunks/{diff-JSJ56EOK.js → diff-DM47S5PT.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-2H5CPEM6.js → chunks/flag-coverage-LLAQBVIG.js} +1 -1
- package/dist/bin/chunks/js-exec-ZAAIZQWI.js +99 -0
- package/dist/bin/chunks/js-exec-worker.js +4995 -0
- package/dist/bin/chunks/python3-TJ6DCPIA.js +14 -0
- package/dist/bin/chunks/{sleep-DVFE2GSF.js → sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/{shell/chunks/sqlite3-KNN6V2W6.js → chunks/sqlite3-CXQTZRPZ.js} +1 -1
- package/dist/bin/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/{chunk-7WBCA2BB.js → chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/{chunks/chunk-MPFNZYEA.js → shell/chunks/chunk-6JEDM6CZ.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/shell/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/shell/chunks/chunk-GBKR5KTT.js +44 -0
- package/dist/bin/{chunks/chunk-MF3GVFLC.js → shell/chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/shell/chunks/{diff-JSJ56EOK.js → diff-DM47S5PT.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-2H5CPEM6.js → shell/chunks/flag-coverage-LLAQBVIG.js} +1 -1
- package/dist/bin/shell/chunks/js-exec-ZAAIZQWI.js +99 -0
- package/dist/bin/shell/chunks/python3-TJ6DCPIA.js +14 -0
- package/dist/bin/shell/chunks/{sleep-DVFE2GSF.js → sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/{chunks/sqlite3-KNN6V2W6.js → shell/chunks/sqlite3-CXQTZRPZ.js} +1 -1
- package/dist/bin/shell/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/browser.js +596 -579
- package/dist/bundle/chunks/{chunk-N3A4JVFJ.js → chunk-6IA4DXG2.js} +1 -1
- package/dist/bundle/chunks/chunk-BS6EJR2R.js +11 -0
- package/dist/bundle/chunks/chunk-E2F4A3CM.js +43 -0
- package/dist/bundle/chunks/{chunk-GNPLDVBD.js → chunk-H3A45X3W.js} +1 -1
- package/dist/bundle/chunks/chunk-PS2RJNZZ.js +2 -0
- package/dist/bundle/chunks/{chunk-DMWNBCXJ.js → chunk-TLPMB3FO.js} +1 -1
- package/dist/bundle/chunks/{chunk-XV2V56NQ.js → chunk-YFFU74KY.js} +1 -1
- package/dist/bundle/chunks/{diff-VDB6RXHO.js → diff-R7TXVVLN.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-UMQ3BWDP.js → flag-coverage-YQGACUSN.js} +1 -1
- package/dist/bundle/chunks/js-exec-MUZRDUJ3.js +98 -0
- package/dist/bundle/chunks/js-exec-worker.js +4995 -0
- package/dist/bundle/chunks/python3-W4UMQJAQ.js +13 -0
- package/dist/bundle/chunks/{sleep-PPRBTSVR.js → sleep-25QUPVDK.js} +1 -1
- package/dist/bundle/chunks/{sqlite3-KB3MXTTM.js → sqlite3-DQNCWDG5.js} +1 -1
- package/dist/bundle/chunks/{timeout-C6WDYPLV.js → timeout-37GM7IIL.js} +1 -1
- package/dist/bundle/index.cjs +1128 -2663
- package/dist/bundle/index.js +2 -2
- package/dist/commands/js-exec/js-exec-worker.d.ts +35 -0
- package/dist/commands/js-exec/js-exec.d.ts +14 -1
- package/dist/fs/vfs-template.d.ts +6 -0
- package/dist/interpreter/interpreter.d.ts +1 -1
- package/dist/interpreter/types.d.ts +1 -1
- package/dist/limits.d.ts +2 -2
- package/dist/timers.d.ts +9 -0
- package/dist/types.d.ts +3 -4
- package/package.json +8 -8
- package/dist/bin/chunks/chunk-2NJJXU4K.js +0 -27
- package/dist/bin/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/chunks/js-exec-T3SAB2B6.js +0 -1651
- package/dist/bin/chunks/python3-3ERN3L6S.js +0 -23
- package/dist/bin/shell/chunks/chunk-2NJJXU4K.js +0 -27
- package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/shell/chunks/js-exec-T3SAB2B6.js +0 -1651
- package/dist/bin/shell/chunks/python3-3ERN3L6S.js +0 -23
- package/dist/bundle/chunks/chunk-B6OSJB22.js +0 -26
- package/dist/bundle/chunks/chunk-WXPNKIIH.js +0 -2
- package/dist/bundle/chunks/js-exec-ZQMIYQTH.js +0 -1650
- package/dist/bundle/chunks/python3-QB7OE256.js +0 -22
- package/dist/commands/js-exec/run-runtime.d.ts +0 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{d as l,e as u}from"./chunk-PS2RJNZZ.js";import{randomBytes as h}from"node:crypto";var d=class{options;protocolToken=h(16).toString("hex");deadline;cleanups=[];cancelHandler;canceledReason;closed=!1;constructor(t){this.options=t,this.deadline=Date.now()+t.timeoutMs}arm(t){if(this.cancelHandler)throw new Error("worker request is already armed");this.cancelHandler=t;let a=this.options.signal;if(a){let i=()=>this.cancel("abort");a.addEventListener("abort",i,{once:!0}),this.cleanups.push(()=>a.removeEventListener("abort",i)),a.aborted&&this.cancel("abort")}if(!this.canceledReason){let i=l(()=>this.cancel("timeout"),Math.max(0,this.options.timeoutMs));i!==void 0&&this.cleanups.push(()=>u(i))}}get isCanceled(){return this.canceledReason!==void 0}remainingTimeMs(){return Math.max(0,this.deadline-Date.now())}timeoutMessage(t="Execution"){return`${t} timeout: exceeded ${this.options.timeoutMs}ms limit`}abortMessage(){return"Execution aborted"}assertMessageSize(t,a){if(f(t,this.options.maxMessageBytes)>this.options.maxMessageBytes)throw new Error(`${this.options.commandName}: worker ${a} exceeds ${this.options.maxMessageBytes} byte limit`)}async terminate(t){if(!t)return!0;try{return await t.terminate(),!0}catch{return!1}}close(){if(!this.closed){this.closed=!0;for(let t=this.cleanups.length-1;t>=0;t--)this.cleanups[t]();this.cleanups.length=0,this.cancelHandler=void 0}}cancel(t){this.closed||this.canceledReason||(this.canceledReason=t,this.cancelHandler?.(t))}};function f(o,t){let a=function*(n){for(let e in n)Object.hasOwn(n,e)&&(yield[e,n[e]])},i=[{kind:"value",value:o}],c=new WeakSet,s=0;for(;i.length>0&&s<=t;){let n=i.pop();if(!n)break;if(n.kind==="array"){n.index<n.value.length&&(i.push({...n,index:n.index+1}),i.push({kind:"value",value:n.value[n.index]}));continue}if(n.kind==="object"){let r=n.iterator.next();r.done||(s+=8+Buffer.byteLength(r.value[0],"utf8"),i.push(n),i.push({kind:"value",value:r.value[1]}));continue}let e=n.value;if(e==null)s+=4;else if(typeof e=="string")s+=Buffer.byteLength(e,"utf8");else if(typeof e=="number"||typeof e=="bigint")s+=8;else if(typeof e=="boolean")s+=1;else if(typeof e=="object"){if(c.has(e))continue;if(c.add(e),ArrayBuffer.isView(e))s+=e.byteLength;else if(e instanceof ArrayBuffer||e instanceof SharedArrayBuffer)s+=e.byteLength;else if(Array.isArray(e)){if(e.length>Math.floor((t-s)/8))return t+1;s+=e.length*8,i.push({kind:"array",value:e,index:0})}else i.push({kind:"object",iterator:a(e)})}}return s}export{d as a};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{b as L}from"./chunk-WNH3HOQA.js";import{a as I,b as l}from"./chunk-KIGPB52X.js";import{d as A,e as m}from"./chunk-PS2RJNZZ.js";import{a as C}from"./chunk-L2UW7DWF.js";import{b as w}from"./chunk-ZBUZKIPX.js";import{a as _,b as f}from"./chunk-T5ZEIOJ3.js";import{a as F,b as D}from"./chunk-FOCWZZDE.js";var h={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,RENAME:14,COPY_FILE:15,WRITE_FILE_RANGE:17,READ_RESULT_RANGE:18,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200,EXEC_COMMAND:300,INVOKE_TOOL:400},S={IDLE:0,REQUEST:1,CANCELLED:2},r={NONE:0,SUCCESS:1,ERROR:2},a={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10,NOT_EMPTY:11,LOOP:12,FILE_TOO_LARGE:13,NO_SPACE:14,BUSY:15,READ_ONLY:16,CROSS_DEVICE:17},O=Object.assign(Object.create(null),{ENOENT:a.NOT_FOUND,EISDIR:a.IS_DIRECTORY,ENOTDIR:a.NOT_DIRECTORY,ENOTEMPTY:a.NOT_EMPTY,EEXIST:a.EXISTS,EPERM:a.PERMISSION_DENIED,EACCES:a.PERMISSION_DENIED,EINVAL:a.INVALID_PATH,ELOOP:a.LOOP,EFBIG:a.FILE_TOO_LARGE,ENOSPC:a.NO_SPACE,EBUSY:a.BUSY,EROFS:a.READ_ONLY,EXDEV:a.CROSS_DEVICE}),P=Object.create(null);for(let[d,t]of Object.entries(O))P[t]=d;var o={OP_CODE:0,REQUEST:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,RESULT_STATE:32,PATH_BUFFER:36,DATA_BUFFER:4132},R={PATH_BUFFER:4096,DATA_BUFFER:8388608,TOTAL:8392740},g={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},u={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function M(){return new I(R.TOTAL)}var T=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return l.load(this.int32View,o.OP_CODE/4)}setOpCode(t){l.store(this.int32View,o.OP_CODE/4,t)}getRequest(){return l.load(this.int32View,o.REQUEST/4)}setRequest(t){l.store(this.int32View,o.REQUEST/4,t)}getResultState(){return l.load(this.int32View,o.RESULT_STATE/4)}setResultState(t){l.store(this.int32View,o.RESULT_STATE/4,t)}getPathLength(){return l.load(this.int32View,o.PATH_LENGTH/4)}setPathLength(t){l.store(this.int32View,o.PATH_LENGTH/4,t)}getDataLength(){return l.load(this.int32View,o.DATA_LENGTH/4)}setDataLength(t){l.store(this.int32View,o.DATA_LENGTH/4,t)}getResultLength(){return l.load(this.int32View,o.RESULT_LENGTH/4)}setResultLength(t){l.store(this.int32View,o.RESULT_LENGTH/4,t)}getErrorCode(){return l.load(this.int32View,o.ERROR_CODE/4)}setErrorCode(t){l.store(this.int32View,o.ERROR_CODE/4,t)}getFlags(){return l.load(this.int32View,o.FLAGS/4)}setFlags(t){l.store(this.int32View,o.FLAGS/4,t)}getMode(){return l.load(this.int32View,o.MODE/4)}setMode(t){l.store(this.int32View,o.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(o.PATH_BUFFER,o.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>R.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${R.PATH_BUFFER}`);this.uint8View.set(e,o.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(o.DATA_BUFFER,o.DATA_BUFFER+t)}setData(t){if(t.length>R.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${R.DATA_BUFFER}`);this.uint8View.set(t,o.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(o.DATA_BUFFER,o.DATA_BUFFER+t)}setResult(t){if(t.length>R.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${R.DATA_BUFFER}`);this.uint8View.set(t,o.DATA_BUFFER),this.setResultLength(t.length)}setResultPrefix(t){if(t.length>2147483647)throw new Error(`Result too large: ${t.length} exceeds int32`);let e=Math.min(t.length,R.DATA_BUFFER);this.uint8View.set(t.subarray(0,e),o.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[o.DATA_BUFFER+u.IS_FILE]=t.isFile?1:0,this.uint8View[o.DATA_BUFFER+u.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[o.DATA_BUFFER+u.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(o.DATA_BUFFER+u.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(o.DATA_BUFFER+u.SIZE,e,!0),this.dataView.setFloat64(o.DATA_BUFFER+u.MTIME,t.mtime.getTime(),!0),this.setResultLength(u.TOTAL)}decodeStat(){return{isFile:this.uint8View[o.DATA_BUFFER+u.IS_FILE]===1,isDirectory:this.uint8View[o.DATA_BUFFER+u.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[o.DATA_BUFFER+u.IS_SYMLINK]===1,mode:this.dataView.getInt32(o.DATA_BUFFER+u.MODE,!0),size:this.dataView.getFloat64(o.DATA_BUFFER+u.SIZE,!0),mtime:new Date(this.dataView.getFloat64(o.DATA_BUFFER+u.MTIME,!0))}}async waitUntilReady(t){let e=Date.now();for(;;){let s=this.getRequest();if(s===S.REQUEST)return!0;if(s!==S.IDLE)return!1;let i=Date.now()-e;if(i>=t)return!1;let n=t-i,c=l.waitAsync(this.int32View,o.REQUEST/4,S.IDLE,n);if(c.async&&await c.value==="timed-out")return!1}}waitForResult(t){return l.wait(this.int32View,o.RESULT_STATE/4,r.NONE,t)}notifyRequest(){return l.notify(this.int32View,o.REQUEST/4)}notifyResult(){return l.notify(this.int32View,o.RESULT_STATE/4)}reset(){this.setOpCode(h.NOOP),this.setRequest(S.IDLE),this.setResultState(r.NONE),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(a.NONE),this.setFlags(g.NONE),this.setMode(0)}};function U(d){return d!==void 0&&Object.hasOwn(O,d)?O[d]:a.IO_ERROR}var N=class{fs;cwd;commandName;secureFetch;maxOutputSize;exec;invokeTool;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;startTime=0;timeoutMs=0;lastResult=null;constructor(t,e,s,i,n=void 0,c=0,E=void 0,p=void 0){this.fs=e,this.cwd=s,this.commandName=i,this.secureFetch=n,this.maxOutputSize=c,this.exec=E,this.invokeTool=p,this.protocol=new T(t)}remainingMs(){return Math.max(0,this.timeoutMs-(Date.now()-this.startTime))}raceDeadline(t){let e=this.remainingMs();if(e<=0)return this.running=!1,this.output.exitCode=124,this.output.stderr+=`
|
|
3
|
+
${this.commandName}: execution timeout exceeded
|
|
4
|
+
`,Promise.reject(new Error("Operation timed out"));let s=t();return e===Number.POSITIVE_INFINITY?s:new Promise((i,n)=>{let c=A(()=>{this.running=!1,this.output.exitCode=124,this.output.stderr+=`
|
|
5
|
+
${this.commandName}: execution timeout exceeded
|
|
6
|
+
`,n(new Error("Operation timed out"))},e);s.then(E=>{m(c),i(E)},E=>{m(c),n(E)})})}async run(t){for(this.running=!0,this.startTime=Date.now(),this.timeoutMs=t;this.running;){if(Date.now()-this.startTime>=t){this.output.stderr+=`
|
|
7
|
+
${this.commandName}: execution timeout exceeded
|
|
8
|
+
`,this.output.exitCode=124;break}let s=this.remainingMs();if(!await this.protocol.waitUntilReady(s)){if(!this.running)break;this.output.stderr+=`
|
|
9
|
+
${this.commandName}: execution timeout exceeded
|
|
10
|
+
`,this.output.exitCode=124;break}if(!this.running)break;this.protocol.setRequest(S.IDLE);let n=this.protocol.getOpCode();await this.handleOperation(n),this.protocol.notifyResult()}return this.output}stop(){this.running=!1,this.lastResult=null,this.protocol.setRequest(S.CANCELLED),this.protocol.notifyRequest()}async handleOperation(t){try{switch(t){case h.READ_FILE:await this.handleReadFile();break;case h.WRITE_FILE:await this.handleWriteFile();break;case h.STAT:await this.handleStat();break;case h.LSTAT:await this.handleLstat();break;case h.READDIR:await this.handleReaddir();break;case h.MKDIR:await this.handleMkdir();break;case h.READ_RESULT_RANGE:this.handleReadResultRange();break;case h.WRITE_FILE_RANGE:await this.handleWriteFileRange();break;case h.RM:await this.handleRm();break;case h.EXISTS:await this.handleExists();break;case h.APPEND_FILE:await this.handleAppendFile();break;case h.SYMLINK:await this.handleSymlink();break;case h.READLINK:await this.handleReadlink();break;case h.CHMOD:await this.handleChmod();break;case h.REALPATH:await this.handleRealpath();break;case h.RENAME:await this.handleRename();break;case h.COPY_FILE:await this.handleCopyFile();break;case h.WRITE_STDOUT:this.handleWriteStdout();break;case h.WRITE_STDERR:this.handleWriteStderr();break;case h.EXIT:this.handleExit();break;case h.HTTP_REQUEST:await this.handleHttpRequest();break;case h.EXEC_COMMAND:await this.handleExecCommand();break;case h.INVOKE_TOOL:await this.handleInvokeTool();break;default:this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultState(r.ERROR)}}catch(e){this.setErrorFromException(e)}}publishResult(t){let e=typeof t=="string"?new TextEncoder().encode(t):t;this.lastResult=e,this.protocol.setResultPrefix(e),this.protocol.setResultState(r.SUCCESS)}handleReadResultRange(){let t=this.protocol.getFlags(),e=this.protocol.getMode(),s=this.lastResult;if(!s||t>=s.length){this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString(`No retained result for range read (offset=${t}, length=${e}, retained=${s?.length??"none"})`),this.protocol.setResultState(r.ERROR);return}this.protocol.setResult(s.subarray(t,t+e)),this.protocol.setResultState(r.SUCCESS)}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.publishResult(e)}catch(e){this.setErrorFromException(e)}}async handleWriteFileRange(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=this.protocol.getData();try{if(e===0)await this.fs.writeFile(t,s);else{let i=await this.fs.stat(t);if(i.size!==e)throw new _("EIO",`non-sequential range write to '${t}': offset ${e} != size ${i.size}`);await this.fs.appendFile(t,s)}this.protocol.setResultState(r.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleWriteFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.writeFile(t,e),this.protocol.setResultState(r.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.setResultState(r.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.setResultState(r.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleReaddir(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readdir(t);this.publishResult(JSON.stringify(e))}catch(e){this.setErrorFromException(e)}}async handleMkdir(){let t=this.resolvePath(this.protocol.getPath()),s=(this.protocol.getFlags()&g.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:s}),this.protocol.setResultState(r.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=(e&g.RECURSIVE)!==0,i=(e&g.FORCE)!==0;try{await this.fs.rm(t,{recursive:s,force:i}),this.protocol.setResultState(r.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.setResultState(r.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.setResultState(r.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.setResultState(r.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleReadlink(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readlink(t);this.protocol.setResultFromString(e),this.protocol.setResultState(r.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.setResultState(r.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.setResultState(r.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleRename(){let t=this.resolvePath(this.protocol.getPath()),e=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.mv(t,e),this.protocol.setResultState(r.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleCopyFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.cp(t,e),this.protocol.setResultState(r.SUCCESS)}catch(s){this.setErrorFromException(s)}}handleWriteStdout(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setResultState(r.ERROR);return}this.protocol.setResultState(r.SUCCESS)}handleWriteStderr(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stderr",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setResultState(r.ERROR);return}this.protocol.setResultState(r.SUCCESS)}handleExit(){let t=this.protocol.getFlags();this.outputLimitExceeded?this.output.exitCode===0&&(this.output.exitCode=1):this.output.exitCode=t,this.protocol.setResultState(r.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=`${this.commandName}: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
|
|
11
|
+
`,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let i=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(i>0)if(this.output.stdout.length>=i)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-i);else{let n=i-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(){let t=this.secureFetch;if(!t){this.protocol.setErrorCode(a.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setResultState(r.ERROR);return}let e=this.protocol.getPath(),s=this.protocol.getDataAsString();try{let i=s?JSON.parse(s):{},n=this.remainingMs(),c=await this.raceDeadline(()=>t(e,{method:i.method,headers:i.headers,body:i.body,timeoutMs:n})),E=JSON.stringify({status:c.status,statusText:c.statusText,headers:c.headers,bodyBase64:L(c.body,"base64"),url:c.url});this.publishResult(E)}catch(i){let n=F(i instanceof Error?i.message:String(i));this.protocol.setErrorCode(a.NETWORK_ERROR),this.protocol.setResultFromString(n),this.protocol.setResultState(r.ERROR)}}async handleExecCommand(){let t=this.exec;if(!t){this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Command execution not available in this context."),this.protocol.setResultState(r.ERROR);return}let e=this.protocol.getPath(),s=this.protocol.getDataAsString(),i=new AbortController;try{let n={cwd:this.cwd,signal:i.signal};if(s){let p=JSON.parse(s);p.stdin&&(n.stdin=p.stdin),p.args&&Array.isArray(p.args)&&(n.args=p.args.map(x=>String(x)),e=C([e]))}let c=await this.raceDeadline(()=>t(e,n)),E=JSON.stringify({stdout:c.stdout,stderr:c.stderr,exitCode:c.exitCode});this.publishResult(E)}catch(n){i.abort();let c=n instanceof Error?n.message:String(n);this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString(c),this.protocol.setResultState(r.ERROR)}}async handleInvokeTool(){let t=this.invokeTool;if(!t){this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Tool invocation not available in this context."),this.protocol.setResultState(r.ERROR);return}let e=this.protocol.getPath(),s=this.protocol.getDataAsString();try{let i=await this.raceDeadline(()=>w.runTrustedAsync(()=>t(e,s)));this.publishResult(i)}catch(i){let n=D(i instanceof Error?i.message:String(i));this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString(n),this.protocol.setResultState(r.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),s=F(e);this.protocol.setErrorCode(U(f(t))),this.protocol.setResultFromString(s),this.protocol.setResultState(r.ERROR)}};export{M as a,N as b};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{d as x}from"./chunk-GN6CQ3J4.js";import{a as q}from"./chunk-QIQMJJZ4.js";import{a as A,b as O}from"./chunk-QAYAQNCG.js";import*as j from"diff";var Y=`\
|
|
3
|
+
`,E=3;function P(t){if(t==="")return{lines:[],noEol:!1};let o=!t.endsWith(`
|
|
4
|
+
`),n=t.split(`
|
|
5
|
+
`);return o||n.pop(),{lines:n,noEol:o}}function H(t,o){let n=t.lines.length-1;return t.lines.map((e,i)=>{let s=i===n&&t.noEol?e:`${e}
|
|
6
|
+
`;return o?s.toLowerCase():s})}function W(t,o,n){let e=j.diffArrays(H(t,n),H(o,n)),i=[],s=0,f=0,a=0;for(;a<e.length;){let r=e[a];if(!r.added&&!r.removed){s+=r.count??r.value.length,f+=r.count??r.value.length,a++;continue}let u={oldStart:s,oldCount:0,newStart:f,newCount:0};for(;a<e.length&&(e[a].added||e[a].removed);){let c=e[a].count??e[a].value.length;e[a].removed?(u.oldCount+=c,s+=c):(u.newCount+=c,f+=c),a++}i.push(u)}return i}function T(t){if(!/[\s"\u0000-\u001f\u007f]/.test(t))return t;let o='"';for(let n of t)n==='"'||n==="\\"?o+=`\\${n}`:n===" "?o+="\\t":n===`
|
|
7
|
+
`?o+="\\n":n==="\r"?o+="\\r":n<" "||n==="\x7F"?o+=`\\${n.charCodeAt(0).toString(8).padStart(3,"0")}`:o+=n;return`${o}"`}function S(t,o,n,e){t.push(`${e}${o.lines[n]}
|
|
8
|
+
`),o.noEol&&n===o.lines.length-1&&t.push(Y)}function I(t,o){return o===0?String(t):o===1?String(t+1):`${t+1},${t+o}`}function z(t,o,n){let e=[];for(let i of n){let s=i.oldCount===0?"a":i.newCount===0?"d":"c";e.push(`${I(i.oldStart,i.oldCount)}${s}${I(i.newStart,i.newCount)}
|
|
9
|
+
`);for(let f=0;f<i.oldCount;f++)S(e,t,i.oldStart+f,"< ");s==="c"&&e.push(`---
|
|
10
|
+
`);for(let f=0;f<i.newCount;f++)S(e,o,i.newStart+f,"> ")}return e.join("")}function X(t,o){let n=[],e=[];for(let i of t){let s=e[e.length-1];s&&i.oldStart-(s.oldStart+s.oldCount)>2*o&&(n.push(e),e=[]),e.push(i)}return e.length>0&&n.push(e),n}function B(t,o,n,e){let i=t[0],s=t[t.length-1];return{oldFrom:Math.max(0,i.oldStart-e),oldTo:Math.min(o.lines.length,s.oldStart+s.oldCount+e),newFrom:Math.max(0,i.newStart-e),newTo:Math.min(n.lines.length,s.newStart+s.newCount+e)}}function R(t,o){let n=o-t;return n===0?`${t},0`:n===1?String(t+1):`${t+1},${n}`}function V(t,o,n,e,i,s){let f=[`--- ${T(t)}
|
|
11
|
+
`,`+++ ${T(o)}
|
|
12
|
+
`];for(let a of X(i,s)){let r=B(a,n,e,s);f.push(`@@ -${R(r.oldFrom,r.oldTo)} +${R(r.newFrom,r.newTo)} @@
|
|
13
|
+
`);let u=r.oldFrom;for(let c of a){for(;u<c.oldStart;u++)S(f,n,u," ");for(let h=0;h<c.oldCount;h++)S(f,n,c.oldStart+h,"-");for(let h=0;h<c.newCount;h++)S(f,e,c.newStart+h,"+");u=c.oldStart+c.oldCount}for(;u<r.oldTo;u++)S(f,n,u," ")}return f.join("")}function U(t,o){let n=o-t;return n===0?String(t):n===1?String(t+1):`${t+1},${o}`}function _(t,o,n,e,i,s){if(!n.some(r=>(s?r.oldCount:r.newCount)>0))return;let a=e;for(let r of n){let u=s?r.oldStart:r.newStart,c=s?r.oldCount:r.newCount;for(;a<u;a++)S(t,o,a," ");let h=r.oldCount>0&&r.newCount>0?"! ":s?"- ":"+ ";for(let g=0;g<c;g++)S(t,o,u+g,h);a=u+c}for(;a<i;a++)S(t,o,a," ")}function G(t,o,n,e,i,s){let f=[`*** ${T(t)}
|
|
14
|
+
`,`--- ${T(o)}
|
|
15
|
+
`];for(let a of X(i,s)){let r=B(a,n,e,s);f.push(`***************
|
|
16
|
+
`),f.push(`*** ${U(r.oldFrom,r.oldTo)} ****
|
|
17
|
+
`),_(f,n,a,r.oldFrom,r.oldTo,!0),f.push(`--- ${U(r.newFrom,r.newTo)} ----
|
|
18
|
+
`),_(f,e,a,r.newFrom,r.newTo,!1)}return f.join("")}var Z={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:[" --normal output a normal diff (default)","-u, --unified output a unified diff","-c, --context output a context diff","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences","-r, --recursive recursively compare directories","-N, --new-file treat absent files as empty"," --version output version information and exit"," --help display this help and exit"]},ee={normal:{long:"normal",type:"boolean"},unified:{short:"u",long:"unified",type:"boolean"},context:{short:"c",long:"context",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},newFile:{short:"N",long:"new-file",type:"boolean"},version:{long:"version",type:"boolean"}},L=100;function N(t,o,n,e,i){let s=n,f=e;if(i.ignoreCase&&(s=s.toLowerCase(),f=f.toLowerCase()),s===f)return i.reportSame?{output:`Files ${t} and ${o} are identical
|
|
19
|
+
`,differs:!1}:{output:"",differs:!1};if(i.brief)return{output:`Files ${t} and ${o} differ
|
|
20
|
+
`,differs:!0};let a=P(n),r=P(e),u=W(a,r,i.ignoreCase),c;return i.unified?c=V(t,o,a,r,u,E):i.context?c=G(t,o,a,r,u,E):c=z(a,r,u),{output:c,differs:!0}}async function F(t,o){return t.fs.readFile(t.fs.resolvePath(t.cwd,o))}async function J(t,o){try{let n=t.fs.resolvePath(t.cwd,o),e=await t.fs.stat(n);return{isFile:e.isFile,isDirectory:e.isDirectory}}catch{return null}}async function k(t,o){if(t.fs.readdirWithFileTypes)return t.fs.readdirWithFileTypes(o);let n=await t.fs.readdir(o),e=[];for(let i of n)try{let s=await t.fs.stat(`${o}/${i}`);e.push({name:i,isFile:s.isFile,isDirectory:s.isDirectory,isSymbolicLink:s.isSymbolicLink??!1})}catch{}return e}function K(t){return t.isDirectory?"directory":t.isSymbolicLink?"symbolic link":"regular file"}async function Q(t,o,n,e,i=0){if(i>L)return{output:`diff: maximum recursion depth exceeded (${L})
|
|
21
|
+
`,differs:!0};let s=n.fs.resolvePath(n.cwd,t),f=n.fs.resolvePath(n.cwd,o),a=await k(n,s),r=await k(n,f),u=new Set(a.map(p=>p.name)),c=new Set(r.map(p=>p.name)),h=[...new Set([...u,...c])].sort(),g=new Map(a.map(p=>[p.name,p])),C=new Map(r.map(p=>[p.name,p])),d="",l=!1;for(let p of h){let m=`${t}/${p}`,w=`${o}/${p}`,y=g.get(p),v=C.get(p);if(y&&v)if(y.isDirectory&&v.isDirectory){let $=await Q(m,w,n,e,i+1);d+=$.output,l=l||$.differs}else if(y.isFile&&v.isFile)try{let $=await F(n,m),b=await F(n,w),D=N(m,w,$,b,e);D.differs&&!e.brief&&D.output&&(d+=`${e.headerPrefix} ${m} ${w}
|
|
22
|
+
`),d+=D.output,l=l||D.differs}catch{d+=`diff: ${m}: No such file or directory
|
|
23
|
+
`,l=!0}else d+=`File ${m} is a ${K(y)} while file ${w} is a ${K(v)}
|
|
24
|
+
`,l=!0;else if(y)if(e.newFile)if(y.isDirectory){let $=await M(m,w,n,e,!0,i+1);d+=$.output,l=l||$.differs}else if(y.isFile){let $=await F(n,m),b=N(m,w,$,"",e);b.differs&&!e.brief&&b.output&&(d+=`${e.headerPrefix} ${m} ${w}
|
|
25
|
+
`),d+=b.output,l=l||b.differs}else d+=`Only in ${t}: ${p}
|
|
26
|
+
`,l=!0;else d+=`Only in ${t}: ${p}
|
|
27
|
+
`,l=!0;else if(v)if(e.newFile)if(v.isDirectory){let $=await M(w,m,n,e,!1,i+1);d+=$.output,l=l||$.differs}else if(v.isFile){let $=await F(n,w),b=N(m,w,"",$,e);b.differs&&!e.brief&&b.output&&(d+=`${e.headerPrefix} ${m} ${w}
|
|
28
|
+
`),d+=b.output,l=l||b.differs}else d+=`Only in ${o}: ${p}
|
|
29
|
+
`,l=!0;else d+=`Only in ${o}: ${p}
|
|
30
|
+
`,l=!0}return{output:d,differs:l}}async function M(t,o,n,e,i,s=0){if(s>L)return{output:`diff: maximum recursion depth exceeded (${L})
|
|
31
|
+
`,differs:!0};let f=n.fs.resolvePath(n.cwd,t),r=[...await k(n,f)].sort((h,g)=>h.name<g.name?-1:h.name>g.name?1:0),u="",c=!1;for(let h of r){let g=`${t}/${h.name}`,C=`${o}/${h.name}`;if(h.isDirectory){let d=await M(g,C,n,e,i,s+1);u+=d.output,c=c||d.differs}else if(h.isFile){let d=await F(n,g),l=i?d:"",p=i?"":d,m=i?g:C,w=i?C:g,y=N(m,w,l,p,e);y.differs&&!e.brief&&y.output&&(u+=`${e.headerPrefix} ${m} ${w}
|
|
32
|
+
`),u+=y.output,c=c||y.differs}}return{output:u,differs:c}}var se={name:"diff",async execute(t,o){if(O(t))return A(Z);let n=q("diff",t,ee);if(!n.ok)return n.error;let e=n.result.flags;if(e.version)return{stdout:`diff (just-bash)
|
|
33
|
+
`,stderr:"",exitCode:0};if(Number(e.normal)+Number(e.unified)+Number(e.context)>1)return{stdout:"",stderr:`diff: conflicting output style options
|
|
34
|
+
diff: Try 'diff --help' for more information.
|
|
35
|
+
`,exitCode:2};let s="diff -r";e.unified&&(s+="u"),e.context&&(s+="c"),e.newFile&&(s+="N"),e.ignoreCase&&(s+="i"),e.brief&&(s+="q");let f={unified:e.unified,context:e.context,brief:e.brief,reportSame:e.reportSame,ignoreCase:e.ignoreCase,newFile:e.newFile,headerPrefix:s},a=n.result.positional;if(a.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
36
|
+
`,exitCode:2};let[r,u]=a;if(e.recursive){let C=await J(o,r),d=await J(o,u);if(C?.isFile&&d?.isDirectory){let l=`${u}/${r.split("/").pop()}`,p;try{p=await F(o,r)}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
37
|
+
`,exitCode:2}}let m;try{m=await F(o,l)}catch{if(f.newFile)m="";else return{stdout:"",stderr:`diff: ${l}: No such file or directory
|
|
38
|
+
`,exitCode:2}}let w=N(r,l,p,m,f);return{stdout:w.output,stderr:"",exitCode:w.differs?1:0}}if(C?.isDirectory&&d?.isFile){let l=`${r}/${u.split("/").pop()}`,p;try{p=await F(o,l)}catch{if(f.newFile)p="";else return{stdout:"",stderr:`diff: ${l}: No such file or directory
|
|
39
|
+
`,exitCode:2}}let m;try{m=await F(o,u)}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
|
|
40
|
+
`,exitCode:2}}let w=N(l,u,p,m,f);return{stdout:w.output,stderr:"",exitCode:w.differs?1:0}}if(!C||!d)return{stdout:"",stderr:`diff: ${C?u:r}: No such file or directory
|
|
41
|
+
`,exitCode:2};if(C.isDirectory&&d.isDirectory){let l=await Q(r,u,o,f);return{stdout:l.output,stderr:"",exitCode:l.differs?1:0}}}let c,h;try{c=r==="-"?x(o.stdin):await F(o,r)}catch{if(f.newFile)c="";else return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
42
|
+
`,exitCode:2}}try{h=u==="-"?x(o.stdin):await F(o,u)}catch{if(f.newFile)h="";else return{stdout:"",stderr:`diff: ${u}: No such file or directory
|
|
43
|
+
`,exitCode:2}}let g=N(r,u,c,h,f);return{stdout:g.output,stderr:"",exitCode:g.differs?1:0}}},fe={name:"diff",flags:[{flag:"--normal",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-N",type:"boolean"}],needsArgs:!0,minArgs:2};export{se as a,fe as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a as W}from"./chunk-
|
|
2
|
+
import{a as W}from"./chunk-6IA4DXG2.js";import{c as $}from"./chunk-BKUWXPEM.js";import{b as C}from"./chunk-ZBUZKIPX.js";import{a as V}from"./chunk-S6DNKKUL.js";import{d as I}from"./chunk-GN6CQ3J4.js";import{a as B,b}from"./chunk-FOCWZZDE.js";import{a as x}from"./chunk-W5DWRFSU.js";import{a as N,b as R}from"./chunk-QAYAQNCG.js";import{existsSync as ce}from"node:fs";import{dirname as de,join as T,sep as Q}from"node:path";import{fileURLToPath as me}from"node:url";import{Worker as he}from"node:worker_threads";import pe from"sql.js";function K(e,t){return e==null?Buffer.byteLength(t,"utf8"):e instanceof Uint8Array||Buffer.isBuffer(e)?e.byteLength:Buffer.byteLength(String(e),"utf8")}function X(e,t,r){let n=r.maxOutputSize??Number.MAX_SAFE_INTEGER,s=Buffer.byteLength(r.separator,"utf8");s+=Buffer.byteLength(r.newline,"utf8");for(let a of e)s+=Buffer.byteLength(a,"utf8");for(let a of t){s+=a.length*16;for(let i of a)s+=K(i,r.nullValue);if(s>n)break}let o=s*8+(t.length+3)*(e.length+3)*16;if(!Number.isSafeInteger(o)||o>n)throw new Error(`formatted output exceeds ${n} byte limit`);return n}function _(e,t,r){let n=X(e,t,r),s;switch(r.mode){case"list":s=Y(e,t,r);break;case"csv":s=Z(e,t,r);break;case"json":s=te(e,t);break;case"line":s=re(e,t,r);break;case"column":s=ne(e,t,r);break;case"table":s=se(e,t,r);break;case"markdown":s=oe(e,t,r);break;case"tabs":s=ie(e,t,r);break;case"box":s=ae(e,t,r);break;case"quote":s=le(e,t,r);break;case"html":s=fe(e,t,r);break;case"ascii":s=ue(e,t,r);break}if(Buffer.byteLength(s,"utf8")>n)throw new Error(`formatted output exceeds ${n} byte limit`);return s}function m(e,t){return e==null?t:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function Y(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.join(r.separator));for(let s of t)n.push(s.map(o=>m(o,r.nullValue)).join(r.separator));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function Z(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.map(v).join(","));for(let s of t)n.push(s.map(o=>v(m(o,r.nullValue))).join(","));return n.length>0?`${n.join(`
|
|
3
3
|
`)}
|
|
4
4
|
`:""}function v(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
|
|
5
5
|
`)?`"${e.replace(/"/g,'""')}"`:e}function F(e){return e.toPrecision(17).replace(/\.?0+$/,"")}function ee(e){return e===null?"null":typeof e=="number"?Number.isInteger(e)?String(e):F(e):JSON.stringify(e)}function te(e,t){return t.length===0?"":`[${t.map(n=>`{${e.map((o,a)=>`${JSON.stringify(o)}:${ee(n[a])}`).join(",")}}`).join(`,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{b as a}from"./chunk-ZBUZKIPX.js";var r=globalThis.setTimeout.bind(globalThis),l=globalThis.clearTimeout.bind(globalThis),T=globalThis.setInterval.bind(globalThis),f=globalThis.clearInterval.bind(globalThis);function u(e){return typeof e!="function"?e:a.bindCurrentContext(e)}var b=((e,n,...i)=>r(u(e),n,...i)),d=l,I=((e,n,...i)=>r(e,n,...i)),c=2147483647;function _(e,n){if(n===Number.POSITIVE_INFINITY)return;let i=u(e),t={cleared:!1,remainingMs:Math.max(0,n),timer:void 0},o=()=>{if(t.cleared)return;let s=Math.min(t.remainingMs,c);t.timer=r(()=>{t.cleared||(t.remainingMs-=s,t.remainingMs>0?o():i())},s)};return o(),t}function g(e){e&&(e.cleared=!0,e.timer!==void 0&&l(e.timer))}export{b as a,d as b,I as c,_ as d,g as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a as p}from"./chunk-SX2HC7SO.js";import{a as n,b as l}from"./chunk-
|
|
2
|
+
import{a as p}from"./chunk-SX2HC7SO.js";import{a as n,b as l}from"./chunk-PS2RJNZZ.js";import{a as m,b as d}from"./chunk-QAYAQNCG.js";var f={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
|
|
3
3
|
s - seconds (default)
|
|
4
4
|
m - minutes
|
|
5
5
|
h - hours
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a as w}from"./chunk-SX2HC7SO.js";import{a as b}from"./chunk-BRJERIF4.js";import{a as h,b as A}from"./chunk-
|
|
2
|
+
import{a as w}from"./chunk-SX2HC7SO.js";import{a as b}from"./chunk-BRJERIF4.js";import{a as h,b as A}from"./chunk-PS2RJNZZ.js";import{a as y}from"./chunk-L2UW7DWF.js";import{a as v,b as O,c as d}from"./chunk-QAYAQNCG.js";var x={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
3
|
|
|
4
4
|
DURATION is a number with optional suffix:
|
|
5
5
|
s - seconds (default)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-E2F4A3CM.js";import"./chunk-GN6CQ3J4.js";import"./chunk-QIQMJJZ4.js";import"./chunk-QAYAQNCG.js";import"./chunk-NCUTH6QL.js";export{a as diffCommand,b as flagsForFuzzing};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{b as yr}from"./chunk-CH7SUFFO.js";import{b as Ar}from"./chunk-GRUZ4SBY.js";import{b as $r}from"./chunk-XQ2ZZFO6.js";import"./chunk-S3ENGQML.js";import"./chunk-6RK4AAB7.js";import{c as Sr}from"./chunk-
|
|
2
|
+
import{b as yr}from"./chunk-CH7SUFFO.js";import{b as Ar}from"./chunk-GRUZ4SBY.js";import{b as $r}from"./chunk-XQ2ZZFO6.js";import"./chunk-S3ENGQML.js";import"./chunk-6RK4AAB7.js";import{c as Sr}from"./chunk-H3A45X3W.js";import"./chunk-6IA4DXG2.js";import{b as wr}from"./chunk-IXFQXNL4.js";import{b as xr}from"./chunk-MQKGGNPS.js";import{b as vr}from"./chunk-2SMD2AUA.js";import{b as kr}from"./chunk-LI6PTSPD.js";import{b as qr}from"./chunk-SBBYKIYU.js";import{b as Cr}from"./chunk-4MZPEZTU.js";import{b as br}from"./chunk-XXBIOG4R.js";import{d as Ir,e as Mr,f as jr}from"./chunk-WE7BJ7YU.js";import"./chunk-WZQNMEQW.js";import{b as tr}from"./chunk-YFFU74KY.js";import{b as lr}from"./chunk-R2FBRMDU.js";import{b as ur}from"./chunk-HXWB4Z5X.js";import{b as pr}from"./chunk-LGIJSCWH.js";import{b as er}from"./chunk-ANCQ4SCV.js";import{b as dr}from"./chunk-FT6ODGOU.js";import{b as cr}from"./chunk-OQ7C4FYO.js";import"./chunk-2KNTH3KH.js";import{b as hr}from"./chunk-5EI7WSRV.js";import{c as or,d as ar}from"./chunk-HDRAUQK2.js";import{b as sr}from"./chunk-7EUWTCWK.js";import{c as ir,d as gr}from"./chunk-EJFBIRMD.js";import{b as mr}from"./chunk-DDPD7SIB.js";import"./chunk-35MBA3VY.js";import{b as Fr}from"./chunk-PCPW54JH.js";import{b as zr}from"./chunk-E2F4A3CM.js";import{b as fr}from"./chunk-Q4JSJ3KQ.js";import{b as nr}from"./chunk-TLPMB3FO.js";import"./chunk-SX2HC7SO.js";import{b as R}from"./chunk-ZDPFA4L3.js";import{b as U}from"./chunk-FX4RBUYU.js";import{b as V}from"./chunk-7AISL3XV.js";import{b as W}from"./chunk-FSKXIFYT.js";import{c as X,d as Y}from"./chunk-A4R2GWRF.js";import{c as Z,d as _}from"./chunk-FHC24QSK.js";import{b as N}from"./chunk-UIJUTQPH.js";import{b as rr}from"./chunk-QHDBQA5N.js";import{b as G}from"./chunk-3WASQYTF.js";import{b as H}from"./chunk-2VWG4LDT.js";import{b as J}from"./chunk-7O2RDO2R.js";import{b as K}from"./chunk-6HO6HX7V.js";import{b as L}from"./chunk-EZNS4GF7.js";import{b as O}from"./chunk-HRIJVWZS.js";import{b as P}from"./chunk-LSLPJOYM.js";import{b as Q}from"./chunk-ATGOUOX2.js";import{b as y}from"./chunk-ROAWFE6V.js";import{b as A}from"./chunk-6WGIZV3E.js";import{b as $}from"./chunk-QJ7OXJAZ.js";import{b as S}from"./chunk-6QF3PCMO.js";import{b as T}from"./chunk-4MJ7VJG4.js";import{b as B}from"./chunk-LVDUF74R.js";import{b as D}from"./chunk-ASE6AYV3.js";import{b as E}from"./chunk-Y62SXZKJ.js";import{b as w}from"./chunk-DVSA72LH.js";import{b as x}from"./chunk-44YCJWNC.js";import{b as v}from"./chunk-U4K5ZDWK.js";import"./chunk-TDD4NFYE.js";import{d as k,e as q,f as C}from"./chunk-Y6JBSHCM.js";import"./chunk-U57DSHID.js";import{b}from"./chunk-45QZRGYF.js";import"./chunk-UUIYAOD4.js";import"./chunk-O452S4KX.js";import{b as I}from"./chunk-6BSOPPZH.js";import{b as M}from"./chunk-BLPYR4TN.js";import{b as j}from"./chunk-ZT3WF5R7.js";import{b as t}from"./chunk-LRFR25IP.js";import{b as l}from"./chunk-3OBCZP7T.js";import{b as u}from"./chunk-RWQWFXMH.js";import{b as p}from"./chunk-3CIDHL5V.js";import{b as e}from"./chunk-SE23TEGG.js";import{b as d}from"./chunk-SHKOQWO4.js";import{b as c}from"./chunk-6QAM55HM.js";import{b as h}from"./chunk-SIOONII3.js";import"./chunk-QJFYYEFV.js";import"./chunk-BRJERIF4.js";import"./chunk-KIGPB52X.js";import"./chunk-PS2RJNZZ.js";import"./chunk-SGX4WOAM.js";import"./chunk-L2UW7DWF.js";import"./chunk-DLL7UR66.js";import"./chunk-BKUWXPEM.js";import"./chunk-4KZT23KR.js";import{b as i}from"./chunk-AGH5UJJI.js";import{b as g}from"./chunk-P57S6Z6R.js";import"./chunk-YEYSCLSJ.js";import"./chunk-AYSZ5MAE.js";import"./chunk-ZBUZKIPX.js";import{b as m}from"./chunk-HP7HWZ2S.js";import"./chunk-ICLA3MUR.js";import"./chunk-57LGFT4S.js";import{b as F}from"./chunk-MWL2I5BV.js";import"./chunk-FTET43KM.js";import"./chunk-STHBFACM.js";import{b as z}from"./chunk-A257L6QO.js";import{b as f}from"./chunk-HCKTU6IR.js";import"./chunk-S6DNKKUL.js";import"./chunk-4CC3OZPU.js";import"./chunk-TVCZIH6M.js";import"./chunk-GN6CQ3J4.js";import"./chunk-T5ZEIOJ3.js";import"./chunk-FOCWZZDE.js";import"./chunk-QIQMJJZ4.js";import{b as n}from"./chunk-FZRQOL3C.js";import"./chunk-W5DWRFSU.js";import"./chunk-QAYAQNCG.js";import"./chunk-NCUTH6QL.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{a as B,b as A}from"./chunk-BS6EJR2R.js";import{a as q}from"./chunk-6IA4DXG2.js";import"./chunk-WNH3HOQA.js";import"./chunk-KIGPB52X.js";import{b as v,c as j}from"./chunk-PS2RJNZZ.js";import"./chunk-L2UW7DWF.js";import{a as F}from"./chunk-DLL7UR66.js";import{b as C}from"./chunk-ZBUZKIPX.js";import{d as E}from"./chunk-GN6CQ3J4.js";import"./chunk-T5ZEIOJ3.js";import{a as W,b as h}from"./chunk-FOCWZZDE.js";import{a as S}from"./chunk-W5DWRFSU.js";import{b as M}from"./chunk-QAYAQNCG.js";import"./chunk-NCUTH6QL.js";import{AsyncLocalStorage as J}from"node:async_hooks";import{fileURLToPath as H}from"node:url";import{Worker as L}from"node:worker_threads";var O=new J,P=`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 by default; configurable via maxJsTimeoutMs
|
|
86
|
+
Engine: QuickJS (compiled to WebAssembly)
|
|
87
|
+
`;function N(r){let e={code:null,scriptFile:null,showVersion:!1,scriptArgs:[],isModule:!1,stripTypes:!1};if(r.length===0)return e;for(let t=0;t<r.length;t++){let s=r[t];if(s==="-m"||s==="--module"){e.isModule=!0;continue}if(s==="--strip-types"){e.stripTypes=!0;continue}if(s==="-c")return t+1>=r.length?{stdout:"",stderr:`js-exec: option requires an argument -- 'c'
|
|
88
|
+
`,exitCode:2}:(e.code=r[t+1],e.scriptArgs=r.slice(t+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 t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)),e;if(!s.startsWith("-"))return e.scriptFile=s,e.scriptArgs=r.slice(t+1),e}return e}var l=null,y=null,c=[],n=null,x=null,U=1e3,R=5e3;function fe(r){R=r}function pe(){return l!==null}function _(r,e,t){r.controller.close();let s=!1,o=()=>{if(!s&&(s=!0,v(i),n===r)){x="worker termination was not acknowledged";for(let a of c)a.bridgeHandler.stop(),a.resolve({success:!1,error:x});c.length=0,r.resolve(t)}},u=()=>{s||(s=!0,v(i),n===r&&(r.resolve(t),n=null,g()))},i=j(()=>{o()},U);r.controller.terminate(e).then(a=>a?u():o(),o)}function me(){y&&(v(y),y=null),n?.bridgeHandler.stop(),n=null;for(let e of c)e.bridgeHandler.stop();c.length=0;let r=l;l=null,r&&r.terminate(),x=null}var D=H(new URL("./js-exec-worker.js",import.meta.url));function g(){if(n||c.length===0)return;let r=c.shift();if(!r)return;n=r;let e=null;try{e=V(),e.postMessage(r.input)}catch(t){r.bridgeHandler.stop();let s={success:!1,error:h(S(t))},o=e??l;l===o&&(l=null),o?_(r,o,s):(r.resolve(s),n===r&&(n=null),g())}}function $(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"}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,type:t.type==="initialization-failure"?"initialization-failure":void 0,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function V(){if(y&&(v(y),y=null),l)return l;let r=C.runTrusted(()=>new L(D));return l=r,r.on("message",e=>{if(l===r){if(n){let t;try{n.controller.assertMessageSize(e,"response"),t=$(e,n.input.protocolToken)}catch(s){t={success:!1,error:h(S(s))}}if(t.type==="initialization-failure"){x=t.error??"Worker initialization failed",n.bridgeHandler.stop(),n.resolve(t),n=null;for(let s of c)s.bridgeHandler.stop(),s.resolve({success:!1,type:"initialization-failure",error:x});c.length=0,l=null,r.terminate();return}n.resolve(t),n=null}c.length>0?g():Q()}}),r.on("error",e=>{if(l===r){if(n){let t=h(S(e));n.resolve({success:!1,error:t}),n=null}for(let t of c)t.resolve({success:!1,error:"Worker crashed"});c.length=0,l=null}}),r.on("exit",()=>{l===r&&(l=null,n&&(n.resolve({success:!1,error:"Worker exited unexpectedly"}),n=null),c.length>0&&g())}),r}function Q(){y=j(()=>{l&&!n&&c.length===0&&(l.terminate(),l=null)},R)}async function G(r,e,t,s=[],o,u,i){return O.getStore()?{stdout:"",stderr:`js-exec: recursive invocation is not supported
|
|
90
|
+
`,exitCode:1}:Y(r,e,t,s,o,u,i)}async function K(r,e,t,s){let o,u=new Promise(d=>{o=d}),i={input:r,bridgeHandler:e,resolve:()=>{},controller:s};s.assertMessageSize({...r,sharedBuffer:void 0},"request");let a=d=>{e.stop();let f={success:!1,error:d==="abort"?i.controller.abortMessage():i.controller.timeoutMessage()};if(n===i){let p=l;l=null,p?_(i,p,f):(i.resolve(f),n=null,g())}else{let p=c.indexOf(i);p!==-1&&c.splice(p,1),i.resolve(f),n||g()}};if(i.resolve=d=>{i.controller.close(),o(d)},i.controller.arm(a),!i.controller.isCanceled){c.push(i);try{g()}catch(d){let f=c.indexOf(i);throw f!==-1&&c.splice(f,1),i.controller.close(),d}}let[m,k]=await Promise.all([e.run(t),u.catch(d=>({success:!1,error:h(S(d))}))]);return{bridgeOutput:m,workerResult:k}}function X(r){return r.limits.maxJsTimeoutMs}async function Y(r,e,t,s=[],o,u,i){if(x!==null)return{stdout:"",stderr:`js-exec: ${h(x)}
|
|
91
|
+
`,exitCode:1};let a=B(),m=e.exec,k=m?(b,I)=>O.run(!0,()=>m(b,I)):void 0,d=new A(a,e.fs,e.cwd,"js-exec",e.fetch,e.limits.maxOutputSize,k,e.invokeTool),f=X(e),p=new q({commandName:"js-exec",timeoutMs:f,signal:e.signal,maxMessageBytes:e.limits.maxWorkerMessageBytes}),z={protocolToken:p.protocolToken,sharedBuffer:a,jsCode:r,cwd:e.cwd,env:F(e.env),args:s,scriptPath:t,bootstrapCode:o,isModule:u,stripTypes:i,timeoutMs:f,memoryBytes:e.limits.maxJsMemoryBytes,hasInvokeTool:e.invokeTool!==void 0},{bridgeOutput:T,workerResult:w}=await K(z,d,f,p);if(!w.success&&w.error){let b=w.error===p.timeoutMessage()||w.error===p.abortMessage();return{stdout:T.stdout,stderr:`${T.stderr}js-exec: ${h(w.error)}
|
|
92
|
+
`,exitCode:T.exitCode||(b?124:1)}}return{...T}}var he={name:"js-exec",async execute(r,e){if(M(r))return{stdout:P,stderr:"",exitCode:0};let t=N(r);if("exitCode"in t)return t;if(t.showVersion)return{stdout:`QuickJS (quickjs-emscripten)
|
|
93
|
+
`,stderr:"",exitCode:0};let s,o;if(t.code!==null)s=t.code,o="-c";else if(t.scriptFile!==null){let m=e.fs.resolvePath(e.cwd,t.scriptFile);if(!await e.fs.exists(m))return{stdout:"",stderr:`js-exec: can't open file '${t.scriptFile}': No such file or directory
|
|
94
|
+
`,exitCode:2};try{s=await e.fs.readFile(m),o=m}catch(k){return{stdout:"",stderr:`js-exec: can't open file '${t.scriptFile}': ${W(k.message)}
|
|
95
|
+
`,exitCode:2}}}else if(E(e.stdin).trim())s=E(e.stdin),o="<stdin>";else return{stdout:"",stderr:`js-exec: no input provided (use -c CODE or provide a script file)
|
|
96
|
+
`,exitCode:2};let u=t.isModule,i=t.stripTypes;o&&o!=="-c"&&o!=="<stdin>"&&((o.endsWith(".mjs")||o.endsWith(".mts")||o.endsWith(".ts"))&&(u=!0),(o.endsWith(".ts")||o.endsWith(".mts"))&&(i=!0)),!u&&/\bawait\s+[\w([`]/.test(s)&&(u=!0);let a=e.jsBootstrapCode;return G(s,e,o,t.scriptArgs,a,u,i)}},ye={name:"node",async execute(){return{stdout:"",stderr:`node: this sandbox uses js-exec instead of node
|
|
97
|
+
|
|
98
|
+
${P}`,exitCode:1}}};export{pe as _hasSharedJsExecWorkerForTests,me as _resetJsExecWorkerForTests,fe as _setJsExecWorkerIdleTimeoutMsForTests,he as jsExecCommand,ye as nodeStubCommand};
|