just-bash 2.12.1 → 2.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/bin/chunks/{base64-YXBFJFHG.js → base64-43M2R3GA.js} +1 -1
  2. package/dist/bin/chunks/{cat-3J7U3HHI.js → cat-XZIJZXKP.js} +1 -1
  3. package/dist/bin/chunks/chunk-2FFXXW3F.js +14 -0
  4. package/dist/bin/chunks/chunk-435ZOZCY.js +63 -0
  5. package/dist/bin/chunks/chunk-4FNW6LFM.js +5 -0
  6. package/dist/bin/chunks/chunk-4PZYIYYG.js +36 -0
  7. package/dist/bin/chunks/chunk-54G6AE72.js +32 -0
  8. package/dist/bin/{shell/chunks/chunk-NEQEZ32M.js → chunks/chunk-CGE2EHYP.js} +3 -3
  9. package/dist/bin/chunks/{chunk-JWVOLGWZ.js → chunk-DREQRXNN.js} +1 -1
  10. package/dist/bin/chunks/{chunk-THLAHQXV.js → chunk-FA2CHD73.js} +1 -1
  11. package/dist/bin/{shell/chunks/chunk-BARKRZDC.js → chunks/chunk-GOJZHH3L.js} +1 -1
  12. package/dist/bin/chunks/chunk-IYZRLSTQ.js +2 -0
  13. package/dist/bin/chunks/chunk-JJHAWOIB.js +2 -0
  14. package/dist/bin/chunks/{chunk-F37UEO7A.js → chunk-JNPUO56K.js} +1 -1
  15. package/dist/bin/chunks/chunk-MRP4ZCD7.js +6 -0
  16. package/dist/bin/{shell/chunks/chunk-45MJQ2LX.js → chunks/chunk-OKL2SPHK.js} +32 -32
  17. package/dist/bin/chunks/{chunk-5U7Q4GUC.js → chunk-WWZVR5NN.js} +4 -4
  18. package/dist/bin/{shell/chunks/cut-HDHQDWRG.js → chunks/cut-5EY2XPXX.js} +1 -1
  19. package/dist/bin/chunks/{expansion-QVHAYGVZ.js → expansion-TCB3WZP5.js} +1 -1
  20. package/dist/bin/{shell/chunks/flag-coverage-F4EAJUHL.js → chunks/flag-coverage-23ZUDENJ.js} +1 -1
  21. package/dist/bin/chunks/{gzip-EENEW6WQ.js → gzip-LHOO65AN.js} +1 -1
  22. package/dist/bin/chunks/python3-74B25WCY.js +17 -0
  23. package/dist/bin/chunks/{sleep-RA6DYTJX.js → sleep-GUJH2AMQ.js} +1 -1
  24. package/dist/bin/chunks/{sort-NZSEYCI6.js → sort-7GENYU2I.js} +1 -1
  25. package/dist/bin/chunks/sqlite3-57UI7HYL.js +2 -0
  26. package/dist/bin/chunks/{tar-GP2CCB47.js → tar-VIYVHMER.js} +1 -1
  27. package/dist/bin/chunks/time-FAWHHOMA.js +2 -0
  28. package/dist/bin/chunks/timeout-4O4YYRTS.js +2 -0
  29. package/dist/bin/chunks/{uniq-FZWFZEN5.js → uniq-TMSAIZM3.js} +1 -1
  30. package/dist/bin/chunks/worker.js +154 -4
  31. package/dist/bin/just-bash.js +294 -294
  32. package/dist/bin/shell/chunks/{base64-YXBFJFHG.js → base64-43M2R3GA.js} +1 -1
  33. package/dist/bin/shell/chunks/{cat-3J7U3HHI.js → cat-XZIJZXKP.js} +1 -1
  34. package/dist/bin/shell/chunks/chunk-2FFXXW3F.js +14 -0
  35. package/dist/bin/shell/chunks/chunk-435ZOZCY.js +63 -0
  36. package/dist/bin/shell/chunks/chunk-4FNW6LFM.js +5 -0
  37. package/dist/bin/shell/chunks/chunk-4PZYIYYG.js +36 -0
  38. package/dist/bin/shell/chunks/chunk-54G6AE72.js +32 -0
  39. package/dist/bin/{chunks/chunk-NEQEZ32M.js → shell/chunks/chunk-CGE2EHYP.js} +3 -3
  40. package/dist/bin/shell/chunks/{chunk-JWVOLGWZ.js → chunk-DREQRXNN.js} +1 -1
  41. package/dist/bin/shell/chunks/{chunk-THLAHQXV.js → chunk-FA2CHD73.js} +1 -1
  42. package/dist/bin/{chunks/chunk-BARKRZDC.js → shell/chunks/chunk-GOJZHH3L.js} +1 -1
  43. package/dist/bin/shell/chunks/chunk-IYZRLSTQ.js +2 -0
  44. package/dist/bin/shell/chunks/chunk-JJHAWOIB.js +2 -0
  45. package/dist/bin/shell/chunks/{chunk-F37UEO7A.js → chunk-JNPUO56K.js} +1 -1
  46. package/dist/bin/shell/chunks/chunk-MRP4ZCD7.js +6 -0
  47. package/dist/bin/{chunks/chunk-45MJQ2LX.js → shell/chunks/chunk-OKL2SPHK.js} +32 -32
  48. package/dist/bin/shell/chunks/{chunk-5U7Q4GUC.js → chunk-WWZVR5NN.js} +4 -4
  49. package/dist/bin/{chunks/cut-HDHQDWRG.js → shell/chunks/cut-5EY2XPXX.js} +1 -1
  50. package/dist/bin/shell/chunks/{expansion-QVHAYGVZ.js → expansion-TCB3WZP5.js} +1 -1
  51. package/dist/bin/{chunks/flag-coverage-F4EAJUHL.js → shell/chunks/flag-coverage-23ZUDENJ.js} +1 -1
  52. package/dist/bin/shell/chunks/{gzip-EENEW6WQ.js → gzip-LHOO65AN.js} +1 -1
  53. package/dist/bin/shell/chunks/python3-74B25WCY.js +17 -0
  54. package/dist/bin/shell/chunks/{sleep-RA6DYTJX.js → sleep-GUJH2AMQ.js} +1 -1
  55. package/dist/bin/shell/chunks/{sort-NZSEYCI6.js → sort-7GENYU2I.js} +1 -1
  56. package/dist/bin/shell/chunks/sqlite3-57UI7HYL.js +2 -0
  57. package/dist/bin/shell/chunks/{tar-GP2CCB47.js → tar-VIYVHMER.js} +1 -1
  58. package/dist/bin/shell/chunks/time-FAWHHOMA.js +2 -0
  59. package/dist/bin/shell/chunks/timeout-4O4YYRTS.js +2 -0
  60. package/dist/bin/shell/chunks/{uniq-FZWFZEN5.js → uniq-TMSAIZM3.js} +1 -1
  61. package/dist/bin/shell/shell.js +269 -269
  62. package/dist/bundle/browser.js +736 -735
  63. package/dist/bundle/chunks/{base64-A3SGWC34.js → base64-4YMZCVJ5.js} +1 -1
  64. package/dist/bundle/chunks/{cat-C2OBLGHA.js → cat-RDUMLXKC.js} +1 -1
  65. package/dist/bundle/chunks/{chunk-WCVBECE6.js → chunk-4VCAQZKQ.js} +32 -32
  66. package/dist/bundle/chunks/chunk-5CJQNRNJ.js +62 -0
  67. package/dist/bundle/chunks/{chunk-VFBZTF5G.js → chunk-7BQDVPII.js} +1 -1
  68. package/dist/bundle/chunks/chunk-7KHLIOOW.js +4 -0
  69. package/dist/bundle/chunks/chunk-BEFDX7IY.js +1 -0
  70. package/dist/bundle/chunks/{chunk-KAEMRWOH.js → chunk-KMEYNNUA.js} +1 -1
  71. package/dist/bundle/chunks/chunk-LTZRCH7N.js +31 -0
  72. package/dist/bundle/chunks/chunk-NBAARP4B.js +1 -0
  73. package/dist/bundle/chunks/{chunk-HBB2R24Y.js → chunk-OKEHYWBE.js} +1 -1
  74. package/dist/bundle/chunks/{chunk-IBFD7QQD.js → chunk-QJ7O6ZN3.js} +1 -1
  75. package/dist/bundle/chunks/chunk-RHOPHAL6.js +35 -0
  76. package/dist/bundle/chunks/{chunk-6NY2AP72.js → chunk-SDNKECQQ.js} +4 -4
  77. package/dist/bundle/chunks/chunk-TXBZCHCQ.js +5 -0
  78. package/dist/bundle/chunks/{chunk-DKOIE53N.js → chunk-UJIR5V54.js} +1 -1
  79. package/dist/bundle/chunks/{chunk-7C6RBHP3.js → chunk-WKFATFPP.js} +3 -3
  80. package/dist/bundle/chunks/chunk-YIY2RKBW.js +13 -0
  81. package/dist/bundle/chunks/{cut-LO6YYY5P.js → cut-OPC3VAGB.js} +1 -1
  82. package/dist/bundle/chunks/{expansion-NCEBD7KB.js → expansion-HJ6B4DDG.js} +1 -1
  83. package/dist/bundle/chunks/{flag-coverage-U322DJFL.js → flag-coverage-L3DCLG6V.js} +1 -1
  84. package/dist/bundle/chunks/{gzip-UTSGNF5Z.js → gzip-AQXSGOVS.js} +1 -1
  85. package/dist/bundle/chunks/python3-6BKA3FYA.js +16 -0
  86. package/dist/bundle/chunks/rg-RAICUFGG.js +1 -0
  87. package/dist/bundle/chunks/{sleep-RKLUWJ7F.js → sleep-LB7FI6AB.js} +1 -1
  88. package/dist/bundle/chunks/{sort-T7TNLWXL.js → sort-DCNRDA7U.js} +1 -1
  89. package/dist/bundle/chunks/sqlite3-FVNA4KNF.js +1 -0
  90. package/dist/bundle/chunks/{tar-H6XTXOAP.js → tar-E2DVQEWO.js} +1 -1
  91. package/dist/bundle/chunks/time-AGNW2ZY6.js +1 -0
  92. package/dist/bundle/chunks/timeout-VN35D5O7.js +1 -0
  93. package/dist/bundle/chunks/{uniq-ZXE4O5XB.js → uniq-SUNANL47.js} +1 -1
  94. package/dist/bundle/chunks/worker.js +154 -4
  95. package/dist/bundle/index.cjs +779 -777
  96. package/dist/bundle/index.js +272 -272
  97. package/dist/commands/python3/fs-bridge-handler.d.ts +5 -1
  98. package/dist/commands/tar/tar-options.d.ts +1 -0
  99. package/dist/interpreter/helpers/result.d.ts +6 -0
  100. package/dist/limits.d.ts +2 -0
  101. package/dist/network/types.d.ts +1 -1
  102. package/dist/sandbox/Command.d.ts +8 -1
  103. package/dist/sandbox/Sandbox.d.ts +1 -0
  104. package/dist/timers.d.ts +1 -0
  105. package/dist/types.d.ts +14 -0
  106. package/package.json +1 -1
  107. package/dist/bin/chunks/chunk-4QM2TCNV.js +0 -2
  108. package/dist/bin/chunks/chunk-C7TH4MVZ.js +0 -14
  109. package/dist/bin/chunks/chunk-DAGNL3F2.js +0 -32
  110. package/dist/bin/chunks/chunk-H7Y3TH22.js +0 -36
  111. package/dist/bin/chunks/chunk-K47SEEPI.js +0 -6
  112. package/dist/bin/chunks/chunk-KTFEQPO7.js +0 -4
  113. package/dist/bin/chunks/chunk-QC46PWBQ.js +0 -63
  114. package/dist/bin/chunks/chunk-WIWKAGK6.js +0 -2
  115. package/dist/bin/chunks/python3-XRP5IZRL.js +0 -16
  116. package/dist/bin/chunks/sqlite3-ZUGDKEIT.js +0 -2
  117. package/dist/bin/chunks/time-E5YULACD.js +0 -2
  118. package/dist/bin/chunks/timeout-TCIINQNA.js +0 -2
  119. package/dist/bin/shell/chunks/chunk-4QM2TCNV.js +0 -2
  120. package/dist/bin/shell/chunks/chunk-C7TH4MVZ.js +0 -14
  121. package/dist/bin/shell/chunks/chunk-DAGNL3F2.js +0 -32
  122. package/dist/bin/shell/chunks/chunk-H7Y3TH22.js +0 -36
  123. package/dist/bin/shell/chunks/chunk-K47SEEPI.js +0 -6
  124. package/dist/bin/shell/chunks/chunk-KTFEQPO7.js +0 -4
  125. package/dist/bin/shell/chunks/chunk-QC46PWBQ.js +0 -63
  126. package/dist/bin/shell/chunks/chunk-WIWKAGK6.js +0 -2
  127. package/dist/bin/shell/chunks/python3-XRP5IZRL.js +0 -16
  128. package/dist/bin/shell/chunks/sqlite3-ZUGDKEIT.js +0 -2
  129. package/dist/bin/shell/chunks/time-E5YULACD.js +0 -2
  130. package/dist/bin/shell/chunks/timeout-TCIINQNA.js +0 -2
  131. package/dist/bundle/chunks/chunk-7DBA735O.js +0 -5
  132. package/dist/bundle/chunks/chunk-BNVESM72.js +0 -35
  133. package/dist/bundle/chunks/chunk-DZ33S2U7.js +0 -31
  134. package/dist/bundle/chunks/chunk-FPGA7RT4.js +0 -62
  135. package/dist/bundle/chunks/chunk-JOVMV4XV.js +0 -13
  136. package/dist/bundle/chunks/chunk-LEOLL6PF.js +0 -1
  137. package/dist/bundle/chunks/chunk-R7KYILVY.js +0 -3
  138. package/dist/bundle/chunks/chunk-YYAPW4OA.js +0 -1
  139. package/dist/bundle/chunks/python3-E7VF6UYO.js +0 -15
  140. package/dist/bundle/chunks/rg-DMOXE47H.js +0 -1
  141. package/dist/bundle/chunks/sqlite3-ZGX3YFJB.js +0 -1
  142. package/dist/bundle/chunks/time-ZEEYNXNZ.js +0 -1
  143. package/dist/bundle/chunks/timeout-LYYTWG45.js +0 -1
@@ -18,10 +18,12 @@ export declare class FsBridgeHandler {
18
18
  private fs;
19
19
  private cwd;
20
20
  private secureFetch;
21
+ private maxOutputSize;
21
22
  private protocol;
22
23
  private running;
23
24
  private output;
24
- constructor(sharedBuffer: SharedArrayBuffer, fs: IFileSystem, cwd: string, secureFetch?: SecureFetch | undefined);
25
+ private outputLimitExceeded;
26
+ constructor(sharedBuffer: SharedArrayBuffer, fs: IFileSystem, cwd: string, secureFetch?: SecureFetch | undefined, maxOutputSize?: number);
25
27
  /**
26
28
  * Run the handler loop until EXIT operation or timeout.
27
29
  */
@@ -45,6 +47,8 @@ export declare class FsBridgeHandler {
45
47
  private handleWriteStdout;
46
48
  private handleWriteStderr;
47
49
  private handleExit;
50
+ private tryAppendOutput;
51
+ private appendOutputLimitError;
48
52
  private handleHttpRequest;
49
53
  private setErrorFromException;
50
54
  }
@@ -20,6 +20,7 @@ export interface TarOptions {
20
20
  touch: boolean;
21
21
  directory: string;
22
22
  preserve: boolean;
23
+ absoluteNames: boolean;
23
24
  strip: number;
24
25
  exclude: string[];
25
26
  filesFrom: string;
@@ -5,6 +5,7 @@
5
5
  * constructing ExecResult objects throughout the interpreter.
6
6
  */
7
7
  import type { ExecResult } from "../../types.js";
8
+ import type { InterpreterContext } from "../types.js";
8
9
  /**
9
10
  * A successful result with no output.
10
11
  * Use this for commands that succeed silently.
@@ -52,3 +53,8 @@ export declare function testResult(passed: boolean): ExecResult;
52
53
  * @throws ExecutionLimitError always
53
54
  */
54
55
  export declare function throwExecutionLimit(message: string, limitType: "recursion" | "iterations" | "commands" | "string_length" | "glob_operations" | "substitution_depth" | "output_size" | "file_descriptors", stdout?: string, stderr?: string): never;
56
+ /**
57
+ * Check file descriptor count against the limit before adding a new one.
58
+ * Throws ExecutionLimitError if the limit would be exceeded.
59
+ */
60
+ export declare function checkFdLimit(ctx: InterpreterContext): void;
package/dist/limits.d.ts CHANGED
@@ -41,6 +41,8 @@ export interface ExecutionLimits {
41
41
  maxOutputSize?: number;
42
42
  /** Maximum number of open file descriptors (default: 1024) */
43
43
  maxFileDescriptors?: number;
44
+ /** Maximum source/. nesting depth (default: 100) */
45
+ maxSourceDepth?: number;
44
46
  }
45
47
  /**
46
48
  * Resolve execution limits by merging user-provided limits with defaults.
@@ -55,7 +55,7 @@ export interface NetworkConfig {
55
55
  maxResponseSize?: number;
56
56
  /**
57
57
  * Reject URLs with private/loopback IP addresses as hostnames.
58
- * This is a URL-string-level check only (no DNS resolution).
58
+ * This is a URL/hostname-level check only (no DNS resolution).
59
59
  * Useful for mitigating SSRF attacks. Default: false (opt-in).
60
60
  */
61
61
  denyPrivateRanges?: boolean;
@@ -13,8 +13,15 @@ export declare class Command {
13
13
  private cmdLine;
14
14
  private env?;
15
15
  private explicitCwd;
16
+ private signal?;
17
+ private timeoutMs?;
18
+ private abortController;
19
+ private timeoutId;
20
+ private externalAbortListener;
16
21
  private resultPromise;
17
- constructor(bashEnv: Bash, cmdLine: string, cwd: string, env?: Record<string, string>, explicitCwd?: boolean);
22
+ constructor(bashEnv: Bash, cmdLine: string, cwd: string, env?: Record<string, string>, explicitCwd?: boolean, signal?: AbortSignal, timeoutMs?: number);
23
+ private setupCancellation;
24
+ private cleanupCancellation;
18
25
  private execute;
19
26
  logs(): AsyncGenerator<OutputMessage, void, unknown>;
20
27
  wait(): Promise<CommandFinished>;
@@ -57,6 +57,7 @@ export interface WriteFilesInput {
57
57
  }
58
58
  export declare class Sandbox {
59
59
  private bashEnv;
60
+ private timeoutMs?;
60
61
  private constructor();
61
62
  static create(opts?: SandboxOptions): Promise<Sandbox>;
62
63
  runCommand(params: RunCommandParams & {
package/dist/timers.d.ts CHANGED
@@ -13,3 +13,4 @@ export declare const _setTimeout: typeof globalThis.setTimeout;
13
13
  export declare const _clearTimeout: typeof globalThis.clearTimeout;
14
14
  export declare const _SharedArrayBuffer: typeof globalThis.SharedArrayBuffer;
15
15
  export declare const _Atomics: typeof globalThis.Atomics;
16
+ export declare const _performanceNow: () => number;
package/dist/types.d.ts CHANGED
@@ -14,6 +14,13 @@ export interface ExecResult {
14
14
  exitCode: number;
15
15
  /** The final environment variables after execution (only set by BashEnv.exec) */
16
16
  env?: Record<string, string>;
17
+ /**
18
+ * Encoding hint for stdout content when writing to files via redirections.
19
+ * Set to "binary" by commands that produce binary output (e.g., cat, gzip)
20
+ * to prevent re-encoding of raw byte data as UTF-8.
21
+ * When not set, the redirect system uses UTF-8 for non-ASCII text.
22
+ */
23
+ stdoutEncoding?: "binary";
17
24
  }
18
25
  /** Result from BashEnv.exec() - always includes env */
19
26
  export interface BashExecResult extends ExecResult {
@@ -160,6 +167,13 @@ export interface CommandContext {
160
167
  }
161
168
  export interface Command {
162
169
  name: string;
170
+ /**
171
+ * When true, execute this command inside DefenseInDepthBox.runTrustedAsync().
172
+ * Use for trusted host-extension commands that need direct Node.js globals.
173
+ * Built-in commands should generally remain untrusted and use explicit
174
+ * trusted wrappers only at narrow infrastructure boundaries.
175
+ */
176
+ trusted?: boolean;
163
177
  execute(args: string[], ctx: CommandContext): Promise<ExecResult>;
164
178
  }
165
179
  export type CommandRegistry = Map<string, Command>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-bash",
3
- "version": "2.12.1",
3
+ "version": "2.12.3",
4
4
  "description": "A simulated bash environment with virtual filesystem",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- 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,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as u}from"./chunk-4OALHZXB.js";import{a as c}from"./chunk-4PRVMER6.js";var b={name:"time",async execute(i,r){let a="%e %M",n=null,m=!1,f=!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'
3
- `,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'
4
- `,exitCode:1};n=i[t],t++}else if(e==="-a"||e==="--append")m=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
5
- Elapsed (wall clock) time: %e seconds
6
- Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")f=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let l=i.slice(t);if(l.length===0)return{stdout:"",stderr:"",exitCode:0};let p=performance.now(),g=u(l),h=l.join(" "),s;try{if(!r.exec)return{stdout:"",stderr:`time: exec not available
7
- `,exitCode:1};s=await r.exec(g,{env:c(r.env),cwd:r.cwd,stdin:r.stdin,signal:r.signal})}catch(e){s={stdout:"",stderr:`time: ${e.message}
8
- `,exitCode:127}}let d=(performance.now()-p)/1e3,o;if(f?o=`real ${d.toFixed(2)}
9
- user 0.00
10
- sys 0.00
11
- `:(o=a.replace(/%e/g,d.toFixed(2)).replace(/%E/g,C(d)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,h),o.endsWith(`
12
- `)||(o+=`
13
- `)),n)try{let e=r.fs.resolvePath(r.cwd,n);if(m&&await r.fs.exists(e)){let w=await r.fs.readFile(e);await r.fs.writeFile(e,w+o)}else await r.fs.writeFile(e,o)}catch(e){return{stdout:s.stdout,stderr:s.stderr+`time: cannot write to '${n}': ${e.message}
14
- `,exitCode:s.exitCode}}else s={...s,stderr:s.stderr+o};return s}};function C(i){let r=Math.floor(i/3600),a=Math.floor(i%3600/60),n=i%60;return r>0?`${r}:${a.toString().padStart(2,"0")}:${n.toFixed(2).padStart(5,"0")}`:`${a}:${n.toFixed(2).padStart(5,"0")}`}var y={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{b as a,y as b};
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as $}from"./chunk-JBABAK44.js";import{a as v,b as z}from"./chunk-GTNBSMZR.js";import{constants as C,gunzipSync as b,gzipSync as w}from"node:zlib";var q={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
3
-
4
- When no FILE is given, or when FILE is -, read from standard input.
5
-
6
- With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},I={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place).
7
-
8
- When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},P={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
9
-
10
- When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},L={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};function F(e){return e.best?C.Z_BEST_COMPRESSION:e.level8?8:e.level7?7:e.level6?6:e.level5?5:e.level4?4:e.level3?3:e.level2?2:e.fast?C.Z_BEST_SPEED:C.Z_DEFAULT_COMPRESSION}function S(e){if(e.length<10)return{originalName:null,mtime:null,headerSize:0};if(e[0]!==31||e[1]!==139)return{originalName:null,mtime:null,headerSize:0};let t=e[3],o=e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r=10;if(t&4){if(r+2>e.length)return{originalName:null,mtime:null,headerSize:0};let n=e[r]|e[r+1]<<8;r+=2+n}let s=null;if(t&8){let n=r;for(;r<e.length&&e[r]!==0;)r++;r<e.length&&(s=new TextDecoder().decode(e.slice(n,r)),r++)}if(t&16){for(;r<e.length&&e[r]!==0;)r++;r++}return t&2&&(r+=2),{originalName:s,mtime:o>0?new Date(o*1e3):null,headerSize:r}}function D(e){if(e.length<4)return 0;let t=e.length;return e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24}function m(e){return e.length>=2&&e[0]===31&&e[1]===139}async function E(e,t,o,r,s,n){let l=o.suffix,f,p,a;if(t==="-"||t==="")if(a=Uint8Array.from(e.stdin,u=>u.charCodeAt(0)),s){if(!m(a))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
11
- `,exitCode:1};try{let u=b(a);return{stdout:String.fromCharCode(...u),stderr:"",exitCode:0}}catch(u){let i=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`${r}: stdin: ${i}
12
- `,exitCode:1}}}else{let u=F(o),i=w(a,{level:u});return{stdout:String.fromCharCode(...i),stderr:"",exitCode:0}}f=e.fs.resolvePath(e.cwd,t);try{if((await e.fs.stat(f)).isDirectory)return o.recursive?await k(e,f,o,r,s,n):o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: is a directory -- ignored
13
- `,exitCode:1}}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
14
- `,exitCode:1}}try{a=await e.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
15
- `,exitCode:1}}if(s){if(!t.endsWith(l))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: unknown suffix -- ignored
16
- `,exitCode:1};if(!m(a))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
17
- `,exitCode:1};let u;try{u=b(a)}catch(i){let c=i instanceof Error?i.message:"unknown error";return{stdout:"",stderr:`${r}: ${t}: ${c}
18
- `,exitCode:1}}if(n)return{stdout:String.fromCharCode(...u),stderr:"",exitCode:0};if(o.name){let i=S(a);i.originalName?p=e.fs.resolvePath(e.cwd,i.originalName):p=f.slice(0,-l.length)}else p=f.slice(0,-l.length);if(!o.force)try{return await e.fs.stat(p),{stdout:"",stderr:`${r}: ${p} already exists; not overwritten
19
- `,exitCode:1}}catch{}if(await e.fs.writeFile(p,u),!o.keep&&!n&&await e.fs.rm(f),o.verbose){let i=a.length>0?((1-a.length/u.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${t}: ${i}% -- replaced with ${p.split("/").pop()}
20
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}else{if(t.endsWith(l))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t} already has ${l} suffix -- unchanged
21
- `,exitCode:1};let u=F(o),i;try{i=w(a,{level:u})}catch(c){let d=c instanceof Error?c.message:"unknown error";return{stdout:"",stderr:`${r}: ${t}: ${d}
22
- `,exitCode:1}}if(n)return{stdout:String.fromCharCode(...i),stderr:"",exitCode:0};if(p=f+l,!o.force)try{return await e.fs.stat(p),{stdout:"",stderr:`${r}: ${p} already exists; not overwritten
23
- `,exitCode:1}}catch{}if(await e.fs.writeFile(p,i),!o.keep&&!n&&await e.fs.rm(f),o.verbose){let c=a.length>0?((1-i.length/a.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${t}: ${c}% -- replaced with ${p.split("/").pop()}
24
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function k(e,t,o,r,s,n){let l=await e.fs.readdir(t),f="",p="",a=0;for(let u of l){let i=e.fs.resolvePath(t,u),c=await e.fs.stat(i);if(c.isDirectory){let d=await k(e,i,o,r,s,n);f+=d.stdout,p+=d.stderr,d.exitCode!==0&&(a=d.exitCode)}else if(c.isFile){let d=o.suffix;if(s&&!u.endsWith(d)||!s&&u.endsWith(d))continue;let y=i.startsWith(`${e.cwd}/`)?i.slice(e.cwd.length+1):i,h=await E(e,y,o,r,s,n);f+=h.stdout,p+=h.stderr,h.exitCode!==0&&(a=h.exitCode)}}return{stdout:f,stderr:p,exitCode:a}}async function O(e,t,o,r){let s;if(t==="-"||t==="")s=Uint8Array.from(e.stdin,i=>i.charCodeAt(0));else{let i=e.fs.resolvePath(e.cwd,t);try{s=await e.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
25
- `,exitCode:1}}}if(!m(s))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
26
- `,exitCode:1};let n=s.length,l=D(s),f=l>0?((1-n/l)*100).toFixed(1):"0.0",a=S(s).originalName||(t==="-"?"":t.replace(/\.gz$/,""));return{stdout:`${n.toString().padStart(10)} ${l.toString().padStart(10)} ${f.padStart(5)}% ${a}
27
- `,stderr:"",exitCode:0}}async function U(e,t,o,r){let s;if(t==="-"||t==="")s=Uint8Array.from(e.stdin,n=>n.charCodeAt(0));else{let n=e.fs.resolvePath(e.cwd,t);try{s=await e.fs.readFileBuffer(n)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
28
- `,exitCode:1}}}if(!m(s))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
29
- `,exitCode:1};try{return b(s),o.verbose?{stdout:"",stderr:`${t}: OK
30
- `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(n){let l=n instanceof Error?n.message:"invalid";return{stdout:"",stderr:`${r}: ${t}: ${l}
31
- `,exitCode:1}}}async function x(e,t,o){let r=o==="zcat"?P:o==="gunzip"?I:q;if(z(e))return v(r);let s=$(o,e,L);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let n=s.result.flags,l=s.result.positional,f=o==="gunzip"||o==="zcat"||n.decompress||n.uncompress,p=o==="zcat"||n.stdout||n.toStdout;if(n.list){l.length===0&&(l=["-"]);let c=` compressed uncompressed ratio uncompressed_name
32
- `,d="",y=0;for(let h of l){let g=await O(t,h,n,o);c+=g.stdout,d+=g.stderr,g.exitCode!==0&&(y=g.exitCode)}return{stdout:c,stderr:d,exitCode:y}}if(n.test){l.length===0&&(l=["-"]);let c="",d="",y=0;for(let h of l){let g=await U(t,h,n,o);c+=g.stdout,d+=g.stderr,g.exitCode!==0&&(y=g.exitCode)}return{stdout:c,stderr:d,exitCode:y}}l.length===0&&(l=["-"]);let a="",u="",i=0;for(let c of l){let d=await E(t,c,n,o,f,p);a+=d.stdout,u+=d.stderr,d.exitCode!==0&&(i=d.exitCode)}return{stdout:a,stderr:u,exitCode:i}}var _={name:"gzip",async execute(e,t){return x(e,t,"gzip")}},H={name:"gunzip",async execute(e,t){return x(e,t,"gunzip")}},B={name:"zcat",async execute(e,t){return x(e,t,"zcat")}},G={name:"gzip",flags:[{flag:"-c",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-k",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-1",type:"boolean"},{flag:"-9",type:"boolean"}],stdinType:"binary",needsFiles:!0},Z={name:"gunzip",flags:[{flag:"-c",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-k",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"binary",needsFiles:!0},M={name:"zcat",flags:[{flag:"-f",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"binary",needsFiles:!0};export{_ as a,H as b,B as c,G as d,Z as e,M as f};
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
- import{b as p}from"./chunk-KTFEQPO7.js";import{a as j,b as h}from"./chunk-WIWKAGK6.js";import{a as S,b as q}from"./chunk-GTNBSMZR.js";import{existsSync as g}from"node:fs";import{dirname as H,join as w}from"node:path";import{fileURLToPath as W}from"node:url";import{Worker as J}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(`
3
- `)}
4
- `:""}function x(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
5
- `)?`"${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(`,
6
- `)}]
7
- `}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(`
8
- `)}
9
- `}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(`
10
- `)}
11
- `:""}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(`
12
- `)}
13
- `}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(`
14
- `)}
15
- `:""}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(`
16
- `)}
17
- `}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(`
18
- `)}
19
- `:""}function E(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}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:`
20
- `,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
21
- `,exitCode:1};r.separator=e[++s]}else if(o==="-newline"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -newline
22
- `,exitCode:1};r.newline=e[++s]}else if(o==="-nullvalue"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -nullvalue
23
- `,exitCode:1};r.nullValue=e[++s]}else if(o==="-cmd"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -cmd
24
- `,exitCode:1};r.cmd=e[++s]}else{if(o.startsWith("-"))return{stdout:"",stderr:`sqlite3: Error: unknown option: ${o.startsWith("--")?o.slice(1):o}
25
- Use -help for a list of options.
26
- `,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(W(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.")}var Z={createWorker(e,r){return new J(e,{workerData:r})}};async function v(e,r){try{let n=K();return await new Promise((t,l)=>{let i=p.runTrusted(()=>Z.createWorker(n,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 fe={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()}
27
- `,stderr:"",exitCode:0};if(!l)return{stdout:"",stderr:`sqlite3: missing database argument
28
- `,exitCode:1};let o=i||r.stdin.trim();if(t.cmd&&(o=t.cmd+(o?`; ${o}`:"")),!o)return{stdout:"",stderr:`sqlite3: no SQL provided
29
- `,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}
30
- `,exitCode:1}}let C=r.limits?.maxSqliteTimeoutMs??z,k={dbBuffer:b,sql:o,options:{bail:t.bail,echo:t.echo}},d;try{d=await v(k,C)}catch(a){return{stdout:"",stderr:`sqlite3: worker error: ${a.message}
31
- `,exitCode:1}}if(!d.success)return{stdout:"",stderr:`sqlite3: ${d.error}
32
- `,exitCode:1};let L={mode:t.mode,header:t.header,separator:t.separator,newline:t.newline,nullValue:t.nullValue},c="";t.echo&&(c+=`${o}
33
- `);let $=!1;for(let a of d.results)if(a.type==="error"){if(t.bail)return{stdout:c,stderr:`Error: ${a.error}
34
- `,exitCode:1};c+=`Error: ${a.error}
35
- `,$=!0}else a.columns&&a.rows&&(a.rows.length>0||t.header)&&(c+=T(a.columns,a.rows,L));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}
36
- `,exitCode:1}}return{stdout:c,stderr:"",exitCode:$&&t.bail?1:0}}},de={name:"sqlite3",flags:[],needsArgs:!0};export{Z as a,fe as b,de as c};
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as d}from"./chunk-5WFYIUU2.js";import{a as p}from"./chunk-JBABAK44.js";import{a as c,b as m}from"./chunk-GTNBSMZR.js";var f={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},b={number:{short:"n",long:"number",type:"boolean"}},N={name:"cat",async execute(t,o){if(m(t))return c(f);let e=p("cat",t,b);if(!e.ok)return e.error;let r=e.result.flags.number,a=e.result.positional,s=await d(o,a,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),n="",l=1;for(let{content:i}of s.files)if(r){let u=g(i,l);n+=u.content,l=u.nextLineNumber}else n+=i;return{stdout:n,stderr:s.stderr,exitCode:s.exitCode}}};function g(t,o){let e=t.split(`
3
- `),r=t.endsWith(`
4
- `),a=r?e.slice(0,-1):e;return{content:a.map((n,l)=>`${String(o+l).padStart(6," ")} ${n}`).join(`
5
- `)+(r?`
6
- `:""),nextLineNumber:o+a.length}}var F={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0};export{N as a,F as b};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as h}from"./chunk-KGOUQS5A.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 _=`
3
-
4
- 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,63 +0,0 @@
1
- #!/usr/bin/env node
2
- import{b as K}from"./chunk-KTFEQPO7.js";import{a as x}from"./chunk-SE4C7FJY.js";import{a as ie,b as se,c as P}from"./chunk-GTNBSMZR.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}
3
- `,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'
4
- `,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'
5
- `,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'
6
- `,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'
7
- `,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'
8
- `,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'
9
- `,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}'
10
- `,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
11
- `,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'
12
- `,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'
13
- `,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
14
- `,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?"/":""}
15
- `}if(i.length===0&&s.length>0)return{stdout:"",stderr:`${s.join(`
16
- `)}
17
- `,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"}
18
- `,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}
19
- `,exitCode:2}}}else c=String.fromCharCode(...a);let l=o;return s.length>0&&(l+=`${s.join(`
20
- `)}
21
- `),{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
22
- `,exitCode:2};if(n.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to append nothing to archive
23
- `,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
24
- `,exitCode:2}}let s=await _(i);if(s.error)return{stdout:"",stderr:`tar: ${s.error}
25
- `,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?"/":""}
26
- `}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"}
27
- `,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}
28
- `,exitCode:2}}let p=d;return l.length>0&&(p+=`${l.join(`
29
- `)}
30
- `),{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
31
- `,exitCode:2};if(n.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to update with nothing
32
- `,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
33
- `,exitCode:2}}let s=await _(i);if(s.error)return{stdout:"",stderr:`tar: ${s.error}
34
- `,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?"/":""}
35
- `))}}if(c.length===0){let m="";return l.length>0&&(m=`${l.join(`
36
- `)}
37
- `),{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"}
38
- `,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}
39
- `,exitCode:2}}let h=d;return l.length>0&&(h+=`${l.join(`
40
- `)}
41
- `),{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
42
- `,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}
43
- `,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}
44
- `)}else if(f.type==="file"){if(t.toStdout){u+=new TextDecoder().decode(f.content),t.verbose&&(d+=`${h}
45
- `);continue}if(t.keepOldFiles)try{await e.fs.stat(S),t.verbose&&(d+=`${h}: not overwritten, file exists
46
- `);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}
47
- `)}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
48
- `);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}
49
- `)}}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(`
50
- `)}
51
- `),{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
52
- `,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}
53
- `,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}
54
- `}else l+=`${u}
55
- `}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
56
- `,exitCode:2};if(s>1)return{stdout:"",stderr:`tar: You may not specify more than one of -c, -r, -u, -x, or -t
57
- `,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
58
- `,exitCode:2};if((r.append||r.update)&&o>0)return{stdout:"",stderr:`tar: Cannot append/update compressed archives - decompress first
59
- `,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(`
60
- `).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
61
- `,exitCode:2}}}if(r.excludeFrom){let c=t.fs.resolvePath(t.cwd,r.excludeFrom);try{let d=(await t.fs.readFile(c)).split(`
62
- `).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
63
- `,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,2 +0,0 @@
1
- #!/usr/bin/env node
2
- 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,16 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as D}from"./chunk-4QM2TCNV.js";import{b as P}from"./chunk-KTFEQPO7.js";import{a as _,b as O,c as I,d as h}from"./chunk-WIWKAGK6.js";import{a as L}from"./chunk-4PRVMER6.js";import{a as U,b as x}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.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+=`
3
- python3: execution timeout exceeded
4
- `,this.output.exitCode=124;break}let o=t-s;if(!await this.protocol.waitUntilReady(o)){this.output.stderr+=`
5
- python3: execution timeout exceeded
6
- `,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'
7
- `,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'
8
- `,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}'
9
- `,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}
10
- `,exitCode:1})),V.catch(R=>({success:!1,error:R.message}))]);return!A.success&&A.error?{stdout:m.stdout,stderr:`${m.stderr}python3: ${A.error}
11
- `,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)
12
- `,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)}'
13
- `,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
14
- `,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}
15
- `,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)
16
- `,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,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a,b,c}from"./chunk-H7Y3TH22.js";import"./chunk-KTFEQPO7.js";import"./chunk-WIWKAGK6.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{a as _internals,c as flagsForFuzzing,b as sqlite3Command};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a,b}from"./chunk-C7TH4MVZ.js";import"./chunk-4OALHZXB.js";import"./chunk-4PRVMER6.js";import"./chunk-KGOUQS5A.js";export{b as flagsForFuzzing,a as timeCommand};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a,b}from"./chunk-JWVOLGWZ.js";import"./chunk-4OALHZXB.js";import"./chunk-WIWKAGK6.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{b as flagsForFuzzing,a as timeoutCommand};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- 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,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as u}from"./chunk-4OALHZXB.js";import{a as c}from"./chunk-4PRVMER6.js";var b={name:"time",async execute(i,r){let a="%e %M",n=null,m=!1,f=!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'
3
- `,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'
4
- `,exitCode:1};n=i[t],t++}else if(e==="-a"||e==="--append")m=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
5
- Elapsed (wall clock) time: %e seconds
6
- Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")f=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let l=i.slice(t);if(l.length===0)return{stdout:"",stderr:"",exitCode:0};let p=performance.now(),g=u(l),h=l.join(" "),s;try{if(!r.exec)return{stdout:"",stderr:`time: exec not available
7
- `,exitCode:1};s=await r.exec(g,{env:c(r.env),cwd:r.cwd,stdin:r.stdin,signal:r.signal})}catch(e){s={stdout:"",stderr:`time: ${e.message}
8
- `,exitCode:127}}let d=(performance.now()-p)/1e3,o;if(f?o=`real ${d.toFixed(2)}
9
- user 0.00
10
- sys 0.00
11
- `:(o=a.replace(/%e/g,d.toFixed(2)).replace(/%E/g,C(d)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,h),o.endsWith(`
12
- `)||(o+=`
13
- `)),n)try{let e=r.fs.resolvePath(r.cwd,n);if(m&&await r.fs.exists(e)){let w=await r.fs.readFile(e);await r.fs.writeFile(e,w+o)}else await r.fs.writeFile(e,o)}catch(e){return{stdout:s.stdout,stderr:s.stderr+`time: cannot write to '${n}': ${e.message}
14
- `,exitCode:s.exitCode}}else s={...s,stderr:s.stderr+o};return s}};function C(i){let r=Math.floor(i/3600),a=Math.floor(i%3600/60),n=i%60;return r>0?`${r}:${a.toString().padStart(2,"0")}:${n.toFixed(2).padStart(5,"0")}`:`${a}:${n.toFixed(2).padStart(5,"0")}`}var y={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{b as a,y as b};