just-bash 2.12.0 → 2.12.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.
- package/dist/Bash.d.ts +5 -0
- package/dist/bin/chunks/{awk2-YRDDZZBN.js → awk2-ZE5HJBNV.js} +1 -1
- package/dist/bin/chunks/chunk-253LRF5J.js +11 -0
- package/dist/bin/chunks/chunk-2BC3N3L2.js +16 -0
- package/dist/bin/chunks/chunk-2FFXXW3F.js +14 -0
- package/dist/bin/chunks/{chunk-D2VMRCQU.js → chunk-35JD7YEM.js} +12 -12
- package/dist/bin/chunks/chunk-435ZOZCY.js +63 -0
- package/dist/bin/{shell/chunks/chunk-JXC25GVQ.js → chunks/chunk-47HZU3SY.js} +1 -1
- package/dist/bin/chunks/chunk-4FNW6LFM.js +5 -0
- package/dist/bin/chunks/chunk-4OALHZXB.js +2 -0
- package/dist/bin/chunks/chunk-4PZYIYYG.js +36 -0
- package/dist/bin/chunks/{chunk-HA4QZ6XJ.js → chunk-DREQRXNN.js} +4 -4
- package/dist/bin/chunks/chunk-IYZRLSTQ.js +2 -0
- package/dist/bin/chunks/chunk-JJHAWOIB.js +2 -0
- package/dist/bin/chunks/{chunk-F37UEO7A.js → chunk-JNPUO56K.js} +1 -1
- package/dist/bin/chunks/{chunk-DAGNL3F2.js → chunk-MZKPWGID.js} +24 -24
- package/dist/bin/chunks/chunk-N4EU64Y4.js +9 -0
- package/dist/bin/chunks/{chunk-CPL5P744.js → chunk-OKL2SPHK.js} +32 -32
- package/dist/bin/chunks/{chunk-6SAF32NO.js → chunk-VZKEP45B.js} +13 -13
- package/dist/bin/chunks/env-HOVBNLUR.js +2 -0
- package/dist/bin/chunks/{expansion-HLAOHDFJ.js → expansion-TCB3WZP5.js} +1 -1
- package/dist/bin/chunks/find-4YAO7JQS.js +2 -0
- package/dist/bin/chunks/flag-coverage-LQ37DA4R.js +2 -0
- package/dist/bin/chunks/{gzip-EENEW6WQ.js → gzip-RQ5RIFJV.js} +1 -1
- package/dist/bin/chunks/help-4H52JYYC.js +2 -0
- package/dist/bin/chunks/python3-74B25WCY.js +17 -0
- package/dist/bin/chunks/rg-34GE6REQ.js +2 -0
- package/dist/bin/{shell/chunks/sleep-RA6DYTJX.js → chunks/sleep-GUJH2AMQ.js} +1 -1
- package/dist/bin/chunks/sqlite3-57UI7HYL.js +2 -0
- package/dist/bin/chunks/{tar-GP2CCB47.js → tar-VIYVHMER.js} +1 -1
- package/dist/bin/chunks/time-FAWHHOMA.js +2 -0
- package/dist/bin/chunks/timeout-4O4YYRTS.js +2 -0
- package/dist/bin/chunks/worker.js +154 -4
- package/dist/bin/{shell/chunks/xargs-YWPEV2QC.js → chunks/xargs-GBL6PZ2K.js} +1 -1
- package/dist/bin/just-bash.js +255 -255
- package/dist/bin/shell/chunks/{awk2-YRDDZZBN.js → awk2-ZE5HJBNV.js} +1 -1
- package/dist/bin/shell/chunks/chunk-253LRF5J.js +11 -0
- package/dist/bin/shell/chunks/chunk-2BC3N3L2.js +16 -0
- package/dist/bin/shell/chunks/chunk-2FFXXW3F.js +14 -0
- package/dist/bin/shell/chunks/{chunk-D2VMRCQU.js → chunk-35JD7YEM.js} +12 -12
- package/dist/bin/shell/chunks/chunk-435ZOZCY.js +63 -0
- package/dist/bin/{chunks/chunk-JXC25GVQ.js → shell/chunks/chunk-47HZU3SY.js} +1 -1
- package/dist/bin/shell/chunks/chunk-4FNW6LFM.js +5 -0
- package/dist/bin/shell/chunks/chunk-4OALHZXB.js +2 -0
- package/dist/bin/shell/chunks/chunk-4PZYIYYG.js +36 -0
- package/dist/bin/shell/chunks/{chunk-HA4QZ6XJ.js → chunk-DREQRXNN.js} +4 -4
- package/dist/bin/shell/chunks/chunk-IYZRLSTQ.js +2 -0
- package/dist/bin/shell/chunks/chunk-JJHAWOIB.js +2 -0
- package/dist/bin/shell/chunks/{chunk-F37UEO7A.js → chunk-JNPUO56K.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-DAGNL3F2.js → chunk-MZKPWGID.js} +24 -24
- package/dist/bin/shell/chunks/chunk-N4EU64Y4.js +9 -0
- package/dist/bin/shell/chunks/{chunk-CPL5P744.js → chunk-OKL2SPHK.js} +32 -32
- package/dist/bin/shell/chunks/{chunk-6SAF32NO.js → chunk-VZKEP45B.js} +13 -13
- package/dist/bin/shell/chunks/env-HOVBNLUR.js +2 -0
- package/dist/bin/shell/chunks/{expansion-HLAOHDFJ.js → expansion-TCB3WZP5.js} +1 -1
- package/dist/bin/shell/chunks/find-4YAO7JQS.js +2 -0
- package/dist/bin/shell/chunks/flag-coverage-LQ37DA4R.js +2 -0
- package/dist/bin/shell/chunks/{gzip-EENEW6WQ.js → gzip-RQ5RIFJV.js} +1 -1
- package/dist/bin/shell/chunks/help-4H52JYYC.js +2 -0
- package/dist/bin/shell/chunks/python3-74B25WCY.js +17 -0
- package/dist/bin/shell/chunks/rg-34GE6REQ.js +2 -0
- package/dist/bin/{chunks/sleep-RA6DYTJX.js → shell/chunks/sleep-GUJH2AMQ.js} +1 -1
- package/dist/bin/shell/chunks/sqlite3-57UI7HYL.js +2 -0
- package/dist/bin/shell/chunks/{tar-GP2CCB47.js → tar-VIYVHMER.js} +1 -1
- package/dist/bin/shell/chunks/time-FAWHHOMA.js +2 -0
- package/dist/bin/shell/chunks/timeout-4O4YYRTS.js +2 -0
- package/dist/bin/{chunks/xargs-YWPEV2QC.js → shell/chunks/xargs-GBL6PZ2K.js} +1 -1
- package/dist/bin/shell/shell.js +252 -252
- package/dist/bundle/browser.js +748 -747
- package/dist/bundle/chunks/{awk2-66MVVLQI.js → awk2-T6LHPVZE.js} +1 -1
- package/dist/bundle/chunks/chunk-2GOYXRRP.js +15 -0
- package/dist/bundle/chunks/chunk-3RA5L262.js +8 -0
- package/dist/bundle/chunks/{chunk-CCCK5QHL.js → chunk-4VCAQZKQ.js} +32 -32
- package/dist/bundle/chunks/chunk-5CJQNRNJ.js +62 -0
- package/dist/bundle/chunks/{chunk-VFBZTF5G.js → chunk-7BQDVPII.js} +1 -1
- package/dist/bundle/chunks/chunk-7KHLIOOW.js +4 -0
- package/dist/bundle/chunks/{chunk-RARYJBGX.js → chunk-BAAVD5NO.js} +13 -13
- package/dist/bundle/chunks/chunk-BEFDX7IY.js +1 -0
- package/dist/bundle/chunks/{chunk-DZ33S2U7.js → chunk-FO655G4V.js} +24 -24
- package/dist/bundle/chunks/chunk-IPJHKYVM.js +1 -0
- package/dist/bundle/chunks/chunk-NBAARP4B.js +1 -0
- package/dist/bundle/chunks/{chunk-FJNVFD75.js → chunk-OKEHYWBE.js} +12 -12
- package/dist/bundle/chunks/chunk-RHOPHAL6.js +35 -0
- package/dist/bundle/chunks/{chunk-S7ED3RD5.js → chunk-UJIR5V54.js} +4 -4
- package/dist/bundle/chunks/chunk-YCABLDKV.js +10 -0
- package/dist/bundle/chunks/chunk-YIY2RKBW.js +13 -0
- package/dist/bundle/chunks/{chunk-SXR3EI72.js → chunk-ZSJYNBAF.js} +1 -1
- package/dist/bundle/chunks/env-XZY4LKEO.js +1 -0
- package/dist/bundle/chunks/{expansion-GY7U2FC2.js → expansion-HJ6B4DDG.js} +1 -1
- package/dist/bundle/chunks/find-DQFMWHAC.js +1 -0
- package/dist/bundle/chunks/{flag-coverage-25MQKYJJ.js → flag-coverage-MPLWXQQK.js} +1 -1
- package/dist/bundle/chunks/{gzip-UTSGNF5Z.js → gzip-Y4N2UKE7.js} +1 -1
- package/dist/bundle/chunks/help-IA5CMGR4.js +1 -0
- package/dist/bundle/chunks/python3-6BKA3FYA.js +16 -0
- package/dist/bundle/chunks/rg-RAICUFGG.js +1 -0
- package/dist/bundle/chunks/{sleep-RKLUWJ7F.js → sleep-LB7FI6AB.js} +1 -1
- package/dist/bundle/chunks/sqlite3-FVNA4KNF.js +1 -0
- package/dist/bundle/chunks/{tar-H6XTXOAP.js → tar-E2DVQEWO.js} +1 -1
- package/dist/bundle/chunks/time-AGNW2ZY6.js +1 -0
- package/dist/bundle/chunks/timeout-VN35D5O7.js +1 -0
- package/dist/bundle/chunks/worker.js +154 -4
- package/dist/bundle/chunks/{xargs-OGI2NN6J.js → xargs-2BBAQDTC.js} +1 -1
- package/dist/bundle/index.cjs +817 -815
- package/dist/bundle/index.js +263 -263
- package/dist/commands/python3/fs-bridge-handler.d.ts +5 -1
- package/dist/commands/sqlite3/sqlite3.d.ts +6 -0
- package/dist/commands/tar/tar-options.d.ts +1 -0
- package/dist/interpreter/helpers/result.d.ts +6 -0
- package/dist/interpreter/interpreter.d.ts +2 -0
- package/dist/interpreter/types.d.ts +2 -0
- package/dist/limits.d.ts +2 -0
- package/dist/network/types.d.ts +1 -1
- package/dist/sandbox/Command.d.ts +8 -1
- package/dist/sandbox/Sandbox.d.ts +1 -0
- package/dist/timers.d.ts +1 -0
- package/dist/types.d.ts +12 -0
- package/package.json +1 -1
- package/dist/bin/chunks/chunk-27KQPTIX.js +0 -36
- package/dist/bin/chunks/chunk-4QM2TCNV.js +0 -2
- package/dist/bin/chunks/chunk-5UH3Q7QT.js +0 -11
- package/dist/bin/chunks/chunk-KLMOJKL4.js +0 -16
- package/dist/bin/chunks/chunk-KTFEQPO7.js +0 -4
- package/dist/bin/chunks/chunk-N73TVRMN.js +0 -14
- package/dist/bin/chunks/chunk-QC46PWBQ.js +0 -63
- package/dist/bin/chunks/chunk-W2FKF3MM.js +0 -9
- package/dist/bin/chunks/chunk-WIWKAGK6.js +0 -2
- package/dist/bin/chunks/env-EVLPSWFF.js +0 -2
- package/dist/bin/chunks/find-PHHSZYDL.js +0 -2
- package/dist/bin/chunks/flag-coverage-GZCUF7B4.js +0 -2
- package/dist/bin/chunks/help-JF5TTAKQ.js +0 -2
- package/dist/bin/chunks/python3-XRP5IZRL.js +0 -16
- package/dist/bin/chunks/rg-EJJ3ILD5.js +0 -2
- package/dist/bin/chunks/sqlite3-2UNB5OLS.js +0 -2
- package/dist/bin/chunks/time-4C3A4THJ.js +0 -2
- package/dist/bin/chunks/timeout-QMKFLOWX.js +0 -2
- package/dist/bin/shell/chunks/chunk-27KQPTIX.js +0 -36
- package/dist/bin/shell/chunks/chunk-4QM2TCNV.js +0 -2
- package/dist/bin/shell/chunks/chunk-5UH3Q7QT.js +0 -11
- package/dist/bin/shell/chunks/chunk-KLMOJKL4.js +0 -16
- package/dist/bin/shell/chunks/chunk-KTFEQPO7.js +0 -4
- package/dist/bin/shell/chunks/chunk-N73TVRMN.js +0 -14
- package/dist/bin/shell/chunks/chunk-QC46PWBQ.js +0 -63
- package/dist/bin/shell/chunks/chunk-W2FKF3MM.js +0 -9
- package/dist/bin/shell/chunks/chunk-WIWKAGK6.js +0 -2
- package/dist/bin/shell/chunks/env-EVLPSWFF.js +0 -2
- package/dist/bin/shell/chunks/find-PHHSZYDL.js +0 -2
- package/dist/bin/shell/chunks/flag-coverage-GZCUF7B4.js +0 -2
- package/dist/bin/shell/chunks/help-JF5TTAKQ.js +0 -2
- package/dist/bin/shell/chunks/python3-XRP5IZRL.js +0 -16
- package/dist/bin/shell/chunks/rg-EJJ3ILD5.js +0 -2
- package/dist/bin/shell/chunks/sqlite3-2UNB5OLS.js +0 -2
- package/dist/bin/shell/chunks/time-4C3A4THJ.js +0 -2
- package/dist/bin/shell/chunks/timeout-QMKFLOWX.js +0 -2
- package/dist/bundle/chunks/chunk-73RYQHTW.js +0 -10
- package/dist/bundle/chunks/chunk-CSBFBYLD.js +0 -13
- package/dist/bundle/chunks/chunk-FPGA7RT4.js +0 -62
- package/dist/bundle/chunks/chunk-K4OVSVUA.js +0 -35
- package/dist/bundle/chunks/chunk-LEOLL6PF.js +0 -1
- package/dist/bundle/chunks/chunk-OGDTSM2Q.js +0 -8
- package/dist/bundle/chunks/chunk-R7KYILVY.js +0 -3
- package/dist/bundle/chunks/chunk-YYAPW4OA.js +0 -1
- package/dist/bundle/chunks/chunk-ZKLK6C7H.js +0 -15
- package/dist/bundle/chunks/env-S547XMN7.js +0 -1
- package/dist/bundle/chunks/find-6U6YYAEP.js +0 -1
- package/dist/bundle/chunks/help-T2NGLTSG.js +0 -1
- package/dist/bundle/chunks/python3-E7VF6UYO.js +0 -15
- package/dist/bundle/chunks/rg-4YNHHQAE.js +0 -1
- package/dist/bundle/chunks/sqlite3-TLIZUW3F.js +0 -1
- package/dist/bundle/chunks/time-BPT76IHZ.js +0 -1
- package/dist/bundle/chunks/timeout-QDZFJCOQ.js +0 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{a as Z}from"./chunk-IJXFPKNC.js";import{a as te}from"./chunk-YNYSPYQ5.js";import{a as le,b as oe,c as ce}from"./chunk-EEXR5ZDP.js";import{a as ae,b as ie}from"./chunk-74CEPOFO.js";function N(e,t){switch(e.type){case"name":{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],o=t.name;if(e.ignoreCase){if(!o.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!o.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,r=t.relativePath,s=n.split("/");for(let i=0;i<s.length-1;i++){let a=s[i];if(a&&a!=="."&&a!==".."&&!a.includes("*")&&!a.includes("?")&&!a.includes("[")){let c=`/${a}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(c.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(c))return{matches:!1,pruned:!1,printed:!1}}}let o=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(o){let i=o[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(i))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(r,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:te(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24),s;return e.comparison==="more"?s=r>e.days:e.comparison==="less"?s=r<e.days:s=Math.floor(r)===e.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=t.size>n:e.comparison==="less"?r=t.size<n:e.unit==="b"?r=Math.ceil(t.size/512)===e.value:r=t.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,r=e.mode&511,s;return e.matchType==="exact"?s=n===r:e.matchType==="all"?s=(n&r)===r:s=(n&r)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=N(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=N(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=N(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=N(e.left,t);if(n.matches)return n;let r=N(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function Y(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return Y(e.expr);case"and":case"or":return Y(e.left)||Y(e.right)}}function _(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right);default:return!1}}function pe(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=be(e);if(ve(e)&&n.length===1){let o=n[0].split("/").filter(i=>i.length>0);if(o.length>=2)for(let i=o.length-2;i>=0;i--){let a=o[i];if(!a.includes("*")&&!a.includes("?")&&!a.includes("[")&&a!=="."&&a!==".."){let c=o[i+1];if(c&&(c.includes("*")||c.includes("?"))){t.terminalDirName=a;let l=c.match(/^\*(\.[a-zA-Z0-9]+)$/);l&&(t.requiredExtension=l[1])}break}}}return t}function be(e){let t=[],n=r=>{r.type==="path"?t.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(e),t}function ve(e){let t=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?t(n.expr):n.type==="and"||n.type==="or"?t(n.left)||t(n.right):!1;return t(e)}function fe(e){let t=[],n=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),t}function V(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return V(e.expr);case"and":case"or":return V(e.left)&&V(e.right)}}function H(e,t,n,r,s){switch(e.type){case"name":{let o=e.pattern,i=o.match(/^\*(\.[a-zA-Z0-9]+)$/);if(i){let a=i[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t,o,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let o=e.pattern,i=o.split("/");for(let c=0;c<i.length-1;c++){let l=i[c];if(l&&l!=="."&&l!==".."&&!l.includes("*")&&!l.includes("?")&&!l.includes("[")){let d=`/${l}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(d.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(d))return{matches:!1,pruned:!1,printed:!1}}}let a=o.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let c=a[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(c.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(c))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(n,o,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let o=e.ignoreCase?"i":"";return{matches:te(e.pattern,o).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:r,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let o=H(e.expr,t,n,r,s);return{matches:!o.matches,pruned:o.pruned,printed:!1}}case"and":{let o=H(e.left,t,n,r,s);if(!o.matches)return{matches:!1,pruned:o.pruned,printed:!1};let i=H(e.right,t,n,r,s);return{matches:i.matches,pruned:o.pruned||i.pruned,printed:o.printed||i.printed}}case"or":{let o=H(e.left,t,n,r,s);if(o.matches)return o;let i=H(e.right,t,n,r,s);return{matches:i.matches,pruned:o.pruned||i.pruned,printed:i.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function J(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return J(e.expr);case"and":case"or":return J(e.left)||J(e.right);default:return!1}}function z(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return z(e.expr);case"and":case"or":return z(e.left)&&z(e.right)}}function ue(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!z(e))return ne(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:N(e,n).pruned}}function ne(e,t){switch(e.type){case"or":{if(z(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(N(e.left,n).pruned)return{shouldPrune:!0}}return ne(e.right,t)}case"and":{if(z(e.left)&&z(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:N(e,n).pruned}}if(z(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return N(e.left,n).matches?ne(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function he(e,t){let n=[],r=[],s=t;for(;s<e.length;){let i=e[s];if(i==="("||i==="\\("){n.push({type:"lparen"}),s++;continue}if(i===")"||i==="\\)"){n.push({type:"rparen"}),s++;continue}if(i==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(i==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(i==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(i==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(i==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(i==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(i==="-type"&&s+1<e.length){let a=e[++s];if(a==="f"||a==="d")n.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
|
|
2
|
-
`,actions:[]}}else if(i==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(i==="-mtime"&&s+1<e.length){let a=e[++s],c="exact",l=a;a.startsWith("+")?(c="more",l=a.slice(1)):a.startsWith("-")&&(c="less",l=a.slice(1));let d=parseInt(l,10);Number.isNaN(d)||n.push({type:"expr",expr:{type:"mtime",days:d,comparison:c}})}else if(i==="-newer"&&s+1<e.length){let a=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:a}})}else if(i==="-size"&&s+1<e.length){let a=e[++s],c="exact",l=a;a.startsWith("+")?(c="more",l=a.slice(1)):a.startsWith("-")&&(c="less",l=a.slice(1));let d=l.match(/^(\d+)([ckMGb])?$/);if(d){let B=parseInt(d[1],10),I=d[2]||"b";n.push({type:"expr",expr:{type:"size",value:B,unit:I,comparison:c}})}}else if(i==="-perm"&&s+1<e.length){let a=e[++s],c="exact",l=a;a.startsWith("-")?(c="all",l=a.slice(1)):a.startsWith("/")&&(c="any",l=a.slice(1));let d=parseInt(l,8);Number.isNaN(d)||n.push({type:"expr",expr:{type:"perm",mode:d,matchType:c}})}else if(i==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(i==="-not"||i==="!")n.push({type:"not"});else if(i==="-o"||i==="-or")n.push({type:"op",op:"or"});else if(i==="-a"||i==="-and")n.push({type:"op",op:"and"});else if(i==="-maxdepth"||i==="-mindepth")s++;else if(i!=="-depth")if(i==="-exec"){let a=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)a.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[s]==="+";r.push({type:"exec",command:a,batchMode:c})}else if(i==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(i==="-print0")r.push({type:"print0"});else if(i==="-printf"&&s+1<e.length){let a=e[++s];r.push({type:"printf",format:a})}else if(i==="-delete")r.push({type:"delete"});else{if(i.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${i}'
|
|
3
|
-
`,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let o=Ee(n);return o.error?{expr:null,pathIndex:s,error:o.error,actions:r}:{expr:o.expr,pathIndex:s,actions:r}}function Ee(e){let t=0;function n(){let a=r();if(!a)return null;for(;t<e.length;){let c=e[t];if(c.type==="op"&&c.op==="or"){t++;let l=r();if(!l)return a;a={type:"or",left:a,right:l}}else break}return a}function r(){let a=s();if(!a)return null;for(;t<e.length;){let c=e[t];if(c.type==="op"&&c.op==="and"){t++;let l=s();if(!l)return a;a={type:"and",left:a,right:l}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let l=s();if(!l)return a;a={type:"and",left:a,right:l}}else break}return a}function s(){if(t<e.length&&e[t].type==="not"){t++;let a=s();return a?{type:"not",expr:a}:null}return o()}function o(){if(t>=e.length)return null;let a=e[t];if(a.type==="lparen"){t++;let c=n();return t<e.length&&e[t].type==="rparen"&&t++,c}return a.type==="expr"?(t++,a.expr):(a.type==="rparen",null)}return{expr:n()}}var de=500;function Me(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function xe(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}var Fe={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},Ie=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),je={name:"find",async execute(e,t){if(ie(e))return ae(Fe);let n=[],r=null,s=null,o=!1,i=!1;for(let p=0;p<e.length;p++){let f=e[p];if(f==="-maxdepth"&&p+1<e.length)i=!0,r=parseInt(e[++p],10);else if(f==="-mindepth"&&p+1<e.length)i=!0,s=parseInt(e[++p],10);else if(f==="-depth")i=!0,o=!0;else if(f==="-exec")for(i=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!f.startsWith("-")&&f!==";"&&f!=="+"&&f!=="("&&f!==")"&&f!=="\\("&&f!=="\\)"&&f!=="!"?i||n.push(f):Ie.has(f)?(i=!0,p++):(f.startsWith("-")||f==="("||f==="\\("||f==="!")&&(i=!0)}n.length===0&&n.push(".");let{expr:a,error:c,actions:l}=he(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let d=l.some(p=>p.type==="print"),B=l.length===0,I=[],me=l.some(p=>p.type==="printf"),se=[],q="",G=0,ye=fe(a),U=new Map;for(let p of ye){let f=t.fs.resolvePath(t.cwd,p);try{let h=await t.fs.stat(f);U.set(p,h.mtime?.getTime()??Date.now())}catch{}}let ge=l.some(p=>{if(p.type!=="printf")return!1;let f=p.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(f)}),we=Y(a)||ge,De=_(a),K=pe(a),re=J(a),Te=V(a),Ce=typeof t.fs.readdirWithFileTypes=="function";for(let p of n){let W=function(u){let R=s===null||u.depth>=s,P=!1;if(R&&a!==null){let S=Date.now(),y;if(Te)y=H(a,u.name,u.relativePath,u.isFile,u.isDirectory);else{let m={name:u.name,relativePath:u.relativePath,isFile:u.isFile,isDirectory:u.isDirectory,isEmpty:u.isEmpty,mtime:u.stat?.mtime?.getTime()??Date.now(),size:u.stat?.size??0,mode:u.stat?.mode??420,newerRefTimes:U};y=N(a,m)}R=y.matches,P=d?y.printed:R,h.evalCalls++,h.evalTime+=Date.now()-S}else R&&(P=!0);return P?{print:!0,printfData:me?{path:u.relativePath,name:u.name,size:u.stat?.size??0,mtime:u.stat?.mtime?.getTime()??Date.now(),mode:u.stat?.mode??420,isDirectory:u.isDirectory,depth:u.depth,startingPoint:p}:null}:{print:!1,printfData:null}};var We=W;p.length>1&&p.endsWith("/")&&(p=p.slice(0,-1));let f=t.fs.resolvePath(t.cwd,p);try{await t.fs.stat(f)}catch{q+=`find: ${p}: No such file or directory
|
|
4
|
-
`,G=1;continue}let h=Me(),$=Date.now();async function b(u){let{path:v,depth:R,typeInfo:P}=u;if(h.nodeCount++,R>(r??256))return null;let E,S,y;if(P&&!we)E=P.isFile,S=P.isDirectory;else{try{let L=Date.now();y=await t.fs.stat(v),h.statCalls++,h.statTime+=Date.now()-L}catch{return null}if(!y)return null;E=y.isFile,S=y.isDirectory}let m;v===f?m=p.split("/").pop()||p:m=v.split("/").pop()||"";let g=v===f?p:p==="."?`./${v.slice(f==="/"?f.length:f.length+1)}`:p+v.slice(f.length),T=[],C=null,w=null,D=!1;S&&re&&!o&&(D=ue(a,{name:m,relativePath:g,isFile:E,isDirectory:S}).shouldPrune,D&&h.earlyPrunes++);let x=R>=(r??256),F=K.terminalDirName!==null&&m===K.terminalDirName,j=!x&&!F&&!D;if(S&&((j||De||F)&&!D)){let L=Date.now();if(Ce&&t.fs.readdirWithFileTypes){if(C=await t.fs.readdirWithFileTypes(v),w=C.map(M=>M.name),h.readdirCalls++,h.readdirTime+=Date.now()-L,j)T=C.map((M,k)=>({path:v==="/"?`/${M.name}`:`${v}/${M.name}`,depth:R+1,typeInfo:{isFile:M.isFile,isDirectory:M.isDirectory},resultIndex:k}));else if(F){let M=K.requiredExtension;T=C.filter(k=>k.isFile&&(!M||k.name.endsWith(M))).map((k,Se)=>({path:v==="/"?`/${k.name}`:`${v}/${k.name}`,depth:R+1,typeInfo:{isFile:k.isFile,isDirectory:k.isDirectory},resultIndex:Se}))}}else w=await t.fs.readdir(v),h.readdirCalls++,h.readdirTime+=Date.now()-L,j&&(T=w.map((M,k)=>({path:v==="/"?`/${M}`:`${v}/${M}`,depth:R+1,resultIndex:k})))}let Q=E?(y?.size??0)===0:w!==null&&w.length===0,O=D;if(!o&&a!==null&&!D&&re){let L=Date.now(),M={name:m,relativePath:g,isFile:E,isDirectory:S,isEmpty:Q,mtime:y?.mtime?.getTime()??Date.now(),size:y?.size??0,mode:y?.mode??420,newerRefTimes:U};O=N(a,M).pruned,h.evalCalls++,h.evalTime+=Date.now()-L}return{relativePath:g,name:m,isFile:E,isDirectory:S,isEmpty:Q,stat:y,depth:R,children:O?[]:T,pruned:O}}async function Pe(){let u={paths:[],printfData:[]};if(o){let y=function(m){let g={paths:[],printfData:[]},T=P[m];if(!T)return g;for(let D of T.childIndices){let x=y(D);g.paths.push(...x.paths),g.printfData.push(...x.printfData)}let{print:C,printfData:w}=W(T.node);return C&&(g.paths.push(T.node.relativePath),w&&g.printfData.push(w)),g};var v=y;let P=[],E=[{item:{path:f,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],S=new Map;for(;E.length>0;){let m=Date.now(),g=E.splice(0,de),T=await Promise.all(g.map(C=>b(C.item)));h.batchCount++,h.batchTime+=Date.now()-m;for(let C=0;C<g.length;C++){let w=T[C],D=g[C];if(!w)continue;let x=P.length;if(D.parentIndex>=0){let F=S.get(D.parentIndex)||[];F.push(x),S.set(D.parentIndex,F)}P.push({node:w,parentIndex:D.parentIndex,childIndices:[]});for(let F=0;F<w.children.length;F++)E.push({item:w.children[F],parentIndex:x,childOrderInParent:F})}}for(let[m,g]of S)m>=0&&m<P.length&&(P[m].childIndices=g);if(P.length>0){let m=y(0);u.paths.push(...m.paths),u.printfData.push(...m.printfData)}}else{let m=function(g){let T=P.get(g);T&&(u.paths.push(T.path),T.printfData&&u.printfData.push(T.printfData));let C=y.get(g);if(C)for(let w of C)m(w)};var R=m;let P=new Map,E=0,S=[{item:{path:f,depth:0,resultIndex:0},orderIndex:E++}],y=new Map;for(;S.length>0;){let g=Date.now(),T=S.splice(0,de),C=await Promise.all(T.map(async({item:w,orderIndex:D})=>{let x=await b(w);return x?{node:x,orderIndex:D}:null}));h.batchCount++,h.batchTime+=Date.now()-g;for(let w of C){if(!w)continue;let{node:D,orderIndex:x}=w,{print:F,printfData:j}=W(D);if(F&&P.set(x,{path:D.relativePath,printfData:j}),D.children.length>0){let ee=[];for(let Q of D.children){let O=E++;ee.push(O),S.push({item:Q,orderIndex:O})}y.set(x,ee)}}}m(0)}return u}let X=await Pe();if(I.push(...X.paths),se.push(...X.printfData),t.trace){let u=Date.now()-$;xe(t.trace,h,u),t.trace({category:"find",name:"searchPath",durationMs:u,details:{path:p,resultsFound:X.paths.length}})}}let A="";if(l.length>0)for(let p of l)switch(p.type){case"print":A+=I.length>0?`${I.join(`
|
|
5
|
-
`)}
|
|
6
|
-
`:"";break;case"print0":A+=I.length>0?`${I.join("\0")}\0`:"";break;case"delete":{let f=[...I].sort((h,$)=>$.length-h.length);for(let h of f){let $=t.fs.resolvePath(t.cwd,h);try{await t.fs.rm($,{recursive:!1})}catch(b){let W=b instanceof Error?b.message:String(b);q+=`find: cannot delete '${h}': ${W}
|
|
7
|
-
`,G=1}}break}case"printf":for(let f of se)A+=$e(p.format,f);break;case"exec":if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
8
|
-
`,exitCode:1};if(p.batchMode){let f=[];for(let b of p.command)b==="{}"?f.push(...I):f.push(b);let h=f.map(b=>`"${b}"`).join(" "),$=await t.exec(h,{cwd:t.cwd});A+=$.stdout,q+=$.stderr,$.exitCode!==0&&(G=$.exitCode)}else for(let f of I){let $=p.command.map(W=>W==="{}"?f:W).map(W=>`"${W}"`).join(" "),b=await t.exec($,{cwd:t.cwd});A+=b.stdout,q+=b.stderr,b.exitCode!==0&&(G=b.exitCode)}break}else B&&(A=I.length>0?`${I.join(`
|
|
9
|
-
`)}
|
|
10
|
-
`:"");return{stdout:A,stderr:q,exitCode:G}}};function $e(e,t){let n=ce(e),r="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){r+="%",s++;continue}let[o,i,a]=oe(n,s);if(s+=a,s>=n.length){r+="%";break}let c=n[s],l;switch(c){case"f":l=t.name,s++;break;case"h":{let d=t.path.lastIndexOf("/");l=d>0?t.path.slice(0,d):".",s++;break}case"p":l=t.path,s++;break;case"P":{let d=t.startingPoint;t.path===d?l="":t.path.startsWith(`${d}/`)?l=t.path.slice(d.length+1):d==="."&&t.path.startsWith("./")?l=t.path.slice(2):l=t.path,s++;break}case"s":l=String(t.size),s++;break;case"d":l=String(t.depth),s++;break;case"m":l=(t.mode&511).toString(8),s++;break;case"M":l=Re(t.mode,t.isDirectory),s++;break;case"t":{let d=new Date(t.mtime);l=ke(d),s++;break}case"T":{if(s+1<n.length){let d=n[s+1],B=new Date(t.mtime);l=Ne(B,d),s+=2}else l="%T",s++;break}default:r+=`%${o!==0||i!==-1?`${o}.${i}`:""}${c}`,s++;continue}r+=le(l,o,i)}else r+=n[s],s++;return r}function Re(e,t){let n=e&511,r=t?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function ke(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=t[e.getDay()],s=n[e.getMonth()],o=String(e.getDate()).padStart(2," "),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),l=e.getFullYear();return`${r} ${s} ${o} ${i}:${a}:${c} ${l}`}function Ne(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var Ze={name:"find",flags:[{flag:"-name",type:"value",valueHint:"pattern"},{flag:"-iname",type:"value",valueHint:"pattern"},{flag:"-type",type:"value",valueHint:"string"},{flag:"-maxdepth",type:"value",valueHint:"number"},{flag:"-mindepth",type:"value",valueHint:"number"},{flag:"-empty",type:"boolean"},{flag:"-print",type:"boolean"},{flag:"-print0",type:"boolean"}],needsFiles:!0};export{je as a,Ze as b};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{a as c}from"./chunk-OJDRYQWQ.js";var C={name:"time",async execute(i,r){let a="%e %M",o=null,d=!1,m=!1,t=0;for(;t<i.length;){let e=i[t];if(e==="-f"||e==="--format"){if(t++,t>=i.length)return{stdout:"",stderr:`time: missing argument to '-f'
|
|
2
|
-
`,exitCode:1};a=i[t],t++}else if(e==="-o"||e==="--output"){if(t++,t>=i.length)return{stdout:"",stderr:`time: missing argument to '-o'
|
|
3
|
-
`,exitCode:1};o=i[t],t++}else if(e==="-a"||e==="--append")d=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
|
|
4
|
-
Elapsed (wall clock) time: %e seconds
|
|
5
|
-
Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")m=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let f=i.slice(t);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let p=performance.now(),u=f.join(" "),s;try{if(!r.exec)return{stdout:"",stderr:`time: exec not available
|
|
6
|
-
`,exitCode:1};s=await r.exec(u,{env:c(r.env),cwd:r.cwd})}catch(e){s={stdout:"",stderr:`time: ${e.message}
|
|
7
|
-
`,exitCode:127}}let l=(performance.now()-p)/1e3,n;if(m?n=`real ${l.toFixed(2)}
|
|
8
|
-
user 0.00
|
|
9
|
-
sys 0.00
|
|
10
|
-
`:(n=a.replace(/%e/g,l.toFixed(2)).replace(/%E/g,w(l)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,u),n.endsWith(`
|
|
11
|
-
`)||(n+=`
|
|
12
|
-
`)),o)try{let e=r.fs.resolvePath(r.cwd,o);if(d&&await r.fs.exists(e)){let g=await r.fs.readFile(e);await r.fs.writeFile(e,g+n)}else await r.fs.writeFile(e,n)}catch(e){return{stdout:s.stdout,stderr:s.stderr+`time: cannot write to '${o}': ${e.message}
|
|
13
|
-
`,exitCode:s.exitCode}}else s={...s,stderr:s.stderr+n};return s}};function w(i){let r=Math.floor(i/3600),a=Math.floor(i%3600/60),o=i%60;return r>0?`${r}:${a.toString().padStart(2,"0")}:${o.toFixed(2).padStart(5,"0")}`:`${a}:${o.toFixed(2).padStart(5,"0")}`}var F={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{C as a,F as b};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import{b as K}from"./chunk-R7KYILVY.js";import{a as x}from"./chunk-YNYSPYQ5.js";import{a as ie,b as se,c as P}from"./chunk-74CEPOFO.js";import xe from"compressjs";var W="file",ce="link",le="symlink",M="directory",$e={file:"0",link:"1",symlink:"2","character-device":"3","block-device":"4",directory:"5",fifo:"6","pax-header":"x","pax-global-header":"g","gnu-long-name":"L","gnu-long-link-name":"K"},Ze={0:W,1:ce,2:le,3:"character-device",4:"block-device",5:M,6:"fifo",x:"pax-header",g:"pax-global-header",L:"gnu-long-name",K:"gnu-long-link-name"},Be=new Uint8Array(512),O=new Uint8Array(0),U=new TextEncoder,ue=new TextDecoder;function T(e,t,n,r){r&&U.encodeInto(r,e.subarray(t,t+n))}function v(e,t,n,r){if(r===void 0)return;let i=r.toString(8).padStart(n-1,"0");U.encodeInto(i,e.subarray(t,t+n-1))}function A(e,t,n){let r=e.indexOf(0,t),i=r===-1||r>t+n?t+n:r;return ue.decode(e.subarray(t,i))}function X(e,t,n){let r=0,i=t+n;for(let s=t;s<i;s++){let o=e[s];if(o===0)break;o!==32&&(r=r*8+(o-48))}return r}function k(e,t,n){if(e[t]&128){let r=0;r=e[t]&127;for(let i=1;i<n;i++)r=r*256+e[t+i];if(!Number.isSafeInteger(r))throw new Error("TAR number too large");return r}return X(e,t,n)}var z=e=>e.type===M||e.type===le||e.type===ce;async function fe(e){if(e==null)return O;if(e instanceof Uint8Array)return e;if(typeof e=="string")return U.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Blob)return new Uint8Array(await e.arrayBuffer());throw new TypeError("Unsupported content type for entry body.")}function de(e,t){let{strip:n,filter:r,map:i}=t;if(!n&&!r&&!i)return e;let s={...e};if(n&&n>0){let a=s.name.split("/").filter(Boolean);if(n>=a.length)return null;let c=a.slice(n).join("/");if(s.name=s.type===M&&!c.endsWith("/")?`${c}/`:c,s.linkname?.startsWith("/")){let l=s.linkname.split("/").filter(Boolean);s.linkname=n>=l.length?"/":`/${l.slice(n).join("/")}`}}if(r?.(s)===!1)return null;let o=i?i(s):s;return o&&(!o.name||!o.name.trim()||o.name==="."||o.name==="/")?null:o}var H=32,De=48;function Ne(e){let t=X(e,148,8),n=0;for(let r=0;r<e.length;r++)r>=148&&r<156?n+=H:n+=e[r];return t===n}function Le(e){e.fill(H,148,156);let t=0;for(let n of e)t+=n;for(let n=153;n>=148;n--)e[n]=(t&7)+De,t>>=3;e[154]=0,e[155]=H}function Ke(e){let t={};e.name.length>100&&me(e.name)===null&&(t.path=e.name),e.linkname&&e.linkname.length>100&&(t.linkpath=e.linkname),e.uname&&e.uname.length>32&&(t.uname=e.uname),e.gname&&e.gname.length>32&&(t.gname=e.gname),e.uid!=null&&e.uid>2097151&&(t.uid=String(e.uid)),e.gid!=null&&e.gid>2097151&&(t.gid=String(e.gid)),e.size!=null&&e.size>8589934591&&(t.size=String(e.size)),e.pax&&Object.assign(t,e.pax);let n=Object.entries(t);if(n.length===0)return null;let r=U.encode(n.map(([i,s])=>{let o=`${i}=${s}
|
|
2
|
-
`,a=U.encode(o).length+1,c=a+String(a).length;return c=a+String(c).length,`${c} ${o}`}).join(""));return{paxHeader:pe({name:ue.decode(U.encode(`PaxHeader/${e.name}`).slice(0,100)),size:r.length,type:"pax-header",mode:420,mtime:e.mtime,uname:e.uname,gname:e.gname,uid:e.uid,gid:e.gid}),paxBody:r}}function me(e){if(e.length<=100)return null;let t=e.length-100-1,n=e.lastIndexOf("/",155);return n>0&&n>=t?{prefix:e.slice(0,n),name:e.slice(n+1)}:null}function pe(e){let t=new Uint8Array(512),n=z(e)?0:e.size??0,r=e.name,i="";if(!e.pax?.path){let s=me(r);s&&(r=s.name,i=s.prefix)}return T(t,0,100,r),v(t,100,8,e.mode??(e.type===M?493:420)),v(t,108,8,e.uid??0),v(t,116,8,e.gid??0),v(t,124,12,n),v(t,136,12,Math.floor((e.mtime?.getTime()??Date.now())/1e3)),T(t,156,1,$e[e.type??W]),T(t,157,100,e.linkname),T(t,257,6,"ustar\0"),T(t,263,2,"00"),T(t,265,32,e.uname),T(t,297,32,e.gname),T(t,345,155,i),Le(t),t}function Pe(e,t){if(t&&!Ne(e))throw new Error("Invalid tar header checksum.");let n=A(e,156,1),r={name:A(e,0,100),mode:X(e,100,8),uid:k(e,108,8),gid:k(e,116,8),size:k(e,124,12),mtime:new Date(k(e,136,12)*1e3),type:Ze[n]||W,linkname:A(e,157,100)},i=A(e,257,6);return i.trim()==="ustar"&&(r.uname=A(e,265,32),r.gname=A(e,297,32)),i==="ustar"&&(r.prefix=A(e,345,155)),r}var Ge={path:["name",e=>e],linkpath:["linkname",e=>e],size:["size",e=>parseInt(e,10)],mtime:["mtime",parseFloat],uid:["uid",e=>parseInt(e,10)],gid:["gid",e=>parseInt(e,10)],uname:["uname",e=>e],gname:["gname",e=>e]};function He(e){let t=new TextDecoder("utf-8"),n={},r={},i=0;for(;i<e.length;){let s=e.indexOf(32,i);if(s===-1)break;let o=parseInt(t.decode(e.subarray(i,s)),10);if(Number.isNaN(o)||o===0)break;let a=i+o,[c,l]=t.decode(e.subarray(s+1,a-1)).split("=",2);if(c&&l!==void 0){r[c]=l;let d=Ge[c];if(d){let[u,g]=d,p=g(l);(typeof p=="string"||!Number.isNaN(p))&&(n[u]=p)}}i=a}return Object.keys(r).length>0&&(n.pax=r),n}function ae(e,t){t.name!==void 0&&(e.name=t.name),t.linkname!==void 0&&(e.linkname=t.linkname),t.size!==void 0&&(e.size=t.size),t.mtime!==void 0&&(e.mtime=new Date(t.mtime*1e3)),t.uid!==void 0&&(e.uid=t.uid),t.gid!==void 0&&(e.gid=t.gid),t.uname!==void 0&&(e.uname=t.uname),t.gname!==void 0&&(e.gname=t.gname),t.pax&&(e.pax=Object.assign({},e.pax??{},t.pax))}function We(e){switch(e){case"pax-global-header":case"pax-header":return He;case"gnu-long-name":return t=>({name:A(t,0,t.length)});case"gnu-long-link-name":return t=>({linkname:A(t,0,t.length)});default:return}}function Xe(e){let t=pe(e),n=Ke(e);if(!n)return[t];let r=-n.paxBody.length&511,i=r>0?[Be.subarray(0,r)]:[];return[n.paxHeader,n.paxBody,...i,t]}var je=new Uint8Array(512*2);function he(e,t,n){let r=null,i=0,s=!1;return{add(o){if(s){let a=new Error("No new tar entries after finalize.");throw t(a),a}if(r!==null){let a=new Error("Previous entry must be completed before adding a new one");throw t(a),a}try{let a=z(o)?0:o.size??0,c=Xe({...o,size:a});for(let l of c)e(l);r={...o,size:a},i=0}catch(a){t(a)}},write(o){if(!r){let c=new Error("No active tar entry.");throw t(c),c}if(s){let c=new Error("Cannot write data after finalize.");throw t(c),c}let a=i+o.length;if(a>r.size){let c=new Error(`"${r.name}" exceeds given size of ${r.size} bytes.`);throw t(c),c}try{i=a,e(o)}catch(c){t(c)}},endEntry(){if(!r){let o=new Error("No active entry to end.");throw t(o),o}if(s){let o=new Error("Cannot end entry after finalize.");throw t(o),o}try{if(i!==r.size){let a=new Error(`Size mismatch for "${r.name}".`);throw t(a),a}let o=-r.size&511;o>0&&e(new Uint8Array(o)),r=null,i=0}catch(o){throw t(o),o}},finalize(){if(s){let o=new Error("Archive has already been finalized");throw t(o),o}if(r!==null){let o=new Error("Cannot finalize while an entry is still active");throw t(o),o}try{e(je),s=!0,n&&n()}catch(o){t(o)}}}}var R=256;function qe(){let e=new Array(R),t=e.length-1,n=0,r=0,i=0,s=a=>{let c=e[n];a===c.length?(e[n]=O,n=n+1&t):e[n]=c.subarray(a),i-=a,i===0&&e.length>R&&(e=new Array(R),t=R-1,n=0,r=0)};function o(a,c){if(c){let p=0,f=Math.min(a,i);for(;f>0;){let h=e[n],m=Math.min(f,h.length),S=m===h.length?h:h.subarray(0,m);if(s(m),f-=m,p+=m,!c(S))break}return p}if(i<a)return null;if(a===0)return O;let l=e[n];if(l.length>=a){let p=l.length===a?l:l.subarray(0,a);return s(a),p}let d=new Uint8Array(a),u=0,g=a;for(;g>0;){let p=e[n],f=Math.min(g,p.length);d.set(f===p.length?p:p.subarray(0,f),u),u+=f,g-=f,s(f)}return d}return{push:a=>{if(a.length===0)return;let c=r+1&t;if(c===n){let l=e.length,d=l*2,u=new Array(d),g=r-n+l&l-1;if(n<r)for(let p=0;p<g;p++)u[p]=e[n+p];else if(g>0){let p=l-n;for(let f=0;f<p;f++)u[f]=e[n+f];for(let f=0;f<r;f++)u[p+f]=e[f]}e=u,t=d-1,n=0,r=g,c=r+1&t}e[r]=a,r=c,i+=a.length},available:()=>i,peek:a=>{if(i<a)return null;if(a===0)return O;let c=e[n];if(c.length>=a)return c.length===a?c:c.subarray(0,a);let l=new Uint8Array(a),d=0,u=n;for(;d<a;){let g=e[u],p=Math.min(a-d,g.length);p===g.length?l.set(g,d):l.set(g.subarray(0,p),d),d+=p,u=u+1&t}return l},discard:a=>{if(a>i)throw new Error("Too many bytes consumed");if(a===0)return;let c=a;for(;c>0;){let l=e[n],d=Math.min(c,l.length);s(d),c-=d}},pull:o}}var G=0,F=1,b=new Error("Tar archive is truncated.");function ge(e={}){let t=e.strict??!1,{available:n,peek:r,push:i,discard:s,pull:o}=qe(),a=G,c=!1,l=!1,d=!1,u=null,g={},p={},f={isEntryActive:()=>a===F,isBodyComplete:()=>!u||u.remaining===0,write(h){if(c)throw new Error("Archive already ended.");i(h)},end(){c=!0},readHeader(){if(a!==G)throw new Error("Cannot read header while an entry is active");if(!l)for(;!l;){if(n()<512){if(c){if(n()>0&&t)throw b;l=!0;return}return null}let h=r(512);if(oe(h)){if(n()<512*2){if(c){if(t)throw b;l=!0;return}return null}if(oe(r(512*2).subarray(512))){s(512*2),l=!0,d=!0;return}if(t)throw new Error("Invalid tar header.");s(512);continue}let m;try{m=Pe(h,t)}catch(y){if(t)throw y;s(512);continue}let S=We(m.type);if(S){let y=m.size+511&-512;if(n()<512+y){if(c&&t)throw b;return null}s(512);let I=S(o(y).subarray(0,m.size)),Me=m.type==="pax-global-header"?g:p;for(let ne in I)Me[ne]=I[ne];continue}s(512);let E=m;return m.prefix&&(E.name=`${m.prefix}/${E.name}`),ae(E,g),ae(E,p),p={},u={header:E,remaining:E.size,padding:-E.size&511},a=F,E}},streamBody(h){if(a!==F||!u||u.remaining===0)return 0;let m=Math.min(u.remaining,n());if(m===0)return 0;let S=o(m,h);return u.remaining-=S,S},skipPadding(){if(a!==F||!u)return!0;if(u.remaining>0)throw new Error("Body not fully consumed");return n()<u.padding?!1:(s(u.padding),u=null,a=G,!0)},skipEntry(){if(a!==F||!u)return!0;let h=Math.min(u.remaining,n());return h>0&&(s(h),u.remaining-=h),u.remaining>0?!1:f.skipPadding()},validateEOF(){if(t){if(!d)throw b;if(n()>0&&o(n()).some(h=>h!==0))throw new Error("Invalid EOF.")}}};return f}function oe(e){if(e.byteOffset%8===0){let t=new BigUint64Array(e.buffer,e.byteOffset,e.length/8);for(let n=0;n<t.length;n++)if(t[n]!==0n)return!1;return!0}for(let t=0;t<e.length;t++)if(e[t]!==0)return!1;return!0}function Ee(){return new CompressionStream("gzip")}function ye(){return new DecompressionStream("gzip")}function Ye(){let e,t;return{readable:new ReadableStream({start(n){e=n,t=he(n.enqueue.bind(n),n.error.bind(n),n.close.bind(n))}}),controller:{add(n){let r=z(n),i={...n};return r&&(i.size=0),t.add(i),r&&t.endEntry(),new WritableStream({write(s){t.write(s)},close(){r||t.endEntry()},abort(s){e.error(s)}})},finalize(){t.finalize()},error(n){e.error(n)}}}}async function we(e){let t=[],n=e.getReader(),r=0;try{for(;;){let{done:o,value:a}=await n.read();if(o)break;t.push(a),r+=a.length}let i=new Uint8Array(r),s=0;for(let o of t)i.set(o,s),s+=o.length;return i}finally{n.releaseLock()}}var Se=e=>e.pipeTo(new WritableStream);function Ve(e={}){let t=ge(e),n=null,r=!1,i=s=>{if(!r){r=!0;try{for(;;)if(t.isEntryActive()){if(n){if(t.streamBody(o=>(n.enqueue(o),!0))===0&&!t.isBodyComplete())break}else if(!t.skipEntry())break;if(t.isBodyComplete()){try{n?.close()}catch{}if(n=null,!t.skipPadding())break}}else{let o=t.readHeader();if(o==null)break;s.enqueue({header:o,body:new ReadableStream({start(a){o.size===0?a.close():n=a},pull:()=>i(s),cancel(){n=null,i(s)}})})}}catch(o){try{n?.error(o)}catch{}throw n=null,o}finally{r=!1}}};return new TransformStream({transform(s,o){try{t.write(s),i(o)}catch(a){try{n?.error(a)}catch{}throw a}},flush(s){try{if(t.end(),i(s),t.validateEOF(),t.isEntryActive()&&!t.isBodyComplete())try{n?.close()}catch{}}catch(o){try{n?.error(o)}catch{}throw o}}},void 0,{highWaterMark:1})}async function Ae(e){let{readable:t,controller:n}=Ye();return await(async()=>{for(let r of e){let i=n.add(r.header),s="body"in r?r.body:r.data;if(!s){await i.close();continue}if(s instanceof ReadableStream)await s.pipeTo(i);else if(s instanceof Blob)await s.stream().pipeTo(i);else try{let o=await fe(s);if(o.length>0){let a=i.getWriter();await a.write(o),await a.close()}else await i.close()}catch{throw new TypeError(`Unsupported content type for entry "${r.header.name}".`)}}})().then(()=>n.finalize()).catch(r=>n.error(r)),new Uint8Array(await we(t))}async function _e(e,t={}){let n=e instanceof ReadableStream?e:new ReadableStream({start(s){s.enqueue(e instanceof Uint8Array?e:new Uint8Array(e)),s.close()}}),r=[],i=n.pipeThrough(Ve(t));for await(let s of i){let o;try{o=de(s.header,t)}catch(a){throw await s.body.cancel(),a}if(o===null){await Se(s.body);continue}z(o)?(await Se(s.body),r.push({header:o})):r.push({header:o,data:await we(s.body)})}return r}var $=null,Z=null;async function Ue(){if($)return $;if(Z)throw Z;try{return $=await K.runTrustedAsync(()=>import("node-liblzma")),$}catch{throw Z=new Error("xz compression requires node-liblzma which failed to load. Install liblzma-dev (apt) or xz (brew) and reinstall dependencies."),Z}}var B=null,D=null;async function Ie(){if(B)return B;if(D)throw D;try{return B=await K.runTrustedAsync(()=>import("@mongodb-js/zstd")),B}catch{throw D=new Error("zstd compression requires @mongodb-js/zstd which is not installed. Install it with: npm install @mongodb-js/zstd"),D}}var w=100*1024*1024,Te=512,Ce=1e4;function Je(e){let t="file";e.isDirectory?t="directory":e.isSymlink&&(t="symlink");let n=e.name;e.isDirectory&&!n.endsWith("/")&&(n+="/");let r;e.content!==void 0&&(typeof e.content=="string"?r=new TextEncoder().encode(e.content):r=e.content);let i=e.isDirectory||e.isSymlink?0:r?.length??0;return{header:{name:n,mode:e.mode??(e.isDirectory?493:420),uid:e.uid??0,gid:e.gid??0,size:i,mtime:e.mtime??new Date,type:t,linkname:e.linkTarget??"",uname:"user",gname:"user"},body:r}}async function C(e){let t=e.map(Je);return Ae(t)}async function ve(e){let t=await C(e),i=new ReadableStream({start(l){l.enqueue(t),l.close()}}).pipeThrough(Ee()).getReader(),s=[];for(;;){let{done:l,value:d}=await i.read();if(l)break;s.push(d)}let o=s.reduce((l,d)=>l+d.length,0),a=new Uint8Array(o),c=0;for(let l of s)a.set(l,c),c+=l.length;return a}async function _(e){if(e.length>w)return{entries:[],error:`Archive too large (max ${w} bytes)`};if(e.length<Te||e.length%Te!==0)return{entries:[],error:"Invalid tar archive format"};try{let t=await _e(e),n=[];for(let r of t){if(n.length>=Ce)return{entries:n,error:`Too many entries (max ${Ce})`};let i="file";switch(r.header.type){case"directory":i="directory";break;case"symlink":i="symlink";break;case"link":i="hardlink";break;case"file":i="file";break;default:i="other"}n.push({name:r.header.name,mode:r.header.mode??420,uid:r.header.uid??0,gid:r.header.gid??0,size:r.header.size,mtime:r.header.mtime??new Date,type:i,linkTarget:r.header.linkname||void 0,content:r.data??new Uint8Array(0)})}return{entries:n}}catch(t){let n=t instanceof Error?t.message:"Unknown error";return{entries:[],error:n}}}async function j(e){if(e.length>w)return{entries:[],error:`Archive too large (max ${w} bytes)`};try{let r=new ReadableStream({start(c){c.enqueue(e),c.close()}}).pipeThrough(ye()).getReader(),i=[];for(;;){let{done:c,value:l}=await r.read();if(c)break;i.push(l)}let s=i.reduce((c,l)=>c+l.length,0),o=new Uint8Array(s),a=0;for(let c of i)o.set(c,a),a+=c.length;return _(o)}catch(t){let n=t instanceof Error?t.message:"Unknown error";return{entries:[],error:`Decompression failed: ${n}`}}}function q(e){return e.length>=2&&e[0]===31&&e[1]===139}function Y(e){return e.length>=3&&e[0]===66&&e[1]===90&&e[2]===104}function V(e){return e.length>=6&&e[0]===253&&e[1]===55&&e[2]===122&&e[3]===88&&e[4]===90&&e[5]===0}async function Qe(e){let n=xe.Bzip2.decompressFile(Array.from(e));return new Uint8Array(n)}async function et(e){let t=xe.Bzip2,n=[];return t.compressFile(Array.from(e),n,9),new Uint8Array(n)}async function tt(e){let n=(await Ue()).unxzSync(Buffer.from(e));return new Uint8Array(n)}async function rt(e){let n=(await Ue()).xzSync(Buffer.from(e));return new Uint8Array(n)}async function Fe(e){let t=await C(e);return et(t)}async function ze(e){let t=await C(e);return rt(t)}async function J(e){if(e.length>w)return{entries:[],error:`Archive too large (max ${w} bytes)`};try{let t=await Qe(e);return _(t)}catch(t){let n=t instanceof Error?t.message:"Unknown error";return{entries:[],error:n}}}async function Q(e,t){if(!t?.allowNativeCodecs)return{entries:[],error:"xz decompression is disabled by default (native codec risk). Pass { allowNativeCodecs: true } to opt in, or decompress the archive externally before extraction."};if(e.length>w)return{entries:[],error:`Archive too large (max ${w} bytes)`};try{let n=await tt(e);return _(n)}catch(n){let r=n instanceof Error?n.message:"Unknown error";return{entries:[],error:r}}}function ee(e){return e.length>=4&&e[0]===40&&e[1]===181&&e[2]===47&&e[3]===253}async function nt(e){let n=await(await Ie()).compress(Buffer.from(e),3);return new Uint8Array(n)}async function it(e){let n=await(await Ie()).decompress(Buffer.from(e));return new Uint8Array(n)}async function ke(e){let t=await C(e);return nt(t)}async function te(e,t){if(!t?.allowNativeCodecs)return{entries:[],error:"zstd decompression is disabled by default (native codec risk). Pass { allowNativeCodecs: true } to opt in, or decompress the archive externally before extraction."};if(e.length>w)return{entries:[],error:`Archive too large (max ${w} bytes)`};try{let n=await it(e);return _(n)}catch(n){let r=n instanceof Error?n.message:"Unknown error";return{entries:[],error:r}}}function Re(e){let t={create:!1,append:!1,update:!1,extract:!1,list:!1,file:"",autoCompress:!1,gzip:!1,bzip2:!1,xz:!1,zstd:!1,verbose:!1,toStdout:!1,keepOldFiles:!1,touch:!1,directory:"",preserve:!1,strip:0,exclude:[],filesFrom:"",excludeFrom:"",wildcards:!1},n=[],r=0;for(;r<e.length;){let i=e[r];if(i.startsWith("-")&&!i.startsWith("--")&&i.length>2){if(/^-\d+$/.test(i)){n.push(i),r++;continue}for(let s=1;s<i.length;s++){let o=i[s];switch(o){case"c":t.create=!0;break;case"r":t.append=!0;break;case"u":t.update=!0;break;case"x":t.extract=!0;break;case"t":t.list=!0;break;case"a":t.autoCompress=!0;break;case"z":t.gzip=!0;break;case"j":t.bzip2=!0;break;case"J":t.xz=!0;break;case"v":t.verbose=!0;break;case"O":t.toStdout=!0;break;case"k":t.keepOldFiles=!0;break;case"m":t.touch=!0;break;case"p":t.preserve=!0;break;case"f":if(s<i.length-1)t.file=i.substring(s+1),s=i.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'f'
|
|
3
|
-
`,exitCode:2}};t.file=e[r]}break;case"C":if(s<i.length-1)t.directory=i.substring(s+1),s=i.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'C'
|
|
4
|
-
`,exitCode:2}};t.directory=e[r]}break;case"T":if(s<i.length-1)t.filesFrom=i.substring(s+1),s=i.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'T'
|
|
5
|
-
`,exitCode:2}};t.filesFrom=e[r]}break;case"X":if(s<i.length-1)t.excludeFrom=i.substring(s+1),s=i.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'X'
|
|
6
|
-
`,exitCode:2}};t.excludeFrom=e[r]}break;default:return{ok:!1,error:P("tar",`-${o}`)}}}r++;continue}if(i==="-c"||i==="--create")t.create=!0;else if(i==="-r"||i==="--append")t.append=!0;else if(i==="-u"||i==="--update")t.update=!0;else if(i==="-x"||i==="--extract"||i==="--get")t.extract=!0;else if(i==="-t"||i==="--list")t.list=!0;else if(i==="-a"||i==="--auto-compress")t.autoCompress=!0;else if(i==="-z"||i==="--gzip"||i==="--gunzip")t.gzip=!0;else if(i==="-j"||i==="--bzip2")t.bzip2=!0;else if(i==="-J"||i==="--xz")t.xz=!0;else if(i==="--zstd")t.zstd=!0;else if(i==="-v"||i==="--verbose")t.verbose=!0;else if(i==="-O"||i==="--to-stdout")t.toStdout=!0;else if(i==="-k"||i==="--keep-old-files")t.keepOldFiles=!0;else if(i==="-m"||i==="--touch")t.touch=!0;else if(i==="--wildcards")t.wildcards=!0;else if(i==="-p"||i==="--preserve"||i==="--preserve-permissions")t.preserve=!0;else if(i==="-f"||i==="--file"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'f'
|
|
7
|
-
`,exitCode:2}};t.file=e[r]}else if(i.startsWith("--file="))t.file=i.substring(7);else if(i==="-C"||i==="--directory"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'C'
|
|
8
|
-
`,exitCode:2}};t.directory=e[r]}else if(i.startsWith("--directory="))t.directory=i.substring(12);else if(i.startsWith("--strip-components=")||i.startsWith("--strip=")){let s=i.includes("--strip-components=")?i.substring(19):i.substring(8),o=parseInt(s,10);if(Number.isNaN(o)||o<0)return{ok:!1,error:{stdout:"",stderr:`tar: invalid number for --strip: '${s}'
|
|
9
|
-
`,exitCode:2}};t.strip=o}else if(i.startsWith("--exclude="))t.exclude.push(i.substring(10));else if(i==="--exclude"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option '--exclude' requires an argument
|
|
10
|
-
`,exitCode:2}};t.exclude.push(e[r])}else if(i==="-T"||i==="--files-from"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'T'
|
|
11
|
-
`,exitCode:2}};t.filesFrom=e[r]}else if(i.startsWith("--files-from="))t.filesFrom=i.substring(13);else if(i==="-X"||i==="--exclude-from"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'X'
|
|
12
|
-
`,exitCode:2}};t.excludeFrom=e[r]}else if(i.startsWith("--exclude-from="))t.excludeFrom=i.substring(15);else if(i==="--"){n.push(...e.slice(r+1));break}else{if(i.startsWith("-"))return{ok:!1,error:P("tar",i)};n.push(i)}r++}return{ok:!0,options:t,files:n}}var be=100,st={name:"tar",summary:"manipulate tape archives",usage:"tar [options] [file...]",description:["Create, extract, or list contents of tar archives.","","One of -c, -r, -u, -x, or -t is required to specify the operation."],options:["-c, --create create a new archive","-r, --append append files to the end of an archive","-u, --update only append files newer than copy in archive","-x, --extract extract files from an archive","-t, --list list contents of an archive","-f, --file=ARCHIVE use archive file ARCHIVE","-a, --auto-compress use archive suffix to determine compression","-z, --gzip filter archive through gzip","-j, --bzip2 filter archive through bzip2","-J, --xz filter archive through xz","--zstd filter archive through zstd","-v, --verbose verbosely list files processed","-O, --to-stdout extract files to standard output","-k, --keep-old-files don't replace existing files when extracting","-m, --touch don't extract file modified time","-C, --directory=DIR change to directory DIR before performing operations","-p, --preserve preserve permissions","-T, --files-from=FILE read files to extract/create from FILE","-X, --exclude-from=FILE read exclude patterns from FILE","--strip=N strip N leading path components on extraction","--exclude=PATTERN exclude files matching PATTERN","--wildcards use wildcards for pattern matching"," --help display this help and exit"],examples:["tar -cvf archive.tar file1 file2 Create archive from files","tar -czvf archive.tar.gz dir/ Create gzip-compressed archive","tar -cjvf archive.tar.bz2 dir/ Create bzip2-compressed archive","tar -rf archive.tar newfile.txt Append file to archive","tar -uf archive.tar dir/ Update archive with newer files","tar -xvf archive.tar Extract archive","tar -xvf archive.tar -C /tmp Extract to /tmp","tar -tvf archive.tar List archive contents","tar -xzf archive.tar.gz Extract gzip archive","tar -xf archive.tar file1.txt Extract specific file","tar -xOf archive.tar file.txt Extract file to stdout","tar -xf archive.tar --wildcards '*.txt' Extract matching files"]};function re(e,t){let n=e.includes("/")?e.substring(e.lastIndexOf("/")+1):e;for(let r of t){let i=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"<<<GLOBSTAR>>>").replace(/\*/g,"[^/]*").replace(/<<<GLOBSTAR>>>/g,".*").replace(/\?/g,".");if(x(`^${i}$`).test(e)||x(`^${i}/`).test(e)||!r.includes("/")&&x(`^${i}$`).test(n))return!0}return!1}function N(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"<<<GLOBSTAR>>>").replace(/\*/g,"[^/]*").replace(/<<<GLOBSTAR>>>/g,".*").replace(/\?/g,"."),r=e.includes("/")?e.substring(e.lastIndexOf("/")+1):e;return x(`^${n}$`).test(e)||x(`^${n}$`).test(r)}function Oe(e,t){if(t<=0)return e;let n=e.split("/").filter(r=>r!=="");return n.length<=t?"":n.slice(t).join("/")}function at(e,t){let n=t?"d":"-",r=[e&256?"r":"-",e&128?"w":"-",e&64?"x":"-",e&32?"r":"-",e&16?"w":"-",e&8?"x":"-",e&4?"r":"-",e&2?"w":"-",e&1?"x":"-"].join("");return n+r}function ot(e){let n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],r=e.getDate().toString().padStart(2," "),i=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0");return`${n} ${r} ${i}:${s}`}async function L(e,t,n,r){let i=[],s=[],o=e.fs.resolvePath(t,n);try{let a=await e.fs.stat(o);if(re(n,r))return{entries:i,errors:s};if(a.isDirectory){i.push({name:n,isDirectory:!0,mode:a.mode,mtime:a.mtime});let c=await e.fs.readdir(o);for(let l=0;l<c.length;l+=be){let d=c.slice(l,l+be),u=await Promise.all(d.map(g=>L(e,t,n?`${n}/${g}`:g,r)));for(let g of u)i.push(...g.entries),s.push(...g.errors)}}else if(a.isFile){let c=await e.fs.readFileBuffer(o);i.push({name:n,content:c,mode:a.mode,mtime:a.mtime})}else if(a.isSymbolicLink){let c=await e.fs.readlink(o);i.push({name:n,isSymlink:!0,linkTarget:c,mode:a.mode,mtime:a.mtime})}}catch(a){let c=a instanceof Error?a.message:"unknown error";s.push(`tar: ${n}: ${c}`)}return{entries:i,errors:s}}async function ct(e,t,n){if(n.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to create an empty archive
|
|
13
|
-
`,exitCode:2};let r=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,i=[],s=[],o="";for(let d of n){let{entries:u,errors:g}=await L(e,r,d,t.exclude);if(i.push(...u),s.push(...g),t.verbose)for(let p of u)o+=`${p.name}${p.isDirectory?"/":""}
|
|
14
|
-
`}if(i.length===0&&s.length>0)return{stdout:"",stderr:`${s.join(`
|
|
15
|
-
`)}
|
|
16
|
-
`,exitCode:2};let a;try{t.gzip?a=await ve(i):t.bzip2?a=await Fe(i):t.xz?a=await ze(i):t.zstd?a=await ke(i):a=await C(i)}catch(d){return{stdout:"",stderr:`tar: error creating archive: ${d instanceof Error?d.message:"unknown error"}
|
|
17
|
-
`,exitCode:2}}let c="";if(t.file&&t.file!=="-"){let d=e.fs.resolvePath(e.cwd,t.file);try{await e.fs.writeFile(d,a)}catch(u){let g=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`tar: ${t.file}: ${g}
|
|
18
|
-
`,exitCode:2}}}else c=String.fromCharCode(...a);let l=o;return s.length>0&&(l+=`${s.join(`
|
|
19
|
-
`)}
|
|
20
|
-
`),{stdout:c,stderr:l,exitCode:s.length>0?2:0}}async function lt(e,t,n){if(!t.file||t.file==="-")return{stdout:"",stderr:`tar: Cannot append to stdin/stdout
|
|
21
|
-
`,exitCode:2};if(n.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to append nothing to archive
|
|
22
|
-
`,exitCode:2};let r=e.fs.resolvePath(e.cwd,t.file),i;try{i=await e.fs.readFileBuffer(r)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
|
|
23
|
-
`,exitCode:2}}let s=await _(i);if(s.error)return{stdout:"",stderr:`tar: ${s.error}
|
|
24
|
-
`,exitCode:2};let o=s.entries.map(f=>({name:f.name,content:f.content,mode:f.mode,mtime:f.mtime,isDirectory:f.type==="directory",isSymlink:f.type==="symlink",linkTarget:f.linkTarget,uid:f.uid,gid:f.gid})),a=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,c=[],l=[],d="";for(let f of n){let{entries:h,errors:m}=await L(e,a,f,t.exclude);if(c.push(...h),l.push(...m),t.verbose)for(let S of h)d+=`${S.name}${S.isDirectory?"/":""}
|
|
25
|
-
`}let u=[...o,...c],g;try{g=await C(u)}catch(f){return{stdout:"",stderr:`tar: error creating archive: ${f instanceof Error?f.message:"unknown error"}
|
|
26
|
-
`,exitCode:2}}try{await e.fs.writeFile(r,g)}catch(f){let h=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`tar: ${t.file}: ${h}
|
|
27
|
-
`,exitCode:2}}let p=d;return l.length>0&&(p+=`${l.join(`
|
|
28
|
-
`)}
|
|
29
|
-
`),{stdout:"",stderr:p,exitCode:l.length>0?2:0}}async function ut(e,t,n){if(!t.file||t.file==="-")return{stdout:"",stderr:`tar: Cannot update stdin/stdout
|
|
30
|
-
`,exitCode:2};if(n.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to update with nothing
|
|
31
|
-
`,exitCode:2};let r=e.fs.resolvePath(e.cwd,t.file),i;try{i=await e.fs.readFileBuffer(r)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
|
|
32
|
-
`,exitCode:2}}let s=await _(i);if(s.error)return{stdout:"",stderr:`tar: ${s.error}
|
|
33
|
-
`,exitCode:2};let o=new Map;for(let m of s.entries)o.set(m.name,m.mtime);let a=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,c=[],l=[],d="";for(let m of n){let{entries:S,errors:E}=await L(e,a,m,t.exclude);l.push(...E);for(let y of S){let I=o.get(y.name);(!I||y.mtime&&y.mtime.getTime()>I.getTime())&&(c.push(y),t.verbose&&(d+=`${y.name}${y.isDirectory?"/":""}
|
|
34
|
-
`))}}if(c.length===0){let m="";return l.length>0&&(m=`${l.join(`
|
|
35
|
-
`)}
|
|
36
|
-
`),{stdout:"",stderr:m,exitCode:l.length>0?2:0}}let u=new Set(c.map(m=>m.name)),p=[...s.entries.filter(m=>!u.has(m.name)).map(m=>({name:m.name,content:m.content,mode:m.mode,mtime:m.mtime,isDirectory:m.type==="directory",isSymlink:m.type==="symlink",linkTarget:m.linkTarget,uid:m.uid,gid:m.gid})),...c],f;try{f=await C(p)}catch(m){return{stdout:"",stderr:`tar: error creating archive: ${m instanceof Error?m.message:"unknown error"}
|
|
37
|
-
`,exitCode:2}}try{await e.fs.writeFile(r,f)}catch(m){let S=m instanceof Error?m.message:"unknown error";return{stdout:"",stderr:`tar: ${t.file}: ${S}
|
|
38
|
-
`,exitCode:2}}let h=d;return l.length>0&&(h+=`${l.join(`
|
|
39
|
-
`)}
|
|
40
|
-
`),{stdout:"",stderr:h,exitCode:l.length>0?2:0}}async function ft(e,t,n){let r;if(t.file&&t.file!=="-"){let f=e.fs.resolvePath(e.cwd,t.file);try{r=await e.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
|
|
41
|
-
`,exitCode:2}}}else r=Uint8Array.from(e.stdin,f=>f.charCodeAt(0));let i,s=t.gzip||q(r),o=t.bzip2||Y(r),a=t.xz||V(r),c=t.zstd||ee(r);if(s?i=await j(r):o?i=await J(r):a?i=await Q(r):c?i=await te(r):i=await _(r),i.error)return{stdout:"",stderr:`tar: ${i.error}
|
|
42
|
-
`,exitCode:2};let l=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,d="",u="",g=[];if(t.directory&&!t.toStdout)try{await e.fs.mkdir(l,{recursive:!0})}catch{}for(let f of i.entries){let h=Oe(f.name,t.strip);if(!h)continue;let m=h.endsWith("/")?h.slice(0,-1):h;if(n.length>0){let E;if(t.wildcards?E=n.some(y=>N(h,y)||N(m,y)||h.startsWith(`${y}/`)):E=n.some(y=>h===y||h.startsWith(`${y}/`)||m===y),!E)continue}if(re(h,t.exclude))continue;let S=e.fs.resolvePath(l,h);try{if(f.type==="directory"){if(t.toStdout)continue;await e.fs.mkdir(S,{recursive:!0}),t.verbose&&(d+=`${h}
|
|
43
|
-
`)}else if(f.type==="file"){if(t.toStdout){u+=new TextDecoder().decode(f.content),t.verbose&&(d+=`${h}
|
|
44
|
-
`);continue}if(t.keepOldFiles)try{await e.fs.stat(S),t.verbose&&(d+=`${h}: not overwritten, file exists
|
|
45
|
-
`);continue}catch{}let E=S.substring(0,S.lastIndexOf("/"));if(E)try{await e.fs.mkdir(E,{recursive:!0})}catch{}if(await e.fs.writeFile(S,f.content),t.preserve&&f.mode)try{await e.fs.chmod(S,f.mode)}catch{}t.verbose&&(d+=`${h}
|
|
46
|
-
`)}else if(f.type==="symlink"&&f.linkTarget){if(t.toStdout)continue;if(t.keepOldFiles)try{await e.fs.stat(S),t.verbose&&(d+=`${h}: not overwritten, file exists
|
|
47
|
-
`);continue}catch{}let E=S.substring(0,S.lastIndexOf("/"));if(E)try{await e.fs.mkdir(E,{recursive:!0})}catch{}try{await e.fs.symlink(f.linkTarget,S)}catch{}t.verbose&&(d+=`${h}
|
|
48
|
-
`)}}catch(E){let y=E instanceof Error?E.message:"unknown error";g.push(`tar: ${h}: ${y}`)}}let p=d;return g.length>0&&(p+=`${g.join(`
|
|
49
|
-
`)}
|
|
50
|
-
`),{stdout:u,stderr:p,exitCode:g.length>0?2:0}}async function dt(e,t,n){let r;if(t.file&&t.file!=="-"){let d=e.fs.resolvePath(e.cwd,t.file);try{r=await e.fs.readFileBuffer(d)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
|
|
51
|
-
`,exitCode:2}}}else r=Uint8Array.from(e.stdin,d=>d.charCodeAt(0));let i,s=t.gzip||q(r),o=t.bzip2||Y(r),a=t.xz||V(r),c=t.zstd||ee(r);if(s?i=await j(r):o?i=await J(r):a?i=await Q(r):c?i=await te(r):i=await _(r),i.error)return{stdout:"",stderr:`tar: ${i.error}
|
|
52
|
-
`,exitCode:2};let l="";for(let d of i.entries){let u=Oe(d.name,t.strip);if(!u)continue;let g=u.endsWith("/")?u.slice(0,-1):u;if(n.length>0){let p;if(t.wildcards?p=n.some(f=>N(u,f)||N(g,f)||u.startsWith(`${f}/`)):p=n.some(f=>u===f||u.startsWith(`${f}/`)||g===f),!p)continue}if(!re(u,t.exclude))if(t.verbose){let p=d.type==="directory",f=at(d.mode,p),h=`${d.uid}/${d.gid}`,m=d.size.toString().padStart(8," "),S=ot(d.mtime),E=`${f} ${h.padEnd(10)} ${m} ${S} ${u}`;d.type==="symlink"&&d.linkTarget&&(E+=` -> ${d.linkTarget}`),l+=`${E}
|
|
53
|
-
`}else l+=`${u}
|
|
54
|
-
`}return{stdout:l,stderr:"",exitCode:0}}var Ut={name:"tar",async execute(e,t){if(se(e))return ie(st);let n=Re(e);if(!n.ok)return n.error;let{options:r,files:i}=n,s=[r.create,r.append,r.update,r.extract,r.list].filter(Boolean).length;if(s===0)return{stdout:"",stderr:`tar: You must specify one of -c, -r, -u, -x, or -t
|
|
55
|
-
`,exitCode:2};if(s>1)return{stdout:"",stderr:`tar: You may not specify more than one of -c, -r, -u, -x, or -t
|
|
56
|
-
`,exitCode:2};if(r.autoCompress&&r.file&&r.create){let c=r.file.toLowerCase();c.endsWith(".tar.gz")||c.endsWith(".tgz")?r.gzip=!0:c.endsWith(".tar.bz2")||c.endsWith(".tbz2")?r.bzip2=!0:c.endsWith(".tar.xz")||c.endsWith(".txz")?r.xz=!0:(c.endsWith(".tar.zst")||c.endsWith(".tzst"))&&(r.zstd=!0)}let o=[r.gzip,r.bzip2,r.xz,r.zstd].filter(Boolean).length;if(o>1)return{stdout:"",stderr:`tar: You may not specify more than one compression option
|
|
57
|
-
`,exitCode:2};if((r.append||r.update)&&o>0)return{stdout:"",stderr:`tar: Cannot append/update compressed archives - decompress first
|
|
58
|
-
`,exitCode:2};let a=i;if(r.filesFrom){let c=t.fs.resolvePath(t.cwd,r.filesFrom);try{let d=(await t.fs.readFile(c)).split(`
|
|
59
|
-
`).map(u=>u.trim()).filter(u=>u.length>0&&!u.startsWith("#"));a=[...i,...d]}catch{return{stdout:"",stderr:`tar: ${r.filesFrom}: Cannot open: No such file or directory
|
|
60
|
-
`,exitCode:2}}}if(r.excludeFrom){let c=t.fs.resolvePath(t.cwd,r.excludeFrom);try{let d=(await t.fs.readFile(c)).split(`
|
|
61
|
-
`).map(u=>u.trim()).filter(u=>u.length>0&&!u.startsWith("#"));r.exclude.push(...d)}catch{return{stdout:"",stderr:`tar: ${r.excludeFrom}: Cannot open: No such file or directory
|
|
62
|
-
`,exitCode:2}}}return r.create?ct(t,r,a):r.append?lt(t,r,a):r.update?ut(t,r,a):r.extract?ft(t,r,a):dt(t,r,a)}},It={name:"tar",flags:[{flag:"-c",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-f",type:"value",valueHint:"path"},{flag:"-z",type:"boolean"},{flag:"-j",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-C",type:"value",valueHint:"path"},{flag:"--strip-components",type:"value",valueHint:"number"},{flag:"--exclude",type:"value",valueHint:"pattern"}],needsArgs:!0};export{Ut as a,It as b};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import{b as p}from"./chunk-R7KYILVY.js";import{a as j,b as h}from"./chunk-LEOLL6PF.js";import{a as S,b as q}from"./chunk-74CEPOFO.js";import{existsSync as g}from"node:fs";import{dirname as H,join as w}from"node:path";import{fileURLToPath as J}from"node:url";import{Worker as W}from"node:worker_threads";import _ from"sql.js";function T(e,r,n){switch(n.mode){case"list":return V(e,r,n);case"csv":return O(e,r,n);case"json":return I(e,r);case"line":return N(e,r,n);case"column":return P(e,r,n);case"table":return M(e,r,n);case"markdown":return R(e,r,n);case"tabs":return F(e,r,n);case"box":return Q(e,r,n);case"quote":return B(e,r,n);case"html":return D(e,r,n);case"ascii":return U(e,r,n)}}function u(e,r){return e==null?r: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 V(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.join(n.separator));for(let l of r)t.push(l.map(i=>u(i,n.nullValue)).join(n.separator));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function O(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.map(x).join(","));for(let l of r)t.push(l.map(i=>x(u(i,n.nullValue))).join(","));return t.length>0?`${t.join(`
|
|
2
|
-
`)}
|
|
3
|
-
`:""}function x(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
|
|
4
|
-
`)?`"${e.replace(/"/g,'""')}"`:e}function y(e){return e.toPrecision(17).replace(/\.?0+$/,"")}function A(e){return e===null?"null":typeof e=="number"?Number.isInteger(e)?String(e):y(e):JSON.stringify(e)}function I(e,r){return r.length===0?"":`[${r.map(t=>`{${e.map((i,s)=>`${JSON.stringify(i)}:${A(t[s])}`).join(",")}}`).join(`,
|
|
5
|
-
`)}]
|
|
6
|
-
`}function N(e,r,n){if(e.length===0||r.length===0)return"";let t=Math.max(5,...e.map(i=>i.length)),l=[];for(let i of r)for(let s=0;s<e.length;s++){let o=e[s].padStart(t);l.push(`${o} = ${u(i[s],n.nullValue)}`)}return`${l.join(`
|
|
7
|
-
`)}
|
|
8
|
-
`}function P(e,r,n){if(e.length===0)return"";let t=e.map(i=>i.length);for(let i of r)for(let s=0;s<i.length;s++){let o=u(i[s],n.nullValue).length;o>t[s]&&(t[s]=o)}let l=[];n.header&&(l.push(e.map((i,s)=>i.padEnd(t[s])).join(" ")),l.push(t.map(i=>"-".repeat(i)).join(" ")));for(let i of r)l.push(i.map((s,o)=>u(s,n.nullValue).padEnd(t[o])).join(" "));return l.length>0?`${l.join(`
|
|
9
|
-
`)}
|
|
10
|
-
`:""}function M(e,r,n){if(e.length===0)return"";let t=e.map(s=>s.length);for(let s of r)for(let o=0;o<s.length;o++){let f=u(s[o],n.nullValue).length;f>t[o]&&(t[o]=f)}let l=[],i=`+${t.map(s=>"-".repeat(s+2)).join("+")}+`;l.push(i),n.header&&(l.push(`| ${e.map((s,o)=>s.padEnd(t[o])).join(" | ")} |`),l.push(i));for(let s of r)l.push(`| ${s.map((o,f)=>u(o,n.nullValue).padEnd(t[f])).join(" | ")} |`);return l.push(i),`${l.join(`
|
|
11
|
-
`)}
|
|
12
|
-
`}function R(e,r,n){if(e.length===0)return"";let t=[];n.header&&(t.push(`| ${e.join(" | ")} |`),t.push(`|${e.map(()=>"---").join("|")}|`));for(let l of r)t.push(`| ${l.map(i=>u(i,n.nullValue)).join(" | ")} |`);return t.length>0?`${t.join(`
|
|
13
|
-
`)}
|
|
14
|
-
`:""}function F(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.join(" "));for(let l of r)t.push(l.map(i=>u(i,n.nullValue)).join(" "));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function Q(e,r,n){if(e.length===0)return"";let t=e.map(i=>i.length);for(let i of r)for(let s=0;s<i.length;s++){let o=u(i[s],n.nullValue).length;o>t[s]&&(t[s]=o)}let l=[];l.push(`\u250C${t.map(i=>"\u2500".repeat(i+2)).join("\u252C")}\u2510`),l.push(`\u2502 ${e.map((i,s)=>i.padEnd(t[s])).join(" \u2502 ")} \u2502`),l.push(`\u251C${t.map(i=>"\u2500".repeat(i+2)).join("\u253C")}\u2524`);for(let i of r)l.push(`\u2502 ${i.map((s,o)=>u(s,n.nullValue).padEnd(t[o])).join(" \u2502 ")} \u2502`);return l.push(`\u2514${t.map(i=>"\u2500".repeat(i+2)).join("\u2534")}\u2518`),`${l.join(`
|
|
15
|
-
`)}
|
|
16
|
-
`}function B(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.map(l=>`'${l}'`).join(","));for(let l of r)t.push(l.map(i=>i==null?"NULL":typeof i=="number"?Number.isInteger(i)?String(i):y(i):`'${String(i)}'`).join(","));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function D(e,r,n){let t=[];n.header&&e.length>0&&(t.push(`<TR>${e.map(l=>`<TH>${E(l)}</TH>`).join("")}`),t.push("</TR>"));for(let l of r)t.push(`<TR>${l.map(i=>`<TD>${E(u(i,n.nullValue))}</TD>`).join("")}`),t.push("</TR>");return t.length>0?`${t.join(`
|
|
17
|
-
`)}
|
|
18
|
-
`:""}function E(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function U(e,r,n){let i=[];n.header&&e.length>0&&i.push(e.join(""));for(let s of r)i.push(s.map(o=>u(o,n.nullValue)).join(""));return i.length>0?i.join("")+"":""}var z=5e3,X={name:"sqlite3",summary:"SQLite database CLI",usage:"sqlite3 [OPTIONS] DATABASE [SQL]",options:["-list output in list mode (default)","-csv output in CSV mode","-json output in JSON mode","-line output in line mode","-column output in column mode","-table output as ASCII table","-markdown output as markdown table","-tabs output in tab-separated mode","-box output in Unicode box mode","-quote output in SQL quote mode","-html output as HTML table","-ascii output in ASCII mode (control chars)","-header show column headers","-noheader hide column headers","-separator SEP field separator for list mode (default: |)","-newline SEP row separator (default: \\n)","-nullvalue TEXT text for NULL values (default: empty)","-readonly open database read-only (no writeback)","-bail stop on first error","-echo print SQL before execution","-cmd COMMAND run SQL command before main SQL","-version show SQLite version","-- end of options","--help show this help"],examples:['sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"','sqlite3 -json data.db "SELECT * FROM users"','sqlite3 -csv -header data.db "SELECT id, name FROM products"','sqlite3 -box data.db "SELECT * FROM users"']};function Y(e){let r={mode:"list",header:!1,separator:"|",newline:`
|
|
19
|
-
`,nullValue:"",readonly:!1,bail:!1,echo:!1,cmd:null},n=null,t=null,l=!1,i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){n===null?n=o:t===null&&(t=o);continue}if(o==="--")i=!0;else if(o==="-version")l=!0;else if(o==="-list")r.mode="list";else if(o==="-csv")r.mode="csv";else if(o==="-json")r.mode="json";else if(o==="-line")r.mode="line";else if(o==="-column")r.mode="column";else if(o==="-table")r.mode="table";else if(o==="-markdown")r.mode="markdown";else if(o==="-tabs")r.mode="tabs";else if(o==="-box")r.mode="box";else if(o==="-quote")r.mode="quote";else if(o==="-html")r.mode="html";else if(o==="-ascii")r.mode="ascii";else if(o==="-header")r.header=!0;else if(o==="-noheader")r.header=!1;else if(o==="-readonly")r.readonly=!0;else if(o==="-bail")r.bail=!0;else if(o==="-echo")r.echo=!0;else if(o==="-separator"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -separator
|
|
20
|
-
`,exitCode:1};r.separator=e[++s]}else if(o==="-newline"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -newline
|
|
21
|
-
`,exitCode:1};r.newline=e[++s]}else if(o==="-nullvalue"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -nullvalue
|
|
22
|
-
`,exitCode:1};r.nullValue=e[++s]}else if(o==="-cmd"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -cmd
|
|
23
|
-
`,exitCode:1};r.cmd=e[++s]}else{if(o.startsWith("-"))return{stdout:"",stderr:`sqlite3: Error: unknown option: ${o.startsWith("--")?o.slice(1):o}
|
|
24
|
-
Use -help for a list of options.
|
|
25
|
-
`,exitCode:1};n===null?n=o:t===null&&(t=o)}}return{options:r,database:n,sql:t,showVersion:l}}async function G(){let e=await p.runTrustedAsync(()=>_()),r=new e.Database;try{let n=r.exec("SELECT sqlite_version()");return n.length>0&&n[0].values.length>0?String(n[0].values[0][0]):"unknown"}finally{r.close()}}function K(){let e=H(J(import.meta.url)),r=w(e,"../../commands/sqlite3/worker.js");if(g(r))return r;let n=w(e,"worker.js");if(g(n))return n;let t=w(e,"../../../dist/commands/sqlite3/worker.js");if(g(t))return t;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}async function Z(e,r){try{let n=K();return await new Promise((t,l)=>{let i=p.runTrusted(()=>new W(n,{workerData:e})),s=j(()=>{i.terminate(),t({success:!1,error:`Query timeout: execution exceeded ${r}ms limit`})},r);i.on("message",o=>{if(o.type==="security-violation"){h(s),t({success:!1,error:`Security violation: ${o.violation?.type??"unknown"}`});return}h(s),t(o)}),i.on("error",o=>{h(s),l(o)}),i.on("exit",o=>{h(s),o!==0&&t({success:!1,error:`Worker exited with code ${o}`})})})}catch(n){throw new Error(`sqlite3 worker failed to load: ${n.message}`)}}var ue={name:"sqlite3",async execute(e,r){if(q(e)||e.includes("-help"))return S(X);let n=Y(e);if("exitCode"in n)return n;let{options:t,database:l,sql:i,showVersion:s}=n;if(s)return{stdout:`${await G()}
|
|
26
|
-
`,stderr:"",exitCode:0};if(!l)return{stdout:"",stderr:`sqlite3: missing database argument
|
|
27
|
-
`,exitCode:1};let o=i||r.stdin.trim();if(t.cmd&&(o=t.cmd+(o?`; ${o}`:"")),!o)return{stdout:"",stderr:`sqlite3: no SQL provided
|
|
28
|
-
`,exitCode:1};let f=l===":memory:",m="",b=null;try{f||(m=r.fs.resolvePath(r.cwd,l),await r.fs.exists(m)&&(b=await r.fs.readFileBuffer(m)))}catch(a){return{stdout:"",stderr:`sqlite3: unable to open database "${l}": ${a.message}
|
|
29
|
-
`,exitCode:1}}let C=r.limits?.maxSqliteTimeoutMs??z,L={dbBuffer:b,sql:o,options:{bail:t.bail,echo:t.echo}},d;try{d=await Z(L,C)}catch(a){return{stdout:"",stderr:`sqlite3: worker error: ${a.message}
|
|
30
|
-
`,exitCode:1}}if(!d.success)return{stdout:"",stderr:`sqlite3: ${d.error}
|
|
31
|
-
`,exitCode:1};let k={mode:t.mode,header:t.header,separator:t.separator,newline:t.newline,nullValue:t.nullValue},c="";t.echo&&(c+=`${o}
|
|
32
|
-
`);let $=!1;for(let a of d.results)if(a.type==="error"){if(t.bail)return{stdout:c,stderr:`Error: ${a.error}
|
|
33
|
-
`,exitCode:1};c+=`Error: ${a.error}
|
|
34
|
-
`,$=!0}else a.columns&&a.rows&&(a.rows.length>0||t.header)&&(c+=T(a.columns,a.rows,k));if(d.hasModifications&&!t.readonly&&!f&&m&&d.dbBuffer)try{await r.fs.writeFile(m,d.dbBuffer)}catch(a){return{stdout:c,stderr:`sqlite3: failed to write database: ${a.message}
|
|
35
|
-
`,exitCode:1}}return{stdout:c,stderr:"",exitCode:$&&t.bail?1:0}}},fe={name:"sqlite3",flags:[],needsArgs:!0};export{ue as a,fe as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=globalThis.setTimeout,e=globalThis.clearTimeout,t=globalThis.SharedArrayBuffer,r=globalThis.Atomics;export{o as a,e as b,t as c,r as d};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{a as m,b as f,c as p}from"./chunk-74CEPOFO.js";var $={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},C={name:"env",async execute(o,l){if(f(o))return m($);let c=!1,i=[],a=new Map,t=-1;for(let n=0;n<o.length;n++){let e=o[n];if(e==="-i"||e==="--ignore-environment")c=!0;else if(e==="-u"&&n+1<o.length)i.push(o[++n]);else if(e.startsWith("-u"))i.push(e.slice(2));else if(e.startsWith("--unset="))i.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return p("env",e);if(e.startsWith("-")&&e!=="-"){for(let r of e.slice(1))if(r!=="i"&&r!=="u")return p("env",`-${r}`);e.includes("i")&&(c=!0)}else if(e.includes("=")&&t===-1){let r=e.indexOf("="),y=e.slice(0,r),A=e.slice(r+1);a.set(y,A)}else{t=n;break}}}let s;if(c)s=new Map(a);else{s=new Map(l.env);for(let n of i)s.delete(n);for(let[n,e]of a)s.set(n,e)}if(t===-1){let n=[];for(let[e,r]of s)n.push(`${e}=${r}`);return{stdout:n.join(`
|
|
2
|
-
`)+(n.length>0?`
|
|
3
|
-
`:""),stderr:"",exitCode:0}}if(!l.exec)return{stdout:"",stderr:`env: command execution not supported in this context
|
|
4
|
-
`,exitCode:1};let u=o.slice(t),h=u[0],g=u.slice(1).map(n=>/[\s"'\\$`!*?[\]{}|&;<>()]/.test(n)?`'${n.replace(/'/g,"'\\''")}'`:n),d=["command",h,...g].join(" "),v=Object.entries(a).map(([n,e])=>`${n}="${e}"`).join(" "),x=v?`${v} ${d}`:d;return l.exec(x,{cwd:l.cwd})}},w={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},E={name:"printenv",async execute(o,l){if(f(o))return m(w);let c=o.filter(t=>!t.startsWith("-"));if(c.length===0){let t=[];for(let[s,u]of l.env)t.push(`${s}=${u}`);return{stdout:t.join(`
|
|
5
|
-
`)+(t.length>0?`
|
|
6
|
-
`:""),stderr:"",exitCode:0}}let i=[],a=0;for(let t of c){let s=l.env.get(t);s!==void 0?i.push(s):a=1}return{stdout:i.join(`
|
|
7
|
-
`)+(i.length>0?`
|
|
8
|
-
`:""),stderr:"",exitCode:a}}},O={name:"env",flags:[{flag:"-i",type:"boolean"},{flag:"-u",type:"value",valueHint:"string"}]},j={name:"printenv",flags:[]};export{C as a,E as b,O as c,j as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as h}from"./chunk-DXB73IDG.js";function x(){let a=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"}];try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&a.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&a.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let e=Object.getPrototypeOf(async function*(){}).constructor;e&&e!==Function&&e!==Object.getPrototypeOf(async()=>{}).constructor&&a.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return a.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var g=typeof __BROWSER__<"u"&&__BROWSER__;function m(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{let e=Math.random()*16|0;return(a==="x"?e:e&3|8).toString(16)})}var b=null;if(!g)try{let{AsyncLocalStorage:a}=h("node:async_hooks");b=a}catch{}var _=`
|
|
2
|
-
|
|
3
|
-
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,p=class extends Error{violation;constructor(e,t){super(e+_),this.violation=t,this.name="SecurityViolationError"}},u=!g&&b?new b:null,P=1e3,y={enabled:!0,auditMode:!1};function T(a){return a===void 0?{...y,enabled:!1}:typeof a=="boolean"?{...y,enabled:a}:{...y,...a}}var v=class a{static instance=null;config;refCount=0;patchFailures=[];originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let t=T(e);if(!a.instance)a.instance=new a(t);else{let r=a.instance.config;if(t.enabled!==r.enabled||t.auditMode!==r.auditMode)throw new Error(`DefenseInDepthBox config conflict: requested {enabled: ${t.enabled}, auditMode: ${t.auditMode}} but singleton already has {enabled: ${r.enabled}, auditMode: ${r.auditMode}}. All Bash instances must use the same defense-in-depth security settings, or call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return a.instance}static resetInstance(){a.instance&&(a.instance.forceDeactivate(),a.instance=null)}static isInSandboxedContext(){return u?u?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(u)return u?.getStore()?.executionId}isEnabled(){return this.config.enabled===!0&&u!==null&&!g}updateConfig(e){this.config={...this.config,...e}}activate(){if(g||!this.config.enabled||!u){let t=m();return{run:r=>r(),deactivate:()=>{},executionId:t}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let e=m();return{run:t=>u.run({sandboxActive:!0,executionId:e},t),deactivate:()=>{this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0)},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(e){if(!u)return e();let t=u.getStore();return t?u.run({...t,trusted:!0},e):e()}static async runTrustedAsync(e){if(!u)return e();let t=u.getStore();return t?u.run({...t,trusted:!0},e):e()}shouldBlock(){if(g||this.config.auditMode||!u)return!1;let e=u?.getStore();return!(e?.sandboxActive!==!0||e.trusted)}recordViolation(e,t,r){let s={timestamp:Date.now(),type:e,message:r,path:t,stack:new Error().stack,executionId:u?.getStore()?.executionId};if(this.violations.length<P&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(o){console.debug("[DefenseInDepthBox] onViolation callback threw:",o instanceof Error?o.message:o)}return s}createBlockingProxy(e,t,r){let s=this;return new Proxy(e,{apply(o,n,c){if(s.shouldBlock()){let i=`${t} is blocked during script execution`,l=s.recordViolation(r,t,i);throw new p(i,l)}return s.config.auditMode&&u?.getStore()?.sandboxActive===!0&&s.recordViolation(r,t,`${t} called (audit mode)`),Reflect.apply(o,n,c)},construct(o,n,c){if(s.shouldBlock()){let i=`${t} constructor is blocked during script execution`,l=s.recordViolation(r,t,i);throw new p(i,l)}return s.config.auditMode&&u?.getStore()?.sandboxActive===!0&&s.recordViolation(r,t,`${t} constructor called (audit mode)`),Reflect.construct(o,n,c)}})}createBlockingObjectProxy(e,t,r,s){let o=this;return new Proxy(e,{get(n,c,i){if(o.shouldBlock()){if(s&&typeof c=="string"&&s.has(c))return Reflect.get(n,c,i);let l=`${t}.${String(c)}`,d=`${l} is blocked during script execution`,f=o.recordViolation(r,l,d);throw new p(d,f)}if(o.config.auditMode&&u?.getStore()?.sandboxActive===!0){let l=`${t}.${String(c)}`;o.recordViolation(r,l,`${l} accessed (audit mode)`)}return Reflect.get(n,c,i)},set(n,c,i,l){if(o.shouldBlock()){let d=`${t}.${String(c)}`,f=`${d} modification is blocked during script execution`,w=o.recordViolation(r,d,f);throw new p(f,w)}return Reflect.set(n,c,i,l)},ownKeys(n){if(o.shouldBlock()){let c=`${t} enumeration is blocked during script execution`,i=o.recordViolation(r,t,c);throw new p(c,i)}return Reflect.ownKeys(n)},getOwnPropertyDescriptor(n,c){if(o.shouldBlock()){let i=`${t}.${String(c)}`,l=`${i} descriptor access is blocked during script execution`,d=o.recordViolation(r,i,l);throw new p(l,d)}return Reflect.getOwnPropertyDescriptor(n,c)},has(n,c){if(o.shouldBlock()){let i=`${t}.${String(c)}`,l=`${i} existence check is blocked during script execution`,d=o.recordViolation(r,i,l);throw new p(l,d)}return Reflect.has(n,c)}})}applyPatches(){this.patchFailures=[];let e=x(),t=new Set(["process_send","process_channel"]);for(let o of e)t.has(o.violationType)||this.applyPatch(o);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectModuleLoad(),this.protectProcessMainModule(),this.protectProcessExecPath();let r=["Function.prototype.constructor","Module._load"],s=this.patchFailures.filter(o=>r.includes(o));if(s.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${s.join(", ")}`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:t});let r=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return r},set(s){if(e.shouldBlock()){let o="Error.prepareStackTrace modification is blocked during script execution",n=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",o);throw new p(o,n)}e.config.auditMode&&u?.getStore()?.sandboxActive===!0&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),r=s},configurable:!0})}catch(t){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",t instanceof Error?t.message:t)}}patchPrototypeConstructor(e,t,r){let s=this;try{let o=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:o});let n=o?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let c=`${t} access is blocked during script execution`,i=s.recordViolation(r,t,c);throw new p(c,i)}return s.config.auditMode&&u?.getStore()?.sandboxActive===!0&&s.recordViolation(r,t,`${t} accessed (audit mode)`),n},set(c){if(s.shouldBlock()){let i=`${t} modification is blocked during script execution`,l=s.recordViolation(r,t,i);throw new p(i,l)}Object.defineProperty(this,"constructor",{value:c,writable:!0,configurable:!0})},configurable:!0})}catch(o){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,o instanceof Error?o.message:o)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:t});let r=t?.value;r!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",o=e.recordViolation("process_main_module","process.mainModule",s);throw new p(s,o)}return e.config.auditMode&&u?.getStore()?.sandboxActive===!0&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),r},set(s){if(e.shouldBlock()){let o="process.mainModule modification is blocked during script execution",n=e.recordViolation("process_main_module","process.mainModule",o);throw new p(o,n)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",t instanceof Error?t.message:t)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:t});let r=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",o=e.recordViolation("process_exec_path","process.execPath",s);throw new p(s,o)}return e.config.auditMode&&u?.getStore()?.sandboxActive===!0&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),r},set(s){if(e.shouldBlock()){let o="process.execPath modification is blocked during script execution",n=e.recordViolation("process_exec_path","process.execPath",o);throw new p(o,n)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",t instanceof Error?t.message:t)}}protectModuleLoad(){if(!g)try{let e=null;if(typeof process<"u"){let n=process.mainModule;n&&typeof n=="object"&&(e=n.constructor)}if(!e&&typeof h<"u"&&typeof h.main<"u"&&(e=h.main.constructor),!e||typeof e._load!="function")return;let t=e._load,r=Object.getOwnPropertyDescriptor(e,"_load");this.originalDescriptors.push({target:e,prop:"_load",descriptor:r});let o=this.createBlockingProxy(t,"Module._load","module_load");Object.defineProperty(e,"_load",{value:o,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._load"),console.debug("[DefenseInDepthBox] Could not protect Module._load:",e instanceof Error?e.message:e)}}applyPatch(e){let{target:t,prop:r,violationType:s,strategy:o}=e;try{let n=t[r];if(n===void 0)return;let c=Object.getOwnPropertyDescriptor(t,r);if(this.originalDescriptors.push({target:t,prop:r,descriptor:c}),o==="freeze")typeof n=="object"&&n!==null&&Object.freeze(n);else{let i=this.getPathForTarget(t,r),l=typeof n=="function"?this.createBlockingProxy(n,i,s):this.createBlockingObjectProxy(n,i,s,e.allowedKeys);Object.defineProperty(t,r,{value:l,writable:!0,configurable:!0})}}catch(n){let c=this.getPathForTarget(t,r);this.patchFailures.push(c),console.debug(`[DefenseInDepthBox] Could not patch ${c}:`,n instanceof Error?n.message:n)}}restorePatches(){for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:r,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(t,r,s):delete t[r]}catch(o){let n=this.getPathForTarget(t,r);console.debug(`[DefenseInDepthBox] Could not restore ${n}:`,o instanceof Error?o.message:o)}}this.originalDescriptors=[]}};export{p as a,v as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function d(t){if(!t)return t;let e=t.replace(/\n\s+at\s.*/g,"");return e=e.replace(/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap))\b[^\s'",)}\]:]*/g,"<path>"),e=e.replace(/[A-Z]:\\[^\s'",)}\]:]+/g,"<path>"),e}import*as o from"node:fs";import*as r from"node:path";function y(t){if(!t||t==="/")return"/";let e=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;e.startsWith("/")||(e=`/${e}`);let n=e.split("/").filter(i=>i&&i!=="."),s=[];for(let i of n)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}function f(t,e){return t===e||t.startsWith(`${e}/`)}function a(t,e){try{let n=o.realpathSync(t);return f(n,e)?n:null}catch(n){if(n.code==="ENOENT"){let s=r.dirname(t);if(s===t)return null;let i=a(s,e);if(i===null)return null;try{if(o.lstatSync(t).isSymbolicLink()){let l=o.readlinkSync(t),u=r.isAbsolute(l)?l:r.resolve(r.dirname(t),l);if(a(u,e)===null)return null}}catch{}return r.join(i,r.basename(t))}return null}}function v(t,e,n){let s=a(t,n);if(s===null)return null;let i=r.resolve(t),c=i.slice(e.length),l=s.slice(n.length);if(c!==l)return null;try{if(o.lstatSync(i).isSymbolicLink())return null}catch{}return s}function m(t,e){if(!o.existsSync(t))throw new Error(`${e} root does not exist`);if(!o.statSync(t).isDirectory())throw new Error(`${e} root is not a directory`)}function S(t,e){if(t.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${e} '${t}'`)}function x(t,e){if(!r.isAbsolute(t))return{withinRoot:!0,relativePath:t};let n;try{n=o.realpathSync(t)}catch{n=r.resolve(t)}return f(n,e)?{withinRoot:!0,relativePath:n.slice(e.length)||"/"}:{withinRoot:!1,safeName:r.basename(t)}}export{d as a,y as b,f as c,a as d,v as e,m as f,S as g,x as h};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var c=new Map([["File operations",["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"]],["Text processing",["grep","sed","awk","sort","uniq","cut","tr","tee","diff"]],["Search",["find"]],["Navigation & paths",["pwd","basename","dirname","tree","du"]],["Environment & shell",["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"]],["Data processing",["xargs","jq","base64","date"]],["Network",["curl","html-to-markdown"]]]);function l(n){let e=[],t=new Set(n);e.push(`Available commands:
|
|
2
|
-
`);let s=[];for(let[a,r]of c){let o=r.filter(i=>t.has(i));if(o.length>0){e.push(` ${a}:`),e.push(` ${o.join(", ")}
|
|
3
|
-
`);for(let i of o)t.delete(i)}}for(let a of t)s.push(a);return s.length>0&&(e.push(" Other:"),e.push(` ${s.sort().join(", ")}
|
|
4
|
-
`)),e.push("Use '<command> --help' for details on a specific command."),`${e.join(`
|
|
5
|
-
`)}
|
|
6
|
-
`}var d={name:"help",async execute(n,e){if(n.includes("--help")||n.includes("-h"))return{stdout:`help - display available commands
|
|
7
|
-
|
|
8
|
-
Usage: help [command]
|
|
9
|
-
|
|
10
|
-
Options:
|
|
11
|
-
-h, --help Show this help message
|
|
12
|
-
|
|
13
|
-
If a command name is provided, shows help for that command.
|
|
14
|
-
Otherwise, lists all available commands.
|
|
15
|
-
`,stderr:"",exitCode:0};if(n.length>0&&e.exec){let s=n[0];return e.exec(`${s} --help`,{cwd:e.cwd})}let t=e.getRegisteredCommands?.()??[];return{stdout:l(t),stderr:"",exitCode:0}}},m={name:"help",flags:[]};export{d as a,m as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-OGDTSM2Q.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as envCommand,c as flagsForFuzzing,b as printenvCommand,d as printenvFlagsForFuzzing};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-73RYQHTW.js";import"./chunk-IJXFPKNC.js";import"./chunk-YNYSPYQ5.js";import"./chunk-EEXR5ZDP.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as findCommand,b as flagsForFuzzing};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-ZKLK6C7H.js";import"./chunk-DXB73IDG.js";export{b as flagsForFuzzing,a as helpCommand};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{a as D}from"./chunk-YYAPW4OA.js";import{b as P}from"./chunk-R7KYILVY.js";import{a as _,b as O,c as I,d as h}from"./chunk-LEOLL6PF.js";import{a as L}from"./chunk-OJDRYQWQ.js";import{a as U,b as x}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import{fileURLToPath as v}from"node:url";import{Worker as b}from"node:worker_threads";var c={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200},n={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},r={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},S={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:1048576,TOTAL:1052704},T={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 N(){return new I(S.TOTAL)}var F=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,r.OP_CODE/4)}setOpCode(t){h.store(this.int32View,r.OP_CODE/4,t)}getStatus(){return h.load(this.int32View,r.STATUS/4)}setStatus(t){h.store(this.int32View,r.STATUS/4,t)}getPathLength(){return h.load(this.int32View,r.PATH_LENGTH/4)}setPathLength(t){h.store(this.int32View,r.PATH_LENGTH/4,t)}getDataLength(){return h.load(this.int32View,r.DATA_LENGTH/4)}setDataLength(t){h.store(this.int32View,r.DATA_LENGTH/4,t)}getResultLength(){return h.load(this.int32View,r.RESULT_LENGTH/4)}setResultLength(t){h.store(this.int32View,r.RESULT_LENGTH/4,t)}getErrorCode(){return h.load(this.int32View,r.ERROR_CODE/4)}setErrorCode(t){h.store(this.int32View,r.ERROR_CODE/4,t)}getFlags(){return h.load(this.int32View,r.FLAGS/4)}setFlags(t){h.store(this.int32View,r.FLAGS/4,t)}getMode(){return h.load(this.int32View,r.MODE/4)}setMode(t){h.store(this.int32View,r.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(r.PATH_BUFFER,r.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>S.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${S.PATH_BUFFER}`);this.uint8View.set(e,r.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(r.DATA_BUFFER,r.DATA_BUFFER+t)}setData(t){if(t.length>S.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${S.DATA_BUFFER}`);this.uint8View.set(t,r.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(r.DATA_BUFFER,r.DATA_BUFFER+t)}setResult(t){if(t.length>S.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${S.DATA_BUFFER}`);this.uint8View.set(t,r.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[r.DATA_BUFFER+l.IS_FILE]=t.isFile?1:0,this.uint8View[r.DATA_BUFFER+l.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[r.DATA_BUFFER+l.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(r.DATA_BUFFER+l.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(r.DATA_BUFFER+l.SIZE,e,!0),this.dataView.setFloat64(r.DATA_BUFFER+l.MTIME,t.mtime.getTime(),!0),this.setResultLength(l.TOTAL)}decodeStat(){return{isFile:this.uint8View[r.DATA_BUFFER+l.IS_FILE]===1,isDirectory:this.uint8View[r.DATA_BUFFER+l.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[r.DATA_BUFFER+l.IS_SYMLINK]===1,mode:this.dataView.getInt32(r.DATA_BUFFER+l.MODE,!0),size:this.dataView.getFloat64(r.DATA_BUFFER+l.SIZE,!0),mtime:new Date(this.dataView.getFloat64(r.DATA_BUFFER+l.MTIME,!0))}}waitForReady(t){return h.wait(this.int32View,r.STATUS/4,n.PENDING,t)}waitForReadyAsync(t){return h.waitAsync(this.int32View,r.STATUS/4,n.PENDING,t)}async waitUntilReady(t){let e=Date.now();for(;;){let s=this.getStatus();if(s===n.READY)return!0;let o=Date.now()-e;if(o>=t)return!1;let a=t-o,d=h.waitAsync(this.int32View,r.STATUS/4,s,a);if(d.async&&await d.value==="timed-out")return!1}}waitForResult(t){return h.wait(this.int32View,r.STATUS/4,n.READY,t)}notify(){return h.notify(this.int32View,r.STATUS/4)}reset(){this.setOpCode(c.NOOP),this.setStatus(n.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(u.NONE),this.setFlags(T.NONE),this.setMode(0)}};var g=class{fs;cwd;secureFetch;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};constructor(t,e,s,o=void 0){this.fs=e,this.cwd=s,this.secureFetch=o,this.protocol=new F(t)}async run(t){this.running=!0;let e=Date.now();for(;this.running;){let s=Date.now()-e;if(s>=t){this.output.stderr+=`
|
|
2
|
-
python3: execution timeout exceeded
|
|
3
|
-
`,this.output.exitCode=124;break}let o=t-s;if(!await this.protocol.waitUntilReady(o)){this.output.stderr+=`
|
|
4
|
-
python3: execution timeout exceeded
|
|
5
|
-
`,this.output.exitCode=124;break}let d=this.protocol.getOpCode();await this.handleOperation(d),this.protocol.notify()}return this.output}stop(){this.running=!1}async handleOperation(t){try{switch(t){case c.READ_FILE:await this.handleReadFile();break;case c.WRITE_FILE:await this.handleWriteFile();break;case c.STAT:await this.handleStat();break;case c.LSTAT:await this.handleLstat();break;case c.READDIR:await this.handleReaddir();break;case c.MKDIR:await this.handleMkdir();break;case c.RM:await this.handleRm();break;case c.EXISTS:await this.handleExists();break;case c.APPEND_FILE:await this.handleAppendFile();break;case c.SYMLINK:await this.handleSymlink();break;case c.READLINK:await this.handleReadlink();break;case c.CHMOD:await this.handleChmod();break;case c.REALPATH:await this.handleRealpath();break;case c.WRITE_STDOUT:this.handleWriteStdout();break;case c.WRITE_STDERR:this.handleWriteStderr();break;case c.EXIT:this.handleExit();break;case c.HTTP_REQUEST:await this.handleHttpRequest();break;default:this.protocol.setErrorCode(u.IO_ERROR),this.protocol.setStatus(n.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(n.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(n.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleStat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.stat(t);this.protocol.encodeStat(e),this.protocol.setStatus(n.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(n.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(n.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleMkdir(){let t=this.resolvePath(this.protocol.getPath()),s=(this.protocol.getFlags()&T.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:s}),this.protocol.setStatus(n.SUCCESS)}catch(o){this.setErrorFromException(o)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=(e&T.RECURSIVE)!==0,o=(e&T.FORCE)!==0;try{await this.fs.rm(t,{recursive:s,force:o}),this.protocol.setStatus(n.SUCCESS)}catch(a){this.setErrorFromException(a)}}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(n.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(n.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleSymlink(){let t=this.protocol.getPath(),e=this.protocol.getDataAsString(),s=this.resolvePath(t);try{await this.fs.symlink(e,s),this.protocol.setStatus(n.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(n.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(n.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRealpath(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.realpath(t);this.protocol.setResultFromString(e),this.protocol.setStatus(n.SUCCESS)}catch(e){this.setErrorFromException(e)}}handleWriteStdout(){let t=this.protocol.getDataAsString();this.output.stdout+=t,this.protocol.setStatus(n.SUCCESS)}handleWriteStderr(){let t=this.protocol.getDataAsString();this.output.stderr+=t,this.protocol.setStatus(n.SUCCESS)}handleExit(){let t=this.protocol.getFlags();this.output.exitCode=t,this.protocol.setStatus(n.SUCCESS),this.running=!1}async handleHttpRequest(){if(!this.secureFetch){this.protocol.setErrorCode(u.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(n.ERROR);return}let t=this.protocol.getPath(),e=this.protocol.getDataAsString();try{let s=e?JSON.parse(e):{},o=await this.secureFetch(t,{method:s.method,headers:s.headers,body:s.body}),a=JSON.stringify({status:o.status,statusText:o.statusText,headers:o.headers,body:o.body,url:o.url});this.protocol.setResultFromString(a),this.protocol.setStatus(n.SUCCESS)}catch(s){let o=D(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(u.NETWORK_ERROR),this.protocol.setResultFromString(o),this.protocol.setStatus(n.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),s=D(e),o=u.IO_ERROR,a=e.toLowerCase();a.includes("no such file")||a.includes("not found")||a.includes("enoent")?o=u.NOT_FOUND:a.includes("is a directory")||a.includes("eisdir")?o=u.IS_DIRECTORY:a.includes("not a directory")||a.includes("enotdir")?o=u.NOT_DIRECTORY:a.includes("already exists")||a.includes("eexist")?o=u.EXISTS:(a.includes("permission")||a.includes("eperm")||a.includes("eacces"))&&(o=u.PERMISSION_DENIED),this.protocol.setErrorCode(o),this.protocol.setResultFromString(s),this.protocol.setStatus(n.ERROR)}};var B=3e4,H={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 W(i){let t={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(i.length===0)return t;let e=i.findIndex(s=>!s.startsWith("-")||s==="-"||s==="--");for(let s=0;s<(e===-1?i.length:e);s++){let o=i[s];if(o==="-c")return s+1>=i.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
|
|
6
|
-
`,exitCode:2}:(t.code=i[s+1],t.scriptArgs=i.slice(s+2),t);if(o==="-m")return s+1>=i.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
|
|
7
|
-
`,exitCode:2}:(t.module=i[s+1],t.scriptArgs=i.slice(s+2),t);if(o==="--version"||o==="-V")return t.showVersion=!0,t;if(o.startsWith("-")&&o!=="-")return{stdout:"",stderr:`python3: unrecognized option '${o}'
|
|
8
|
-
`,exitCode:2}}if(e!==-1){let s=i[e];s==="--"?e+1<i.length&&(t.scriptFile=i[e+1],t.scriptArgs=i.slice(e+2)):(t.scriptFile=s,t.scriptArgs=i.slice(e+1))}return t}var p=[],E=!1;function it(){p.length=0,E=!1}var G=v(new URL("./worker.js",import.meta.url));function w(){if(E||p.length===0)return;for(;p.length>0&&p[0].canceled;)p.shift();if(p.length===0)return;let i=p.shift();if(!i)return;E=!0;let t=P.runTrusted(()=>new b(G,{workerData:i.input}));i.workerRef&&(i.workerRef.current=t),t.on("message",e=>{if(e.type==="security-violation"){i.resolve({success:!1,error:`Security violation: ${e.violation?.type??"unknown"}`}),E=!1,t.terminate(),w();return}i.resolve(e),E=!1,t.terminate(),w()}),t.on("error",e=>{i.resolve({success:!1,error:e.message}),E=!1,w()}),t.on("exit",()=>{E&&(i.resolve({success:!1,error:"Worker exited unexpectedly"}),E=!1,w())})}async function $(i,t,e,s=[]){let o=N(),a=new g(o,t.fs,t.cwd,t.fetch),d=t.limits?.maxPythonTimeoutMs??B,C={sharedBuffer:o,pythonCode:i,cwd:t.cwd,env:L(t.env),args:s,scriptPath:e},f={current:null},V=new Promise(R=>{let y={input:C,resolve:()=>{},workerRef:f},M=_(()=>{f.current?f.current.terminate():y.canceled=!0,R({success:!1,error:`Execution timeout: exceeded ${d}ms limit`})},d);y.resolve=k=>{O(M),R(k)},p.push(y),w()}),[m,A]=await Promise.all([a.run(d).catch(R=>({stdout:"",stderr:`python3: bridge error: ${R.message}
|
|
9
|
-
`,exitCode:1})),V.catch(R=>({success:!1,error:R.message}))]);return!A.success&&A.error?{stdout:m.stdout,stderr:`${m.stderr}python3: ${A.error}
|
|
10
|
-
`,exitCode:m.exitCode||1}:m}var Y={name:"python3",async execute(i,t){if(x(i))return U(H);let e=W(i);if("exitCode"in e)return e;if(e.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
|
|
11
|
-
`,stderr:"",exitCode:0};let s,o;if(e.code!==null)s=e.code,o="-c";else if(e.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(e.module))return{stdout:"",stderr:`python3: No module named '${e.module.slice(0,200)}'
|
|
12
|
-
`,exitCode:1};s=`import runpy; runpy.run_module('${e.module}', run_name='__main__')`,o=e.module}else if(e.scriptFile!==null){let a=t.fs.resolvePath(t.cwd,e.scriptFile);if(!await t.fs.exists(a))return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': [Errno 2] No such file or directory
|
|
13
|
-
`,exitCode:2};try{s=await t.fs.readFile(a),o=e.scriptFile}catch(d){return{stdout:"",stderr:`python3: can't open file '${e.scriptFile}': ${d.message}
|
|
14
|
-
`,exitCode:2}}}else if(t.stdin.trim())s=t.stdin,o="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
|
|
15
|
-
`,exitCode:2};return $(s,t,o,e.scriptArgs)}},nt={name:"python",async execute(i,t){return Y.execute(i,t)}};export{it as _resetExecutionQueue,Y as python3Command,nt as pythonCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-FJNVFD75.js";import"./chunk-VLGZJRPG.js";import"./chunk-YNYSPYQ5.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{b as flagsForFuzzing,a as rgCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-K4OVSVUA.js";import"./chunk-R7KYILVY.js";import"./chunk-LEOLL6PF.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{b as flagsForFuzzing,a as sqlite3Command};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-CSBFBYLD.js";import"./chunk-OJDRYQWQ.js";import"./chunk-DXB73IDG.js";export{b as flagsForFuzzing,a as timeCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-S7ED3RD5.js";import"./chunk-LEOLL6PF.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{b as flagsForFuzzing,a as timeoutCommand};
|