just-bash 2.14.1 → 2.14.2

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.
Files changed (28) hide show
  1. package/dist/bin/chunks/chunk-NTW6IA45.js +2 -0
  2. package/dist/bin/chunks/{chunk-3KAVXQP4.js → chunk-XXCTETRW.js} +2 -2
  3. package/dist/bin/{shell/chunks/curl-SRTMGOVV.js → chunks/curl-2DCNBIKJ.js} +8 -8
  4. package/dist/bin/chunks/{js-exec-BDQGEAU6.js → js-exec-CAD5RWEY.js} +1 -1
  5. package/dist/bin/chunks/js-exec-worker.js +11 -1
  6. package/dist/bin/{shell/chunks/python3-KFZH67GD.js → chunks/python3-3423HR2R.js} +1 -1
  7. package/dist/bin/chunks/worker.js +20 -2
  8. package/dist/bin/just-bash.js +262 -262
  9. package/dist/bin/shell/chunks/chunk-NTW6IA45.js +2 -0
  10. package/dist/bin/shell/chunks/{chunk-3KAVXQP4.js → chunk-XXCTETRW.js} +2 -2
  11. package/dist/bin/{chunks/curl-SRTMGOVV.js → shell/chunks/curl-2DCNBIKJ.js} +8 -8
  12. package/dist/bin/shell/chunks/{js-exec-HPXZV7UJ.js → js-exec-DYEFS64P.js} +1 -1
  13. package/dist/bin/{chunks/python3-VCIXXAXF.js → shell/chunks/python3-D3QLNTTN.js} +1 -1
  14. package/dist/bin/shell/shell.js +94 -94
  15. package/dist/browser.d.ts +1 -0
  16. package/dist/bundle/browser.js +568 -568
  17. package/dist/bundle/chunks/{chunk-S4EYC6T6.js → chunk-I57KEIP3.js} +2 -2
  18. package/dist/bundle/chunks/chunk-R6VWJ2ZL.js +1 -0
  19. package/dist/bundle/chunks/{curl-COE4TZE6.js → curl-47BFPSFW.js} +8 -8
  20. package/dist/bundle/chunks/{js-exec-4CW5N6RM.js → js-exec-M6UR76J5.js} +1 -1
  21. package/dist/bundle/chunks/js-exec-worker.js +11 -1
  22. package/dist/bundle/chunks/{python3-SG3DOKBZ.js → python3-AUFTPCU6.js} +1 -1
  23. package/dist/bundle/chunks/worker.js +20 -2
  24. package/dist/bundle/index.cjs +654 -654
  25. package/dist/bundle/index.js +166 -166
  26. package/dist/commands/worker-bridge/sync-backend.d.ts +1 -0
  27. package/dist/network/types.d.ts +2 -1
  28. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{a as w,b as n}from"./chunk-CWQS3NFK.js";import{a as T,b as g}from"./chunk-A5O5YHGN.js";import{a as F}from"./chunk-IPJHKYVM.js";import{a as m}from"./chunk-3THT3N7L.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_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200,EXEC_COMMAND:300},a={PENDING:0,READY:1,SUCCESS:2,ERROR:3},u={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},s={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},E={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:1048576,TOTAL:1052704},S={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},l={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function _(){return new w(E.TOTAL)}var R=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return n.load(this.int32View,s.OP_CODE/4)}setOpCode(t){n.store(this.int32View,s.OP_CODE/4,t)}getStatus(){return n.load(this.int32View,s.STATUS/4)}setStatus(t){n.store(this.int32View,s.STATUS/4,t)}getPathLength(){return n.load(this.int32View,s.PATH_LENGTH/4)}setPathLength(t){n.store(this.int32View,s.PATH_LENGTH/4,t)}getDataLength(){return n.load(this.int32View,s.DATA_LENGTH/4)}setDataLength(t){n.store(this.int32View,s.DATA_LENGTH/4,t)}getResultLength(){return n.load(this.int32View,s.RESULT_LENGTH/4)}setResultLength(t){n.store(this.int32View,s.RESULT_LENGTH/4,t)}getErrorCode(){return n.load(this.int32View,s.ERROR_CODE/4)}setErrorCode(t){n.store(this.int32View,s.ERROR_CODE/4,t)}getFlags(){return n.load(this.int32View,s.FLAGS/4)}setFlags(t){n.store(this.int32View,s.FLAGS/4,t)}getMode(){return n.load(this.int32View,s.MODE/4)}setMode(t){n.store(this.int32View,s.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(s.PATH_BUFFER,s.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>E.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${E.PATH_BUFFER}`);this.uint8View.set(e,s.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(s.DATA_BUFFER,s.DATA_BUFFER+t)}setData(t){if(t.length>E.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,s.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(s.DATA_BUFFER,s.DATA_BUFFER+t)}setResult(t){if(t.length>E.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,s.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[s.DATA_BUFFER+l.IS_FILE]=t.isFile?1:0,this.uint8View[s.DATA_BUFFER+l.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[s.DATA_BUFFER+l.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(s.DATA_BUFFER+l.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(s.DATA_BUFFER+l.SIZE,e,!0),this.dataView.setFloat64(s.DATA_BUFFER+l.MTIME,t.mtime.getTime(),!0),this.setResultLength(l.TOTAL)}decodeStat(){return{isFile:this.uint8View[s.DATA_BUFFER+l.IS_FILE]===1,isDirectory:this.uint8View[s.DATA_BUFFER+l.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[s.DATA_BUFFER+l.IS_SYMLINK]===1,mode:this.dataView.getInt32(s.DATA_BUFFER+l.MODE,!0),size:this.dataView.getFloat64(s.DATA_BUFFER+l.SIZE,!0),mtime:new Date(this.dataView.getFloat64(s.DATA_BUFFER+l.MTIME,!0))}}waitForReady(t){return n.wait(this.int32View,s.STATUS/4,a.PENDING,t)}waitForReadyAsync(t){return n.waitAsync(this.int32View,s.STATUS/4,a.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let r=this.getStatus();if(r===a.READY)return!0;let o=Date.now()-e;if(o>=t)return!1;let i=t-o,c=n.waitAsync(this.int32View,s.STATUS/4,r,i);if(c.async&&await c.value==="timed-out")return!1}}waitForResult(t){return n.wait(this.int32View,s.STATUS/4,a.READY,t)}notify(){return n.notify(this.int32View,s.STATUS/4)}reset(){this.setOpCode(h.NOOP),this.setStatus(a.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(u.NONE),this.setFlags(S.NONE),this.setMode(0)}};var A=class{fs;cwd;commandName;secureFetch;maxOutputSize;exec;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;startTime=0;timeoutMs=0;constructor(t,e,r,o,i=void 0,c=0,d=void 0){this.fs=e,this.cwd=r,this.commandName=o,this.secureFetch=i,this.maxOutputSize=c,this.exec=d,this.protocol=new R(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+=`
1
+ import{b as A}from"./chunk-R6VWJ2ZL.js";import{a as w,b as n}from"./chunk-CWQS3NFK.js";import{a as T,b as g}from"./chunk-A5O5YHGN.js";import{a as F}from"./chunk-IPJHKYVM.js";import{a as m}from"./chunk-3THT3N7L.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_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200,EXEC_COMMAND:300},a={PENDING:0,READY:1,SUCCESS:2,ERROR:3},u={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},s={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},E={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:1048576,TOTAL:1052704},S={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},l={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function f(){return new w(E.TOTAL)}var R=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return n.load(this.int32View,s.OP_CODE/4)}setOpCode(t){n.store(this.int32View,s.OP_CODE/4,t)}getStatus(){return n.load(this.int32View,s.STATUS/4)}setStatus(t){n.store(this.int32View,s.STATUS/4,t)}getPathLength(){return n.load(this.int32View,s.PATH_LENGTH/4)}setPathLength(t){n.store(this.int32View,s.PATH_LENGTH/4,t)}getDataLength(){return n.load(this.int32View,s.DATA_LENGTH/4)}setDataLength(t){n.store(this.int32View,s.DATA_LENGTH/4,t)}getResultLength(){return n.load(this.int32View,s.RESULT_LENGTH/4)}setResultLength(t){n.store(this.int32View,s.RESULT_LENGTH/4,t)}getErrorCode(){return n.load(this.int32View,s.ERROR_CODE/4)}setErrorCode(t){n.store(this.int32View,s.ERROR_CODE/4,t)}getFlags(){return n.load(this.int32View,s.FLAGS/4)}setFlags(t){n.store(this.int32View,s.FLAGS/4,t)}getMode(){return n.load(this.int32View,s.MODE/4)}setMode(t){n.store(this.int32View,s.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(s.PATH_BUFFER,s.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>E.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${E.PATH_BUFFER}`);this.uint8View.set(e,s.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(s.DATA_BUFFER,s.DATA_BUFFER+t)}setData(t){if(t.length>E.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,s.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(s.DATA_BUFFER,s.DATA_BUFFER+t)}setResult(t){if(t.length>E.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,s.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[s.DATA_BUFFER+l.IS_FILE]=t.isFile?1:0,this.uint8View[s.DATA_BUFFER+l.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[s.DATA_BUFFER+l.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(s.DATA_BUFFER+l.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(s.DATA_BUFFER+l.SIZE,e,!0),this.dataView.setFloat64(s.DATA_BUFFER+l.MTIME,t.mtime.getTime(),!0),this.setResultLength(l.TOTAL)}decodeStat(){return{isFile:this.uint8View[s.DATA_BUFFER+l.IS_FILE]===1,isDirectory:this.uint8View[s.DATA_BUFFER+l.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[s.DATA_BUFFER+l.IS_SYMLINK]===1,mode:this.dataView.getInt32(s.DATA_BUFFER+l.MODE,!0),size:this.dataView.getFloat64(s.DATA_BUFFER+l.SIZE,!0),mtime:new Date(this.dataView.getFloat64(s.DATA_BUFFER+l.MTIME,!0))}}waitForReady(t){return n.wait(this.int32View,s.STATUS/4,a.PENDING,t)}waitForReadyAsync(t){return n.waitAsync(this.int32View,s.STATUS/4,a.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let r=this.getStatus();if(r===a.READY)return!0;let o=Date.now()-e;if(o>=t)return!1;let i=t-o,c=n.waitAsync(this.int32View,s.STATUS/4,r,i);if(c.async&&await c.value==="timed-out")return!1}}waitForResult(t){return n.wait(this.int32View,s.STATUS/4,a.READY,t)}notify(){return n.notify(this.int32View,s.STATUS/4)}reset(){this.setOpCode(h.NOOP),this.setStatus(a.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(u.NONE),this.setFlags(S.NONE),this.setMode(0)}};var O=class{fs;cwd;commandName;secureFetch;maxOutputSize;exec;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;startTime=0;timeoutMs=0;constructor(t,e,r,o,i=void 0,c=0,d=void 0){this.fs=e,this.cwd=r,this.commandName=o,this.secureFetch=i,this.maxOutputSize=c,this.exec=d,this.protocol=new R(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+=`
2
2
  ${this.commandName}: execution timeout exceeded
3
3
  `,Promise.reject(new Error("Operation timed out"));let r=t();return new Promise((o,i)=>{let c=T(()=>{this.running=!1,this.output.exitCode=124,this.output.stderr+=`
4
4
  ${this.commandName}: execution timeout exceeded
@@ -7,4 +7,4 @@ ${this.commandName}: execution timeout exceeded
7
7
  `,this.output.exitCode=124;break}let r=this.remainingMs();if(!await this.protocol.waitUntilReady(r)){this.output.stderr+=`
8
8
  ${this.commandName}: execution timeout exceeded
9
9
  `,this.output.exitCode=124;break}let i=this.protocol.getOpCode();await this.handleOperation(i),this.protocol.notify()}return this.output}stop(){this.running=!1}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.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;default:this.protocol.setErrorCode(u.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(r){this.setErrorFromException(r)}}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()),r=(this.protocol.getFlags()&S.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:r}),this.protocol.setStatus(a.SUCCESS)}catch(o){this.setErrorFromException(o)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),r=(e&S.RECURSIVE)!==0,o=(e&S.FORCE)!==0;try{await this.fs.rm(t,{recursive:r,force:o}),this.protocol.setStatus(a.SUCCESS)}catch(i){this.setErrorFromException(i)}}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(r){this.setErrorFromException(r)}}async handleSymlink(){let t=this.protocol.getPath(),e=this.protocol.getDataAsString(),r=this.resolvePath(t);try{await this.fs.symlink(e,r),this.protocol.setStatus(a.SUCCESS)}catch(o){this.setErrorFromException(o)}}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(r){this.setErrorFromException(r)}}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)}}async handleRename(){let t=this.resolvePath(this.protocol.getPath()),e=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.mv(t,e),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleCopyFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.cp(t,e),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}handleWriteStdout(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(u.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(u.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=`${this.commandName}: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
10
- `,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let o=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(o>0)if(this.output.stdout.length>=o)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-o);else{let i=o-this.output.stdout.length;this.output.stdout="",i>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-i)}this.output.stderr+=e}async handleHttpRequest(){let t=this.secureFetch;if(!t){this.protocol.setErrorCode(u.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(a.ERROR);return}let e=this.protocol.getPath(),r=this.protocol.getDataAsString();try{let o=r?JSON.parse(r):{},i=this.remainingMs(),c=await this.raceDeadline(()=>t(e,{method:o.method,headers:o.headers,body:o.body,timeoutMs:i})),d=JSON.stringify({status:c.status,statusText:c.statusText,headers:c.headers,body:c.body,url:c.url});this.protocol.setResultFromString(d),this.protocol.setStatus(a.SUCCESS)}catch(o){let i=m(o instanceof Error?o.message:String(o));this.protocol.setErrorCode(u.NETWORK_ERROR),this.protocol.setResultFromString(i),this.protocol.setStatus(a.ERROR)}}async handleExecCommand(){let t=this.exec;if(!t){this.protocol.setErrorCode(u.IO_ERROR),this.protocol.setResultFromString("Command execution not available in this context."),this.protocol.setStatus(a.ERROR);return}let e=this.protocol.getPath(),r=this.protocol.getDataAsString(),o=new AbortController;try{let i={cwd:this.cwd,signal:o.signal};if(r){let p=JSON.parse(r);p.stdin&&(i.stdin=p.stdin),p.args&&Array.isArray(p.args)&&(i.args=p.args.map(D=>String(D)),e=F([e]))}let c=await this.raceDeadline(()=>t(e,i)),d=JSON.stringify({stdout:c.stdout,stderr:c.stderr,exitCode:c.exitCode});this.protocol.setResultFromString(d),this.protocol.setStatus(a.SUCCESS)}catch(i){o.abort();let c=i instanceof Error?i.message:String(i);this.protocol.setErrorCode(u.IO_ERROR),this.protocol.setResultFromString(c),this.protocol.setStatus(a.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),r=m(e),o=u.IO_ERROR,i=e.toLowerCase();i.includes("no such file")||i.includes("not found")||i.includes("enoent")?o=u.NOT_FOUND:i.includes("is a directory")||i.includes("eisdir")?o=u.IS_DIRECTORY:i.includes("not a directory")||i.includes("enotdir")?o=u.NOT_DIRECTORY:i.includes("already exists")||i.includes("eexist")?o=u.EXISTS:(i.includes("permission")||i.includes("eperm")||i.includes("eacces"))&&(o=u.PERMISSION_DENIED),this.protocol.setErrorCode(o),this.protocol.setResultFromString(r),this.protocol.setStatus(a.ERROR)}};export{_ as a,A as b};
10
+ `,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let o=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(o>0)if(this.output.stdout.length>=o)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-o);else{let i=o-this.output.stdout.length;this.output.stdout="",i>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-i)}this.output.stderr+=e}async handleHttpRequest(){let t=this.secureFetch;if(!t){this.protocol.setErrorCode(u.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(a.ERROR);return}let e=this.protocol.getPath(),r=this.protocol.getDataAsString();try{let o=r?JSON.parse(r):{},i=this.remainingMs(),c=await this.raceDeadline(()=>t(e,{method:o.method,headers:o.headers,body:o.body,timeoutMs:i})),d=JSON.stringify({status:c.status,statusText:c.statusText,headers:c.headers,bodyBase64:A(c.body,"base64"),url:c.url});this.protocol.setResultFromString(d),this.protocol.setStatus(a.SUCCESS)}catch(o){let i=m(o instanceof Error?o.message:String(o));this.protocol.setErrorCode(u.NETWORK_ERROR),this.protocol.setResultFromString(i),this.protocol.setStatus(a.ERROR)}}async handleExecCommand(){let t=this.exec;if(!t){this.protocol.setErrorCode(u.IO_ERROR),this.protocol.setResultFromString("Command execution not available in this context."),this.protocol.setStatus(a.ERROR);return}let e=this.protocol.getPath(),r=this.protocol.getDataAsString(),o=new AbortController;try{let i={cwd:this.cwd,signal:o.signal};if(r){let p=JSON.parse(r);p.stdin&&(i.stdin=p.stdin),p.args&&Array.isArray(p.args)&&(i.args=p.args.map(C=>String(C)),e=F([e]))}let c=await this.raceDeadline(()=>t(e,i)),d=JSON.stringify({stdout:c.stdout,stderr:c.stderr,exitCode:c.exitCode});this.protocol.setResultFromString(d),this.protocol.setStatus(a.SUCCESS)}catch(i){o.abort();let c=i instanceof Error?i.message:String(i);this.protocol.setErrorCode(u.IO_ERROR),this.protocol.setResultFromString(c),this.protocol.setStatus(a.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),r=m(e),o=u.IO_ERROR,i=e.toLowerCase();i.includes("no such file")||i.includes("not found")||i.includes("enoent")?o=u.NOT_FOUND:i.includes("is a directory")||i.includes("eisdir")?o=u.IS_DIRECTORY:i.includes("not a directory")||i.includes("enotdir")?o=u.NOT_DIRECTORY:i.includes("already exists")||i.includes("eexist")?o=u.EXISTS:(i.includes("permission")||i.includes("eperm")||i.includes("eacces"))&&(o=u.PERMISSION_DENIED),this.protocol.setErrorCode(o),this.protocol.setResultFromString(r),this.protocol.setStatus(a.ERROR)}};export{f as a,O as b};
@@ -0,0 +1 @@
1
+ var u=new TextEncoder,a=new TextDecoder;function o(r,i){if(r instanceof Uint8Array)return r;if(i==="base64")return Uint8Array.from(atob(r),t=>t.charCodeAt(0));if(i==="hex"){let t=new Uint8Array(r.length/2);for(let n=0;n<r.length;n+=2)t[n/2]=parseInt(r.slice(n,n+2),16);return t}if(i==="binary"||i==="latin1"){if(r.length<=65536)return Uint8Array.from(r,e=>e.charCodeAt(0));let n=new Uint8Array(r.length);for(let e=0;e<r.length;e++)n[e]=r.charCodeAt(e);return n}return u.encode(r)}function h(r,i){if(i==="base64"){if(typeof Buffer<"u")return Buffer.from(r).toString("base64");let t=65536,n="";for(let e=0;e<r.length;e+=t){let f=r.subarray(e,e+t);n+=String.fromCharCode(...f)}return btoa(n)}if(i==="hex")return Array.from(r).map(t=>t.toString(16).padStart(2,"0")).join("");if(i==="binary"||i==="latin1"){if(typeof Buffer<"u")return Buffer.from(r).toString(i);let t=65536;if(r.length<=t)return String.fromCharCode(...r);let n="";for(let e=0;e<r.length;e+=t){let f=r.subarray(e,e+t);n+=String.fromCharCode(...f)}return n}return a.decode(r)}function l(r){if(r!=null)return typeof r=="string"?r:r.encoding??void 0}export{o as a,h as b,l as c};
@@ -1,13 +1,13 @@
1
- import{d}from"./chunk-CWQS3NFK.js";import{a as b}from"./chunk-44UOCSGV.js";import{a as T,b as w,c as f}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";function c(s){let t=s.indexOf("=");if(t>=0){let a=s.slice(0,t),r=s.slice(t+1);return a?`${encodeURIComponent(a)}=${encodeURIComponent(r)}`:encodeURIComponent(r)}return encodeURIComponent(s)}function m(s){let t=s.indexOf("=");if(t<0)return null;let a=s.slice(0,t),r=s.slice(t+1),e,i,o=r.match(/;type=([^;]+)$/);o&&(i=o[1],r=r.slice(0,-o[0].length));let n=r.match(/;filename=([^;]+)/);return n&&(e=n[1],r=r.replace(n[0],"")),(r.startsWith("@")||r.startsWith("<"))&&(e=e??r.slice(1).split("/").pop()),{name:a,value:r,filename:e,contentType:i}}function v(s,t){let a=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let e of s){let i=e.value;if(i.startsWith("@")||i.startsWith("<")){let n=i.slice(1);i=t.get(n)??""}let o=`--${a}\r
1
+ import{b as v}from"./chunk-R6VWJ2ZL.js";import{d}from"./chunk-CWQS3NFK.js";import{a as w}from"./chunk-44UOCSGV.js";import{a as T,b,c as f}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";function c(s){let t=s.indexOf("=");if(t>=0){let a=s.slice(0,t),r=s.slice(t+1);return a?`${encodeURIComponent(a)}=${encodeURIComponent(r)}`:encodeURIComponent(r)}return encodeURIComponent(s)}function m(s){let t=s.indexOf("=");if(t<0)return null;let a=s.slice(0,t),r=s.slice(t+1),e,i,o=r.match(/;type=([^;]+)$/);o&&(i=o[1],r=r.slice(0,-o[0].length));let n=r.match(/;filename=([^;]+)/);return n&&(e=n[1],r=r.replace(n[0],"")),(r.startsWith("@")||r.startsWith("<"))&&(e=e??r.slice(1).split("/").pop()),{name:a,value:r,filename:e,contentType:i}}function F(s,t){let a=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let e of s){let i=e.value;if(i.startsWith("@")||i.startsWith("<")){let n=i.slice(1);i=t.get(n)??""}let o=`--${a}\r
2
2
  `;e.filename?(o+=`Content-Disposition: form-data; name="${e.name}"; filename="${e.filename}"\r
3
3
  `,e.contentType&&(o+=`Content-Type: ${e.contentType}\r
4
4
  `)):o+=`Content-Disposition: form-data; name="${e.name}"\r
5
5
  `,o+=`\r
6
6
  ${i}\r
7
7
  `,r.push(o)}return r.push(`--${a}--\r
8
- `),{body:r.join(""),boundary:a}}var F={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]};function O(s){let t={method:"GET",headers:new d,dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1},a=!1;for(let r=0;r<s.length;r++){let e=s[r];if(e==="-X"||e==="--request")t.method=s[++r]??"GET";else if(e.startsWith("-X"))t.method=e.slice(2);else if(e.startsWith("--request="))t.method=e.slice(10);else if(e==="-H"||e==="--header"){let i=s[++r];if(i){let o=i.indexOf(":");if(o>0){let n=i.slice(0,o).trim(),l=i.slice(o+1).trim();t.headers.append(n,l)}}}else if(e.startsWith("--header=")){let i=e.slice(9),o=i.indexOf(":");if(o>0){let n=i.slice(0,o).trim(),l=i.slice(o+1).trim();t.headers.append(n,l)}}else if(e==="-d"||e==="--data"||e==="--data-raw")t.data=s[++r]??"",a=!0;else if(e.startsWith("-d"))t.data=e.slice(2),a=!0;else if(e.startsWith("--data="))t.data=e.slice(7),a=!0;else if(e.startsWith("--data-raw="))t.data=e.slice(11),a=!0;else if(e==="--data-binary")t.data=s[++r]??"",t.dataBinary=!0,a=!0;else if(e.startsWith("--data-binary="))t.data=e.slice(14),t.dataBinary=!0,a=!0;else if(e==="--data-urlencode"){let i=s[++r]??"";t.data=(t.data?`${t.data}&`:"")+c(i),a=!0}else if(e.startsWith("--data-urlencode=")){let i=e.slice(17);t.data=(t.data?`${t.data}&`:"")+c(i),a=!0}else if(e==="-F"||e==="--form"){let i=s[++r]??"",o=m(i);o&&t.formFields.push(o),a=!0}else if(e.startsWith("--form=")){let i=e.slice(7),o=m(i);o&&t.formFields.push(o),a=!0}else if(e==="-u"||e==="--user")t.user=s[++r];else if(e.startsWith("-u"))t.user=e.slice(2);else if(e.startsWith("--user="))t.user=e.slice(7);else if(e==="-A"||e==="--user-agent")t.headers.set("User-Agent",s[++r]??"");else if(e.startsWith("-A"))t.headers.set("User-Agent",e.slice(2));else if(e.startsWith("--user-agent="))t.headers.set("User-Agent",e.slice(13));else if(e==="-e"||e==="--referer")t.headers.set("Referer",s[++r]??"");else if(e.startsWith("-e"))t.headers.set("Referer",e.slice(2));else if(e.startsWith("--referer="))t.headers.set("Referer",e.slice(10));else if(e==="-b"||e==="--cookie")t.headers.set("Cookie",s[++r]??"");else if(e.startsWith("-b"))t.headers.set("Cookie",e.slice(2));else if(e.startsWith("--cookie="))t.headers.set("Cookie",e.slice(9));else if(e==="-c"||e==="--cookie-jar")t.cookieJar=s[++r];else if(e.startsWith("--cookie-jar="))t.cookieJar=e.slice(13);else if(e==="-T"||e==="--upload-file")t.uploadFile=s[++r],t.method==="GET"&&(t.method="PUT");else if(e.startsWith("--upload-file="))t.uploadFile=e.slice(14),t.method==="GET"&&(t.method="PUT");else if(e==="-m"||e==="--max-time"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--max-time=")){let i=parseFloat(e.slice(11));!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e==="--connect-timeout"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--connect-timeout=")){let i=parseFloat(e.slice(18));!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e==="-o"||e==="--output")t.outputFile=s[++r];else if(e.startsWith("--output="))t.outputFile=e.slice(9);else if(e==="-O"||e==="--remote-name")t.useRemoteName=!0;else if(e==="-I"||e==="--head")t.headOnly=!0,t.method="HEAD";else if(e==="-i"||e==="--include")t.includeHeaders=!0;else if(e==="-s"||e==="--silent")t.silent=!0;else if(e==="-S"||e==="--show-error")t.showError=!0;else if(e==="-f"||e==="--fail")t.failSilently=!0;else if(e==="-L"||e==="--location")t.followRedirects=!0;else if(e==="--max-redirs")r++;else if(!e.startsWith("--max-redirs="))if(e==="-w"||e==="--write-out")t.writeOut=s[++r];else if(e.startsWith("--write-out="))t.writeOut=e.slice(12);else if(e==="-v"||e==="--verbose")t.verbose=!0;else{if(e.startsWith("--")&&e!=="--")return f("curl",e);if(e.startsWith("-")&&e!=="-")for(let i of e.slice(1))switch(i){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD";break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;default:return f("curl",`-${i}`)}else e.startsWith("-")||(t.url=e)}}return a&&t.method==="GET"&&(t.method="POST"),t}function h(s){return Object.entries(s).map(([t,a])=>`${t}: ${a}`).join(`\r
9
- `)}function W(s){try{return new URL(s).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function p(s,t){let a=s;return a=a.replace(/%\{http_code\}/g,String(t.status)),a=a.replace(/%\{content_type\}/g,t.headers["content-type"]||""),a=a.replace(/%\{url_effective\}/g,t.url),a=a.replace(/%\{size_download\}/g,String(t.bodyLength)),a=a.replace(/\\n/g,`
10
- `),a}async function S(s,t){if(s.uploadFile){let a=t.fs.resolvePath(t.cwd,s.uploadFile);return{body:await t.fs.readFile(a)}}if(s.formFields.length>0){let a=new Map;for(let i of s.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let o=t.fs.resolvePath(t.cwd,i.value.slice(1));try{let n=await t.fs.readFile(o);a.set(i.value.slice(1),n)}catch{a.set(i.value.slice(1),"")}}let{body:r,boundary:e}=v(s.formFields,a);return{body:r,contentType:`multipart/form-data; boundary=${e}`}}return s.data!==void 0?{body:s.data}:{}}function E(s,t){let a=new d(s.headers);if(s.user){let r=Buffer.from(s.user).toString("base64");a.set("Authorization",`Basic ${r}`)}return t&&!a.has("Content-Type")&&a.set("Content-Type",t),a}async function P(s,t,a){if(!s.cookieJar)return;let r=t["set-cookie"];if(!r)return;let e=a.fs.resolvePath(a.cwd,s.cookieJar);await a.fs.writeFile(e,r)}function H(s,t,a){let r="";if(s.verbose){r+=`> ${s.method} ${a}
8
+ `),{body:r.join(""),boundary:a}}var O={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]};function W(s){let t={method:"GET",headers:new d,dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1},a=!1;for(let r=0;r<s.length;r++){let e=s[r];if(e==="-X"||e==="--request")t.method=s[++r]??"GET";else if(e.startsWith("-X"))t.method=e.slice(2);else if(e.startsWith("--request="))t.method=e.slice(10);else if(e==="-H"||e==="--header"){let i=s[++r];if(i){let o=i.indexOf(":");if(o>0){let n=i.slice(0,o).trim(),l=i.slice(o+1).trim();t.headers.append(n,l)}}}else if(e.startsWith("--header=")){let i=e.slice(9),o=i.indexOf(":");if(o>0){let n=i.slice(0,o).trim(),l=i.slice(o+1).trim();t.headers.append(n,l)}}else if(e==="-d"||e==="--data"||e==="--data-raw")t.data=s[++r]??"",a=!0;else if(e.startsWith("-d"))t.data=e.slice(2),a=!0;else if(e.startsWith("--data="))t.data=e.slice(7),a=!0;else if(e.startsWith("--data-raw="))t.data=e.slice(11),a=!0;else if(e==="--data-binary")t.data=s[++r]??"",t.dataBinary=!0,a=!0;else if(e.startsWith("--data-binary="))t.data=e.slice(14),t.dataBinary=!0,a=!0;else if(e==="--data-urlencode"){let i=s[++r]??"";t.data=(t.data?`${t.data}&`:"")+c(i),a=!0}else if(e.startsWith("--data-urlencode=")){let i=e.slice(17);t.data=(t.data?`${t.data}&`:"")+c(i),a=!0}else if(e==="-F"||e==="--form"){let i=s[++r]??"",o=m(i);o&&t.formFields.push(o),a=!0}else if(e.startsWith("--form=")){let i=e.slice(7),o=m(i);o&&t.formFields.push(o),a=!0}else if(e==="-u"||e==="--user")t.user=s[++r];else if(e.startsWith("-u"))t.user=e.slice(2);else if(e.startsWith("--user="))t.user=e.slice(7);else if(e==="-A"||e==="--user-agent")t.headers.set("User-Agent",s[++r]??"");else if(e.startsWith("-A"))t.headers.set("User-Agent",e.slice(2));else if(e.startsWith("--user-agent="))t.headers.set("User-Agent",e.slice(13));else if(e==="-e"||e==="--referer")t.headers.set("Referer",s[++r]??"");else if(e.startsWith("-e"))t.headers.set("Referer",e.slice(2));else if(e.startsWith("--referer="))t.headers.set("Referer",e.slice(10));else if(e==="-b"||e==="--cookie")t.headers.set("Cookie",s[++r]??"");else if(e.startsWith("-b"))t.headers.set("Cookie",e.slice(2));else if(e.startsWith("--cookie="))t.headers.set("Cookie",e.slice(9));else if(e==="-c"||e==="--cookie-jar")t.cookieJar=s[++r];else if(e.startsWith("--cookie-jar="))t.cookieJar=e.slice(13);else if(e==="-T"||e==="--upload-file")t.uploadFile=s[++r],t.method==="GET"&&(t.method="PUT");else if(e.startsWith("--upload-file="))t.uploadFile=e.slice(14),t.method==="GET"&&(t.method="PUT");else if(e==="-m"||e==="--max-time"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--max-time=")){let i=parseFloat(e.slice(11));!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e==="--connect-timeout"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--connect-timeout=")){let i=parseFloat(e.slice(18));!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e==="-o"||e==="--output")t.outputFile=s[++r];else if(e.startsWith("--output="))t.outputFile=e.slice(9);else if(e==="-O"||e==="--remote-name")t.useRemoteName=!0;else if(e==="-I"||e==="--head")t.headOnly=!0,t.method="HEAD";else if(e==="-i"||e==="--include")t.includeHeaders=!0;else if(e==="-s"||e==="--silent")t.silent=!0;else if(e==="-S"||e==="--show-error")t.showError=!0;else if(e==="-f"||e==="--fail")t.failSilently=!0;else if(e==="-L"||e==="--location")t.followRedirects=!0;else if(e==="--max-redirs")r++;else if(!e.startsWith("--max-redirs="))if(e==="-w"||e==="--write-out")t.writeOut=s[++r];else if(e.startsWith("--write-out="))t.writeOut=e.slice(12);else if(e==="-v"||e==="--verbose")t.verbose=!0;else{if(e.startsWith("--")&&e!=="--")return f("curl",e);if(e.startsWith("-")&&e!=="-")for(let i of e.slice(1))switch(i){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD";break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;default:return f("curl",`-${i}`)}else e.startsWith("-")||(t.url=e)}}return a&&t.method==="GET"&&(t.method="POST"),t}function h(s){return Object.entries(s).map(([t,a])=>`${t}: ${a}`).join(`\r
9
+ `)}function S(s){try{return new URL(s).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function p(s,t){let a=s;return a=a.replace(/%\{http_code\}/g,String(t.status)),a=a.replace(/%\{content_type\}/g,t.headers["content-type"]||""),a=a.replace(/%\{url_effective\}/g,t.url),a=a.replace(/%\{size_download\}/g,String(t.bodyLength)),a=a.replace(/\\n/g,`
10
+ `),a}async function E(s,t){if(s.uploadFile){let a=t.fs.resolvePath(t.cwd,s.uploadFile);return{body:await t.fs.readFile(a)}}if(s.formFields.length>0){let a=new Map;for(let i of s.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let o=t.fs.resolvePath(t.cwd,i.value.slice(1));try{let n=await t.fs.readFile(o);a.set(i.value.slice(1),n)}catch{a.set(i.value.slice(1),"")}}let{body:r,boundary:e}=F(s.formFields,a);return{body:r,contentType:`multipart/form-data; boundary=${e}`}}return s.data!==void 0?{body:s.data}:{}}function P(s,t){let a=new d(s.headers);if(s.user){let r=Buffer.from(s.user).toString("base64");a.set("Authorization",`Basic ${r}`)}return t&&!a.has("Content-Type")&&a.set("Content-Type",t),a}async function H(s,t,a){if(!s.cookieJar)return;let r=t["set-cookie"];if(!r)return;let e=a.fs.resolvePath(a.cwd,s.cookieJar);await a.fs.writeFile(e,r)}function R(s){return v(s,"binary")}function k(s,t,a){let r="";if(s.verbose){r+=`> ${s.method} ${a}
11
11
  `;for(let[e,i]of s.headers)r+=`> ${e}: ${i}
12
12
  `;r+=`>
13
13
  `,r+=`< HTTP/1.1 ${t.status} ${t.statusText}
@@ -18,8 +18,8 @@ ${i}\r
18
18
  \r
19
19
  `),s.headOnly?s.includeHeaders||s.verbose||(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r
20
20
  `,r+=h(t.headers),r+=`\r
21
- `):r+=t.body,s.writeOut&&(r+=p(s.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),r}var q={name:"curl",async execute(s,t){if(w(s))return T(F);let a=O(s);if("exitCode"in a)return a;let r=a;if(!r.url)return{stdout:"",stderr:`curl: no URL specified
21
+ `):r+=R(t.body),s.writeOut&&(r+=p(s.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.byteLength})),r}var J={name:"curl",async execute(s,t){if(b(s))return T(O);let a=W(s);if("exitCode"in a)return a;let r=a;if(!r.url)return{stdout:"",stderr:`curl: no URL specified
22
22
  `,exitCode:2};if(!t.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
23
- `,exitCode:1};let e=r.url;e.match(/^https?:\/\//)||(e=`https://${e}`);try{let{body:i,contentType:o}=await S(r,t),n=E(r,o),l=await t.fetch(e,{method:r.method,headers:n,body:i,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs});if(await P(r,l.headers,t),r.failSilently&&l.status>=400)return{stdout:"",stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${l.status}
24
- `:"",exitCode:22};let u=H(r,l,e);if(r.outputFile||r.useRemoteName){let y=r.outputFile||W(e),$=t.fs.resolvePath(t.cwd,y);await t.fs.writeFile($,r.headOnly?"":l.body),r.verbose||(u=""),r.writeOut&&(u=p(r.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:u,stderr:"",exitCode:0}}catch(i){let o=b(i),n=1;return o.includes("Network access denied")?n=7:o.includes("HTTP method")&&o.includes("not allowed")?n=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?n=47:o.includes("aborted")&&(n=28),{stdout:"",stderr:!r.silent||r.showError?`curl: (${n}) ${o}
25
- `:"",exitCode:n}}}};export{q as curlCommand};
23
+ `,exitCode:1};let e=r.url;e.match(/^https?:\/\//)||(e=`https://${e}`);try{let{body:i,contentType:o}=await E(r,t),n=P(r,o),l=await t.fetch(e,{method:r.method,headers:n,body:i,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs});if(await H(r,l.headers,t),r.failSilently&&l.status>=400)return{stdout:"",stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${l.status}
24
+ `:"",exitCode:22};let u=k(r,l,e);if(r.outputFile||r.useRemoteName){let y=r.outputFile||S(e),$=t.fs.resolvePath(t.cwd,y);await t.fs.writeFile($,r.headOnly?"":l.body),r.verbose||(u=""),r.writeOut&&(u=p(r.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.byteLength}))}return{stdout:u,stderr:"",exitCode:0}}catch(i){let o=w(i),n=1;return o.includes("Network access denied")?n=7:o.includes("HTTP method")&&o.includes("not allowed")?n=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?n=47:o.includes("aborted")&&(n=28),{stdout:"",stderr:!r.silent||r.showError?`curl: (${n}) ${o}
25
+ `:"",exitCode:n}}}};export{J as curlCommand};
@@ -1,4 +1,4 @@
1
- import{a as A,b as P}from"./chunk-S4EYC6T6.js";import"./chunk-XHM67O4N.js";import"./chunk-CWQS3NFK.js";import{a as k,b as T}from"./chunk-A5O5YHGN.js";import"./chunk-IPJHKYVM.js";import{a as W}from"./chunk-OJDRYQWQ.js";import{b as C}from"./chunk-5QMZ5MUS.js";import{a as M,b as x}from"./chunk-3THT3N7L.js";import{a as v}from"./chunk-44UOCSGV.js";import{b as F}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import{AsyncLocalStorage as U}from"node:async_hooks";import{randomBytes as I}from"node:crypto";import{fileURLToPath as J}from"node:url";import{Worker as D}from"node:worker_threads";var N=1e4,H=6e4,B=new U,_=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
1
+ import{a as A,b as P}from"./chunk-I57KEIP3.js";import"./chunk-XHM67O4N.js";import"./chunk-R6VWJ2ZL.js";import"./chunk-CWQS3NFK.js";import{a as k,b as T}from"./chunk-A5O5YHGN.js";import"./chunk-IPJHKYVM.js";import{a as W}from"./chunk-OJDRYQWQ.js";import{b as C}from"./chunk-5QMZ5MUS.js";import{a as M,b as x}from"./chunk-3THT3N7L.js";import{a as v}from"./chunk-44UOCSGV.js";import{b as F}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import{AsyncLocalStorage as U}from"node:async_hooks";import{randomBytes as I}from"node:crypto";import{fileURLToPath as J}from"node:url";import{Worker as D}from"node:worker_threads";var N=1e4,H=6e4,B=new U,_=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
2
2
 
3
3
  Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
4
4
 
@@ -1975,7 +1975,17 @@ var SyncBackend = class {
1975
1975
  throw new Error(result.error || "HTTP request failed");
1976
1976
  }
1977
1977
  const responseJson = new TextDecoder().decode(result.result);
1978
- return JSON.parse(responseJson);
1978
+ const parsed = JSON.parse(responseJson);
1979
+ const bodyBase64 = parsed.bodyBase64 ?? "";
1980
+ const body = atob(bodyBase64);
1981
+ return {
1982
+ status: parsed.status,
1983
+ statusText: parsed.statusText,
1984
+ headers: parsed.headers,
1985
+ url: parsed.url,
1986
+ body,
1987
+ bodyBase64
1988
+ };
1979
1989
  }
1980
1990
  /**
1981
1991
  * Execute a shell command through the main thread's exec function.
@@ -1,4 +1,4 @@
1
- import{a as _,b as O}from"./chunk-S4EYC6T6.js";import"./chunk-XHM67O4N.js";import"./chunk-CWQS3NFK.js";import{a as v,b as T}from"./chunk-A5O5YHGN.js";import"./chunk-IPJHKYVM.js";import{a as D}from"./chunk-OJDRYQWQ.js";import{c as y}from"./chunk-24IMIIXA.js";import{b as C}from"./chunk-5QMZ5MUS.js";import{a as M,b as c}from"./chunk-3THT3N7L.js";import{a as E}from"./chunk-44UOCSGV.js";import{a as b,b as P}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import{randomBytes as $}from"node:crypto";import{fileURLToPath as Q}from"node:url";import{Worker as R}from"node:worker_threads";var U=1e4,H=6e4,I={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 L(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'
1
+ import{a as _,b as O}from"./chunk-I57KEIP3.js";import"./chunk-XHM67O4N.js";import"./chunk-R6VWJ2ZL.js";import"./chunk-CWQS3NFK.js";import{a as v,b as T}from"./chunk-A5O5YHGN.js";import"./chunk-IPJHKYVM.js";import{a as D}from"./chunk-OJDRYQWQ.js";import{c as y}from"./chunk-24IMIIXA.js";import{b as C}from"./chunk-5QMZ5MUS.js";import{a as M,b as c}from"./chunk-3THT3N7L.js";import{a as E}from"./chunk-44UOCSGV.js";import{a as b,b as P}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import{randomBytes as $}from"node:crypto";import{fileURLToPath as Q}from"node:url";import{Worker as R}from"node:worker_threads";var U=1e4,H=6e4,I={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 L(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'
2
2
  `,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'
3
3
  `,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}'
4
4
  `,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 k=new WeakMap;function z(r){let e=k.get(r);return e||(e={executionQueue:[],isExecuting:!1},k.set(r,e)),e}function ie(){k=new WeakMap}var N=Q(new URL("./worker.js",import.meta.url));function B(){return $(16).toString("hex")}function V(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=C.runTrusted(()=>new R(N,{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=y(e.requireDefenseContext,"python3","worker message callback",n=>{e.resolve(V(n,e.input.protocolToken)),r.isExecuting=!1,t.terminate(),a(r)}),s=y(e.requireDefenseContext,"python3","worker error callback",n=>{let i=c(E(n));e.resolve({success:!1,error:i}),r.isExecuting=!1,a(r)}),p=y(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)}},g=()=>{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",g)}async function j(r,e,t,o=[]){let s=_(),p=new O(s,e.fs,e.cwd,"python3",e.fetch,e.limits?.maxOutputSize??0),f=e.limits?.maxPythonTimeoutMs??U,l=e.fetch?Math.max(f,H):f,g=z(e.fs),n={protocolToken:B(),sharedBuffer:s,pythonCode:r,cwd:e.cwd,env:D(e.env),args:o,scriptPath:t,timeoutMs:l},i={current:null},m=new Promise(u=>{let d={input:n,resolve:()=>{},workerRef:i,requireDefenseContext:e.requireDefenseContext},A=y(e.requireDefenseContext,"python3","worker timeout callback",()=>{i.current?i.current.terminate():d.canceled=!0,u({success:!1,error:`Execution timeout: exceeded ${l}ms limit`})}),F=v(()=>{try{A()}catch(h){let W=h instanceof Error?h.message:String(h);u({success:!1,error:c(W)})}},l);d.resolve=h=>{T(F),u(h)},g.executionQueue.push(d),a(g)}),[x,w]=await Promise.all([p.run(l).catch(u=>({stdout:"",stderr:`python3: bridge error: ${c(E(u))}
@@ -2014,7 +2014,17 @@ var SyncBackend = class {
2014
2014
  throw new Error(result.error || "HTTP request failed");
2015
2015
  }
2016
2016
  const responseJson = new TextDecoder().decode(result.result);
2017
- return JSON.parse(responseJson);
2017
+ const parsed = JSON.parse(responseJson);
2018
+ const bodyBase64 = parsed.bodyBase64 ?? "";
2019
+ const body = atob(bodyBase64);
2020
+ return {
2021
+ status: parsed.status,
2022
+ statusText: parsed.statusText,
2023
+ headers: parsed.headers,
2024
+ url: parsed.url,
2025
+ body,
2026
+ bodyBase64
2027
+ };
2018
2028
  }
2019
2029
  /**
2020
2030
  * Execute a shell command through the main thread's exec function.
@@ -2822,6 +2832,8 @@ function generateHttpBridgeCode() {
2822
2832
  # Write request JSON to /_jb_http/request (custom FS triggers HTTP via SharedArrayBuffer)
2823
2833
  # Then read response JSON from same path.
2824
2834
 
2835
+ import base64 as _base64
2836
+
2825
2837
  class _JbHttpResponse:
2826
2838
  """HTTP response object similar to requests.Response"""
2827
2839
  def __init__(self, data):
@@ -2829,9 +2841,15 @@ class _JbHttpResponse:
2829
2841
  self.reason = data.get('statusText', '')
2830
2842
  # @banned-pattern-ignore: Python code, not JavaScript
2831
2843
  self.headers = data.get('headers', {})
2832
- self.text = data.get('body', '')
2833
2844
  self.url = data.get('url', '')
2834
2845
  self._error = data.get('error')
2846
+ b64 = data.get('bodyBase64')
2847
+ if b64 is not None:
2848
+ self.content = _base64.b64decode(b64)
2849
+ self.text = self.content.decode('utf-8', errors='replace')
2850
+ else:
2851
+ self.content = b''
2852
+ self.text = data.get('body', '')
2835
2853
 
2836
2854
  @property
2837
2855
  def ok(self):