just-bash 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +47 -0
  3. package/dist/ast/types.d.ts +4 -1
  4. package/dist/bin/chunks/{chunk-QF7PPON7.js → chunk-5SR55TXB.js} +10 -10
  5. package/dist/bin/{shell/chunks/chunk-TL4JI2SL.js → chunks/chunk-6UK23ZFT.js} +17 -18
  6. package/dist/bin/chunks/{chunk-XBB73LFB.js → chunk-CMTQFWZK.js} +2 -2
  7. package/dist/bin/chunks/{chunk-YMELOXDK.js → chunk-D5G3L4PR.js} +8 -8
  8. package/dist/bin/chunks/{chunk-PRKSLEHG.js → chunk-DKIOFM35.js} +1 -1
  9. package/dist/bin/chunks/chunk-IJIJAQBT.js +12 -0
  10. package/dist/bin/{shell/chunks/chunk-NQQ3X7MZ.js → chunks/chunk-KXWWWQZK.js} +1 -1
  11. package/dist/bin/chunks/{chunk-3HUI54BW.js → chunk-TROO33BG.js} +1 -1
  12. package/dist/bin/chunks/chunk-USMDLXMM.js +21 -0
  13. package/dist/bin/{shell/chunks/chunk-JQER3HUP.js → chunks/chunk-XAVWLYZR.js} +1 -1
  14. package/dist/bin/chunks/{echo-4OUEL7QB.js → echo-NYDCCFWB.js} +1 -1
  15. package/dist/bin/chunks/{flag-coverage-WGSE667D.js → flag-coverage-EB3DK32J.js} +1 -1
  16. package/dist/bin/chunks/{grep-CMT2H2S7.js → grep-73YHJEX4.js} +1 -1
  17. package/dist/bin/{shell/chunks/jq-ACCMBTSD.js → chunks/jq-AO5GTPN4.js} +1 -1
  18. package/dist/bin/chunks/js-exec-worker.js +56 -20
  19. package/dist/bin/{shell/chunks/printf-F2KOCULO.js → chunks/printf-CNXNRQ3I.js} +1 -1
  20. package/dist/bin/chunks/python3-N252MJV6.js +14 -0
  21. package/dist/bin/{shell/chunks/rg-JRKJ6I4X.js → chunks/rg-OGGL3RIE.js} +1 -1
  22. package/dist/bin/chunks/{sqlite3-ZXF6BGDW.js → sqlite3-FEUFATVW.js} +1 -1
  23. package/dist/bin/chunks/worker.js +17 -1
  24. package/dist/bin/chunks/{xan-D6US4ZGL.js → xan-Q52EBQYW.js} +1 -1
  25. package/dist/bin/chunks/{yq-EYV7HLKK.js → yq-UA5NX5RT.js} +1 -1
  26. package/dist/bin/just-bash.js +391 -389
  27. package/dist/bin/shell/chunks/{chunk-QF7PPON7.js → chunk-5SR55TXB.js} +10 -10
  28. package/dist/bin/{chunks/chunk-TL4JI2SL.js → shell/chunks/chunk-6UK23ZFT.js} +17 -18
  29. package/dist/bin/shell/chunks/{chunk-XBB73LFB.js → chunk-CMTQFWZK.js} +2 -2
  30. package/dist/bin/shell/chunks/{chunk-YMELOXDK.js → chunk-D5G3L4PR.js} +8 -8
  31. package/dist/bin/shell/chunks/{chunk-PRKSLEHG.js → chunk-DKIOFM35.js} +1 -1
  32. package/dist/bin/shell/chunks/chunk-IJIJAQBT.js +12 -0
  33. package/dist/bin/{chunks/chunk-NQQ3X7MZ.js → shell/chunks/chunk-KXWWWQZK.js} +1 -1
  34. package/dist/bin/shell/chunks/{chunk-3HUI54BW.js → chunk-TROO33BG.js} +1 -1
  35. package/dist/bin/shell/chunks/chunk-USMDLXMM.js +21 -0
  36. package/dist/bin/{chunks/chunk-JQER3HUP.js → shell/chunks/chunk-XAVWLYZR.js} +1 -1
  37. package/dist/bin/shell/chunks/{echo-4OUEL7QB.js → echo-NYDCCFWB.js} +1 -1
  38. package/dist/bin/shell/chunks/{flag-coverage-WGSE667D.js → flag-coverage-EB3DK32J.js} +1 -1
  39. package/dist/bin/shell/chunks/{grep-CMT2H2S7.js → grep-73YHJEX4.js} +1 -1
  40. package/dist/bin/{chunks/jq-ACCMBTSD.js → shell/chunks/jq-AO5GTPN4.js} +1 -1
  41. package/dist/bin/{chunks/printf-F2KOCULO.js → shell/chunks/printf-CNXNRQ3I.js} +1 -1
  42. package/dist/bin/shell/chunks/python3-N252MJV6.js +14 -0
  43. package/dist/bin/{chunks/rg-JRKJ6I4X.js → shell/chunks/rg-OGGL3RIE.js} +1 -1
  44. package/dist/bin/shell/chunks/{sqlite3-ZXF6BGDW.js → sqlite3-FEUFATVW.js} +1 -1
  45. package/dist/bin/shell/chunks/{xan-D6US4ZGL.js → xan-Q52EBQYW.js} +1 -1
  46. package/dist/bin/shell/chunks/{yq-EYV7HLKK.js → yq-UA5NX5RT.js} +1 -1
  47. package/dist/bin/shell/shell.js +396 -394
  48. package/dist/bundle/browser.js +836 -823
  49. package/dist/bundle/chunks/{chunk-RAHPENCM.js → chunk-3ZBJCAAR.js} +1 -1
  50. package/dist/bundle/chunks/{chunk-AMLHAS2N.js → chunk-4AKAIZPW.js} +9 -9
  51. package/dist/bundle/chunks/{chunk-6SHYIICL.js → chunk-AGH5UJJI.js} +2 -2
  52. package/dist/bundle/chunks/{chunk-NOPXHH6G.js → chunk-EZDB7TGH.js} +1 -1
  53. package/dist/bundle/chunks/chunk-FC5NW7U4.js +11 -0
  54. package/dist/bundle/chunks/{chunk-5KGKXQF6.js → chunk-FHFPWM4W.js} +1 -1
  55. package/dist/bundle/chunks/chunk-H3PXMIY3.js +20 -0
  56. package/dist/bundle/chunks/{chunk-EWWPEE2G.js → chunk-IHGFM3FN.js} +17 -18
  57. package/dist/bundle/chunks/{chunk-65Z4QURM.js → chunk-J5G3ZBEK.js} +8 -8
  58. package/dist/bundle/chunks/{chunk-WENIVVEE.js → chunk-LTCWFMCI.js} +1 -1
  59. package/dist/bundle/chunks/{echo-HZOVZAPR.js → echo-PLLZYM2L.js} +1 -1
  60. package/dist/bundle/chunks/{flag-coverage-THYQHOT3.js → flag-coverage-UV7GI2DF.js} +1 -1
  61. package/dist/bundle/chunks/{grep-S6SNTIHZ.js → grep-UDCQDUQK.js} +1 -1
  62. package/dist/bundle/chunks/{jq-D6N4QCAJ.js → jq-B5324QOX.js} +1 -1
  63. package/dist/bundle/chunks/js-exec-worker.js +56 -20
  64. package/dist/bundle/chunks/{printf-QHD2JRWQ.js → printf-V42QCPHL.js} +1 -1
  65. package/dist/bundle/chunks/python3-ETPBGJP3.js +13 -0
  66. package/dist/bundle/chunks/{rg-OUJZ5DH6.js → rg-XCX2J2RF.js} +1 -1
  67. package/dist/bundle/chunks/{sqlite3-WWZJZW37.js → sqlite3-ZTQJIC3G.js} +1 -1
  68. package/dist/bundle/chunks/worker.js +17 -1
  69. package/dist/bundle/chunks/{xan-KKPV2TJ3.js → xan-EGU5VRRP.js} +1 -1
  70. package/dist/bundle/chunks/{yq-ZGB3W46S.js → yq-FMWLA3S2.js} +1 -1
  71. package/dist/bundle/index.cjs +1026 -1014
  72. package/dist/bundle/index.js +391 -389
  73. package/dist/commands/python3/worker.d.ts +1 -0
  74. package/dist/commands/query-engine/evaluator.d.ts +8 -0
  75. package/dist/fs/read-write-fs/read-write-fs.d.ts +42 -1
  76. package/dist/interpreter/builtin-dispatch.d.ts +9 -2
  77. package/dist/interpreter/builtins/eval.d.ts +7 -1
  78. package/dist/interpreter/control-flow.d.ts +1 -1
  79. package/dist/interpreter/fd-table.d.ts +130 -0
  80. package/dist/interpreter/functions.d.ts +3 -1
  81. package/dist/interpreter/helpers/word-matching.d.ts +0 -10
  82. package/dist/interpreter/interpreter.d.ts +7 -0
  83. package/dist/interpreter/numeric-fd-redirects.d.ts +8 -0
  84. package/dist/interpreter/process-substitution.d.ts +62 -0
  85. package/dist/interpreter/redirections.d.ts +33 -37
  86. package/dist/interpreter/subshell-group.d.ts +10 -2
  87. package/dist/interpreter/types.d.ts +38 -1
  88. package/dist/network/dns-pin.d.ts +11 -0
  89. package/dist/parser/expansion-parser.d.ts +3 -1
  90. package/dist/parser/lexer.d.ts +7 -9
  91. package/dist/parser/parser-substitution.d.ts +13 -4
  92. package/dist/parser/parser.d.ts +18 -4
  93. package/dist/parser/types.d.ts +6 -0
  94. package/dist/parser/word-parser.d.ts +2 -0
  95. package/dist/types.d.ts +6 -0
  96. package/package.json +1 -1
  97. package/dist/bin/chunks/chunk-P6NPCASY.js +0 -11
  98. package/dist/bin/chunks/chunk-WYTPLN2M.js +0 -11
  99. package/dist/bin/chunks/python3-AYUQQRCR.js +0 -14
  100. package/dist/bin/shell/chunks/chunk-P6NPCASY.js +0 -11
  101. package/dist/bin/shell/chunks/chunk-WYTPLN2M.js +0 -11
  102. package/dist/bin/shell/chunks/python3-AYUQQRCR.js +0 -14
  103. package/dist/bundle/chunks/chunk-VECGTAPW.js +0 -10
  104. package/dist/bundle/chunks/chunk-YOUUMJLJ.js +0 -10
  105. package/dist/bundle/chunks/python3-QDNG2UXX.js +0 -13
@@ -4,7 +4,7 @@
4
4
  * Contains pure string analysis functions and substitution parsing utilities
5
5
  * extracted from the main parser.
6
6
  */
7
- import { type CommandSubstitutionPart, type ScriptNode } from "../ast/types.js";
7
+ import { type CommandSubstitutionPart, type ProcessSubstitutionPart, type ScriptNode } from "../ast/types.js";
8
8
  /**
9
9
  * Type for a parser factory function that creates new parser instances.
10
10
  * Used to avoid circular dependencies.
@@ -33,9 +33,10 @@ export type ErrorFn = (message: string) => never;
33
33
  export declare function isDollarDparenSubshell(value: string, start: number): boolean;
34
34
  /**
35
35
  * Read a heredoc delimiter starting at `pos` (the first character after the
36
- * `<<` / `<<-` operator and any leading blanks). Returns the *unquoted*
37
- * delimiter — the exact string a terminator line must equal — and the index
38
- * just past the delimiter token.
36
+ * `<<` / `<<-` operator and any leading blanks). Returns the delimiter after
37
+ * outer-word quote removal, plus metadata needed by both the lexer and nested
38
+ * substitution scanner. Syntax inside unexpanded `$(`, `<(`, and `>(` atoms
39
+ * remains literal.
39
40
  *
40
41
  * Quoting only controls whether the body is expanded, which is irrelevant to
41
42
  * finding the substitution boundary, so `'EOF'`, `"EOF"`, and `\EOF` all yield
@@ -44,6 +45,9 @@ export declare function isDollarDparenSubshell(value: string, start: number): bo
44
45
  export declare function readHeredocDelimiter(value: string, pos: number): {
45
46
  delim: string;
46
47
  endPos: number;
48
+ quoted: boolean;
49
+ unclosedQuote: "'" | '"' | undefined;
50
+ unclosedSubstitution: boolean;
47
51
  };
48
52
  /**
49
53
  * Parse a command substitution starting at the given position.
@@ -59,6 +63,11 @@ export declare function parseCommandSubstitutionFromString(value: string, start:
59
63
  part: CommandSubstitutionPart;
60
64
  endIndex: number;
61
65
  };
66
+ /** Parse process substitution syntax found inside a recursively parsed word fragment. */
67
+ export declare function parseProcessSubstitutionFromString(value: string, start: number, createParser: ParserFactory, error: ErrorFn): {
68
+ part: ProcessSubstitutionPart;
69
+ endIndex: number;
70
+ };
62
71
  /**
63
72
  * Parse a backtick command substitution starting at the given position.
64
73
  * Handles `...` syntax with proper escape processing.
@@ -12,9 +12,9 @@
12
12
  * simple_cmd ::= (assignment)* [word] (word)* (redirection)*
13
13
  * compound_cmd ::= if | for | while | until | case | subshell | group | (( | [[
14
14
  */
15
- import { type ArithmeticExpansionPart, type ArithmeticExpressionNode, type CommandSubstitutionPart, type RedirectionNode, type ScriptNode, type StatementNode, type WordNode } from "../ast/types.js";
15
+ import { type ArithmeticExpansionPart, type ArithmeticExpressionNode, type CommandSubstitutionPart, type ProcessSubstitutionPart, type RedirectionNode, type ScriptNode, type StatementNode, type WordNode, type WordPart } from "../ast/types.js";
16
16
  import { type LexerOptions, type Token, TokenType } from "./lexer.js";
17
- import { ParseBudget } from "./types.js";
17
+ import { ParseBudget, WordParseContext } from "./types.js";
18
18
  export type { ParseError } from "./types.js";
19
19
  export { ParseException } from "./types.js";
20
20
  /**
@@ -27,6 +27,7 @@ export declare class Parser {
27
27
  private readonly parseBudget;
28
28
  private readonly ownsParseBudget;
29
29
  private _input;
30
+ private processLineState;
30
31
  constructor(parseBudget?: ParseBudget);
31
32
  /**
32
33
  * Get the raw input string being parsed.
@@ -55,6 +56,7 @@ export declare class Parser {
55
56
  peek(offset?: number): Token;
56
57
  advance(): Token;
57
58
  getPos(): number;
59
+ getSourceLine(token?: Token): number;
58
60
  /**
59
61
  * Check if current token matches any of the given types.
60
62
  * Optimized to avoid array allocation for common cases (1-4 args).
@@ -76,6 +78,7 @@ export declare class Parser {
76
78
  */
77
79
  private checkUnexpectedToken;
78
80
  parseStatement(): StatementNode | null;
81
+ private parseTimePrefix;
79
82
  private parsePipeline;
80
83
  private parseCommand;
81
84
  /**
@@ -91,7 +94,12 @@ export declare class Parser {
91
94
  */
92
95
  private parseNestedSubshellsFromDparen;
93
96
  isWord(): boolean;
94
- parseWord(): WordNode;
97
+ private isWordToken;
98
+ isProcessSubstitutionStart(offset?: number): boolean;
99
+ private currentTokenJoinsProcessSubstitution;
100
+ private isAdjacentWordToken;
101
+ parseWord(context?: WordParseContext): WordNode;
102
+ parseAdjacentWordParts(parts: WordPart[], previousEnd: number, context?: WordParseContext): WordNode;
95
103
  /**
96
104
  * Parse a word without brace expansion (for [[ ]] conditionals).
97
105
  * In bash, brace expansion does not occur inside [[ ]].
@@ -104,11 +112,17 @@ export declare class Parser {
104
112
  * in the final regex pattern.
105
113
  */
106
114
  parseWordForRegex(): WordNode;
107
- parseWordFromString(value: string, quoted?: boolean, singleQuoted?: boolean, isAssignment?: boolean, hereDoc?: boolean, noBraceExpansion?: boolean, regexPattern?: boolean): WordNode;
115
+ private parseWordToken;
116
+ parseWordFromString(value: string, quoted?: boolean, singleQuoted?: boolean, isAssignment?: boolean, hereDoc?: boolean, noBraceExpansion?: boolean, regexPattern?: boolean, atWordStart?: boolean): WordNode;
108
117
  parseCommandSubstitution(value: string, start: number): {
109
118
  part: CommandSubstitutionPart;
110
119
  endIndex: number;
111
120
  };
121
+ parseProcessSubstitutionFromString(value: string, start: number): {
122
+ part: ProcessSubstitutionPart;
123
+ endIndex: number;
124
+ };
125
+ private parseProcessSubstitution;
112
126
  parseBacktickSubstitution(value: string, start: number,
113
127
  /** Whether the backtick is inside double quotes */
114
128
  inDoubleQuotes?: boolean): {
@@ -7,6 +7,12 @@ import { type Token, TokenType } from "./lexer.js";
7
7
  export declare const MAX_INPUT_SIZE = 1000000;
8
8
  export declare const MAX_TOKENS = 100000;
9
9
  export declare const MAX_PARSER_DEPTH = 200;
10
+ export declare enum WordParseContext {
11
+ Default = 0,
12
+ Assignment = 1,
13
+ NoBraceExpansion = 2,
14
+ Regex = 4
15
+ }
10
16
  export declare const REDIRECTION_TOKENS: Set<TokenType>;
11
17
  export declare const REDIRECTION_AFTER_NUMBER: Set<TokenType>;
12
18
  export declare const REDIRECTION_AFTER_FD_VARIABLE: Set<TokenType>;
@@ -7,6 +7,8 @@
7
7
  import { type ArithmeticExpressionNode, type RedirectionOperator, type WordNode, type WordPart } from "../ast/types.js";
8
8
  import { TokenType } from "./lexer.js";
9
9
  import type { Parser } from "./parser.js";
10
+ /** Lexer-level escapes in unquoted arithmetic subscripts need quote removal. */
11
+ export declare const quoteRemoveEscapes: (value: string) => string;
10
12
  export declare function findTildeEnd(_p: Parser, value: string, start: number): number;
11
13
  export declare function findMatchingBracket(_p: Parser, value: string, start: number, open: string, close: string): number;
12
14
  export declare function findParameterOperationEnd(_p: Parser, value: string, start: number): number;
package/dist/types.d.ts CHANGED
@@ -40,6 +40,12 @@ export interface ExecResult {
40
40
  stdoutEncoding?: "binary";
41
41
  /** @internal PIPESTATUS override used by synthesized transform builtins. */
42
42
  internalPipeStatusOverride?: number[];
43
+ /** @internal Leaf command that produced output through wrapper builtins. */
44
+ internalProducerCommand?: string;
45
+ /** @internal Whether `exec` gives the producer external diagnostic formatting. */
46
+ internalProducerOmitsShellPrefix?: boolean;
47
+ /** @internal Bytes consumed from a descriptor-backed stdin stream. */
48
+ internalStdinConsumed?: number;
43
49
  /**
44
50
  * Bytes in the current result that have already been charged to the shared
45
51
  * execution output budget. Interpreter plumbing must preserve this when it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-bash",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "A simulated bash environment with virtual filesystem",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as P,b as j,c as U,d as W}from"./chunk-YMELOXDK.js";import{d as D}from"./chunk-WDV2ECOC.js";import{a as A,b as H}from"./chunk-4SQKKW2M.js";import{b as _}from"./chunk-O74FSWB4.js";import{a as F}from"./chunk-46CDVHZ3.js";import{l as y}from"./chunk-LCP3IKI7.js";import{a as M,b as z}from"./chunk-CPKBPQ2C.js";import{a as J}from"./chunk-PBOVSFTJ.js";import{a as R,b as V,c as I}from"./chunk-MUFNRCMY.js";function G(n){switch(n){case"\b":return"\\b";case"\f":return"\\f";case`
4
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${n.charCodeAt(0).toString(16).padStart(4,"0")}`}}function Y(n){let s="",d=!1,f=!1;for(let t=0;t<n.length;t++){let l=n[t];if(f){s+=l,f=!1;continue}if(l==="\\"){s+=l,f=!0;continue}if(l==='"'){s+=l,d=!d;continue}if(d&&l.charCodeAt(0)<=31){s+=G(l);continue}s+=l}return s}function L(n,s,d){return JSON.parse(Y(n.slice(s,d)))}function K(n,s){let d=[],f=g=>{if(d.length>=s.maxElements)throw new y(`query result element limit exceeded (${s.maxElements})`,"array_elements");d.push(g)},t=0,l=n.length;for(;t<l;){for(;t<l&&/\s/.test(n[t]);)t++;if(t>=l)break;let g=t,c=n[t];if(c==="{"||c==="["){let a=[c==="{"?"}":"]"],p=!1,w=!1;for(t++;t<l&&a.length>0;){let h=n[t];if(w)w=!1;else if(h==="\\")w=!0;else if(h==='"')p=!p;else if(!p){if(h==="{"||h==="["){if(a.push(h==="{"?"}":"]"),a.length>s.maxDepth)throw new y(`query depth limit exceeded (${s.maxDepth})`,"recursion")}else if((h==="}"||h==="]")&&a.pop()!==h)throw new Error(`Mismatched JSON delimiter at position ${t}`)}t++}if(a.length!==0)throw new Error(`Unexpected end of JSON input at position ${t} (unclosed ${c})`);f(D(L(n,g,t),{maxDepth:s.maxDepth,maxElements:s.maxElements}))}else if(c==='"'){let a=!1;for(t++;t<l;){let p=n[t];if(a)a=!1;else if(p==="\\")a=!0;else if(p==='"'){t++;break}t++}f(D(L(n,g,t),s))}else if(c==="-"||c>="0"&&c<="9"){for(;t<l&&/[\d.eE+-]/.test(n[t]);)t++;f(D(L(n,g,t),s))}else if(n.slice(t,t+4)==="true")f(!0),t+=4;else if(n.slice(t,t+5)==="false")f(!1),t+=5;else if(n.slice(t,t+4)==="null")f(null),t+=4;else{let a=n.slice(t,t+10);throw new Error(`Invalid JSON at position ${g}: unexpected '${a.split(/\s/)[0]}'`)}}return d}var Z={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE...]",options:["-R, --raw-input read each line as string instead of JSON","-r, --raw-output output strings without quotes","-c, --compact-output compact instead of pretty-printed output","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]},pe={name:"jq",async execute(n,s){A(s.requireDefenseContext,"jq","execution entry");let d=(r,e)=>H(s.requireDefenseContext,"jq",r,e);if(V(n))return R(Z);let f=!1,t=!1,l=!1,g=!1,c=!1,a=!1,p=!1,w=!1,h=!1,Q=".",T=!1,E=[];for(let r=0;r<n.length;r++){let e=n[r];if(e==="-R"||e==="--raw-input")t=!0;else if(e==="-r"||e==="--raw-output")f=!0;else if(e==="-c"||e==="--compact-output")l=!0;else if(e==="-e"||e==="--exit-status")g=!0;else if(e==="-s"||e==="--slurp")c=!0;else if(e==="-n"||e==="--null-input")a=!0;else if(e==="-j"||e==="--join-output")p=!0;else if(!(e==="-a"||e==="--ascii")){if(e==="-S"||e==="--sort-keys")w=!0;else if(!(e==="-C"||e==="--color")){if(!(e==="-M"||e==="--monochrome"))if(e==="--tab")h=!0;else if(e==="-")E.push("-");else{if(e.startsWith("--"))return I("jq",e);if(e.startsWith("-")){for(let i of e.slice(1))if(i==="R")t=!0;else if(i==="r")f=!0;else if(i==="c")l=!0;else if(i==="e")g=!0;else if(i==="s")c=!0;else if(i==="n")a=!0;else if(i==="j")p=!0;else if(i!=="a"){if(i==="S")w=!0;else if(i!=="C"){if(i!=="M")return I("jq",`-${i}`)}}}else T?E.push(e):(Q=e,T=!0)}}}}let C=[];if(!a)if(E.length===0||E.length===1&&E[0]==="-")C.push({source:"stdin",content:z(s.stdin)});else{let r=await d("file read",()=>_(s,E,{cmdName:"jq",stopOnError:!0}));if(r.exitCode!==0)return{stdout:"",stderr:r.stderr,exitCode:2};C=r.files.map(e=>({source:e.filename||"stdin",content:z(e.content)}))}try{let r=U(Q,{maxDepth:s.limits.maxQueryDepth,maxTokens:s.limits.maxQueryTokens,maxSourceLength:s.limits.maxStringLength}),e=[],i={limits:s.limits?{maxIterations:s.limits.maxJqIterations,maxStringLength:s.limits.maxStringLength,maxOutputSize:s.limits.maxOutputSize,maxArrayElements:s.limits.maxQueryElements,maxDepth:s.limits.maxQueryDepth}:void 0,env:s.env,coverage:s.coverage,requireDefenseContext:s.requireDefenseContext,budget:{operations:0,callDepth:0}},v={maxDepth:s.limits.maxQueryDepth,maxElements:s.limits.maxQueryElements},b=(o,u)=>{if(u.length>s.limits.maxQueryElements-o.length)throw new y(`query result element limit exceeded (${s.limits.maxQueryElements})`,"array_elements");for(let m of u)o.push(m)};if(a)e=j(null,r,i);else if(t&&c){let o=C.map(({content:u})=>u).join("");e=j(o,r,i)}else if(t){let o="";for(let{content:u}of C){let m=o+u,x=0,S=m.indexOf(`
5
- `,x);for(;S!==-1;)b(e,j(m.slice(x,S),r,i)),x=S+1,S=m.indexOf(`
6
- `,x);o=m.slice(x)}o!==""&&b(e,j(o,r,i))}else if(c){let o=[];for(let{content:u}of C){let m=u.trim();m&&b(o,K(m,v))}e=j(o,r,i)}else for(let{content:o}of C){let u=o.trim();if(!u)continue;let m=K(u,v);for(let x of m)b(e,j(x,r,i))}let N=p?"":`
7
- `,q=Math.min(s.limits.maxStringLength,s.limits.maxOutputSize),O=[],$=0;for(let o of e){let u=O.length>0?N.length:0,m=p?0:1,x=q-$-u-m;if(x<0)throw new y(`output size limit exceeded (${q} bytes)`,"string_length");if(P(o,s.limits.maxQueryDepth+1)>s.limits.maxQueryDepth)throw new y(`query depth limit exceeded (${s.limits.maxQueryDepth})`,"recursion");let S=W(o,x,{compact:l,raw:f,sortKeys:w,useTab:h,limitKind:"string_length"}),B=M(S);if($+u+B+m>q)throw new y(`output size limit exceeded (${q} bytes)`,"string_length");$+=u+B,O.push(S)}let k=O.join(N),X=g&&(e.length===0||e.every(o=>o==null||o===!1))?1:0;return{stdout:k?p?k:`${k}
8
- `:"",stderr:"",exitCode:X}}catch(r){if(r instanceof F)throw r;if(r instanceof y)return{stdout:"",stderr:`jq: ${J(r.message)}
9
- `,exitCode:y.EXIT_CODE};let e=J(r.message);return e.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${e}
10
- `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${e}
11
- `,exitCode:5}}}},de={name:"jq",flags:[{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-j",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"--tab",type:"boolean"}],stdinType:"json",needsArgs:!0};export{pe as a,de as b};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as v}from"./chunk-X5VUGFUL.js";import{a as K,b as le}from"./chunk-JQER3HUP.js";import{a as G}from"./chunk-BNYIXXC2.js";import{l as U}from"./chunk-LCP3IKI7.js";import{b as ie}from"./chunk-CPKBPQ2C.js";import{a as re,c as J}from"./chunk-MUFNRCMY.js";function oe(s){let t=s.limits.maxLoopIterations,r=s.limits.maxArrayElements;return Math.max(t,Math.min(r,t*10))}function x(s){if(++s.operations>s.maxOperations)throw new U(`grep: glob operation limit exceeded (${s.maxOperations})`,"glob_operations")}function H(s){if(s.results>=s.maxResults)throw new U(`grep: array element limit exceeded (${s.maxResults})`,"array_elements");s.results++}var me={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},ae={name:"grep",async execute(s,t){let r=!1,h=!1,a=!1,m=!1,u=!1,f=!1,o=!1,l=!1,c=!1,w=!1,R=!1,d=!1,g=!1,$=!1,Q=!1,O=0,E=0,M=0,L=[],B=[],_=[],A=null,b=[],k=!0;for(let i=0;i<s.length;i++){let n=s[i];if(k&&n==="--"){k=!1;continue}if(k&&n==="--help")return re(me);if(k&&n.startsWith("-")&&n!=="-"){if(n==="-e"&&i+1<s.length){A=s[++i];continue}if(n.startsWith("--include=")){L.push(n.slice(10));continue}if(n.startsWith("--exclude=")){B.push(n.slice(10));continue}if(n.startsWith("--exclude-dir=")){_.push(n.slice(14));continue}if(n.startsWith("--max-count=")){O=parseInt(n.slice(12),10);continue}let P=n.match(/^-m(\d+)$/);if(P){O=parseInt(P[1],10);continue}if(n==="-m"&&i+1<s.length){O=parseInt(s[++i],10);continue}let p=n.match(/^-([ABC])(\d+)$/);if(p){let e=parseInt(p[2],10);p[1]==="A"?M=e:p[1]==="B"?E=e:p[1]==="C"&&(E=e,M=e);continue}if((n==="-A"||n==="-B"||n==="-C")&&i+1<s.length){let e=parseInt(s[++i],10);n==="-A"?M=e:n==="-B"?E=e:(E=e,M=e);continue}let y=n.startsWith("--")?[n]:n.slice(1).split("");for(let e of y)if(e==="i"||e==="--ignore-case")r=!0;else if(e==="n"||e==="--line-number")h=!0;else if(e==="v"||e==="--invert-match")a=!0;else if(e==="c"||e==="--count")m=!0;else if(e==="l"||e==="--files-with-matches")u=!0;else if(e==="L"||e==="--files-without-match")f=!0;else if(e==="r"||e==="R"||e==="--recursive")o=!0;else if(e==="w"||e==="--word-regexp")l=!0;else if(e==="x"||e==="--line-regexp")c=!0;else if(e==="E"||e==="--extended-regexp")w=!0;else if(e==="P"||e==="--perl-regexp")R=!0;else if(e==="F"||e==="--fixed-strings")d=!0;else if(e==="o"||e==="--only-matching")g=!0;else if(e==="h"||e==="--no-filename")$=!0;else if(e==="q"||e==="--quiet"||e==="--silent")Q=!0;else{if(e.startsWith("--"))return J("grep",e);if(e.length===1)return J("grep",`-${e}`)}}else A===null?A=n:b.push(n)}if(A===null)return{stdout:"",stderr:`grep: missing pattern
4
- `,exitCode:2};let ce=d?"fixed":w?"extended":R?"perl":"basic",q,z,W;try{let i=le(A,{mode:ce,ignoreCase:r,wholeWord:l,lineRegexp:c});q=i.regex,z=i.kResetGroup,W=i.preFilter}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${A}
5
- `,exitCode:2}}if(b.length===0&&t.stdin!==void 0){let i=K(ie(t.stdin),q,{invertMatch:a,showLineNumbers:h,countOnly:m,filename:"",onlyMatching:g,beforeContext:E,afterContext:M,maxCount:O,kResetGroup:z,preFilter:W,maxWork:oe(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return Q?{stdout:"",stderr:"",exitCode:i.matched?0:1}:{stdout:i.output,stderr:"",exitCode:i.matched?0:1}}if(b.length===0)return{stdout:"",stderr:`grep: no input files
6
- `,exitCode:2};let N="",V="",Y=!1,ee=!1,T=[],C={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},D=i=>{if(i.length>C.maxResults-T.length)throw new U(`grep: array element limit exceeded (${C.maxResults})`,"array_elements");T.push(...i)};for(let i of b)if(i.includes("*")||i.includes("?")||i.includes("[")){let n=await he(i,t,C);if(o)for(let P of n){let p=await S(P.path,t,L,B,_,P.isFile,C);D(p)}else D(n)}else if(o){let n=await S(i,t,L,B,_,void 0,C);D(n)}else{if(T.length>=C.maxResults)throw new U(`grep: array element limit exceeded (${C.maxResults})`,"array_elements");T.push({path:i})}let te=(T.length>1||o)&&!$,se=50;for(let i=0;i<T.length;i+=se){let n=T.slice(i,i+se),P=await Promise.all(n.map(async p=>{let y=p.path,e=y.split("/").pop()||y;if(B.length>0&&!o&&B.some(F=>v(e,F,{stripQuotes:!0}))||L.length>0&&!o&&!L.some(F=>v(e,F,{stripQuotes:!0})))return null;try{let F=t.fs.resolvePath(t.cwd,y),X=!1;if(p.isFile===void 0?X=(await t.fs.stat(F)).isDirectory:X=!p.isFile,X)return o?null:{error:`grep: ${y}: Is a directory
7
- `};let Z=await t.fs.readFile(F);if(W&&!a){let ne=W.ignoreCase?Z.toLowerCase():Z;if(!W.needles.some(j=>ne.includes(j))){if(m){let j=te?`${y}:0`:"0";return{file:y,result:{output:`${j}
8
- `,matched:!1,matchCount:0}}}return{file:y,result:{output:"",matched:!1,matchCount:0}}}}let pe=K(Z,q,{invertMatch:a,showLineNumbers:h,countOnly:m,filename:te?y:"",onlyMatching:g,beforeContext:E,afterContext:M,maxCount:O,kResetGroup:z,preFilter:W,maxWork:oe(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return{file:y,result:pe}}catch(F){return G(F),{error:`grep: ${y}: No such file or directory
9
- `}}}));for(let p of P){if(p===null)continue;if("error"in p&&p.error){V+=p.error,p.error.includes("Is a directory")||(ee=!0);continue}if(!("file"in p)||!p.result)continue;let{file:y,result:e}=p;if(e.matched){if(Y=!0,Q)return{stdout:"",stderr:"",exitCode:0};u?N+=`${y}
10
- `:f||(N+=e.output)}else f?N+=`${y}
11
- `:m&&!u&&(N+=e.output)}}let I;return ee?I=2:f?I=N.length>0?0:1:I=Y?0:1,Q?{stdout:"",stderr:"",exitCode:I}:{stdout:N,stderr:V,exitCode:I}}},fe=256;async function ue(s,t,r,h,a,m=0){if(m>=fe)return;let u=r.fs.resolvePath(r.cwd,s);try{if(x(a),!(await r.fs.stat(u)).isDirectory){let l=s.split("/").pop()||"";if(t){let c=t.replace(/^\//,"");v(l,c,{stripQuotes:!0})&&(H(a),h.push(s))}return}x(a);let o=await r.fs.readdir(u);for(let l of o){let c=s==="."?l:`${s}/${l}`,w=r.fs.resolvePath(r.cwd,c);if(x(a),(await r.fs.stat(w)).isDirectory)await ue(c,t,r,h,a,m+1);else if(t){let d=t.replace(/^\//,"");v(l,d,{stripQuotes:!0})&&(H(a),h.push(c))}}}catch(f){G(f)}}async function he(s,t,r){let h=[],a=s.lastIndexOf("/"),m,u;if(a===-1?(m=t.cwd,u=s):(m=s.slice(0,a)||"/",u=s.slice(a+1)),s.includes("**")){let o=[],l=s.split("**"),c=l[0].replace(/\/$/,"")||".",w=l[1]||"";return await ue(c,w,t,o,r),o.map(R=>({path:R}))}let f=t.fs.resolvePath(t.cwd,m);try{if(t.fs.readdirWithFileTypes){x(r);let o=await t.fs.readdirWithFileTypes(f);for(let l of o)if(x(r),v(l.name,u,{stripQuotes:!0})){let c=a===-1?l.name:`${m}/${l.name}`;H(r),h.push({path:c,isFile:l.isFile})}}else{x(r);let o=await t.fs.readdir(f);for(let l of o)if(x(r),v(l,u,{stripQuotes:!0})){let c=a===-1?l:`${m}/${l}`;H(r),h.push({path:c})}}}catch(o){G(o)}return h.sort((o,l)=>o.path.localeCompare(l.path))}async function S(s,t,r=[],h=[],a=[],m,u={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},f=[],o=0){if(o>=fe)return f;let l=t.fs.resolvePath(t.cwd,s);try{let c,w;if(m!==void 0)c=m,w=!m;else{x(u);let d=await t.fs.stat(l);c=d.isFile,w=d.isDirectory}if(c){let d=s.split("/").pop()||s;return h.length>0&&h.some(g=>v(d,g,{stripQuotes:!0}))||r.length>0&&!r.some(g=>v(d,g,{stripQuotes:!0}))||(H(u),f.push({path:s,isFile:!0})),f}if(!w)return f;let R=s.split("/").pop()||s;if(a.length>0&&a.some(d=>v(R,d,{stripQuotes:!0})))return f;if(t.fs.readdirWithFileTypes){x(u);let d=await t.fs.readdirWithFileTypes(l);for(let g of d){if(x(u),g.name.startsWith("."))continue;let $=s==="."?g.name:`${s}/${g.name}`;await S($,t,r,h,a,g.isFile,u,f,o+1)}}else{x(u);let d=await t.fs.readdir(l);for(let g of d){if(x(u),g.startsWith("."))continue;let $=s==="."?g:`${s}/${g}`;await S($,t,r,h,a,void 0,u,f,o+1)}}}catch(c){G(c)}return f}var Fe={name:"fgrep",async execute(s,t){return ae.execute(["-F",...s],t)}},Re={name:"egrep",async execute(s,t){return ae.execute(["-E",...s],t)}},Te={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"}],stdinType:"text",needsArgs:!0},Ce={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},Pe={name:"egrep",flags:[],stdinType:"text",needsArgs:!0};export{ae as a,Fe as b,Re as c,Te as d,Ce as e,Pe as f};
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as Q,b as F}from"./chunk-WSLBBXPJ.js";import{a as I}from"./chunk-7I6MNC5I.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import"./chunk-SSK3N7FN.js";import{a as A}from"./chunk-MROECM42.js";import{c as E}from"./chunk-4SQKKW2M.js";import{b}from"./chunk-46CDVHZ3.js";import{b as v}from"./chunk-CPKBPQ2C.js";import{a as D,b as d}from"./chunk-PBOVSFTJ.js";import{a as g}from"./chunk-I4IRHQDW.js";import{a as M,b as P}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{fileURLToPath as $}from"node:url";import{Worker as L}from"node:worker_threads";var z={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};function B(r){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(r.length===0)return e;let t=r.findIndex(n=>!n.startsWith("-")||n==="-"||n==="--");for(let n=0;n<(t===-1?r.length:t);n++){let i=r[n];if(i==="-c")return n+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
4
- `,exitCode:2}:(e.code=r[n+1],e.scriptArgs=r.slice(n+2),e);if(i==="-m")return n+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
5
- `,exitCode:2}:(e.module=r[n+1],e.scriptArgs=r.slice(n+2),e);if(i==="--version"||i==="-V")return e.showVersion=!0,e;if(i.startsWith("-")&&i!=="-")return{stdout:"",stderr:`python3: unrecognized option '${i}'
6
- `,exitCode:2}}if(t!==-1){let n=r[t];n==="--"?t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)):(e.scriptFile=n,e.scriptArgs=r.slice(t+1))}return e}var C=new WeakMap;function _(r){let e=C.get(r);return e||(e={executionQueue:[],activeExecution:null,poisonedError:null},C.set(r,e)),e}function te(){C=new WeakMap}var R=$(new URL("./worker.js",import.meta.url));function H(r,e){if(!r||typeof r!="object")return{success:!1,error:"Malformed worker response"};let t=r;return typeof t.protocolToken!="string"||t.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:t.type==="security-violation"?{success:!1,error:`Security violation: ${typeof t.violation?.type=="string"?t.violation.type:"unknown"}`}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function w(r){if(r.poisonedError!==null){for(let o of r.executionQueue.splice(0))o.state==="queued"&&(o.state="settled",o.stopBridge(),o.settle({success:!1,error:r.poisonedError}));return}if(r.activeExecution!==null||r.executionQueue.length===0)return;for(;r.executionQueue.length>0&&r.executionQueue[0]?.state!=="queued";)r.executionQueue.shift();if(r.executionQueue.length===0)return;let e=r.executionQueue.shift();if(!e)return;e.state="running",r.activeExecution=e;let t;try{t=b.runTrusted(()=>new L(R,{workerData:e.input}))}catch(o){let s=o instanceof Error?o.message:String(o);e.state="settled",e.settle({success:!1,error:d(s)}),r.activeExecution===e&&(r.activeExecution=null,w(r));return}e.worker=t;let n=!0,i=()=>{n&&(n=!1,t.removeListener("message",x),t.removeListener("error",k),t.removeListener("exit",m))},c=async(o,s)=>{if(!(r.activeExecution?.executionId!==e.executionId||e.state!=="running")){if(e.state="terminating",i(),e.settle(o),s&&!await e.controller.terminate(t)){let p="Worker termination was not acknowledged";e.worker=null,e.state="settled",r.poisonedError=p,r.activeExecution?.executionId===e.executionId&&(r.activeExecution=null),w(r);return}e.worker=null,e.state="settled",r.activeExecution?.executionId===e.executionId&&(r.activeExecution=null,w(r))}};e.cancel=o=>{c(o,!0)};let f=E(e.requireDefenseContext,"python3","worker message callback",o=>{try{e.controller.assertMessageSize(o,"response")}catch(s){c({success:!1,error:d(g(s))},!0);return}c(H(o,e.input.protocolToken),!0)}),l=E(e.requireDefenseContext,"python3","worker error callback",o=>{let s=d(g(o));c({success:!1,error:s},!0)}),u=E(e.requireDefenseContext,"python3","worker exit callback",()=>{c({success:!1,error:"Worker exited unexpectedly"},!1)}),x=o=>{try{f(o)}catch(s){let a=s instanceof Error?s.message:String(s);c({success:!1,error:d(a)},!0)}},k=o=>{try{l(o)}catch(s){let a=s instanceof Error?s.message:String(s);c({success:!1,error:d(a)},!0)}},m=()=>{try{u()}catch(o){let s=o instanceof Error?o.message:String(o);c({success:!1,error:d(s)},!0)}};t.on("message",x),t.on("error",k),t.on("exit",m)}async function U(r,e,t,n=[]){let i=Q(),c=new F(i,e.fs,e.cwd,"python3",e.fetch,e.limits.maxOutputSize),f=e.limits.maxPythonTimeoutMs,l=_(e.fs);if(l.poisonedError!==null)return{stdout:"",stderr:`python3: ${l.poisonedError}
7
- `,exitCode:1};let u=new I({commandName:"python3",timeoutMs:f,signal:e.signal,maxMessageBytes:e.limits.maxWorkerMessageBytes}),x={protocolToken:u.protocolToken,sharedBuffer:i,pythonCode:r,cwd:e.cwd,env:A(e.env),args:n,scriptPath:t,timeoutMs:f,maxFileSize:e.limits.maxStringLength};u.assertMessageSize({...x,sharedBuffer:void 0},"request");let k=new Promise(s=>{let a=!1,p={executionId:Symbol("python3 execution"),input:x,settle:h=>{a||(a=!0,u.close(),s(h))},requireDefenseContext:e.requireDefenseContext,state:"queued",worker:null,controller:u,stopBridge:()=>c.stop?.(),cancel:()=>{}};p.cancel=h=>{if(p.state!=="queued")return;p.state="settled";let y=l.executionQueue.indexOf(p);y!==-1&&l.executionQueue.splice(y,1),p.settle(h),w(l)};let W=E(e.requireDefenseContext,"python3","worker cancellation callback",h=>{c.stop?.(),p.cancel({success:!1,error:h==="abort"?u.abortMessage():u.timeoutMessage()})}),O=h=>{try{W(h)}catch(y){let T=y instanceof Error?y.message:String(y);p.cancel({success:!1,error:d(T)})}};u.arm(O),u.isCanceled||(l.executionQueue.push(p),w(l))}),[m,o]=await Promise.all([c.run(f).catch(s=>({stdout:"",stderr:`python3: bridge error: ${d(g(s))}
8
- `,exitCode:1})),k.catch(s=>({success:!1,error:d(g(s))}))]);if(!o.success&&o.error){let s=d(o.error),a=o.error===u.timeoutMessage()||o.error===u.abortMessage();return{stdout:m.stdout,stderr:`${m.stderr}python3: ${s}
9
- `,exitCode:m.exitCode||(a?124:1)}}return{...m}}var N={name:"python3",async execute(r,e){if(P(r))return M(z);let t=B(r);if("exitCode"in t)return t;if(t.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
10
- `,stderr:"",exitCode:0};let n,i;if(t.code!==null)n=t.code,i="-c";else if(t.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(t.module))return{stdout:"",stderr:`python3: No module named '${t.module.slice(0,200)}'
11
- `,exitCode:1};n=`import runpy; runpy.run_module('${t.module}', run_name='__main__')`,i=t.module}else if(t.scriptFile==="-")n=v(e.stdin),i="-";else if(t.scriptFile!==null){let c=e.fs.resolvePath(e.cwd,t.scriptFile);if(!await e.fs.exists(c))return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': [Errno 2] No such file or directory
12
- `,exitCode:2};try{n=await e.fs.readFile(c),i=t.scriptFile}catch(f){let l=D(f.message);return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': ${l}
13
- `,exitCode:2}}}else if(v(e.stdin).trim())n=v(e.stdin),i="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
14
- `,exitCode:2};return U(n,e,i,t.scriptArgs)}},oe={name:"python",async execute(r,e){return N.execute(r,e)}};export{te as _resetExecutionQueue,N as python3Command,oe as pythonCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as P,b as j,c as U,d as W}from"./chunk-YMELOXDK.js";import{d as D}from"./chunk-WDV2ECOC.js";import{a as A,b as H}from"./chunk-4SQKKW2M.js";import{b as _}from"./chunk-O74FSWB4.js";import{a as F}from"./chunk-46CDVHZ3.js";import{l as y}from"./chunk-LCP3IKI7.js";import{a as M,b as z}from"./chunk-CPKBPQ2C.js";import{a as J}from"./chunk-PBOVSFTJ.js";import{a as R,b as V,c as I}from"./chunk-MUFNRCMY.js";function G(n){switch(n){case"\b":return"\\b";case"\f":return"\\f";case`
4
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${n.charCodeAt(0).toString(16).padStart(4,"0")}`}}function Y(n){let s="",d=!1,f=!1;for(let t=0;t<n.length;t++){let l=n[t];if(f){s+=l,f=!1;continue}if(l==="\\"){s+=l,f=!0;continue}if(l==='"'){s+=l,d=!d;continue}if(d&&l.charCodeAt(0)<=31){s+=G(l);continue}s+=l}return s}function L(n,s,d){return JSON.parse(Y(n.slice(s,d)))}function K(n,s){let d=[],f=g=>{if(d.length>=s.maxElements)throw new y(`query result element limit exceeded (${s.maxElements})`,"array_elements");d.push(g)},t=0,l=n.length;for(;t<l;){for(;t<l&&/\s/.test(n[t]);)t++;if(t>=l)break;let g=t,c=n[t];if(c==="{"||c==="["){let a=[c==="{"?"}":"]"],p=!1,w=!1;for(t++;t<l&&a.length>0;){let h=n[t];if(w)w=!1;else if(h==="\\")w=!0;else if(h==='"')p=!p;else if(!p){if(h==="{"||h==="["){if(a.push(h==="{"?"}":"]"),a.length>s.maxDepth)throw new y(`query depth limit exceeded (${s.maxDepth})`,"recursion")}else if((h==="}"||h==="]")&&a.pop()!==h)throw new Error(`Mismatched JSON delimiter at position ${t}`)}t++}if(a.length!==0)throw new Error(`Unexpected end of JSON input at position ${t} (unclosed ${c})`);f(D(L(n,g,t),{maxDepth:s.maxDepth,maxElements:s.maxElements}))}else if(c==='"'){let a=!1;for(t++;t<l;){let p=n[t];if(a)a=!1;else if(p==="\\")a=!0;else if(p==='"'){t++;break}t++}f(D(L(n,g,t),s))}else if(c==="-"||c>="0"&&c<="9"){for(;t<l&&/[\d.eE+-]/.test(n[t]);)t++;f(D(L(n,g,t),s))}else if(n.slice(t,t+4)==="true")f(!0),t+=4;else if(n.slice(t,t+5)==="false")f(!1),t+=5;else if(n.slice(t,t+4)==="null")f(null),t+=4;else{let a=n.slice(t,t+10);throw new Error(`Invalid JSON at position ${g}: unexpected '${a.split(/\s/)[0]}'`)}}return d}var Z={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE...]",options:["-R, --raw-input read each line as string instead of JSON","-r, --raw-output output strings without quotes","-c, --compact-output compact instead of pretty-printed output","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]},pe={name:"jq",async execute(n,s){A(s.requireDefenseContext,"jq","execution entry");let d=(r,e)=>H(s.requireDefenseContext,"jq",r,e);if(V(n))return R(Z);let f=!1,t=!1,l=!1,g=!1,c=!1,a=!1,p=!1,w=!1,h=!1,Q=".",T=!1,E=[];for(let r=0;r<n.length;r++){let e=n[r];if(e==="-R"||e==="--raw-input")t=!0;else if(e==="-r"||e==="--raw-output")f=!0;else if(e==="-c"||e==="--compact-output")l=!0;else if(e==="-e"||e==="--exit-status")g=!0;else if(e==="-s"||e==="--slurp")c=!0;else if(e==="-n"||e==="--null-input")a=!0;else if(e==="-j"||e==="--join-output")p=!0;else if(!(e==="-a"||e==="--ascii")){if(e==="-S"||e==="--sort-keys")w=!0;else if(!(e==="-C"||e==="--color")){if(!(e==="-M"||e==="--monochrome"))if(e==="--tab")h=!0;else if(e==="-")E.push("-");else{if(e.startsWith("--"))return I("jq",e);if(e.startsWith("-")){for(let i of e.slice(1))if(i==="R")t=!0;else if(i==="r")f=!0;else if(i==="c")l=!0;else if(i==="e")g=!0;else if(i==="s")c=!0;else if(i==="n")a=!0;else if(i==="j")p=!0;else if(i!=="a"){if(i==="S")w=!0;else if(i!=="C"){if(i!=="M")return I("jq",`-${i}`)}}}else T?E.push(e):(Q=e,T=!0)}}}}let C=[];if(!a)if(E.length===0||E.length===1&&E[0]==="-")C.push({source:"stdin",content:z(s.stdin)});else{let r=await d("file read",()=>_(s,E,{cmdName:"jq",stopOnError:!0}));if(r.exitCode!==0)return{stdout:"",stderr:r.stderr,exitCode:2};C=r.files.map(e=>({source:e.filename||"stdin",content:z(e.content)}))}try{let r=U(Q,{maxDepth:s.limits.maxQueryDepth,maxTokens:s.limits.maxQueryTokens,maxSourceLength:s.limits.maxStringLength}),e=[],i={limits:s.limits?{maxIterations:s.limits.maxJqIterations,maxStringLength:s.limits.maxStringLength,maxOutputSize:s.limits.maxOutputSize,maxArrayElements:s.limits.maxQueryElements,maxDepth:s.limits.maxQueryDepth}:void 0,env:s.env,coverage:s.coverage,requireDefenseContext:s.requireDefenseContext,budget:{operations:0,callDepth:0}},v={maxDepth:s.limits.maxQueryDepth,maxElements:s.limits.maxQueryElements},b=(o,u)=>{if(u.length>s.limits.maxQueryElements-o.length)throw new y(`query result element limit exceeded (${s.limits.maxQueryElements})`,"array_elements");for(let m of u)o.push(m)};if(a)e=j(null,r,i);else if(t&&c){let o=C.map(({content:u})=>u).join("");e=j(o,r,i)}else if(t){let o="";for(let{content:u}of C){let m=o+u,x=0,S=m.indexOf(`
5
- `,x);for(;S!==-1;)b(e,j(m.slice(x,S),r,i)),x=S+1,S=m.indexOf(`
6
- `,x);o=m.slice(x)}o!==""&&b(e,j(o,r,i))}else if(c){let o=[];for(let{content:u}of C){let m=u.trim();m&&b(o,K(m,v))}e=j(o,r,i)}else for(let{content:o}of C){let u=o.trim();if(!u)continue;let m=K(u,v);for(let x of m)b(e,j(x,r,i))}let N=p?"":`
7
- `,q=Math.min(s.limits.maxStringLength,s.limits.maxOutputSize),O=[],$=0;for(let o of e){let u=O.length>0?N.length:0,m=p?0:1,x=q-$-u-m;if(x<0)throw new y(`output size limit exceeded (${q} bytes)`,"string_length");if(P(o,s.limits.maxQueryDepth+1)>s.limits.maxQueryDepth)throw new y(`query depth limit exceeded (${s.limits.maxQueryDepth})`,"recursion");let S=W(o,x,{compact:l,raw:f,sortKeys:w,useTab:h,limitKind:"string_length"}),B=M(S);if($+u+B+m>q)throw new y(`output size limit exceeded (${q} bytes)`,"string_length");$+=u+B,O.push(S)}let k=O.join(N),X=g&&(e.length===0||e.every(o=>o==null||o===!1))?1:0;return{stdout:k?p?k:`${k}
8
- `:"",stderr:"",exitCode:X}}catch(r){if(r instanceof F)throw r;if(r instanceof y)return{stdout:"",stderr:`jq: ${J(r.message)}
9
- `,exitCode:y.EXIT_CODE};let e=J(r.message);return e.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${e}
10
- `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${e}
11
- `,exitCode:5}}}},de={name:"jq",flags:[{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-j",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"--tab",type:"boolean"}],stdinType:"json",needsArgs:!0};export{pe as a,de as b};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as v}from"./chunk-X5VUGFUL.js";import{a as K,b as le}from"./chunk-JQER3HUP.js";import{a as G}from"./chunk-BNYIXXC2.js";import{l as U}from"./chunk-LCP3IKI7.js";import{b as ie}from"./chunk-CPKBPQ2C.js";import{a as re,c as J}from"./chunk-MUFNRCMY.js";function oe(s){let t=s.limits.maxLoopIterations,r=s.limits.maxArrayElements;return Math.max(t,Math.min(r,t*10))}function x(s){if(++s.operations>s.maxOperations)throw new U(`grep: glob operation limit exceeded (${s.maxOperations})`,"glob_operations")}function H(s){if(s.results>=s.maxResults)throw new U(`grep: array element limit exceeded (${s.maxResults})`,"array_elements");s.results++}var me={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},ae={name:"grep",async execute(s,t){let r=!1,h=!1,a=!1,m=!1,u=!1,f=!1,o=!1,l=!1,c=!1,w=!1,R=!1,d=!1,g=!1,$=!1,Q=!1,O=0,E=0,M=0,L=[],B=[],_=[],A=null,b=[],k=!0;for(let i=0;i<s.length;i++){let n=s[i];if(k&&n==="--"){k=!1;continue}if(k&&n==="--help")return re(me);if(k&&n.startsWith("-")&&n!=="-"){if(n==="-e"&&i+1<s.length){A=s[++i];continue}if(n.startsWith("--include=")){L.push(n.slice(10));continue}if(n.startsWith("--exclude=")){B.push(n.slice(10));continue}if(n.startsWith("--exclude-dir=")){_.push(n.slice(14));continue}if(n.startsWith("--max-count=")){O=parseInt(n.slice(12),10);continue}let P=n.match(/^-m(\d+)$/);if(P){O=parseInt(P[1],10);continue}if(n==="-m"&&i+1<s.length){O=parseInt(s[++i],10);continue}let p=n.match(/^-([ABC])(\d+)$/);if(p){let e=parseInt(p[2],10);p[1]==="A"?M=e:p[1]==="B"?E=e:p[1]==="C"&&(E=e,M=e);continue}if((n==="-A"||n==="-B"||n==="-C")&&i+1<s.length){let e=parseInt(s[++i],10);n==="-A"?M=e:n==="-B"?E=e:(E=e,M=e);continue}let y=n.startsWith("--")?[n]:n.slice(1).split("");for(let e of y)if(e==="i"||e==="--ignore-case")r=!0;else if(e==="n"||e==="--line-number")h=!0;else if(e==="v"||e==="--invert-match")a=!0;else if(e==="c"||e==="--count")m=!0;else if(e==="l"||e==="--files-with-matches")u=!0;else if(e==="L"||e==="--files-without-match")f=!0;else if(e==="r"||e==="R"||e==="--recursive")o=!0;else if(e==="w"||e==="--word-regexp")l=!0;else if(e==="x"||e==="--line-regexp")c=!0;else if(e==="E"||e==="--extended-regexp")w=!0;else if(e==="P"||e==="--perl-regexp")R=!0;else if(e==="F"||e==="--fixed-strings")d=!0;else if(e==="o"||e==="--only-matching")g=!0;else if(e==="h"||e==="--no-filename")$=!0;else if(e==="q"||e==="--quiet"||e==="--silent")Q=!0;else{if(e.startsWith("--"))return J("grep",e);if(e.length===1)return J("grep",`-${e}`)}}else A===null?A=n:b.push(n)}if(A===null)return{stdout:"",stderr:`grep: missing pattern
4
- `,exitCode:2};let ce=d?"fixed":w?"extended":R?"perl":"basic",q,z,W;try{let i=le(A,{mode:ce,ignoreCase:r,wholeWord:l,lineRegexp:c});q=i.regex,z=i.kResetGroup,W=i.preFilter}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${A}
5
- `,exitCode:2}}if(b.length===0&&t.stdin!==void 0){let i=K(ie(t.stdin),q,{invertMatch:a,showLineNumbers:h,countOnly:m,filename:"",onlyMatching:g,beforeContext:E,afterContext:M,maxCount:O,kResetGroup:z,preFilter:W,maxWork:oe(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return Q?{stdout:"",stderr:"",exitCode:i.matched?0:1}:{stdout:i.output,stderr:"",exitCode:i.matched?0:1}}if(b.length===0)return{stdout:"",stderr:`grep: no input files
6
- `,exitCode:2};let N="",V="",Y=!1,ee=!1,T=[],C={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},D=i=>{if(i.length>C.maxResults-T.length)throw new U(`grep: array element limit exceeded (${C.maxResults})`,"array_elements");T.push(...i)};for(let i of b)if(i.includes("*")||i.includes("?")||i.includes("[")){let n=await he(i,t,C);if(o)for(let P of n){let p=await S(P.path,t,L,B,_,P.isFile,C);D(p)}else D(n)}else if(o){let n=await S(i,t,L,B,_,void 0,C);D(n)}else{if(T.length>=C.maxResults)throw new U(`grep: array element limit exceeded (${C.maxResults})`,"array_elements");T.push({path:i})}let te=(T.length>1||o)&&!$,se=50;for(let i=0;i<T.length;i+=se){let n=T.slice(i,i+se),P=await Promise.all(n.map(async p=>{let y=p.path,e=y.split("/").pop()||y;if(B.length>0&&!o&&B.some(F=>v(e,F,{stripQuotes:!0}))||L.length>0&&!o&&!L.some(F=>v(e,F,{stripQuotes:!0})))return null;try{let F=t.fs.resolvePath(t.cwd,y),X=!1;if(p.isFile===void 0?X=(await t.fs.stat(F)).isDirectory:X=!p.isFile,X)return o?null:{error:`grep: ${y}: Is a directory
7
- `};let Z=await t.fs.readFile(F);if(W&&!a){let ne=W.ignoreCase?Z.toLowerCase():Z;if(!W.needles.some(j=>ne.includes(j))){if(m){let j=te?`${y}:0`:"0";return{file:y,result:{output:`${j}
8
- `,matched:!1,matchCount:0}}}return{file:y,result:{output:"",matched:!1,matchCount:0}}}}let pe=K(Z,q,{invertMatch:a,showLineNumbers:h,countOnly:m,filename:te?y:"",onlyMatching:g,beforeContext:E,afterContext:M,maxCount:O,kResetGroup:z,preFilter:W,maxWork:oe(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return{file:y,result:pe}}catch(F){return G(F),{error:`grep: ${y}: No such file or directory
9
- `}}}));for(let p of P){if(p===null)continue;if("error"in p&&p.error){V+=p.error,p.error.includes("Is a directory")||(ee=!0);continue}if(!("file"in p)||!p.result)continue;let{file:y,result:e}=p;if(e.matched){if(Y=!0,Q)return{stdout:"",stderr:"",exitCode:0};u?N+=`${y}
10
- `:f||(N+=e.output)}else f?N+=`${y}
11
- `:m&&!u&&(N+=e.output)}}let I;return ee?I=2:f?I=N.length>0?0:1:I=Y?0:1,Q?{stdout:"",stderr:"",exitCode:I}:{stdout:N,stderr:V,exitCode:I}}},fe=256;async function ue(s,t,r,h,a,m=0){if(m>=fe)return;let u=r.fs.resolvePath(r.cwd,s);try{if(x(a),!(await r.fs.stat(u)).isDirectory){let l=s.split("/").pop()||"";if(t){let c=t.replace(/^\//,"");v(l,c,{stripQuotes:!0})&&(H(a),h.push(s))}return}x(a);let o=await r.fs.readdir(u);for(let l of o){let c=s==="."?l:`${s}/${l}`,w=r.fs.resolvePath(r.cwd,c);if(x(a),(await r.fs.stat(w)).isDirectory)await ue(c,t,r,h,a,m+1);else if(t){let d=t.replace(/^\//,"");v(l,d,{stripQuotes:!0})&&(H(a),h.push(c))}}}catch(f){G(f)}}async function he(s,t,r){let h=[],a=s.lastIndexOf("/"),m,u;if(a===-1?(m=t.cwd,u=s):(m=s.slice(0,a)||"/",u=s.slice(a+1)),s.includes("**")){let o=[],l=s.split("**"),c=l[0].replace(/\/$/,"")||".",w=l[1]||"";return await ue(c,w,t,o,r),o.map(R=>({path:R}))}let f=t.fs.resolvePath(t.cwd,m);try{if(t.fs.readdirWithFileTypes){x(r);let o=await t.fs.readdirWithFileTypes(f);for(let l of o)if(x(r),v(l.name,u,{stripQuotes:!0})){let c=a===-1?l.name:`${m}/${l.name}`;H(r),h.push({path:c,isFile:l.isFile})}}else{x(r);let o=await t.fs.readdir(f);for(let l of o)if(x(r),v(l,u,{stripQuotes:!0})){let c=a===-1?l:`${m}/${l}`;H(r),h.push({path:c})}}}catch(o){G(o)}return h.sort((o,l)=>o.path.localeCompare(l.path))}async function S(s,t,r=[],h=[],a=[],m,u={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},f=[],o=0){if(o>=fe)return f;let l=t.fs.resolvePath(t.cwd,s);try{let c,w;if(m!==void 0)c=m,w=!m;else{x(u);let d=await t.fs.stat(l);c=d.isFile,w=d.isDirectory}if(c){let d=s.split("/").pop()||s;return h.length>0&&h.some(g=>v(d,g,{stripQuotes:!0}))||r.length>0&&!r.some(g=>v(d,g,{stripQuotes:!0}))||(H(u),f.push({path:s,isFile:!0})),f}if(!w)return f;let R=s.split("/").pop()||s;if(a.length>0&&a.some(d=>v(R,d,{stripQuotes:!0})))return f;if(t.fs.readdirWithFileTypes){x(u);let d=await t.fs.readdirWithFileTypes(l);for(let g of d){if(x(u),g.name.startsWith("."))continue;let $=s==="."?g.name:`${s}/${g.name}`;await S($,t,r,h,a,g.isFile,u,f,o+1)}}else{x(u);let d=await t.fs.readdir(l);for(let g of d){if(x(u),g.startsWith("."))continue;let $=s==="."?g:`${s}/${g}`;await S($,t,r,h,a,void 0,u,f,o+1)}}}catch(c){G(c)}return f}var Fe={name:"fgrep",async execute(s,t){return ae.execute(["-F",...s],t)}},Re={name:"egrep",async execute(s,t){return ae.execute(["-E",...s],t)}},Te={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"}],stdinType:"text",needsArgs:!0},Ce={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},Pe={name:"egrep",flags:[],stdinType:"text",needsArgs:!0};export{ae as a,Fe as b,Re as c,Te as d,Ce as e,Pe as f};
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as Q,b as F}from"./chunk-WSLBBXPJ.js";import{a as I}from"./chunk-7I6MNC5I.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import"./chunk-SSK3N7FN.js";import{a as A}from"./chunk-MROECM42.js";import{c as E}from"./chunk-4SQKKW2M.js";import{b}from"./chunk-46CDVHZ3.js";import{b as v}from"./chunk-CPKBPQ2C.js";import{a as D,b as d}from"./chunk-PBOVSFTJ.js";import{a as g}from"./chunk-I4IRHQDW.js";import{a as M,b as P}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{fileURLToPath as $}from"node:url";import{Worker as L}from"node:worker_threads";var z={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};function B(r){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(r.length===0)return e;let t=r.findIndex(n=>!n.startsWith("-")||n==="-"||n==="--");for(let n=0;n<(t===-1?r.length:t);n++){let i=r[n];if(i==="-c")return n+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
4
- `,exitCode:2}:(e.code=r[n+1],e.scriptArgs=r.slice(n+2),e);if(i==="-m")return n+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
5
- `,exitCode:2}:(e.module=r[n+1],e.scriptArgs=r.slice(n+2),e);if(i==="--version"||i==="-V")return e.showVersion=!0,e;if(i.startsWith("-")&&i!=="-")return{stdout:"",stderr:`python3: unrecognized option '${i}'
6
- `,exitCode:2}}if(t!==-1){let n=r[t];n==="--"?t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)):(e.scriptFile=n,e.scriptArgs=r.slice(t+1))}return e}var C=new WeakMap;function _(r){let e=C.get(r);return e||(e={executionQueue:[],activeExecution:null,poisonedError:null},C.set(r,e)),e}function te(){C=new WeakMap}var R=$(new URL("./worker.js",import.meta.url));function H(r,e){if(!r||typeof r!="object")return{success:!1,error:"Malformed worker response"};let t=r;return typeof t.protocolToken!="string"||t.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:t.type==="security-violation"?{success:!1,error:`Security violation: ${typeof t.violation?.type=="string"?t.violation.type:"unknown"}`}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function w(r){if(r.poisonedError!==null){for(let o of r.executionQueue.splice(0))o.state==="queued"&&(o.state="settled",o.stopBridge(),o.settle({success:!1,error:r.poisonedError}));return}if(r.activeExecution!==null||r.executionQueue.length===0)return;for(;r.executionQueue.length>0&&r.executionQueue[0]?.state!=="queued";)r.executionQueue.shift();if(r.executionQueue.length===0)return;let e=r.executionQueue.shift();if(!e)return;e.state="running",r.activeExecution=e;let t;try{t=b.runTrusted(()=>new L(R,{workerData:e.input}))}catch(o){let s=o instanceof Error?o.message:String(o);e.state="settled",e.settle({success:!1,error:d(s)}),r.activeExecution===e&&(r.activeExecution=null,w(r));return}e.worker=t;let n=!0,i=()=>{n&&(n=!1,t.removeListener("message",x),t.removeListener("error",k),t.removeListener("exit",m))},c=async(o,s)=>{if(!(r.activeExecution?.executionId!==e.executionId||e.state!=="running")){if(e.state="terminating",i(),e.settle(o),s&&!await e.controller.terminate(t)){let p="Worker termination was not acknowledged";e.worker=null,e.state="settled",r.poisonedError=p,r.activeExecution?.executionId===e.executionId&&(r.activeExecution=null),w(r);return}e.worker=null,e.state="settled",r.activeExecution?.executionId===e.executionId&&(r.activeExecution=null,w(r))}};e.cancel=o=>{c(o,!0)};let f=E(e.requireDefenseContext,"python3","worker message callback",o=>{try{e.controller.assertMessageSize(o,"response")}catch(s){c({success:!1,error:d(g(s))},!0);return}c(H(o,e.input.protocolToken),!0)}),l=E(e.requireDefenseContext,"python3","worker error callback",o=>{let s=d(g(o));c({success:!1,error:s},!0)}),u=E(e.requireDefenseContext,"python3","worker exit callback",()=>{c({success:!1,error:"Worker exited unexpectedly"},!1)}),x=o=>{try{f(o)}catch(s){let a=s instanceof Error?s.message:String(s);c({success:!1,error:d(a)},!0)}},k=o=>{try{l(o)}catch(s){let a=s instanceof Error?s.message:String(s);c({success:!1,error:d(a)},!0)}},m=()=>{try{u()}catch(o){let s=o instanceof Error?o.message:String(o);c({success:!1,error:d(s)},!0)}};t.on("message",x),t.on("error",k),t.on("exit",m)}async function U(r,e,t,n=[]){let i=Q(),c=new F(i,e.fs,e.cwd,"python3",e.fetch,e.limits.maxOutputSize),f=e.limits.maxPythonTimeoutMs,l=_(e.fs);if(l.poisonedError!==null)return{stdout:"",stderr:`python3: ${l.poisonedError}
7
- `,exitCode:1};let u=new I({commandName:"python3",timeoutMs:f,signal:e.signal,maxMessageBytes:e.limits.maxWorkerMessageBytes}),x={protocolToken:u.protocolToken,sharedBuffer:i,pythonCode:r,cwd:e.cwd,env:A(e.env),args:n,scriptPath:t,timeoutMs:f,maxFileSize:e.limits.maxStringLength};u.assertMessageSize({...x,sharedBuffer:void 0},"request");let k=new Promise(s=>{let a=!1,p={executionId:Symbol("python3 execution"),input:x,settle:h=>{a||(a=!0,u.close(),s(h))},requireDefenseContext:e.requireDefenseContext,state:"queued",worker:null,controller:u,stopBridge:()=>c.stop?.(),cancel:()=>{}};p.cancel=h=>{if(p.state!=="queued")return;p.state="settled";let y=l.executionQueue.indexOf(p);y!==-1&&l.executionQueue.splice(y,1),p.settle(h),w(l)};let W=E(e.requireDefenseContext,"python3","worker cancellation callback",h=>{c.stop?.(),p.cancel({success:!1,error:h==="abort"?u.abortMessage():u.timeoutMessage()})}),O=h=>{try{W(h)}catch(y){let T=y instanceof Error?y.message:String(y);p.cancel({success:!1,error:d(T)})}};u.arm(O),u.isCanceled||(l.executionQueue.push(p),w(l))}),[m,o]=await Promise.all([c.run(f).catch(s=>({stdout:"",stderr:`python3: bridge error: ${d(g(s))}
8
- `,exitCode:1})),k.catch(s=>({success:!1,error:d(g(s))}))]);if(!o.success&&o.error){let s=d(o.error),a=o.error===u.timeoutMessage()||o.error===u.abortMessage();return{stdout:m.stdout,stderr:`${m.stderr}python3: ${s}
9
- `,exitCode:m.exitCode||(a?124:1)}}return{...m}}var N={name:"python3",async execute(r,e){if(P(r))return M(z);let t=B(r);if("exitCode"in t)return t;if(t.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
10
- `,stderr:"",exitCode:0};let n,i;if(t.code!==null)n=t.code,i="-c";else if(t.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(t.module))return{stdout:"",stderr:`python3: No module named '${t.module.slice(0,200)}'
11
- `,exitCode:1};n=`import runpy; runpy.run_module('${t.module}', run_name='__main__')`,i=t.module}else if(t.scriptFile==="-")n=v(e.stdin),i="-";else if(t.scriptFile!==null){let c=e.fs.resolvePath(e.cwd,t.scriptFile);if(!await e.fs.exists(c))return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': [Errno 2] No such file or directory
12
- `,exitCode:2};try{n=await e.fs.readFile(c),i=t.scriptFile}catch(f){let l=D(f.message);return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': ${l}
13
- `,exitCode:2}}}else if(v(e.stdin).trim())n=v(e.stdin),i="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
14
- `,exitCode:2};return U(n,e,i,t.scriptArgs)}},oe={name:"python",async execute(r,e){return N.execute(r,e)}};export{te as _resetExecutionQueue,N as python3Command,oe as pythonCommand};
@@ -1,10 +0,0 @@
1
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
2
- import{a as P,b as j,c as U,d as W}from"./chunk-65Z4QURM.js";import{d as D}from"./chunk-FIMO5HLX.js";import{a as A,b as H}from"./chunk-AI5LSBJC.js";import{b as _}from"./chunk-CHHWTPDH.js";import{a as F}from"./chunk-UBTKJ6MG.js";import{l as y}from"./chunk-EFORKKSH.js";import{a as M,d as z}from"./chunk-GN6CQ3J4.js";import{a as J}from"./chunk-FOCWZZDE.js";import{a as R,b as V,c as I}from"./chunk-QAYAQNCG.js";function G(n){switch(n){case"\b":return"\\b";case"\f":return"\\f";case`
3
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${n.charCodeAt(0).toString(16).padStart(4,"0")}`}}function Y(n){let s="",d=!1,f=!1;for(let t=0;t<n.length;t++){let l=n[t];if(f){s+=l,f=!1;continue}if(l==="\\"){s+=l,f=!0;continue}if(l==='"'){s+=l,d=!d;continue}if(d&&l.charCodeAt(0)<=31){s+=G(l);continue}s+=l}return s}function L(n,s,d){return JSON.parse(Y(n.slice(s,d)))}function K(n,s){let d=[],f=g=>{if(d.length>=s.maxElements)throw new y(`query result element limit exceeded (${s.maxElements})`,"array_elements");d.push(g)},t=0,l=n.length;for(;t<l;){for(;t<l&&/\s/.test(n[t]);)t++;if(t>=l)break;let g=t,c=n[t];if(c==="{"||c==="["){let a=[c==="{"?"}":"]"],p=!1,w=!1;for(t++;t<l&&a.length>0;){let h=n[t];if(w)w=!1;else if(h==="\\")w=!0;else if(h==='"')p=!p;else if(!p){if(h==="{"||h==="["){if(a.push(h==="{"?"}":"]"),a.length>s.maxDepth)throw new y(`query depth limit exceeded (${s.maxDepth})`,"recursion")}else if((h==="}"||h==="]")&&a.pop()!==h)throw new Error(`Mismatched JSON delimiter at position ${t}`)}t++}if(a.length!==0)throw new Error(`Unexpected end of JSON input at position ${t} (unclosed ${c})`);f(D(L(n,g,t),{maxDepth:s.maxDepth,maxElements:s.maxElements}))}else if(c==='"'){let a=!1;for(t++;t<l;){let p=n[t];if(a)a=!1;else if(p==="\\")a=!0;else if(p==='"'){t++;break}t++}f(D(L(n,g,t),s))}else if(c==="-"||c>="0"&&c<="9"){for(;t<l&&/[\d.eE+-]/.test(n[t]);)t++;f(D(L(n,g,t),s))}else if(n.slice(t,t+4)==="true")f(!0),t+=4;else if(n.slice(t,t+5)==="false")f(!1),t+=5;else if(n.slice(t,t+4)==="null")f(null),t+=4;else{let a=n.slice(t,t+10);throw new Error(`Invalid JSON at position ${g}: unexpected '${a.split(/\s/)[0]}'`)}}return d}var Z={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE...]",options:["-R, --raw-input read each line as string instead of JSON","-r, --raw-output output strings without quotes","-c, --compact-output compact instead of pretty-printed output","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]},pe={name:"jq",async execute(n,s){A(s.requireDefenseContext,"jq","execution entry");let d=(r,e)=>H(s.requireDefenseContext,"jq",r,e);if(V(n))return R(Z);let f=!1,t=!1,l=!1,g=!1,c=!1,a=!1,p=!1,w=!1,h=!1,Q=".",T=!1,E=[];for(let r=0;r<n.length;r++){let e=n[r];if(e==="-R"||e==="--raw-input")t=!0;else if(e==="-r"||e==="--raw-output")f=!0;else if(e==="-c"||e==="--compact-output")l=!0;else if(e==="-e"||e==="--exit-status")g=!0;else if(e==="-s"||e==="--slurp")c=!0;else if(e==="-n"||e==="--null-input")a=!0;else if(e==="-j"||e==="--join-output")p=!0;else if(!(e==="-a"||e==="--ascii")){if(e==="-S"||e==="--sort-keys")w=!0;else if(!(e==="-C"||e==="--color")){if(!(e==="-M"||e==="--monochrome"))if(e==="--tab")h=!0;else if(e==="-")E.push("-");else{if(e.startsWith("--"))return I("jq",e);if(e.startsWith("-")){for(let i of e.slice(1))if(i==="R")t=!0;else if(i==="r")f=!0;else if(i==="c")l=!0;else if(i==="e")g=!0;else if(i==="s")c=!0;else if(i==="n")a=!0;else if(i==="j")p=!0;else if(i!=="a"){if(i==="S")w=!0;else if(i!=="C"){if(i!=="M")return I("jq",`-${i}`)}}}else T?E.push(e):(Q=e,T=!0)}}}}let C=[];if(!a)if(E.length===0||E.length===1&&E[0]==="-")C.push({source:"stdin",content:z(s.stdin)});else{let r=await d("file read",()=>_(s,E,{cmdName:"jq",stopOnError:!0}));if(r.exitCode!==0)return{stdout:"",stderr:r.stderr,exitCode:2};C=r.files.map(e=>({source:e.filename||"stdin",content:z(e.content)}))}try{let r=U(Q,{maxDepth:s.limits.maxQueryDepth,maxTokens:s.limits.maxQueryTokens,maxSourceLength:s.limits.maxStringLength}),e=[],i={limits:s.limits?{maxIterations:s.limits.maxJqIterations,maxStringLength:s.limits.maxStringLength,maxOutputSize:s.limits.maxOutputSize,maxArrayElements:s.limits.maxQueryElements,maxDepth:s.limits.maxQueryDepth}:void 0,env:s.env,coverage:s.coverage,requireDefenseContext:s.requireDefenseContext,budget:{operations:0,callDepth:0}},v={maxDepth:s.limits.maxQueryDepth,maxElements:s.limits.maxQueryElements},b=(o,u)=>{if(u.length>s.limits.maxQueryElements-o.length)throw new y(`query result element limit exceeded (${s.limits.maxQueryElements})`,"array_elements");for(let m of u)o.push(m)};if(a)e=j(null,r,i);else if(t&&c){let o=C.map(({content:u})=>u).join("");e=j(o,r,i)}else if(t){let o="";for(let{content:u}of C){let m=o+u,x=0,S=m.indexOf(`
4
- `,x);for(;S!==-1;)b(e,j(m.slice(x,S),r,i)),x=S+1,S=m.indexOf(`
5
- `,x);o=m.slice(x)}o!==""&&b(e,j(o,r,i))}else if(c){let o=[];for(let{content:u}of C){let m=u.trim();m&&b(o,K(m,v))}e=j(o,r,i)}else for(let{content:o}of C){let u=o.trim();if(!u)continue;let m=K(u,v);for(let x of m)b(e,j(x,r,i))}let N=p?"":`
6
- `,q=Math.min(s.limits.maxStringLength,s.limits.maxOutputSize),O=[],$=0;for(let o of e){let u=O.length>0?N.length:0,m=p?0:1,x=q-$-u-m;if(x<0)throw new y(`output size limit exceeded (${q} bytes)`,"string_length");if(P(o,s.limits.maxQueryDepth+1)>s.limits.maxQueryDepth)throw new y(`query depth limit exceeded (${s.limits.maxQueryDepth})`,"recursion");let S=W(o,x,{compact:l,raw:f,sortKeys:w,useTab:h,limitKind:"string_length"}),B=M(S);if($+u+B+m>q)throw new y(`output size limit exceeded (${q} bytes)`,"string_length");$+=u+B,O.push(S)}let k=O.join(N),X=g&&(e.length===0||e.every(o=>o==null||o===!1))?1:0;return{stdout:k?p?k:`${k}
7
- `:"",stderr:"",exitCode:X}}catch(r){if(r instanceof F)throw r;if(r instanceof y)return{stdout:"",stderr:`jq: ${J(r.message)}
8
- `,exitCode:y.EXIT_CODE};let e=J(r.message);return e.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${e}
9
- `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${e}
10
- `,exitCode:5}}}},de={name:"jq",flags:[{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-j",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"--tab",type:"boolean"}],stdinType:"json",needsArgs:!0};export{pe as a,de as b};
@@ -1,10 +0,0 @@
1
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
2
- import{a as v}from"./chunk-FBXMKFE2.js";import{a as K,b as le}from"./chunk-WENIVVEE.js";import{a as G}from"./chunk-LJRVJXUI.js";import{l as U}from"./chunk-EFORKKSH.js";import{d as ie}from"./chunk-GN6CQ3J4.js";import{a as re,c as J}from"./chunk-QAYAQNCG.js";function oe(s){let t=s.limits.maxLoopIterations,r=s.limits.maxArrayElements;return Math.max(t,Math.min(r,t*10))}function x(s){if(++s.operations>s.maxOperations)throw new U(`grep: glob operation limit exceeded (${s.maxOperations})`,"glob_operations")}function H(s){if(s.results>=s.maxResults)throw new U(`grep: array element limit exceeded (${s.maxResults})`,"array_elements");s.results++}var me={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},ae={name:"grep",async execute(s,t){let r=!1,h=!1,a=!1,m=!1,u=!1,f=!1,o=!1,l=!1,c=!1,w=!1,R=!1,d=!1,g=!1,$=!1,Q=!1,O=0,E=0,M=0,L=[],B=[],_=[],A=null,b=[],k=!0;for(let i=0;i<s.length;i++){let n=s[i];if(k&&n==="--"){k=!1;continue}if(k&&n==="--help")return re(me);if(k&&n.startsWith("-")&&n!=="-"){if(n==="-e"&&i+1<s.length){A=s[++i];continue}if(n.startsWith("--include=")){L.push(n.slice(10));continue}if(n.startsWith("--exclude=")){B.push(n.slice(10));continue}if(n.startsWith("--exclude-dir=")){_.push(n.slice(14));continue}if(n.startsWith("--max-count=")){O=parseInt(n.slice(12),10);continue}let P=n.match(/^-m(\d+)$/);if(P){O=parseInt(P[1],10);continue}if(n==="-m"&&i+1<s.length){O=parseInt(s[++i],10);continue}let p=n.match(/^-([ABC])(\d+)$/);if(p){let e=parseInt(p[2],10);p[1]==="A"?M=e:p[1]==="B"?E=e:p[1]==="C"&&(E=e,M=e);continue}if((n==="-A"||n==="-B"||n==="-C")&&i+1<s.length){let e=parseInt(s[++i],10);n==="-A"?M=e:n==="-B"?E=e:(E=e,M=e);continue}let y=n.startsWith("--")?[n]:n.slice(1).split("");for(let e of y)if(e==="i"||e==="--ignore-case")r=!0;else if(e==="n"||e==="--line-number")h=!0;else if(e==="v"||e==="--invert-match")a=!0;else if(e==="c"||e==="--count")m=!0;else if(e==="l"||e==="--files-with-matches")u=!0;else if(e==="L"||e==="--files-without-match")f=!0;else if(e==="r"||e==="R"||e==="--recursive")o=!0;else if(e==="w"||e==="--word-regexp")l=!0;else if(e==="x"||e==="--line-regexp")c=!0;else if(e==="E"||e==="--extended-regexp")w=!0;else if(e==="P"||e==="--perl-regexp")R=!0;else if(e==="F"||e==="--fixed-strings")d=!0;else if(e==="o"||e==="--only-matching")g=!0;else if(e==="h"||e==="--no-filename")$=!0;else if(e==="q"||e==="--quiet"||e==="--silent")Q=!0;else{if(e.startsWith("--"))return J("grep",e);if(e.length===1)return J("grep",`-${e}`)}}else A===null?A=n:b.push(n)}if(A===null)return{stdout:"",stderr:`grep: missing pattern
3
- `,exitCode:2};let ce=d?"fixed":w?"extended":R?"perl":"basic",q,z,W;try{let i=le(A,{mode:ce,ignoreCase:r,wholeWord:l,lineRegexp:c});q=i.regex,z=i.kResetGroup,W=i.preFilter}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${A}
4
- `,exitCode:2}}if(b.length===0&&t.stdin!==void 0){let i=K(ie(t.stdin),q,{invertMatch:a,showLineNumbers:h,countOnly:m,filename:"",onlyMatching:g,beforeContext:E,afterContext:M,maxCount:O,kResetGroup:z,preFilter:W,maxWork:oe(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return Q?{stdout:"",stderr:"",exitCode:i.matched?0:1}:{stdout:i.output,stderr:"",exitCode:i.matched?0:1}}if(b.length===0)return{stdout:"",stderr:`grep: no input files
5
- `,exitCode:2};let N="",V="",Y=!1,ee=!1,T=[],C={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},D=i=>{if(i.length>C.maxResults-T.length)throw new U(`grep: array element limit exceeded (${C.maxResults})`,"array_elements");T.push(...i)};for(let i of b)if(i.includes("*")||i.includes("?")||i.includes("[")){let n=await he(i,t,C);if(o)for(let P of n){let p=await S(P.path,t,L,B,_,P.isFile,C);D(p)}else D(n)}else if(o){let n=await S(i,t,L,B,_,void 0,C);D(n)}else{if(T.length>=C.maxResults)throw new U(`grep: array element limit exceeded (${C.maxResults})`,"array_elements");T.push({path:i})}let te=(T.length>1||o)&&!$,se=50;for(let i=0;i<T.length;i+=se){let n=T.slice(i,i+se),P=await Promise.all(n.map(async p=>{let y=p.path,e=y.split("/").pop()||y;if(B.length>0&&!o&&B.some(F=>v(e,F,{stripQuotes:!0}))||L.length>0&&!o&&!L.some(F=>v(e,F,{stripQuotes:!0})))return null;try{let F=t.fs.resolvePath(t.cwd,y),X=!1;if(p.isFile===void 0?X=(await t.fs.stat(F)).isDirectory:X=!p.isFile,X)return o?null:{error:`grep: ${y}: Is a directory
6
- `};let Z=await t.fs.readFile(F);if(W&&!a){let ne=W.ignoreCase?Z.toLowerCase():Z;if(!W.needles.some(j=>ne.includes(j))){if(m){let j=te?`${y}:0`:"0";return{file:y,result:{output:`${j}
7
- `,matched:!1,matchCount:0}}}return{file:y,result:{output:"",matched:!1,matchCount:0}}}}let pe=K(Z,q,{invertMatch:a,showLineNumbers:h,countOnly:m,filename:te?y:"",onlyMatching:g,beforeContext:E,afterContext:M,maxCount:O,kResetGroup:z,preFilter:W,maxWork:oe(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return{file:y,result:pe}}catch(F){return G(F),{error:`grep: ${y}: No such file or directory
8
- `}}}));for(let p of P){if(p===null)continue;if("error"in p&&p.error){V+=p.error,p.error.includes("Is a directory")||(ee=!0);continue}if(!("file"in p)||!p.result)continue;let{file:y,result:e}=p;if(e.matched){if(Y=!0,Q)return{stdout:"",stderr:"",exitCode:0};u?N+=`${y}
9
- `:f||(N+=e.output)}else f?N+=`${y}
10
- `:m&&!u&&(N+=e.output)}}let I;return ee?I=2:f?I=N.length>0?0:1:I=Y?0:1,Q?{stdout:"",stderr:"",exitCode:I}:{stdout:N,stderr:V,exitCode:I}}},fe=256;async function ue(s,t,r,h,a,m=0){if(m>=fe)return;let u=r.fs.resolvePath(r.cwd,s);try{if(x(a),!(await r.fs.stat(u)).isDirectory){let l=s.split("/").pop()||"";if(t){let c=t.replace(/^\//,"");v(l,c,{stripQuotes:!0})&&(H(a),h.push(s))}return}x(a);let o=await r.fs.readdir(u);for(let l of o){let c=s==="."?l:`${s}/${l}`,w=r.fs.resolvePath(r.cwd,c);if(x(a),(await r.fs.stat(w)).isDirectory)await ue(c,t,r,h,a,m+1);else if(t){let d=t.replace(/^\//,"");v(l,d,{stripQuotes:!0})&&(H(a),h.push(c))}}}catch(f){G(f)}}async function he(s,t,r){let h=[],a=s.lastIndexOf("/"),m,u;if(a===-1?(m=t.cwd,u=s):(m=s.slice(0,a)||"/",u=s.slice(a+1)),s.includes("**")){let o=[],l=s.split("**"),c=l[0].replace(/\/$/,"")||".",w=l[1]||"";return await ue(c,w,t,o,r),o.map(R=>({path:R}))}let f=t.fs.resolvePath(t.cwd,m);try{if(t.fs.readdirWithFileTypes){x(r);let o=await t.fs.readdirWithFileTypes(f);for(let l of o)if(x(r),v(l.name,u,{stripQuotes:!0})){let c=a===-1?l.name:`${m}/${l.name}`;H(r),h.push({path:c,isFile:l.isFile})}}else{x(r);let o=await t.fs.readdir(f);for(let l of o)if(x(r),v(l,u,{stripQuotes:!0})){let c=a===-1?l:`${m}/${l}`;H(r),h.push({path:c})}}}catch(o){G(o)}return h.sort((o,l)=>o.path.localeCompare(l.path))}async function S(s,t,r=[],h=[],a=[],m,u={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},f=[],o=0){if(o>=fe)return f;let l=t.fs.resolvePath(t.cwd,s);try{let c,w;if(m!==void 0)c=m,w=!m;else{x(u);let d=await t.fs.stat(l);c=d.isFile,w=d.isDirectory}if(c){let d=s.split("/").pop()||s;return h.length>0&&h.some(g=>v(d,g,{stripQuotes:!0}))||r.length>0&&!r.some(g=>v(d,g,{stripQuotes:!0}))||(H(u),f.push({path:s,isFile:!0})),f}if(!w)return f;let R=s.split("/").pop()||s;if(a.length>0&&a.some(d=>v(R,d,{stripQuotes:!0})))return f;if(t.fs.readdirWithFileTypes){x(u);let d=await t.fs.readdirWithFileTypes(l);for(let g of d){if(x(u),g.name.startsWith("."))continue;let $=s==="."?g.name:`${s}/${g.name}`;await S($,t,r,h,a,g.isFile,u,f,o+1)}}else{x(u);let d=await t.fs.readdir(l);for(let g of d){if(x(u),g.startsWith("."))continue;let $=s==="."?g:`${s}/${g}`;await S($,t,r,h,a,void 0,u,f,o+1)}}}catch(c){G(c)}return f}var Fe={name:"fgrep",async execute(s,t){return ae.execute(["-F",...s],t)}},Re={name:"egrep",async execute(s,t){return ae.execute(["-E",...s],t)}},Te={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"}],stdinType:"text",needsArgs:!0},Ce={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},Pe={name:"egrep",flags:[],stdinType:"text",needsArgs:!0};export{ae as a,Fe as b,Re as c,Te as d,Ce as e,Pe as f};
@@ -1,13 +0,0 @@
1
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
2
- import{a as Q,b as F}from"./chunk-CN3HTJTZ.js";import{a as I}from"./chunk-UK4BO5W3.js";import"./chunk-WNH3HOQA.js";import"./chunk-KIGPB52X.js";import"./chunk-K3XJ2WT4.js";import"./chunk-L2UW7DWF.js";import{a as A}from"./chunk-DLL7UR66.js";import{c as E}from"./chunk-AI5LSBJC.js";import{b}from"./chunk-UBTKJ6MG.js";import{d as v}from"./chunk-GN6CQ3J4.js";import{a as D,b as d}from"./chunk-FOCWZZDE.js";import{a as g}from"./chunk-W5DWRFSU.js";import{a as M,b as P}from"./chunk-QAYAQNCG.js";import"./chunk-NCUTH6QL.js";import{fileURLToPath as $}from"node:url";import{Worker as L}from"node:worker_threads";var z={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};function B(r){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(r.length===0)return e;let t=r.findIndex(n=>!n.startsWith("-")||n==="-"||n==="--");for(let n=0;n<(t===-1?r.length:t);n++){let i=r[n];if(i==="-c")return n+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
3
- `,exitCode:2}:(e.code=r[n+1],e.scriptArgs=r.slice(n+2),e);if(i==="-m")return n+1>=r.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
4
- `,exitCode:2}:(e.module=r[n+1],e.scriptArgs=r.slice(n+2),e);if(i==="--version"||i==="-V")return e.showVersion=!0,e;if(i.startsWith("-")&&i!=="-")return{stdout:"",stderr:`python3: unrecognized option '${i}'
5
- `,exitCode:2}}if(t!==-1){let n=r[t];n==="--"?t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)):(e.scriptFile=n,e.scriptArgs=r.slice(t+1))}return e}var C=new WeakMap;function _(r){let e=C.get(r);return e||(e={executionQueue:[],activeExecution:null,poisonedError:null},C.set(r,e)),e}function te(){C=new WeakMap}var R=$(new URL("./worker.js",import.meta.url));function H(r,e){if(!r||typeof r!="object")return{success:!1,error:"Malformed worker response"};let t=r;return typeof t.protocolToken!="string"||t.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:t.type==="security-violation"?{success:!1,error:`Security violation: ${typeof t.violation?.type=="string"?t.violation.type:"unknown"}`}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function w(r){if(r.poisonedError!==null){for(let o of r.executionQueue.splice(0))o.state==="queued"&&(o.state="settled",o.stopBridge(),o.settle({success:!1,error:r.poisonedError}));return}if(r.activeExecution!==null||r.executionQueue.length===0)return;for(;r.executionQueue.length>0&&r.executionQueue[0]?.state!=="queued";)r.executionQueue.shift();if(r.executionQueue.length===0)return;let e=r.executionQueue.shift();if(!e)return;e.state="running",r.activeExecution=e;let t;try{t=b.runTrusted(()=>new L(R,{workerData:e.input}))}catch(o){let s=o instanceof Error?o.message:String(o);e.state="settled",e.settle({success:!1,error:d(s)}),r.activeExecution===e&&(r.activeExecution=null,w(r));return}e.worker=t;let n=!0,i=()=>{n&&(n=!1,t.removeListener("message",x),t.removeListener("error",k),t.removeListener("exit",m))},c=async(o,s)=>{if(!(r.activeExecution?.executionId!==e.executionId||e.state!=="running")){if(e.state="terminating",i(),e.settle(o),s&&!await e.controller.terminate(t)){let p="Worker termination was not acknowledged";e.worker=null,e.state="settled",r.poisonedError=p,r.activeExecution?.executionId===e.executionId&&(r.activeExecution=null),w(r);return}e.worker=null,e.state="settled",r.activeExecution?.executionId===e.executionId&&(r.activeExecution=null,w(r))}};e.cancel=o=>{c(o,!0)};let f=E(e.requireDefenseContext,"python3","worker message callback",o=>{try{e.controller.assertMessageSize(o,"response")}catch(s){c({success:!1,error:d(g(s))},!0);return}c(H(o,e.input.protocolToken),!0)}),l=E(e.requireDefenseContext,"python3","worker error callback",o=>{let s=d(g(o));c({success:!1,error:s},!0)}),u=E(e.requireDefenseContext,"python3","worker exit callback",()=>{c({success:!1,error:"Worker exited unexpectedly"},!1)}),x=o=>{try{f(o)}catch(s){let a=s instanceof Error?s.message:String(s);c({success:!1,error:d(a)},!0)}},k=o=>{try{l(o)}catch(s){let a=s instanceof Error?s.message:String(s);c({success:!1,error:d(a)},!0)}},m=()=>{try{u()}catch(o){let s=o instanceof Error?o.message:String(o);c({success:!1,error:d(s)},!0)}};t.on("message",x),t.on("error",k),t.on("exit",m)}async function U(r,e,t,n=[]){let i=Q(),c=new F(i,e.fs,e.cwd,"python3",e.fetch,e.limits.maxOutputSize),f=e.limits.maxPythonTimeoutMs,l=_(e.fs);if(l.poisonedError!==null)return{stdout:"",stderr:`python3: ${l.poisonedError}
6
- `,exitCode:1};let u=new I({commandName:"python3",timeoutMs:f,signal:e.signal,maxMessageBytes:e.limits.maxWorkerMessageBytes}),x={protocolToken:u.protocolToken,sharedBuffer:i,pythonCode:r,cwd:e.cwd,env:A(e.env),args:n,scriptPath:t,timeoutMs:f,maxFileSize:e.limits.maxStringLength};u.assertMessageSize({...x,sharedBuffer:void 0},"request");let k=new Promise(s=>{let a=!1,p={executionId:Symbol("python3 execution"),input:x,settle:h=>{a||(a=!0,u.close(),s(h))},requireDefenseContext:e.requireDefenseContext,state:"queued",worker:null,controller:u,stopBridge:()=>c.stop?.(),cancel:()=>{}};p.cancel=h=>{if(p.state!=="queued")return;p.state="settled";let y=l.executionQueue.indexOf(p);y!==-1&&l.executionQueue.splice(y,1),p.settle(h),w(l)};let W=E(e.requireDefenseContext,"python3","worker cancellation callback",h=>{c.stop?.(),p.cancel({success:!1,error:h==="abort"?u.abortMessage():u.timeoutMessage()})}),O=h=>{try{W(h)}catch(y){let T=y instanceof Error?y.message:String(y);p.cancel({success:!1,error:d(T)})}};u.arm(O),u.isCanceled||(l.executionQueue.push(p),w(l))}),[m,o]=await Promise.all([c.run(f).catch(s=>({stdout:"",stderr:`python3: bridge error: ${d(g(s))}
7
- `,exitCode:1})),k.catch(s=>({success:!1,error:d(g(s))}))]);if(!o.success&&o.error){let s=d(o.error),a=o.error===u.timeoutMessage()||o.error===u.abortMessage();return{stdout:m.stdout,stderr:`${m.stderr}python3: ${s}
8
- `,exitCode:m.exitCode||(a?124:1)}}return{...m}}var N={name:"python3",async execute(r,e){if(P(r))return M(z);let t=B(r);if("exitCode"in t)return t;if(t.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
9
- `,stderr:"",exitCode:0};let n,i;if(t.code!==null)n=t.code,i="-c";else if(t.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(t.module))return{stdout:"",stderr:`python3: No module named '${t.module.slice(0,200)}'
10
- `,exitCode:1};n=`import runpy; runpy.run_module('${t.module}', run_name='__main__')`,i=t.module}else if(t.scriptFile==="-")n=v(e.stdin),i="-";else if(t.scriptFile!==null){let c=e.fs.resolvePath(e.cwd,t.scriptFile);if(!await e.fs.exists(c))return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': [Errno 2] No such file or directory
11
- `,exitCode:2};try{n=await e.fs.readFile(c),i=t.scriptFile}catch(f){let l=D(f.message);return{stdout:"",stderr:`python3: can't open file '${t.scriptFile}': ${l}
12
- `,exitCode:2}}}else if(v(e.stdin).trim())n=v(e.stdin),i="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
13
- `,exitCode:2};return U(n,e,i,t.scriptArgs)}},oe={name:"python",async execute(r,e){return N.execute(r,e)}};export{te as _resetExecutionQueue,N as python3Command,oe as pythonCommand};