@jerryan/just-bash 3.5.0 → 3.6.1

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 (80) hide show
  1. package/CHANGELOG.md +334 -308
  2. package/LICENSE +201 -201
  3. package/README.md +827 -827
  4. package/dist/agent-sandbox.d.ts +27 -0
  5. package/dist/bin/chunks/{chunk-7WBCA2BB.js → chunk-3DWQCLNP.js} +1 -1
  6. package/dist/bin/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
  7. package/dist/bin/chunks/chunk-JHEAT7AR.js +12 -0
  8. package/dist/bin/chunks/{chunk-MF3GVFLC.js → chunk-L345YZ6R.js} +1 -1
  9. package/dist/bin/chunks/chunk-QKJAAJ7J.js +3 -0
  10. package/dist/bin/chunks/chunk-SE7JHGP3.js +9 -0
  11. package/dist/bin/{shell/chunks/chunk-NLU5LALY.js → chunks/chunk-YCOJCFGU.js} +1 -1
  12. package/dist/bin/{shell/chunks/flag-coverage-J2ZHA465.js → chunks/flag-coverage-FYJ2V7J4.js} +1 -1
  13. package/dist/bin/chunks/{js-exec-DJQLXWCS.js → js-exec-5QZZCOR7.js} +7 -7
  14. package/dist/bin/chunks/js-exec-worker.js +155 -33
  15. package/dist/bin/{shell/chunks/python3-JCJHSX4Z.js → chunks/python3-TMFYDQAP.js} +1 -1
  16. package/dist/bin/chunks/{rm-3PLW4O4B.js → rm-NLG5344W.js} +1 -1
  17. package/dist/bin/chunks/{sleep-DVFE2GSF.js → sleep-MOJQBZMY.js} +1 -1
  18. package/dist/bin/{shell/chunks/sqlite3-KP42NNIY.js → chunks/sqlite3-3EUPHVEZ.js} +1 -1
  19. package/dist/bin/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
  20. package/dist/bin/chunks/worker.js +162 -48
  21. package/dist/bin/just-bash.js +307 -307
  22. package/dist/bin/shell/chunks/{chunk-7WBCA2BB.js → chunk-3DWQCLNP.js} +1 -1
  23. package/dist/bin/shell/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
  24. package/dist/bin/shell/chunks/chunk-JHEAT7AR.js +12 -0
  25. package/dist/bin/shell/chunks/{chunk-MF3GVFLC.js → chunk-L345YZ6R.js} +1 -1
  26. package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +3 -0
  27. package/dist/bin/shell/chunks/chunk-SE7JHGP3.js +9 -0
  28. package/dist/bin/{chunks/chunk-NLU5LALY.js → shell/chunks/chunk-YCOJCFGU.js} +1 -1
  29. package/dist/bin/{chunks/flag-coverage-J2ZHA465.js → shell/chunks/flag-coverage-FYJ2V7J4.js} +1 -1
  30. package/dist/bin/shell/chunks/{js-exec-DJQLXWCS.js → js-exec-5QZZCOR7.js} +7 -7
  31. package/dist/bin/{chunks/python3-JCJHSX4Z.js → shell/chunks/python3-TMFYDQAP.js} +1 -1
  32. package/dist/bin/shell/chunks/{rm-3PLW4O4B.js → rm-NLG5344W.js} +1 -1
  33. package/dist/bin/shell/chunks/{sleep-DVFE2GSF.js → sleep-MOJQBZMY.js} +1 -1
  34. package/dist/bin/{chunks/sqlite3-KP42NNIY.js → shell/chunks/sqlite3-3EUPHVEZ.js} +1 -1
  35. package/dist/bin/shell/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
  36. package/dist/bin/shell/shell.js +237 -237
  37. package/dist/bundle/browser.js +240 -240
  38. package/dist/bundle/chunks/{chunk-N3A4JVFJ.js → chunk-6IA4DXG2.js} +1 -1
  39. package/dist/bundle/chunks/chunk-G3IRZ4FN.js +8 -0
  40. package/dist/bundle/chunks/{chunk-24NLAR7R.js → chunk-KEMO3CBM.js} +1 -1
  41. package/dist/bundle/chunks/chunk-PS2RJNZZ.js +2 -0
  42. package/dist/bundle/chunks/{chunk-DMWNBCXJ.js → chunk-TLPMB3FO.js} +1 -1
  43. package/dist/bundle/chunks/chunk-ULXGGWAD.js +11 -0
  44. package/dist/bundle/chunks/{chunk-XV2V56NQ.js → chunk-YFFU74KY.js} +1 -1
  45. package/dist/bundle/chunks/{flag-coverage-DPSAPFXA.js → flag-coverage-XSPWRCVG.js} +1 -1
  46. package/dist/bundle/chunks/{js-exec-XKF2B7C3.js → js-exec-57QMXJG5.js} +7 -7
  47. package/dist/bundle/chunks/js-exec-worker.js +155 -33
  48. package/dist/bundle/chunks/{python3-F5S5TYGS.js → python3-NNONJINM.js} +1 -1
  49. package/dist/bundle/chunks/{rm-JQ4GDKDD.js → rm-R2ZENNSN.js} +1 -1
  50. package/dist/bundle/chunks/{sleep-PPRBTSVR.js → sleep-25QUPVDK.js} +1 -1
  51. package/dist/bundle/chunks/{sqlite3-4EZ4GXVD.js → sqlite3-M4UZPXDO.js} +1 -1
  52. package/dist/bundle/chunks/{timeout-C6WDYPLV.js → timeout-37GM7IIL.js} +1 -1
  53. package/dist/bundle/chunks/worker.js +162 -48
  54. package/dist/bundle/index.cjs +760 -760
  55. package/dist/bundle/index.js +306 -306
  56. package/dist/commands/js-exec/js-exec.d.ts +4 -0
  57. package/dist/commands/worker-bridge/bridge-handler.d.ts +9 -0
  58. package/dist/commands/worker-bridge/protocol.d.ts +17 -0
  59. package/dist/commands/worker-bridge/sync-backend.d.ts +3 -0
  60. package/dist/fs/overlay-fs/apply.d.ts +13 -0
  61. package/dist/fs/overlay-fs/index.d.ts +2 -0
  62. package/dist/fs/overlay-fs/merge.d.ts +24 -0
  63. package/dist/fs/overlay-fs/overlay-fs.d.ts +17 -0
  64. package/dist/fs/overlay-fs/overlay-tree.d.ts +39 -0
  65. package/dist/fs/real-fs-utils.d.ts +15 -0
  66. package/dist/fs/vfs-template.d.ts +51 -0
  67. package/dist/index.d.cts +2 -1
  68. package/dist/index.d.ts +2 -1
  69. package/dist/timers.d.ts +9 -0
  70. package/package.json +32 -33
  71. package/vendor/cpython-emscripten/python.cjs +2 -2
  72. package/dist/bin/chunks/chunk-JQM3DKCH.js +0 -12
  73. package/dist/bin/chunks/chunk-PPVF2N6C.js +0 -3
  74. package/dist/bin/chunks/chunk-YOIFOOGX.js +0 -9
  75. package/dist/bin/shell/chunks/chunk-JQM3DKCH.js +0 -12
  76. package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +0 -3
  77. package/dist/bin/shell/chunks/chunk-YOIFOOGX.js +0 -9
  78. package/dist/bundle/chunks/chunk-LPJEKUCB.js +0 -8
  79. package/dist/bundle/chunks/chunk-WXPNKIIH.js +0 -2
  80. package/dist/bundle/chunks/chunk-YJKHREBZ.js +0 -11
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{c as l,d as u}from"./chunk-PPVF2N6C.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};
3
+ import{d as l,e as u}from"./chunk-QKJAAJ7J.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};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as w}from"./chunk-B2DRBHGQ.js";import{a as y}from"./chunk-3MRB66F4.js";import{a as b}from"./chunk-3PCPQIUD.js";import{a as h,b as A}from"./chunk-PPVF2N6C.js";import{a as v,b as O,c as d}from"./chunk-MUFNRCMY.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
+ import{a as w}from"./chunk-B2DRBHGQ.js";import{a as y}from"./chunk-3MRB66F4.js";import{a as b}from"./chunk-3PCPQIUD.js";import{a as h,b as A}from"./chunk-QKJAAJ7J.js";import{a as v,b as O,c as d}from"./chunk-MUFNRCMY.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.
4
4
 
5
5
  DURATION is a number with optional suffix:
6
6
  s - seconds (default)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
+ import{a as A}from"./chunk-3MRB66F4.js";import{b as f}from"./chunk-O2BCKSMK.js";import{a as O,b as h}from"./chunk-TW2IJRUF.js";import{d as F,e as g}from"./chunk-QKJAAJ7J.js";import{b as m}from"./chunk-HWI42GQO.js";import{a as T,b as w}from"./chunk-PBOVSFTJ.js";var n={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},a={PENDING:0,READY:1,SUCCESS:2,ERROR:3},l={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,NOT_EMPTY:11},i={OP_CODE:0,STATUS:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,PATH_BUFFER:32,DATA_BUFFER:4128},E={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:8388608,TOTAL:8392736},R={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 x(){return new O(E.TOTAL)}var S=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return h.load(this.int32View,i.OP_CODE/4)}setOpCode(t){h.store(this.int32View,i.OP_CODE/4,t)}getStatus(){return h.load(this.int32View,i.STATUS/4)}setStatus(t){h.store(this.int32View,i.STATUS/4,t)}getPathLength(){return h.load(this.int32View,i.PATH_LENGTH/4)}setPathLength(t){h.store(this.int32View,i.PATH_LENGTH/4,t)}getDataLength(){return h.load(this.int32View,i.DATA_LENGTH/4)}setDataLength(t){h.store(this.int32View,i.DATA_LENGTH/4,t)}getResultLength(){return h.load(this.int32View,i.RESULT_LENGTH/4)}setResultLength(t){h.store(this.int32View,i.RESULT_LENGTH/4,t)}getErrorCode(){return h.load(this.int32View,i.ERROR_CODE/4)}setErrorCode(t){h.store(this.int32View,i.ERROR_CODE/4,t)}getFlags(){return h.load(this.int32View,i.FLAGS/4)}setFlags(t){h.store(this.int32View,i.FLAGS/4,t)}getMode(){return h.load(this.int32View,i.MODE/4)}setMode(t){h.store(this.int32View,i.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(i.PATH_BUFFER,i.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>E.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${E.PATH_BUFFER}`);this.uint8View.set(e,i.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setData(t){if(t.length>E.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,i.DATA_BUFFER),this.setDataLength(t.length)}getDataAsString(){let t=this.getData();return new TextDecoder().decode(t)}setDataFromString(t){let e=new TextEncoder().encode(t);this.setData(e)}getResult(){let t=this.getResultLength();return this.uint8View.slice(i.DATA_BUFFER,i.DATA_BUFFER+t)}setResult(t){if(t.length>E.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${E.DATA_BUFFER}`);this.uint8View.set(t,i.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,E.DATA_BUFFER);this.uint8View.set(t.subarray(0,e),i.DATA_BUFFER),this.setResultLength(t.length)}getResultAsString(){let t=this.getResult();return new TextDecoder().decode(t)}setResultFromString(t){let e=new TextEncoder().encode(t);this.setResult(e)}encodeStat(t){this.uint8View[i.DATA_BUFFER+u.IS_FILE]=t.isFile?1:0,this.uint8View[i.DATA_BUFFER+u.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[i.DATA_BUFFER+u.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(i.DATA_BUFFER+u.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(i.DATA_BUFFER+u.SIZE,e,!0),this.dataView.setFloat64(i.DATA_BUFFER+u.MTIME,t.mtime.getTime(),!0),this.setResultLength(u.TOTAL)}decodeStat(){return{isFile:this.uint8View[i.DATA_BUFFER+u.IS_FILE]===1,isDirectory:this.uint8View[i.DATA_BUFFER+u.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[i.DATA_BUFFER+u.IS_SYMLINK]===1,mode:this.dataView.getInt32(i.DATA_BUFFER+u.MODE,!0),size:this.dataView.getFloat64(i.DATA_BUFFER+u.SIZE,!0),mtime:new Date(this.dataView.getFloat64(i.DATA_BUFFER+u.MTIME,!0))}}waitForReady(t){return h.wait(this.int32View,i.STATUS/4,a.PENDING,t)}waitForReadyAsync(t){return h.waitAsync(this.int32View,i.STATUS/4,a.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let o=this.getStatus();if(o===a.READY)return!0;let s=Date.now()-e;if(s>=t)return!1;let r=t-s,c=h.waitAsync(this.int32View,i.STATUS/4,o,r);if(c.async&&await c.value==="timed-out")return!1}}waitForResult(t){return h.wait(this.int32View,i.STATUS/4,a.READY,t)}notify(){return h.notify(this.int32View,i.STATUS/4)}reset(){this.setOpCode(n.NOOP),this.setStatus(a.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(l.NONE),this.setFlags(R.NONE),this.setMode(0)}};var D=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,o,s,r=void 0,c=0,d=void 0,p=void 0){this.fs=e,this.cwd=o,this.commandName=s,this.secureFetch=r,this.maxOutputSize=c,this.exec=d,this.invokeTool=p,this.protocol=new S(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+=`
4
+ ${this.commandName}: execution timeout exceeded
5
+ `,Promise.reject(new Error("Operation timed out"));let o=t();return e===Number.POSITIVE_INFINITY?o:new Promise((s,r)=>{let c=F(()=>{this.running=!1,this.output.exitCode=124,this.output.stderr+=`
6
+ ${this.commandName}: execution timeout exceeded
7
+ `,r(new Error("Operation timed out"))},e);o.then(d=>{g(c),s(d)},d=>{g(c),r(d)})})}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+=`
8
+ ${this.commandName}: execution timeout exceeded
9
+ `,this.output.exitCode=124;break}let o=this.remainingMs();if(!await this.protocol.waitUntilReady(o)){this.output.stderr+=`
10
+ ${this.commandName}: execution timeout exceeded
11
+ `,this.output.exitCode=124;break}if(!this.running)break;let r=this.protocol.getOpCode();await this.handleOperation(r),this.protocol.notify()}return this.output}stop(){this.running=!1,this.lastResult=null,this.protocol.setStatus(a.READY),this.protocol.notify()}async handleOperation(t){try{switch(t){case n.READ_FILE:await this.handleReadFile();break;case n.WRITE_FILE:await this.handleWriteFile();break;case n.STAT:await this.handleStat();break;case n.LSTAT:await this.handleLstat();break;case n.READDIR:await this.handleReaddir();break;case n.MKDIR:await this.handleMkdir();break;case n.READ_RESULT_RANGE:this.handleReadResultRange();break;case n.WRITE_FILE_RANGE:await this.handleWriteFileRange();break;case n.RM:await this.handleRm();break;case n.EXISTS:await this.handleExists();break;case n.APPEND_FILE:await this.handleAppendFile();break;case n.SYMLINK:await this.handleSymlink();break;case n.READLINK:await this.handleReadlink();break;case n.CHMOD:await this.handleChmod();break;case n.REALPATH:await this.handleRealpath();break;case n.RENAME:await this.handleRename();break;case n.COPY_FILE:await this.handleCopyFile();break;case n.WRITE_STDOUT:this.handleWriteStdout();break;case n.WRITE_STDERR:this.handleWriteStderr();break;case n.EXIT:this.handleExit();break;case n.HTTP_REQUEST:await this.handleHttpRequest();break;case n.EXEC_COMMAND:await this.handleExecCommand();break;case n.INVOKE_TOOL:await this.handleInvokeTool();break;default:this.protocol.setErrorCode(l.IO_ERROR),this.protocol.setStatus(a.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.setStatus(a.SUCCESS)}handleReadResultRange(){let t=this.protocol.getFlags(),e=this.protocol.getMode(),o=this.lastResult;if(!o||t>o.length){this.protocol.setErrorCode(l.IO_ERROR),this.protocol.setResultFromString("No retained result for range read"),this.protocol.setStatus(a.ERROR);return}this.protocol.setResult(o.subarray(t,t+e)),this.protocol.setStatus(a.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(),o=this.protocol.getData();try{if(e===0)await this.fs.writeFile(t,o);else{let s=await this.fs.stat(t);if(s.size!==e)throw new Error(`EIO: non-sequential range write to '${t}': offset ${e} != size ${s.size}`);await this.fs.appendFile(t,o)}this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}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(o){this.setErrorFromException(o)}}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.publishResult(JSON.stringify(e))}catch(e){this.setErrorFromException(e)}}async handleMkdir(){let t=this.resolvePath(this.protocol.getPath()),o=(this.protocol.getFlags()&R.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:o}),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),o=(e&R.RECURSIVE)!==0,s=(e&R.FORCE)!==0;try{await this.fs.rm(t,{recursive:o,force:s}),this.protocol.setStatus(a.SUCCESS)}catch(r){this.setErrorFromException(r)}}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(o){this.setErrorFromException(o)}}async handleSymlink(){let t=this.protocol.getPath(),e=this.protocol.getDataAsString(),o=this.resolvePath(t);try{await this.fs.symlink(e,o),this.protocol.setStatus(a.SUCCESS)}catch(s){this.setErrorFromException(s)}}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(o){this.setErrorFromException(o)}}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(o){this.setErrorFromException(o)}}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(o){this.setErrorFromException(o)}}handleWriteStdout(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(l.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(l.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
12
+ `,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let s=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(s>0)if(this.output.stdout.length>=s)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-s);else{let r=s-this.output.stdout.length;this.output.stdout="",r>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-r)}this.output.stderr+=e}async handleHttpRequest(){let t=this.secureFetch;if(!t){this.protocol.setErrorCode(l.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(),o=this.protocol.getDataAsString();try{let s=o?JSON.parse(o):{},r=this.remainingMs(),c=await this.raceDeadline(()=>t(e,{method:s.method,headers:s.headers,body:s.body,timeoutMs:r})),d=JSON.stringify({status:c.status,statusText:c.statusText,headers:c.headers,bodyBase64:f(c.body,"base64"),url:c.url});this.publishResult(d)}catch(s){let r=T(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(l.NETWORK_ERROR),this.protocol.setResultFromString(r),this.protocol.setStatus(a.ERROR)}}async handleExecCommand(){let t=this.exec;if(!t){this.protocol.setErrorCode(l.IO_ERROR),this.protocol.setResultFromString("Command execution not available in this context."),this.protocol.setStatus(a.ERROR);return}let e=this.protocol.getPath(),o=this.protocol.getDataAsString(),s=new AbortController;try{let r={cwd:this.cwd,signal:s.signal};if(o){let p=JSON.parse(o);p.stdin&&(r.stdin=p.stdin),p.args&&Array.isArray(p.args)&&(r.args=p.args.map(C=>String(C)),e=A([e]))}let c=await this.raceDeadline(()=>t(e,r)),d=JSON.stringify({stdout:c.stdout,stderr:c.stderr,exitCode:c.exitCode});this.publishResult(d)}catch(r){s.abort();let c=r instanceof Error?r.message:String(r);this.protocol.setErrorCode(l.IO_ERROR),this.protocol.setResultFromString(c),this.protocol.setStatus(a.ERROR)}}async handleInvokeTool(){let t=this.invokeTool;if(!t){this.protocol.setErrorCode(l.IO_ERROR),this.protocol.setResultFromString("Tool invocation not available in this context."),this.protocol.setStatus(a.ERROR);return}let e=this.protocol.getPath(),o=this.protocol.getDataAsString();try{let s=await this.raceDeadline(()=>m.runTrustedAsync(()=>t(e,o)));this.publishResult(s)}catch(s){let r=w(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(l.IO_ERROR),this.protocol.setResultFromString(r),this.protocol.setStatus(a.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),o=T(e),s=l.IO_ERROR,r=e.toLowerCase();r.includes("no such file")||r.includes("not found")||r.includes("enoent")?s=l.NOT_FOUND:r.includes("is a directory")||r.includes("eisdir")?s=l.IS_DIRECTORY:r.includes("not a directory")||r.includes("enotdir")?s=l.NOT_DIRECTORY:r.includes("not empty")||r.includes("enotempty")?s=l.NOT_EMPTY:r.includes("already exists")||r.includes("eexist")?s=l.EXISTS:(r.includes("permission")||r.includes("eperm")||r.includes("eacces"))&&(s=l.PERMISSION_DENIED),this.protocol.setErrorCode(s),this.protocol.setResultFromString(o),this.protocol.setStatus(a.ERROR)}};export{x as a,D as b};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as p}from"./chunk-B2DRBHGQ.js";import{a as n,b as l}from"./chunk-PPVF2N6C.js";import{a as m,b as d}from"./chunk-MUFNRCMY.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
+ import{a as p}from"./chunk-B2DRBHGQ.js";import{a as n,b as l}from"./chunk-QKJAAJ7J.js";import{a as m,b as d}from"./chunk-MUFNRCMY.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:
4
4
  s - seconds (default)
5
5
  m - minutes
6
6
  h - hours
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
+ import{b as a}from"./chunk-HWI42GQO.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};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
+ import{a as g}from"./chunk-PBOVSFTJ.js";import{a as u}from"./chunk-NE4R2FVV.js";import{a as p}from"./chunk-I4IRHQDW.js";var y={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},$={name:"rm",async execute(d,s){let e=u("rm",d,y);if(!e.ok)return e.error;let l=e.result.flags.recursive||e.result.flags.recursiveUpper,a=e.result.flags.force,v=e.result.flags.verbose,c=e.result.positional;if(c.length===0)return a?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand
4
+ `,exitCode:1};let f="",o="",i=0;for(let r of c)try{let n=s.fs.resolvePath(s.cwd,r);if((await s.fs.stat(n)).isDirectory&&!l){o+=`rm: cannot remove '${r}': Is a directory
5
+ `,i=1;continue}await s.fs.rm(n,{recursive:l,force:a}),v&&(f+=`removed '${r}'
6
+ `)}catch(n){let t=p(n),m=t.startsWith("ENOENT");if(a&&m)continue;m?o+=`rm: cannot remove '${r}': No such file or directory
7
+ `:t.includes("ENOTEMPTY")||t.includes("not empty")?o+=`rm: cannot remove '${r}': Directory not empty
8
+ `:o+=`rm: cannot remove '${r}': ${g(t)}
9
+ `,i=1}return{stdout:f,stderr:o,exitCode:i}}},C={name:"rm",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0};export{$ as a,C as b};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as W}from"./chunk-7WBCA2BB.js";import{c as $}from"./chunk-42AMF6EE.js";import{b as C}from"./chunk-HWI42GQO.js";import{a as V}from"./chunk-WEHA3JFD.js";import{b as I}from"./chunk-CPKBPQ2C.js";import{a as B,b}from"./chunk-PBOVSFTJ.js";import{a as x}from"./chunk-I4IRHQDW.js";import{a as N,b as R}from"./chunk-MUFNRCMY.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
+ import{a as W}from"./chunk-3DWQCLNP.js";import{c as $}from"./chunk-42AMF6EE.js";import{b as C}from"./chunk-HWI42GQO.js";import{a as V}from"./chunk-WEHA3JFD.js";import{b as I}from"./chunk-CPKBPQ2C.js";import{a as B,b}from"./chunk-PBOVSFTJ.js";import{a as x}from"./chunk-I4IRHQDW.js";import{a as N,b as R}from"./chunk-MUFNRCMY.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(`
4
4
  `)}
5
5
  `:""}function v(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
6
6
  `)?`"${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(`,
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{b as yr}from"./chunk-RPUFEP5O.js";import{b as Ar}from"./chunk-V2XF3TTW.js";import{b as $r}from"./chunk-7PUOS2OO.js";import"./chunk-V4U26ZWL.js";import"./chunk-KP2UH5CJ.js";import{c as Sr}from"./chunk-NLU5LALY.js";import"./chunk-7WBCA2BB.js";import{b as wr}from"./chunk-PQ2INDRF.js";import{b as xr}from"./chunk-DYIBFLS3.js";import{b as vr}from"./chunk-RVPTAYDS.js";import{b as kr}from"./chunk-TYBXHT6W.js";import{b as qr}from"./chunk-AJF3OBTR.js";import{b as Cr}from"./chunk-2ETT4ELS.js";import{b as br}from"./chunk-OUQKFRVR.js";import{d as Ir,e as Mr,f as jr}from"./chunk-HQ63MFHG.js";import"./chunk-QES5OSUC.js";import{b as tr}from"./chunk-QFTZKD5O.js";import{b as lr}from"./chunk-CC2AQ6B7.js";import{b as ur}from"./chunk-QMPZXXEK.js";import{b as pr}from"./chunk-WFHYGSLJ.js";import{b as er}from"./chunk-LXFMIXGA.js";import{b as dr}from"./chunk-WFVCEB5T.js";import{b as cr}from"./chunk-KG2KXL4Y.js";import"./chunk-2YLY6FJA.js";import{b as hr}from"./chunk-OXLC2WWX.js";import{c as or,d as ar}from"./chunk-KI54R2QB.js";import{b as sr}from"./chunk-KUMHQGUR.js";import{c as ir,d as gr}from"./chunk-MYTNZ7MA.js";import{b as mr}from"./chunk-7PPAWLUI.js";import"./chunk-F3UDTTI7.js";import{b as Fr}from"./chunk-FPWHWWXO.js";import{b as zr}from"./chunk-23OI2XDJ.js";import{b as fr}from"./chunk-LJQIAFWS.js";import{b as nr}from"./chunk-MF3GVFLC.js";import"./chunk-B2DRBHGQ.js";import{b as R}from"./chunk-YJ5OCPSK.js";import{b as U}from"./chunk-Q2GOPGDA.js";import{b as V}from"./chunk-PXP4YYZA.js";import{b as W}from"./chunk-6ESRNSO7.js";import{c as X,d as Y}from"./chunk-YUZRUF5F.js";import{c as Z,d as _}from"./chunk-DJAX3ZRG.js";import{b as N}from"./chunk-PZQVSQX6.js";import{b as rr}from"./chunk-SDGPS6XI.js";import{b as G}from"./chunk-SC5TEGMM.js";import{b as H}from"./chunk-5SKEZPTU.js";import{b as J}from"./chunk-OYXHOZZ4.js";import{b as K}from"./chunk-M7SIPZZZ.js";import{b as L}from"./chunk-N26Y42L6.js";import{b as O}from"./chunk-4JF56A3P.js";import{b as P}from"./chunk-AGKL4LDL.js";import{b as Q}from"./chunk-B2GCIQI2.js";import{b as y}from"./chunk-FHMIEBRM.js";import{b as A}from"./chunk-7FGDUBSN.js";import{b as $}from"./chunk-GOWX7VPU.js";import{b as S}from"./chunk-B6WWC6K3.js";import{b as T}from"./chunk-MVBK66TR.js";import{b as B}from"./chunk-YIANER7Y.js";import{b as D}from"./chunk-HDWHYM2T.js";import{b as E}from"./chunk-Q3LE3Y66.js";import{b as w}from"./chunk-3FQBUEB6.js";import{b as x}from"./chunk-45DUHCXR.js";import{b as v}from"./chunk-HZGHQZSY.js";import"./chunk-BIJXTWZ4.js";import{d as k,e as q,f as C}from"./chunk-JELR4642.js";import"./chunk-QYZN33JA.js";import{b}from"./chunk-DZAFUADN.js";import"./chunk-47IFMQYS.js";import"./chunk-3MRB66F4.js";import"./chunk-R2J5MJOM.js";import{b as I}from"./chunk-7VWOECJ3.js";import{b as M}from"./chunk-472JZJ2D.js";import{b as j}from"./chunk-FONAGXRJ.js";import{b as t}from"./chunk-YOIFOOGX.js";import{b as l}from"./chunk-AI7JUA46.js";import{b as u}from"./chunk-GQKQEK5N.js";import{b as p}from"./chunk-YQEKKZTU.js";import{b as e}from"./chunk-67XYNGRV.js";import{b as d}from"./chunk-G4AUMZUY.js";import{b as c}from"./chunk-LE2XKKGQ.js";import{b as h}from"./chunk-VTAMGD42.js";import"./chunk-6KHZX4HU.js";import"./chunk-3PCPQIUD.js";import"./chunk-TW2IJRUF.js";import"./chunk-PPVF2N6C.js";import"./chunk-K27FY3ES.js";import"./chunk-MROECM42.js";import"./chunk-42AMF6EE.js";import"./chunk-GA5TPRMF.js";import{b as i}from"./chunk-CMTQFWZK.js";import{b as g}from"./chunk-NXUXZWS5.js";import"./chunk-2UV6ZFHK.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import{b as m}from"./chunk-WAJVRK5B.js";import"./chunk-HW2VJKFH.js";import"./chunk-YERKK5B3.js";import{b as F}from"./chunk-CL7IYCGG.js";import"./chunk-I57EACSL.js";import"./chunk-7JZKVC3F.js";import{b as z}from"./chunk-OLEQNRKX.js";import{b as f}from"./chunk-ZMGLTHSU.js";import"./chunk-WEHA3JFD.js";import"./chunk-43E7AR6A.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import{b as n}from"./chunk-QL33F2W6.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.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};
3
+ import{b as yr}from"./chunk-RPUFEP5O.js";import{b as Ar}from"./chunk-V2XF3TTW.js";import{b as $r}from"./chunk-7PUOS2OO.js";import"./chunk-V4U26ZWL.js";import"./chunk-KP2UH5CJ.js";import{c as Sr}from"./chunk-YCOJCFGU.js";import"./chunk-3DWQCLNP.js";import{b as wr}from"./chunk-PQ2INDRF.js";import{b as xr}from"./chunk-DYIBFLS3.js";import{b as vr}from"./chunk-RVPTAYDS.js";import{b as kr}from"./chunk-TYBXHT6W.js";import{b as qr}from"./chunk-AJF3OBTR.js";import{b as Cr}from"./chunk-2ETT4ELS.js";import{b as br}from"./chunk-OUQKFRVR.js";import{d as Ir,e as Mr,f as jr}from"./chunk-HQ63MFHG.js";import"./chunk-QES5OSUC.js";import{b as tr}from"./chunk-6TUILMPB.js";import{b as lr}from"./chunk-CC2AQ6B7.js";import{b as ur}from"./chunk-QMPZXXEK.js";import{b as pr}from"./chunk-WFHYGSLJ.js";import{b as er}from"./chunk-LXFMIXGA.js";import{b as dr}from"./chunk-WFVCEB5T.js";import{b as cr}from"./chunk-KG2KXL4Y.js";import"./chunk-2YLY6FJA.js";import{b as hr}from"./chunk-OXLC2WWX.js";import{c as or,d as ar}from"./chunk-KI54R2QB.js";import{b as sr}from"./chunk-KUMHQGUR.js";import{c as ir,d as gr}from"./chunk-MYTNZ7MA.js";import{b as mr}from"./chunk-7PPAWLUI.js";import"./chunk-F3UDTTI7.js";import{b as Fr}from"./chunk-FPWHWWXO.js";import{b as zr}from"./chunk-23OI2XDJ.js";import{b as fr}from"./chunk-LJQIAFWS.js";import{b as nr}from"./chunk-L345YZ6R.js";import"./chunk-B2DRBHGQ.js";import{b as R}from"./chunk-YJ5OCPSK.js";import{b as U}from"./chunk-Q2GOPGDA.js";import{b as V}from"./chunk-PXP4YYZA.js";import{b as W}from"./chunk-6ESRNSO7.js";import{c as X,d as Y}from"./chunk-YUZRUF5F.js";import{c as Z,d as _}from"./chunk-DJAX3ZRG.js";import{b as N}from"./chunk-PZQVSQX6.js";import{b as rr}from"./chunk-SDGPS6XI.js";import{b as G}from"./chunk-SC5TEGMM.js";import{b as H}from"./chunk-5SKEZPTU.js";import{b as J}from"./chunk-OYXHOZZ4.js";import{b as K}from"./chunk-M7SIPZZZ.js";import{b as L}from"./chunk-N26Y42L6.js";import{b as O}from"./chunk-4JF56A3P.js";import{b as P}from"./chunk-AGKL4LDL.js";import{b as Q}from"./chunk-B2GCIQI2.js";import{b as y}from"./chunk-FHMIEBRM.js";import{b as A}from"./chunk-7FGDUBSN.js";import{b as $}from"./chunk-GOWX7VPU.js";import{b as S}from"./chunk-B6WWC6K3.js";import{b as T}from"./chunk-MVBK66TR.js";import{b as B}from"./chunk-YIANER7Y.js";import{b as D}from"./chunk-HDWHYM2T.js";import{b as E}from"./chunk-Q3LE3Y66.js";import{b as w}from"./chunk-3FQBUEB6.js";import{b as x}from"./chunk-45DUHCXR.js";import{b as v}from"./chunk-HZGHQZSY.js";import"./chunk-BIJXTWZ4.js";import{d as k,e as q,f as C}from"./chunk-JELR4642.js";import"./chunk-QYZN33JA.js";import{b}from"./chunk-DZAFUADN.js";import"./chunk-47IFMQYS.js";import"./chunk-3MRB66F4.js";import"./chunk-R2J5MJOM.js";import{b as I}from"./chunk-7VWOECJ3.js";import{b as M}from"./chunk-472JZJ2D.js";import{b as j}from"./chunk-FONAGXRJ.js";import{b as t}from"./chunk-SE7JHGP3.js";import{b as l}from"./chunk-AI7JUA46.js";import{b as u}from"./chunk-GQKQEK5N.js";import{b as p}from"./chunk-YQEKKZTU.js";import{b as e}from"./chunk-67XYNGRV.js";import{b as d}from"./chunk-G4AUMZUY.js";import{b as c}from"./chunk-LE2XKKGQ.js";import{b as h}from"./chunk-VTAMGD42.js";import"./chunk-6KHZX4HU.js";import"./chunk-3PCPQIUD.js";import"./chunk-TW2IJRUF.js";import"./chunk-QKJAAJ7J.js";import"./chunk-K27FY3ES.js";import"./chunk-MROECM42.js";import"./chunk-42AMF6EE.js";import"./chunk-GA5TPRMF.js";import{b as i}from"./chunk-CMTQFWZK.js";import{b as g}from"./chunk-NXUXZWS5.js";import"./chunk-2UV6ZFHK.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import{b as m}from"./chunk-WAJVRK5B.js";import"./chunk-HW2VJKFH.js";import"./chunk-YERKK5B3.js";import{b as F}from"./chunk-CL7IYCGG.js";import"./chunk-I57EACSL.js";import"./chunk-7JZKVC3F.js";import{b as z}from"./chunk-OLEQNRKX.js";import{b as f}from"./chunk-ZMGLTHSU.js";import"./chunk-WEHA3JFD.js";import"./chunk-43E7AR6A.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import{b as n}from"./chunk-QL33F2W6.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.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};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as A,b as B}from"./chunk-JQM3DKCH.js";import{a as F}from"./chunk-7WBCA2BB.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import{a as j,b as v}from"./chunk-PPVF2N6C.js";import{a as q}from"./chunk-MROECM42.js";import{b as C}from"./chunk-HWI42GQO.js";import{b as E}from"./chunk-CPKBPQ2C.js";import{a as W,b as h}from"./chunk-PBOVSFTJ.js";import{a as S}from"./chunk-I4IRHQDW.js";import{b as M}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{AsyncLocalStorage as H}from"node:async_hooks";import{fileURLToPath as I}from"node:url";import{Worker as L}from"node:worker_threads";var O=new H,P=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
3
+ import{a as A,b as B}from"./chunk-JHEAT7AR.js";import{a as q}from"./chunk-3DWQCLNP.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import{b as v,c as j}from"./chunk-QKJAAJ7J.js";import{a as F}from"./chunk-MROECM42.js";import{b as C}from"./chunk-HWI42GQO.js";import{b as E}from"./chunk-CPKBPQ2C.js";import{a as W,b as h}from"./chunk-PBOVSFTJ.js";import{a as S}from"./chunk-I4IRHQDW.js";import{b as M}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{AsyncLocalStorage as H}from"node:async_hooks";import{fileURLToPath as J}from"node:url";import{Worker as L}from"node:worker_threads";var O=new H,P=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
4
4
 
5
5
  Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
6
6
 
@@ -87,13 +87,13 @@ Limits:
87
87
  Engine: QuickJS (compiled to WebAssembly)
88
88
  `;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'
89
89
  `,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}'
90
- `,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,J=1e3;function R(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()},J);r.controller.terminate(e).then(a=>a?u():o(),o)}function de(){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 U=I(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=$(),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(r,o,s):(r.resolve(s),n===r&&(n=null),g())}}function D(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 $(){if(y&&(v(y),y=null),l)return l;let r=C.runTrusted(()=>new L(U));return l=r,r.on("message",e=>{if(l===r){if(n){let t;try{n.controller.assertMessageSize(e,"response"),t=D(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():V()}}),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 V(){y=j(()=>{l&&!n&&c.length===0&&(l.terminate(),l=null)},5e3)}async function Q(r,e,t,s=[],o,u,i){return O.getStore()?{stdout:"",stderr:`js-exec: recursive invocation is not supported
91
- `,exitCode:1}:X(r,e,t,s,o,u,i)}async function G(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?R(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 K(r){return r.limits.maxJsTimeoutMs}async function X(r,e,t,s=[],o,u,i){if(x!==null)return{stdout:"",stderr:`js-exec: ${h(x)}
92
- `,exitCode:1};let a=A(),m=e.exec,k=m?(T,_)=>O.run(!0,()=>m(T,_)):void 0,d=new B(a,e.fs,e.cwd,"js-exec",e.fetch,e.limits.maxOutputSize,k,e.invokeTool),f=K(e),p=new F({commandName:"js-exec",timeoutMs:f,signal:e.signal,maxMessageBytes:e.limits.maxWorkerMessageBytes}),z={protocolToken:p.protocolToken,sharedBuffer:a,jsCode:r,cwd:e.cwd,env:q(e.env),args:s,scriptPath:t,bootstrapCode:o,isModule:u,stripTypes:i,timeoutMs:f,hasInvokeTool:e.invokeTool!==void 0},{bridgeOutput:b,workerResult:w}=await G(z,d,f,p);if(!w.success&&w.error){let T=w.error===p.timeoutMessage()||w.error===p.abortMessage();return{stdout:b.stdout,stderr:`${b.stderr}js-exec: ${h(w.error)}
93
- `,exitCode:b.exitCode||(T?124:1)}}return{...b}}var fe={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)
90
+ `,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=J(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
91
+ `,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)}
92
+ `,exitCode:1};let a=A(),m=e.exec,k=m?(b,I)=>O.run(!0,()=>m(b,I)):void 0,d=new B(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,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)}
93
+ `,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)
94
94
  `,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
95
95
  `,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)}
96
96
  `,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)
97
- `,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 Q(s,e,o,t.scriptArgs,a,u,i)}},pe={name:"node",async execute(){return{stdout:"",stderr:`node: this sandbox uses js-exec instead of node
97
+ `,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
98
98
 
99
- ${P}`,exitCode:1}}};export{de as _resetJsExecWorkerForTests,fe as jsExecCommand,pe as nodeStubCommand};
99
+ ${P}`,exitCode:1}}};export{pe as _hasSharedJsExecWorkerForTests,me as _resetJsExecWorkerForTests,fe as _setJsExecWorkerIdleTimeoutMsForTests,he as jsExecCommand,ye as nodeStubCommand};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as Q,b as W}from"./chunk-JQM3DKCH.js";import{a as I}from"./chunk-7WBCA2BB.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import"./chunk-PPVF2N6C.js";import{a as F}from"./chunk-MROECM42.js";import{c as w}from"./chunk-42AMF6EE.js";import{b as M}from"./chunk-HWI42GQO.js";import{b as C}from"./chunk-CPKBPQ2C.js";import{a as A,b as d}from"./chunk-PBOVSFTJ.js";import{a as E}from"./chunk-I4IRHQDW.js";import{a as P,b as D}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{fileURLToPath as B}from"node:url";import{Worker as L}from"node:worker_threads";var z={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 _(t){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(t.length===0)return e;let r=t.findIndex(n=>!n.startsWith("-")||n==="-"||n==="--");for(let n=0;n<(r===-1?t.length:r);n++){let i=t[n];if(i==="-c")return n+1>=t.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
3
+ import{a as Q,b as W}from"./chunk-JHEAT7AR.js";import{a as I}from"./chunk-3DWQCLNP.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import"./chunk-QKJAAJ7J.js";import{a as F}from"./chunk-MROECM42.js";import{c as w}from"./chunk-42AMF6EE.js";import{b as M}from"./chunk-HWI42GQO.js";import{b as C}from"./chunk-CPKBPQ2C.js";import{a as A,b as d}from"./chunk-PBOVSFTJ.js";import{a as E}from"./chunk-I4IRHQDW.js";import{a as P,b as D}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{fileURLToPath as B}from"node:url";import{Worker as L}from"node:worker_threads";var z={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 _(t){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(t.length===0)return e;let r=t.findIndex(n=>!n.startsWith("-")||n==="-"||n==="--");for(let n=0;n<(r===-1?t.length:r);n++){let i=t[n];if(i==="-c")return n+1>=t.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
4
4
  `,exitCode:2}:(e.code=t[n+1],e.scriptArgs=t.slice(n+2),e);if(i==="-m")return n+1>=t.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
5
5
  `,exitCode:2}:(e.module=t[n+1],e.scriptArgs=t.slice(n+2),e);if(i==="--version"||i==="-V")return e.showVersion=!0,e;if(i.startsWith("-")&&i!=="-")return{stdout:"",stderr:`python3: unrecognized option '${i}'
6
6
  `,exitCode:2}}if(r!==-1){let n=t[r];n==="--"?r+1<t.length&&(e.scriptFile=t[r+1],e.scriptArgs=t.slice(r+2)):(e.scriptFile=n,e.scriptArgs=t.slice(r+1))}return e}var b=new WeakMap;function R(t){let e=b.get(t);return e||(e={executionQueue:[],activeExecution:null,poisonedError:null},b.set(t,e)),e}function ne(){b=new WeakMap}var H=B(new URL("./worker.js",import.meta.url));function U(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let r=t;return typeof r.protocolToken!="string"||r.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:r.type==="security-violation"?{success:!1,error:`Security violation: ${typeof r.violation?.type=="string"?r.violation.type:"unknown"}`}:typeof r.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:r.success?{success:!0}:{success:!1,error:typeof r.error=="string"&&r.error.length>0?r.error:"Worker execution failed"}}function k(t){if(t.poisonedError!==null){for(let o of t.executionQueue.splice(0))o.state==="queued"&&(o.state="settled",o.stopBridge(),o.settle({success:!1,error:t.poisonedError}));return}if(t.activeExecution!==null||t.executionQueue.length===0)return;for(;t.executionQueue.length>0&&t.executionQueue[0]?.state!=="queued";)t.executionQueue.shift();if(t.executionQueue.length===0)return;let e=t.executionQueue.shift();if(!e)return;e.state="running",t.activeExecution=e;let r;try{r=M.runTrusted(()=>new L(H,{workerData:e.input}))}catch(o){let s=o instanceof Error?o.message:String(o);e.state="settled",e.settle({success:!1,error:d(s)}),t.activeExecution===e&&(t.activeExecution=null,k(t));return}e.worker=r;let n=!0,i=()=>{n&&(n=!1,r.removeListener("message",u),r.removeListener("error",g),r.removeListener("exit",v))},c=async(o,s)=>{if(!(t.activeExecution?.executionId!==e.executionId||e.state!=="running")){if(e.state="terminating",i(),e.settle(o),s&&!await e.controller.terminate(r)){let f="Worker termination was not acknowledged";e.worker=null,e.state="settled",t.poisonedError=f,t.activeExecution?.executionId===e.executionId&&(t.activeExecution=null),k(t);return}e.worker=null,e.state="settled",t.activeExecution?.executionId===e.executionId&&(t.activeExecution=null,k(t))}};e.cancel=o=>{c(o,!0)};let p=w(e.requireDefenseContext,"python3","worker message callback",o=>{try{e.controller.assertMessageSize(o,"response")}catch(s){c({success:!1,error:d(E(s))},!0);return}c(U(o,e.input.protocolToken),!0)}),h=w(e.requireDefenseContext,"python3","worker error callback",o=>{let s=d(E(o));c({success:!1,error:s},!0)}),a=w(e.requireDefenseContext,"python3","worker exit callback",()=>{c({success:!1,error:"Worker exited unexpectedly"},!1)}),u=o=>{try{p(o)}catch(s){let l=s instanceof Error?s.message:String(s);c({success:!1,error:d(l)},!0)}},g=o=>{try{h(o)}catch(s){let l=s instanceof Error?s.message:String(s);c({success:!1,error:d(l)},!0)}},v=()=>{try{a()}catch(o){let s=o instanceof Error?o.message:String(o);c({success:!1,error:d(s)},!0)}};r.on("message",u),r.on("error",g),r.on("exit",v)}async function N(t,e,r,n,i=[]){let c=Q(),p=new W(c,r.fs,r.cwd,"python3",r.fetch,r.limits.maxOutputSize),h=r.limits.maxPythonTimeoutMs,a=R(r.fs);if(a.poisonedError!==null)return{stdout:"",stderr:`python3: ${a.poisonedError}
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b}from"./chunk-YOIFOOGX.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{b as flagsForFuzzing,a as rmCommand};
3
+ import{a,b}from"./chunk-SE7JHGP3.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{b as flagsForFuzzing,a as rmCommand};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b}from"./chunk-MF3GVFLC.js";import"./chunk-B2DRBHGQ.js";import"./chunk-PPVF2N6C.js";import"./chunk-HWI42GQO.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{b as flagsForFuzzing,a as sleepCommand};
3
+ import{a,b}from"./chunk-L345YZ6R.js";import"./chunk-B2DRBHGQ.js";import"./chunk-QKJAAJ7J.js";import"./chunk-HWI42GQO.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{b as flagsForFuzzing,a as sleepCommand};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b,c}from"./chunk-NLU5LALY.js";import"./chunk-7WBCA2BB.js";import"./chunk-PPVF2N6C.js";import"./chunk-42AMF6EE.js";import"./chunk-HWI42GQO.js";import"./chunk-WEHA3JFD.js";import"./chunk-43E7AR6A.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-PBOVSFTJ.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as _internals,c as flagsForFuzzing,b as sqlite3Command};
3
+ import{a,b,c}from"./chunk-YCOJCFGU.js";import"./chunk-3DWQCLNP.js";import"./chunk-QKJAAJ7J.js";import"./chunk-42AMF6EE.js";import"./chunk-HWI42GQO.js";import"./chunk-WEHA3JFD.js";import"./chunk-43E7AR6A.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-PBOVSFTJ.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as _internals,c as flagsForFuzzing,b as sqlite3Command};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b}from"./chunk-QFTZKD5O.js";import"./chunk-B2DRBHGQ.js";import"./chunk-3MRB66F4.js";import"./chunk-3PCPQIUD.js";import"./chunk-PPVF2N6C.js";import"./chunk-HWI42GQO.js";import"./chunk-CPKBPQ2C.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{b as flagsForFuzzing,a as timeoutCommand};
3
+ import{a,b}from"./chunk-6TUILMPB.js";import"./chunk-B2DRBHGQ.js";import"./chunk-3MRB66F4.js";import"./chunk-3PCPQIUD.js";import"./chunk-QKJAAJ7J.js";import"./chunk-HWI42GQO.js";import"./chunk-CPKBPQ2C.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{b as flagsForFuzzing,a as timeoutCommand};