gemkit-cli 0.2.2 → 0.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.
- package/README.md +152 -5
- package/dist/commands/agent/index.d.ts +9 -0
- package/dist/commands/agent/index.js +1329 -0
- package/dist/commands/cache/index.d.ts +5 -0
- package/dist/commands/cache/index.js +43 -0
- package/dist/commands/catalog/index.d.ts +2 -0
- package/dist/commands/catalog/index.js +57 -0
- package/dist/commands/config/index.d.ts +7 -0
- package/dist/commands/config/index.js +122 -0
- package/dist/commands/convert/index.d.ts +8 -0
- package/dist/commands/convert/index.js +391 -0
- package/dist/commands/doctor/index.d.ts +2 -0
- package/dist/commands/doctor/index.js +243 -0
- package/dist/commands/extension/index.d.ts +5 -0
- package/dist/commands/extension/index.js +52 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +37 -0
- package/dist/commands/init/index.d.ts +6 -0
- package/dist/commands/init/index.js +345 -0
- package/dist/commands/new/index.d.ts +5 -0
- package/dist/commands/new/index.js +49 -0
- package/dist/commands/office/index.d.ts +5 -0
- package/dist/commands/office/index.js +283 -0
- package/dist/commands/paste/index.d.ts +10 -0
- package/dist/commands/paste/index.js +533 -0
- package/dist/commands/plan/index.d.ts +8 -0
- package/dist/commands/plan/index.js +247 -0
- package/dist/commands/session/index.d.ts +8 -0
- package/dist/commands/session/index.js +289 -0
- package/dist/commands/tokens/index.d.ts +6 -0
- package/dist/commands/tokens/index.js +148 -0
- package/dist/commands/update/index.d.ts +26 -0
- package/dist/commands/update/index.js +199 -0
- package/dist/commands/versions/index.d.ts +5 -0
- package/dist/commands/versions/index.js +39 -0
- package/dist/domains/agent/index.d.ts +8 -0
- package/dist/domains/agent/index.js +8 -0
- package/dist/domains/agent/mappings.d.ts +32 -0
- package/dist/domains/agent/mappings.js +164 -0
- package/dist/domains/agent/profile.d.ts +26 -0
- package/dist/domains/agent/profile.js +225 -0
- package/dist/domains/agent/pty-context.d.ts +11 -0
- package/dist/domains/agent/pty-context.js +83 -0
- package/dist/domains/agent/pty-providers.d.ts +18 -0
- package/dist/domains/agent/pty-providers.js +66 -0
- package/dist/domains/agent/pty-session.d.ts +33 -0
- package/dist/domains/agent/pty-session.js +82 -0
- package/dist/domains/agent/pty-types.d.ts +127 -0
- package/dist/domains/agent/pty-types.js +4 -0
- package/dist/domains/agent/search.d.ts +45 -0
- package/dist/domains/agent/search.js +614 -0
- package/dist/domains/agent/types.d.ts +78 -0
- package/dist/domains/agent/types.js +5 -0
- package/dist/domains/agent-office/documents-scanner.d.ts +9 -0
- package/dist/domains/agent-office/documents-scanner.js +143 -0
- package/dist/domains/agent-office/event-emitter.d.ts +43 -0
- package/dist/domains/agent-office/event-emitter.js +86 -0
- package/dist/domains/agent-office/file-watcher.d.ts +40 -0
- package/dist/domains/agent-office/file-watcher.js +173 -0
- package/dist/domains/agent-office/icons.d.ts +11 -0
- package/dist/domains/agent-office/icons.js +36 -0
- package/dist/domains/agent-office/index.d.ts +12 -0
- package/dist/domains/agent-office/index.js +20 -0
- package/dist/domains/agent-office/renderer/web/assets.d.ts +11 -0
- package/dist/domains/agent-office/renderer/web/assets.js +3419 -0
- package/dist/domains/agent-office/renderer/web/server.d.ts +42 -0
- package/dist/domains/agent-office/renderer/web/server.js +228 -0
- package/dist/domains/agent-office/renderer/web.d.ts +30 -0
- package/dist/domains/agent-office/renderer/web.js +111 -0
- package/dist/domains/agent-office/session-bridge.d.ts +23 -0
- package/dist/domains/agent-office/session-bridge.js +171 -0
- package/dist/domains/agent-office/state-machine.d.ts +5 -0
- package/dist/domains/agent-office/state-machine.js +82 -0
- package/dist/domains/agent-office/types.d.ts +91 -0
- package/dist/domains/agent-office/types.js +4 -0
- package/dist/domains/cache/index.d.ts +1 -0
- package/dist/domains/cache/index.js +1 -0
- package/dist/domains/cache/manager.d.ts +22 -0
- package/dist/domains/cache/manager.js +84 -0
- package/dist/domains/config/index.d.ts +5 -0
- package/dist/domains/config/index.js +5 -0
- package/dist/domains/config/manager.d.ts +24 -0
- package/dist/domains/config/manager.js +85 -0
- package/dist/domains/config/schema.d.ts +17 -0
- package/dist/domains/config/schema.js +96 -0
- package/dist/domains/convert/converter.d.ts +78 -0
- package/dist/domains/convert/converter.js +471 -0
- package/dist/domains/convert/index.d.ts +5 -0
- package/dist/domains/convert/index.js +5 -0
- package/dist/domains/convert/types.d.ts +88 -0
- package/dist/domains/convert/types.js +18 -0
- package/dist/domains/github/download.d.ts +12 -0
- package/dist/domains/github/download.js +51 -0
- package/dist/domains/github/index.d.ts +2 -0
- package/dist/domains/github/index.js +2 -0
- package/dist/domains/github/releases.d.ts +16 -0
- package/dist/domains/github/releases.js +68 -0
- package/dist/domains/installation/conflict.d.ts +13 -0
- package/dist/domains/installation/conflict.js +38 -0
- package/dist/domains/installation/file-sync.d.ts +16 -0
- package/dist/domains/installation/file-sync.js +77 -0
- package/dist/domains/installation/index.d.ts +3 -0
- package/dist/domains/installation/index.js +3 -0
- package/dist/domains/installation/metadata.d.ts +20 -0
- package/dist/domains/installation/metadata.js +52 -0
- package/dist/domains/plan/index.d.ts +2 -0
- package/dist/domains/plan/index.js +2 -0
- package/dist/domains/plan/resolver.d.ts +24 -0
- package/dist/domains/plan/resolver.js +164 -0
- package/dist/domains/plan/types.d.ts +13 -0
- package/dist/domains/plan/types.js +4 -0
- package/dist/domains/session/env.d.ts +51 -0
- package/dist/domains/session/env.js +118 -0
- package/dist/domains/session/index.d.ts +8 -0
- package/dist/domains/session/index.js +8 -0
- package/dist/domains/session/manager.d.ts +56 -0
- package/dist/domains/session/manager.js +205 -0
- package/dist/domains/session/paths.d.ts +6 -0
- package/dist/domains/session/paths.js +6 -0
- package/dist/domains/session/types.d.ts +121 -0
- package/dist/domains/session/types.js +5 -0
- package/dist/domains/session/writer.d.ts +82 -0
- package/dist/domains/session/writer.js +431 -0
- package/dist/domains/tokens/index.d.ts +5 -0
- package/dist/domains/tokens/index.js +5 -0
- package/dist/domains/tokens/pricing.d.ts +38 -0
- package/dist/domains/tokens/pricing.js +129 -0
- package/dist/domains/tokens/scanner.d.ts +42 -0
- package/dist/domains/tokens/scanner.js +168 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +86 -57
- package/dist/services/aipty.d.ts +76 -0
- package/dist/services/aipty.js +276 -0
- package/dist/services/archive.d.ts +22 -0
- package/dist/services/archive.js +53 -0
- package/dist/services/auto-update.d.ts +26 -0
- package/dist/services/auto-update.js +117 -0
- package/dist/services/hash.d.ts +36 -0
- package/dist/services/hash.js +63 -0
- package/dist/services/logger.d.ts +28 -0
- package/dist/services/logger.js +102 -0
- package/dist/services/music.d.ts +67 -0
- package/dist/services/music.js +290 -0
- package/dist/services/npm.d.ts +22 -0
- package/dist/services/npm.js +65 -0
- package/dist/services/pty-client.d.ts +66 -0
- package/dist/services/pty-client.js +154 -0
- package/dist/services/pty-server.d.ts +102 -0
- package/dist/services/pty-server.js +613 -0
- package/dist/types/index.d.ts +155 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/colors.d.ts +43 -0
- package/dist/utils/colors.js +98 -0
- package/dist/utils/errors.d.ts +24 -0
- package/dist/utils/errors.js +56 -0
- package/dist/utils/paths.d.ts +46 -0
- package/dist/utils/paths.js +89 -0
- package/dist/utils/platform.d.ts +11 -0
- package/dist/utils/platform.js +31 -0
- package/package.json +55 -54
package/dist/index.js
CHANGED
|
@@ -1,53 +1,82 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var FA=Object.create;var qc=Object.defineProperty;var QA=Object.getOwnPropertyDescriptor;var JA=Object.getOwnPropertyNames;var bA=Object.getPrototypeOf,BA=Object.prototype.hasOwnProperty;var Ln=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ZA=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of JA(e))!BA.call(t,r)&&r!==i&&qc(t,r,{get:()=>e[r],enumerable:!(n=QA(e,r))||n.enumerable});return t};var _n=(t,e,i)=>(i=t!=null?FA(bA(t)):{},ZA(e||!t||!t.__esModule?qc(i,"default",{value:t,enumerable:!0}):i,t));var ml=Ln((ff,G7)=>{G7.exports={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\u{1F604} ","\u{1F61D} "]},monkey:{interval:300,frames:["\u{1F648} ","\u{1F648} ","\u{1F649} ","\u{1F64A} "]},hearts:{interval:100,frames:["\u{1F49B} ","\u{1F499} ","\u{1F49C} ","\u{1F49A} ","\u2764\uFE0F "]},clock:{interval:100,frames:["\u{1F55B} ","\u{1F550} ","\u{1F551} ","\u{1F552} ","\u{1F553} ","\u{1F554} ","\u{1F555} ","\u{1F556} ","\u{1F557} ","\u{1F558} ","\u{1F559} ","\u{1F55A} "]},earth:{interval:180,frames:["\u{1F30D} ","\u{1F30E} ","\u{1F30F} "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\u{1F311} ","\u{1F312} ","\u{1F313} ","\u{1F314} ","\u{1F315} ","\u{1F316} ","\u{1F317} ","\u{1F318} "]},runner:{interval:140,frames:["\u{1F6B6} ","\u{1F3C3} "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\u{1F324} ","\u26C5\uFE0F ","\u{1F325} ","\u2601\uFE0F ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u26C8 ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u2601\uFE0F ","\u{1F325} ","\u26C5\uFE0F ","\u{1F324} ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\u{1F332}","\u{1F384}"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\u{1F918} ","\u{1F91F} ","\u{1F596} ","\u270B ","\u{1F91A} ","\u{1F446} "]},fistBump:{interval:80,frames:["\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u3000\u{1F91C}\u3000\u3000\u{1F91B}\u3000 ","\u3000\u3000\u{1F91C}\u{1F91B}\u3000\u3000 ","\u3000\u{1F91C}\u2728\u{1F91B}\u3000\u3000 ","\u{1F91C}\u3000\u2728\u3000\u{1F91B}\u3000 "]},soccerHeader:{interval:80,frames:[" \u{1F9D1}\u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F\u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} "]},mindblown:{interval:160,frames:["\u{1F610} ","\u{1F610} ","\u{1F62E} ","\u{1F62E} ","\u{1F626} ","\u{1F626} ","\u{1F627} ","\u{1F627} ","\u{1F92F} ","\u{1F4A5} ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\u{1F508} ","\u{1F509} ","\u{1F50A} ","\u{1F509} "]},orangePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} "]},bluePulse:{interval:100,frames:["\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},orangeBluePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} ","\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},timeTravel:{interval:100,frames:["\u{1F55B} ","\u{1F55A} ","\u{1F559} ","\u{1F558} ","\u{1F557} ","\u{1F556} ","\u{1F555} ","\u{1F554} ","\u{1F553} ","\u{1F552} ","\u{1F551} ","\u{1F550} "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]}}});var js=Ln((hf,Il)=>{"use strict";var lr=Object.assign({},ml()),El=Object.keys(lr);Object.defineProperty(lr,"random",{get(){let t=Math.floor(Math.random()*El.length),e=El[t];return lr[e]}});Il.exports=lr});var zl=Ln((Of,Rl)=>{Rl.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var cv=Ln((pz,ec)=>{var Go=process||{},sv=Go.argv||[],xo=Go.env||{},EE=!(xo.NO_COLOR||sv.includes("--no-color"))&&(!!xo.FORCE_COLOR||sv.includes("--color")||Go.platform==="win32"||(Go.stdout||{}).isTTY&&xo.TERM!=="dumb"||!!xo.CI),IE=(t,e,i=t)=>n=>{let r=""+n,o=r.indexOf(e,t.length);return~o?t+pE(r,e,i,o)+e:t+r+e},pE=(t,e,i,n)=>{let r="",o=0;do r+=t.substring(o,n)+i,o=n+e.length,n=t.indexOf(e,o);while(~n);return r+t.substring(o)},av=(t=EE)=>{let e=t?IE:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};ec.exports=av();ec.exports.createColors=av});import{EventEmitter as PA}from"events";function as(t){return t==null?[]:Array.isArray(t)?t:[t]}function qA(t,e,i,n){var r,o=t[e],s=~n.string.indexOf(e)?i==null||i===!0?"":String(i):typeof i=="boolean"?i:~n.boolean.indexOf(e)?i==="false"?!1:i==="true"||(t._.push((r=+i,r*0===0?r:i)),!!i):(r=+i,r*0===0?r:i);t[e]=o==null?s:Array.isArray(o)?o.concat(s):[o,s]}function yA(t,e){t=t||[],e=e||{};var i,n,r,o,s,c={_:[]},l=0,v=0,A=0,u=t.length;let I=e.alias!==void 0,E=e.unknown!==void 0,f=e.default!==void 0;if(e.alias=e.alias||{},e.string=as(e.string),e.boolean=as(e.boolean),I)for(i in e.alias)for(n=e.alias[i]=as(e.alias[i]),l=0;l<n.length;l++)(e.alias[n[l]]=n.concat(i)).splice(l,1);for(l=e.boolean.length;l-- >0;)for(n=e.alias[e.boolean[l]]||[],v=n.length;v-- >0;)e.boolean.push(n[v]);for(l=e.string.length;l-- >0;)for(n=e.alias[e.string[l]]||[],v=n.length;v-- >0;)e.string.push(n[v]);if(f){for(i in e.default)if(o=typeof e.default[i],n=e.alias[i]=e.alias[i]||[],e[o]!==void 0)for(e[o].push(i),l=0;l<n.length;l++)e[o].push(n[l])}let R=E?Object.keys(e.alias):[];for(l=0;l<u;l++){if(r=t[l],r==="--"){c._=c._.concat(t.slice(++l));break}for(v=0;v<r.length&&r.charCodeAt(v)===45;v++);if(v===0)c._.push(r);else if(r.substring(v,v+3)==="no-"){if(o=r.substring(v+3),E&&!~R.indexOf(o))return e.unknown(r);c[o]=!1}else{for(A=v+1;A<r.length&&r.charCodeAt(A)!==61;A++);for(o=r.substring(v,A),s=r.substring(++A)||l+1===u||(""+t[l+1]).charCodeAt(0)===45||t[++l],n=v===2?[o]:o,A=0;A<n.length;A++){if(o=n[A],E&&!~R.indexOf(o))return e.unknown("-".repeat(v)+o);qA(c,o,A+1<n.length||s,e)}}}if(f)for(i in e.default)c[i]===void 0&&(c[i]=e.default[i]);if(I)for(i in c)for(n=e.alias[i]||[];n.length>0;)c[n.shift()]=c[i];return c}var wc=t=>t.replace(/[<[].+/,"").trim(),DA=t=>{let e=/<([^>]+)>/g,i=/\[([^\]]+)\]/g,n=[],r=c=>{let l=!1,v=c[1];return v.startsWith("...")&&(v=v.slice(3),l=!0),{required:c[0].startsWith("<"),value:v,variadic:l}},o;for(;o=e.exec(t);)n.push(r(o));let s;for(;s=i.exec(t);)n.push(r(s));return n},wA=t=>{let e={alias:{},boolean:[]};for(let[i,n]of t.entries())n.names.length>1&&(e.alias[n.names[0]]=n.names.slice(1)),n.isBoolean&&(n.negated&&t.some((o,s)=>s!==i&&o.names.some(c=>n.names.includes(c))&&typeof o.required=="boolean")||e.boolean.push(n.names[0]));return e},yc=t=>t.sort((e,i)=>e.length>i.length?-1:1)[0],Dc=(t,e)=>t.length>=e?t:`${t}${" ".repeat(e-t.length)}`,TA=t=>t.replace(/([a-z])-([a-z])/g,(e,i,n)=>i+n.toUpperCase()),XA=(t,e,i)=>{let n=0,r=e.length,o=t,s;for(;n<r;++n)s=o[e[n]],o=o[e[n]]=n===r-1?i:s??(~e[n+1].indexOf(".")||!(+e[n+1]>-1)?{}:[])},HA=(t,e)=>{for(let i of Object.keys(e)){let n=e[i];n.shouldTransform&&(t[i]=Array.prototype.concat.call([],t[i]),typeof n.transformFunction=="function"&&(t[i]=t[i].map(n.transformFunction)))}},LA=t=>{let e=/([^\\\/]+)$/.exec(t);return e?e[1]:""},Tc=t=>t.split(".").map((e,i)=>i===0?TA(e):e).join("."),Hi=class extends Error{constructor(e){super(e),this.name=this.constructor.name,typeof Error.captureStackTrace=="function"?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}},cs=class{constructor(e,i,n){this.rawName=e,this.description=i,this.config=Object.assign({},n),e=e.replace(/\.\*/g,""),this.negated=!1,this.names=wc(e).split(",").map(r=>{let o=r.trim().replace(/^-{1,2}/,"");return o.startsWith("no-")&&(this.negated=!0,o=o.replace(/^no-/,"")),Tc(o)}).sort((r,o)=>r.length>o.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null&&(this.config.default=!0),e.includes("<")?this.required=!0:e.includes("[")?this.required=!1:this.isBoolean=!0}},_A=process.argv,$A=`${process.platform}-${process.arch} node-${process.version}`,er=class{constructor(e,i,n={},r){this.rawName=e,this.description=i,this.config=n,this.cli=r,this.options=[],this.aliasNames=[],this.name=wc(e),this.args=DA(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,i="-v, --version"){return this.versionNumber=e,this.option(i,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,i,n){let r=new cs(e,i,n);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof tr}hasOption(e){return e=e.split(".")[0],this.options.find(i=>i.names.includes(e))}outputHelp(){let{name:e,commands:i}=this.cli,{versionNumber:n,options:r,helpCallback:o}=this.cli.globalCommand,s=[{body:`${e}${n?`/${n}`:""}`}];if(s.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&i.length>0){let v=yc(i.map(A=>A.rawName));s.push({title:"Commands",body:i.map(A=>` ${Dc(A.rawName,v.length)} ${A.description}`).join(`
|
|
3
|
-
`)})
|
|
4
|
-
`)})}let l=this.isGlobalCommand?r:[...this.options,...r||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(l=l.filter(v=>v.name!=="version")),l.length>0){let v=yc(l.map(A=>A.rawName));s.push({title:"Options",body:l.map(A=>` ${Dc(A.rawName,v.length)} ${A.description} ${A.config.default===void 0?"":`(default: ${A.config.default})`}`).join(`
|
|
5
|
-
`)})}
|
|
6
|
-
`)}),o
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`)
|
|
2
|
+
var bA=Object.create;var La=Object.defineProperty;var PA=Object.getOwnPropertyDescriptor;var QA=Object.getOwnPropertyNames;var BA=Object.getPrototypeOf,JA=Object.prototype.hasOwnProperty;var ZA=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Y=(t,e)=>()=>(t&&(e=t(t=0)),e);var ps=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),nm=(t,e)=>{for(var i in e)La(t,i,{get:e[i],enumerable:!0})},yA=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of QA(e))!JA.call(t,r)&&r!==i&&La(t,r,{get:()=>e[r],enumerable:!(n=PA(e,r))||n.enumerable});return t};var As=(t,e,i)=>(i=t!=null?bA(BA(t)):{},yA(e||!t||!t.__esModule?La(i,"default",{value:t,enumerable:!0}):i,t));var Gm=ps((_R,Md)=>{Md.exports={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\u{1F604} ","\u{1F61D} "]},monkey:{interval:300,frames:["\u{1F648} ","\u{1F648} ","\u{1F649} ","\u{1F64A} "]},hearts:{interval:100,frames:["\u{1F49B} ","\u{1F499} ","\u{1F49C} ","\u{1F49A} ","\u2764\uFE0F "]},clock:{interval:100,frames:["\u{1F55B} ","\u{1F550} ","\u{1F551} ","\u{1F552} ","\u{1F553} ","\u{1F554} ","\u{1F555} ","\u{1F556} ","\u{1F557} ","\u{1F558} ","\u{1F559} ","\u{1F55A} "]},earth:{interval:180,frames:["\u{1F30D} ","\u{1F30E} ","\u{1F30F} "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\u{1F311} ","\u{1F312} ","\u{1F313} ","\u{1F314} ","\u{1F315} ","\u{1F316} ","\u{1F317} ","\u{1F318} "]},runner:{interval:140,frames:["\u{1F6B6} ","\u{1F3C3} "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\u{1F324} ","\u26C5\uFE0F ","\u{1F325} ","\u2601\uFE0F ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u26C8 ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u2601\uFE0F ","\u{1F325} ","\u26C5\uFE0F ","\u{1F324} ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\u{1F332}","\u{1F384}"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\u{1F918} ","\u{1F91F} ","\u{1F596} ","\u270B ","\u{1F91A} ","\u{1F446} "]},fistBump:{interval:80,frames:["\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u3000\u{1F91C}\u3000\u3000\u{1F91B}\u3000 ","\u3000\u3000\u{1F91C}\u{1F91B}\u3000\u3000 ","\u3000\u{1F91C}\u2728\u{1F91B}\u3000\u3000 ","\u{1F91C}\u3000\u2728\u3000\u{1F91B}\u3000 "]},soccerHeader:{interval:80,frames:[" \u{1F9D1}\u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F\u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} "]},mindblown:{interval:160,frames:["\u{1F610} ","\u{1F610} ","\u{1F62E} ","\u{1F62E} ","\u{1F626} ","\u{1F626} ","\u{1F627} ","\u{1F627} ","\u{1F92F} ","\u{1F4A5} ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\u{1F508} ","\u{1F509} ","\u{1F50A} ","\u{1F509} "]},orangePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} "]},bluePulse:{interval:100,frames:["\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},orangeBluePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} ","\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},timeTravel:{interval:100,frames:["\u{1F55B} ","\u{1F55A} ","\u{1F559} ","\u{1F558} ","\u{1F557} ","\u{1F556} ","\u{1F555} ","\u{1F554} ","\u{1F553} ","\u{1F552} ","\u{1F551} ","\u{1F550} "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]}}});var pc=ps(($R,Ym)=>{"use strict";var Ss=Object.assign({},Gm()),Mm=Object.keys(Ss);Object.defineProperty(Ss,"random",{get(){let t=Math.floor(Math.random()*Mm.length),e=Mm[t];return Ss[e]}});Ym.exports=Ss});var km=ps((vz,Km)=>{Km.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});import{homedir as Fm}from"os";import{join as ne}from"path";function Ms(t=process.cwd()){return ne(t,mn)}function xc(t=process.cwd()){return ne(t,mn,Qd)}function Sc(t=process.cwd()){return ne(t,mn,Bd)}function Wi(t=process.cwd()){return ne(t,mn,Jd)}function ar(t=process.cwd()){return ne(t,mn,"agents")}function Ci(t=process.cwd()){return ne(t,mn,"extensions")}function vn(t=process.cwd()){return ne(t,Pd)}function ge(t){return t?t.replace(/^[A-Za-z]:/,e=>e.replace(":","")).replace(/[\\/]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""):""}function xt(t){return ne(zc,t)}function Oi(t,e){return ne(xt(t),`gk-session-${e}.json`)}function cr(t,e){return ne(xt(t),`gk-project-${e}.json`)}var bd,zc,jc,Kz,un,kz,mn,Pd,Qd,Bd,Jd,k=Y(()=>{"use strict";bd=ne(Fm(),".gemkit"),zc=ne(bd,"projects"),jc=ne(Fm(),".gemini"),Kz=ne(jc,"config"),un=ne(jc,"cache"),kz=ne(jc,"tmp"),mn=".gemini",Pd="plans",Qd=".gk.json",Bd="metadata.json",Jd=".env"});var Rv=ps((LS,ql)=>{var Bo=process||{},Iv=Bo.argv||[],Qo=Bo.env||{},hh=!(Qo.NO_COLOR||Iv.includes("--no-color"))&&(!!Qo.FORCE_COLOR||Iv.includes("--color")||Bo.platform==="win32"||(Bo.stdout||{}).isTTY&&Qo.TERM!=="dumb"||!!Qo.CI),gh=(t,e,i=t)=>n=>{let r=""+n,s=r.indexOf(e,t.length);return~s?t+Ih(r,e,i,s)+e:t+r+e},Ih=(t,e,i,n)=>{let r="",s=0;do r+=t.substring(s,n)+i,s=n+e.length,n=t.indexOf(e,s);while(~n);return r+t.substring(s)},Ev=(t=hh)=>{let e=t?gh:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};ql.exports=Ev();ql.exports.createColors=Ev});function mi(t,e){return e==="claude"?lg.includes(t)?t:ag[t]||"sonnet":t.startsWith("gemini-")?t:cg[t]||"gemini-3-flash-preview"}function vg(t){return/^[A-Z]/.test(t)}function pg(t){return t.includes("_")||t.startsWith("gemini")}function Ag(t,e){let i=t.match(/^([^(]+)(\(.*\))?$/),n=i?.[1]||t,r=i?.[2]||"";if(e==="claude"){if(vg(n))return t;let s=ug[n];return s?n==="run_shell_command"&&r==="(*)"?s:s+r:t}else{if(pg(n))return t;let s=mg[n];return s?n==="Bash"&&!r?"run_shell_command(*)":s+r:t}}function vi(t,e){let i=t.map(n=>Ag(n,e)).filter(Boolean);return[...new Set(i)]}function kv(t){return t==="claude"?[".claude/agents",".gemini/agents"]:[".gemini/agents",".claude/agents"]}var ag,cg,lg,ug,mg,Nn=Y(()=>{"use strict";ag={"gemini-3-pro-preview":"opus","gemini-2.5-pro":"opus","gemini-3-flash-preview":"sonnet","gemini-2.5-flash":"sonnet","gemini-2.5-flash-lite":"haiku"},cg={opus:"gemini-3-pro-preview",sonnet:"gemini-3-flash-preview",haiku:"gemini-2.5-flash-lite"},lg=["haiku","sonnet","opus"];ug={list_directory:"Bash",read_file:"Read",write_file:"Write",glob:"Glob",search_file_content:"Grep",replace:"Edit",run_shell_command:"Bash",web_fetch:"WebFetch",google_web_search:"WebSearch",save_memory:"TodoWrite",write_todos:"TodoWrite"},mg={Read:"read_file",Write:"write_file",Edit:"replace",Bash:"run_shell_command",Glob:"glob",Grep:"search_file_content",WebFetch:"web_fetch",WebSearch:"google_web_search",TodoWrite:"write_todos",Task:""}});import{existsSync as yo,readFileSync as dg,readdirSync as fg}from"fs";import{join as wl,basename as hg}from"path";function Fv(t,e){let i=ar(e),n=wl(i,`${t}.md`);return yo(n)?Dl(n):null}function qo(t){let e=ar(t);if(!yo(e))return[];let i=fg(e).filter(r=>r.endsWith(".md")),n=[];for(let r of i){let s=wl(e,r),o=Dl(s);o&&n.push(o)}return n}function gg(t){let e=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!e)return null;let i={};for(let n of e[1].split(/\r?\n/)){let r=n.indexOf(":");if(r===-1)continue;let s=n.slice(0,r).trim(),o=n.slice(r+1).trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),i[s]=o}return i}function Vv(t){if(!t)return[];let e=t.trim();return e.startsWith("[")&&e.endsWith("]")&&(e=e.slice(1,-1)),e.split(",").map(i=>i.trim().replace(/['"]/g,"")).filter(Boolean)}function Nv(t){if(!t)return[];let e=t.trim();return e.startsWith("[")&&e.endsWith("]")&&(e=e.slice(1,-1)),e.split(",").map(i=>i.trim().replace(/['"]/g,"")).filter(Boolean)}function Dl(t){if(!yo(t))return null;let e=dg(t,"utf-8"),i=hg(t,".md"),n="",r="gemini-2.5-flash",s=[],o=[],c=gg(e),l=e;if(c)c.description&&(n=c.description),c.model&&(r=c.model),s=Vv(c.skills),o=Nv(c.tools),l=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"").trim();else{let u=e.split(`
|
|
3
|
+
`);for(let A of u){if(A.startsWith("# ")){n=A.substring(2).trim();break}if(A.trim()&&!A.startsWith("#")){n=A.trim();break}}let m=e.match(/model:\s*(.+)/i);m&&(r=m[1].trim());let p=e.match(/skills:\s*(.+)/i);p&&(s=Vv(p[1]));let d=e.match(/tools:\s*(.+)/i);d&&(o=Nv(d[1]))}return{name:i,description:n,model:r,skills:s,tools:o,content:l,filePath:t}}function Fn(t,e,i){let n=i||process.cwd(),r=kv(e);for(let s of r){let o=wl(n,s,`${t}.md`);if(yo(o)){let c=Dl(o);if(c)return s===r[0]||(c.model=mi(c.model,e),c.tools&&c.tools.length>0&&(c.tools=vi(c.tools,e))),c}}return null}var Xr=Y(()=>{"use strict";k();Nn()});import{existsSync as _i,readFileSync as Hl,readdirSync as Ig}from"fs";import{join as Hr}from"path";function zg(t){let e=[],i="",n=!1;for(let r=0;r<t.length;r++){let s=t[r];s==='"'?n=!n:s===","&&!n?(e.push(i),i=""):i+=s}return e.push(i),e}function _l(t){if(!_i(t))return[];let i=Hl(t,"utf-8").trim().split(`
|
|
4
|
+
`);if(i.length<2)return[];let n=i[0].split(",").map(s=>s.trim()),r=[];for(let s=1;s<i.length;s++){let o=zg(i[s]),c={};n.forEach((l,u)=>{c[l]=o[u]?.trim()||""}),r.push(c)}return r}function jg(t,e,i,n,r){if(!_i(t))return[];let s=_l(t),o=s.map(m=>e.map(p=>String(m[p]||"")).join(" ")),c=new wo;c.fit(o);let l=c.score(n),u=[];for(let[m,p]of l.slice(0,r))if(p>0){let d=s[m],A={};for(let f of i)f in d&&(A[f]=d[f]);A._score=Math.round(p*1e4)/1e4,u.push(A)}return u}function $l(){let t=Hr(Ll,"synonyms.csv");if(!_i(t))return new Map;let e=_l(t),i=new Map;for(let n of e){let r=(n.word||"").toLowerCase().trim(),s=(n.synonyms||"").toLowerCase().trim();r&&s&&i.set(r,s.split(",").map(o=>o.trim()))}return i}function Qv(t,e){e||(e=$l());let i=t.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/),n=new Set(i);for(let r of i){let s=e.get(r);s&&s.forEach(o=>n.add(o))}return Array.from(n).join(" ")}function eu(t){let e=t.toLowerCase();for(let[i,n]of Object.entries(Eg))for(let r of n)if(e.includes(r))return i;return"standard"}function tu(t){let e=t.toLowerCase(),n=e.split(/\s+/)[0]||"",r=[[/system architecture/,"plan"],[/design.*architecture/,"plan"],[/architect.*system/,"plan"],[/create.*roadmap/,"plan"],[/build.*roadmap/,"plan"],[/create.*strategy/,"plan"],[/stunning/,"design"],[/gorgeous/,"design"],[/beautiful.*ui/,"design"],[/beautiful.*component/,"design"],[/beautiful.*page/,"design"],[/write.*documentation/,"docs"],[/write.*docs/,"docs"],[/create.*documentation/,"docs"],[/research.*codebase/,"research"],[/deep research/,"research"]];for(let[u,m]of r)if(typeof u=="string"?e.includes(u):u.test(e))return m;let s={implement:"execute",build:"execute",create:"execute",add:"execute",make:"execute",code:"execute",develop:"execute",write:"execute",setup:"execute",configure:"execute",test:"test",verify:"test",validate:"test",debug:"debug",fix:"debug",troubleshoot:"debug",review:"review",audit:"review",document:"docs",plan:"plan",design:"design",research:"research",analyze:"research",investigate:"research"};if(n in s)return s[n];let o=[["best practices","research"],["how does","research"],["how do","research"],["what is","research"],["why is","research"],["compare","research"],["investigate","research"],["research","research"],["understand","research"],["system architecture","plan"],["implementation plan","plan"],["roadmap","plan"],["strategy for","plan"],["blueprint","plan"],["fix the","debug"],["debug the","debug"],["not working","debug"],["is broken","debug"],["error in","debug"],["fix bug","debug"],["test the","test"],["run tests","test"],["verify the","test"],["review the","review"],["audit the","review"],["check code","review"],["document the","docs"],["write docs","docs"],["api documentation","docs"]];for(let[u,m]of o)if(e.includes(u))return m;let c={debug:["fix","debug","troubleshoot","error","issue","bug","broken","failing","crash"],review:["review","audit","assess","check code","pr review","security audit"],test:["test","verify","validate","qa","coverage","unit test","e2e test"],design:["beautiful","stunning","gorgeous","ui design","ux design","mockup","layout"],docs:["document","documentation","readme","api docs","technical writing"],git:["commit","push","pull","merge","branch","git","stage"],manage:["status","progress","track","milestone","sprint"],plan:["plan","architect","roadmap","strategy","architecture design"],execute:["implement","build","create","add","make","code","develop"],research:["research","investigate","explore","study","analyze","examine","learn"]},l={};for(let[u,m]of Object.entries(c)){let p=m.filter(d=>e.includes(d)).length;p>0&&(l[u]=p)}return Object.keys(l).length>0?Object.entries(l).sort((u,m)=>m[1]-u[1])[0][0]:"execute"}function iu(t){let e=t.toLowerCase(),i=[["flutter","mobile"],["react native","mobile"],["swift","mobile"],["kotlin","mobile"],["ios app","mobile"],["android app","mobile"],["next.js","fullstack"],["nextjs","fullstack"],["nuxt","fullstack"],["sveltekit","fullstack"],["remix","fullstack"],["server component","fullstack"],["openai","ai"],["anthropic","ai"],["claude","ai"],["langchain","ai"],["llm","ai"],["chatbot","ai"],["rag","ai"],["embedding","ai"],["gpt","ai"],["angular","frontend"],["react","frontend"],["vue","frontend"],["svelte","frontend"],["tailwind","frontend"],["nestjs","backend"],["express","backend"],["fastify","backend"],["hono","backend"],["fastapi","backend"],["websocket","backend"],["shopify","ecommerce"],["product catalog","ecommerce"],["checkout flow","ecommerce"],["stripe","payment"],["paypal","payment"],["subscription","payment"],["billing","payment"],["oauth","auth"],["authentication","auth"],["login","auth"],["signup","auth"],["prisma","database"],["drizzle","database"],["postgresql","database"],["mongodb","database"],["mysql","database"],["pdf","media"],["image","media"],["video","media"],["audio","media"],["codebase","codebase"],["repository","codebase"]];for(let[s,o]of i)if(e.includes(s))return o;let n={auth:["login","signup","authentication","oauth","jwt","session","password","2fa"],payment:["payment","checkout","billing","stripe","subscription","invoice","cart"],database:["database","sql","query","migration","schema","prisma","postgresql"],frontend:["ui","component","react","vue","css","tailwind","button","form","modal"],backend:["api","endpoint","server","service","route","rest","graphql","middleware"],mobile:["mobile","ios","android","react native","flutter","app","native"],fullstack:["fullstack","nextjs","next.js","nuxt","sveltekit","app router"],ecommerce:["ecommerce","shopify","store","product","cart","checkout","order"],media:["image","video","audio","media","upload","file","ocr"],ai:["ai","llm","gpt","claude","machine learning","embedding","vector","openai"],quality:["code review","lint","test","coverage","quality","refactor"],codebase:["codebase","repository","repo","project structure"],general:[]},r={};for(let[s,o]of Object.entries(n)){let c=o.filter(l=>e.includes(l)).length;c>0&&(r[s]=c)}return Object.keys(r).length>0?Object.entries(r).sort((s,o)=>o[1]-s[1])[0][0]:"general"}function Bv(t,e=bv,i=!0){let n=Pv.combination,r=Hr(Ll,n.file),s=t;if(i){let c=$l();s=Qv(t,c)}let o=jg(r,n.searchCols,n.outputCols,s,e);return{query:t,expandedQuery:i?s:void 0,detectedIntent:tu(t),detectedDomain:iu(t),detectedComplexity:eu(t),count:o.length,results:o}}function Xl(t,e,i,n=bv,r=!0){let s=Pv.combination,o=Hr(Ll,s.file);if(!_i(o))return{results:[],count:0};let c=_l(o);if(e&&(c=c.filter(A=>(A.intent||"").toLowerCase()===e.toLowerCase())),i&&(c=c.filter(A=>(A.domain||"").toLowerCase()===i.toLowerCase())),c.length===0)return{results:[],count:0};let l=t;if(r){let A=$l();l=Qv(t,A)}let u=c.map(A=>s.searchCols.map(f=>String(A[f]||"")).join(" ")),m=new wo;m.fit(u);let p=m.score(l),d=[];for(let[A,f]of p.slice(0,n))if(f>0){let g=c[A],E={};for(let J of s.outputCols)J in g&&(E[J]=g[J]);E._score=Math.round(f*1e4)/1e4,d.push(E)}return{results:d,count:d.length}}function xg(t){let e=tu(t),i=iu(t),n=eu(t);if(["debug","review","test","design","docs","research","plan"].includes(e)){let m=Xl(t,e,void 0,1,!0);if(m.results.length>0){let p=m.results[0],A=(p.skills||"").split("|").map(f=>f.trim()).filter(Boolean);return{agent:Tl[e]||p.agent||"code-executor",skills:A,intent:e,domain:p.domain||i,complexity:p.complexity||n,score:p._score||0,fallback:!1,description:p.description||"",useWhen:p.use_when||""}}}if(e==="execute"&&["mobile","ai","payment","ecommerce","media","auth","database","fullstack"].includes(i)){let m=Xl(t,"execute",i,1,!0);if(m.results.length>0){let p=m.results[0];return{agent:"code-executor",skills:(p.skills||"").split("|").map(f=>f.trim()).filter(Boolean),intent:e,domain:i,complexity:p.complexity||n,score:p._score||0,fallback:!1,description:p.description||"",useWhen:p.use_when||""}}}let o=Bv(t,1,!0);if(o.count===0){let m=Tl[e]||"code-executor",p=Rg[i]||["research"];return{agent:m,skills:p,intent:e,domain:i,complexity:n,score:0,fallback:!0,description:`Fallback combination based on detected intent (${e}) and domain (${i})`}}let c=o.results[0],u=(c.skills||"").split("|").map(m=>m.trim()).filter(Boolean);return{agent:c.agent||"code-executor",skills:u,intent:c.intent||e,domain:c.domain||i,complexity:c.complexity||n,score:c._score||0,fallback:!1,description:c.description||"",useWhen:c.use_when||""}}function nu(t,e){let{top:i=5,forceIntent:n,forceDomain:r,maxSkills:s}=e||{};if(n||r)return Xl(t,n,r,i,!0).results.map(l=>{let m=(l.skills||"").split("|").map(p=>p.trim()).filter(Boolean);return s&&(m=m.slice(0,s)),{agent:n?Tl[n]:l.agent||"code-executor",skills:m,intent:l.intent||n||tu(t),domain:l.domain||r||iu(t),complexity:l.complexity||eu(t),score:l._score||0,fallback:!1,description:l.description||"",useWhen:l.use_when||""}});let o=Bv(t,i,!0);return o.count===0?[xg(t)]:o.results.map(c=>{let u=(c.skills||"").split("|").map(m=>m.trim()).filter(Boolean);return s&&(u=u.slice(0,s)),{agent:c.agent||"code-executor",skills:u,intent:c.intent||o.detectedIntent,domain:c.domain||o.detectedDomain,complexity:c.complexity||o.detectedComplexity,score:c._score||0,fallback:!1,description:c.description||"",useWhen:c.use_when||""}})}function Jv(t){let e=Ci(t),i=[];if(!_i(e))return i;let n=Ig(e,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>r.name);for(let r of n){let s=Hr(e,r,"SKILL.md");if(_i(s)){let o=Hl(s,"utf-8");i.push({name:r,path:s,content:o})}}return i}function bn(t,e){let i=Ci(e),n=Hr(i,t,"SKILL.md");return _i(n)?Hl(n,"utf-8"):null}var Ll,bv,Pv,Eg,Tl,Rg,wo,Lr=Y(()=>{"use strict";k();Ll=".gemini/extensions/spawn-agent/data",bv=3,Pv={combination:{file:"combinations.csv",searchCols:["keywords","description","use_when","agent","skills","intent","domain"],outputCols:["id","agent","skills","intent","domain","complexity","description","use_when"]},intent:{file:"intents.csv",searchCols:["primary_keywords","expanded_keywords","question_patterns"],outputCols:["intent","agent","primary_keywords","expanded_keywords","action_verbs"]},domain:{file:"domains.csv",searchCols:["keywords","frameworks","file_patterns","technical_terms"],outputCols:["domain","base_skills","enhanced_skills","keywords","frameworks"]},synonym:{file:"synonyms.csv",searchCols:["word","synonyms"],outputCols:["word","synonyms","category"]}},Eg={simple:["quick","simple","basic","small","minor","trivial","easy","straightforward"],standard:[],full:["comprehensive","full","complete","entire","thorough","detailed"],complex:["deep","extensive","advanced","complex","sophisticated","enterprise","production"]},Tl={research:"researcher",plan:"planner",execute:"code-executor",debug:"debugger",review:"code-reviewer",test:"tester",design:"ui-ux-designer",docs:"docs-manager",git:"git-manager",manage:"project-manager"},Rg={frontend:["frontend-design"],backend:["backend-development"],auth:["better-auth","backend-development"],payment:["payment-integration"],database:["databases"],mobile:["mobile-development"],fullstack:["web-frameworks","backend-development"],ecommerce:["shopify"],media:["ai-multimodal"],ai:["ai-multimodal"],quality:["code-review"],codebase:["repomix"],general:["research"]},wo=class{k1;b;corpus=[];docLengths=[];avgdl=0;idf=new Map;docFreqs=new Map;N=0;constructor(e=1.5,i=.75){this.k1=e,this.b=i}tokenize(e){return String(e).toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(n=>n.length>1)}fit(e){if(this.corpus=e.map(i=>this.tokenize(i)),this.N=this.corpus.length,this.N!==0){this.docLengths=this.corpus.map(i=>i.length),this.avgdl=this.docLengths.reduce((i,n)=>i+n,0)/this.N;for(let i of this.corpus){let n=new Set;for(let r of i)n.has(r)||(this.docFreqs.set(r,(this.docFreqs.get(r)||0)+1),n.add(r))}for(let[i,n]of this.docFreqs.entries())this.idf.set(i,Math.log((this.N-n+.5)/(n+.5)+1))}}score(e){let i=this.tokenize(e),n=[];for(let r=0;r<this.corpus.length;r++){let s=this.corpus[r],o=0,c=this.docLengths[r],l=new Map;for(let u of s)l.set(u,(l.get(u)||0)+1);for(let u of i){let m=this.idf.get(u);if(m!==void 0){let p=l.get(u)||0,d=p*(this.k1+1),A=p+this.k1*(1-this.b+this.b*c/this.avgdl);o+=m*d/A}}n.push([r,o])}return n.sort((r,s)=>s[1]-r[1])}}});import{existsSync as qv}from"fs";import{join as wv}from"path";function Dv(t,e){let i=[],n=e.provider;if(i.push("<subagent-context>"),i.push("Agent Type: Interactive Session"),i.push(`Agent Role: ${e.context.agentName||"Assistant"}`),i.push(`Project: ${process.cwd()}`),i.push("</subagent-context>"),i.push(""),i.push("<task>"),i.push(t),i.push("</task>"),i.push(""),e.context.agentName){let r=su(e.context.agentName,n);r&&(i.push("<agent>"),i.push(`Your role and responsibilities are defined in: @${r}`),i.push("</agent>"),i.push(""))}if(e.context.skills.length>0){i.push("<skills>"),i.push("You have access to the following skills and capabilities:");for(let r of e.context.skills){let s=ou(r,n);s&&i.push(`- ${r}: @${s}`)}i.push("</skills>"),i.push("")}if(e.context.contextFiles.length>0){i.push("<context>"),i.push("The following documents provide additional context:");for(let r of e.context.contextFiles)r.path&&i.push(`- ${r.name}: @${r.path}`);i.push("</context>"),i.push("")}return i.join(`
|
|
5
|
+
`)}function su(t,e){let i=process.cwd(),n=e==="claude"?[`.claude/agents/${t}.md`,`.gemini/agents/${t}.md`]:[`.gemini/agents/${t}.md`,`.claude/agents/${t}.md`];for(let r of n){let s=wv(i,r);if(qv(s))return r}return n[0]}function ou(t,e){let i=process.cwd(),n=e==="claude"?[`.claude/skills/${t}.md`,`.gemini/skills/${t}/SKILL.md`,`.gemini/extensions/${t}/SKILL.md`]:[`.gemini/skills/${t}/SKILL.md`,`.gemini/extensions/${t}/SKILL.md`,`.claude/skills/${t}.md`];for(let r of n){let s=wv(i,r);if(qv(s))return r}return n[0]}var au=Y(()=>{"use strict"});import Cg from"net";var Og,Ug,ee,Do=Y(()=>{"use strict";Og=3377,Ug="127.0.0.1",ee=class{port;host;constructor(e=Og,i=Ug){this.port=e,this.host=i}sendCommand(e){return new Promise((i,n)=>{let r=new Cg.Socket,s="";r.setTimeout(1e4),r.connect(this.port,this.host,()=>{r.write(e+`
|
|
6
|
+
`)}),r.on("data",o=>{s+=o.toString(),r.destroy()}),r.on("close",()=>{i(s.trim())}),r.on("error",o=>{o.code==="ECONNREFUSED"?n(new Error('No server running. Use "gk agent start" first.')):n(o)}),r.on("timeout",()=>{r.destroy(),n(new Error("Connection timeout"))})})}async isServerRunning(){try{return await this.sendCommand("status"),!0}catch{return!1}}async status(){let e=await this.sendCommand("status");return JSON.parse(e)}async send(e){let i=await this.sendCommand("send "+e);return JSON.parse(i)}async waitForCompletion(e=120){let i=Date.now(),n=e*1e3;for(;Date.now()-i<n;){try{let r=await this.complete();if(r.complete)return!0;if(r.reason==="pending_tool")return!1}catch(r){throw r}await this.sleep(2e3)}return!1}async complete(){let e=await this.sendCommand("complete");return JSON.parse(e)}async exchange(){let e=await this.sendCommand("exchange");return JSON.parse(e)}async pending(){let e=await this.sendCommand("pending");return JSON.parse(e)}async read(e=200){return await this.sendCommand("read "+e)}async history(){let e=await this.sendCommand("history");return JSON.parse(e)}async clearHistory(){await this.sendCommand("history clear")}async stop(){try{await this.sendCommand("stop")}catch{}}sleep(e){return new Promise(i=>setTimeout(i,e))}}});var Tv,Xv=Y(()=>{"use strict";Tv={claude:{name:"Claude Code",command:"claude",package:"@anthropic-ai/claude-code",modelFlag:"--model",toolsFlag:"--allowedTools",toolsFormat:"csv",pipeFlag:void 0,readyIndicator:"\u276F",responseMarker:"\u25CF",exitCommand:"/exit\r"},gemini:{name:"Gemini CLI",command:"gemini",package:"@google/gemini-cli",modelFlag:"-m",toolsFlag:"--allowed-tools",toolsFormat:"json",pipeFlag:void 0,readyIndicator:">",responseMarker:"\u2726",exitCommand:"/exit\r"}}});import*as Hv from"node-pty";import{EventEmitter as Kg}from"events";var To,Lv=Y(()=>{"use strict";Xv();To=class extends Kg{process=null;output="";outputBuffer=[];isReady=!1;provider;config;model;tools;cwd;debug;constructor(e){if(super(),this.provider=e.provider,this.config=Tv[e.provider],!this.config)throw new Error(`Unknown provider: ${e.provider}. Use 'claude' or 'gemini'`);this.model=e.model||"",this.tools=e.tools||[],this.cwd=e.cwd||process.cwd(),this.debug=e.debug||!1}start(){return new Promise((e,i)=>{if(this.process){i(new Error("Session already running"));return}let n=process.platform==="win32"?"npx.cmd":"npx",r=["-y",this.config.package];this.config.pipeFlag&&r.push(this.config.pipeFlag),this.model&&r.push(this.config.modelFlag,this.model),this.tools.length>0&&(this.config.toolsFormat==="json"?r.push(this.config.toolsFlag,JSON.stringify(this.tools)):r.push(this.config.toolsFlag,this.tools.join(","))),this.debug&&console.log(`[DEBUG] Spawning: ${n} ${r.join(" ")}`);try{this.process=Hv.spawn(n,r,{name:"xterm-256color",cols:120,rows:40,cwd:this.cwd,env:{...process.env,TERM:"xterm-256color"}})}catch(o){i(new Error(`Failed to spawn ${n}: ${o.message}`));return}this.output="",this.outputBuffer=[],this.process.onData(o=>{this.output+=o,this.outputBuffer.push({time:Date.now(),data:o}),this.debug&&process.stdout.write(o),this.emit("data",o),!this.isReady&&this.output.includes(this.config.readyIndicator)&&(this.isReady=!0,this.emit("ready"))}),this.process.onExit(({exitCode:o})=>{this.isReady=!1,this.process=null,this.emit("exit",o)});let s=setTimeout(()=>{this.isReady||(this.output.includes("Yes, I trust")?(this.write("1"),setTimeout(()=>{this.isReady?e():i(new Error(`Timeout waiting for ${this.config.name} to be ready`))},5e3)):i(new Error(`Timeout waiting for ${this.config.name} to start`)))},6e4);this.once("ready",()=>{clearTimeout(s),e()})})}write(e){if(!this.process)throw new Error("No active session");this.process.write(e)}send(e,i={}){return new Promise((n,r)=>{if(!this.process||!this.isReady){r(new Error("No active session or not ready"));return}let s=i.timeout||12e4,o=this.output.length;this.write(e),setTimeout(()=>{this.write("\r"),this.debug&&console.log(`
|
|
7
|
+
[DEBUG] Prompt sent, waiting for response...`)},500);let c=setInterval(()=>{let u=this.output.slice(o),m=!1;if(this.provider==="claude"){let p=u.includes("\u25CF"),d=u.lastIndexOf("\u276F")>u.lastIndexOf("\u25CF");m=p&&d}else this.provider==="gemini"&&(m=u.includes("\u2726")&&u.length>100);if(m){clearInterval(c),clearTimeout(l);let p=this.extractLastAnswer();n(p)}},500),l=setTimeout(()=>{clearInterval(c),r(new Error("Timeout waiting for response"))},s)})}extractLastAnswer(){let e=this.output.replace(/\x1b\[1C/g," ").replace(/\x1b\[[0-9;]*[A-Za-z]/g,"").replace(/\x1b\][^\x07]*\x07/g,"").replace(/\r/g,"");return this.provider==="claude"?this.extractAnswerClaude(e):this.provider==="gemini"?this.extractAnswerGemini(e):""}extractAnswerClaude(e){let i=e.match(/●\s*([\s\S]*?)(?=❯|$)/g);if(i&&i.length>0){let n=i[i.length-1];return n=n.replace(/^●\s*/,"").replace(/[─╭╰│┌┐└┘├┤┬┴┼]+/g,"").replace(/\? for shortcuts/g,"").replace(/esc to interrupt/g,"").replace(/Churning…/g,"").replace(/\(thinking\)/g,"").trim(),n.split(`
|
|
8
|
+
`).map(s=>s.trim()).filter(s=>!(s.length===0||s.match(/^[\s─╭╰│┌┐└┘├┤┬┴┼✢✶✻✽·*]+$/)||s.match(/Cascading|Churning|thinking|thought for/i)||s.match(/^\d+s\)$/))).join(`
|
|
9
|
+
`).trim()}return""}extractAnswerGemini(e){let i=e.split(`
|
|
10
|
+
`),n=!1,r=[];for(let s of i){let o=s.trim();o.match(/^[┃┏┓┗┛━─╭╮╯╰│]+$/)||o.match(/^Gemini/i)||o.match(/^Type .* to/i)||o.length>0&&!o.match(/^>/)&&r.push(o)}return r.join(`
|
|
11
|
+
`).trim()}getOutput(e=100){return this.output.split(`
|
|
12
|
+
`).slice(-e).join(`
|
|
13
|
+
`)}getFullOutput(){return this.output}isRunning(){return this.process!==null&&this.isReady}getIsReady(){return this.isReady}getProvider(){return this.provider}stop(){return new Promise(e=>{if(!this.process){e();return}this.once("exit",()=>e()),this.write(this.config.exitCommand),setTimeout(()=>{this.process&&this.process.kill(),e()},3e3)})}}});import{existsSync as _r,mkdirSync as kg,writeFileSync as Vg,readFileSync as Ng,renameSync as Fg,unlinkSync as bg,readdirSync as Pg,rmSync as Qg}from"fs";import{join as Ai}from"path";import{homedir as Bg}from"os";function ce(t){let e=ge(t);return Ai($v,e)}function di(t,e){return Ai(ce(t),`team-${e}.json`)}function Xo(t){return Ai(ce(t),"ports.json")}function $r(t){return Ai(ce(t),"tasks")}function tt(t,e){return Ai($r(t),`task-${e}.json`)}function es(t,e){return Ai(ce(t),`inbox-${e}.jsonl`)}function pi(t){_r(t)||kg(t,{recursive:!0})}function ve(t,e){let i=`${t}.tmp`;try{let n=JSON.stringify(e,null,2);return Vg(i,n,"utf8"),Fg(i,t),!0}catch{try{_r(i)&&bg(i)}catch{}return!1}}function Pn(t){if(!_r(t))return null;try{let e=Ng(t,"utf8");return JSON.parse(e)}catch{return null}}function Ho(t,e,i){if(!_r(t))return[];try{return Pg(t).filter(r=>r.startsWith(e)&&r.endsWith(i))}catch{return[]}}function cu(t){if(!_r(t))return!0;try{return Qg(t,{recursive:!0,force:!0}),!0}catch{return!1}}function lu(t){pi(ce(t)),pi($r(t))}var _v,$v,Qn=Y(()=>{"use strict";k();_v=Ai(Bg(),".gemkit"),$v=Ai(_v,"teams")});function Q(t,e){return Pn(di(t,e))}function It(t){let e=ce(t),i=Ho(e,"team-",".json"),n=[];for(let r of i){let s=r.replace("team-","").replace(".json",""),o=Q(t,s);o&&n.push(o)}return n}function P(t,e){return Pn(tt(t,e))}function uu(t){let e=$r(t),i=Ho(e,"task-",".json"),n=[];for(let r of i){let s=r.replace("task-","").replace(".json",""),o=P(t,s);o&&n.push(o)}return n.sort((r,s)=>new Date(r.createdAt).getTime()-new Date(s.createdAt).getTime())}function ts(t,e){return uu(t).filter(i=>i.teamId===e)}function fi(t,e){let n=ts(t,e).filter(p=>p.status!=="deleted"),r=n.filter(p=>p.status==="completed"),s=n.filter(p=>p.status==="in_progress"),o=n.filter(p=>p.status==="pending"),c=new Set(r.map(p=>p.taskId)),l=o.filter(p=>p.blockedBy.length>0&&p.blockedBy.some(d=>!c.has(d))),u=new Set(l.map(p=>p.taskId)),m=o.filter(p=>!u.has(p.taskId)&&!p.owner);return{tasks:n,available:m,blocked:l,inProgress:s,completed:r}}function mu(t,e){let i=P(t,e);if(!i||i.blockedBy.length===0)return!1;for(let n of i.blockedBy){let r=P(t,n);if(!r||r.status!=="completed")return!0}return!1}function vu(t,e){return uu(t).filter(n=>{if(n.status!=="pending"||!n.blockedBy.includes(e))return!1;let r=n.blockedBy.filter(s=>s!==e);for(let s of r){let o=P(t,s);if(!o||o.status!=="completed")return!1}return!0})}var hi=Y(()=>{"use strict";Qn()});import{createHash as Jg}from"crypto";function Zg(t){return Jg("sha256").update(t).digest("hex")}function yg(t){return Zg(t).substring(0,8)}function ep(t){let e=t.replace(/\\/g,"/").toLowerCase();return yg(e)}function Lo(t=""){let e=Date.now().toString(36),i=Math.random().toString(36).substring(2,8);return t?`${t}-${e}-${i}`:`${e}-${i}`}function Et(t,e){let i=Date.now().toString(36),n=Math.random().toString(36).substring(2,6);return`${t}-${e}-${i}-${n}`}var en=Y(()=>{"use strict"});function _o(t){let e=Lo("team");lu(t.projectDir);let i=new Date().toISOString(),n={teamId:e,teamName:t.teamName,description:t.description||"",projectDir:t.projectDir,leaderId:t.leaderId,leaderPort:t.leaderPort,members:[{agentId:t.leaderId,name:"leader",agentType:"leader",role:"leader",port:t.leaderPort,pid:process.pid,status:"ready",joinedAt:i,lastActiveAt:i}],status:"active",createdAt:i,updatedAt:i};return ve(di(t.projectDir,e),n)?n:null}function gi(t,e,i){let n=Q(t,e);if(!n)return!1;let r=n.members.findIndex(c=>c.agentId===i.agentId),s=new Date().toISOString(),o={...i,joinedAt:s,lastActiveAt:s};return r>=0?n.members[r]=o:n.members.push(o),n.updatedAt=s,!!ve(di(t,e),n)}function Z(t,e,i,n){let r=Q(t,e);if(!r)return!1;let s=r.members.find(o=>o.agentId===i);return s?(s.status=n,s.lastActiveAt=new Date().toISOString(),r.updatedAt=new Date().toISOString(),ve(di(t,e),r)):!1}function pu(t,e,i,n){let r=Q(t,e);if(!r)return!1;let s=r.members.find(o=>o.agentId===i);return s?(s.pid=n,s.lastActiveAt=new Date().toISOString(),r.updatedAt=new Date().toISOString(),ve(di(t,e),r)):!1}function Au(t){return cu(ce(t))}function du(t,e){let i=Lo("task"),n=new Date().toISOString(),r={taskId:i,teamId:e.teamId,subject:e.subject,description:e.description,activeForm:e.activeForm||`Working on: ${e.subject}`,status:"pending",owner:null,createdBy:e.createdBy,blockedBy:e.blockedBy||[],blocks:[],metadata:e.metadata||{},createdAt:n,updatedAt:n,completedAt:null};for(let s of r.blockedBy){let o=P(t,s);o&&!o.blocks.includes(i)&&(o.blocks.push(i),ve(tt(t,s),o))}return ve(tt(t,i),r)?r:null}function tn(t,e,i){let n=P(t,e);if(!n)return null;let r=new Date().toISOString();if(i.status!==void 0&&(n.status=i.status,i.status==="completed"&&(n.completedAt=r)),i.subject!==void 0&&(n.subject=i.subject),i.description!==void 0&&(n.description=i.description),i.activeForm!==void 0&&(n.activeForm=i.activeForm),i.owner!==void 0&&(n.owner=i.owner),i.metadata!==void 0&&(n.metadata={...n.metadata,...i.metadata}),i.addBlockedBy){for(let s of i.addBlockedBy)if(!n.blockedBy.includes(s)){n.blockedBy.push(s);let o=P(t,s);o&&!o.blocks.includes(e)&&(o.blocks.push(e),ve(tt(t,s),o))}}if(i.addBlocks){for(let s of i.addBlocks)if(!n.blocks.includes(s)){n.blocks.push(s);let o=P(t,s);o&&!o.blockedBy.includes(e)&&(o.blockedBy.push(e),ve(tt(t,s),o))}}if(i.removeBlockedBy)for(let s of i.removeBlockedBy){let o=n.blockedBy.indexOf(s);if(o!==-1){n.blockedBy.splice(o,1);let c=P(t,s);if(c){let l=c.blocks.indexOf(e);l!==-1&&(c.blocks.splice(l,1),ve(tt(t,s),c))}}}if(i.removeBlocks)for(let s of i.removeBlocks){let o=n.blocks.indexOf(s);if(o!==-1){n.blocks.splice(o,1);let c=P(t,s);if(c){let l=c.blockedBy.indexOf(e);l!==-1&&(c.blockedBy.splice(l,1),ve(tt(t,s),c))}}}return n.updatedAt=r,ve(tt(t,e),n)?n:null}var Pt=Y(()=>{"use strict";Qn();hi();en()});var tp=Y(()=>{"use strict"});var cp={};nm(cp,{createAgentRef:()=>Be,createLeaderRef:()=>pe,formatMessageForDisplay:()=>Jn,getAllPending:()=>sp,getInboxMessage:()=>is,getPendingApprovals:()=>$o,getPendingForAgent:()=>ns,readInbox:()=>Qt,updateInboxMessage:()=>Bt,writeApprovalRequest:()=>ta,writeApprovalResponse:()=>op,writeBroadcast:()=>Bn,writeInbox:()=>Qe,writeMessage:()=>ea,writeShutdownRequest:()=>sa,writeShutdownResponse:()=>oa,writeStatusUpdate:()=>ap,writeTaskClaimed:()=>na,writeTaskCompleted:()=>ra,writeTaskCreated:()=>ia});import{existsSync as fu,appendFileSync as ip,readFileSync as np,writeFileSync as wg}from"fs";import{randomUUID as rp}from"crypto";function Dg(t){let e=t.replace(/_/g,"-"),i=rp().slice(0,8);return`${e}-${i}`}function Tg(t,e){let i=ce(t);pi(i);let n=es(t,e);return fu(n)||ip(n,""),n}function Qe(t,e,i){let n=Tg(t,e),r={id:Dg(i.type),timestamp:new Date().toISOString(),...i},s=JSON.stringify(r)+`
|
|
14
|
+
`;return ip(n,s,"utf-8"),r}function Qt(t,e,i){let n=es(t,e);if(!fu(n))return[];let o=np(n,"utf-8").trim().split(`
|
|
15
|
+
`).filter(c=>c.trim()).map(c=>{try{return JSON.parse(c)}catch{return null}}).filter(c=>c!==null);if(i){if(i.to&&(o=o.filter(c=>c.to==="all"||typeof c.to=="object"&&c.to.name===i.to)),i.from&&(o=o.filter(c=>c.from.name===i.from)),i.type){let c=Array.isArray(i.type)?i.type:[i.type];o=o.filter(l=>c.includes(l.type))}if(i.status){let c=Array.isArray(i.status)?i.status:[i.status];o=o.filter(l=>c.includes(l.status))}if(i.since){let c=new Date(i.since);o=o.filter(l=>new Date(l.timestamp)>=c)}i.limit&&i.limit>0&&(o=o.slice(-i.limit))}return o}function is(t,e,i){return Qt(t,e).find(r=>r.id===i)||null}function Bt(t,e,i,n){let r=es(t,e);if(!fu(r))return!1;let o=np(r,"utf-8").trim().split(`
|
|
16
|
+
`).filter(u=>u.trim()),c=!1,l=o.map(u=>{try{let m=JSON.parse(u);if(m.id===i){c=!0;let p={...m,...n,metadata:{...m.metadata,...n.metadata}};return JSON.stringify(p)}return u}catch{return u}});if(c){let u=l.join(`
|
|
17
|
+
`)+`
|
|
18
|
+
`;wg(r,u,"utf-8")}return c}function ns(t,e,i){return Qt(t,e,{status:"pending"}).filter(n=>n.to==="all"||typeof n.to=="object"&&n.to.name===i)}function $o(t,e){return Qt(t,e,{type:"approval_request",status:"pending"})}function sp(t,e){return Qt(t,e,{status:"pending"})}function Be(t,e,i="member"){return{id:t,name:e,role:i}}function pe(t="leader"){return{id:t,name:"leader",role:"leader"}}function ea(t,e,i,n,r,s){return Qe(t,e,{type:"message",from:i,to:n,content:r,summary:s,status:"pending"})}function Bn(t,e,i,n,r){return Qe(t,e,{type:"broadcast",from:i,to:"all",content:n,summary:r,status:"pending"})}function ta(t,e,i,n,r,s){return Qe(t,e,{type:"approval_request",from:i,to:pe(),content:`Tool approval needed: ${n}
|
|
19
|
+
${r}`,summary:`${n}: ${r.slice(0,50)}`,status:"pending",metadata:{toolType:n,toolDetail:r,agentPort:s}})}function op(t,e,i,n,r,s){return Qe(t,e,{type:"approval_response",from:pe(),to:i,content:r?"Approved":`Rejected: ${s||"No reason provided"}`,summary:r?"Approved":"Rejected",status:"processed",metadata:{requestId:n,approved:r,reason:s}})}function ia(t,e,i,n,r,s){return Qe(t,e,{type:"task_created",from:i,to:"all",content:`New task: ${r}`,summary:`Task created: ${r.slice(0,40)}`,status:"pending",metadata:{taskId:n,blockedBy:s}})}function na(t,e,i,n,r){return Qe(t,e,{type:"task_claimed",from:i,to:"all",content:`${i.name} claimed: ${r}`,summary:`${i.name} claimed task`,status:"pending",metadata:{taskId:n}})}function ra(t,e,i,n,r){return Qe(t,e,{type:"task_completed",from:i,to:"all",content:`${i.name} completed: ${r}`,summary:`${i.name} completed task`,status:"pending",metadata:{taskId:n}})}function ap(t,e,i,n,r){return Qe(t,e,{type:"status_update",from:i,to:pe(),content:`${i.name} status: ${n} \u2192 ${r}`,summary:`Status: ${r}`,status:"processed",metadata:{previousStatus:n,newStatus:r}})}function sa(t,e,i,n){let r=rp().slice(0,8);return Qe(t,e,{type:"shutdown_request",from:pe(),to:i,content:n||"Shutdown requested by leader",summary:"Shutdown request",status:"pending",metadata:{requestId:r}})}function oa(t,e,i,n,r,s){return Qe(t,e,{type:"shutdown_response",from:i,to:pe(),content:r?"Shutdown approved":`Shutdown declined: ${s}`,summary:r?"Shutdown approved":"Shutdown declined",status:"pending",metadata:{requestId:n,approved:r,reason:s}})}function Jn(t){let e=t.to==="all"?"all":t.to.name,i={pending:"\u23F3",delivered:"\u{1F4EC}",processed:"\u2705",failed:"\u274C",stale:"\u{1F550}"}[t.status]||"?",n={message:"\u{1F4AC}",broadcast:"\u{1F4E2}",approval_request:"\u{1F514}",approval_response:"\u2713",plan_approval_request:"\u{1F4CB}",plan_approval_response:"\u2705",task_created:"\u{1F4CB}",task_claimed:"\u{1F3C3}",task_completed:"\u{1F389}",status_update:"\u{1F4CA}",shutdown_request:"\u{1F534}",shutdown_response:"\u{1F7E2}"}[t.type]||"\u{1F4E8}";return`${i} ${n} [${t.id}] ${t.from.name} \u2192 ${e}: ${t.summary}`}var Ii=Y(()=>{"use strict";Qn()});import{existsSync as vp,writeFileSync as Xg,unlinkSync as pp,readFileSync as Hg}from"fs";import{join as Lg}from"path";function fp(t){return Lg(ce(t),"ports.lock")}function _g(t){let e=fp(t),i=Date.now();for(pi(ce(t));Date.now()-i<lp;)try{if(vp(e)){let n=Hg(e,"utf8"),r=parseInt(n,10);if(Date.now()-r>lp)pp(e);else{let s=up+Math.random()*50,o=Date.now()+s;for(;Date.now()<o;);continue}}return Xg(e,Date.now().toString(),{flag:"wx"}),!0}catch(n){if(n.code==="EEXIST"){let r=up+Math.random()*50,s=Date.now()+r;for(;Date.now()<s;);continue}continue}return!1}function $g(t){let e=fp(t);try{vp(e)&&pp(e)}catch{}}function eI(t){if(!t||t<=0)return!1;try{return process.kill(t,0),!0}catch{return!1}}function rs(t){return Pn(Xo(t))||{allocations:[],lastUpdated:new Date().toISOString()}}function hu(t,e){return pi(ce(t)),e.lastUpdated=new Date().toISOString(),ve(Xo(t),e)}function Jt(t,e,i,n=null){if(!_g(t))return console.error("[PortManager] Failed to acquire lock"),null;try{let r=rs(t),s=r.allocations.find(c=>c.agentId===e);if(s)return s.port;let o=new Set(r.allocations.map(c=>c.port));for(let c=Ap;c<=dp;c++)if(!o.has(c)){let l={port:c,agentId:e,teamId:i,pid:n,allocatedAt:new Date().toISOString()};return r.allocations.push(l),hu(t,r)?c:null}return null}finally{$g(t)}}function Me(t,e){let i=rs(t),n=i.allocations.findIndex(r=>r.agentId===e);return n===-1?!0:(i.allocations.splice(n,1),hu(t,i))}async function ss(t){let e=rs(t),i=e.allocations.length;e.allocations=e.allocations.filter(r=>r.pid?eI(r.pid):!0);let n=i-e.allocations.length;return n>0&&hu(t,e),n}function gu(t){let e=rs(t),i={};for(let n of e.allocations)i[n.teamId]=(i[n.teamId]||0)+1;return{total:mp,used:e.allocations.length,available:mp-e.allocations.length,byTeam:i}}var lp,up,Ap,dp,mp,Zn=Y(()=>{"use strict";Qn();lp=5e3,up=50,Ap=3377,dp=3476,mp=dp-Ap+1});async function aa(t,e,i){switch(i.type){case"approval_response":return tI(t,e,i);case"task_completed":return iI(t,e,i);case"shutdown_response":return nI(t,e,i);case"message":case"broadcast":return{success:!0,action:"Queued for delivery"};default:return{success:!0,action:"No hook action needed"}}}async function tI(t,e,i){let{requestId:n,approved:r}=i.metadata||{};if(!n)return{success:!1,error:"No requestId in approval response"};let s=is(t,e,n);if(!s)return{success:!1,error:`Original request not found: ${n}`};let o=s.metadata?.agentPort;if(!o)return{success:!1,error:"No agent port in original request"};try{let c=new ee(o);return r?(await c.send("1"),Bt(t,e,n,{status:"processed",processedAt:new Date().toISOString()}),{success:!0,action:`Sent approval to PTY port ${o}`}):(await c.send("3"),Bt(t,e,n,{status:"processed",processedAt:new Date().toISOString()}),{success:!0,action:`Sent rejection to PTY port ${o}`})}catch(c){return{success:!1,error:`Failed to send to PTY: ${c.message}`}}}async function iI(t,e,i){let{taskId:n}=i.metadata||{};if(!n)return{success:!1,error:"No taskId in task_completed message"};let r=ts(t,e),s=[];for(let o of r)if(o.blockedBy&&o.blockedBy.includes(n)){tn(t,o.taskId,{removeBlockedBy:[n]});let c=P(t,o.taskId);c&&c.blockedBy.length===0&&c.status==="pending"&&s.push(o.taskId)}if(s.length>0){let o=s.map(c=>{let l=P(t,c);return l?`${c}: ${l.subject}`:c});return Bn(t,e,pe("system"),`Tasks now available:
|
|
20
|
+
${o.join(`
|
|
21
|
+
`)}`,`${s.length} task(s) unblocked`),{success:!0,action:`Unblocked ${s.length} task(s): ${s.join(", ")}`}}return{success:!0,action:"No tasks to unblock"}}async function nI(t,e,i){let{approved:n}=i.metadata||{};if(!n)return{success:!0,action:"Shutdown declined by agent"};let r=i.from.name,s=Q(t,e);if(!s)return{success:!1,error:"Team not found"};let o=s.members.find(c=>c.name===r);if(!o)return{success:!1,error:`Member not found: ${r}`};if(o.pid)try{process.kill(o.pid)}catch{}return Z(t,e,o.agentId,"shutdown"),Me(t,o.agentId),{success:!0,action:`Shutdown ${r} (PID: ${o.pid})`}}async function hp(t,e,i){let n=is(t,e,i);if(!n)return{valid:!1,error:`Request not found: ${i}`};if(n.type!=="approval_request")return{valid:!1,error:`Cannot approve: type is '${n.type}', not 'approval_request'`};if(n.status!=="pending")return{valid:!1,error:`Request already ${n.status}${n.processedAt?` at ${n.processedAt}`:""}`};let r=n.metadata?.agentPort;if(!r)return{valid:!1,error:"No agent port in request metadata"};try{if(!(await new ee(r).pending()).hasPending)return Bt(t,e,i,{status:"stale"}),{valid:!1,error:"Agent has no pending tool (request marked stale)"}}catch(s){return{valid:!1,error:`Cannot reach agent: ${s.message}`}}return{valid:!0,message:n}}async function ca(t,e,i,n,r){let s=await hp(t,e,i);if(!s.valid)return{success:!1,error:s.error};let o=s.message,{writeApprovalResponse:c}=await Promise.resolve().then(()=>(Ii(),cp)),l=c(t,e,o.from,i,n,r);return aa(t,e,l)}var Iu=Y(()=>{"use strict";Ii();hi();Pt();Pt();Zn();Do()});async function la(t,e,i,n,r,s,o,c,l={}){let u=n==="leader"?pe(i):Be(i,n,"member"),m=s==="leader"?pe(r):Be(r,s,"member"),p=l.type||"message";return p==="shutdown_request"?sa(t,e,m,o):p==="shutdown_response"?oa(t,e,u,l.requestId||"",l.approve||!1,o):ea(t,e,u,m,o,c)}async function ua(t,e,i,n,r,s){if(!Q(t,e))return[];let c=n==="leader"?pe(i):Be(i,n,"member");return[Bn(t,e,c,r,s).id]}var ma=Y(()=>{"use strict";hi();en();Ii()});function va(t,e,i,n,r,s={}){if(s.blockedBy){for(let l of s.blockedBy)if(!P(t,l))return console.error(`Task ${l} does not exist, cannot add as blocker`),null}let o={teamId:e,subject:i,description:n,activeForm:s.activeForm,createdBy:r,blockedBy:s.blockedBy,metadata:s.metadata},c=du(t,o);if(c){let l=r==="leader"?pe():Be(r,r,"member");ia(t,e,l,c.taskId,i,s.blockedBy)}return c}function gp(t,e,i){let n=tn(t,e,{status:i});if(!n)return null;let r=[];if(i==="completed"){let s=vu(t,e);r.push(...s)}return{task:n,unblocked:r}}function pa(t,e,i){let n=P(t,e);if(!n)return null;if(n.owner&&n.owner!==i)return console.error(`Task ${e} already claimed by ${n.owner}`),null;if(mu(t,e))return console.error(`Task ${e} is blocked by unfinished dependencies`),null;let r=tn(t,e,{owner:i,status:"in_progress"});if(r){let s=Be(i,i,"member");na(t,n.teamId,s,e,n.subject)}return r}async function Aa(t,e){let i=P(t,e);if(!i)return null;let n=gp(t,e,"completed");if(!n)return null;let r=i.owner||"unknown",s=Be(r,r,"member"),o=ra(t,i.teamId,s,e,i.subject);return await aa(t,i.teamId,o),n}function da(t,e){let i=fi(t,e);return{total:i.tasks.length,pending:i.tasks.filter(n=>n.status==="pending").length,inProgress:i.inProgress.length,completed:i.completed.length,blocked:i.blocked.length,available:i.available.length}}var Eu=Y(()=>{"use strict";hi();Pt();Ii();Iu()});var Ep=Y(()=>{"use strict";hi();Pt();ma();Ii();Eu();Zn()});import{existsSync as uI,readFileSync as mI}from"fs";function B(t=process.cwd()){let e={ACTIVE_GK_SESSION_ID:"",GK_PROJECT_HASH:"",PROJECT_DIR:"",ACTIVE_GEMINI_SESSION_ID:"",GEMINI_PROJECT_HASH:"",GEMINI_PARENT_ID:"",ACTIVE_PLAN:"",SUGGESTED_PLAN:"",PLAN_DATE_FORMAT:""},i=Wi(t);if(!uI(i))return e;try{let n=mI(i,"utf-8"),r=n.match(/^ACTIVE_GK_SESSION_ID=(.*)$/m);r&&(e.ACTIVE_GK_SESSION_ID=r[1].trim());let s=n.match(/^GK_PROJECT_HASH=(.*)$/m);s&&(e.GK_PROJECT_HASH=s[1].trim());let o=n.match(/^PROJECT_DIR=(.*)$/m);o&&(e.PROJECT_DIR=o[1].trim());let c=n.match(/^ACTIVE_GEMINI_SESSION_ID=(.*)$/m);c&&(e.ACTIVE_GEMINI_SESSION_ID=c[1].trim());let l=n.match(/^GEMINI_PROJECT_HASH=(.*)$/m);l&&(e.GEMINI_PROJECT_HASH=l[1].trim());let u=n.match(/^GEMINI_PARENT_ID=(.*)$/m);u&&(e.GEMINI_PARENT_ID=u[1].trim());let m=n.match(/^ACTIVE_PLAN=(.*)$/m);m&&(e.ACTIVE_PLAN=m[1].trim());let p=n.match(/^SUGGESTED_PLAN=(.*)$/m);p&&(e.SUGGESTED_PLAN=p[1].trim());let d=n.match(/^PLAN_DATE_FORMAT=(.*)$/m);d&&(e.PLAN_DATE_FORMAT=d[1].trim())}catch{}return e}function nn(t=process.cwd()){return B(t).ACTIVE_GK_SESSION_ID||void 0}function Zt(t=process.cwd()){let e=B(t);return e.PROJECT_DIR?e.PROJECT_DIR:ge(t)}function fa(t=process.cwd()){return B(t).GEMINI_PROJECT_HASH||void 0}function os(t=process.cwd()){return B(t).ACTIVE_PLAN||void 0}var it=Y(()=>{"use strict";k()});var Rp=Y(()=>{"use strict";Xr();Lr();Nn();Pt();Zn();en();it()});import{execSync as pI}from"child_process";function zp(t){if(!t||t<=0)return!1;try{return process.kill(t,0),!0}catch{return!1}}function AI(t){if(!t||t<=0)return!1;try{return process.platform==="win32"?pI(`cmd.exe /c taskkill /F /PID ${t}`,{stdio:["pipe","pipe","pipe"],timeout:5e3}):process.kill(t,"SIGKILL"),!0}catch{try{return process.kill(t,"SIGKILL"),!0}catch{return!1}}}async function Ru(t){let e=It(t),i=0,n=0,r=0;for(let o of e)for(let c of o.members)i++,c.status!=="shutdown"&&c.pid&&!zp(c.pid)&&(n++,Z(t,o.teamId,c.agentId,"shutdown"),Me(t,c.agentId),r++);let s=await ss(t);return{teamsChecked:e.length,membersChecked:i,orphansFound:n,cleaned:r+s}}async function ha(t,e){let i=Q(t,e);if(!i)return{killed:0,cleaned:0};let n=0,r=0;for(let s of i.members)s.status!=="shutdown"&&(s.pid&&zp(s.pid)&&AI(s.pid)&&n++,Z(t,e,s.agentId,"shutdown"),Me(t,s.agentId),r++);return{killed:n,cleaned:r}}var jp=Y(()=>{"use strict";hi();Pt();ma();Zn();Ii()});var ga=Y(()=>{"use strict";tp();Qn();Ii();Iu();Zn();hi();Pt();ma();Eu();Ep();Rp();jp()});var Sp={};nm(Sp,{PtyServer:()=>yn,startPtyServerProcess:()=>II});import dI from"net";import zu from"crypto";async function II(t){let e=new yn(t);await e.start(),process.on("SIGINT",async()=>{await e.stop(),process.exit(0)}),process.on("SIGTERM",async()=>{await e.stop(),process.exit(0)})}var fI,xp,hI,gI,yn,ju=Y(()=>{"use strict";Lv();au();Pt();ga();k();fI=3377,xp="127.0.0.1",hI=2e3,gI=1e3,yn=class{constructor(e){this.options=e;this.port=e.port||fI,this.debug=e.debug||!1,this.teamContext=this.loadTeamContext()}ai=null;server=null;outputHistory="";lastPromptIndex=0;lastSentPrompt="";lastDataReceivedTime=0;currentExchangeId=null;exchangeHistory=[];streamClients=[];port;debug;teamContext=null;isPollingMessages=!1;lastApprovalRequestId=null;lastApprovalToolDetail=null;pid=0;loadTeamContext(){let e=process.env.GK_TEAM_ID;return e?{teamId:e,teamName:process.env.GK_TEAM_NAME||"unknown",role:process.env.GK_TEAM_ROLE==="leader"?"leader":"member",agentId:process.env.GK_SUB_SESSION_ID||process.env.GK_PARENT_SESSION_ID||"",agentName:process.env.GK_AGENT_NAME||"agent",leaderPort:parseInt(process.env.GK_TEAM_LEADER_PORT||"3377",10),projectDir:ge(process.cwd())}:null}async start(){let{provider:e,model:i,tools:n,sessionState:r}=this.options;this.debug&&console.log(`[Server] Starting ${e} with model: ${i}`),this.ai=new To({provider:e,model:i,tools:n,debug:this.debug}),this.ai.on("data",s=>{if(this.outputHistory+=s,this.lastDataReceivedTime=Date.now(),this.streamClients.length>0){let o=this.parseOutputForEvents(s);for(let c of o)this.emitStreamEvent(c)}}),this.ai.on("ready",()=>{this.debug&&console.log(`[Server] ${e} is ready`)}),this.ai.on("exit",s=>{this.debug&&console.log(`[Server] ${e} exited with code: ${s}`),this.ai=null}),await this.ai.start(),await this.startTcpServer(),this.teamContext&&this.startTeamMessagePolling()}startTeamMessagePolling(){if(!this.teamContext||this.isPollingMessages)return;let{projectDir:e,agentId:i,teamId:n,agentName:r}=this.teamContext;this.debug&&console.log(`[Server] Starting team message polling for ${r} (${i})`),Z(e,n,i,"ready"),this.isPollingMessages=!0,this.startInboxPolling()}inboxPollingInterval=null;startInboxPolling(){if(!this.teamContext||this.inboxPollingInterval)return;let{projectDir:e,teamId:i,agentName:n}=this.teamContext;this.inboxPollingInterval=setInterval(()=>{let r=ns(e,i,n);for(let s of r)(s.type==="message"||s.type==="broadcast")&&(this.injectInboxMessage(s),Bt(e,i,s.id,{status:"delivered",deliveredAt:new Date().toISOString()}));this.checkAndWriteApprovalRequest()},gI)}stopInboxPolling(){this.inboxPollingInterval&&(clearInterval(this.inboxPollingInterval),this.inboxPollingInterval=null)}checkAndWriteApprovalRequest(){if(!this.teamContext)return;let e=this.detectPendingTools();if(e.hasPending&&e.tools.length>0){let i=e.tools[0],n=i.command||i.path||"unknown";if(n!==this.lastApprovalToolDetail){let{projectDir:r,teamId:s,agentId:o,agentName:c}=this.teamContext,l=Be(o,c,"member"),u=ta(r,s,l,i.type,n,this.port);this.lastApprovalRequestId=u.id,this.lastApprovalToolDetail=n,this.debug&&console.log(`[Server] Wrote approval request to inbox: ${u.id}`)}}else this.lastApprovalToolDetail!==null&&(this.lastApprovalRequestId=null,this.lastApprovalToolDetail=null)}stopTeamMessagePolling(){if(!this.teamContext||!this.isPollingMessages)return;let{projectDir:e,agentId:i,teamId:n}=this.teamContext;this.debug&&console.log("[Server] Stopping team message polling"),this.stopInboxPolling(),this.isPollingMessages=!1,Z(e,n,i,"idle")}injectInboxMessage(e){if(!this.ai||!this.ai.getIsReady()){this.debug&&console.log("[Server] Cannot inject message - AI not ready");return}let i=this.formatInboxMessageForInjection(e);this.debug&&console.log(`[Server] Injecting message from ${e.from.name}: ${e.summary}`),this.teamContext&&Z(this.teamContext.projectDir,this.teamContext.teamId,this.teamContext.agentId,"busy"),this.lastPromptIndex=this.outputHistory.length,this.lastSentPrompt=i,this.currentExchangeId=zu.randomUUID(),this.lastDataReceivedTime=Date.now(),this.ai.write(i),setTimeout(()=>this.ai?.write("\r"),300),this.emitStreamEvent({type:"team_message_received",from:e.from.name,messageType:e.type,summary:e.summary})}formatInboxMessageForInjection(e){let i=[];if(i.push("<team-message>"),i.push(`From: ${e.from.name}`),i.push(`Type: ${e.type}`),e.metadata?.requestId&&i.push(`Request ID: ${e.metadata.requestId}`),i.push(""),i.push(e.content),i.push("</team-message>"),this.teamContext){let n=this.options.sessionState,r=this.options.provider,s=this.teamContext.agentName||"agent",c=n?.context?.agentName||s.replace(/-\d+$/,"");i.push(""),i.push("<agent-context>"),i.push(`You are: ${s}`),i.push(`Role: ${c}`),i.push(`Team: ${this.teamContext.teamName}`);let l=su(c,r);if(l&&i.push(`Profile: @${l}`),n?.context?.skills&&n.context.skills.length>0){i.push("Skills:");for(let u of n.context.skills){let m=ou(u,r);m&&i.push(` - ${u}: @${m}`)}}i.push("</agent-context>")}if(this.teamContext&&(e.type==="message"||e.type==="broadcast")){let n=fi(this.teamContext.projectDir,this.teamContext.teamId);if(i.push(""),i.push("<team-tasks>"),n.available.length>0){i.push("Available (ready to claim):");for(let r of n.available)i.push(` - ${r.taskId}: ${r.subject}`),r.description&&r.description!==r.subject&&i.push(` Description: ${r.description.slice(0,200)}`)}if(n.inProgress.length>0){i.push("In Progress:");for(let r of n.inProgress)i.push(` - ${r.taskId}: ${r.subject} [${r.owner}]`)}if(n.blocked.length>0){i.push("Blocked:");for(let r of n.blocked)i.push(` - ${r.taskId}: ${r.subject} (waiting on: ${r.blockedBy.join(", ")})`)}n.completed.length>0&&i.push(`Completed: ${n.completed.length} task(s)`),i.push("</team-tasks>")}switch(e.type){case"shutdown_request":i.push(""),i.push('Instructions: You have received a shutdown request. If you have completed your current task, respond with SendMessage(type: "shutdown_response", approve: true). If you need more time, respond with approve: false and explain why.');break;case"message":case"broadcast":i.push(""),i.push("<instructions>"),i.push("Process this message from your teammate. Use the task list above to understand the current state."),i.push(""),i.push("SHELL COMMANDS:"),i.push("- Claim a task: gk team task-claim <taskId> --as "+(this.teamContext?.agentName||"agent")),i.push("- Complete a task: gk team task-done <taskId>"),i.push('- Send message: gk team send <recipientName> "<message>"'),i.push("- List tasks: gk team tasks"),i.push(""),i.push("COMMUNICATION PROTOCOL:"),i.push("- You can send messages to any teammate (Main Agent or other sub-agents)"),i.push("- Request progress updates from upstream agents (tasks you depend on)"),i.push("- Provide progress updates to downstream agents (tasks blocked by yours)"),i.push(""),i.push("WHEN YOU COMPLETE A TASK:"),i.push("1. Run task-done command to mark it complete"),i.push("2. Send completion message to Main Agent (leader)"),i.push("3. Notify downstream agents who are blocked by your task"),i.push(' Example: "Task task-xxx completed. Results saved to plans/research.md. You can now proceed."'),i.push("</instructions>");break;case"plan_approval_request":i.push(""),i.push('Instructions: A teammate is requesting approval for their plan. Review it and respond with SendMessage(type: "plan_approval_response", approve: true/false).');break}return i.join(`
|
|
22
|
+
`)}startTcpServer(){return new Promise((e,i)=>{this.server=dI.createServer(n=>{let r=!1;n.on("data",s=>{let o=s.toString().trim(),[c,...l]=o.split(" "),u=l.join(" "),m=this.handleCommand(c,u);if(m==="__STREAM_MODE__"){r=!0,this.streamClients.push(n),n.write(JSON.stringify({type:"stream_started"})+`
|
|
23
|
+
`);return}n.write(m+`
|
|
24
|
+
`)}),n.on("error",()=>{}),n.on("close",()=>{r&&(this.streamClients=this.streamClients.filter(s=>s!==n))})}),this.server.listen(this.port,xp,()=>{this.debug&&console.log(`[Server] Listening on ${xp}:${this.port}`),e()}),this.server.on("error",n=>{n.code==="EADDRINUSE"?i(new Error(`Port ${this.port} is already in use`)):i(n)})})}handleCommand(e,i){switch(e){case"status":return JSON.stringify(this.getStatus());case"send":return this.handleSend(i);case"read":let n=parseInt(i)||200;return this.outputHistory.split(`
|
|
25
|
+
`).slice(-n).join(`
|
|
26
|
+
`);case"extract":return this.extractAnswer();case"exchange":return JSON.stringify(this.getStructuredExchange());case"pending":return JSON.stringify(this.detectPendingTools());case"complete":return JSON.stringify(this.isComplete());case"history":return i==="clear"?(this.exchangeHistory=[],JSON.stringify({ok:!0,message:"History cleared"})):JSON.stringify({provider:this.options.provider,count:this.exchangeHistory.length,exchanges:this.exchangeHistory});case"stop":return this.ai?(this.ai.stop().then(()=>{process.exit(0)}),JSON.stringify({ok:!0,message:"Stopping..."})):JSON.stringify({error:"Not running"});case"stream":return"__STREAM_MODE__";case"team":return JSON.stringify(this.getTeamStatus());default:return JSON.stringify({error:"Unknown command: "+e})}}handleSend(e){return!this.ai||!this.ai.getIsReady()?JSON.stringify({error:"Not ready"}):(this.lastPromptIndex=this.outputHistory.length,/^[123yn]$/i.test(e.trim())||(this.lastSentPrompt=e,this.currentExchangeId=zu.randomUUID()),this.lastDataReceivedTime=Date.now(),this.ai.write(e),setTimeout(()=>this.ai?.write("\r"),300),JSON.stringify({ok:!0,exchangeId:this.currentExchangeId}))}getStatus(){return{running:this.ai!==null,ready:this.ai?.getIsReady()||!1,provider:this.options.provider,outputLength:this.outputHistory.length}}cleanAnsi(e){return e.replace(/\x1b\[\?[0-9;]*[a-z]/gi,"").replace(/\x1b\[1C/g," ").replace(/\x1b\[[0-9;]*[A-Za-z]/g,"").replace(/\x1b\][^\x07]*\x07/g,"").replace(/\r/g,"")}extractAnswer(){return this.options.provider==="gemini"?this.extractAnswerGemini():this.extractAnswerClaude()}extractAnswerClaude(){let i=this.cleanAnsi(this.outputHistory).match(/●\s*([\s\S]*?)(?=❯|$)/g);if(i&&i.length>0){let n=i[i.length-1];return n=n.replace(/^●\s*/,"").replace(/[─╭╰│┌┐└┘├┤┬┴┼⎿⎾]+/g,"").replace(/\? for shortcuts/g,"").replace(/esc to interrupt/g,"").replace(/\w+ing…/g,"").replace(/\(thinking\)/g,"").replace(/·\s*/g,"").replace(/[✢✶✻✽*]/g,"").replace(/Tip:\s*Use\s+\/\w+[^.]*\./gi,"").trim(),n.split(`
|
|
27
|
+
`).map(s=>s.trim()).filter(s=>!(s.length===0||s.match(/^[\s─╭╰│┌┐└┘├┤┬┴┼⎿⎾✢✶✻✽·*]+$/)||s.match(/thinking|thought for/i)||s.match(/^\d+s\)$/)||s.match(/^IDE disconnected$/)||s.match(/^Tip:\s*Use\s+\/\w+/i))).join(`
|
|
28
|
+
`).trim()}return""}extractAnswerGemini(){let e=this.outputHistory.slice(this.lastPromptIndex),i=this.cleanAnsi(e),n=i.lastIndexOf("\u2726");if(n===-1)return"";let r=i.slice(n+1),s=r.match(/[✓⊶⊷x?]\s*(?:Shell|WriteFile|ReadFile|ReadFolder|GoogleSearch|Activate Skill)/i);s&&(r=r.slice(0,s.index));let o=r.match(/[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]|\(esc to cancel/);o&&(r=r.slice(0,o.index));let c=r.match(/╭─|│\s*\d+\s*│|│\s*\d+\s+[*#\-\w]/);c&&(r=r.slice(0,c.index));let l=r.match(/\n\s*>\s+(?!Type your message)[^\n]{10,}/);l&&(r=r.slice(0,l.index));let u=r.trim();u=u.replace(/[█▀▄░▓▒│┃╭╮╯╰┌┐└┘├┤┬┴┼─━╱╲]+/g,"").replace(/[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]/g,"").replace(/\d+s\)/g,"").replace(/\(esc to cancel[^)]*\)/g,"").replace(/Action Required[^\n]*/gi,"").replace(/Waiting for user confirmation[^\n]*/gi,"").replace(/\d+\.\s*Allow[^\n]*/gi,"").replace(/>\s+[^\n]+/g,"").replace(/Type your message[^\n]*/gi,"");let m=u.split(`
|
|
29
|
+
`),p=[],d=new Set;for(let A of m){let f=A.trim();f.length===0?(p.length===0||p[p.length-1].trim()!=="")&&p.push(A):d.has(f)||(d.add(f),p.push(A))}return p.join(`
|
|
30
|
+
`).trim()}detectPendingTools(){let i=this.cleanAnsi(this.outputHistory).slice(-8e3),n=[],r=i.includes("Waiting for user confirmation")||i.includes("Action Required")||i.includes("Allow once")||i.includes("Allow for this session")||i.match(/●\s*1\.\s*Allow/)||i.match(/Apply this change\?/i);if(this.options.provider==="gemini"){let s=[{regex:/\?\s*Shell\s+([^\n│\[]+)/gi,type:"shell",field:"command"},{regex:/\?\s*WriteFile\s+(?:Writing to\s+)?([^\n│]+)/gi,type:"write_file",field:"path"},{regex:/\?\s*ReadFile\s+(?:Reading\s+)?([^\n│]+)/gi,type:"read_file",field:"path"},{regex:/\?\s*ReadFolder\s+([^\n│]+)/gi,type:"read_folder",field:"path"}],o=new Set;for(let{regex:l,type:u,field:m}of s){let p=i.matchAll(l);for(let d of p){let A=this.cleanToolDetail(d[1]),f=`${u}:${A.slice(0,30)}`;if(A&&!o.has(f)&&r){o.add(f);let g={type:u,[m]:A,waiting:!0,options:["1. Allow once","2. Allow for this session","3. No, suggest changes"]};n.push(g)}}}i.match(/Apply this change\?/i)&&r&&n.push({type:"apply_change",waiting:!0,options:["1. Allow once","2. Allow for this session","3. No, suggest changes"]});let c=i.match(/Action Required\s*(\d+)\s*of\s*(\d+)/i);c&&n.forEach(l=>{l.actionRequired={current:parseInt(c[1]),total:parseInt(c[2])}})}if(this.options.provider==="claude"){let s=i.match(/Run\s+(.+?)\s*\?/i);s&&r&&n.push({type:"shell",command:s[1].trim(),waiting:!0});let o=i.match(/Write to\s+(.+?)\s*\?/i);o&&r&&n.push({type:"write_file",path:o[1].trim(),waiting:!0});let c=i.match(/Edit\s+(.+?)\s*\?/i);c&&r&&n.push({type:"edit_file",path:c[1].trim(),waiting:!0})}return{hasPending:n.length>0&&!!r,tools:n,hint:r?'Send "1" to allow once, "2" for session, "3" to suggest changes':void 0}}cleanToolDetail(e){return e.replace(/[│┃╭╮╯╰┌┐└┘├┤┬┴┼█▀▄░▓▒]+/g,"").replace(/[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]/g,"").replace(/\(esc to cancel[^)]*\)/g,"").replace(/\d+s\)/g,"").replace(/…\s*$/,"").replace(/\s+/g," ").trim()}extractToolResults(){let e=[],i=new Set;if(this.options.provider==="gemini"){let n=this.cleanAnsi(this.outputHistory),r=`> ${this.lastSentPrompt}`,s=n.lastIndexOf(r),o=s!==-1?n.slice(s):n.slice(-3e4),c=[{regex:/✓\s*Shell\s+([^\n│]+)/gi,type:"shell",status:"completed"},{regex:/✓\s*WriteFile\s+(?:Writing to\s+)?([^\n│]+)/gi,type:"write_file",status:"completed"},{regex:/✓\s*ReadFile\s+(?:Reading\s+)?([^\n│]+)/gi,type:"read_file",status:"completed"},{regex:/✓\s*ReadFolder\s+([^\n│]+)/gi,type:"read_folder",status:"completed"},{regex:/✓\s*GoogleSearch\s+([^\n│]+)/gi,type:"web_search",status:"completed"},{regex:/x\s*Shell\s+([^\n│]+)/gi,type:"shell",status:"failed"},{regex:/x\s*WriteFile\s+([^\n│]+)/gi,type:"write_file",status:"failed"}];for(let{regex:l,type:u,status:m}of c){let p=o.matchAll(l);for(let d of p){let A=this.cleanToolDetail(d[1]),f=`${u}:${A.slice(0,50)}`;A&&!i.has(f)&&(i.add(f),e.push({type:u,detail:A,status:m}))}}}if(this.options.provider==="claude"){let r=this.cleanAnsi(this.outputHistory).matchAll(/Ran\s+(\w+):\s*([^\n]+)/g);for(let s of r){let o=`${s[1]}:${s[2].slice(0,50)}`;i.has(o)||(i.add(o),e.push({type:s[1],detail:s[2].trim(),status:"completed"}))}}return e}getStructuredExchange(){let e=this.extractAnswer(),i=this.detectPendingTools(),n=this.extractToolResults();this.currentExchangeId||(this.currentExchangeId=zu.randomUUID());let r={id:this.currentExchangeId,timestamp:new Date().toISOString(),prompt:this.lastSentPrompt,answer:e,pending:i.hasPending?i.tools:[],toolResults:n,status:i.hasPending?"waiting_confirmation":"complete"};if(r.status==="complete"&&e.trim()){let s=this.exchangeHistory.findIndex(o=>o.id===this.currentExchangeId);s>=0?this.exchangeHistory[s]=r:this.exchangeHistory.push(r),this.currentExchangeId=null}return r}isComplete(){let e=this.outputHistory.slice(this.lastPromptIndex),i=this.cleanAnsi(e);if(this.options.provider==="claude"){let n=i.includes("\u25CF"),r=i.lastIndexOf("\u25CF"),s=i.lastIndexOf("\u276F");return n&&s>r?{complete:!0}:{complete:!1,reason:"streaming"}}else if(this.options.provider==="gemini"){if(!i.includes("\u2726"))return{complete:!1,reason:"no_response"};let r=i.slice(-3e3),s=r.includes("Waiting for user confirmation")||r.includes("Action Required")||r.includes("Allow once")&&r.includes("Allow for this session"),o=/\?\s*(Shell|WriteFile|ReadFile|ReadFolder)/i.test(r);if(s||o)return{complete:!1,reason:"pending_tool",hint:'Tool confirmation required. Use "gk agent send 1" to approve.'};if(Date.now()-this.lastDataReceivedTime<hI)return{complete:!1,reason:"streaming"};let u=i.lastIndexOf("\u2726");return i.slice(u+1).trim().length>50?{complete:!0}:{complete:!1,reason:"waiting_content"}}return{complete:!1,reason:"unknown"}}parseOutputForEvents(e){let i=this.cleanAnsi(e),n=[];if(i.match(/\?\s*(Shell|WriteFile|ReadFile|ReadFolder)/i)){let s=i.match(/\?\s*(Shell|WriteFile|ReadFile|ReadFolder)\s+([^\n\[]+)/i);n.push({type:"tool_confirmation_required",tool:s?s[1]:"unknown",detail:s?s[2].trim():null})}let r=i.match(/✓\s*(Shell|WriteFile|ReadFile|ReadFolder|GoogleSearch)\s+([^\n]+)/i);return r&&n.push({type:"tool_completed",tool:r[1],detail:r[2].trim()}),(i.includes("\u2726")||i.includes("\u25CF"))&&n.push({type:"response_chunk"}),(i.match(/[❯>]\s*$/)||i.includes("Type your message"))&&n.push({type:"prompt_ready"}),n}emitStreamEvent(e){let i=JSON.stringify(e)+`
|
|
31
|
+
`;for(let n of this.streamClients)try{n.write(i)}catch{}this.streamClients=this.streamClients.filter(n=>!n.destroyed)}async stop(){this.stopTeamMessagePolling(),this.teamContext&&Z(this.teamContext.projectDir,this.teamContext.teamId,this.teamContext.agentId,"shutdown"),this.server&&this.server.close(),this.ai&&await this.ai.stop()}getTeamContext(){return this.teamContext}isInTeamMode(){return this.teamContext!==null}getTeamStatus(){return this.teamContext?{inTeam:!0,teamId:this.teamContext.teamId,teamName:this.teamContext.teamName,role:this.teamContext.role,agentName:this.teamContext.agentName,isPolling:this.isPollingMessages}:{inTeam:!1}}}});import{EventEmitter as qA}from"events";function _a(t){return t==null?[]:Array.isArray(t)?t:[t]}function wA(t,e,i,n){var r,s=t[e],o=~n.string.indexOf(e)?i==null||i===!0?"":String(i):typeof i=="boolean"?i:~n.boolean.indexOf(e)?i==="false"?!1:i==="true"||(t._.push((r=+i,r*0===0?r:i)),!!i):(r=+i,r*0===0?r:i);t[e]=s==null?o:Array.isArray(s)?s.concat(o):[s,o]}function DA(t,e){t=t||[],e=e||{};var i,n,r,s,o,c={_:[]},l=0,u=0,m=0,p=t.length;let d=e.alias!==void 0,A=e.unknown!==void 0,f=e.default!==void 0;if(e.alias=e.alias||{},e.string=_a(e.string),e.boolean=_a(e.boolean),d)for(i in e.alias)for(n=e.alias[i]=_a(e.alias[i]),l=0;l<n.length;l++)(e.alias[n[l]]=n.concat(i)).splice(l,1);for(l=e.boolean.length;l-- >0;)for(n=e.alias[e.boolean[l]]||[],u=n.length;u-- >0;)e.boolean.push(n[u]);for(l=e.string.length;l-- >0;)for(n=e.alias[e.string[l]]||[],u=n.length;u-- >0;)e.string.push(n[u]);if(f){for(i in e.default)if(s=typeof e.default[i],n=e.alias[i]=e.alias[i]||[],e[s]!==void 0)for(e[s].push(i),l=0;l<n.length;l++)e[s].push(n[l])}let g=A?Object.keys(e.alias):[];for(l=0;l<p;l++){if(r=t[l],r==="--"){c._=c._.concat(t.slice(++l));break}for(u=0;u<r.length&&r.charCodeAt(u)===45;u++);if(u===0)c._.push(r);else if(r.substring(u,u+3)==="no-"){if(s=r.substring(u+3),A&&!~g.indexOf(s))return e.unknown(r);c[s]=!1}else{for(m=u+1;m<r.length&&r.charCodeAt(m)!==61;m++);for(s=r.substring(u,m),o=r.substring(++m)||l+1===p||(""+t[l+1]).charCodeAt(0)===45||t[++l],n=u===2?[s]:s,m=0;m<n.length;m++){if(s=n[m],A&&!~g.indexOf(s))return e.unknown("-".repeat(u)+s);wA(c,s,m+1<n.length||o,e)}}}if(f)for(i in e.default)c[i]===void 0&&(c[i]=e.default[i]);if(d)for(i in c)for(n=e.alias[i]||[];n.length>0;)c[n.shift()]=c[i];return c}var om=t=>t.replace(/[<[].+/,"").trim(),TA=t=>{let e=/<([^>]+)>/g,i=/\[([^\]]+)\]/g,n=[],r=c=>{let l=!1,u=c[1];return u.startsWith("...")&&(u=u.slice(3),l=!0),{required:c[0].startsWith("<"),value:u,variadic:l}},s;for(;s=e.exec(t);)n.push(r(s));let o;for(;o=i.exec(t);)n.push(r(o));return n},XA=t=>{let e={alias:{},boolean:[]};for(let[i,n]of t.entries())n.names.length>1&&(e.alias[n.names[0]]=n.names.slice(1)),n.isBoolean&&(n.negated&&t.some((s,o)=>o!==i&&s.names.some(c=>n.names.includes(c))&&typeof s.required=="boolean")||e.boolean.push(n.names[0]));return e},rm=t=>t.sort((e,i)=>e.length>i.length?-1:1)[0],sm=(t,e)=>t.length>=e?t:`${t}${" ".repeat(e-t.length)}`,HA=t=>t.replace(/([a-z])-([a-z])/g,(e,i,n)=>i+n.toUpperCase()),LA=(t,e,i)=>{let n=0,r=e.length,s=t,o;for(;n<r;++n)o=s[e[n]],s=s[e[n]]=n===r-1?i:o??(~e[n+1].indexOf(".")||!(+e[n+1]>-1)?{}:[])},_A=(t,e)=>{for(let i of Object.keys(e)){let n=e[i];n.shouldTransform&&(t[i]=Array.prototype.concat.call([],t[i]),typeof n.transformFunction=="function"&&(t[i]=t[i].map(n.transformFunction)))}},$A=t=>{let e=/([^\\\/]+)$/.exec(t);return e?e[1]:""},am=t=>t.split(".").map((e,i)=>i===0?HA(e):e).join("."),tr=class extends Error{constructor(e){super(e),this.name=this.constructor.name,typeof Error.captureStackTrace=="function"?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}},$a=class{constructor(e,i,n){this.rawName=e,this.description=i,this.config=Object.assign({},n),e=e.replace(/\.\*/g,""),this.negated=!1,this.names=om(e).split(",").map(r=>{let s=r.trim().replace(/^-{1,2}/,"");return s.startsWith("no-")&&(this.negated=!0,s=s.replace(/^no-/,"")),am(s)}).sort((r,s)=>r.length>s.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null&&(this.config.default=!0),e.includes("<")?this.required=!0:e.includes("[")?this.required=!1:this.isBoolean=!0}},ed=process.argv,td=`${process.platform}-${process.arch} node-${process.version}`,fs=class{constructor(e,i,n={},r){this.rawName=e,this.description=i,this.config=n,this.cli=r,this.options=[],this.aliasNames=[],this.name=om(e),this.args=TA(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,i="-v, --version"){return this.versionNumber=e,this.option(i,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,i,n){let r=new $a(e,i,n);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof hs}hasOption(e){return e=e.split(".")[0],this.options.find(i=>i.names.includes(e))}outputHelp(){let{name:e,commands:i}=this.cli,{versionNumber:n,options:r,helpCallback:s}=this.cli.globalCommand,o=[{body:`${e}${n?`/${n}`:""}`}];if(o.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&i.length>0){let u=rm(i.map(m=>m.rawName));o.push({title:"Commands",body:i.map(m=>` ${sm(m.rawName,u.length)} ${m.description}`).join(`
|
|
32
|
+
`)}),o.push({title:"For more info, run any command with the `--help` flag",body:i.map(m=>` $ ${e}${m.name===""?"":` ${m.name}`} --help`).join(`
|
|
33
|
+
`)})}let l=this.isGlobalCommand?r:[...this.options,...r||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(l=l.filter(u=>u.name!=="version")),l.length>0){let u=rm(l.map(m=>m.rawName));o.push({title:"Options",body:l.map(m=>` ${sm(m.rawName,u.length)} ${m.description} ${m.config.default===void 0?"":`(default: ${m.config.default})`}`).join(`
|
|
34
|
+
`)})}this.examples.length>0&&o.push({title:"Examples",body:this.examples.map(u=>typeof u=="function"?u(e):u).join(`
|
|
35
|
+
`)}),s&&(o=s(o)||o),console.log(o.map(u=>u.title?`${u.title}:
|
|
36
|
+
${u.body}`:u.body).join(`
|
|
37
|
+
|
|
38
|
+
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:i}=this.cli.globalCommand;i&&console.log(`${e}/${i} ${td}`)}checkRequiredArgs(){let e=this.args.filter(i=>i.required).length;if(this.cli.args.length<e)throw new tr(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:i}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!i.hasOption(n))throw new tr(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:i}=this.cli,n=[...i.options,...this.options];for(let r of n){let s=e[r.name.split(".")[0]];if(r.required){let o=n.some(c=>c.negated&&c.names.includes(r.name));if(s===!0||s===!1&&!o)throw new tr(`option \`${r.rawName}\` value is missing`)}}}},hs=class extends fs{constructor(e){super("@@global@@","",{},e)}},ds=Object.assign,ec=class extends qA{constructor(e=""){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new hs(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,i,n){let r=new fs(e,i||"",n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,i,n){return this.globalCommand.option(e,i,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,i="-v, --version"){return this.globalCommand.version(e,i),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:i},n,r){return this.args=e,this.options=i,n&&(this.matchedCommand=n),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e=ed,{run:i=!0}={}){this.rawArgs=e,this.name||(this.name=e[1]?$A(e[1]):"cli");let n=!0;for(let s of this.commands){let o=this.mri(e.slice(2),s),c=o.args[0];if(s.isMatched(c)){n=!1;let l=ds(ds({},o),{args:o.args.slice(1)});this.setParsedInfo(l,s,c),this.emit(`command:${c}`,s)}}if(n){for(let s of this.commands)if(s.name===""){n=!1;let o=this.mri(e.slice(2),s);this.setParsedInfo(o,s),this.emit("command:!",s)}}if(n){let s=this.mri(e.slice(2));this.setParsedInfo(s)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),i=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),i=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return i&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.emit("command:*"),r}mri(e,i){let n=[...this.globalCommand.options,...i?i.options:[]],r=XA(n),s=[],o=e.indexOf("--");o>-1&&(s=e.slice(o+1),e=e.slice(0,o));let c=DA(e,r);c=Object.keys(c).reduce((d,A)=>ds(ds({},d),{[am(A)]:c[A]}),{_:[]});let l=c._,u={"--":s},m=i&&i.config.ignoreOptionDefaultValue?i.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,p=Object.create(null);for(let d of n){if(!m&&d.config.default!==void 0)for(let A of d.names)u[A]=d.config.default;Array.isArray(d.config.type)&&p[d.name]===void 0&&(p[d.name]=Object.create(null),p[d.name].shouldTransform=!0,p[d.name].transformFunction=d.config.type[0])}for(let d of Object.keys(c))if(d!=="_"){let A=d.split(".");LA(u,A,c[d]),_A(u,p)}return{args:l,options:u}}runMatchedCommand(){let{args:e,options:i,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs();let r=[];return n.args.forEach((s,o)=>{s.variadic?r.push(e.slice(o)):r.push(e[o])}),r.push(i),n.commandAction.apply(this,r)}},cm=(t="")=>new ec(t);import{existsSync as Ph}from"fs";import{join as Qh}from"path";import{spawn as Bh,spawnSync as Jh}from"child_process";import Gs from"node:process";var lm=(t=0)=>e=>`\x1B[${e+t}m`,um=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,mm=(t=0)=>(e,i,n)=>`\x1B[${38+t};2;${e};${i};${n}m`,W={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},xR=Object.keys(W.modifier),id=Object.keys(W.color),nd=Object.keys(W.bgColor),SR=[...id,...nd];function rd(){let t=new Map;for(let[e,i]of Object.entries(W)){for(let[n,r]of Object.entries(i))W[n]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},i[n]=W[n],t.set(r[0],r[1]);Object.defineProperty(W,e,{value:i,enumerable:!1})}return Object.defineProperty(W,"codes",{value:t,enumerable:!1}),W.color.close="\x1B[39m",W.bgColor.close="\x1B[49m",W.color.ansi=lm(),W.color.ansi256=um(),W.color.ansi16m=mm(),W.bgColor.ansi=lm(10),W.bgColor.ansi256=um(10),W.bgColor.ansi16m=mm(10),Object.defineProperties(W,{rgbToAnsi256:{value(e,i,n){return e===i&&i===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!i)return[0,0,0];let[n]=i;n.length===3&&(n=[...n].map(s=>s+s).join(""));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>W.rgbToAnsi256(...W.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let i,n,r;if(e>=232)i=((e-232)*10+8)/255,n=i,r=i;else{e-=16;let c=e%36;i=Math.floor(e/36)/5,n=Math.floor(c/6)/5,r=c%6/5}let s=Math.max(i,n,r)*2;if(s===0)return 30;let o=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(i));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,i,n)=>W.ansi256ToAnsi(W.rgbToAnsi256(e,i,n)),enumerable:!1},hexToAnsi:{value:e=>W.ansi256ToAnsi(W.hexToAnsi256(e)),enumerable:!1}}),W}var sd=rd(),ye=sd;import tc from"node:process";import od from"node:os";import vm from"node:tty";function Ue(t,e=globalThis.Deno?globalThis.Deno.args:tc.argv){let i=t.startsWith("-")?"":t.length===1?"-":"--",n=e.indexOf(i+t),r=e.indexOf("--");return n!==-1&&(r===-1||n<r)}var{env:C}=tc,gs;Ue("no-color")||Ue("no-colors")||Ue("color=false")||Ue("color=never")?gs=0:(Ue("color")||Ue("colors")||Ue("color=true")||Ue("color=always"))&&(gs=1);function ad(){if("FORCE_COLOR"in C)return C.FORCE_COLOR==="true"?1:C.FORCE_COLOR==="false"?0:C.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(C.FORCE_COLOR,10),3)}function cd(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function ld(t,{streamIsTTY:e,sniffFlags:i=!0}={}){let n=ad();n!==void 0&&(gs=n);let r=i?gs:n;if(r===0)return 0;if(i){if(Ue("color=16m")||Ue("color=full")||Ue("color=truecolor"))return 3;if(Ue("color=256"))return 2}if("TF_BUILD"in C&&"AGENT_NAME"in C)return 1;if(t&&!e&&r===void 0)return 0;let s=r||0;if(C.TERM==="dumb")return s;if(tc.platform==="win32"){let o=od.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in C)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in C)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in C)||C.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in C)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(C.TEAMCITY_VERSION)?1:0;if(C.COLORTERM==="truecolor"||C.TERM==="xterm-kitty"||C.TERM==="xterm-ghostty"||C.TERM==="wezterm")return 3;if("TERM_PROGRAM"in C){let o=Number.parseInt((C.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(C.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(C.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(C.TERM)||"COLORTERM"in C?1:s}function pm(t,e={}){let i=ld(t,{streamIsTTY:t&&t.isTTY,...e});return cd(i)}var ud={stdout:pm({isTTY:vm.isatty(1)}),stderr:pm({isTTY:vm.isatty(2)})},Am=ud;function dm(t,e,i){let n=t.indexOf(e);if(n===-1)return t;let r=e.length,s=0,o="";do o+=t.slice(s,n)+e+i,s=n+r,n=t.indexOf(e,s);while(n!==-1);return o+=t.slice(s),o}function fm(t,e,i,n){let r=0,s="";do{let o=t[n-1]==="\r";s+=t.slice(r,o?n-1:n)+e+(o?`\r
|
|
10
39
|
`:`
|
|
11
40
|
`)+i,r=n+1,n=t.indexOf(`
|
|
12
|
-
`,r)}while(n!==-1);return
|
|
13
|
-
`);return
|
|
14
|
-
${e}`,d7=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),R7=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),z7=(t,e,i)=>{let n=i===""?"":`with ${i.trim()}() `,r=h7.bind(null,n,e.toString());Object.defineProperty(r,"name",R7);let{writable:o,enumerable:s,configurable:c}=d7;Object.defineProperty(t,"toString",{value:r,writable:o,enumerable:s,configurable:c})};function Es(t,e,{ignoreNonConfigurable:i=!1}={}){let{name:n}=t;for(let r of Reflect.ownKeys(e))I7(t,e,r,i);return f7(t,e),z7(t,e,n),t}var rr=new WeakMap,al=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let i,n=0,r=t.displayName||t.name||"<anonymous>",o=function(...s){if(rr.set(o,++n),n===1)i=t.apply(this,s),t=void 0;else if(e.throw===!0)throw new Error(`Function \`${r}\` can only be called once`);return i};return Es(o,t),rr.set(o,n),o};al.callCount=t=>{if(!rr.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return rr.get(t)};var cl=al;var Jt=[];Jt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Jt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Jt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var or=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Is=Symbol.for("signal-exit emitter"),ps=globalThis,j7=Object.defineProperty.bind(Object),fs=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ps[Is])return ps[Is];j7(ps,Is,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,i){this.listeners[e].push(i)}removeListener(e,i){let n=this.listeners[e],r=n.indexOf(i);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,i,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let o of this.listeners[e])r=o(i,n)===!0||r;return e==="exit"&&(r=this.emit("afterExit",i,n)||r),r}},sr=class{},g7=t=>({onExit(e,i){return t.onExit(e,i)},load(){return t.load()},unload(){return t.unload()}}),hs=class extends sr{onExit(){return()=>{}}load(){}unload(){}},ds=class extends sr{#e=Rs.platform==="win32"?"SIGINT":"SIGHUP";#n=new fs;#i;#r;#a;#t={};#o=!1;constructor(e){super(),this.#i=e,this.#t={};for(let i of Jt)this.#t[i]=()=>{let n=this.#i.listeners(i),{count:r}=this.#n,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(r+=o.__signal_exit_emitter__.count),n.length===r){this.unload();let s=this.#n.emit("exit",null,i),c=i==="SIGHUP"?this.#e:i;s||e.kill(e.pid,c)}};this.#a=e.reallyExit,this.#r=e.emit}onExit(e,i){if(!or(this.#i))return()=>{};this.#o===!1&&this.load();let n=i?.alwaysLast?"afterExit":"exit";return this.#n.on(n,e),()=>{this.#n.removeListener(n,e),this.#n.listeners.exit.length===0&&this.#n.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#n.count+=1;for(let e of Jt)try{let i=this.#t[e];i&&this.#i.on(e,i)}catch{}this.#i.emit=(e,...i)=>this.#m(e,...i),this.#i.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,Jt.forEach(e=>{let i=this.#t[e];if(!i)throw new Error("Listener not defined for signal: "+e);try{this.#i.removeListener(e,i)}catch{}}),this.#i.emit=this.#r,this.#i.reallyExit=this.#a,this.#n.count-=1)}#s(e){return or(this.#i)?(this.#i.exitCode=e||0,this.#n.emit("exit",this.#i.exitCode,null),this.#a.call(this.#i,this.#i.exitCode)):0}#m(e,...i){let n=this.#r;if(e==="exit"&&or(this.#i)){typeof i[0]=="number"&&(this.#i.exitCode=i[0]);let r=n.call(this.#i,e,...i);return this.#n.emit("exit",this.#i.exitCode,null),r}else return n.call(this.#i,e,...i)}},Rs=globalThis.process,{onExit:ll,load:af,unload:cf}=g7(or(Rs)?new ds(Rs):new hs);var vl=ar.stderr.isTTY?ar.stderr:ar.stdout.isTTY?ar.stdout:void 0,x7=vl?cl(()=>{ll(()=>{vl.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Al=x7;var cr=!1,pi={};pi.show=(t=ul.stderr)=>{t.isTTY&&(cr=!1,t.write("\x1B[?25h"))};pi.hide=(t=ul.stderr)=>{t.isTTY&&(Al(),cr=!0,t.write("\x1B[?25l"))};pi.toggle=(t,e)=>{t!==void 0&&(cr=t),cr?pi.show(e):pi.hide(e)};var zs=pi;var tn=_n(js(),1);import je from"node:process";function gs(){return je.platform!=="win32"?je.env.TERM!=="linux":!!je.env.CI||!!je.env.WT_SESSION||!!je.env.TERMINUS_SUBLIME||je.env.ConEmuTask==="{cmd::Cmder}"||je.env.TERM_PROGRAM==="Terminus-Sublime"||je.env.TERM_PROGRAM==="vscode"||je.env.TERM==="xterm-256color"||je.env.TERM==="alacritty"||je.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var S7={info:ze.blue("\u2139"),success:ze.green("\u2714"),warning:ze.yellow("\u26A0"),error:ze.red("\u2716")},Y7={info:ze.blue("i"),success:ze.green("\u221A"),warning:ze.yellow("\u203C"),error:ze.red("\xD7")},W7=gs()?S7:Y7,$i=W7;function xs({onlyFirst:t=!1}={}){let r="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(r,t?void 0:"g")}var M7=xs();function en(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(M7,"")}function pl(t){return t===161||t===164||t===167||t===168||t===170||t===173||t===174||t>=176&&t<=180||t>=182&&t<=186||t>=188&&t<=191||t===198||t===208||t===215||t===216||t>=222&&t<=225||t===230||t>=232&&t<=234||t===236||t===237||t===240||t===242||t===243||t>=247&&t<=250||t===252||t===254||t===257||t===273||t===275||t===283||t===294||t===295||t===299||t>=305&&t<=307||t===312||t>=319&&t<=322||t===324||t>=328&&t<=331||t===333||t===338||t===339||t===358||t===359||t===363||t===462||t===464||t===466||t===468||t===470||t===472||t===474||t===476||t===593||t===609||t===708||t===711||t>=713&&t<=715||t===717||t===720||t>=728&&t<=731||t===733||t===735||t>=768&&t<=879||t>=913&&t<=929||t>=931&&t<=937||t>=945&&t<=961||t>=963&&t<=969||t===1025||t>=1040&&t<=1103||t===1105||t===8208||t>=8211&&t<=8214||t===8216||t===8217||t===8220||t===8221||t>=8224&&t<=8226||t>=8228&&t<=8231||t===8240||t===8242||t===8243||t===8245||t===8251||t===8254||t===8308||t===8319||t>=8321&&t<=8324||t===8364||t===8451||t===8453||t===8457||t===8467||t===8470||t===8481||t===8482||t===8486||t===8491||t===8531||t===8532||t>=8539&&t<=8542||t>=8544&&t<=8555||t>=8560&&t<=8569||t===8585||t>=8592&&t<=8601||t===8632||t===8633||t===8658||t===8660||t===8679||t===8704||t===8706||t===8707||t===8711||t===8712||t===8715||t===8719||t===8721||t===8725||t===8730||t>=8733&&t<=8736||t===8739||t===8741||t>=8743&&t<=8748||t===8750||t>=8756&&t<=8759||t===8764||t===8765||t===8776||t===8780||t===8786||t===8800||t===8801||t>=8804&&t<=8807||t===8810||t===8811||t===8814||t===8815||t===8834||t===8835||t===8838||t===8839||t===8853||t===8857||t===8869||t===8895||t===8978||t>=9312&&t<=9449||t>=9451&&t<=9547||t>=9552&&t<=9587||t>=9600&&t<=9615||t>=9618&&t<=9621||t===9632||t===9633||t>=9635&&t<=9641||t===9650||t===9651||t===9654||t===9655||t===9660||t===9661||t===9664||t===9665||t>=9670&&t<=9672||t===9675||t>=9678&&t<=9681||t>=9698&&t<=9701||t===9711||t===9733||t===9734||t===9737||t===9742||t===9743||t===9756||t===9758||t===9792||t===9794||t===9824||t===9825||t>=9827&&t<=9829||t>=9831&&t<=9834||t===9836||t===9837||t===9839||t===9886||t===9887||t===9919||t>=9926&&t<=9933||t>=9935&&t<=9939||t>=9941&&t<=9953||t===9955||t===9960||t===9961||t>=9963&&t<=9969||t===9972||t>=9974&&t<=9977||t===9979||t===9980||t===9982||t===9983||t===10045||t>=10102&&t<=10111||t>=11094&&t<=11097||t>=12872&&t<=12879||t>=57344&&t<=63743||t>=65024&&t<=65039||t===65533||t>=127232&&t<=127242||t>=127248&&t<=127277||t>=127280&&t<=127337||t>=127344&&t<=127373||t===127375||t===127376||t>=127387&&t<=127404||t>=917760&&t<=917999||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function fl(t){return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510}function hl(t){return t>=4352&&t<=4447||t===8986||t===8987||t===9001||t===9002||t>=9193&&t<=9196||t===9200||t===9203||t===9725||t===9726||t===9748||t===9749||t>=9776&&t<=9783||t>=9800&&t<=9811||t===9855||t>=9866&&t<=9871||t===9875||t===9889||t===9898||t===9899||t===9917||t===9918||t===9924||t===9925||t===9934||t===9940||t===9962||t===9970||t===9971||t===9973||t===9978||t===9981||t===9989||t===9994||t===9995||t===10024||t===10060||t===10062||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t===11035||t===11036||t===11088||t===11093||t>=11904&&t<=11929||t>=11931&&t<=12019||t>=12032&&t<=12245||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12353&&t<=12438||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12773||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=42124||t>=42128&&t<=42182||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=94176&&t<=94180||t>=94192&&t<=94198||t>=94208&&t<=101589||t>=101631&&t<=101662||t>=101760&&t<=101874||t>=110576&&t<=110579||t>=110581&&t<=110587||t===110589||t===110590||t>=110592&&t<=110882||t===110898||t>=110928&&t<=110930||t===110933||t>=110948&&t<=110951||t>=110960&&t<=111355||t>=119552&&t<=119638||t>=119648&&t<=119670||t===126980||t===127183||t===127374||t>=127377&&t<=127386||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t===127568||t===127569||t>=127584&&t<=127589||t>=127744&&t<=127776||t>=127789&&t<=127797||t>=127799&&t<=127868||t>=127870&&t<=127891||t>=127904&&t<=127946||t>=127951&&t<=127955||t>=127968&&t<=127984||t===127988||t>=127992&&t<=128062||t===128064||t>=128066&&t<=128252||t>=128255&&t<=128317||t>=128331&&t<=128334||t>=128336&&t<=128359||t===128378||t===128405||t===128406||t===128420||t>=128507&&t<=128591||t>=128640&&t<=128709||t===128716||t>=128720&&t<=128722||t>=128725&&t<=128728||t>=128732&&t<=128735||t===128747||t===128748||t>=128756&&t<=128764||t>=128992&&t<=129003||t===129008||t>=129292&&t<=129338||t>=129340&&t<=129349||t>=129351&&t<=129535||t>=129648&&t<=129660||t>=129664&&t<=129674||t>=129678&&t<=129734||t===129736||t>=129741&&t<=129756||t>=129759&&t<=129770||t>=129775&&t<=129784||t>=131072&&t<=196605||t>=196608&&t<=262141}function C7(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function dl(t,{ambiguousAsWide:e=!1}={}){return C7(t),fl(t)||hl(t)||e&&pl(t)?2:1}var jl=_n(zl(),1),O7=new Intl.Segmenter,U7=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function Gs(t,e={}){if(typeof t!="string"||t.length===0)return 0;let{ambiguousIsNarrow:i=!0,countAnsiEscapeCodes:n=!1}=e;if(n||(t=en(t)),t.length===0)return 0;let r=0,o={ambiguousAsWide:!i};for(let{segment:s}of O7.segment(t)){let c=s.codePointAt(0);if(!(c<=31||c>=127&&c<=159)&&!(c>=8203&&c<=8207||c===65279)&&!(c>=768&&c<=879||c>=6832&&c<=6911||c>=7616&&c<=7679||c>=8400&&c<=8447||c>=65056&&c<=65071)&&!(c>=55296&&c<=57343)&&!(c>=65024&&c<=65039)&&!U7.test(s)){if((0,jl.default)().test(s)){r+=2;continue}r+=dl(c,o)}}return r}function Ss({stream:t=process.stdout}={}){return!!(t&&t.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import gl from"node:process";function Ys(){let{env:t}=gl,{TERM:e,TERM_PROGRAM:i}=t;return gl.platform!=="win32"?e!=="linux":!!t.WT_SESSION||!!t.TERMINUS_SUBLIME||t.ConEmuTask==="{cmd::Cmder}"||i==="Terminus-Sublime"||i==="vscode"||e==="xterm-256color"||e==="alacritty"||e==="rxvt-unicode"||e==="rxvt-unicode-256color"||t.TERMINAL_EMULATOR==="JetBrains-JediTerm"}import Ue from"node:process";var K7=3,Ws=class{#e=0;start(){this.#e++,this.#e===1&&this.#n()}stop(){if(this.#e<=0)throw new Error("`stop` called more times than `start`");this.#e--,this.#e===0&&this.#i()}#n(){Ue.platform==="win32"||!Ue.stdin.isTTY||(Ue.stdin.setRawMode(!0),Ue.stdin.on("data",this.#r),Ue.stdin.resume())}#i(){Ue.stdin.isTTY&&(Ue.stdin.off("data",this.#r),Ue.stdin.pause(),Ue.stdin.setRawMode(!1))}#r(e){e[0]===K7&&Ue.emit("SIGINT")}},V7=new Ws,Ms=V7;var N7=_n(js(),1),Cs=class{#e=0;#n=!1;#i=0;#r=-1;#a=0;#t;#o;#s;#m;#I;#v;#A;#u;#p;#c;#l;color;constructor(e){typeof e=="string"&&(e={text:e}),this.#t={color:"cyan",stream:vr.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#t.color,this.spinner=this.#t.spinner,this.#I=this.#t.interval,this.#s=this.#t.stream,this.#v=typeof this.#t.isEnabled=="boolean"?this.#t.isEnabled:Ss({stream:this.#s}),this.#A=typeof this.#t.isSilent=="boolean"?this.#t.isSilent:!1,this.text=this.#t.text,this.prefixText=this.#t.prefixText,this.suffixText=this.#t.suffixText,this.indent=this.#t.indent,vr.env.NODE_ENV==="test"&&(this._stream=this.#s,this._isEnabled=this.#v,Object.defineProperty(this,"_linesToClear",{get(){return this.#e},set(i){this.#e=i}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#r}}),Object.defineProperty(this,"_lineCount",{get(){return this.#i}}))}get indent(){return this.#u}set indent(e=0){if(!(e>=0&&Number.isInteger(e)))throw new Error("The `indent` option must be an integer from 0 and up");this.#u=e,this.#E()}get interval(){return this.#I??this.#o.interval??100}get spinner(){return this.#o}set spinner(e){if(this.#r=-1,this.#I=void 0,typeof e=="object"){if(e.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#o=e}else if(!Ys())this.#o=tn.default.line;else if(e===void 0)this.#o=tn.default.dots;else if(e!=="default"&&tn.default[e])this.#o=tn.default[e];else throw new Error(`There is no built-in spinner named '${e}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#p}set text(e=""){this.#p=e,this.#E()}get prefixText(){return this.#c}set prefixText(e=""){this.#c=e,this.#E()}get suffixText(){return this.#l}set suffixText(e=""){this.#l=e,this.#E()}get isSpinning(){return this.#m!==void 0}#f(e=this.#c,i=" "){return typeof e=="string"&&e!==""?e+i:typeof e=="function"?e()+i:""}#h(e=this.#l,i=" "){return typeof e=="string"&&e!==""?i+e:typeof e=="function"?i+e():""}#E(){let e=this.#s.columns??80,i=this.#f(this.#c,"-"),n=this.#h(this.#l,"-"),r=" ".repeat(this.#u)+i+"--"+this.#p+"--"+n;this.#i=0;for(let o of en(r).split(`
|
|
15
|
-
`))this.#i+=Math.max(1,Math.ceil(
|
|
16
|
-
`),this)}stop(){return this.#
|
|
17
|
-
`;return this.stop(),this.#s.write(A),this}};function Ke(t){return new Cs(t)}import{existsSync as Yl,readFileSync as B7,writeFileSync as Z7,mkdirSync as P7}from"fs";import{dirname as q7}from"path";import{homedir as xl}from"os";import{join as y}from"path";var k7=y(xl(),".gemkit"),Os=y(k7,"projects"),Us=y(xl(),".gemini"),_f=y(Us,"config"),fi=y(Us,"cache"),$f=y(Us,"tmp"),hi=".gemini";var F7="plans",Q7=".gk.json",J7="metadata.json",b7=".env";function Ar(t=process.cwd()){return y(t,hi)}function Ks(t=process.cwd()){return y(t,hi,Q7)}function Vs(t=process.cwd()){return y(t,hi,J7)}function bt(t=process.cwd()){return y(t,hi,b7)}function nn(t=process.cwd()){return y(t,hi,"agents")}function Bt(t=process.cwd()){return y(t,hi,"extensions")}function di(t=process.cwd()){return y(t,F7)}function rn(t){return t?t.replace(/^[A-Za-z]:/,e=>e.replace(":","")).replace(/[\\/]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""):""}function we(t){return y(Os,t)}function Zt(t,e){return y(we(t),`gk-session-${e}.json`)}function on(t,e){return y(we(t),`gk-project-${e}.json`)}var me={defaultScope:"local",github:{repo:"therichardngai-code/gemkit-kits-starter",apiUrl:"https://api.github.com"},cache:{enabled:!0,ttl:3600},installation:{excludePatterns:[],backupOnUpdate:!0},ui:{colors:!0,spinner:!0,verbose:!1},paths:{},spawn:{defaultModel:"gemini-2.5-flash",music:!1},office:{enabled:!0,mode:"web",port:3847,autoOpen:!0,sounds:!1,refreshRate:500},update:{autoCheck:!0,checkInterval:24,notifyOnly:!0}};function Gl(t){return!(!t||typeof t!="object")}function Sl(t){return{...me,...t,github:{...me.github,...t.github||{}},cache:{...me.cache,...t.cache||{}},installation:{...me.installation,...t.installation||{}},ui:{...me.ui,...t.ui||{}},paths:{...me.paths,...t.paths||{}},spawn:{...me.spawn,...t.spawn||{}},office:{...me.office,...t.office||{}},update:{...me.update,...t.update||{}}}}var ur=class extends Error{constructor(i,n="GEMKIT_ERROR",r){super(i);this.code=n;this.details=r;this.name="GemKitError"}},Pt=class extends ur{constructor(e,i){super(e,"CONFIG_ERROR",i),this.name="ConfigError"}};var Ee=class extends ur{constructor(e,i){super(e,"GITHUB_ERROR",i),this.name="GitHubError"}};function Ve(t){let e=Ks(t);if(!Yl(e))return me;try{let i=B7(e,"utf-8"),n=JSON.parse(i);if(!Gl(n))throw new Pt("Invalid configuration format");return Sl(n)}catch(i){throw i instanceof Pt?i:new Pt(`Failed to load config: ${i}`)}}function Wl(t,e){let i=Ks(e),n=q7(i);Yl(n)||P7(n,{recursive:!0}),Z7(i,JSON.stringify(t,null,2))}function Ml(t,e){let i=Ve(e),n=t.split("."),r=i;for(let o of n)if(r&&typeof r=="object"&&o in r)r=r[o];else return;return r}function Cl(t,e,i){let n=Ve(i),r=t.split("."),o=r.pop();if(!o)throw new Pt("Invalid config path");let s=n;for(let c of r)(!(c in s)||typeof s[c]!="object")&&(s[c]={}),s=s[c];s[o]=e,Wl(n,i)}function Ol(t){Wl(me,t)}import{existsSync as Ul,readFileSync as y7,writeFileSync as D7,mkdirSync as w7,readdirSync as Kl,unlinkSync as Vl,statSync as T7}from"fs";import{join as Ns}from"path";function ks(){return Ul(fi)||w7(fi,{recursive:!0}),fi}function Nl(t){let e=t.replace(/[^a-zA-Z0-9-_]/g,"_");return Ns(ks(),`${e}.json`)}function mr(t){let e=Nl(t);if(!Ul(e))return null;try{let i=y7(e,"utf-8"),n=JSON.parse(i);return Date.now()-n.timestamp>n.ttl*1e3?(Vl(e),null):n.data}catch{return null}}function Er(t,e,i=3600){let n=Nl(t),r={key:t,data:e,timestamp:Date.now(),ttl:i};D7(n,JSON.stringify(r,null,2))}function kl(){let t=ks(),e=Kl(t).filter(i=>i.endsWith(".json"));for(let i of e)Vl(Ns(t,i));return e.length}function Fl(){let t=ks(),e=Kl(t).filter(n=>n.endsWith(".json")),i=0;for(let n of e){let r=T7(Ns(t,n));i+=r.size}return{entries:e.length,size:i}}var Ql="github-releases",X7=300;async function Ir(t=10){let e=mr(Ql);if(e)return e.slice(0,t);let i=Ve(),{repo:n,apiUrl:r}=i.github,o=`${r}/repos/${n}/releases?per_page=${t}`;try{let s=await fetch(o,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"gemkit-cli"}});if(!s.ok)throw new Ee(`Failed to fetch releases: ${s.status}`);let l=(await s.json()).map(v=>({version:v.tag_name.replace(/^v/,""),tag:v.tag_name,publishedAt:v.published_at,prerelease:v.prerelease,assets:v.assets.map(A=>({name:A.name,url:A.url,size:A.size,downloadUrl:A.browser_download_url}))}));return Er(Ql,l,X7),l}catch(s){throw s instanceof Ee?s:new Ee(`Failed to fetch releases: ${s}`)}}async function qt(){let t=await Ir(1);return t.length>0?t[0]:null}async function Jl(t){return(await Ir(50)).find(i=>i.version===t||i.tag===t)||null}import{createWriteStream as H7,existsSync as L7,mkdirSync as _7}from"fs";import{pipeline as $7}from"stream/promises";import{join as eu}from"path";async function tu(t,e=fi){L7(e)||_7(e,{recursive:!0});let i=eu(e,t.name);try{let n=await fetch(t.downloadUrl,{headers:{"User-Agent":"gemkit-cli"}});if(!n.ok)throw new Ee(`Failed to download asset: ${n.status}`);if(!n.body)throw new Ee("No response body");let r=H7(i);return await $7(n.body,r),i}catch(n){throw n instanceof Ee?n:new Ee(`Download failed: ${n}`)}}async function Ri(t){let e=t.assets.find(i=>i.name.endsWith(".tar.gz")||i.name.endsWith(".tgz"));if(!e)throw new Ee("No tarball asset found in release");return tu(e)}import{createReadStream as sE,createWriteStream as cz,existsSync as iv,mkdirSync as aE}from"fs";import{pipeline as cE}from"stream/promises";import{createGunzip as lE}from"zlib";import uu from"events";import ee from"fs";import{EventEmitter as Ps}from"node:events";import ql from"node:stream";import{StringDecoder as iu}from"node:string_decoder";var bl=typeof process=="object"&&process?process:{stdout:null,stderr:null},nu=t=>!!t&&typeof t=="object"&&(t instanceof vn||t instanceof ql||ru(t)||ou(t)),ru=t=>!!t&&typeof t=="object"&&t instanceof Ps&&typeof t.pipe=="function"&&t.pipe!==ql.Writable.prototype.pipe,ou=t=>!!t&&typeof t=="object"&&t instanceof Ps&&typeof t.write=="function"&&typeof t.end=="function",Te=Symbol("EOF"),Xe=Symbol("maybeEmitEnd"),mt=Symbol("emittedEnd"),pr=Symbol("emittingEnd"),sn=Symbol("emittedError"),fr=Symbol("closed"),Bl=Symbol("read"),hr=Symbol("flush"),Zl=Symbol("flushChunk"),ge=Symbol("encoding"),zi=Symbol("decoder"),k=Symbol("flowing"),an=Symbol("paused"),ji=Symbol("resume"),F=Symbol("buffer"),L=Symbol("pipes"),Q=Symbol("bufferLength"),Fs=Symbol("bufferPush"),dr=Symbol("bufferShift"),D=Symbol("objectMode"),C=Symbol("destroyed"),Qs=Symbol("error"),Js=Symbol("emitData"),Pl=Symbol("emitEnd"),bs=Symbol("emitEnd2"),Ne=Symbol("async"),Bs=Symbol("abort"),Rr=Symbol("aborted"),cn=Symbol("signal"),yt=Symbol("dataListeners"),te=Symbol("discarded"),ln=t=>Promise.resolve().then(t),su=t=>t(),au=t=>t==="end"||t==="finish"||t==="prefinish",cu=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,lu=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),zr=class{src;dest;opts;ondrain;constructor(e,i,n){this.src=e,this.dest=i,this.opts=n,this.ondrain=()=>e[ji](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Zs=class extends zr{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,i,n){super(e,i,n),this.proxyErrors=r=>i.emit("error",r),e.on("error",this.proxyErrors)}},vu=t=>!!t.objectMode,Au=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",vn=class extends Ps{[k]=!1;[an]=!1;[L]=[];[F]=[];[D];[ge];[Ne];[zi];[Te]=!1;[mt]=!1;[pr]=!1;[fr]=!1;[sn]=null;[Q]=0;[C]=!1;[cn];[Rr]=!1;[yt]=0;[te]=!1;writable=!0;readable=!0;constructor(...e){let i=e[0]||{};if(super(),i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");vu(i)?(this[D]=!0,this[ge]=null):Au(i)?(this[ge]=i.encoding,this[D]=!1):(this[D]=!1,this[ge]=null),this[Ne]=!!i.async,this[zi]=this[ge]?new iu(this[ge]):null,i&&i.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[F]}),i&&i.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[L]});let{signal:n}=i;n&&(this[cn]=n,n.aborted?this[Bs]():n.addEventListener("abort",()=>this[Bs]()))}get bufferLength(){return this[Q]}get encoding(){return this[ge]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[D]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Ne]}set async(e){this[Ne]=this[Ne]||!!e}[Bs](){this[Rr]=!0,this.emit("abort",this[cn]?.reason),this.destroy(this[cn]?.reason)}get aborted(){return this[Rr]}set aborted(e){}write(e,i,n){if(this[Rr])return!1;if(this[Te])throw new Error("write after end");if(this[C])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof i=="function"&&(n=i,i="utf8"),i||(i="utf8");let r=this[Ne]?ln:su;if(!this[D]&&!Buffer.isBuffer(e)){if(lu(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(cu(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[D]?(this[k]&&this[Q]!==0&&this[hr](!0),this[k]?this.emit("data",e):this[Fs](e),this[Q]!==0&&this.emit("readable"),n&&r(n),this[k]):e.length?(typeof e=="string"&&!(i===this[ge]&&!this[zi]?.lastNeed)&&(e=Buffer.from(e,i)),Buffer.isBuffer(e)&&this[ge]&&(e=this[zi].write(e)),this[k]&&this[Q]!==0&&this[hr](!0),this[k]?this.emit("data",e):this[Fs](e),this[Q]!==0&&this.emit("readable"),n&&r(n),this[k]):(this[Q]!==0&&this.emit("readable"),n&&r(n),this[k])}read(e){if(this[C])return null;if(this[te]=!1,this[Q]===0||e===0||e&&e>this[Q])return this[Xe](),null;this[D]&&(e=null),this[F].length>1&&!this[D]&&(this[F]=[this[ge]?this[F].join(""):Buffer.concat(this[F],this[Q])]);let i=this[Bl](e||null,this[F][0]);return this[Xe](),i}[Bl](e,i){if(this[D])this[dr]();else{let n=i;e===n.length||e===null?this[dr]():typeof n=="string"?(this[F][0]=n.slice(e),i=n.slice(0,e),this[Q]-=e):(this[F][0]=n.subarray(e),i=n.subarray(0,e),this[Q]-=e)}return this.emit("data",i),!this[F].length&&!this[Te]&&this.emit("drain"),i}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i="utf8"),e!==void 0&&this.write(e,i),n&&this.once("end",n),this[Te]=!0,this.writable=!1,(this[k]||!this[an])&&this[Xe](),this}[ji](){this[C]||(!this[yt]&&!this[L].length&&(this[te]=!0),this[an]=!1,this[k]=!0,this.emit("resume"),this[F].length?this[hr]():this[Te]?this[Xe]():this.emit("drain"))}resume(){return this[ji]()}pause(){this[k]=!1,this[an]=!0,this[te]=!1}get destroyed(){return this[C]}get flowing(){return this[k]}get paused(){return this[an]}[Fs](e){this[D]?this[Q]+=1:this[Q]+=e.length,this[F].push(e)}[dr](){return this[D]?this[Q]-=1:this[Q]-=this[F][0].length,this[F].shift()}[hr](e=!1){do;while(this[Zl](this[dr]())&&this[F].length);!e&&!this[F].length&&!this[Te]&&this.emit("drain")}[Zl](e){return this.emit("data",e),this[k]}pipe(e,i){if(this[C])return e;this[te]=!1;let n=this[mt];return i=i||{},e===bl.stdout||e===bl.stderr?i.end=!1:i.end=i.end!==!1,i.proxyErrors=!!i.proxyErrors,n?i.end&&e.end():(this[L].push(i.proxyErrors?new Zs(this,e,i):new zr(this,e,i)),this[Ne]?ln(()=>this[ji]()):this[ji]()),e}unpipe(e){let i=this[L].find(n=>n.dest===e);i&&(this[L].length===1?(this[k]&&this[yt]===0&&(this[k]=!1),this[L]=[]):this[L].splice(this[L].indexOf(i),1),i.unpipe())}addListener(e,i){return this.on(e,i)}on(e,i){let n=super.on(e,i);if(e==="data")this[te]=!1,this[yt]++,!this[L].length&&!this[k]&&this[ji]();else if(e==="readable"&&this[Q]!==0)super.emit("readable");else if(au(e)&&this[mt])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[sn]){let r=i;this[Ne]?ln(()=>r.call(this,this[sn])):r.call(this,this[sn])}return n}removeListener(e,i){return this.off(e,i)}off(e,i){let n=super.off(e,i);return e==="data"&&(this[yt]=this.listeners("data").length,this[yt]===0&&!this[te]&&!this[L].length&&(this[k]=!1)),n}removeAllListeners(e){let i=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[yt]=0,!this[te]&&!this[L].length&&(this[k]=!1)),i}get emittedEnd(){return this[mt]}[Xe](){!this[pr]&&!this[mt]&&!this[C]&&this[F].length===0&&this[Te]&&(this[pr]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[fr]&&this.emit("close"),this[pr]=!1)}emit(e,...i){let n=i[0];if(e!=="error"&&e!=="close"&&e!==C&&this[C])return!1;if(e==="data")return!this[D]&&!n?!1:this[Ne]?(ln(()=>this[Js](n)),!0):this[Js](n);if(e==="end")return this[Pl]();if(e==="close"){if(this[fr]=!0,!this[mt]&&!this[C])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(e==="error"){this[sn]=n,super.emit(Qs,n);let o=!this[cn]||this.listeners("error").length?super.emit("error",n):!1;return this[Xe](),o}else if(e==="resume"){let o=super.emit("resume");return this[Xe](),o}else if(e==="finish"||e==="prefinish"){let o=super.emit(e);return this.removeAllListeners(e),o}let r=super.emit(e,...i);return this[Xe](),r}[Js](e){for(let n of this[L])n.dest.write(e)===!1&&this.pause();let i=this[te]?!1:super.emit("data",e);return this[Xe](),i}[Pl](){return this[mt]?!1:(this[mt]=!0,this.readable=!1,this[Ne]?(ln(()=>this[bs]()),!0):this[bs]())}[bs](){if(this[zi]){let i=this[zi].end();if(i){for(let n of this[L])n.dest.write(i);this[te]||super.emit("data",i)}}for(let i of this[L])i.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[D]||(e.dataLength=0);let i=this.promise();return this.on("data",n=>{e.push(n),this[D]||(e.dataLength+=n.length)}),await i,e}async concat(){if(this[D])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[ge]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,i)=>{this.on(C,()=>i(new Error("stream destroyed"))),this.on("error",n=>i(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[te]=!1;let e=!1,i=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return i();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Te])return i();let o,s,c=u=>{this.off("data",l),this.off("end",v),this.off(C,A),i(),s(u)},l=u=>{this.off("error",c),this.off("end",v),this.off(C,A),this.pause(),o({value:u,done:!!this[Te]})},v=()=>{this.off("error",c),this.off("data",l),this.off(C,A),i(),o({done:!0,value:void 0})},A=()=>c(new Error("stream destroyed"));return new Promise((u,I)=>{s=I,o=u,this.once(C,A),this.once("error",c),this.once("end",v),this.once("data",l)})},throw:i,return:i,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[te]=!1;let e=!1,i=()=>(this.pause(),this.off(Qs,i),this.off(C,i),this.off("end",i),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return i();let r=this.read();return r===null?i():{done:!1,value:r}};return this.once("end",i),this.once(Qs,i),this.once(C,i),{next:n,throw:i,return:i,[Symbol.iterator](){return this}}}destroy(e){if(this[C])return e?this.emit("error",e):this.emit(C),this;this[C]=!0,this[te]=!0,this[F].length=0,this[Q]=0;let i=this;return typeof i.close=="function"&&!this[fr]&&i.close(),e?this.emit("error",e):this.emit(C),this}static get isStream(){return nu}};var mu=ee.writev,It=Symbol("_autoClose"),Ge=Symbol("_close"),An=Symbol("_ended"),g=Symbol("_fd"),qs=Symbol("_finished"),Le=Symbol("_flags"),ys=Symbol("_flush"),Xs=Symbol("_handleChunk"),Hs=Symbol("_makeBuf"),mn=Symbol("_mode"),jr=Symbol("_needDrain"),Gi=Symbol("_onerror"),Si=Symbol("_onopen"),Ds=Symbol("_onread"),gi=Symbol("_onwrite"),pt=Symbol("_open"),xe=Symbol("_path"),Et=Symbol("_pos"),ke=Symbol("_queue"),xi=Symbol("_read"),ws=Symbol("_readSize"),He=Symbol("_reading"),un=Symbol("_remain"),Ts=Symbol("_size"),gr=Symbol("_write"),Dt=Symbol("_writing"),xr=Symbol("_defaultFlag"),wt=Symbol("_errored"),Tt=class extends vn{[wt]=!1;[g];[xe];[ws];[He]=!1;[Ts];[un];[It];constructor(e,i){if(i=i||{},super(i),this.readable=!0,this.writable=!1,typeof e!="string")throw new TypeError("path must be a string");this[wt]=!1,this[g]=typeof i.fd=="number"?i.fd:void 0,this[xe]=e,this[ws]=i.readSize||16*1024*1024,this[He]=!1,this[Ts]=typeof i.size=="number"?i.size:1/0,this[un]=this[Ts],this[It]=typeof i.autoClose=="boolean"?i.autoClose:!0,typeof this[g]=="number"?this[xi]():this[pt]()}get fd(){return this[g]}get path(){return this[xe]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[pt](){ee.open(this[xe],"r",(e,i)=>this[Si](e,i))}[Si](e,i){e?this[Gi](e):(this[g]=i,this.emit("open",i),this[xi]())}[Hs](){return Buffer.allocUnsafe(Math.min(this[ws],this[un]))}[xi](){if(!this[He]){this[He]=!0;let e=this[Hs]();if(e.length===0)return process.nextTick(()=>this[Ds](null,0,e));ee.read(this[g],e,0,e.length,null,(i,n,r)=>this[Ds](i,n,r))}}[Ds](e,i,n){this[He]=!1,e?this[Gi](e):this[Xs](i,n)&&this[xi]()}[Ge](){if(this[It]&&typeof this[g]=="number"){let e=this[g];this[g]=void 0,ee.close(e,i=>i?this.emit("error",i):this.emit("close"))}}[Gi](e){this[He]=!0,this[Ge](),this.emit("error",e)}[Xs](e,i){let n=!1;return this[un]-=e,e>0&&(n=super.write(e<i.length?i.subarray(0,e):i)),(e===0||this[un]<=0)&&(n=!1,this[Ge](),super.end()),n}emit(e,...i){switch(e){case"prefinish":case"finish":return!1;case"drain":return typeof this[g]=="number"&&this[xi](),!1;case"error":return this[wt]?!1:(this[wt]=!0,super.emit(e,...i));default:return super.emit(e,...i)}}},Gr=class extends Tt{[pt](){let e=!0;try{this[Si](null,ee.openSync(this[xe],"r")),e=!1}finally{e&&this[Ge]()}}[xi](){let e=!0;try{if(!this[He]){this[He]=!0;do{let i=this[Hs](),n=i.length===0?0:ee.readSync(this[g],i,0,i.length,null);if(!this[Xs](n,i))break}while(!0);this[He]=!1}e=!1}finally{e&&this[Ge]()}}[Ge](){if(this[It]&&typeof this[g]=="number"){let e=this[g];this[g]=void 0,ee.closeSync(e),this.emit("close")}}},_e=class extends uu{readable=!1;writable=!0;[wt]=!1;[Dt]=!1;[An]=!1;[ke]=[];[jr]=!1;[xe];[mn];[It];[g];[xr];[Le];[qs]=!1;[Et];constructor(e,i){i=i||{},super(i),this[xe]=e,this[g]=typeof i.fd=="number"?i.fd:void 0,this[mn]=i.mode===void 0?438:i.mode,this[Et]=typeof i.start=="number"?i.start:void 0,this[It]=typeof i.autoClose=="boolean"?i.autoClose:!0;let n=this[Et]!==void 0?"r+":"w";this[xr]=i.flags===void 0,this[Le]=i.flags===void 0?n:i.flags,this[g]===void 0&&this[pt]()}emit(e,...i){if(e==="error"){if(this[wt])return!1;this[wt]=!0}return super.emit(e,...i)}get fd(){return this[g]}get path(){return this[xe]}[Gi](e){this[Ge](),this[Dt]=!0,this.emit("error",e)}[pt](){ee.open(this[xe],this[Le],this[mn],(e,i)=>this[Si](e,i))}[Si](e,i){this[xr]&&this[Le]==="r+"&&e&&e.code==="ENOENT"?(this[Le]="w",this[pt]()):e?this[Gi](e):(this[g]=i,this.emit("open",i),this[Dt]||this[ys]())}end(e,i){return e&&this.write(e,i),this[An]=!0,!this[Dt]&&!this[ke].length&&typeof this[g]=="number"&&this[gi](null,0),this}write(e,i){return typeof e=="string"&&(e=Buffer.from(e,i)),this[An]?(this.emit("error",new Error("write() after end()")),!1):this[g]===void 0||this[Dt]||this[ke].length?(this[ke].push(e),this[jr]=!0,!1):(this[Dt]=!0,this[gr](e),!0)}[gr](e){ee.write(this[g],e,0,e.length,this[Et],(i,n)=>this[gi](i,n))}[gi](e,i){e?this[Gi](e):(this[Et]!==void 0&&typeof i=="number"&&(this[Et]+=i),this[ke].length?this[ys]():(this[Dt]=!1,this[An]&&!this[qs]?(this[qs]=!0,this[Ge](),this.emit("finish")):this[jr]&&(this[jr]=!1,this.emit("drain"))))}[ys](){if(this[ke].length===0)this[An]&&this[gi](null,0);else if(this[ke].length===1)this[gr](this[ke].pop());else{let e=this[ke];this[ke]=[],mu(this[g],e,this[Et],(i,n)=>this[gi](i,n))}}[Ge](){if(this[It]&&typeof this[g]=="number"){let e=this[g];this[g]=void 0,ee.close(e,i=>i?this.emit("error",i):this.emit("close"))}}},Yi=class extends _e{[pt](){let e;if(this[xr]&&this[Le]==="r+")try{e=ee.openSync(this[xe],this[Le],this[mn])}catch(i){if(i?.code==="ENOENT")return this[Le]="w",this[pt]();throw i}else e=ee.openSync(this[xe],this[Le],this[mn]);this[Si](null,e)}[Ge](){if(this[It]&&typeof this[g]=="number"){let e=this[g];this[g]=void 0,ee.closeSync(e),this.emit("close")}}[gr](e){let i=!0;try{this[gi](null,ee.writeSync(this[g],e,0,e.length,this[Et])),i=!1}finally{if(i)try{this[Ge]()}catch{}}}};import V3 from"node:path";import ki from"node:fs";import{dirname as vm,parse as Am}from"path";var Eu=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),yl=t=>!!t.sync&&!!t.file,Dl=t=>!t.sync&&!!t.file,wl=t=>!!t.sync&&!t.file,Tl=t=>!t.sync&&!t.file;var Xl=t=>!!t.file;var Iu=t=>{let e=Eu.get(t);return e||t},En=(t={})=>{if(!t)return{};let e={};for(let[i,n]of Object.entries(t)){let r=Iu(i);e[r]=n}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e};var Fe=(t,e,i,n,r)=>Object.assign((o=[],s,c)=>{Array.isArray(o)&&(s=o,o={}),typeof s=="function"&&(c=s,s=void 0),s?s=Array.from(s):s=[];let l=En(o);if(r?.(l,s),yl(l)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return t(l,s)}else if(Dl(l)){let v=e(l,s),A=c||void 0;return A?v.then(()=>A(),A):v}else if(wl(l)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return i(l,s)}else if(Tl(l)){if(typeof c=="function")throw new TypeError("callback only supported with file option");return n(l,s)}else throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:n,validate:r});import{EventEmitter as sm}from"events";import aa from"assert";import{Buffer as Ht}from"buffer";import{EventEmitter as ra}from"node:events";import e3 from"node:stream";import{StringDecoder as pu}from"node:string_decoder";var Hl=typeof process=="object"&&process?process:{stdout:null,stderr:null},fu=t=>!!t&&typeof t=="object"&&(t instanceof dn||t instanceof e3||hu(t)||du(t)),hu=t=>!!t&&typeof t=="object"&&t instanceof ra&&typeof t.pipe=="function"&&t.pipe!==e3.Writable.prototype.pipe,du=t=>!!t&&typeof t=="object"&&t instanceof ra&&typeof t.write=="function"&&typeof t.end=="function",$e=Symbol("EOF"),et=Symbol("maybeEmitEnd"),ft=Symbol("emittedEnd"),Sr=Symbol("emittingEnd"),In=Symbol("emittedError"),Yr=Symbol("closed"),Ll=Symbol("read"),Wr=Symbol("flush"),_l=Symbol("flushChunk"),Se=Symbol("encoding"),Wi=Symbol("decoder"),J=Symbol("flowing"),pn=Symbol("paused"),Mi=Symbol("resume"),b=Symbol("buffer"),_=Symbol("pipes"),B=Symbol("bufferLength"),_s=Symbol("bufferPush"),Mr=Symbol("bufferShift"),w=Symbol("objectMode"),O=Symbol("destroyed"),$s=Symbol("error"),ea=Symbol("emitData"),$l=Symbol("emitEnd"),ta=Symbol("emitEnd2"),Qe=Symbol("async"),ia=Symbol("abort"),Cr=Symbol("aborted"),fn=Symbol("signal"),Xt=Symbol("dataListeners"),ie=Symbol("discarded"),hn=t=>Promise.resolve().then(t),Ru=t=>t(),zu=t=>t==="end"||t==="finish"||t==="prefinish",ju=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,gu=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Or=class{src;dest;opts;ondrain;constructor(e,i,n){this.src=e,this.dest=i,this.opts=n,this.ondrain=()=>e[Mi](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},na=class extends Or{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,i,n){super(e,i,n),this.proxyErrors=r=>i.emit("error",r),e.on("error",this.proxyErrors)}},xu=t=>!!t.objectMode,Gu=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",dn=class extends ra{[J]=!1;[pn]=!1;[_]=[];[b]=[];[w];[Se];[Qe];[Wi];[$e]=!1;[ft]=!1;[Sr]=!1;[Yr]=!1;[In]=null;[B]=0;[O]=!1;[fn];[Cr]=!1;[Xt]=0;[ie]=!1;writable=!0;readable=!0;constructor(...e){let i=e[0]||{};if(super(),i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");xu(i)?(this[w]=!0,this[Se]=null):Gu(i)?(this[Se]=i.encoding,this[w]=!1):(this[w]=!1,this[Se]=null),this[Qe]=!!i.async,this[Wi]=this[Se]?new pu(this[Se]):null,i&&i.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[b]}),i&&i.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[_]});let{signal:n}=i;n&&(this[fn]=n,n.aborted?this[ia]():n.addEventListener("abort",()=>this[ia]()))}get bufferLength(){return this[B]}get encoding(){return this[Se]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[w]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Qe]}set async(e){this[Qe]=this[Qe]||!!e}[ia](){this[Cr]=!0,this.emit("abort",this[fn]?.reason),this.destroy(this[fn]?.reason)}get aborted(){return this[Cr]}set aborted(e){}write(e,i,n){if(this[Cr])return!1;if(this[$e])throw new Error("write after end");if(this[O])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof i=="function"&&(n=i,i="utf8"),i||(i="utf8");let r=this[Qe]?hn:Ru;if(!this[w]&&!Buffer.isBuffer(e)){if(gu(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(ju(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[w]?(this[J]&&this[B]!==0&&this[Wr](!0),this[J]?this.emit("data",e):this[_s](e),this[B]!==0&&this.emit("readable"),n&&r(n),this[J]):e.length?(typeof e=="string"&&!(i===this[Se]&&!this[Wi]?.lastNeed)&&(e=Buffer.from(e,i)),Buffer.isBuffer(e)&&this[Se]&&(e=this[Wi].write(e)),this[J]&&this[B]!==0&&this[Wr](!0),this[J]?this.emit("data",e):this[_s](e),this[B]!==0&&this.emit("readable"),n&&r(n),this[J]):(this[B]!==0&&this.emit("readable"),n&&r(n),this[J])}read(e){if(this[O])return null;if(this[ie]=!1,this[B]===0||e===0||e&&e>this[B])return this[et](),null;this[w]&&(e=null),this[b].length>1&&!this[w]&&(this[b]=[this[Se]?this[b].join(""):Buffer.concat(this[b],this[B])]);let i=this[Ll](e||null,this[b][0]);return this[et](),i}[Ll](e,i){if(this[w])this[Mr]();else{let n=i;e===n.length||e===null?this[Mr]():typeof n=="string"?(this[b][0]=n.slice(e),i=n.slice(0,e),this[B]-=e):(this[b][0]=n.subarray(e),i=n.subarray(0,e),this[B]-=e)}return this.emit("data",i),!this[b].length&&!this[$e]&&this.emit("drain"),i}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i="utf8"),e!==void 0&&this.write(e,i),n&&this.once("end",n),this[$e]=!0,this.writable=!1,(this[J]||!this[pn])&&this[et](),this}[Mi](){this[O]||(!this[Xt]&&!this[_].length&&(this[ie]=!0),this[pn]=!1,this[J]=!0,this.emit("resume"),this[b].length?this[Wr]():this[$e]?this[et]():this.emit("drain"))}resume(){return this[Mi]()}pause(){this[J]=!1,this[pn]=!0,this[ie]=!1}get destroyed(){return this[O]}get flowing(){return this[J]}get paused(){return this[pn]}[_s](e){this[w]?this[B]+=1:this[B]+=e.length,this[b].push(e)}[Mr](){return this[w]?this[B]-=1:this[B]-=this[b][0].length,this[b].shift()}[Wr](e=!1){do;while(this[_l](this[Mr]())&&this[b].length);!e&&!this[b].length&&!this[$e]&&this.emit("drain")}[_l](e){return this.emit("data",e),this[J]}pipe(e,i){if(this[O])return e;this[ie]=!1;let n=this[ft];return i=i||{},e===Hl.stdout||e===Hl.stderr?i.end=!1:i.end=i.end!==!1,i.proxyErrors=!!i.proxyErrors,n?i.end&&e.end():(this[_].push(i.proxyErrors?new na(this,e,i):new Or(this,e,i)),this[Qe]?hn(()=>this[Mi]()):this[Mi]()),e}unpipe(e){let i=this[_].find(n=>n.dest===e);i&&(this[_].length===1?(this[J]&&this[Xt]===0&&(this[J]=!1),this[_]=[]):this[_].splice(this[_].indexOf(i),1),i.unpipe())}addListener(e,i){return this.on(e,i)}on(e,i){let n=super.on(e,i);if(e==="data")this[ie]=!1,this[Xt]++,!this[_].length&&!this[J]&&this[Mi]();else if(e==="readable"&&this[B]!==0)super.emit("readable");else if(zu(e)&&this[ft])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[In]){let r=i;this[Qe]?hn(()=>r.call(this,this[In])):r.call(this,this[In])}return n}removeListener(e,i){return this.off(e,i)}off(e,i){let n=super.off(e,i);return e==="data"&&(this[Xt]=this.listeners("data").length,this[Xt]===0&&!this[ie]&&!this[_].length&&(this[J]=!1)),n}removeAllListeners(e){let i=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Xt]=0,!this[ie]&&!this[_].length&&(this[J]=!1)),i}get emittedEnd(){return this[ft]}[et](){!this[Sr]&&!this[ft]&&!this[O]&&this[b].length===0&&this[$e]&&(this[Sr]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Yr]&&this.emit("close"),this[Sr]=!1)}emit(e,...i){let n=i[0];if(e!=="error"&&e!=="close"&&e!==O&&this[O])return!1;if(e==="data")return!this[w]&&!n?!1:this[Qe]?(hn(()=>this[ea](n)),!0):this[ea](n);if(e==="end")return this[$l]();if(e==="close"){if(this[Yr]=!0,!this[ft]&&!this[O])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(e==="error"){this[In]=n,super.emit($s,n);let o=!this[fn]||this.listeners("error").length?super.emit("error",n):!1;return this[et](),o}else if(e==="resume"){let o=super.emit("resume");return this[et](),o}else if(e==="finish"||e==="prefinish"){let o=super.emit(e);return this.removeAllListeners(e),o}let r=super.emit(e,...i);return this[et](),r}[ea](e){for(let n of this[_])n.dest.write(e)===!1&&this.pause();let i=this[ie]?!1:super.emit("data",e);return this[et](),i}[$l](){return this[ft]?!1:(this[ft]=!0,this.readable=!1,this[Qe]?(hn(()=>this[ta]()),!0):this[ta]())}[ta](){if(this[Wi]){let i=this[Wi].end();if(i){for(let n of this[_])n.dest.write(i);this[ie]||super.emit("data",i)}}for(let i of this[_])i.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[w]||(e.dataLength=0);let i=this.promise();return this.on("data",n=>{e.push(n),this[w]||(e.dataLength+=n.length)}),await i,e}async concat(){if(this[w])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Se]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,i)=>{this.on(O,()=>i(new Error("stream destroyed"))),this.on("error",n=>i(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[ie]=!1;let e=!1,i=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return i();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[$e])return i();let o,s,c=u=>{this.off("data",l),this.off("end",v),this.off(O,A),i(),s(u)},l=u=>{this.off("error",c),this.off("end",v),this.off(O,A),this.pause(),o({value:u,done:!!this[$e]})},v=()=>{this.off("error",c),this.off("data",l),this.off(O,A),i(),o({done:!0,value:void 0})},A=()=>c(new Error("stream destroyed"));return new Promise((u,I)=>{s=I,o=u,this.once(O,A),this.once("error",c),this.once("end",v),this.once("data",l)})},throw:i,return:i,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[ie]=!1;let e=!1,i=()=>(this.pause(),this.off($s,i),this.off(O,i),this.off("end",i),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return i();let r=this.read();return r===null?i():{done:!1,value:r}};return this.once("end",i),this.once($s,i),this.once(O,i),{next:n,throw:i,return:i,[Symbol.iterator](){return this}}}destroy(e){if(this[O])return e?this.emit("error",e):this.emit(O),this;this[O]=!0,this[ie]=!0,this[b].length=0,this[B]=0;let i=this;return typeof i.close=="function"&&!this[Yr]&&i.close(),e?this.emit("error",e):this.emit(O),this}static get isStream(){return fu}};import*as t3 from"zlib";import Su from"zlib";var Yu=Su.constants||{ZLIB_VERNUM:4736},Ie=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Yu));var Wu=Ht.concat,i3=Object.getOwnPropertyDescriptor(Ht,"concat"),Mu=t=>t,oa=i3?.writable===!0||i3?.set!==void 0?t=>{Ht.concat=t?Mu:Wu}:t=>{},Lt=Symbol("_superWrite"),Ci=class extends Error{code;errno;constructor(e,i){super("zlib: "+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+e.message,Error.captureStackTrace(this,i??this.constructor)}get name(){return"ZlibError"}},sa=Symbol("flushFlag"),Rn=class extends dn{#e=!1;#n=!1;#i;#r;#a;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#i}constructor(e,i){if(!e||typeof e!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(e),this.#i=e.flush??0,this.#r=e.finishFlush??0,this.#a=e.fullFlushFlag??0,typeof t3[i]!="function")throw new TypeError("Compression method not supported: "+i);try{this.#t=new t3[i](e)}catch(n){throw new Ci(n,this.constructor)}this.#o=n=>{this.#e||(this.#e=!0,this.close(),this.emit("error",n))},this.#t?.on("error",n=>this.#o(new Ci(n))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return aa(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(e){this.ended||(typeof e!="number"&&(e=this.#a),this.write(Object.assign(Ht.alloc(0),{[sa]:e})))}end(e,i,n){return typeof e=="function"&&(n=e,i=void 0,e=void 0),typeof i=="function"&&(n=i,i=void 0),e&&(i?this.write(e,i):this.write(e)),this.flush(this.#r),this.#n=!0,super.end(n)}get ended(){return this.#n}[Lt](e){return super.write(e)}write(e,i,n){if(typeof i=="function"&&(n=i,i="utf8"),typeof e=="string"&&(e=Ht.from(e,i)),this.#e)return;aa(this.#t,"zlib binding closed");let r=this.#t._handle,o=r.close;r.close=()=>{};let s=this.#t.close;this.#t.close=()=>{},oa(!0);let c;try{let v=typeof e[sa]=="number"?e[sa]:this.#i;c=this.#t._processChunk(e,v),oa(!1)}catch(v){oa(!1),this.#o(new Ci(v,this.write))}finally{this.#t&&(this.#t._handle=r,r.close=o,this.#t.close=s,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",v=>this.#o(new Ci(v,this.write)));let l;if(c)if(Array.isArray(c)&&c.length>0){let v=c[0];l=this[Lt](Ht.from(v));for(let A=1;A<c.length;A++)l=this[Lt](c[A])}else l=this[Lt](Ht.from(c));return n&&n(),l}},Ur=class extends Rn{#e;#n;constructor(e,i){e=e||{},e.flush=e.flush||Ie.Z_NO_FLUSH,e.finishFlush=e.finishFlush||Ie.Z_FINISH,e.fullFlushFlag=Ie.Z_FULL_FLUSH,super(e,i),this.#e=e.level,this.#n=e.strategy}params(e,i){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==e||this.#n!==i){this.flush(Ie.Z_SYNC_FLUSH),aa(this.handle,"zlib binding closed");let n=this.handle.flush;this.handle.flush=(r,o)=>{typeof r=="function"&&(o=r,r=this.flushFlag),this.flush(r),o?.()};try{this.handle.params(e,i)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#n=i)}}}};var Kr=class extends Ur{#e;constructor(e){super(e,"Gzip"),this.#e=e&&!!e.portable}[Lt](e){return this.#e?(this.#e=!1,e[9]=255,super[Lt](e)):super[Lt](e)}};var Vr=class extends Ur{constructor(e){super(e,"Unzip")}},Nr=class extends Rn{constructor(e,i){e=e||{},e.flush=e.flush||Ie.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||Ie.BROTLI_OPERATION_FINISH,e.fullFlushFlag=Ie.BROTLI_OPERATION_FLUSH,super(e,i)}},kr=class extends Nr{constructor(e){super(e,"BrotliCompress")}},Fr=class extends Nr{constructor(e){super(e,"BrotliDecompress")}},Qr=class extends Rn{constructor(e,i){e=e||{},e.flush=e.flush||Ie.ZSTD_e_continue,e.finishFlush=e.finishFlush||Ie.ZSTD_e_end,e.fullFlushFlag=Ie.ZSTD_e_flush,super(e,i)}},Jr=class extends Qr{constructor(e){super(e,"ZstdCompress")}},br=class extends Qr{constructor(e){super(e,"ZstdDecompress")}};import{posix as Oi}from"node:path";var n3=(t,e)=>{if(Number.isSafeInteger(t))t<0?Uu(t,e):Ou(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Ou=(t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=t&255,t=Math.floor(t/256)},Uu=(t,e)=>{e[0]=255;var i=!1;t=t*-1;for(var n=e.length;n>1;n--){var r=t&255;t=Math.floor(t/256),i?e[n-1]=o3(r):r===0?e[n-1]=0:(i=!0,e[n-1]=s3(r))}},r3=t=>{let e=t[0],i=e===128?Vu(t.subarray(1,t.length)):e===255?Ku(t):null;if(i===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i},Ku=t=>{for(var e=t.length,i=0,n=!1,r=e-1;r>-1;r--){var o=Number(t[r]),s;n?s=o3(o):o===0?s=o:(n=!0,s=s3(o)),s!==0&&(i-=s*Math.pow(256,e-r-1))}return i},Vu=t=>{for(var e=t.length,i=0,n=e-1;n>-1;n--){var r=Number(t[n]);r!==0&&(i+=r*Math.pow(256,e-n-1))}return i},o3=t=>(255^t)&255,s3=t=>(255^t)+1&255;var Br=t=>Zr.has(t);var Zr=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),a3=new Map(Array.from(Zr).map(t=>[t[1],t[0]]));var ne=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,i=0,n,r){Buffer.isBuffer(e)?this.decode(e,i||0,n,r):e&&this.#n(e)}decode(e,i,n,r){if(i||(i=0),!e||!(e.length>=i+512))throw new Error("need 512 bytes for header");this.path=n?.path??_t(e,i,100),this.mode=n?.mode??r?.mode??ht(e,i+100,8),this.uid=n?.uid??r?.uid??ht(e,i+108,8),this.gid=n?.gid??r?.gid??ht(e,i+116,8),this.size=n?.size??r?.size??ht(e,i+124,12),this.mtime=n?.mtime??r?.mtime??ca(e,i+136,12),this.cksum=ht(e,i+148,12),r&&this.#n(r,!0),n&&this.#n(n);let o=_t(e,i+156,1);if(Br(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=_t(e,i+157,100),e.subarray(i+257,i+265).toString()==="ustar\x0000")if(this.uname=n?.uname??r?.uname??_t(e,i+265,32),this.gname=n?.gname??r?.gname??_t(e,i+297,32),this.devmaj=n?.devmaj??r?.devmaj??ht(e,i+329,8)??0,this.devmin=n?.devmin??r?.devmin??ht(e,i+337,8)??0,e[i+475]!==0){let c=_t(e,i+345,155);this.path=c+"/"+this.path}else{let c=_t(e,i+345,130);c&&(this.path=c+"/"+this.path),this.atime=n?.atime??r?.atime??ca(e,i+476,12),this.ctime=n?.ctime??r?.ctime??ca(e,i+488,12)}let s=256;for(let c=i;c<i+148;c++)s+=e[c];for(let c=i+156;c<i+512;c++)s+=e[c];this.cksumValid=s===this.cksum,this.cksum===void 0&&s===256&&(this.nullBlock=!0)}#n(e,i=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,r])=>!(r==null||n==="path"&&i||n==="linkpath"&&i||n==="global"))))}encode(e,i=0){if(e||(e=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=i+512))throw new Error("need 512 bytes for header");let n=this.ctime||this.atime?130:155,r=ku(this.path||"",n),o=r[0],s=r[1];this.needPax=!!r[2],this.needPax=$t(e,i,100,o)||this.needPax,this.needPax=dt(e,i+100,8,this.mode)||this.needPax,this.needPax=dt(e,i+108,8,this.uid)||this.needPax,this.needPax=dt(e,i+116,8,this.gid)||this.needPax,this.needPax=dt(e,i+124,12,this.size)||this.needPax,this.needPax=la(e,i+136,12,this.mtime)||this.needPax,e[i+156]=this.#e.charCodeAt(0),this.needPax=$t(e,i+157,100,this.linkpath)||this.needPax,e.write("ustar\x0000",i+257,8),this.needPax=$t(e,i+265,32,this.uname)||this.needPax,this.needPax=$t(e,i+297,32,this.gname)||this.needPax,this.needPax=dt(e,i+329,8,this.devmaj)||this.needPax,this.needPax=dt(e,i+337,8,this.devmin)||this.needPax,this.needPax=$t(e,i+345,n,s)||this.needPax,e[i+475]!==0?this.needPax=$t(e,i+345,155,s)||this.needPax:(this.needPax=$t(e,i+345,130,s)||this.needPax,this.needPax=la(e,i+476,12,this.atime)||this.needPax,this.needPax=la(e,i+488,12,this.ctime)||this.needPax);let c=256;for(let l=i;l<i+148;l++)c+=e[l];for(let l=i+156;l<i+512;l++)c+=e[l];return this.cksum=c,dt(e,i+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Zr.get(this.#e)}get typeKey(){return this.#e}set type(e){let i=String(a3.get(e));if(Br(i)||i==="Unsupported")this.#e=i;else if(Br(e))this.#e=e;else throw new TypeError("invalid entry type: "+e)}},ku=(t,e)=>{let n=t,r="",o,s=Oi.parse(t).root||".";if(Buffer.byteLength(n)<100)o=[n,r,!1];else{r=Oi.dirname(n),n=Oi.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(r)<=e?o=[n,r,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(r)<=e?o=[n.slice(0,99),r,!0]:(n=Oi.join(Oi.basename(r),n),r=Oi.dirname(r));while(r!==s&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},_t=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),ca=(t,e,i)=>Fu(ht(t,e,i)),Fu=t=>t===void 0?void 0:new Date(t*1e3),ht=(t,e,i)=>Number(t[e])&128?r3(t.subarray(e,e+i)):Ju(t,e,i),Qu=t=>isNaN(t)?void 0:t,Ju=(t,e,i)=>Qu(parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),bu={12:8589934591,8:2097151},dt=(t,e,i,n)=>n===void 0?!1:n>bu[i]||n<0?(n3(n,t.subarray(e,e+i)),!0):(Bu(t,e,i,n),!1),Bu=(t,e,i,n)=>t.write(Zu(n,i),e,i,"ascii"),Zu=(t,e)=>Pu(Math.floor(t).toString(8),e),Pu=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",la=(t,e,i,n)=>n===void 0?!1:dt(t,e,i,n.getTime()/1e3),qu=new Array(156).join("\0"),$t=(t,e,i,n)=>n===void 0?!1:(t.write(n+qu,e,i,"utf8"),n.length!==Buffer.byteLength(n)||n.length>i);import{basename as yu}from"node:path";var Rt=class t{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,i=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=i,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(e),n=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(n);for(let o=0;o<512;o++)r[o]=0;new ne({path:("PaxHeader/"+yu(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:i,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(r),r.write(e,512,i,"utf8");for(let o=i+512;o<r.length;o++)r[o]=0;return r}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let i=this[e],n=i instanceof Date?i.getTime()/1e3:i,r=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+n+`
|
|
18
|
-
`,
|
|
19
|
-
`).reduce(Tu,Object.create(null)),Tu=(t,e)=>{let i=parseInt(e,10);if(i!==Buffer.byteLength(e)+1)return t;e=e.slice((i+" ").length);let n=e.split("="),r=n.shift();if(!r)return t;let o=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),s=n.join("=");return t[o]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(o)?new Date(Number(s)*1e3):/^[0-9]+$/.test(s)?+s:s,t};import{EventEmitter as pa}from"node:events";import m3 from"node:stream";import{StringDecoder as Xu}from"node:string_decoder";var l3=typeof process=="object"&&process?process:{stdout:null,stderr:null},Hu=t=>!!t&&typeof t=="object"&&(t instanceof be||t instanceof m3||Lu(t)||_u(t)),Lu=t=>!!t&&typeof t=="object"&&t instanceof pa&&typeof t.pipe=="function"&&t.pipe!==m3.Writable.prototype.pipe,_u=t=>!!t&&typeof t=="object"&&t instanceof pa&&typeof t.write=="function"&&typeof t.end=="function",tt=Symbol("EOF"),it=Symbol("maybeEmitEnd"),zt=Symbol("emittedEnd"),Pr=Symbol("emittingEnd"),zn=Symbol("emittedError"),qr=Symbol("closed"),v3=Symbol("read"),yr=Symbol("flush"),A3=Symbol("flushChunk"),Ye=Symbol("encoding"),Ui=Symbol("decoder"),Z=Symbol("flowing"),jn=Symbol("paused"),Ki=Symbol("resume"),P=Symbol("buffer"),$=Symbol("pipes"),q=Symbol("bufferLength"),va=Symbol("bufferPush"),Dr=Symbol("bufferShift"),T=Symbol("objectMode"),U=Symbol("destroyed"),Aa=Symbol("error"),ua=Symbol("emitData"),u3=Symbol("emitEnd"),ma=Symbol("emitEnd2"),Je=Symbol("async"),Ea=Symbol("abort"),wr=Symbol("aborted"),gn=Symbol("signal"),ei=Symbol("dataListeners"),re=Symbol("discarded"),xn=t=>Promise.resolve().then(t),$u=t=>t(),em=t=>t==="end"||t==="finish"||t==="prefinish",tm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,im=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Tr=class{src;dest;opts;ondrain;constructor(e,i,n){this.src=e,this.dest=i,this.opts=n,this.ondrain=()=>e[Ki](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ia=class extends Tr{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,i,n){super(e,i,n),this.proxyErrors=r=>i.emit("error",r),e.on("error",this.proxyErrors)}},nm=t=>!!t.objectMode,rm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",be=class extends pa{[Z]=!1;[jn]=!1;[$]=[];[P]=[];[T];[Ye];[Je];[Ui];[tt]=!1;[zt]=!1;[Pr]=!1;[qr]=!1;[zn]=null;[q]=0;[U]=!1;[gn];[wr]=!1;[ei]=0;[re]=!1;writable=!0;readable=!0;constructor(...e){let i=e[0]||{};if(super(),i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");nm(i)?(this[T]=!0,this[Ye]=null):rm(i)?(this[Ye]=i.encoding,this[T]=!1):(this[T]=!1,this[Ye]=null),this[Je]=!!i.async,this[Ui]=this[Ye]?new Xu(this[Ye]):null,i&&i.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[P]}),i&&i.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[$]});let{signal:n}=i;n&&(this[gn]=n,n.aborted?this[Ea]():n.addEventListener("abort",()=>this[Ea]()))}get bufferLength(){return this[q]}get encoding(){return this[Ye]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[T]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Je]}set async(e){this[Je]=this[Je]||!!e}[Ea](){this[wr]=!0,this.emit("abort",this[gn]?.reason),this.destroy(this[gn]?.reason)}get aborted(){return this[wr]}set aborted(e){}write(e,i,n){if(this[wr])return!1;if(this[tt])throw new Error("write after end");if(this[U])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof i=="function"&&(n=i,i="utf8"),i||(i="utf8");let r=this[Je]?xn:$u;if(!this[T]&&!Buffer.isBuffer(e)){if(im(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(tm(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[T]?(this[Z]&&this[q]!==0&&this[yr](!0),this[Z]?this.emit("data",e):this[va](e),this[q]!==0&&this.emit("readable"),n&&r(n),this[Z]):e.length?(typeof e=="string"&&!(i===this[Ye]&&!this[Ui]?.lastNeed)&&(e=Buffer.from(e,i)),Buffer.isBuffer(e)&&this[Ye]&&(e=this[Ui].write(e)),this[Z]&&this[q]!==0&&this[yr](!0),this[Z]?this.emit("data",e):this[va](e),this[q]!==0&&this.emit("readable"),n&&r(n),this[Z]):(this[q]!==0&&this.emit("readable"),n&&r(n),this[Z])}read(e){if(this[U])return null;if(this[re]=!1,this[q]===0||e===0||e&&e>this[q])return this[it](),null;this[T]&&(e=null),this[P].length>1&&!this[T]&&(this[P]=[this[Ye]?this[P].join(""):Buffer.concat(this[P],this[q])]);let i=this[v3](e||null,this[P][0]);return this[it](),i}[v3](e,i){if(this[T])this[Dr]();else{let n=i;e===n.length||e===null?this[Dr]():typeof n=="string"?(this[P][0]=n.slice(e),i=n.slice(0,e),this[q]-=e):(this[P][0]=n.subarray(e),i=n.subarray(0,e),this[q]-=e)}return this.emit("data",i),!this[P].length&&!this[tt]&&this.emit("drain"),i}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i="utf8"),e!==void 0&&this.write(e,i),n&&this.once("end",n),this[tt]=!0,this.writable=!1,(this[Z]||!this[jn])&&this[it](),this}[Ki](){this[U]||(!this[ei]&&!this[$].length&&(this[re]=!0),this[jn]=!1,this[Z]=!0,this.emit("resume"),this[P].length?this[yr]():this[tt]?this[it]():this.emit("drain"))}resume(){return this[Ki]()}pause(){this[Z]=!1,this[jn]=!0,this[re]=!1}get destroyed(){return this[U]}get flowing(){return this[Z]}get paused(){return this[jn]}[va](e){this[T]?this[q]+=1:this[q]+=e.length,this[P].push(e)}[Dr](){return this[T]?this[q]-=1:this[q]-=this[P][0].length,this[P].shift()}[yr](e=!1){do;while(this[A3](this[Dr]())&&this[P].length);!e&&!this[P].length&&!this[tt]&&this.emit("drain")}[A3](e){return this.emit("data",e),this[Z]}pipe(e,i){if(this[U])return e;this[re]=!1;let n=this[zt];return i=i||{},e===l3.stdout||e===l3.stderr?i.end=!1:i.end=i.end!==!1,i.proxyErrors=!!i.proxyErrors,n?i.end&&e.end():(this[$].push(i.proxyErrors?new Ia(this,e,i):new Tr(this,e,i)),this[Je]?xn(()=>this[Ki]()):this[Ki]()),e}unpipe(e){let i=this[$].find(n=>n.dest===e);i&&(this[$].length===1?(this[Z]&&this[ei]===0&&(this[Z]=!1),this[$]=[]):this[$].splice(this[$].indexOf(i),1),i.unpipe())}addListener(e,i){return this.on(e,i)}on(e,i){let n=super.on(e,i);if(e==="data")this[re]=!1,this[ei]++,!this[$].length&&!this[Z]&&this[Ki]();else if(e==="readable"&&this[q]!==0)super.emit("readable");else if(em(e)&&this[zt])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[zn]){let r=i;this[Je]?xn(()=>r.call(this,this[zn])):r.call(this,this[zn])}return n}removeListener(e,i){return this.off(e,i)}off(e,i){let n=super.off(e,i);return e==="data"&&(this[ei]=this.listeners("data").length,this[ei]===0&&!this[re]&&!this[$].length&&(this[Z]=!1)),n}removeAllListeners(e){let i=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[ei]=0,!this[re]&&!this[$].length&&(this[Z]=!1)),i}get emittedEnd(){return this[zt]}[it](){!this[Pr]&&!this[zt]&&!this[U]&&this[P].length===0&&this[tt]&&(this[Pr]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[qr]&&this.emit("close"),this[Pr]=!1)}emit(e,...i){let n=i[0];if(e!=="error"&&e!=="close"&&e!==U&&this[U])return!1;if(e==="data")return!this[T]&&!n?!1:this[Je]?(xn(()=>this[ua](n)),!0):this[ua](n);if(e==="end")return this[u3]();if(e==="close"){if(this[qr]=!0,!this[zt]&&!this[U])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(e==="error"){this[zn]=n,super.emit(Aa,n);let o=!this[gn]||this.listeners("error").length?super.emit("error",n):!1;return this[it](),o}else if(e==="resume"){let o=super.emit("resume");return this[it](),o}else if(e==="finish"||e==="prefinish"){let o=super.emit(e);return this.removeAllListeners(e),o}let r=super.emit(e,...i);return this[it](),r}[ua](e){for(let n of this[$])n.dest.write(e)===!1&&this.pause();let i=this[re]?!1:super.emit("data",e);return this[it](),i}[u3](){return this[zt]?!1:(this[zt]=!0,this.readable=!1,this[Je]?(xn(()=>this[ma]()),!0):this[ma]())}[ma](){if(this[Ui]){let i=this[Ui].end();if(i){for(let n of this[$])n.dest.write(i);this[re]||super.emit("data",i)}}for(let i of this[$])i.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[T]||(e.dataLength=0);let i=this.promise();return this.on("data",n=>{e.push(n),this[T]||(e.dataLength+=n.length)}),await i,e}async concat(){if(this[T])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Ye]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,i)=>{this.on(U,()=>i(new Error("stream destroyed"))),this.on("error",n=>i(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[re]=!1;let e=!1,i=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return i();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[tt])return i();let o,s,c=u=>{this.off("data",l),this.off("end",v),this.off(U,A),i(),s(u)},l=u=>{this.off("error",c),this.off("end",v),this.off(U,A),this.pause(),o({value:u,done:!!this[tt]})},v=()=>{this.off("error",c),this.off("data",l),this.off(U,A),i(),o({done:!0,value:void 0})},A=()=>c(new Error("stream destroyed"));return new Promise((u,I)=>{s=I,o=u,this.once(U,A),this.once("error",c),this.once("end",v),this.once("data",l)})},throw:i,return:i,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[re]=!1;let e=!1,i=()=>(this.pause(),this.off(Aa,i),this.off(U,i),this.off("end",i),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return i();let r=this.read();return r===null?i():{done:!1,value:r}};return this.once("end",i),this.once(Aa,i),this.once(U,i),{next:n,throw:i,return:i,[Symbol.iterator](){return this}}}destroy(e){if(this[U])return e?this.emit("error",e):this.emit(U),this;this[U]=!0,this[re]=!0,this[P].length=0,this[q]=0;let i=this;return typeof i.close=="function"&&!this[qr]&&i.close(),e?this.emit("error",e):this.emit(U),this}static get isStream(){return Hu}};var om=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,z=om!=="win32"?t=>t:t=>t&&t.replace(/\\/g,"/");var Vi=class extends be{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,i,n){switch(super({}),this.pause(),this.extended=i,this.globalExtended=n,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw new Error("no path provided for tar.ReadEntry");this.path=z(e.path),this.mode=e.mode,this.mode&&(this.mode=this.mode&4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?z(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,i&&this.#e(i),n&&this.#e(n,!0)}write(e){let i=e.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");let n=this.remain,r=this.blockRemain;return this.remain=Math.max(0,n-i),this.blockRemain=Math.max(0,r-i),this.ignore?!0:n>=i?super.write(e):super.write(e.subarray(0,n))}#e(e,i=!1){e.path&&(e.path=z(e.path)),e.linkpath&&(e.linkpath=z(e.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,r])=>!(r==null||n==="path"&&i))))}};var ti=(t,e,i,n={})=>{t.file&&(n.file=t.file),t.cwd&&(n.cwd=t.cwd),n.code=i instanceof Error&&i.code||e,n.tarCode=e,!t.strict&&n.recoverable!==!1?(i instanceof Error&&(n=Object.assign(i,n),i=i.message),t.emit("warn",e,i,n)):i instanceof Error?t.emit("error",Object.assign(i,n)):t.emit("error",Object.assign(new Error(`${e}: ${i}`),n))};var am=1024*1024,za=Buffer.from([31,139]),ja=Buffer.from([40,181,47,253]),cm=Math.max(za.length,ja.length),pe=Symbol("state"),ii=Symbol("writeEntry"),nt=Symbol("readEntry"),fa=Symbol("nextEntry"),E3=Symbol("processEntry"),Be=Symbol("extendedHeader"),Gn=Symbol("globalExtendedHeader"),jt=Symbol("meta"),I3=Symbol("emitMeta"),x=Symbol("buffer"),rt=Symbol("queue"),gt=Symbol("ended"),ha=Symbol("emittedEnd"),ni=Symbol("emit"),K=Symbol("unzip"),Xr=Symbol("consumeChunk"),Hr=Symbol("consumeChunkSub"),da=Symbol("consumeBody"),p3=Symbol("consumeMeta"),f3=Symbol("consumeHeader"),Sn=Symbol("consuming"),Ra=Symbol("bufferConcat"),Lr=Symbol("maybeEnd"),Ni=Symbol("writing"),xt=Symbol("aborted"),_r=Symbol("onDone"),ri=Symbol("sawValidEntry"),$r=Symbol("sawNullBlock"),eo=Symbol("sawEOF"),h3=Symbol("closeStream"),lm=()=>!0,ot=class extends sm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[rt]=[];[x];[nt];[ii];[pe]="begin";[jt]="";[Be];[Gn];[gt]=!1;[K];[xt]=!1;[ri];[$r]=!1;[eo]=!1;[Ni]=!1;[Sn]=!1;[ha]=!1;constructor(e={}){super(),this.file=e.file||"",this.on(_r,()=>{(this[pe]==="begin"||this[ri]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),e.ondone?this.on(_r,e.ondone):this.on(_r,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||am,this.filter=typeof e.filter=="function"?e.filter:lm;let i=e.file&&(e.file.endsWith(".tar.br")||e.file.endsWith(".tbr"));this.brotli=!(e.gzip||e.zstd)&&e.brotli!==void 0?e.brotli:i?void 0:!1;let n=e.file&&(e.file.endsWith(".tar.zst")||e.file.endsWith(".tzst"));this.zstd=!(e.gzip||e.brotli)&&e.zstd!==void 0?e.zstd:n?!0:void 0,this.on("end",()=>this[h3]()),typeof e.onwarn=="function"&&this.on("warn",e.onwarn),typeof e.onReadEntry=="function"&&this.on("entry",e.onReadEntry)}warn(e,i,n={}){ti(this,e,i,n)}[f3](e,i){this[ri]===void 0&&(this[ri]=!1);let n;try{n=new ne(e,i,this[Be],this[Gn])}catch(r){return this.warn("TAR_ENTRY_INVALID",r)}if(n.nullBlock)this[$r]?(this[eo]=!0,this[pe]==="begin"&&(this[pe]="header"),this[ni]("eof")):(this[$r]=!0,this[ni]("nullBlock"));else if(this[$r]=!1,!n.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:n});else if(!n.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:n});else{let r=n.type;if(/^(Symbolic)?Link$/.test(r)&&!n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:n});else if(!/^(Symbolic)?Link$/.test(r)&&!/^(Global)?ExtendedHeader$/.test(r)&&n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:n});else{let o=this[ii]=new Vi(n,this[Be],this[Gn]);if(!this[ri])if(o.remain){let s=()=>{o.invalid||(this[ri]=!0)};o.on("end",s)}else this[ri]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[ni]("ignoredEntry",o),this[pe]="ignore",o.resume()):o.size>0&&(this[jt]="",o.on("data",s=>this[jt]+=s),this[pe]="meta"):(this[Be]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[ni]("ignoredEntry",o),this[pe]=o.remain?"ignore":"header",o.resume()):(o.remain?this[pe]="body":(this[pe]="header",o.end()),this[nt]?this[rt].push(o):(this[rt].push(o),this[fa]())))}}}[h3](){queueMicrotask(()=>this.emit("close"))}[E3](e){let i=!0;if(!e)this[nt]=void 0,i=!1;else if(Array.isArray(e)){let[n,...r]=e;this.emit(n,...r)}else this[nt]=e,this.emit("entry",e),e.emittedEnd||(e.on("end",()=>this[fa]()),i=!1);return i}[fa](){do;while(this[E3](this[rt].shift()));if(!this[rt].length){let e=this[nt];!e||e.flowing||e.size===e.remain?this[Ni]||this.emit("drain"):e.once("drain",()=>this.emit("drain"))}}[da](e,i){let n=this[ii];if(!n)throw new Error("attempt to consume body without entry??");let r=n.blockRemain??0,o=r>=e.length&&i===0?e:e.subarray(i,i+r);return n.write(o),n.blockRemain||(this[pe]="header",this[ii]=void 0,n.end()),o.length}[p3](e,i){let n=this[ii],r=this[da](e,i);return!this[ii]&&n&&this[I3](n),r}[ni](e,i,n){!this[rt].length&&!this[nt]?this.emit(e,i,n):this[rt].push([e,i,n])}[I3](e){switch(this[ni]("meta",this[jt]),e.type){case"ExtendedHeader":case"OldExtendedHeader":this[Be]=Rt.parse(this[jt],this[Be],!1);break;case"GlobalExtendedHeader":this[Gn]=Rt.parse(this[jt],this[Gn],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let i=this[Be]??Object.create(null);this[Be]=i,i.path=this[jt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let i=this[Be]||Object.create(null);this[Be]=i,i.linkpath=this[jt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+e.type)}}abort(e){this[xt]=!0,this.emit("abort",e),this.warn("TAR_ABORT",e,{recoverable:!1})}write(e,i,n){if(typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof i=="string"?i:"utf8")),this[xt])return n?.(),!1;if((this[K]===void 0||this.brotli===void 0&&this[K]===!1)&&e){if(this[x]&&(e=Buffer.concat([this[x],e]),this[x]=void 0),e.length<cm)return this[x]=e,n?.(),!0;for(let l=0;this[K]===void 0&&l<za.length;l++)e[l]!==za[l]&&(this[K]=!1);let s=!1;if(this[K]===!1&&this.zstd!==!1){s=!0;for(let l=0;l<ja.length;l++)if(e[l]!==ja[l]){s=!1;break}}let c=this.brotli===void 0&&!s;if(this[K]===!1&&c)if(e.length<512)if(this[gt])this.brotli=!0;else return this[x]=e,n?.(),!0;else try{new ne(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[K]===void 0||this[K]===!1&&(this.brotli||s)){let l=this[gt];this[gt]=!1,this[K]=this[K]===void 0?new Vr({}):s?new br({}):new Fr({}),this[K].on("data",A=>this[Xr](A)),this[K].on("error",A=>this.abort(A)),this[K].on("end",()=>{this[gt]=!0,this[Xr]()}),this[Ni]=!0;let v=!!this[K][l?"end":"write"](e);return this[Ni]=!1,n?.(),v}}this[Ni]=!0,this[K]?this[K].write(e):this[Xr](e),this[Ni]=!1;let o=this[rt].length?!1:this[nt]?this[nt].flowing:!0;return!o&&!this[rt].length&&this[nt]?.once("drain",()=>this.emit("drain")),n?.(),o}[Ra](e){e&&!this[xt]&&(this[x]=this[x]?Buffer.concat([this[x],e]):e)}[Lr](){if(this[gt]&&!this[ha]&&!this[xt]&&!this[Sn]){this[ha]=!0;let e=this[ii];if(e&&e.blockRemain){let i=this[x]?this[x].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${e.blockRemain} more bytes, only ${i} available)`,{entry:e}),this[x]&&e.write(this[x]),e.end()}this[ni](_r)}}[Xr](e){if(this[Sn]&&e)this[Ra](e);else if(!e&&!this[x])this[Lr]();else if(e){if(this[Sn]=!0,this[x]){this[Ra](e);let i=this[x];this[x]=void 0,this[Hr](i)}else this[Hr](e);for(;this[x]&&this[x]?.length>=512&&!this[xt]&&!this[eo];){let i=this[x];this[x]=void 0,this[Hr](i)}this[Sn]=!1}(!this[x]||this[gt])&&this[Lr]()}[Hr](e){let i=0,n=e.length;for(;i+512<=n&&!this[xt]&&!this[eo];)switch(this[pe]){case"begin":case"header":this[f3](e,i),i+=512;break;case"ignore":case"body":i+=this[da](e,i);break;case"meta":i+=this[p3](e,i);break;default:throw new Error("invalid state: "+this[pe])}i<n&&(this[x]?this[x]=Buffer.concat([e.subarray(i),this[x]]):this[x]=e.subarray(i))}end(e,i,n){return typeof e=="function"&&(n=e,i=void 0,e=void 0),typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,i)),n&&this.once("finish",n),this[xt]||(this[K]?(e&&this[K].write(e),this[K].end()):(this[gt]=!0,(this.brotli===void 0||this.zstd===void 0)&&(e=e||Buffer.alloc(0)),e&&this.write(e),this[Lr]())),this}};var Gt=t=>{let e=t.length-1,i=-1;for(;e>-1&&t.charAt(e)==="/";)i=e,e--;return i===-1?t:t.slice(0,i)};var um=t=>{let e=t.onReadEntry;t.onReadEntry=e?i=>{e(i),i.resume()}:i=>i.resume()},ga=(t,e)=>{let i=new Map(e.map(o=>[Gt(o),!0])),n=t.filter,r=(o,s="")=>{let c=s||Am(o).root||".",l;if(o===c)l=!1;else{let v=i.get(o);v!==void 0?l=v:l=r(vm(o),c)}return i.set(o,l),l};t.filter=n?(o,s)=>n(o,s)&&r(Gt(o)):o=>r(Gt(o))},mm=t=>{let e=new ot(t),i=t.file,n;try{n=ki.openSync(i,"r");let r=ki.fstatSync(n),o=t.maxReadSize||16*1024*1024;if(r.size<o){let s=Buffer.allocUnsafe(r.size),c=ki.readSync(n,s,0,r.size,0);e.end(c===s.byteLength?s:s.subarray(0,c))}else{let s=0,c=Buffer.allocUnsafe(o);for(;s<r.size;){let l=ki.readSync(n,c,0,o,s);if(l===0)break;s+=l,e.write(c.subarray(0,l))}e.end()}}finally{if(typeof n=="number")try{ki.closeSync(n)}catch{}}},Em=(t,e)=>{let i=new ot(t),n=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((s,c)=>{i.on("error",c),i.on("end",s),ki.stat(r,(l,v)=>{if(l)c(l);else{let A=new Tt(r,{readSize:n,size:v.size});A.on("error",c),A.pipe(i)}})})},oi=Fe(mm,Em,t=>new ot(t),t=>new ot(t),(t,e)=>{e?.length&&ga(t,e),t.noResume||um(t)});import mo from"fs";import Ze from"fs";import j3 from"path";var xa=(t,e,i)=>(t&=4095,i&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t);import{win32 as Im}from"node:path";var{isAbsolute:pm,parse:d3}=Im,Yn=t=>{let e="",i=d3(t);for(;pm(t)||i.root;){let n=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":i.root;t=t.slice(n.length),e+=n,i=d3(t)}return[e,t]};var to=["|","<",">","?",":"],Ga=to.map(t=>String.fromCharCode(61440+t.charCodeAt(0))),fm=new Map(to.map((t,e)=>[t,Ga[e]])),hm=new Map(Ga.map((t,e)=>[t,to[e]])),Sa=t=>to.reduce((e,i)=>e.split(i).join(fm.get(i)),t),R3=t=>Ga.reduce((e,i)=>e.split(i).join(hm.get(i)),t);var Y3=(t,e)=>e?(t=z(t).replace(/^\.(\/|$)/,""),Gt(e)+"/"+t):z(t),dm=16*1024*1024,g3=Symbol("process"),x3=Symbol("file"),G3=Symbol("directory"),Wa=Symbol("symlink"),S3=Symbol("hardlink"),Wn=Symbol("header"),io=Symbol("read"),Ma=Symbol("lstat"),no=Symbol("onlstat"),Ca=Symbol("onread"),Oa=Symbol("onreadlink"),Ua=Symbol("openfile"),Ka=Symbol("onopenfile"),St=Symbol("close"),ro=Symbol("mode"),Va=Symbol("awaitDrain"),Ya=Symbol("ondrain"),Pe=Symbol("prefix"),Mn=class extends be{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(e,i={}){let n=En(i);super(),this.path=z(e),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||dm,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=z(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?z(n.prefix):void 0,this.onWriteEntry=n.onWriteEntry,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let r=!1;if(!this.preservePaths){let[s,c]=Yn(this.path);s&&typeof c=="string"&&(this.path=c,r=s)}this.win32=!!n.win32||process.platform==="win32",this.win32&&(this.path=R3(this.path.replace(/\\/g,"/")),e=e.replace(/\\/g,"/")),this.absolute=z(n.absolute||j3.resolve(this.cwd,e)),this.path===""&&(this.path="./"),r&&this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:this,path:r+this.path});let o=this.statCache.get(this.absolute);o?this[no](o):this[Ma]()}warn(e,i,n={}){return ti(this,e,i,n)}emit(e,...i){return e==="error"&&(this.#e=!0),super.emit(e,...i)}[Ma](){Ze.lstat(this.absolute,(e,i)=>{if(e)return this.emit("error",e);this[no](i)})}[no](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=Rm(e),this.emit("stat",e),this[g3]()}[g3](){switch(this.type){case"File":return this[x3]();case"Directory":return this[G3]();case"SymbolicLink":return this[Wa]();default:return this.end()}}[ro](e){return xa(e,this.type==="Directory",this.portable)}[Pe](e){return Y3(e,this.prefix)}[Wn](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new ne({path:this[Pe](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pe](this.linkpath):this.linkpath,mode:this[ro](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Rt({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Pe](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pe](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw new Error("failed to encode header");super.write(e)}[G3](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Wn](),this.end()}[Wa](){Ze.readlink(this.absolute,(e,i)=>{if(e)return this.emit("error",e);this[Oa](i)})}[Oa](e){this.linkpath=z(e),this[Wn](),this.end()}[S3](e){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=z(j3.relative(this.cwd,e)),this.stat.size=0,this[Wn](),this.end()}[x3](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,i=this.linkCache.get(e);if(i?.indexOf(this.cwd)===0)return this[S3](i);this.linkCache.set(e,this.absolute)}if(this[Wn](),this.stat.size===0)return this.end();this[Ua]()}[Ua](){Ze.open(this.absolute,"r",(e,i)=>{if(e)return this.emit("error",e);this[Ka](i)})}[Ka](e){if(this.fd=e,this.#e)return this[St]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let i=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(i),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[io]()}[io](){let{fd:e,buf:i,offset:n,length:r,pos:o}=this;if(e===void 0||i===void 0)throw new Error("cannot read file without first opening");Ze.read(e,i,n,r,o,(s,c)=>{if(s)return this[St](()=>this.emit("error",s));this[Ca](c)})}[St](e=()=>{}){this.fd!==void 0&&Ze.close(this.fd,e)}[Ca](e){if(e<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[St](()=>this.emit("error",r))}if(e>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[St](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(e===this.remain)for(let r=e;r<this.length&&e<this.blockRemain;r++)this.buf[r+this.offset]=0,e++,this.remain++;let i=this.offset===0&&e===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+e);this.write(i)?this[Ya]():this[Va](()=>this[Ya]())}[Va](e){this.once("drain",e)}write(e,i,n){if(typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof i=="string"?i:"utf8")),this.blockRemain<e.length){let r=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",r)}return this.remain-=e.length,this.blockRemain-=e.length,this.pos+=e.length,this.offset+=e.length,super.write(e,null,n)}[Ya](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[St](e=>e?this.emit("error",e):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[io]()}},oo=class extends Mn{sync=!0;[Ma](){this[no](Ze.lstatSync(this.absolute))}[Wa](){this[Oa](Ze.readlinkSync(this.absolute))}[Ua](){this[Ka](Ze.openSync(this.absolute,"r"))}[io](){let e=!0;try{let{fd:i,buf:n,offset:r,length:o,pos:s}=this;if(i===void 0||n===void 0)throw new Error("fd and buf must be set in READ method");let c=Ze.readSync(i,n,r,o,s);this[Ca](c),e=!1}finally{if(e)try{this[St](()=>{})}catch{}}}[Va](e){e()}[St](e=()=>{}){this.fd!==void 0&&Ze.closeSync(this.fd),e()}},so=class extends be{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(e,i,n={}){return ti(this,e,i,n)}constructor(e,i={}){let n=En(i);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.onWriteEntry=n.onWriteEntry,this.readEntry=e;let{type:r}=e;if(r==="Unsupported")throw new Error("writing entry that should be ignored");this.type=r,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=z(e.path),this.mode=e.mode!==void 0?this[ro](e.mode):void 0,this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:n.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath!==void 0?z(e.linkpath):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let o=!1;if(!this.preservePaths){let[c,l]=Yn(this.path);c&&typeof l=="string"&&(this.path=l,o=c)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.onWriteEntry?.(this),this.header=new ne({path:this[Pe](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pe](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new Rt({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Pe](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pe](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let s=this.header?.block;if(!s)throw new Error("failed to encode header");super.write(s),e.pipe(this)}[Pe](e){return Y3(e,this.prefix)}[ro](e){return xa(e,this.type==="Directory",this.portable)}write(e,i,n){typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof i=="string"?i:"utf8"));let r=e.length;if(r>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=r,super.write(e,n)}end(e,i,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e=="function"&&(n=e,i=void 0,e=void 0),typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,i??"utf8")),n&&this.once("finish",n),e?super.end(e,n):super.end(n),this}},Rm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var ao=class t{tail;head;length=0;static create(e=[]){return new t(e)}constructor(e=[]){for(let i of e)this.push(i)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let i=e.next,n=e.prev;return i&&(i.prev=n),n&&(n.next=i),e===this.head&&(this.head=i),e===this.tail&&(this.tail=n),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,i}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let i=this.head;e.list=this,e.next=i,i&&(i.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let i=this.tail;e.list=this,e.prev=i,i&&(i.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let i=0,n=e.length;i<n;i++)jm(this,e[i]);return this.length}unshift(...e){for(var i=0,n=e.length;i<n;i++)gm(this,e[i]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,i=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,i.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,i=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,i.list=void 0,this.length--,e}forEach(e,i){i=i||this;for(let n=this.head,r=0;n;r++)e.call(i,n.value,r,this),n=n.next}forEachReverse(e,i){i=i||this;for(let n=this.tail,r=this.length-1;n;r--)e.call(i,n.value,r,this),n=n.prev}get(e){let i=0,n=this.head;for(;n&&i<e;i++)n=n.next;if(i===e&&n)return n.value}getReverse(e){let i=0,n=this.tail;for(;n&&i<e;i++)n=n.prev;if(i===e&&n)return n.value}map(e,i){i=i||this;let n=new t;for(let r=this.head;r;)n.push(e.call(i,r.value,this)),r=r.next;return n}mapReverse(e,i){i=i||this;var n=new t;for(let r=this.tail;r;)n.push(e.call(i,r.value,this)),r=r.prev;return n}reduce(e,i){let n,r=this.head;if(arguments.length>1)n=i;else if(this.head)r=this.head.next,n=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=0;r;o++)n=e(n,r.value,o),r=r.next;return n}reduceReverse(e,i){let n,r=this.tail;if(arguments.length>1)n=i;else if(this.tail)r=this.tail.prev,n=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let o=this.length-1;r;o--)n=e(n,r.value,o),r=r.prev;return n}toArray(){let e=new Array(this.length);for(let i=0,n=this.head;n;i++)e[i]=n.value,n=n.next;return e}toArrayReverse(){let e=new Array(this.length);for(let i=0,n=this.tail;n;i++)e[i]=n.value,n=n.prev;return e}slice(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let n=new t;if(i<e||i<0)return n;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.head,o=0;for(o=0;r&&o<e;o++)r=r.next;for(;r&&o<i;o++,r=r.next)n.push(r.value);return n}sliceReverse(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let n=new t;if(i<e||i<0)return n;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.length,o=this.tail;for(;o&&r>i;r--)o=o.prev;for(;o&&r>e;r--,o=o.prev)n.push(o.value);return n}splice(e,i=0,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let r=this.head;for(let s=0;r&&s<e;s++)r=r.next;let o=[];for(let s=0;r&&s<i;s++)o.push(r.value),r=this.removeNode(r);r?r!==this.tail&&(r=r.prev):r=this.tail;for(let s of n)r=zm(this,r,s);return o}reverse(){let e=this.head,i=this.tail;for(let n=e;n;n=n.prev){let r=n.prev;n.prev=n.next,n.next=r}return this.head=i,this.tail=e,this}};function zm(t,e,i){let n=e,r=e?e.next:t.head,o=new Cn(i,n,r,t);return o.next===void 0&&(t.tail=o),o.prev===void 0&&(t.head=o),t.length++,o}function jm(t,e){t.tail=new Cn(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function gm(t,e){t.head=new Cn(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Cn=class{list;next;prev;value;constructor(e,i,n,r){this.list=r,this.value=e,i?(i.next=this,this.prev=i):this.prev=void 0,n?(n.prev=this,this.next=n):this.next=void 0}};import U3 from"path";var Eo=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(e,i){this.path=e||"./",this.absolute=i}},W3=Buffer.alloc(1024),co=Symbol("onStat"),On=Symbol("ended"),We=Symbol("queue"),Fi=Symbol("current"),si=Symbol("process"),Un=Symbol("processing"),M3=Symbol("processJob"),Me=Symbol("jobs"),Na=Symbol("jobDone"),lo=Symbol("addFSEntry"),C3=Symbol("addTarEntry"),Qa=Symbol("stat"),Ja=Symbol("readdir"),vo=Symbol("onreaddir"),Ao=Symbol("pipe"),O3=Symbol("entry"),ka=Symbol("entryOpt"),uo=Symbol("writeEntryClass"),K3=Symbol("write"),Fa=Symbol("ondrain"),Yt=class extends be{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[uo];onWriteEntry;[We];[Me]=0;[Un]=!1;[On]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||"",this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=z(e.prefix||""),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[uo]=Mn,typeof e.onwarn=="function"&&this.on("warn",e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli||e.zstd){if((e.gzip?1:0)+(e.brotli?1:0)+(e.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(e.gzip&&(typeof e.gzip!="object"&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new Kr(e.gzip)),e.brotli&&(typeof e.brotli!="object"&&(e.brotli={}),this.zip=new kr(e.brotli)),e.zstd&&(typeof e.zstd!="object"&&(e.zstd={}),this.zip=new Jr(e.zstd)),!this.zip)throw new Error("impossible");let i=this.zip;i.on("data",n=>super.write(n)),i.on("end",()=>super.end()),i.on("drain",()=>this[Fa]()),this.on("resume",()=>i.resume())}else this.on("drain",this[Fa]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter=="function"?e.filter:()=>!0,this[We]=new ao,this[Me]=0,this.jobs=Number(e.jobs)||4,this[Un]=!1,this[On]=!1}[K3](e){return super.write(e)}add(e){return this.write(e),this}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i=void 0),e&&this.add(e),this[On]=!0,this[si](),n&&n(),this}write(e){if(this[On])throw new Error("write after end");return e instanceof Vi?this[C3](e):this[lo](e),this.flowing}[C3](e){let i=z(U3.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let n=new Eo(e.path,i);n.entry=new so(e,this[ka](n)),n.entry.on("end",()=>this[Na](n)),this[Me]+=1,this[We].push(n)}this[si]()}[lo](e){let i=z(U3.resolve(this.cwd,e));this[We].push(new Eo(e,i)),this[si]()}[Qa](e){e.pending=!0,this[Me]+=1;let i=this.follow?"stat":"lstat";mo[i](e.absolute,(n,r)=>{e.pending=!1,this[Me]-=1,n?this.emit("error",n):this[co](e,r)})}[co](e,i){this.statCache.set(e.absolute,i),e.stat=i,this.filter(e.path,i)||(e.ignore=!0),this[si]()}[Ja](e){e.pending=!0,this[Me]+=1,mo.readdir(e.absolute,(i,n)=>{if(e.pending=!1,this[Me]-=1,i)return this.emit("error",i);this[vo](e,n)})}[vo](e,i){this.readdirCache.set(e.absolute,i),e.readdir=i,this[si]()}[si](){if(!this[Un]){this[Un]=!0;for(let e=this[We].head;e&&this[Me]<this.jobs;e=e.next)if(this[M3](e.value),e.value.ignore){let i=e.next;this[We].removeNode(e),e.next=i}this[Un]=!1,this[On]&&!this[We].length&&this[Me]===0&&(this.zip?this.zip.end(W3):(super.write(W3),super.end()))}}get[Fi](){return this[We]&&this[We].head&&this[We].head.value}[Na](e){this[We].shift(),this[Me]-=1,this[si]()}[M3](e){if(!e.pending){if(e.entry){e===this[Fi]&&!e.piped&&this[Ao](e);return}if(!e.stat){let i=this.statCache.get(e.absolute);i?this[co](e,i):this[Qa](e)}if(e.stat&&!e.ignore){if(!this.noDirRecurse&&e.stat.isDirectory()&&!e.readdir){let i=this.readdirCache.get(e.absolute);if(i?this[vo](e,i):this[Ja](e),!e.readdir)return}if(e.entry=this[O3](e),!e.entry){e.ignore=!0;return}e===this[Fi]&&!e.piped&&this[Ao](e)}}}[ka](e){return{onwarn:(i,n,r)=>this.warn(i,n,r),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[O3](e){this[Me]+=1;try{return new this[uo](e.path,this[ka](e)).on("end",()=>this[Na](e)).on("error",n=>this.emit("error",n))}catch(i){this.emit("error",i)}}[Fa](){this[Fi]&&this[Fi].entry&&this[Fi].entry.resume()}[Ao](e){e.piped=!0,e.readdir&&e.readdir.forEach(r=>{let o=e.path,s=o==="./"?"":o.replace(/\/*$/,"/");this[lo](s+r)});let i=e.entry,n=this.zip;if(!i)throw new Error("cannot pipe without source");n?i.on("data",r=>{n.write(r)||i.pause()}):i.on("data",r=>{super.write(r)||i.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,i,n={}){ti(this,e,i,n)}},ai=class extends Yt{sync=!0;constructor(e){super(e),this[uo]=oo}pause(){}resume(){}[Qa](e){let i=this.follow?"statSync":"lstatSync";this[co](e,mo[i](e.absolute))}[Ja](e){this[vo](e,mo.readdirSync(e.absolute))}[Ao](e){let i=e.entry,n=this.zip;if(e.readdir&&e.readdir.forEach(r=>{let o=e.path,s=o==="./"?"":o.replace(/\/*$/,"/");this[lo](s+r)}),!i)throw new Error("Cannot pipe without source");n?i.on("data",r=>{n.write(r)}):i.on("data",r=>{super[K3](r)})}};var xm=(t,e)=>{let i=new ai(t),n=new Yi(t.file,{mode:t.mode||438});i.pipe(n),N3(i,e)},Gm=(t,e)=>{let i=new Yt(t),n=new _e(t.file,{mode:t.mode||438});i.pipe(n);let r=new Promise((o,s)=>{n.on("error",s),n.on("close",o),i.on("error",s)});return k3(i,e),r},N3=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?oi({file:V3.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(i)}),t.end()},k3=async(t,e)=>{for(let i=0;i<e.length;i++){let n=String(e[i]);n.charAt(0)==="@"?await oi({file:V3.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:r=>{t.add(r)}}):t.add(n)}t.end()},Sm=(t,e)=>{let i=new ai(t);return N3(i,e),i},Ym=(t,e)=>{let i=new Yt(t);return k3(i,e),i},Wm=Fe(xm,Gm,Sm,Ym,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")});import ev from"node:fs";import ym from"node:assert";import{randomBytes as $3}from"node:crypto";import j from"node:fs";import st from"node:path";import F3 from"fs";var Mm=process.env.__FAKE_PLATFORM__||process.platform,Cm=Mm==="win32",{O_CREAT:Om,O_TRUNC:Um,O_WRONLY:Km}=F3.constants,Q3=Number(process.env.__FAKE_FS_O_FILENAME__)||F3.constants.UV_FS_O_FILEMAP||0,Vm=Cm&&!!Q3,Nm=512*1024,km=Q3|Um|Om|Km,ba=Vm?t=>t<Nm?km:"w":()=>"w";import po from"node:fs";import Kn from"node:path";var Ba=(t,e,i)=>{try{return po.lchownSync(t,e,i)}catch(n){if(n?.code!=="ENOENT")throw n}},Io=(t,e,i,n)=>{po.lchown(t,e,i,r=>{n(r&&r?.code!=="ENOENT"?r:null)})},Fm=(t,e,i,n,r)=>{if(e.isDirectory())Za(Kn.resolve(t,e.name),i,n,o=>{if(o)return r(o);let s=Kn.resolve(t,e.name);Io(s,i,n,r)});else{let o=Kn.resolve(t,e.name);Io(o,i,n,r)}},Za=(t,e,i,n)=>{po.readdir(t,{withFileTypes:!0},(r,o)=>{if(r){if(r.code==="ENOENT")return n();if(r.code!=="ENOTDIR"&&r.code!=="ENOTSUP")return n(r)}if(r||!o.length)return Io(t,e,i,n);let s=o.length,c=null,l=v=>{if(!c){if(v)return n(c=v);if(--s===0)return Io(t,e,i,n)}};for(let v of o)Fm(t,v,e,i,l)})},Qm=(t,e,i,n)=>{e.isDirectory()&&Pa(Kn.resolve(t,e.name),i,n),Ba(Kn.resolve(t,e.name),i,n)},Pa=(t,e,i)=>{let n;try{n=po.readdirSync(t,{withFileTypes:!0})}catch(r){let o=r;if(o?.code==="ENOENT")return;if(o?.code==="ENOTDIR"||o?.code==="ENOTSUP")return Ba(t,e,i);throw o}for(let r of n)Qm(t,r,e,i);return Ba(t,e,i)};import oe from"node:fs";import Jm from"node:fs/promises";import fo from"node:path";var Vn=class extends Error{path;code;syscall="chdir";constructor(e,i){super(`${i}: Cannot cd into '${e}'`),this.path=e,this.code=i}get name(){return"CwdError"}};var Nn=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,i){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=i}get name(){return"SymlinkError"}};var bm=(t,e)=>{oe.stat(t,(i,n)=>{(i||!n.isDirectory())&&(i=new Vn(t,i?.code||"ENOTDIR")),e(i)})},J3=(t,e,i)=>{t=z(t);let n=e.umask??18,r=e.mode|448,o=(r&n)!==0,s=e.uid,c=e.gid,l=typeof s=="number"&&typeof c=="number"&&(s!==e.processUid||c!==e.processGid),v=e.preserve,A=e.unlink,u=z(e.cwd),I=(R,h)=>{R?i(R):h&&l?Za(h,s,c,H=>I(H)):o?oe.chmod(t,r,i):i()};if(t===u)return bm(t,I);if(v)return Jm.mkdir(t,{mode:r,recursive:!0}).then(R=>I(null,R??void 0),I);let f=z(fo.relative(u,t)).split("/");qa(u,f,r,A,u,void 0,I)},qa=(t,e,i,n,r,o,s)=>{if(!e.length)return s(null,o);let c=e.shift(),l=z(fo.resolve(t+"/"+c));oe.mkdir(l,i,b3(l,e,i,n,r,o,s))},b3=(t,e,i,n,r,o,s)=>c=>{c?oe.lstat(t,(l,v)=>{if(l)l.path=l.path&&z(l.path),s(l);else if(v.isDirectory())qa(t,e,i,n,r,o,s);else if(n)oe.unlink(t,A=>{if(A)return s(A);oe.mkdir(t,i,b3(t,e,i,n,r,o,s))});else{if(v.isSymbolicLink())return s(new Nn(t,t+"/"+e.join("/")));s(c)}}):(o=o||t,qa(t,e,i,n,r,o,s))},Bm=t=>{let e=!1,i;try{e=oe.statSync(t).isDirectory()}catch(n){i=n?.code}finally{if(!e)throw new Vn(t,i??"ENOTDIR")}},B3=(t,e)=>{t=z(t);let i=e.umask??18,n=e.mode|448,r=(n&i)!==0,o=e.uid,s=e.gid,c=typeof o=="number"&&typeof s=="number"&&(o!==e.processUid||s!==e.processGid),l=e.preserve,v=e.unlink,A=z(e.cwd),u=R=>{R&&c&&Pa(R,o,s),r&&oe.chmodSync(t,n)};if(t===A)return Bm(A),u();if(l)return u(oe.mkdirSync(t,{mode:n,recursive:!0})??void 0);let E=z(fo.relative(A,t)).split("/"),f;for(let R=E.shift(),h=A;R&&(h+="/"+R);R=E.shift()){h=z(fo.resolve(h));try{oe.mkdirSync(h,n),f=f||h}catch{let ve=oe.lstatSync(h);if(ve.isDirectory())continue;if(v){oe.unlinkSync(h),oe.mkdirSync(h,n),f=f||h;continue}else if(ve.isSymbolicLink())return new Nn(h,h+"/"+E.join("/"))}}return u(f)};import{join as q3}from"node:path";var ya=Object.create(null),Z3=1e4,Qi=new Set,P3=t=>{Qi.has(t)?Qi.delete(t):ya[t]=t.normalize("NFD"),Qi.add(t);let e=ya[t],i=Qi.size-Z3;if(i>Z3/10){for(let n of Qi)if(Qi.delete(n),delete ya[n],--i<=0)break}return e};var Zm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Pm=Zm==="win32",qm=t=>t.split("/").slice(0,-1).reduce((i,n)=>{let r=i[i.length-1];return r!==void 0&&(n=q3(r,n)),i.push(n||"/"),i},[]),ho=class{#e=new Map;#n=new Map;#i=new Set;reserve(e,i){e=Pm?["win32 parallelization disabled"]:e.map(r=>Gt(q3(P3(r))).toLowerCase());let n=new Set(e.map(r=>qm(r)).reduce((r,o)=>r.concat(o)));this.#n.set(i,{dirs:n,paths:e});for(let r of e){let o=this.#e.get(r);o?o.push(i):this.#e.set(r,[i])}for(let r of n){let o=this.#e.get(r);if(!o)this.#e.set(r,[new Set([i])]);else{let s=o[o.length-1];s instanceof Set?s.add(i):o.push(new Set([i]))}}return this.#a(i)}#r(e){let i=this.#n.get(e);if(!i)throw new Error("function does not have any path reservations");return{paths:i.paths.map(n=>this.#e.get(n)),dirs:[...i.dirs].map(n=>this.#e.get(n))}}check(e){let{paths:i,dirs:n}=this.#r(e);return i.every(r=>r&&r[0]===e)&&n.every(r=>r&&r[0]instanceof Set&&r[0].has(e))}#a(e){return this.#i.has(e)||!this.check(e)?!1:(this.#i.add(e),e(()=>this.#t(e)),!0)}#t(e){if(!this.#i.has(e))return!1;let i=this.#n.get(e);if(!i)throw new Error("invalid reservation");let{paths:n,dirs:r}=i,o=new Set;for(let s of n){let c=this.#e.get(s);if(!c||c?.[0]!==e)continue;let l=c[1];if(!l){this.#e.delete(s);continue}if(c.shift(),typeof l=="function")o.add(l);else for(let v of l)o.add(v)}for(let s of r){let c=this.#e.get(s),l=c?.[0];if(!(!c||!(l instanceof Set)))if(l.size===1&&c.length===1){this.#e.delete(s);continue}else if(l.size===1){c.shift();let v=c[0];typeof v=="function"&&o.add(v)}else l.delete(e)}return this.#i.delete(e),o.forEach(s=>this.#a(s)),!0}};var y3=Symbol("onEntry"),Ta=Symbol("checkFs"),D3=Symbol("checkFs2"),Xa=Symbol("isReusable"),fe=Symbol("makeFs"),Ha=Symbol("file"),La=Symbol("directory"),jo=Symbol("link"),w3=Symbol("symlink"),T3=Symbol("hardlink"),X3=Symbol("unsupported"),H3=Symbol("checkPath"),Wt=Symbol("mkdir"),X=Symbol("onError"),Ro=Symbol("pending"),L3=Symbol("pend"),Ji=Symbol("unpend"),Da=Symbol("ended"),wa=Symbol("maybeClose"),_a=Symbol("skip"),kn=Symbol("doChown"),Fn=Symbol("uid"),Qn=Symbol("gid"),Jn=Symbol("checkedCwd"),Dm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,bn=Dm==="win32",wm=1024,Tm=(t,e)=>{if(!bn)return j.unlink(t,e);let i=t+".DELETE."+$3(16).toString("hex");j.rename(t,i,n=>{if(n)return e(n);j.unlink(i,e)})},Xm=t=>{if(!bn)return j.unlinkSync(t);let e=t+".DELETE."+$3(16).toString("hex");j.renameSync(t,e),j.unlinkSync(e)},_3=(t,e,i)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:i,bi=class extends ot{[Da]=!1;[Jn]=!1;[Ro]=0;reservations=new ho;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[Da]=!0,this[wa]()},super(e),this.transform=e.transform,this.chmod=!!e.chmod,typeof e.uid=="number"||typeof e.gid=="number"){if(typeof e.uid!="number"||typeof e.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(e.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;e.preserveOwner===void 0&&typeof e.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:wm,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||bn,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=z(st.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask=="number"?e.processUmask:process.umask():0,this.umask=typeof e.umask=="number"?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on("entry",i=>this[y3](i))}warn(e,i,n={}){return(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(n.recoverable=!1),super.warn(e,i,n)}[wa](){this[Da]&&this[Ro]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[H3](e){let i=z(e.path),n=i.split("/");if(this.strip){if(n.length<this.strip)return!1;if(e.type==="Link"){let r=z(String(e.linkpath)).split("/");if(r.length>=this.strip)e.linkpath=r.slice(this.strip).join("/");else return!1}n.splice(0,this.strip),e.path=n.join("/")}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:i,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this.preservePaths){if(n.includes("..")||bn&&/^[a-z]:\.\.$/i.test(n[0]??""))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:e,path:i}),!1;let[r,o]=Yn(i);r&&(e.path=String(o),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:e,path:i}))}if(st.isAbsolute(e.path)?e.absolute=z(st.resolve(e.path)):e.absolute=z(st.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute=="string"&&e.absolute.indexOf(this.cwd+"/")!==0&&e.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:z(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!=="Directory"&&e.type!=="GNUDumpDir")return!1;if(this.win32){let{root:r}=st.win32.parse(String(e.absolute));e.absolute=r+Sa(String(e.absolute).slice(r.length));let{root:o}=st.win32.parse(e.path);e.path=o+Sa(e.path.slice(o.length))}return!0}[y3](e){if(!this[H3](e))return e.resume();switch(ym.equal(typeof e.absolute,"string"),e.type){case"Directory":case"GNUDumpDir":e.mode&&(e.mode=e.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ta](e);default:return this[X3](e)}}[X](e,i){e.name==="CwdError"?this.emit("error",e):(this.warn("TAR_ENTRY_ERROR",e,{entry:i}),this[Ji](),i.resume())}[Wt](e,i,n){J3(z(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:i},n)}[kn](e){return this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Fn](e){return _3(this.uid,e.uid,this.processUid)}[Qn](e){return _3(this.gid,e.gid,this.processGid)}[Ha](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,r=new _e(String(e.absolute),{flags:ba(e.size),mode:n,autoClose:!1});r.on("error",l=>{r.fd&&j.close(r.fd,()=>{}),r.write=()=>!0,this[X](l,e),i()});let o=1,s=l=>{if(l){r.fd&&j.close(r.fd,()=>{}),this[X](l,e),i();return}--o===0&&r.fd!==void 0&&j.close(r.fd,v=>{v?this[X](v,e):this[Ji](),i()})};r.on("finish",()=>{let l=String(e.absolute),v=r.fd;if(typeof v=="number"&&e.mtime&&!this.noMtime){o++;let A=e.atime||new Date,u=e.mtime;j.futimes(v,A,u,I=>I?j.utimes(l,A,u,E=>s(E&&I)):s())}if(typeof v=="number"&&this[kn](e)){o++;let A=this[Fn](e),u=this[Qn](e);typeof A=="number"&&typeof u=="number"&&j.fchown(v,A,u,I=>I?j.chown(l,A,u,E=>s(E&&I)):s())}s()});let c=this.transform&&this.transform(e)||e;c!==e&&(c.on("error",l=>{this[X](l,e),i()}),e.pipe(c)),c.pipe(r)}[La](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.dmode;this[Wt](String(e.absolute),n,r=>{if(r){this[X](r,e),i();return}let o=1,s=()=>{--o===0&&(i(),this[Ji](),e.resume())};e.mtime&&!this.noMtime&&(o++,j.utimes(String(e.absolute),e.atime||new Date,e.mtime,s)),this[kn](e)&&(o++,j.chown(String(e.absolute),Number(this[Fn](e)),Number(this[Qn](e)),s)),s()})}[X3](e){e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[w3](e,i){this[jo](e,String(e.linkpath),"symlink",i)}[T3](e,i){let n=z(st.resolve(this.cwd,String(e.linkpath)));this[jo](e,n,"link",i)}[L3](){this[Ro]++}[Ji](){this[Ro]--,this[wa]()}[_a](e){this[Ji](),e.resume()}[Xa](e,i){return e.type==="File"&&!this.unlink&&i.isFile()&&i.nlink<=1&&!bn}[Ta](e){this[L3]();let i=[e.path];e.linkpath&&i.push(e.linkpath),this.reservations.reserve(i,n=>this[D3](e,n))}[D3](e,i){let n=c=>{i(c)},r=()=>{this[Wt](this.cwd,this.dmode,c=>{if(c){this[X](c,e),n();return}this[Jn]=!0,o()})},o=()=>{if(e.absolute!==this.cwd){let c=z(st.dirname(String(e.absolute)));if(c!==this.cwd)return this[Wt](c,this.dmode,l=>{if(l){this[X](l,e),n();return}s()})}s()},s=()=>{j.lstat(String(e.absolute),(c,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(e.mtime??l.mtime))){this[_a](e),n();return}if(c||this[Xa](e,l))return this[fe](null,e,n);if(l.isDirectory()){if(e.type==="Directory"){let v=this.chmod&&e.mode&&(l.mode&4095)!==e.mode,A=u=>this[fe](u??null,e,n);return v?j.chmod(String(e.absolute),Number(e.mode),A):A()}if(e.absolute!==this.cwd)return j.rmdir(String(e.absolute),v=>this[fe](v??null,e,n))}if(e.absolute===this.cwd)return this[fe](null,e,n);Tm(String(e.absolute),v=>this[fe](v??null,e,n))})};this[Jn]?o():r()}[fe](e,i,n){if(e){this[X](e,i),n();return}switch(i.type){case"File":case"OldFile":case"ContiguousFile":return this[Ha](i,n);case"Link":return this[T3](i,n);case"SymbolicLink":return this[w3](i,n);case"Directory":case"GNUDumpDir":return this[La](i,n)}}[jo](e,i,n,r){j[n](i,String(e.absolute),o=>{o?this[X](o,e):(this[Ji](),e.resume()),r()})}},zo=t=>{try{return[null,t()]}catch(e){return[e,null]}},Bn=class extends bi{sync=!0;[fe](e,i){return super[fe](e,i,()=>{})}[Ta](e){if(!this[Jn]){let o=this[Wt](this.cwd,this.dmode);if(o)return this[X](o,e);this[Jn]=!0}if(e.absolute!==this.cwd){let o=z(st.dirname(String(e.absolute)));if(o!==this.cwd){let s=this[Wt](o,this.dmode);if(s)return this[X](s,e)}}let[i,n]=zo(()=>j.lstatSync(String(e.absolute)));if(n&&(this.keep||this.newer&&n.mtime>(e.mtime??n.mtime)))return this[_a](e);if(i||this[Xa](e,n))return this[fe](null,e);if(n.isDirectory()){if(e.type==="Directory"){let s=this.chmod&&e.mode&&(n.mode&4095)!==e.mode,[c]=s?zo(()=>{j.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[fe](c,e)}let[o]=zo(()=>j.rmdirSync(String(e.absolute)));this[fe](o,e)}let[r]=e.absolute===this.cwd?[]:zo(()=>Xm(String(e.absolute)));this[fe](r,e)}[Ha](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,r=c=>{let l;try{j.closeSync(o)}catch(v){l=v}(c||l)&&this[X](c||l,e),i()},o;try{o=j.openSync(String(e.absolute),ba(e.size),n)}catch(c){return r(c)}let s=this.transform&&this.transform(e)||e;s!==e&&(s.on("error",c=>this[X](c,e)),e.pipe(s)),s.on("data",c=>{try{j.writeSync(o,c,0,c.length)}catch(l){r(l)}}),s.on("end",()=>{let c=null;if(e.mtime&&!this.noMtime){let l=e.atime||new Date,v=e.mtime;try{j.futimesSync(o,l,v)}catch(A){try{j.utimesSync(String(e.absolute),l,v)}catch{c=A}}}if(this[kn](e)){let l=this[Fn](e),v=this[Qn](e);try{j.fchownSync(o,Number(l),Number(v))}catch(A){try{j.chownSync(String(e.absolute),Number(l),Number(v))}catch{c=c||A}}}r(c)})}[La](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.dmode,r=this[Wt](String(e.absolute),n);if(r){this[X](r,e),i();return}if(e.mtime&&!this.noMtime)try{j.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[kn](e))try{j.chownSync(String(e.absolute),Number(this[Fn](e)),Number(this[Qn](e)))}catch{}i(),e.resume()}[Wt](e,i){try{return B3(z(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:i})}catch(n){return n}}[jo](e,i,n,r){let o=`${n}Sync`;try{j[o](i,String(e.absolute)),r(),e.resume()}catch(s){return this[X](s,e)}}};var Hm=t=>{let e=new Bn(t),i=t.file,n=ev.statSync(i),r=t.maxReadSize||16*1024*1024;new Gr(i,{readSize:r,size:n.size}).pipe(e)},Lm=(t,e)=>{let i=new bi(t),n=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((s,c)=>{i.on("error",c),i.on("close",s),ev.stat(r,(l,v)=>{if(l)c(l);else{let A=new Tt(r,{readSize:n,size:v.size});A.on("error",c),A.pipe(i)}})})},$a=Fe(Hm,Lm,t=>new Bn(t),t=>new bi(t),(t,e)=>{e?.length&&ga(t,e)});import se from"node:fs";import tv from"node:path";var _m=(t,e)=>{let i=new ai(t),n=!0,r,o;try{try{r=se.openSync(t.file,"r+")}catch(l){if(l?.code==="ENOENT")r=se.openSync(t.file,"w+");else throw l}let s=se.fstatSync(r),c=Buffer.alloc(512);e:for(o=0;o<s.size;o+=512){for(let A=0,u=0;A<512;A+=u){if(u=se.readSync(r,c,A,c.length-A,o+A),o===0&&c[0]===31&&c[1]===139)throw new Error("cannot append to compressed archives");if(!u)break e}let l=new ne(c);if(!l.cksumValid)break;let v=512*Math.ceil((l.size||0)/512);if(o+v+512>s.size)break;o+=v,t.mtimeCache&&l.mtime&&t.mtimeCache.set(String(l.path),l.mtime)}n=!1,$m(t,i,o,r,e)}finally{if(n)try{se.closeSync(r)}catch{}}},$m=(t,e,i,n,r)=>{let o=new Yi(t.file,{fd:n,start:i});e.pipe(o),tE(e,r)},eE=(t,e)=>{e=Array.from(e);let i=new Yt(t),n=(o,s,c)=>{let l=(E,f)=>{E?se.close(o,R=>c(E)):c(null,f)},v=0;if(s===0)return l(null,0);let A=0,u=Buffer.alloc(512),I=(E,f)=>{if(E||typeof f>"u")return l(E);if(A+=f,A<512&&f)return se.read(o,u,A,u.length-A,v+A,I);if(v===0&&u[0]===31&&u[1]===139)return l(new Error("cannot append to compressed archives"));if(A<512)return l(null,v);let R=new ne(u);if(!R.cksumValid)return l(null,v);let h=512*Math.ceil((R.size??0)/512);if(v+h+512>s||(v+=h+512,v>=s))return l(null,v);t.mtimeCache&&R.mtime&&t.mtimeCache.set(String(R.path),R.mtime),A=0,se.read(o,u,0,512,v,I)};se.read(o,u,0,512,v,I)};return new Promise((o,s)=>{i.on("error",s);let c="r+",l=(v,A)=>{if(v&&v.code==="ENOENT"&&c==="r+")return c="w+",se.open(t.file,c,l);if(v||!A)return s(v);se.fstat(A,(u,I)=>{if(u)return se.close(A,()=>s(u));n(A,I.size,(E,f)=>{if(E)return s(E);let R=new _e(t.file,{fd:A,start:f});i.pipe(R),R.on("error",s),R.on("close",o),iE(i,e)})})};se.open(t.file,c,l)})},tE=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?oi({file:tv.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(i)}),t.end()},iE=async(t,e)=>{for(let i=0;i<e.length;i++){let n=String(e[i]);n.charAt(0)==="@"?await oi({file:tv.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:r=>t.add(r)}):t.add(n)}t.end()},ci=Fe(_m,eE,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Xl(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")});var nE=Fe(ci.syncFile,ci.asyncFile,ci.syncNoFile,ci.asyncNoFile,(t,e=[])=>{ci.validate?.(t,e),rE(t)}),rE=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(i,n)=>e(i,n)&&!((t.mtimeCache?.get(i)??n.mtime??0)>(n.mtime??0)):(i,n)=>!((t.mtimeCache?.get(i)??n.mtime??0)>(n.mtime??0))};async function Bi(t){let{source:e,destination:i,strip:n=1,filter:r}=t,o=[];if(!iv(e))return{success:!1,extractedFiles:[],error:`Source file not found: ${e}`};iv(i)||aE(i,{recursive:!0});try{return await cE(sE(e),lE(),$a({cwd:i,strip:n,filter:s=>r&&!r(s)?!1:(o.push(s),!0)})),{success:!0,extractedFiles:o}}catch(s){return{success:!1,extractedFiles:o,error:s instanceof Error?s.message:String(s)}}}import{existsSync as nv,readFileSync as vE,writeFileSync as AE,mkdirSync as uE}from"fs";import{dirname as mE}from"path";function Mt(t){let e=Vs(t);if(!nv(e))return null;try{let i=vE(e,"utf-8");return JSON.parse(i)}catch{return null}}function go(t,e){let i=Vs(e),n=mE(i);nv(n)||uE(n,{recursive:!0}),AE(i,JSON.stringify(t,null,2))}function rv(t,e,i){return{name:"gemkit",version:t,installedAt:new Date().toISOString(),scope:e,installedFiles:i,customizedFiles:[]}}function ov(t){return Mt(t)!==null}var p=_n(cv(),1),fE=t=>{let e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return`\x1B[38;2;${e};${i};${n}m`},Zn=t=>e=>p.default.isColorSupported?`${fE(t)}${e}\x1B[39m`:e,a={primary:Zn("#4f46e5"),secondary:Zn("#9333ea"),accent:Zn("#06b6d4"),geminiBlue:Zn("#1a73e8"),geminiPurple:Zn("#8e24aa"),success:t=>p.default.green(t),error:t=>p.default.red(t),warn:t=>p.default.yellow(t),info:t=>p.default.cyan(t),dim:t=>p.default.dim(t)},M={line:(t=60)=>"\u2500".repeat(t),doubleLine:(t=60)=>"\u2550".repeat(t),statusIcon:t=>{switch(t){case"active":return a.success("\u25CF");case"completed":return a.dim("\u25CB");case"failed":return a.error("\u2717");default:return"?"}},checkIcon:(t,e=!1)=>t?a.success("\u2713"):e?a.warn("\u25CB"):a.error("\u2717"),header:t=>p.default.bold(a.geminiPurple(t)),section:(t,e=60)=>{console.log(),console.log("\u2500".repeat(e)),console.log(p.default.bold(a.geminiPurple(t))),console.log("\u2500".repeat(e)),console.log()}};var fz={success:a.success,error:a.error,warning:a.warn,info:a.info,dim:a.dim,primary:a.primary,secondary:a.secondary,bold:p.default.bold};var lv={debug:0,info:1,warn:2,error:3,silent:4},he={level:"info",verbose:!1,json:!1};function So(t){he={...he,...t}}function Pn(t){return lv[t]>=lv[he.level]}function hE(t,e){Pn("debug")&&(he.json?console.log(JSON.stringify({level:"debug",message:t,data:e})):(console.log(a.dim(`[DEBUG] ${t}`)),e&&he.verbose&&console.log(a.dim(JSON.stringify(e,null,2)))))}function dE(t,e){Pn("info")&&(he.json?console.log(JSON.stringify({level:"info",message:t,data:e})):(console.log(`${a.info("\u2139")} ${t}`),e&&he.verbose&&console.log(JSON.stringify(e,null,2))))}function RE(t,e){Pn("info")&&(he.json?console.log(JSON.stringify({level:"success",message:t,data:e})):console.log(`${a.success("\u2713")} ${t}`))}function zE(t,e){Pn("warn")&&(he.json?console.log(JSON.stringify({level:"warn",message:t,data:e})):console.log(`${a.warn("\u26A0")} ${t}`))}function jE(t,e){Pn("error")&&(he.json?console.error(JSON.stringify({level:"error",message:t,data:e})):(console.error(`${a.error("\u2717")} ${t}`),e&&he.verbose&&console.error(JSON.stringify(e,null,2))))}function gE(t){he.json?console.log(JSON.stringify(t)):console.table(t)}function xE(t){console.log(JSON.stringify(t,null,2))}var m={debug:hE,info:dE,success:RE,warn:zE,error:jE,table:gE,json:xE,configure:So};import{spawnSync as ME}from"child_process";var GE="https://registry.npmjs.org",SE="npm-version",YE=3600;async function qn(t){let e=`${SE}-${t}`,i=mr(e);if(i)return i;try{let n=await fetch(`${GE}/${t}/latest`,{headers:{Accept:"application/json","User-Agent":"gemkit-cli"}});if(!n.ok)return null;let r=await n.json(),o={name:r.name,version:r.version,description:r.description,publishedAt:r.time?.[r.version]};return Er(e,o,YE),o}catch{return null}}function WE(t,e){let i=t.replace(/^v/,"").split(".").map(Number),n=e.replace(/^v/,"").split(".").map(Number);for(let r=0;r<Math.max(i.length,n.length);r++){let o=i[r]||0,s=n[r]||0;if(o>s)return 1;if(o<s)return-1}return 0}function Zi(t,e){return WE(e,t)>0}import{readFileSync as CE}from"fs";import{join as vv,dirname as OE}from"path";import{fileURLToPath as UE}from"url";var yn="gemkit-cli";function KE(){try{let t=UE(import.meta.url),e=OE(t),i=[vv(e,"..","package.json"),vv(e,"..","..","..","package.json")];for(let n of i)try{let r=JSON.parse(CE(n,"utf-8"));if(r.name===yn&&r.version)return r.version}catch{}}catch{}return"0.0.0"}var de=KE();function Av(t){t.command("update","Update GemKit CLI and/or Kits to latest version").option("-f, --force","Force update even if already up to date").option("--no-backup","Disable backup before kits update").option("--cli","Update CLI only (npm package)").option("--kits","Update Kits only (.gemini folder)").action(async e=>{let i=e.cli===!0||!e.cli&&!e.kits,n=e.kits===!0||!e.cli&&!e.kits,r=!1,o=!1;i&&(r=await VE(e.force)),n&&(o=await NE(e.force)),console.log(),r||o?m.success("Update complete!"):m.info("Everything is up to date.")})}async function VE(t){console.log(),m.info(`${a.primary("CLI")} Checking for updates...`);let e=await qn(yn);if(!e)return m.warn("Failed to check npm registry for CLI updates."),!1;let i=de,n=e.version;return!Zi(i,n)&&!t?(m.success(`CLI is up to date (v${i})`),!1):(m.info(`Updating CLI: v${i} \u2192 v${n}`),ME("npm",["install","-g",`${yn}@latest`],{encoding:"utf-8",stdio:"inherit",shell:!0}).status!==0?(m.error("CLI update failed. Try running manually:"),m.info(` npm install -g ${yn}@latest`),!1):(m.success(`CLI updated to v${n}`),!0))}async function NE(t){console.log(),m.info(`${a.primary("Kits")} Checking for updates...`);let e=Mt();if(!e)return m.warn('GemKit not initialized. Run "gk init" first to install kits.'),!1;let i=await qt();if(!i)return m.warn("Failed to check GitHub for kits updates."),!1;if(i.version===e.version&&!t)return m.success(`Kits are up to date (v${e.version})`),!1;m.info(`Updating Kits: v${e.version} \u2192 v${i.version}`);let n=await Ri(i),r=Ar(),o=await Bi({source:n,destination:r,strip:1});if(!o.success)return m.error(`Kits update failed: ${o.error}`),!1;let s={...e,version:i.version,installedAt:new Date().toISOString(),installedFiles:o.extractedFiles};return go(s),m.success(`Kits updated to v${i.version}`),!0}async function uv(){let t={cli:null,kits:null};try{let e=await qn(yn);e&&(t.cli={current:de,latest:e.version,available:Zi(de,e.version)})}catch{}try{let e=Mt(),i=await qt();e&&i&&(t.kits={current:e.version,latest:i.version,available:Zi(e.version,i.version)})}catch{}return t}var mv="gemkit-cli";function bE(t){return JE("npm",["install","-g",`${mv}@${t}`],{encoding:"utf-8",stdio:"pipe",shell:!0}).status===0}function BE(t){switch(t){case"gemini":return[".claude",".claude/**",".agent",".agent/**"];case"claude":return[".agent",".agent/**"];case"antigravity":return[".claude",".claude/**"];default:return[]}}function ZE(t){switch(t){case"gemini":return"Gemini CLI (excludes .claude, .agent)";case"claude":return"Claude Code (excludes .agent)";case"antigravity":return"Antigravity (excludes .claude)";default:return"Full (all files)"}}function PE(t,e){let i=t.replace(/\\/g,"/");for(let n of e)if(n.includes("*")){if(n.endsWith("/**")){let r=n.slice(0,-3);if(i.startsWith(r+"/"))return!0}}else if(i===n||i.startsWith(n+"/"))return!0;return!1}function qE(t){if(t.length!==0)return e=>!PE(e,t)}async function yE(){let t=FE(".gemini","extensions","spawn-agent");return kE(t)?new Promise(e=>{let i=QE("gemini",["extensions","install",t],{stdio:["pipe","pipe","pipe"],shell:process.platform==="win32",cwd:process.cwd()}),n="",r="",o=!1,s=setTimeout(()=>{o||(o=!0,i.kill(),e({success:!1,error:"Extension installation timed out"}))},3e4);i.stdout?.on("data",c=>{n+=c.toString()}),i.stderr?.on("data",c=>{r+=c.toString()}),i.on("close",c=>{o||(o=!0,clearTimeout(s),e(c===0?{success:!0}:{success:!1,error:r||n||`Exit code: ${c}`}))}),i.on("error",c=>{o||(o=!0,clearTimeout(s),e({success:!1,error:`Failed to run gemini CLI: ${c.message}`}))})}):{success:!1,error:`Extension directory not found: ${t}`}}function Ev(t){t.command("init","Initialize GemKit in project").option("--version <ver>","Specific version to install").option("-f, --force","Overwrite existing installation").option("--exclude <patterns...>","File patterns to exclude").option("--skip-extension","Skip spawn-agent extension installation").option("--full","Install all files (default)").option("--gemini","Gemini CLI mode (excludes .claude, .agent folders)").option("--claude","Claude Code mode (excludes .agent folder)").option("--antigravity","Antigravity mode (excludes .claude folder)").action(async e=>{let i="full";if(e.gemini?i="gemini":e.claude?i="claude":e.antigravity?i="antigravity":e.full&&(i="full"),ov()&&!e.force){console.log(),m.warn("GemKit is already installed. Use --force to reinstall."),console.log();return}console.log(),console.log(p.default.bold(a.geminiPurple("Initializing GemKit"))),console.log(),console.log(` ${a.dim("Mode")} ${a.accent(ZE(i))}`),console.log();let n=Ke({text:"Checking CLI version...",color:"magenta"}).start();try{let f=await qn(mv);f&&Zi(de,f.version)?(n.text=`Updating CLI v${de} \u2192 v${f.version}...`,bE(f.version)?n.succeed(`CLI updated v${a.primary(de)} \u2192 v${a.primary(f.version)}`):n.warn(`CLI v${a.primary(de)} (update to v${f.version} failed)`)):n.succeed(`CLI v${a.primary(de)}`)}catch{n.succeed(`CLI v${a.primary(de)}`)}let r=Ke({text:"Fetching latest Kits release...",color:"magenta"}).start(),o=e.version?await Jl(e.version):await qt();o||(r.fail("No Kits release found"),console.log(),process.exit(1)),r.succeed(`Found Kits v${a.primary(o.version)}`);let s=Ke({text:"Downloading Kits...",color:"magenta"}).start(),c;try{c=await Ri(o),s.succeed("Kits downloaded")}catch(f){s.fail(`Kits download failed: ${f instanceof Error?f.message:String(f)}`),console.log(),process.exit(1)}let l=BE(i),v=Ke({text:i==="full"?"Extracting Kits...":`Extracting Kits (${i} mode)...`,color:"magenta"}).start(),A=process.cwd(),u=await Bi({source:c,destination:A,strip:1,filter:qE(l)});u.success||(v.fail(`Kits extraction failed: ${u.error}`),console.log(),process.exit(1)),v.succeed(`Extracted ${u.extractedFiles.length} files`);let I=rv(o.version,"local",u.extractedFiles);if(go(I),console.log(),m.success(`Kits v${a.primary(o.version)} installed successfully!`),!e.skipExtension&&(i==="full"||i==="gemini")){console.log();let f=Ke({text:"Installing spawn-agent extension...",color:"magenta"}).start(),R=await yE();R.success?f.succeed("spawn-agent extension installed in Gemini CLI"):(f.warn(`Could not install spawn-agent extension: ${R.error}`),m.info(`You can manually install it with: ${a.primary("gemini extensions install .gemini/extensions/spawn-agent")}`))}else(i==="claude"||i==="antigravity")&&(console.log(),m.info(`Skipped Gemini extension (${i} mode).`));console.log(),m.info(`Run ${a.primary("gk doctor")} to verify installation.`),console.log()})}function Iv(t){t.command("versions","List available GemKit versions").alias("v").option("--json","Output as JSON").action(async e=>{let i=Mt(),n=await Ir();if(e.json){console.log(JSON.stringify({current:i?.version||null,available:n},null,2));return}console.log(),console.log(p.default.bold(a.geminiPurple("GemKit Versions"))),console.log(),console.log(i?` ${a.dim("Current:")} ${a.success(i.version)}`:` ${a.dim("Current:")} ${a.dim("Not installed")}`),console.log(),console.log(` ${p.default.bold("Available Releases:")}`);for(let r of n){let o=r.version===i?.version?a.success(" (current)"):"";console.log(` - ${a.primary(r.version)}${o}`)}console.log()})}import{existsSync as Yo}from"fs";import{join as DE}from"path";import{spawn as pv}from"child_process";async function wE(){return new Promise(t=>{let e=pv("gemini",["extensions","list"],{stdio:["pipe","pipe","pipe"],shell:process.platform==="win32"}),i="",n="",r=!1,o=setTimeout(()=>{r||(r=!0,e.kill(),t({installed:!1,error:"Check timed out"}))},2e4);e.stdout?.on("data",s=>{i+=s.toString()}),e.stderr?.on("data",s=>{n+=s.toString()}),e.on("close",s=>{if(!r)if(r=!0,clearTimeout(o),s===0){let c=i.toLowerCase().includes("spawn-agent");t({installed:c})}else t({installed:!1,error:n||"Failed to check extensions"})}),e.on("error",s=>{r||(r=!0,clearTimeout(o),t({installed:!1,error:`Gemini CLI not available: ${s.message}`}))})})}async function TE(){return new Promise(t=>{let e=pv("gemini",["--version"],{stdio:["pipe","pipe","pipe"],shell:process.platform==="win32"}),i="",n=!1,r=setTimeout(()=>{n||(n=!0,e.kill(),t({available:!1,error:"Timed out"}))},15e3);e.stdout?.on("data",o=>{i+=o.toString()}),e.on("close",o=>{if(!n)if(n=!0,clearTimeout(r),o===0){let s=i.trim().split(`
|
|
20
|
-
`)[0]||"unknown";t({available:!0,version:
|
|
21
|
-
Run: gemini extensions install .gemini/extensions/spawn-agent`:"Run: gemini extensions install .gemini/extensions/spawn-agent"}),i++)}let
|
|
22
|
-
`))console.log(` ${a.dim(
|
|
41
|
+
`,r)}while(n!==-1);return s+=t.slice(r),s}var{stdout:hm,stderr:gm}=Am,ic=Symbol("GENERATOR"),an=Symbol("STYLER"),ir=Symbol("IS_EMPTY"),Im=["ansi","ansi","ansi256","ansi16m"],cn=Object.create(null),md=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let i=hm?hm.level:0;t.level=e.level===void 0?i:e.level};var vd=t=>{let e=(...i)=>i.join(" ");return md(e,t),Object.setPrototypeOf(e,nr.prototype),e};function nr(t){return vd(t)}Object.setPrototypeOf(nr.prototype,Function.prototype);for(let[t,e]of Object.entries(ye))cn[t]={get(){let i=Is(this,rc(e.open,e.close,this[an]),this[ir]);return Object.defineProperty(this,t,{value:i}),i}};cn.visible={get(){let t=Is(this,this[an],!0);return Object.defineProperty(this,"visible",{value:t}),t}};var nc=(t,e,i,...n)=>t==="rgb"?e==="ansi16m"?ye[i].ansi16m(...n):e==="ansi256"?ye[i].ansi256(ye.rgbToAnsi256(...n)):ye[i].ansi(ye.rgbToAnsi(...n)):t==="hex"?nc("rgb",e,i,...ye.hexToRgb(...n)):ye[i][t](...n),pd=["rgb","hex","ansi256"];for(let t of pd){cn[t]={get(){let{level:i}=this;return function(...n){let r=rc(nc(t,Im[i],"color",...n),ye.color.close,this[an]);return Is(this,r,this[ir])}}};let e="bg"+t[0].toUpperCase()+t.slice(1);cn[e]={get(){let{level:i}=this;return function(...n){let r=rc(nc(t,Im[i],"bgColor",...n),ye.bgColor.close,this[an]);return Is(this,r,this[ir])}}}}var Ad=Object.defineProperties(()=>{},{...cn,level:{enumerable:!0,get(){return this[ic].level},set(t){this[ic].level=t}}}),rc=(t,e,i)=>{let n,r;return i===void 0?(n=t,r=e):(n=i.openAll+t,r=e+i.closeAll),{open:t,close:e,openAll:n,closeAll:r,parent:i}},Is=(t,e,i)=>{let n=(...r)=>dd(n,r.length===1?""+r[0]:r.join(" "));return Object.setPrototypeOf(n,Ad),n[ic]=t,n[an]=e,n[ir]=i,n},dd=(t,e)=>{if(t.level<=0||!e)return t[ir]?"":e;let i=t[an];if(i===void 0)return e;let{openAll:n,closeAll:r}=i;if(e.includes("\x1B"))for(;i!==void 0;)e=dm(e,i.close,i.open),i=i.parent;let s=e.indexOf(`
|
|
42
|
+
`);return s!==-1&&(e=fm(e,r,n,s)),n+e+r};Object.defineProperties(nr.prototype,cn);var fd=nr(),VR=nr({level:gm?gm.level:0});var qe=fd;import Sm from"node:process";import js from"node:process";var hd=(t,e,i,n)=>{if(i==="length"||i==="prototype"||i==="arguments"||i==="caller")return;let r=Object.getOwnPropertyDescriptor(t,i),s=Object.getOwnPropertyDescriptor(e,i);!gd(r,s)&&n||Object.defineProperty(t,i,s)},gd=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},Id=(t,e)=>{let i=Object.getPrototypeOf(e);i!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,i)},Ed=(t,e)=>`/* Wrapped ${t}*/
|
|
43
|
+
${e}`,Rd=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),zd=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),jd=(t,e,i)=>{let n=i===""?"":`with ${i.trim()}() `,r=Ed.bind(null,n,e.toString());Object.defineProperty(r,"name",zd);let{writable:s,enumerable:o,configurable:c}=Rd;Object.defineProperty(t,"toString",{value:r,writable:s,enumerable:o,configurable:c})};function sc(t,e,{ignoreNonConfigurable:i=!1}={}){let{name:n}=t;for(let r of Reflect.ownKeys(e))hd(t,e,r,i);return Id(t,e),jd(t,e,n),t}var Es=new WeakMap,Em=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let i,n=0,r=t.displayName||t.name||"<anonymous>",s=function(...o){if(Es.set(s,++n),n===1)i=t.apply(this,o),t=void 0;else if(e.throw===!0)throw new Error(`Function \`${r}\` can only be called once`);return i};return sc(s,t),Es.set(s,n),s};Em.callCount=t=>{if(!Es.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return Es.get(t)};var Rm=Em;var Yi=[];Yi.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Yi.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Yi.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Rs=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",oc=Symbol.for("signal-exit emitter"),ac=globalThis,xd=Object.defineProperty.bind(Object),cc=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ac[oc])return ac[oc];xd(ac,oc,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,i){this.listeners[e].push(i)}removeListener(e,i){let n=this.listeners[e],r=n.indexOf(i);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,i,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let s of this.listeners[e])r=s(i,n)===!0||r;return e==="exit"&&(r=this.emit("afterExit",i,n)||r),r}},zs=class{},Sd=t=>({onExit(e,i){return t.onExit(e,i)},load(){return t.load()},unload(){return t.unload()}}),lc=class extends zs{onExit(){return()=>{}}load(){}unload(){}},uc=class extends zs{#e=mc.platform==="win32"?"SIGINT":"SIGHUP";#n=new cc;#i;#r;#a;#t={};#s=!1;constructor(e){super(),this.#i=e,this.#t={};for(let i of Yi)this.#t[i]=()=>{let n=this.#i.listeners(i),{count:r}=this.#n,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(r+=s.__signal_exit_emitter__.count),n.length===r){this.unload();let o=this.#n.emit("exit",null,i),c=i==="SIGHUP"?this.#e:i;o||e.kill(e.pid,c)}};this.#a=e.reallyExit,this.#r=e.emit}onExit(e,i){if(!Rs(this.#i))return()=>{};this.#s===!1&&this.load();let n=i?.alwaysLast?"afterExit":"exit";return this.#n.on(n,e),()=>{this.#n.removeListener(n,e),this.#n.listeners.exit.length===0&&this.#n.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#n.count+=1;for(let e of Yi)try{let i=this.#t[e];i&&this.#i.on(e,i)}catch{}this.#i.emit=(e,...i)=>this.#p(e,...i),this.#i.reallyExit=e=>this.#o(e)}}unload(){this.#s&&(this.#s=!1,Yi.forEach(e=>{let i=this.#t[e];if(!i)throw new Error("Listener not defined for signal: "+e);try{this.#i.removeListener(e,i)}catch{}}),this.#i.emit=this.#r,this.#i.reallyExit=this.#a,this.#n.count-=1)}#o(e){return Rs(this.#i)?(this.#i.exitCode=e||0,this.#n.emit("exit",this.#i.exitCode,null),this.#a.call(this.#i,this.#i.exitCode)):0}#p(e,...i){let n=this.#r;if(e==="exit"&&Rs(this.#i)){typeof i[0]=="number"&&(this.#i.exitCode=i[0]);let r=n.call(this.#i,e,...i);return this.#n.emit("exit",this.#i.exitCode,null),r}else return n.call(this.#i,e,...i)}},mc=globalThis.process,{onExit:zm,load:JR,unload:ZR}=Sd(Rs(mc)?new uc(mc):new lc);var jm=js.stderr.isTTY?js.stderr:js.stdout.isTTY?js.stdout:void 0,Gd=jm?Rm(()=>{zm(()=>{jm.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},xm=Gd;var xs=!1,ln={};ln.show=(t=Sm.stderr)=>{t.isTTY&&(xs=!1,t.write("\x1B[?25h"))};ln.hide=(t=Sm.stderr)=>{t.isTTY&&(xm(),xs=!0,t.write("\x1B[?25l"))};ln.toggle=(t,e)=>{t!==void 0&&(xs=t),xs?ln.show(e):ln.hide(e)};var vc=ln;var or=As(pc(),1);import we from"node:process";function Ac(){return we.platform!=="win32"?we.env.TERM!=="linux":!!we.env.CI||!!we.env.WT_SESSION||!!we.env.TERMINUS_SUBLIME||we.env.ConEmuTask==="{cmd::Cmder}"||we.env.TERM_PROGRAM==="Terminus-Sublime"||we.env.TERM_PROGRAM==="vscode"||we.env.TERM==="xterm-256color"||we.env.TERM==="alacritty"||we.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Yd={info:qe.blue("\u2139"),success:qe.green("\u2714"),warning:qe.yellow("\u26A0"),error:qe.red("\u2716")},Wd={info:qe.blue("i"),success:qe.green("\u221A"),warning:qe.yellow("\u203C"),error:qe.red("\xD7")},Cd=Ac()?Yd:Wd,rr=Cd;function dc({onlyFirst:t=!1}={}){let r="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(r,t?void 0:"g")}var Od=dc();function sr(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Od,"")}function Wm(t){return t===161||t===164||t===167||t===168||t===170||t===173||t===174||t>=176&&t<=180||t>=182&&t<=186||t>=188&&t<=191||t===198||t===208||t===215||t===216||t>=222&&t<=225||t===230||t>=232&&t<=234||t===236||t===237||t===240||t===242||t===243||t>=247&&t<=250||t===252||t===254||t===257||t===273||t===275||t===283||t===294||t===295||t===299||t>=305&&t<=307||t===312||t>=319&&t<=322||t===324||t>=328&&t<=331||t===333||t===338||t===339||t===358||t===359||t===363||t===462||t===464||t===466||t===468||t===470||t===472||t===474||t===476||t===593||t===609||t===708||t===711||t>=713&&t<=715||t===717||t===720||t>=728&&t<=731||t===733||t===735||t>=768&&t<=879||t>=913&&t<=929||t>=931&&t<=937||t>=945&&t<=961||t>=963&&t<=969||t===1025||t>=1040&&t<=1103||t===1105||t===8208||t>=8211&&t<=8214||t===8216||t===8217||t===8220||t===8221||t>=8224&&t<=8226||t>=8228&&t<=8231||t===8240||t===8242||t===8243||t===8245||t===8251||t===8254||t===8308||t===8319||t>=8321&&t<=8324||t===8364||t===8451||t===8453||t===8457||t===8467||t===8470||t===8481||t===8482||t===8486||t===8491||t===8531||t===8532||t>=8539&&t<=8542||t>=8544&&t<=8555||t>=8560&&t<=8569||t===8585||t>=8592&&t<=8601||t===8632||t===8633||t===8658||t===8660||t===8679||t===8704||t===8706||t===8707||t===8711||t===8712||t===8715||t===8719||t===8721||t===8725||t===8730||t>=8733&&t<=8736||t===8739||t===8741||t>=8743&&t<=8748||t===8750||t>=8756&&t<=8759||t===8764||t===8765||t===8776||t===8780||t===8786||t===8800||t===8801||t>=8804&&t<=8807||t===8810||t===8811||t===8814||t===8815||t===8834||t===8835||t===8838||t===8839||t===8853||t===8857||t===8869||t===8895||t===8978||t>=9312&&t<=9449||t>=9451&&t<=9547||t>=9552&&t<=9587||t>=9600&&t<=9615||t>=9618&&t<=9621||t===9632||t===9633||t>=9635&&t<=9641||t===9650||t===9651||t===9654||t===9655||t===9660||t===9661||t===9664||t===9665||t>=9670&&t<=9672||t===9675||t>=9678&&t<=9681||t>=9698&&t<=9701||t===9711||t===9733||t===9734||t===9737||t===9742||t===9743||t===9756||t===9758||t===9792||t===9794||t===9824||t===9825||t>=9827&&t<=9829||t>=9831&&t<=9834||t===9836||t===9837||t===9839||t===9886||t===9887||t===9919||t>=9926&&t<=9933||t>=9935&&t<=9939||t>=9941&&t<=9953||t===9955||t===9960||t===9961||t>=9963&&t<=9969||t===9972||t>=9974&&t<=9977||t===9979||t===9980||t===9982||t===9983||t===10045||t>=10102&&t<=10111||t>=11094&&t<=11097||t>=12872&&t<=12879||t>=57344&&t<=63743||t>=65024&&t<=65039||t===65533||t>=127232&&t<=127242||t>=127248&&t<=127277||t>=127280&&t<=127337||t>=127344&&t<=127373||t===127375||t===127376||t>=127387&&t<=127404||t>=917760&&t<=917999||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function Cm(t){return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510}function Om(t){return t>=4352&&t<=4447||t===8986||t===8987||t===9001||t===9002||t>=9193&&t<=9196||t===9200||t===9203||t===9725||t===9726||t===9748||t===9749||t>=9776&&t<=9783||t>=9800&&t<=9811||t===9855||t>=9866&&t<=9871||t===9875||t===9889||t===9898||t===9899||t===9917||t===9918||t===9924||t===9925||t===9934||t===9940||t===9962||t===9970||t===9971||t===9973||t===9978||t===9981||t===9989||t===9994||t===9995||t===10024||t===10060||t===10062||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t===11035||t===11036||t===11088||t===11093||t>=11904&&t<=11929||t>=11931&&t<=12019||t>=12032&&t<=12245||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12353&&t<=12438||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12773||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=42124||t>=42128&&t<=42182||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=94176&&t<=94180||t>=94192&&t<=94198||t>=94208&&t<=101589||t>=101631&&t<=101662||t>=101760&&t<=101874||t>=110576&&t<=110579||t>=110581&&t<=110587||t===110589||t===110590||t>=110592&&t<=110882||t===110898||t>=110928&&t<=110930||t===110933||t>=110948&&t<=110951||t>=110960&&t<=111355||t>=119552&&t<=119638||t>=119648&&t<=119670||t===126980||t===127183||t===127374||t>=127377&&t<=127386||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t===127568||t===127569||t>=127584&&t<=127589||t>=127744&&t<=127776||t>=127789&&t<=127797||t>=127799&&t<=127868||t>=127870&&t<=127891||t>=127904&&t<=127946||t>=127951&&t<=127955||t>=127968&&t<=127984||t===127988||t>=127992&&t<=128062||t===128064||t>=128066&&t<=128252||t>=128255&&t<=128317||t>=128331&&t<=128334||t>=128336&&t<=128359||t===128378||t===128405||t===128406||t===128420||t>=128507&&t<=128591||t>=128640&&t<=128709||t===128716||t>=128720&&t<=128722||t>=128725&&t<=128728||t>=128732&&t<=128735||t===128747||t===128748||t>=128756&&t<=128764||t>=128992&&t<=129003||t===129008||t>=129292&&t<=129338||t>=129340&&t<=129349||t>=129351&&t<=129535||t>=129648&&t<=129660||t>=129664&&t<=129674||t>=129678&&t<=129734||t===129736||t>=129741&&t<=129756||t>=129759&&t<=129770||t>=129775&&t<=129784||t>=131072&&t<=196605||t>=196608&&t<=262141}function Ud(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function Um(t,{ambiguousAsWide:e=!1}={}){return Ud(t),Cm(t)||Om(t)||e&&Wm(t)?2:1}var Vm=As(km(),1),Kd=new Intl.Segmenter,kd=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function fc(t,e={}){if(typeof t!="string"||t.length===0)return 0;let{ambiguousIsNarrow:i=!0,countAnsiEscapeCodes:n=!1}=e;if(n||(t=sr(t)),t.length===0)return 0;let r=0,s={ambiguousAsWide:!i};for(let{segment:o}of Kd.segment(t)){let c=o.codePointAt(0);if(!(c<=31||c>=127&&c<=159)&&!(c>=8203&&c<=8207||c===65279)&&!(c>=768&&c<=879||c>=6832&&c<=6911||c>=7616&&c<=7679||c>=8400&&c<=8447||c>=65056&&c<=65071)&&!(c>=55296&&c<=57343)&&!(c>=65024&&c<=65039)&&!kd.test(o)){if((0,Vm.default)().test(o)){r+=2;continue}r+=Um(c,s)}}return r}function hc({stream:t=process.stdout}={}){return!!(t&&t.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import Nm from"node:process";function gc(){let{env:t}=Nm,{TERM:e,TERM_PROGRAM:i}=t;return Nm.platform!=="win32"?e!=="linux":!!t.WT_SESSION||!!t.TERMINUS_SUBLIME||t.ConEmuTask==="{cmd::Cmder}"||i==="Terminus-Sublime"||i==="vscode"||e==="xterm-256color"||e==="alacritty"||e==="rxvt-unicode"||e==="rxvt-unicode-256color"||t.TERMINAL_EMULATOR==="JetBrains-JediTerm"}import ct from"node:process";var Vd=3,Ic=class{#e=0;start(){this.#e++,this.#e===1&&this.#n()}stop(){if(this.#e<=0)throw new Error("`stop` called more times than `start`");this.#e--,this.#e===0&&this.#i()}#n(){ct.platform==="win32"||!ct.stdin.isTTY||(ct.stdin.setRawMode(!0),ct.stdin.on("data",this.#r),ct.stdin.resume())}#i(){ct.stdin.isTTY&&(ct.stdin.off("data",this.#r),ct.stdin.pause(),ct.stdin.setRawMode(!1))}#r(e){e[0]===Vd&&ct.emit("SIGINT")}},Nd=new Ic,Ec=Nd;var Fd=As(pc(),1),Rc=class{#e=0;#n=!1;#i=0;#r=-1;#a=0;#t;#s;#o;#p;#d;#u;#m;#v;#f;#c;#l;color;constructor(e){typeof e=="string"&&(e={text:e}),this.#t={color:"cyan",stream:Gs.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#t.color,this.spinner=this.#t.spinner,this.#d=this.#t.interval,this.#o=this.#t.stream,this.#u=typeof this.#t.isEnabled=="boolean"?this.#t.isEnabled:hc({stream:this.#o}),this.#m=typeof this.#t.isSilent=="boolean"?this.#t.isSilent:!1,this.text=this.#t.text,this.prefixText=this.#t.prefixText,this.suffixText=this.#t.suffixText,this.indent=this.#t.indent,Gs.env.NODE_ENV==="test"&&(this._stream=this.#o,this._isEnabled=this.#u,Object.defineProperty(this,"_linesToClear",{get(){return this.#e},set(i){this.#e=i}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#r}}),Object.defineProperty(this,"_lineCount",{get(){return this.#i}}))}get indent(){return this.#v}set indent(e=0){if(!(e>=0&&Number.isInteger(e)))throw new Error("The `indent` option must be an integer from 0 and up");this.#v=e,this.#A()}get interval(){return this.#d??this.#s.interval??100}get spinner(){return this.#s}set spinner(e){if(this.#r=-1,this.#d=void 0,typeof e=="object"){if(e.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#s=e}else if(!gc())this.#s=or.default.line;else if(e===void 0)this.#s=or.default.dots;else if(e!=="default"&&or.default[e])this.#s=or.default[e];else throw new Error(`There is no built-in spinner named '${e}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#f}set text(e=""){this.#f=e,this.#A()}get prefixText(){return this.#c}set prefixText(e=""){this.#c=e,this.#A()}get suffixText(){return this.#l}set suffixText(e=""){this.#l=e,this.#A()}get isSpinning(){return this.#p!==void 0}#h(e=this.#c,i=" "){return typeof e=="string"&&e!==""?e+i:typeof e=="function"?e()+i:""}#g(e=this.#l,i=" "){return typeof e=="string"&&e!==""?i+e:typeof e=="function"?i+e():""}#A(){let e=this.#o.columns??80,i=this.#h(this.#c,"-"),n=this.#g(this.#l,"-"),r=" ".repeat(this.#v)+i+"--"+this.#f+"--"+n;this.#i=0;for(let s of sr(r).split(`
|
|
44
|
+
`))this.#i+=Math.max(1,Math.ceil(fc(s,{countAnsiEscapeCodes:!0})/e))}get isEnabled(){return this.#u&&!this.#m}set isEnabled(e){if(typeof e!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#u=e}get isSilent(){return this.#m}set isSilent(e){if(typeof e!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#m=e}frame(){let e=Date.now();(this.#r===-1||e-this.#a>=this.interval)&&(this.#r=++this.#r%this.#s.frames.length,this.#a=e);let{frames:i}=this.#s,n=i[this.#r];this.color&&(n=qe[this.color](n));let r=typeof this.#c=="string"&&this.#c!==""?this.#c+" ":"",s=typeof this.text=="string"?" "+this.text:"",o=typeof this.#l=="string"&&this.#l!==""?" "+this.#l:"";return r+n+s+o}clear(){if(!this.#u||!this.#o.isTTY)return this;this.#o.cursorTo(0);for(let e=0;e<this.#e;e++)e>0&&this.#o.moveCursor(0,-1),this.#o.clearLine(1);return(this.#v||this.lastIndent!==this.#v)&&this.#o.cursorTo(this.#v),this.lastIndent=this.#v,this.#e=0,this}render(){return this.#m?this:(this.clear(),this.#o.write(this.frame()),this.#e=this.#i,this)}start(e){return e&&(this.text=e),this.#m?this:this.#u?this.isSpinning?this:(this.#t.hideCursor&&vc.hide(this.#o),this.#t.discardStdin&&Gs.stdin.isTTY&&(this.#n=!0,Ec.start()),this.render(),this.#p=setInterval(this.render.bind(this),this.interval),this):(this.text&&this.#o.write(`- ${this.text}
|
|
45
|
+
`),this)}stop(){return this.#u?(clearInterval(this.#p),this.#p=void 0,this.#r=0,this.clear(),this.#t.hideCursor&&vc.show(this.#o),this.#t.discardStdin&&Gs.stdin.isTTY&&this.#n&&(Ec.stop(),this.#n=!1),this):this}succeed(e){return this.stopAndPersist({symbol:rr.success,text:e})}fail(e){return this.stopAndPersist({symbol:rr.error,text:e})}warn(e){return this.stopAndPersist({symbol:rr.warning,text:e})}info(e){return this.stopAndPersist({symbol:rr.info,text:e})}stopAndPersist(e={}){if(this.#m)return this;let i=e.prefixText??this.#c,n=this.#h(i," "),r=e.symbol??" ",s=e.text??this.text,c=typeof s=="string"?(r?" ":"")+s:"",l=e.suffixText??this.#l,u=this.#g(l," "),m=n+r+c+u+`
|
|
46
|
+
`;return this.stop(),this.#o.write(m),this}};function lt(t){return new Rc(t)}k();import{existsSync as Qm,readFileSync as Zd,writeFileSync as yd,mkdirSync as qd}from"fs";import{dirname as wd}from"path";var Ke={defaultScope:"local",github:{repo:"therichardngai-code/gemkit-kits-starter",apiUrl:"https://api.github.com"},cache:{enabled:!0,ttl:3600},installation:{excludePatterns:[],backupOnUpdate:!0},ui:{colors:!0,spinner:!0,verbose:!1},paths:{},spawn:{defaultModel:"gemini-3-flash-preview",music:!1},office:{enabled:!0,mode:"web",port:3847,autoOpen:!0,sounds:!1,refreshRate:500},update:{autoCheck:!0,checkInterval:24,notifyOnly:!0}};function bm(t){return!(!t||typeof t!="object")}function Pm(t){return{...Ke,...t,github:{...Ke.github,...t.github||{}},cache:{...Ke.cache,...t.cache||{}},installation:{...Ke.installation,...t.installation||{}},ui:{...Ke.ui,...t.ui||{}},paths:{...Ke.paths,...t.paths||{}},spawn:{...Ke.spawn,...t.spawn||{}},office:{...Ke.office,...t.office||{}},update:{...Ke.update,...t.update||{}}}}var Ys=class extends Error{constructor(i,n="GEMKIT_ERROR",r){super(i);this.code=n;this.details=r;this.name="GemKitError"}},Ui=class extends Ys{constructor(e,i){super(e,"CONFIG_ERROR",i),this.name="ConfigError"}};var ke=class extends Ys{constructor(e,i){super(e,"GITHUB_ERROR",i),this.name="GitHubError"}};function Ie(t){let e=xc(t);if(!Qm(e))return Ke;try{let i=Zd(e,"utf-8"),n=JSON.parse(i);if(!bm(n))throw new Ui("Invalid configuration format");return Pm(n)}catch(i){throw i instanceof Ui?i:new Ui(`Failed to load config: ${i}`)}}function Bm(t,e){let i=xc(e),n=wd(i);Qm(n)||qd(n,{recursive:!0}),yd(i,JSON.stringify(t,null,2))}function Jm(t,e){let i=Ie(e),n=t.split("."),r=i;for(let s of n)if(r&&typeof r=="object"&&s in r)r=r[s];else return;return r}function Zm(t,e,i){let n=Ie(i),r=t.split("."),s=r.pop();if(!s)throw new Ui("Invalid config path");let o=n;for(let c of r)(!(c in o)||typeof o[c]!="object")&&(o[c]={}),o=o[c];o[s]=e,Bm(n,i)}function ym(t){Bm(Ke,t)}k();import{existsSync as qm,readFileSync as Dd,writeFileSync as Td,mkdirSync as Xd,readdirSync as wm,unlinkSync as Dm,statSync as Hd}from"fs";import{join as Gc}from"path";function Mc(){return qm(un)||Xd(un,{recursive:!0}),un}function Tm(t){let e=t.replace(/[^a-zA-Z0-9-_]/g,"_");return Gc(Mc(),`${e}.json`)}function Ws(t){let e=Tm(t);if(!qm(e))return null;try{let i=Dd(e,"utf-8"),n=JSON.parse(i);return Date.now()-n.timestamp>n.ttl*1e3?(Dm(e),null):n.data}catch{return null}}function Cs(t,e,i=3600){let n=Tm(t),r={key:t,data:e,timestamp:Date.now(),ttl:i};Td(n,JSON.stringify(r,null,2))}function Xm(){let t=Mc(),e=wm(t).filter(i=>i.endsWith(".json"));for(let i of e)Dm(Gc(t,i));return e.length}function Hm(){let t=Mc(),e=wm(t).filter(n=>n.endsWith(".json")),i=0;for(let n of e){let r=Hd(Gc(t,n));i+=r.size}return{entries:e.length,size:i}}var Lm="github-releases",Ld=300;async function Os(t=10){let e=Ws(Lm);if(e)return e.slice(0,t);let i=Ie(),{repo:n,apiUrl:r}=i.github,s=`${r}/repos/${n}/releases?per_page=${t}`;try{let o=await fetch(s,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"gemkit-cli"}});if(!o.ok)throw new ke(`Failed to fetch releases: ${o.status}`);let l=(await o.json()).map(u=>({version:u.tag_name.replace(/^v/,""),tag:u.tag_name,publishedAt:u.published_at,prerelease:u.prerelease,assets:u.assets.map(m=>({name:m.name,url:m.url,size:m.size,downloadUrl:m.browser_download_url}))}));return Cs(Lm,l,Ld),l}catch(o){throw o instanceof ke?o:new ke(`Failed to fetch releases: ${o}`)}}async function Ki(){let t=await Os(1);return t.length>0?t[0]:null}async function _m(t){return(await Os(50)).find(i=>i.version===t||i.tag===t)||null}k();import{createWriteStream as _d,existsSync as $d,mkdirSync as ef}from"fs";import{pipeline as tf}from"stream/promises";import{join as nf}from"path";async function rf(t,e=un){$d(e)||ef(e,{recursive:!0});let i=nf(e,t.name);try{let n=await fetch(t.downloadUrl,{headers:{"User-Agent":"gemkit-cli"}});if(!n.ok)throw new ke(`Failed to download asset: ${n.status}`);if(!n.body)throw new ke("No response body");let r=_d(i);return await tf(n.body,r),i}catch(n){throw n instanceof ke?n:new ke(`Download failed: ${n}`)}}async function pn(t){let e=t.assets.find(i=>i.name.endsWith(".tar.gz")||i.name.endsWith(".tgz"));if(!e)throw new ke("No tarball asset found in release");return rf(e)}import{createReadStream as lh,createWriteStream as ZS,existsSync as dv,mkdirSync as uh}from"fs";import{pipeline as mh}from"stream/promises";import{createGunzip as vh}from"zlib";import df from"events";import fe from"fs";import{EventEmitter as kc}from"node:events";import n3 from"node:stream";import{StringDecoder as sf}from"node:string_decoder";var $m=typeof process=="object"&&process?process:{stdout:null,stderr:null},of=t=>!!t&&typeof t=="object"&&(t instanceof pr||t instanceof n3||af(t)||cf(t)),af=t=>!!t&&typeof t=="object"&&t instanceof kc&&typeof t.pipe=="function"&&t.pipe!==n3.Writable.prototype.pipe,cf=t=>!!t&&typeof t=="object"&&t instanceof kc&&typeof t.write=="function"&&typeof t.end=="function",St=Symbol("EOF"),Gt=Symbol("maybeEmitEnd"),Tt=Symbol("emittedEnd"),Us=Symbol("emittingEnd"),lr=Symbol("emittedError"),Ks=Symbol("closed"),e3=Symbol("read"),ks=Symbol("flush"),t3=Symbol("flushChunk"),De=Symbol("encoding"),An=Symbol("decoder"),q=Symbol("flowing"),ur=Symbol("paused"),dn=Symbol("resume"),w=Symbol("buffer"),le=Symbol("pipes"),D=Symbol("bufferLength"),Yc=Symbol("bufferPush"),Vs=Symbol("bufferShift"),re=Symbol("objectMode"),V=Symbol("destroyed"),Wc=Symbol("error"),Cc=Symbol("emitData"),i3=Symbol("emitEnd"),Oc=Symbol("emitEnd2"),ut=Symbol("async"),Uc=Symbol("abort"),Ns=Symbol("aborted"),mr=Symbol("signal"),ki=Symbol("dataListeners"),Ee=Symbol("discarded"),vr=t=>Promise.resolve().then(t),lf=t=>t(),uf=t=>t==="end"||t==="finish"||t==="prefinish",mf=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,vf=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Fs=class{src;dest;opts;ondrain;constructor(e,i,n){this.src=e,this.dest=i,this.opts=n,this.ondrain=()=>e[dn](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Kc=class extends Fs{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,i,n){super(e,i,n),this.proxyErrors=r=>i.emit("error",r),e.on("error",this.proxyErrors)}},pf=t=>!!t.objectMode,Af=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",pr=class extends kc{[q]=!1;[ur]=!1;[le]=[];[w]=[];[re];[De];[ut];[An];[St]=!1;[Tt]=!1;[Us]=!1;[Ks]=!1;[lr]=null;[D]=0;[V]=!1;[mr];[Ns]=!1;[ki]=0;[Ee]=!1;writable=!0;readable=!0;constructor(...e){let i=e[0]||{};if(super(),i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");pf(i)?(this[re]=!0,this[De]=null):Af(i)?(this[De]=i.encoding,this[re]=!1):(this[re]=!1,this[De]=null),this[ut]=!!i.async,this[An]=this[De]?new sf(this[De]):null,i&&i.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[w]}),i&&i.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[le]});let{signal:n}=i;n&&(this[mr]=n,n.aborted?this[Uc]():n.addEventListener("abort",()=>this[Uc]()))}get bufferLength(){return this[D]}get encoding(){return this[De]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[re]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[ut]}set async(e){this[ut]=this[ut]||!!e}[Uc](){this[Ns]=!0,this.emit("abort",this[mr]?.reason),this.destroy(this[mr]?.reason)}get aborted(){return this[Ns]}set aborted(e){}write(e,i,n){if(this[Ns])return!1;if(this[St])throw new Error("write after end");if(this[V])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof i=="function"&&(n=i,i="utf8"),i||(i="utf8");let r=this[ut]?vr:lf;if(!this[re]&&!Buffer.isBuffer(e)){if(vf(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(mf(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[re]?(this[q]&&this[D]!==0&&this[ks](!0),this[q]?this.emit("data",e):this[Yc](e),this[D]!==0&&this.emit("readable"),n&&r(n),this[q]):e.length?(typeof e=="string"&&!(i===this[De]&&!this[An]?.lastNeed)&&(e=Buffer.from(e,i)),Buffer.isBuffer(e)&&this[De]&&(e=this[An].write(e)),this[q]&&this[D]!==0&&this[ks](!0),this[q]?this.emit("data",e):this[Yc](e),this[D]!==0&&this.emit("readable"),n&&r(n),this[q]):(this[D]!==0&&this.emit("readable"),n&&r(n),this[q])}read(e){if(this[V])return null;if(this[Ee]=!1,this[D]===0||e===0||e&&e>this[D])return this[Gt](),null;this[re]&&(e=null),this[w].length>1&&!this[re]&&(this[w]=[this[De]?this[w].join(""):Buffer.concat(this[w],this[D])]);let i=this[e3](e||null,this[w][0]);return this[Gt](),i}[e3](e,i){if(this[re])this[Vs]();else{let n=i;e===n.length||e===null?this[Vs]():typeof n=="string"?(this[w][0]=n.slice(e),i=n.slice(0,e),this[D]-=e):(this[w][0]=n.subarray(e),i=n.subarray(0,e),this[D]-=e)}return this.emit("data",i),!this[w].length&&!this[St]&&this.emit("drain"),i}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i="utf8"),e!==void 0&&this.write(e,i),n&&this.once("end",n),this[St]=!0,this.writable=!1,(this[q]||!this[ur])&&this[Gt](),this}[dn](){this[V]||(!this[ki]&&!this[le].length&&(this[Ee]=!0),this[ur]=!1,this[q]=!0,this.emit("resume"),this[w].length?this[ks]():this[St]?this[Gt]():this.emit("drain"))}resume(){return this[dn]()}pause(){this[q]=!1,this[ur]=!0,this[Ee]=!1}get destroyed(){return this[V]}get flowing(){return this[q]}get paused(){return this[ur]}[Yc](e){this[re]?this[D]+=1:this[D]+=e.length,this[w].push(e)}[Vs](){return this[re]?this[D]-=1:this[D]-=this[w][0].length,this[w].shift()}[ks](e=!1){do;while(this[t3](this[Vs]())&&this[w].length);!e&&!this[w].length&&!this[St]&&this.emit("drain")}[t3](e){return this.emit("data",e),this[q]}pipe(e,i){if(this[V])return e;this[Ee]=!1;let n=this[Tt];return i=i||{},e===$m.stdout||e===$m.stderr?i.end=!1:i.end=i.end!==!1,i.proxyErrors=!!i.proxyErrors,n?i.end&&e.end():(this[le].push(i.proxyErrors?new Kc(this,e,i):new Fs(this,e,i)),this[ut]?vr(()=>this[dn]()):this[dn]()),e}unpipe(e){let i=this[le].find(n=>n.dest===e);i&&(this[le].length===1?(this[q]&&this[ki]===0&&(this[q]=!1),this[le]=[]):this[le].splice(this[le].indexOf(i),1),i.unpipe())}addListener(e,i){return this.on(e,i)}on(e,i){let n=super.on(e,i);if(e==="data")this[Ee]=!1,this[ki]++,!this[le].length&&!this[q]&&this[dn]();else if(e==="readable"&&this[D]!==0)super.emit("readable");else if(uf(e)&&this[Tt])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[lr]){let r=i;this[ut]?vr(()=>r.call(this,this[lr])):r.call(this,this[lr])}return n}removeListener(e,i){return this.off(e,i)}off(e,i){let n=super.off(e,i);return e==="data"&&(this[ki]=this.listeners("data").length,this[ki]===0&&!this[Ee]&&!this[le].length&&(this[q]=!1)),n}removeAllListeners(e){let i=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[ki]=0,!this[Ee]&&!this[le].length&&(this[q]=!1)),i}get emittedEnd(){return this[Tt]}[Gt](){!this[Us]&&!this[Tt]&&!this[V]&&this[w].length===0&&this[St]&&(this[Us]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ks]&&this.emit("close"),this[Us]=!1)}emit(e,...i){let n=i[0];if(e!=="error"&&e!=="close"&&e!==V&&this[V])return!1;if(e==="data")return!this[re]&&!n?!1:this[ut]?(vr(()=>this[Cc](n)),!0):this[Cc](n);if(e==="end")return this[i3]();if(e==="close"){if(this[Ks]=!0,!this[Tt]&&!this[V])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[lr]=n,super.emit(Wc,n);let s=!this[mr]||this.listeners("error").length?super.emit("error",n):!1;return this[Gt](),s}else if(e==="resume"){let s=super.emit("resume");return this[Gt](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let r=super.emit(e,...i);return this[Gt](),r}[Cc](e){for(let n of this[le])n.dest.write(e)===!1&&this.pause();let i=this[Ee]?!1:super.emit("data",e);return this[Gt](),i}[i3](){return this[Tt]?!1:(this[Tt]=!0,this.readable=!1,this[ut]?(vr(()=>this[Oc]()),!0):this[Oc]())}[Oc](){if(this[An]){let i=this[An].end();if(i){for(let n of this[le])n.dest.write(i);this[Ee]||super.emit("data",i)}}for(let i of this[le])i.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[re]||(e.dataLength=0);let i=this.promise();return this.on("data",n=>{e.push(n),this[re]||(e.dataLength+=n.length)}),await i,e}async concat(){if(this[re])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[De]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,i)=>{this.on(V,()=>i(new Error("stream destroyed"))),this.on("error",n=>i(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Ee]=!1;let e=!1,i=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return i();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[St])return i();let s,o,c=p=>{this.off("data",l),this.off("end",u),this.off(V,m),i(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(V,m),this.pause(),s({value:p,done:!!this[St]})},u=()=>{this.off("error",c),this.off("data",l),this.off(V,m),i(),s({done:!0,value:void 0})},m=()=>c(new Error("stream destroyed"));return new Promise((p,d)=>{o=d,s=p,this.once(V,m),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:i,return:i,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Ee]=!1;let e=!1,i=()=>(this.pause(),this.off(Wc,i),this.off(V,i),this.off("end",i),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return i();let r=this.read();return r===null?i():{done:!1,value:r}};return this.once("end",i),this.once(Wc,i),this.once(V,i),{next:n,throw:i,return:i,[Symbol.iterator](){return this}}}destroy(e){if(this[V])return e?this.emit("error",e):this.emit(V),this;this[V]=!0,this[Ee]=!0,this[w].length=0,this[D]=0;let i=this;return typeof i.close=="function"&&!this[Ks]&&i.close(),e?this.emit("error",e):this.emit(V),this}static get isStream(){return of}};var ff=fe.writev,Ht=Symbol("_autoClose"),Xe=Symbol("_close"),Ar=Symbol("_ended"),x=Symbol("_fd"),Vc=Symbol("_finished"),Yt=Symbol("_flags"),Nc=Symbol("_flush"),Qc=Symbol("_handleChunk"),Bc=Symbol("_makeBuf"),fr=Symbol("_mode"),bs=Symbol("_needDrain"),gn=Symbol("_onerror"),In=Symbol("_onopen"),Fc=Symbol("_onread"),fn=Symbol("_onwrite"),Lt=Symbol("_open"),Te=Symbol("_path"),Xt=Symbol("_pos"),mt=Symbol("_queue"),hn=Symbol("_read"),bc=Symbol("_readSize"),Mt=Symbol("_reading"),dr=Symbol("_remain"),Pc=Symbol("_size"),Ps=Symbol("_write"),Vi=Symbol("_writing"),Qs=Symbol("_defaultFlag"),Ni=Symbol("_errored"),Fi=class extends pr{[Ni]=!1;[x];[Te];[bc];[Mt]=!1;[Pc];[dr];[Ht];constructor(e,i){if(i=i||{},super(i),this.readable=!0,this.writable=!1,typeof e!="string")throw new TypeError("path must be a string");this[Ni]=!1,this[x]=typeof i.fd=="number"?i.fd:void 0,this[Te]=e,this[bc]=i.readSize||16*1024*1024,this[Mt]=!1,this[Pc]=typeof i.size=="number"?i.size:1/0,this[dr]=this[Pc],this[Ht]=typeof i.autoClose=="boolean"?i.autoClose:!0,typeof this[x]=="number"?this[hn]():this[Lt]()}get fd(){return this[x]}get path(){return this[Te]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[Lt](){fe.open(this[Te],"r",(e,i)=>this[In](e,i))}[In](e,i){e?this[gn](e):(this[x]=i,this.emit("open",i),this[hn]())}[Bc](){return Buffer.allocUnsafe(Math.min(this[bc],this[dr]))}[hn](){if(!this[Mt]){this[Mt]=!0;let e=this[Bc]();if(e.length===0)return process.nextTick(()=>this[Fc](null,0,e));fe.read(this[x],e,0,e.length,null,(i,n,r)=>this[Fc](i,n,r))}}[Fc](e,i,n){this[Mt]=!1,e?this[gn](e):this[Qc](i,n)&&this[hn]()}[Xe](){if(this[Ht]&&typeof this[x]=="number"){let e=this[x];this[x]=void 0,fe.close(e,i=>i?this.emit("error",i):this.emit("close"))}}[gn](e){this[Mt]=!0,this[Xe](),this.emit("error",e)}[Qc](e,i){let n=!1;return this[dr]-=e,e>0&&(n=super.write(e<i.length?i.subarray(0,e):i)),(e===0||this[dr]<=0)&&(n=!1,this[Xe](),super.end()),n}emit(e,...i){switch(e){case"prefinish":case"finish":return!1;case"drain":return typeof this[x]=="number"&&this[hn](),!1;case"error":return this[Ni]?!1:(this[Ni]=!0,super.emit(e,...i));default:return super.emit(e,...i)}}},Bs=class extends Fi{[Lt](){let e=!0;try{this[In](null,fe.openSync(this[Te],"r")),e=!1}finally{e&&this[Xe]()}}[hn](){let e=!0;try{if(!this[Mt]){this[Mt]=!0;do{let i=this[Bc](),n=i.length===0?0:fe.readSync(this[x],i,0,i.length,null);if(!this[Qc](n,i))break}while(!0);this[Mt]=!1}e=!1}finally{e&&this[Xe]()}}[Xe](){if(this[Ht]&&typeof this[x]=="number"){let e=this[x];this[x]=void 0,fe.closeSync(e),this.emit("close")}}},Wt=class extends df{readable=!1;writable=!0;[Ni]=!1;[Vi]=!1;[Ar]=!1;[mt]=[];[bs]=!1;[Te];[fr];[Ht];[x];[Qs];[Yt];[Vc]=!1;[Xt];constructor(e,i){i=i||{},super(i),this[Te]=e,this[x]=typeof i.fd=="number"?i.fd:void 0,this[fr]=i.mode===void 0?438:i.mode,this[Xt]=typeof i.start=="number"?i.start:void 0,this[Ht]=typeof i.autoClose=="boolean"?i.autoClose:!0;let n=this[Xt]!==void 0?"r+":"w";this[Qs]=i.flags===void 0,this[Yt]=i.flags===void 0?n:i.flags,this[x]===void 0&&this[Lt]()}emit(e,...i){if(e==="error"){if(this[Ni])return!1;this[Ni]=!0}return super.emit(e,...i)}get fd(){return this[x]}get path(){return this[Te]}[gn](e){this[Xe](),this[Vi]=!0,this.emit("error",e)}[Lt](){fe.open(this[Te],this[Yt],this[fr],(e,i)=>this[In](e,i))}[In](e,i){this[Qs]&&this[Yt]==="r+"&&e&&e.code==="ENOENT"?(this[Yt]="w",this[Lt]()):e?this[gn](e):(this[x]=i,this.emit("open",i),this[Vi]||this[Nc]())}end(e,i){return e&&this.write(e,i),this[Ar]=!0,!this[Vi]&&!this[mt].length&&typeof this[x]=="number"&&this[fn](null,0),this}write(e,i){return typeof e=="string"&&(e=Buffer.from(e,i)),this[Ar]?(this.emit("error",new Error("write() after end()")),!1):this[x]===void 0||this[Vi]||this[mt].length?(this[mt].push(e),this[bs]=!0,!1):(this[Vi]=!0,this[Ps](e),!0)}[Ps](e){fe.write(this[x],e,0,e.length,this[Xt],(i,n)=>this[fn](i,n))}[fn](e,i){e?this[gn](e):(this[Xt]!==void 0&&typeof i=="number"&&(this[Xt]+=i),this[mt].length?this[Nc]():(this[Vi]=!1,this[Ar]&&!this[Vc]?(this[Vc]=!0,this[Xe](),this.emit("finish")):this[bs]&&(this[bs]=!1,this.emit("drain"))))}[Nc](){if(this[mt].length===0)this[Ar]&&this[fn](null,0);else if(this[mt].length===1)this[Ps](this[mt].pop());else{let e=this[mt];this[mt]=[],ff(this[x],e,this[Xt],(i,n)=>this[fn](i,n))}}[Xe](){if(this[Ht]&&typeof this[x]=="number"){let e=this[x];this[x]=void 0,fe.close(e,i=>i?this.emit("error",i):this.emit("close"))}}},En=class extends Wt{[Lt](){let e;if(this[Qs]&&this[Yt]==="r+")try{e=fe.openSync(this[Te],this[Yt],this[fr])}catch(i){if(i?.code==="ENOENT")return this[Yt]="w",this[Lt]();throw i}else e=fe.openSync(this[Te],this[Yt],this[fr]);this[In](null,e)}[Xe](){if(this[Ht]&&typeof this[x]=="number"){let e=this[x];this[x]=void 0,fe.closeSync(e),this.emit("close")}}[Ps](e){let i=!0;try{this[fn](null,fe.writeSync(this[x],e,0,e.length,this[Xt])),i=!1}finally{if(i)try{this[Xe]()}catch{}}}};import D3 from"node:path";import Wn from"node:fs";import{dirname as p7,parse as A7}from"path";var hf=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),r3=t=>!!t.sync&&!!t.file,s3=t=>!t.sync&&!!t.file,o3=t=>!!t.sync&&!t.file,a3=t=>!t.sync&&!t.file;var c3=t=>!!t.file;var gf=t=>{let e=hf.get(t);return e||t},hr=(t={})=>{if(!t)return{};let e={};for(let[i,n]of Object.entries(t)){let r=gf(i);e[r]=n}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e};var vt=(t,e,i,n,r)=>Object.assign((s=[],o,c)=>{Array.isArray(s)&&(o=s,s={}),typeof o=="function"&&(c=o,o=void 0),o?o=Array.from(o):o=[];let l=hr(s);if(r?.(l,o),r3(l)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return t(l,o)}else if(s3(l)){let u=e(l,o),m=c||void 0;return m?u.then(()=>m(),m):u}else if(o3(l)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return i(l,o)}else if(a3(l)){if(typeof c=="function")throw new TypeError("callback only supported with file option");return n(l,o)}else throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:n,validate:r});import{EventEmitter as l7}from"events";import _c from"assert";import{Buffer as Pi}from"buffer";import{EventEmitter as Xc}from"node:events";import p3 from"node:stream";import{StringDecoder as If}from"node:string_decoder";var l3=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ef=t=>!!t&&typeof t=="object"&&(t instanceof zr||t instanceof p3||Rf(t)||zf(t)),Rf=t=>!!t&&typeof t=="object"&&t instanceof Xc&&typeof t.pipe=="function"&&t.pipe!==p3.Writable.prototype.pipe,zf=t=>!!t&&typeof t=="object"&&t instanceof Xc&&typeof t.write=="function"&&typeof t.end=="function",Ct=Symbol("EOF"),Ot=Symbol("maybeEmitEnd"),_t=Symbol("emittedEnd"),Js=Symbol("emittingEnd"),gr=Symbol("emittedError"),Zs=Symbol("closed"),u3=Symbol("read"),ys=Symbol("flush"),m3=Symbol("flushChunk"),He=Symbol("encoding"),Rn=Symbol("decoder"),T=Symbol("flowing"),Ir=Symbol("paused"),zn=Symbol("resume"),X=Symbol("buffer"),ue=Symbol("pipes"),H=Symbol("bufferLength"),Zc=Symbol("bufferPush"),qs=Symbol("bufferShift"),se=Symbol("objectMode"),N=Symbol("destroyed"),yc=Symbol("error"),qc=Symbol("emitData"),v3=Symbol("emitEnd"),wc=Symbol("emitEnd2"),pt=Symbol("async"),Dc=Symbol("abort"),ws=Symbol("aborted"),Er=Symbol("signal"),bi=Symbol("dataListeners"),Re=Symbol("discarded"),Rr=t=>Promise.resolve().then(t),jf=t=>t(),xf=t=>t==="end"||t==="finish"||t==="prefinish",Sf=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Gf=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Ds=class{src;dest;opts;ondrain;constructor(e,i,n){this.src=e,this.dest=i,this.opts=n,this.ondrain=()=>e[zn](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Tc=class extends Ds{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,i,n){super(e,i,n),this.proxyErrors=r=>i.emit("error",r),e.on("error",this.proxyErrors)}},Mf=t=>!!t.objectMode,Yf=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",zr=class extends Xc{[T]=!1;[Ir]=!1;[ue]=[];[X]=[];[se];[He];[pt];[Rn];[Ct]=!1;[_t]=!1;[Js]=!1;[Zs]=!1;[gr]=null;[H]=0;[N]=!1;[Er];[ws]=!1;[bi]=0;[Re]=!1;writable=!0;readable=!0;constructor(...e){let i=e[0]||{};if(super(),i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Mf(i)?(this[se]=!0,this[He]=null):Yf(i)?(this[He]=i.encoding,this[se]=!1):(this[se]=!1,this[He]=null),this[pt]=!!i.async,this[Rn]=this[He]?new If(this[He]):null,i&&i.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[X]}),i&&i.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[ue]});let{signal:n}=i;n&&(this[Er]=n,n.aborted?this[Dc]():n.addEventListener("abort",()=>this[Dc]()))}get bufferLength(){return this[H]}get encoding(){return this[He]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[se]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[pt]}set async(e){this[pt]=this[pt]||!!e}[Dc](){this[ws]=!0,this.emit("abort",this[Er]?.reason),this.destroy(this[Er]?.reason)}get aborted(){return this[ws]}set aborted(e){}write(e,i,n){if(this[ws])return!1;if(this[Ct])throw new Error("write after end");if(this[N])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof i=="function"&&(n=i,i="utf8"),i||(i="utf8");let r=this[pt]?Rr:jf;if(!this[se]&&!Buffer.isBuffer(e)){if(Gf(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Sf(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[se]?(this[T]&&this[H]!==0&&this[ys](!0),this[T]?this.emit("data",e):this[Zc](e),this[H]!==0&&this.emit("readable"),n&&r(n),this[T]):e.length?(typeof e=="string"&&!(i===this[He]&&!this[Rn]?.lastNeed)&&(e=Buffer.from(e,i)),Buffer.isBuffer(e)&&this[He]&&(e=this[Rn].write(e)),this[T]&&this[H]!==0&&this[ys](!0),this[T]?this.emit("data",e):this[Zc](e),this[H]!==0&&this.emit("readable"),n&&r(n),this[T]):(this[H]!==0&&this.emit("readable"),n&&r(n),this[T])}read(e){if(this[N])return null;if(this[Re]=!1,this[H]===0||e===0||e&&e>this[H])return this[Ot](),null;this[se]&&(e=null),this[X].length>1&&!this[se]&&(this[X]=[this[He]?this[X].join(""):Buffer.concat(this[X],this[H])]);let i=this[u3](e||null,this[X][0]);return this[Ot](),i}[u3](e,i){if(this[se])this[qs]();else{let n=i;e===n.length||e===null?this[qs]():typeof n=="string"?(this[X][0]=n.slice(e),i=n.slice(0,e),this[H]-=e):(this[X][0]=n.subarray(e),i=n.subarray(0,e),this[H]-=e)}return this.emit("data",i),!this[X].length&&!this[Ct]&&this.emit("drain"),i}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i="utf8"),e!==void 0&&this.write(e,i),n&&this.once("end",n),this[Ct]=!0,this.writable=!1,(this[T]||!this[Ir])&&this[Ot](),this}[zn](){this[N]||(!this[bi]&&!this[ue].length&&(this[Re]=!0),this[Ir]=!1,this[T]=!0,this.emit("resume"),this[X].length?this[ys]():this[Ct]?this[Ot]():this.emit("drain"))}resume(){return this[zn]()}pause(){this[T]=!1,this[Ir]=!0,this[Re]=!1}get destroyed(){return this[N]}get flowing(){return this[T]}get paused(){return this[Ir]}[Zc](e){this[se]?this[H]+=1:this[H]+=e.length,this[X].push(e)}[qs](){return this[se]?this[H]-=1:this[H]-=this[X][0].length,this[X].shift()}[ys](e=!1){do;while(this[m3](this[qs]())&&this[X].length);!e&&!this[X].length&&!this[Ct]&&this.emit("drain")}[m3](e){return this.emit("data",e),this[T]}pipe(e,i){if(this[N])return e;this[Re]=!1;let n=this[_t];return i=i||{},e===l3.stdout||e===l3.stderr?i.end=!1:i.end=i.end!==!1,i.proxyErrors=!!i.proxyErrors,n?i.end&&e.end():(this[ue].push(i.proxyErrors?new Tc(this,e,i):new Ds(this,e,i)),this[pt]?Rr(()=>this[zn]()):this[zn]()),e}unpipe(e){let i=this[ue].find(n=>n.dest===e);i&&(this[ue].length===1?(this[T]&&this[bi]===0&&(this[T]=!1),this[ue]=[]):this[ue].splice(this[ue].indexOf(i),1),i.unpipe())}addListener(e,i){return this.on(e,i)}on(e,i){let n=super.on(e,i);if(e==="data")this[Re]=!1,this[bi]++,!this[ue].length&&!this[T]&&this[zn]();else if(e==="readable"&&this[H]!==0)super.emit("readable");else if(xf(e)&&this[_t])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[gr]){let r=i;this[pt]?Rr(()=>r.call(this,this[gr])):r.call(this,this[gr])}return n}removeListener(e,i){return this.off(e,i)}off(e,i){let n=super.off(e,i);return e==="data"&&(this[bi]=this.listeners("data").length,this[bi]===0&&!this[Re]&&!this[ue].length&&(this[T]=!1)),n}removeAllListeners(e){let i=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[bi]=0,!this[Re]&&!this[ue].length&&(this[T]=!1)),i}get emittedEnd(){return this[_t]}[Ot](){!this[Js]&&!this[_t]&&!this[N]&&this[X].length===0&&this[Ct]&&(this[Js]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Zs]&&this.emit("close"),this[Js]=!1)}emit(e,...i){let n=i[0];if(e!=="error"&&e!=="close"&&e!==N&&this[N])return!1;if(e==="data")return!this[se]&&!n?!1:this[pt]?(Rr(()=>this[qc](n)),!0):this[qc](n);if(e==="end")return this[v3]();if(e==="close"){if(this[Zs]=!0,!this[_t]&&!this[N])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[gr]=n,super.emit(yc,n);let s=!this[Er]||this.listeners("error").length?super.emit("error",n):!1;return this[Ot](),s}else if(e==="resume"){let s=super.emit("resume");return this[Ot](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let r=super.emit(e,...i);return this[Ot](),r}[qc](e){for(let n of this[ue])n.dest.write(e)===!1&&this.pause();let i=this[Re]?!1:super.emit("data",e);return this[Ot](),i}[v3](){return this[_t]?!1:(this[_t]=!0,this.readable=!1,this[pt]?(Rr(()=>this[wc]()),!0):this[wc]())}[wc](){if(this[Rn]){let i=this[Rn].end();if(i){for(let n of this[ue])n.dest.write(i);this[Re]||super.emit("data",i)}}for(let i of this[ue])i.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[se]||(e.dataLength=0);let i=this.promise();return this.on("data",n=>{e.push(n),this[se]||(e.dataLength+=n.length)}),await i,e}async concat(){if(this[se])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[He]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,i)=>{this.on(N,()=>i(new Error("stream destroyed"))),this.on("error",n=>i(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Re]=!1;let e=!1,i=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return i();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ct])return i();let s,o,c=p=>{this.off("data",l),this.off("end",u),this.off(N,m),i(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(N,m),this.pause(),s({value:p,done:!!this[Ct]})},u=()=>{this.off("error",c),this.off("data",l),this.off(N,m),i(),s({done:!0,value:void 0})},m=()=>c(new Error("stream destroyed"));return new Promise((p,d)=>{o=d,s=p,this.once(N,m),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:i,return:i,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Re]=!1;let e=!1,i=()=>(this.pause(),this.off(yc,i),this.off(N,i),this.off("end",i),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return i();let r=this.read();return r===null?i():{done:!1,value:r}};return this.once("end",i),this.once(yc,i),this.once(N,i),{next:n,throw:i,return:i,[Symbol.iterator](){return this}}}destroy(e){if(this[N])return e?this.emit("error",e):this.emit(N),this;this[N]=!0,this[Re]=!0,this[X].length=0,this[H]=0;let i=this;return typeof i.close=="function"&&!this[Zs]&&i.close(),e?this.emit("error",e):this.emit(N),this}static get isStream(){return Ef}};import*as A3 from"zlib";import Wf from"zlib";var Cf=Wf.constants||{ZLIB_VERNUM:4736},Ve=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Cf));var Of=Pi.concat,d3=Object.getOwnPropertyDescriptor(Pi,"concat"),Uf=t=>t,Hc=d3?.writable===!0||d3?.set!==void 0?t=>{Pi.concat=t?Uf:Of}:t=>{},Qi=Symbol("_superWrite"),jn=class extends Error{code;errno;constructor(e,i){super("zlib: "+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+e.message,Error.captureStackTrace(this,i??this.constructor)}get name(){return"ZlibError"}},Lc=Symbol("flushFlag"),jr=class extends zr{#e=!1;#n=!1;#i;#r;#a;#t;#s;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#i}constructor(e,i){if(!e||typeof e!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(e),this.#i=e.flush??0,this.#r=e.finishFlush??0,this.#a=e.fullFlushFlag??0,typeof A3[i]!="function")throw new TypeError("Compression method not supported: "+i);try{this.#t=new A3[i](e)}catch(n){throw new jn(n,this.constructor)}this.#s=n=>{this.#e||(this.#e=!0,this.close(),this.emit("error",n))},this.#t?.on("error",n=>this.#s(new jn(n))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return _c(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(e){this.ended||(typeof e!="number"&&(e=this.#a),this.write(Object.assign(Pi.alloc(0),{[Lc]:e})))}end(e,i,n){return typeof e=="function"&&(n=e,i=void 0,e=void 0),typeof i=="function"&&(n=i,i=void 0),e&&(i?this.write(e,i):this.write(e)),this.flush(this.#r),this.#n=!0,super.end(n)}get ended(){return this.#n}[Qi](e){return super.write(e)}write(e,i,n){if(typeof i=="function"&&(n=i,i="utf8"),typeof e=="string"&&(e=Pi.from(e,i)),this.#e)return;_c(this.#t,"zlib binding closed");let r=this.#t._handle,s=r.close;r.close=()=>{};let o=this.#t.close;this.#t.close=()=>{},Hc(!0);let c;try{let u=typeof e[Lc]=="number"?e[Lc]:this.#i;c=this.#t._processChunk(e,u),Hc(!1)}catch(u){Hc(!1),this.#s(new jn(u,this.write))}finally{this.#t&&(this.#t._handle=r,r.close=s,this.#t.close=o,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",u=>this.#s(new jn(u,this.write)));let l;if(c)if(Array.isArray(c)&&c.length>0){let u=c[0];l=this[Qi](Pi.from(u));for(let m=1;m<c.length;m++)l=this[Qi](c[m])}else l=this[Qi](Pi.from(c));return n&&n(),l}},Ts=class extends jr{#e;#n;constructor(e,i){e=e||{},e.flush=e.flush||Ve.Z_NO_FLUSH,e.finishFlush=e.finishFlush||Ve.Z_FINISH,e.fullFlushFlag=Ve.Z_FULL_FLUSH,super(e,i),this.#e=e.level,this.#n=e.strategy}params(e,i){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==e||this.#n!==i){this.flush(Ve.Z_SYNC_FLUSH),_c(this.handle,"zlib binding closed");let n=this.handle.flush;this.handle.flush=(r,s)=>{typeof r=="function"&&(s=r,r=this.flushFlag),this.flush(r),s?.()};try{this.handle.params(e,i)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#n=i)}}}};var Xs=class extends Ts{#e;constructor(e){super(e,"Gzip"),this.#e=e&&!!e.portable}[Qi](e){return this.#e?(this.#e=!1,e[9]=255,super[Qi](e)):super[Qi](e)}};var Hs=class extends Ts{constructor(e){super(e,"Unzip")}},Ls=class extends jr{constructor(e,i){e=e||{},e.flush=e.flush||Ve.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||Ve.BROTLI_OPERATION_FINISH,e.fullFlushFlag=Ve.BROTLI_OPERATION_FLUSH,super(e,i)}},_s=class extends Ls{constructor(e){super(e,"BrotliCompress")}},$s=class extends Ls{constructor(e){super(e,"BrotliDecompress")}},eo=class extends jr{constructor(e,i){e=e||{},e.flush=e.flush||Ve.ZSTD_e_continue,e.finishFlush=e.finishFlush||Ve.ZSTD_e_end,e.fullFlushFlag=Ve.ZSTD_e_flush,super(e,i)}},to=class extends eo{constructor(e){super(e,"ZstdCompress")}},io=class extends eo{constructor(e){super(e,"ZstdDecompress")}};import{posix as xn}from"node:path";var f3=(t,e)=>{if(Number.isSafeInteger(t))t<0?Vf(t,e):kf(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},kf=(t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=t&255,t=Math.floor(t/256)},Vf=(t,e)=>{e[0]=255;var i=!1;t=t*-1;for(var n=e.length;n>1;n--){var r=t&255;t=Math.floor(t/256),i?e[n-1]=g3(r):r===0?e[n-1]=0:(i=!0,e[n-1]=I3(r))}},h3=t=>{let e=t[0],i=e===128?Ff(t.subarray(1,t.length)):e===255?Nf(t):null;if(i===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i},Nf=t=>{for(var e=t.length,i=0,n=!1,r=e-1;r>-1;r--){var s=Number(t[r]),o;n?o=g3(s):s===0?o=s:(n=!0,o=I3(s)),o!==0&&(i-=o*Math.pow(256,e-r-1))}return i},Ff=t=>{for(var e=t.length,i=0,n=e-1;n>-1;n--){var r=Number(t[n]);r!==0&&(i+=r*Math.pow(256,e-n-1))}return i},g3=t=>(255^t)&255,I3=t=>(255^t)+1&255;var no=t=>ro.has(t);var ro=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),E3=new Map(Array.from(ro).map(t=>[t[1],t[0]]));var ze=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,i=0,n,r){Buffer.isBuffer(e)?this.decode(e,i||0,n,r):e&&this.#n(e)}decode(e,i,n,r){if(i||(i=0),!e||!(e.length>=i+512))throw new Error("need 512 bytes for header");this.path=n?.path??Bi(e,i,100),this.mode=n?.mode??r?.mode??$t(e,i+100,8),this.uid=n?.uid??r?.uid??$t(e,i+108,8),this.gid=n?.gid??r?.gid??$t(e,i+116,8),this.size=n?.size??r?.size??$t(e,i+124,12),this.mtime=n?.mtime??r?.mtime??$c(e,i+136,12),this.cksum=$t(e,i+148,12),r&&this.#n(r,!0),n&&this.#n(n);let s=Bi(e,i+156,1);if(no(s)&&(this.#e=s||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Bi(e,i+157,100),e.subarray(i+257,i+265).toString()==="ustar\x0000")if(this.uname=n?.uname??r?.uname??Bi(e,i+265,32),this.gname=n?.gname??r?.gname??Bi(e,i+297,32),this.devmaj=n?.devmaj??r?.devmaj??$t(e,i+329,8)??0,this.devmin=n?.devmin??r?.devmin??$t(e,i+337,8)??0,e[i+475]!==0){let c=Bi(e,i+345,155);this.path=c+"/"+this.path}else{let c=Bi(e,i+345,130);c&&(this.path=c+"/"+this.path),this.atime=n?.atime??r?.atime??$c(e,i+476,12),this.ctime=n?.ctime??r?.ctime??$c(e,i+488,12)}let o=256;for(let c=i;c<i+148;c++)o+=e[c];for(let c=i+156;c<i+512;c++)o+=e[c];this.cksumValid=o===this.cksum,this.cksum===void 0&&o===256&&(this.nullBlock=!0)}#n(e,i=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,r])=>!(r==null||n==="path"&&i||n==="linkpath"&&i||n==="global"))))}encode(e,i=0){if(e||(e=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=i+512))throw new Error("need 512 bytes for header");let n=this.ctime||this.atime?130:155,r=Pf(this.path||"",n),s=r[0],o=r[1];this.needPax=!!r[2],this.needPax=Ji(e,i,100,s)||this.needPax,this.needPax=ei(e,i+100,8,this.mode)||this.needPax,this.needPax=ei(e,i+108,8,this.uid)||this.needPax,this.needPax=ei(e,i+116,8,this.gid)||this.needPax,this.needPax=ei(e,i+124,12,this.size)||this.needPax,this.needPax=el(e,i+136,12,this.mtime)||this.needPax,e[i+156]=this.#e.charCodeAt(0),this.needPax=Ji(e,i+157,100,this.linkpath)||this.needPax,e.write("ustar\x0000",i+257,8),this.needPax=Ji(e,i+265,32,this.uname)||this.needPax,this.needPax=Ji(e,i+297,32,this.gname)||this.needPax,this.needPax=ei(e,i+329,8,this.devmaj)||this.needPax,this.needPax=ei(e,i+337,8,this.devmin)||this.needPax,this.needPax=Ji(e,i+345,n,o)||this.needPax,e[i+475]!==0?this.needPax=Ji(e,i+345,155,o)||this.needPax:(this.needPax=Ji(e,i+345,130,o)||this.needPax,this.needPax=el(e,i+476,12,this.atime)||this.needPax,this.needPax=el(e,i+488,12,this.ctime)||this.needPax);let c=256;for(let l=i;l<i+148;l++)c+=e[l];for(let l=i+156;l<i+512;l++)c+=e[l];return this.cksum=c,ei(e,i+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:ro.get(this.#e)}get typeKey(){return this.#e}set type(e){let i=String(E3.get(e));if(no(i)||i==="Unsupported")this.#e=i;else if(no(e))this.#e=e;else throw new TypeError("invalid entry type: "+e)}},Pf=(t,e)=>{let n=t,r="",s,o=xn.parse(t).root||".";if(Buffer.byteLength(n)<100)s=[n,r,!1];else{r=xn.dirname(n),n=xn.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(r)<=e?s=[n,r,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(r)<=e?s=[n.slice(0,99),r,!0]:(n=xn.join(xn.basename(r),n),r=xn.dirname(r));while(r!==o&&s===void 0);s||(s=[t.slice(0,99),"",!0])}return s},Bi=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),$c=(t,e,i)=>Qf($t(t,e,i)),Qf=t=>t===void 0?void 0:new Date(t*1e3),$t=(t,e,i)=>Number(t[e])&128?h3(t.subarray(e,e+i)):Jf(t,e,i),Bf=t=>isNaN(t)?void 0:t,Jf=(t,e,i)=>Bf(parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),Zf={12:8589934591,8:2097151},ei=(t,e,i,n)=>n===void 0?!1:n>Zf[i]||n<0?(f3(n,t.subarray(e,e+i)),!0):(yf(t,e,i,n),!1),yf=(t,e,i,n)=>t.write(qf(n,i),e,i,"ascii"),qf=(t,e)=>wf(Math.floor(t).toString(8),e),wf=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",el=(t,e,i,n)=>n===void 0?!1:ei(t,e,i,n.getTime()/1e3),Df=new Array(156).join("\0"),Ji=(t,e,i,n)=>n===void 0?!1:(t.write(n+Df,e,i,"utf8"),n.length!==Buffer.byteLength(n)||n.length>i);import{basename as Tf}from"node:path";var ti=class t{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,i=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=i,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(e),n=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(n);for(let s=0;s<512;s++)r[s]=0;new ze({path:("PaxHeader/"+Tf(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:i,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(r),r.write(e,512,i,"utf8");for(let s=i+512;s<r.length;s++)r[s]=0;return r}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let i=this[e],n=i instanceof Date?i.getTime()/1e3:i,r=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+n+`
|
|
47
|
+
`,s=Buffer.byteLength(r),o=Math.floor(Math.log(s)/Math.log(10))+1;return s+o>=Math.pow(10,o)&&(o+=1),o+s+r}static parse(e,i,n=!1){return new t(Xf(Hf(e),i),n)}},Xf=(t,e)=>e?Object.assign({},e,t):t,Hf=t=>t.replace(/\n$/,"").split(`
|
|
48
|
+
`).reduce(Lf,Object.create(null)),Lf=(t,e)=>{let i=parseInt(e,10);if(i!==Buffer.byteLength(e)+1)return t;e=e.slice((i+" ").length);let n=e.split("="),r=n.shift();if(!r)return t;let s=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),o=n.join("=");return t[s]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(s)?new Date(Number(o)*1e3):/^[0-9]+$/.test(o)?+o:o,t};import{EventEmitter as al}from"node:events";import G3 from"node:stream";import{StringDecoder as _f}from"node:string_decoder";var z3=typeof process=="object"&&process?process:{stdout:null,stderr:null},$f=t=>!!t&&typeof t=="object"&&(t instanceof dt||t instanceof G3||e7(t)||t7(t)),e7=t=>!!t&&typeof t=="object"&&t instanceof al&&typeof t.pipe=="function"&&t.pipe!==G3.Writable.prototype.pipe,t7=t=>!!t&&typeof t=="object"&&t instanceof al&&typeof t.write=="function"&&typeof t.end=="function",Ut=Symbol("EOF"),Kt=Symbol("maybeEmitEnd"),ii=Symbol("emittedEnd"),so=Symbol("emittingEnd"),xr=Symbol("emittedError"),oo=Symbol("closed"),j3=Symbol("read"),ao=Symbol("flush"),x3=Symbol("flushChunk"),Le=Symbol("encoding"),Sn=Symbol("decoder"),L=Symbol("flowing"),Sr=Symbol("paused"),Gn=Symbol("resume"),_=Symbol("buffer"),me=Symbol("pipes"),$=Symbol("bufferLength"),tl=Symbol("bufferPush"),co=Symbol("bufferShift"),oe=Symbol("objectMode"),F=Symbol("destroyed"),il=Symbol("error"),nl=Symbol("emitData"),S3=Symbol("emitEnd"),rl=Symbol("emitEnd2"),At=Symbol("async"),sl=Symbol("abort"),lo=Symbol("aborted"),Gr=Symbol("signal"),Zi=Symbol("dataListeners"),je=Symbol("discarded"),Mr=t=>Promise.resolve().then(t),i7=t=>t(),n7=t=>t==="end"||t==="finish"||t==="prefinish",r7=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,s7=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),uo=class{src;dest;opts;ondrain;constructor(e,i,n){this.src=e,this.dest=i,this.opts=n,this.ondrain=()=>e[Gn](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ol=class extends uo{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,i,n){super(e,i,n),this.proxyErrors=r=>i.emit("error",r),e.on("error",this.proxyErrors)}},o7=t=>!!t.objectMode,a7=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",dt=class extends al{[L]=!1;[Sr]=!1;[me]=[];[_]=[];[oe];[Le];[At];[Sn];[Ut]=!1;[ii]=!1;[so]=!1;[oo]=!1;[xr]=null;[$]=0;[F]=!1;[Gr];[lo]=!1;[Zi]=0;[je]=!1;writable=!0;readable=!0;constructor(...e){let i=e[0]||{};if(super(),i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");o7(i)?(this[oe]=!0,this[Le]=null):a7(i)?(this[Le]=i.encoding,this[oe]=!1):(this[oe]=!1,this[Le]=null),this[At]=!!i.async,this[Sn]=this[Le]?new _f(this[Le]):null,i&&i.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[_]}),i&&i.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[me]});let{signal:n}=i;n&&(this[Gr]=n,n.aborted?this[sl]():n.addEventListener("abort",()=>this[sl]()))}get bufferLength(){return this[$]}get encoding(){return this[Le]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[oe]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[At]}set async(e){this[At]=this[At]||!!e}[sl](){this[lo]=!0,this.emit("abort",this[Gr]?.reason),this.destroy(this[Gr]?.reason)}get aborted(){return this[lo]}set aborted(e){}write(e,i,n){if(this[lo])return!1;if(this[Ut])throw new Error("write after end");if(this[F])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof i=="function"&&(n=i,i="utf8"),i||(i="utf8");let r=this[At]?Mr:i7;if(!this[oe]&&!Buffer.isBuffer(e)){if(s7(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(r7(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[oe]?(this[L]&&this[$]!==0&&this[ao](!0),this[L]?this.emit("data",e):this[tl](e),this[$]!==0&&this.emit("readable"),n&&r(n),this[L]):e.length?(typeof e=="string"&&!(i===this[Le]&&!this[Sn]?.lastNeed)&&(e=Buffer.from(e,i)),Buffer.isBuffer(e)&&this[Le]&&(e=this[Sn].write(e)),this[L]&&this[$]!==0&&this[ao](!0),this[L]?this.emit("data",e):this[tl](e),this[$]!==0&&this.emit("readable"),n&&r(n),this[L]):(this[$]!==0&&this.emit("readable"),n&&r(n),this[L])}read(e){if(this[F])return null;if(this[je]=!1,this[$]===0||e===0||e&&e>this[$])return this[Kt](),null;this[oe]&&(e=null),this[_].length>1&&!this[oe]&&(this[_]=[this[Le]?this[_].join(""):Buffer.concat(this[_],this[$])]);let i=this[j3](e||null,this[_][0]);return this[Kt](),i}[j3](e,i){if(this[oe])this[co]();else{let n=i;e===n.length||e===null?this[co]():typeof n=="string"?(this[_][0]=n.slice(e),i=n.slice(0,e),this[$]-=e):(this[_][0]=n.subarray(e),i=n.subarray(0,e),this[$]-=e)}return this.emit("data",i),!this[_].length&&!this[Ut]&&this.emit("drain"),i}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i="utf8"),e!==void 0&&this.write(e,i),n&&this.once("end",n),this[Ut]=!0,this.writable=!1,(this[L]||!this[Sr])&&this[Kt](),this}[Gn](){this[F]||(!this[Zi]&&!this[me].length&&(this[je]=!0),this[Sr]=!1,this[L]=!0,this.emit("resume"),this[_].length?this[ao]():this[Ut]?this[Kt]():this.emit("drain"))}resume(){return this[Gn]()}pause(){this[L]=!1,this[Sr]=!0,this[je]=!1}get destroyed(){return this[F]}get flowing(){return this[L]}get paused(){return this[Sr]}[tl](e){this[oe]?this[$]+=1:this[$]+=e.length,this[_].push(e)}[co](){return this[oe]?this[$]-=1:this[$]-=this[_][0].length,this[_].shift()}[ao](e=!1){do;while(this[x3](this[co]())&&this[_].length);!e&&!this[_].length&&!this[Ut]&&this.emit("drain")}[x3](e){return this.emit("data",e),this[L]}pipe(e,i){if(this[F])return e;this[je]=!1;let n=this[ii];return i=i||{},e===z3.stdout||e===z3.stderr?i.end=!1:i.end=i.end!==!1,i.proxyErrors=!!i.proxyErrors,n?i.end&&e.end():(this[me].push(i.proxyErrors?new ol(this,e,i):new uo(this,e,i)),this[At]?Mr(()=>this[Gn]()):this[Gn]()),e}unpipe(e){let i=this[me].find(n=>n.dest===e);i&&(this[me].length===1?(this[L]&&this[Zi]===0&&(this[L]=!1),this[me]=[]):this[me].splice(this[me].indexOf(i),1),i.unpipe())}addListener(e,i){return this.on(e,i)}on(e,i){let n=super.on(e,i);if(e==="data")this[je]=!1,this[Zi]++,!this[me].length&&!this[L]&&this[Gn]();else if(e==="readable"&&this[$]!==0)super.emit("readable");else if(n7(e)&&this[ii])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[xr]){let r=i;this[At]?Mr(()=>r.call(this,this[xr])):r.call(this,this[xr])}return n}removeListener(e,i){return this.off(e,i)}off(e,i){let n=super.off(e,i);return e==="data"&&(this[Zi]=this.listeners("data").length,this[Zi]===0&&!this[je]&&!this[me].length&&(this[L]=!1)),n}removeAllListeners(e){let i=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Zi]=0,!this[je]&&!this[me].length&&(this[L]=!1)),i}get emittedEnd(){return this[ii]}[Kt](){!this[so]&&!this[ii]&&!this[F]&&this[_].length===0&&this[Ut]&&(this[so]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[oo]&&this.emit("close"),this[so]=!1)}emit(e,...i){let n=i[0];if(e!=="error"&&e!=="close"&&e!==F&&this[F])return!1;if(e==="data")return!this[oe]&&!n?!1:this[At]?(Mr(()=>this[nl](n)),!0):this[nl](n);if(e==="end")return this[S3]();if(e==="close"){if(this[oo]=!0,!this[ii]&&!this[F])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[xr]=n,super.emit(il,n);let s=!this[Gr]||this.listeners("error").length?super.emit("error",n):!1;return this[Kt](),s}else if(e==="resume"){let s=super.emit("resume");return this[Kt](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let r=super.emit(e,...i);return this[Kt](),r}[nl](e){for(let n of this[me])n.dest.write(e)===!1&&this.pause();let i=this[je]?!1:super.emit("data",e);return this[Kt](),i}[S3](){return this[ii]?!1:(this[ii]=!0,this.readable=!1,this[At]?(Mr(()=>this[rl]()),!0):this[rl]())}[rl](){if(this[Sn]){let i=this[Sn].end();if(i){for(let n of this[me])n.dest.write(i);this[je]||super.emit("data",i)}}for(let i of this[me])i.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[oe]||(e.dataLength=0);let i=this.promise();return this.on("data",n=>{e.push(n),this[oe]||(e.dataLength+=n.length)}),await i,e}async concat(){if(this[oe])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Le]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,i)=>{this.on(F,()=>i(new Error("stream destroyed"))),this.on("error",n=>i(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[je]=!1;let e=!1,i=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return i();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ut])return i();let s,o,c=p=>{this.off("data",l),this.off("end",u),this.off(F,m),i(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(F,m),this.pause(),s({value:p,done:!!this[Ut]})},u=()=>{this.off("error",c),this.off("data",l),this.off(F,m),i(),s({done:!0,value:void 0})},m=()=>c(new Error("stream destroyed"));return new Promise((p,d)=>{o=d,s=p,this.once(F,m),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:i,return:i,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[je]=!1;let e=!1,i=()=>(this.pause(),this.off(il,i),this.off(F,i),this.off("end",i),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return i();let r=this.read();return r===null?i():{done:!1,value:r}};return this.once("end",i),this.once(il,i),this.once(F,i),{next:n,throw:i,return:i,[Symbol.iterator](){return this}}}destroy(e){if(this[F])return e?this.emit("error",e):this.emit(F),this;this[F]=!0,this[je]=!0,this[_].length=0,this[$]=0;let i=this;return typeof i.close=="function"&&!this[oo]&&i.close(),e?this.emit("error",e):this.emit(F),this}static get isStream(){return $f}};var c7=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,R=c7!=="win32"?t=>t:t=>t&&t.replace(/\\/g,"/");var Mn=class extends dt{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,i,n){switch(super({}),this.pause(),this.extended=i,this.globalExtended=n,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw new Error("no path provided for tar.ReadEntry");this.path=R(e.path),this.mode=e.mode,this.mode&&(this.mode=this.mode&4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?R(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,i&&this.#e(i),n&&this.#e(n,!0)}write(e){let i=e.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");let n=this.remain,r=this.blockRemain;return this.remain=Math.max(0,n-i),this.blockRemain=Math.max(0,r-i),this.ignore?!0:n>=i?super.write(e):super.write(e.subarray(0,n))}#e(e,i=!1){e.path&&(e.path=R(e.path)),e.linkpath&&(e.linkpath=R(e.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,r])=>!(r==null||n==="path"&&i))))}};var yi=(t,e,i,n={})=>{t.file&&(n.file=t.file),t.cwd&&(n.cwd=t.cwd),n.code=i instanceof Error&&i.code||e,n.tarCode=e,!t.strict&&n.recoverable!==!1?(i instanceof Error&&(n=Object.assign(i,n),i=i.message),t.emit("warn",e,i,n)):i instanceof Error?t.emit("error",Object.assign(i,n)):t.emit("error",Object.assign(new Error(`${e}: ${i}`),n))};var u7=1024*1024,vl=Buffer.from([31,139]),pl=Buffer.from([40,181,47,253]),m7=Math.max(vl.length,pl.length),Ne=Symbol("state"),qi=Symbol("writeEntry"),kt=Symbol("readEntry"),cl=Symbol("nextEntry"),M3=Symbol("processEntry"),ft=Symbol("extendedHeader"),Yr=Symbol("globalExtendedHeader"),ni=Symbol("meta"),Y3=Symbol("emitMeta"),S=Symbol("buffer"),Vt=Symbol("queue"),ri=Symbol("ended"),ll=Symbol("emittedEnd"),wi=Symbol("emit"),b=Symbol("unzip"),mo=Symbol("consumeChunk"),vo=Symbol("consumeChunkSub"),ul=Symbol("consumeBody"),W3=Symbol("consumeMeta"),C3=Symbol("consumeHeader"),Wr=Symbol("consuming"),ml=Symbol("bufferConcat"),po=Symbol("maybeEnd"),Yn=Symbol("writing"),si=Symbol("aborted"),Ao=Symbol("onDone"),Di=Symbol("sawValidEntry"),fo=Symbol("sawNullBlock"),ho=Symbol("sawEOF"),O3=Symbol("closeStream"),v7=()=>!0,Nt=class extends l7{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Vt]=[];[S];[kt];[qi];[Ne]="begin";[ni]="";[ft];[Yr];[ri]=!1;[b];[si]=!1;[Di];[fo]=!1;[ho]=!1;[Yn]=!1;[Wr]=!1;[ll]=!1;constructor(e={}){super(),this.file=e.file||"",this.on(Ao,()=>{(this[Ne]==="begin"||this[Di]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),e.ondone?this.on(Ao,e.ondone):this.on(Ao,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||u7,this.filter=typeof e.filter=="function"?e.filter:v7;let i=e.file&&(e.file.endsWith(".tar.br")||e.file.endsWith(".tbr"));this.brotli=!(e.gzip||e.zstd)&&e.brotli!==void 0?e.brotli:i?void 0:!1;let n=e.file&&(e.file.endsWith(".tar.zst")||e.file.endsWith(".tzst"));this.zstd=!(e.gzip||e.brotli)&&e.zstd!==void 0?e.zstd:n?!0:void 0,this.on("end",()=>this[O3]()),typeof e.onwarn=="function"&&this.on("warn",e.onwarn),typeof e.onReadEntry=="function"&&this.on("entry",e.onReadEntry)}warn(e,i,n={}){yi(this,e,i,n)}[C3](e,i){this[Di]===void 0&&(this[Di]=!1);let n;try{n=new ze(e,i,this[ft],this[Yr])}catch(r){return this.warn("TAR_ENTRY_INVALID",r)}if(n.nullBlock)this[fo]?(this[ho]=!0,this[Ne]==="begin"&&(this[Ne]="header"),this[wi]("eof")):(this[fo]=!0,this[wi]("nullBlock"));else if(this[fo]=!1,!n.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:n});else if(!n.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:n});else{let r=n.type;if(/^(Symbolic)?Link$/.test(r)&&!n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:n});else if(!/^(Symbolic)?Link$/.test(r)&&!/^(Global)?ExtendedHeader$/.test(r)&&n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:n});else{let s=this[qi]=new Mn(n,this[ft],this[Yr]);if(!this[Di])if(s.remain){let o=()=>{s.invalid||(this[Di]=!0)};s.on("end",o)}else this[Di]=!0;s.meta?s.size>this.maxMetaEntrySize?(s.ignore=!0,this[wi]("ignoredEntry",s),this[Ne]="ignore",s.resume()):s.size>0&&(this[ni]="",s.on("data",o=>this[ni]+=o),this[Ne]="meta"):(this[ft]=void 0,s.ignore=s.ignore||!this.filter(s.path,s),s.ignore?(this[wi]("ignoredEntry",s),this[Ne]=s.remain?"ignore":"header",s.resume()):(s.remain?this[Ne]="body":(this[Ne]="header",s.end()),this[kt]?this[Vt].push(s):(this[Vt].push(s),this[cl]())))}}}[O3](){queueMicrotask(()=>this.emit("close"))}[M3](e){let i=!0;if(!e)this[kt]=void 0,i=!1;else if(Array.isArray(e)){let[n,...r]=e;this.emit(n,...r)}else this[kt]=e,this.emit("entry",e),e.emittedEnd||(e.on("end",()=>this[cl]()),i=!1);return i}[cl](){do;while(this[M3](this[Vt].shift()));if(!this[Vt].length){let e=this[kt];!e||e.flowing||e.size===e.remain?this[Yn]||this.emit("drain"):e.once("drain",()=>this.emit("drain"))}}[ul](e,i){let n=this[qi];if(!n)throw new Error("attempt to consume body without entry??");let r=n.blockRemain??0,s=r>=e.length&&i===0?e:e.subarray(i,i+r);return n.write(s),n.blockRemain||(this[Ne]="header",this[qi]=void 0,n.end()),s.length}[W3](e,i){let n=this[qi],r=this[ul](e,i);return!this[qi]&&n&&this[Y3](n),r}[wi](e,i,n){!this[Vt].length&&!this[kt]?this.emit(e,i,n):this[Vt].push([e,i,n])}[Y3](e){switch(this[wi]("meta",this[ni]),e.type){case"ExtendedHeader":case"OldExtendedHeader":this[ft]=ti.parse(this[ni],this[ft],!1);break;case"GlobalExtendedHeader":this[Yr]=ti.parse(this[ni],this[Yr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let i=this[ft]??Object.create(null);this[ft]=i,i.path=this[ni].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let i=this[ft]||Object.create(null);this[ft]=i,i.linkpath=this[ni].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+e.type)}}abort(e){this[si]=!0,this.emit("abort",e),this.warn("TAR_ABORT",e,{recoverable:!1})}write(e,i,n){if(typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof i=="string"?i:"utf8")),this[si])return n?.(),!1;if((this[b]===void 0||this.brotli===void 0&&this[b]===!1)&&e){if(this[S]&&(e=Buffer.concat([this[S],e]),this[S]=void 0),e.length<m7)return this[S]=e,n?.(),!0;for(let l=0;this[b]===void 0&&l<vl.length;l++)e[l]!==vl[l]&&(this[b]=!1);let o=!1;if(this[b]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<pl.length;l++)if(e[l]!==pl[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[b]===!1&&c)if(e.length<512)if(this[ri])this.brotli=!0;else return this[S]=e,n?.(),!0;else try{new ze(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[b]===void 0||this[b]===!1&&(this.brotli||o)){let l=this[ri];this[ri]=!1,this[b]=this[b]===void 0?new Hs({}):o?new io({}):new $s({}),this[b].on("data",m=>this[mo](m)),this[b].on("error",m=>this.abort(m)),this[b].on("end",()=>{this[ri]=!0,this[mo]()}),this[Yn]=!0;let u=!!this[b][l?"end":"write"](e);return this[Yn]=!1,n?.(),u}}this[Yn]=!0,this[b]?this[b].write(e):this[mo](e),this[Yn]=!1;let s=this[Vt].length?!1:this[kt]?this[kt].flowing:!0;return!s&&!this[Vt].length&&this[kt]?.once("drain",()=>this.emit("drain")),n?.(),s}[ml](e){e&&!this[si]&&(this[S]=this[S]?Buffer.concat([this[S],e]):e)}[po](){if(this[ri]&&!this[ll]&&!this[si]&&!this[Wr]){this[ll]=!0;let e=this[qi];if(e&&e.blockRemain){let i=this[S]?this[S].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${e.blockRemain} more bytes, only ${i} available)`,{entry:e}),this[S]&&e.write(this[S]),e.end()}this[wi](Ao)}}[mo](e){if(this[Wr]&&e)this[ml](e);else if(!e&&!this[S])this[po]();else if(e){if(this[Wr]=!0,this[S]){this[ml](e);let i=this[S];this[S]=void 0,this[vo](i)}else this[vo](e);for(;this[S]&&this[S]?.length>=512&&!this[si]&&!this[ho];){let i=this[S];this[S]=void 0,this[vo](i)}this[Wr]=!1}(!this[S]||this[ri])&&this[po]()}[vo](e){let i=0,n=e.length;for(;i+512<=n&&!this[si]&&!this[ho];)switch(this[Ne]){case"begin":case"header":this[C3](e,i),i+=512;break;case"ignore":case"body":i+=this[ul](e,i);break;case"meta":i+=this[W3](e,i);break;default:throw new Error("invalid state: "+this[Ne])}i<n&&(this[S]?this[S]=Buffer.concat([e.subarray(i),this[S]]):this[S]=e.subarray(i))}end(e,i,n){return typeof e=="function"&&(n=e,i=void 0,e=void 0),typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,i)),n&&this.once("finish",n),this[si]||(this[b]?(e&&this[b].write(e),this[b].end()):(this[ri]=!0,(this.brotli===void 0||this.zstd===void 0)&&(e=e||Buffer.alloc(0)),e&&this.write(e),this[po]())),this}};var oi=t=>{let e=t.length-1,i=-1;for(;e>-1&&t.charAt(e)==="/";)i=e,e--;return i===-1?t:t.slice(0,i)};var d7=t=>{let e=t.onReadEntry;t.onReadEntry=e?i=>{e(i),i.resume()}:i=>i.resume()},Al=(t,e)=>{let i=new Map(e.map(s=>[oi(s),!0])),n=t.filter,r=(s,o="")=>{let c=o||A7(s).root||".",l;if(s===c)l=!1;else{let u=i.get(s);u!==void 0?l=u:l=r(p7(s),c)}return i.set(s,l),l};t.filter=n?(s,o)=>n(s,o)&&r(oi(s)):s=>r(oi(s))},f7=t=>{let e=new Nt(t),i=t.file,n;try{n=Wn.openSync(i,"r");let r=Wn.fstatSync(n),s=t.maxReadSize||16*1024*1024;if(r.size<s){let o=Buffer.allocUnsafe(r.size),c=Wn.readSync(n,o,0,r.size,0);e.end(c===o.byteLength?o:o.subarray(0,c))}else{let o=0,c=Buffer.allocUnsafe(s);for(;o<r.size;){let l=Wn.readSync(n,c,0,s,o);if(l===0)break;o+=l,e.write(c.subarray(0,l))}e.end()}}finally{if(typeof n=="number")try{Wn.closeSync(n)}catch{}}},h7=(t,e)=>{let i=new Nt(t),n=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((o,c)=>{i.on("error",c),i.on("end",o),Wn.stat(r,(l,u)=>{if(l)c(l);else{let m=new Fi(r,{readSize:n,size:u.size});m.on("error",c),m.pipe(i)}})})},Ti=vt(f7,h7,t=>new Nt(t),t=>new Nt(t),(t,e)=>{e?.length&&Al(t,e),t.noResume||d7(t)});import Co from"fs";import ht from"fs";import V3 from"path";var dl=(t,e,i)=>(t&=4095,i&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t);import{win32 as g7}from"node:path";var{isAbsolute:I7,parse:U3}=g7,Cr=t=>{let e="",i=U3(t);for(;I7(t)||i.root;){let n=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":i.root;t=t.slice(n.length),e+=n,i=U3(t)}return[e,t]};var go=["|","<",">","?",":"],fl=go.map(t=>String.fromCharCode(61440+t.charCodeAt(0))),E7=new Map(go.map((t,e)=>[t,fl[e]])),R7=new Map(fl.map((t,e)=>[t,go[e]])),hl=t=>go.reduce((e,i)=>e.split(i).join(E7.get(i)),t),K3=t=>fl.reduce((e,i)=>e.split(i).join(R7.get(i)),t);var Q3=(t,e)=>e?(t=R(t).replace(/^\.(\/|$)/,""),oi(e)+"/"+t):R(t),z7=16*1024*1024,N3=Symbol("process"),F3=Symbol("file"),b3=Symbol("directory"),Il=Symbol("symlink"),P3=Symbol("hardlink"),Or=Symbol("header"),Io=Symbol("read"),El=Symbol("lstat"),Eo=Symbol("onlstat"),Rl=Symbol("onread"),zl=Symbol("onreadlink"),jl=Symbol("openfile"),xl=Symbol("onopenfile"),ai=Symbol("close"),Ro=Symbol("mode"),Sl=Symbol("awaitDrain"),gl=Symbol("ondrain"),gt=Symbol("prefix"),Ur=class extends dt{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(e,i={}){let n=hr(i);super(),this.path=R(e),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||z7,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=R(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?R(n.prefix):void 0,this.onWriteEntry=n.onWriteEntry,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let r=!1;if(!this.preservePaths){let[o,c]=Cr(this.path);o&&typeof c=="string"&&(this.path=c,r=o)}this.win32=!!n.win32||process.platform==="win32",this.win32&&(this.path=K3(this.path.replace(/\\/g,"/")),e=e.replace(/\\/g,"/")),this.absolute=R(n.absolute||V3.resolve(this.cwd,e)),this.path===""&&(this.path="./"),r&&this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:this,path:r+this.path});let s=this.statCache.get(this.absolute);s?this[Eo](s):this[El]()}warn(e,i,n={}){return yi(this,e,i,n)}emit(e,...i){return e==="error"&&(this.#e=!0),super.emit(e,...i)}[El](){ht.lstat(this.absolute,(e,i)=>{if(e)return this.emit("error",e);this[Eo](i)})}[Eo](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=j7(e),this.emit("stat",e),this[N3]()}[N3](){switch(this.type){case"File":return this[F3]();case"Directory":return this[b3]();case"SymbolicLink":return this[Il]();default:return this.end()}}[Ro](e){return dl(e,this.type==="Directory",this.portable)}[gt](e){return Q3(e,this.prefix)}[Or](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new ze({path:this[gt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[gt](this.linkpath):this.linkpath,mode:this[Ro](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new ti({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[gt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[gt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw new Error("failed to encode header");super.write(e)}[b3](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Or](),this.end()}[Il](){ht.readlink(this.absolute,(e,i)=>{if(e)return this.emit("error",e);this[zl](i)})}[zl](e){this.linkpath=R(e),this[Or](),this.end()}[P3](e){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=R(V3.relative(this.cwd,e)),this.stat.size=0,this[Or](),this.end()}[F3](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,i=this.linkCache.get(e);if(i?.indexOf(this.cwd)===0)return this[P3](i);this.linkCache.set(e,this.absolute)}if(this[Or](),this.stat.size===0)return this.end();this[jl]()}[jl](){ht.open(this.absolute,"r",(e,i)=>{if(e)return this.emit("error",e);this[xl](i)})}[xl](e){if(this.fd=e,this.#e)return this[ai]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let i=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(i),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Io]()}[Io](){let{fd:e,buf:i,offset:n,length:r,pos:s}=this;if(e===void 0||i===void 0)throw new Error("cannot read file without first opening");ht.read(e,i,n,r,s,(o,c)=>{if(o)return this[ai](()=>this.emit("error",o));this[Rl](c)})}[ai](e=()=>{}){this.fd!==void 0&&ht.close(this.fd,e)}[Rl](e){if(e<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[ai](()=>this.emit("error",r))}if(e>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[ai](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(e===this.remain)for(let r=e;r<this.length&&e<this.blockRemain;r++)this.buf[r+this.offset]=0,e++,this.remain++;let i=this.offset===0&&e===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+e);this.write(i)?this[gl]():this[Sl](()=>this[gl]())}[Sl](e){this.once("drain",e)}write(e,i,n){if(typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof i=="string"?i:"utf8")),this.blockRemain<e.length){let r=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",r)}return this.remain-=e.length,this.blockRemain-=e.length,this.pos+=e.length,this.offset+=e.length,super.write(e,null,n)}[gl](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[ai](e=>e?this.emit("error",e):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Io]()}},zo=class extends Ur{sync=!0;[El](){this[Eo](ht.lstatSync(this.absolute))}[Il](){this[zl](ht.readlinkSync(this.absolute))}[jl](){this[xl](ht.openSync(this.absolute,"r"))}[Io](){let e=!0;try{let{fd:i,buf:n,offset:r,length:s,pos:o}=this;if(i===void 0||n===void 0)throw new Error("fd and buf must be set in READ method");let c=ht.readSync(i,n,r,s,o);this[Rl](c),e=!1}finally{if(e)try{this[ai](()=>{})}catch{}}}[Sl](e){e()}[ai](e=()=>{}){this.fd!==void 0&&ht.closeSync(this.fd),e()}},jo=class extends dt{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(e,i,n={}){return yi(this,e,i,n)}constructor(e,i={}){let n=hr(i);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.onWriteEntry=n.onWriteEntry,this.readEntry=e;let{type:r}=e;if(r==="Unsupported")throw new Error("writing entry that should be ignored");this.type=r,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=R(e.path),this.mode=e.mode!==void 0?this[Ro](e.mode):void 0,this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:n.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath!==void 0?R(e.linkpath):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let s=!1;if(!this.preservePaths){let[c,l]=Cr(this.path);c&&typeof l=="string"&&(this.path=l,s=c)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.onWriteEntry?.(this),this.header=new ze({path:this[gt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[gt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path}),this.header.encode()&&!this.noPax&&super.write(new ti({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[gt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[gt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let o=this.header?.block;if(!o)throw new Error("failed to encode header");super.write(o),e.pipe(this)}[gt](e){return Q3(e,this.prefix)}[Ro](e){return dl(e,this.type==="Directory",this.portable)}write(e,i,n){typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof i=="string"?i:"utf8"));let r=e.length;if(r>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=r,super.write(e,n)}end(e,i,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e=="function"&&(n=e,i=void 0,e=void 0),typeof i=="function"&&(n=i,i=void 0),typeof e=="string"&&(e=Buffer.from(e,i??"utf8")),n&&this.once("finish",n),e?super.end(e,n):super.end(n),this}},j7=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var xo=class t{tail;head;length=0;static create(e=[]){return new t(e)}constructor(e=[]){for(let i of e)this.push(i)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let i=e.next,n=e.prev;return i&&(i.prev=n),n&&(n.next=i),e===this.head&&(this.head=i),e===this.tail&&(this.tail=n),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,i}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let i=this.head;e.list=this,e.next=i,i&&(i.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let i=this.tail;e.list=this,e.prev=i,i&&(i.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let i=0,n=e.length;i<n;i++)S7(this,e[i]);return this.length}unshift(...e){for(var i=0,n=e.length;i<n;i++)G7(this,e[i]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,i=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,i.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,i=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,i.list=void 0,this.length--,e}forEach(e,i){i=i||this;for(let n=this.head,r=0;n;r++)e.call(i,n.value,r,this),n=n.next}forEachReverse(e,i){i=i||this;for(let n=this.tail,r=this.length-1;n;r--)e.call(i,n.value,r,this),n=n.prev}get(e){let i=0,n=this.head;for(;n&&i<e;i++)n=n.next;if(i===e&&n)return n.value}getReverse(e){let i=0,n=this.tail;for(;n&&i<e;i++)n=n.prev;if(i===e&&n)return n.value}map(e,i){i=i||this;let n=new t;for(let r=this.head;r;)n.push(e.call(i,r.value,this)),r=r.next;return n}mapReverse(e,i){i=i||this;var n=new t;for(let r=this.tail;r;)n.push(e.call(i,r.value,this)),r=r.prev;return n}reduce(e,i){let n,r=this.head;if(arguments.length>1)n=i;else if(this.head)r=this.head.next,n=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var s=0;r;s++)n=e(n,r.value,s),r=r.next;return n}reduceReverse(e,i){let n,r=this.tail;if(arguments.length>1)n=i;else if(this.tail)r=this.tail.prev,n=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let s=this.length-1;r;s--)n=e(n,r.value,s),r=r.prev;return n}toArray(){let e=new Array(this.length);for(let i=0,n=this.head;n;i++)e[i]=n.value,n=n.next;return e}toArrayReverse(){let e=new Array(this.length);for(let i=0,n=this.tail;n;i++)e[i]=n.value,n=n.prev;return e}slice(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let n=new t;if(i<e||i<0)return n;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.head,s=0;for(s=0;r&&s<e;s++)r=r.next;for(;r&&s<i;s++,r=r.next)n.push(r.value);return n}sliceReverse(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let n=new t;if(i<e||i<0)return n;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.length,s=this.tail;for(;s&&r>i;r--)s=s.prev;for(;s&&r>e;r--,s=s.prev)n.push(s.value);return n}splice(e,i=0,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let r=this.head;for(let o=0;r&&o<e;o++)r=r.next;let s=[];for(let o=0;r&&o<i;o++)s.push(r.value),r=this.removeNode(r);r?r!==this.tail&&(r=r.prev):r=this.tail;for(let o of n)r=x7(this,r,o);return s}reverse(){let e=this.head,i=this.tail;for(let n=e;n;n=n.prev){let r=n.prev;n.prev=n.next,n.next=r}return this.head=i,this.tail=e,this}};function x7(t,e,i){let n=e,r=e?e.next:t.head,s=new Kr(i,n,r,t);return s.next===void 0&&(t.tail=s),s.prev===void 0&&(t.head=s),t.length++,s}function S7(t,e){t.tail=new Kr(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function G7(t,e){t.head=new Kr(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Kr=class{list;next;prev;value;constructor(e,i,n,r){this.list=r,this.value=e,i?(i.next=this,this.prev=i):this.prev=void 0,n?(n.prev=this,this.next=n):this.next=void 0}};import q3 from"path";var Oo=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(e,i){this.path=e||"./",this.absolute=i}},B3=Buffer.alloc(1024),So=Symbol("onStat"),kr=Symbol("ended"),_e=Symbol("queue"),Cn=Symbol("current"),Xi=Symbol("process"),Vr=Symbol("processing"),J3=Symbol("processJob"),$e=Symbol("jobs"),Gl=Symbol("jobDone"),Go=Symbol("addFSEntry"),Z3=Symbol("addTarEntry"),Wl=Symbol("stat"),Cl=Symbol("readdir"),Mo=Symbol("onreaddir"),Yo=Symbol("pipe"),y3=Symbol("entry"),Ml=Symbol("entryOpt"),Wo=Symbol("writeEntryClass"),w3=Symbol("write"),Yl=Symbol("ondrain"),ci=class extends dt{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Wo];onWriteEntry;[_e];[$e]=0;[Vr]=!1;[kr]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||"",this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=R(e.prefix||""),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[Wo]=Ur,typeof e.onwarn=="function"&&this.on("warn",e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli||e.zstd){if((e.gzip?1:0)+(e.brotli?1:0)+(e.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(e.gzip&&(typeof e.gzip!="object"&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new Xs(e.gzip)),e.brotli&&(typeof e.brotli!="object"&&(e.brotli={}),this.zip=new _s(e.brotli)),e.zstd&&(typeof e.zstd!="object"&&(e.zstd={}),this.zip=new to(e.zstd)),!this.zip)throw new Error("impossible");let i=this.zip;i.on("data",n=>super.write(n)),i.on("end",()=>super.end()),i.on("drain",()=>this[Yl]()),this.on("resume",()=>i.resume())}else this.on("drain",this[Yl]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter=="function"?e.filter:()=>!0,this[_e]=new xo,this[$e]=0,this.jobs=Number(e.jobs)||4,this[Vr]=!1,this[kr]=!1}[w3](e){return super.write(e)}add(e){return this.write(e),this}end(e,i,n){return typeof e=="function"&&(n=e,e=void 0),typeof i=="function"&&(n=i,i=void 0),e&&this.add(e),this[kr]=!0,this[Xi](),n&&n(),this}write(e){if(this[kr])throw new Error("write after end");return e instanceof Mn?this[Z3](e):this[Go](e),this.flowing}[Z3](e){let i=R(q3.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let n=new Oo(e.path,i);n.entry=new jo(e,this[Ml](n)),n.entry.on("end",()=>this[Gl](n)),this[$e]+=1,this[_e].push(n)}this[Xi]()}[Go](e){let i=R(q3.resolve(this.cwd,e));this[_e].push(new Oo(e,i)),this[Xi]()}[Wl](e){e.pending=!0,this[$e]+=1;let i=this.follow?"stat":"lstat";Co[i](e.absolute,(n,r)=>{e.pending=!1,this[$e]-=1,n?this.emit("error",n):this[So](e,r)})}[So](e,i){this.statCache.set(e.absolute,i),e.stat=i,this.filter(e.path,i)||(e.ignore=!0),this[Xi]()}[Cl](e){e.pending=!0,this[$e]+=1,Co.readdir(e.absolute,(i,n)=>{if(e.pending=!1,this[$e]-=1,i)return this.emit("error",i);this[Mo](e,n)})}[Mo](e,i){this.readdirCache.set(e.absolute,i),e.readdir=i,this[Xi]()}[Xi](){if(!this[Vr]){this[Vr]=!0;for(let e=this[_e].head;e&&this[$e]<this.jobs;e=e.next)if(this[J3](e.value),e.value.ignore){let i=e.next;this[_e].removeNode(e),e.next=i}this[Vr]=!1,this[kr]&&!this[_e].length&&this[$e]===0&&(this.zip?this.zip.end(B3):(super.write(B3),super.end()))}}get[Cn](){return this[_e]&&this[_e].head&&this[_e].head.value}[Gl](e){this[_e].shift(),this[$e]-=1,this[Xi]()}[J3](e){if(!e.pending){if(e.entry){e===this[Cn]&&!e.piped&&this[Yo](e);return}if(!e.stat){let i=this.statCache.get(e.absolute);i?this[So](e,i):this[Wl](e)}if(e.stat&&!e.ignore){if(!this.noDirRecurse&&e.stat.isDirectory()&&!e.readdir){let i=this.readdirCache.get(e.absolute);if(i?this[Mo](e,i):this[Cl](e),!e.readdir)return}if(e.entry=this[y3](e),!e.entry){e.ignore=!0;return}e===this[Cn]&&!e.piped&&this[Yo](e)}}}[Ml](e){return{onwarn:(i,n,r)=>this.warn(i,n,r),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[y3](e){this[$e]+=1;try{return new this[Wo](e.path,this[Ml](e)).on("end",()=>this[Gl](e)).on("error",n=>this.emit("error",n))}catch(i){this.emit("error",i)}}[Yl](){this[Cn]&&this[Cn].entry&&this[Cn].entry.resume()}[Yo](e){e.piped=!0,e.readdir&&e.readdir.forEach(r=>{let s=e.path,o=s==="./"?"":s.replace(/\/*$/,"/");this[Go](o+r)});let i=e.entry,n=this.zip;if(!i)throw new Error("cannot pipe without source");n?i.on("data",r=>{n.write(r)||i.pause()}):i.on("data",r=>{super.write(r)||i.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,i,n={}){yi(this,e,i,n)}},Hi=class extends ci{sync=!0;constructor(e){super(e),this[Wo]=zo}pause(){}resume(){}[Wl](e){let i=this.follow?"statSync":"lstatSync";this[So](e,Co[i](e.absolute))}[Cl](e){this[Mo](e,Co.readdirSync(e.absolute))}[Yo](e){let i=e.entry,n=this.zip;if(e.readdir&&e.readdir.forEach(r=>{let s=e.path,o=s==="./"?"":s.replace(/\/*$/,"/");this[Go](o+r)}),!i)throw new Error("Cannot pipe without source");n?i.on("data",r=>{n.write(r)}):i.on("data",r=>{super[w3](r)})}};var M7=(t,e)=>{let i=new Hi(t),n=new En(t.file,{mode:t.mode||438});i.pipe(n),T3(i,e)},Y7=(t,e)=>{let i=new ci(t),n=new Wt(t.file,{mode:t.mode||438});i.pipe(n);let r=new Promise((s,o)=>{n.on("error",o),n.on("close",s),i.on("error",o)});return X3(i,e),r},T3=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Ti({file:D3.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(i)}),t.end()},X3=async(t,e)=>{for(let i=0;i<e.length;i++){let n=String(e[i]);n.charAt(0)==="@"?await Ti({file:D3.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:r=>{t.add(r)}}):t.add(n)}t.end()},W7=(t,e)=>{let i=new Hi(t);return T3(i,e),i},C7=(t,e)=>{let i=new ci(t);return X3(i,e),i},O7=vt(M7,Y7,W7,C7,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")});import pv from"node:fs";import T7 from"node:assert";import{randomBytes as vv}from"node:crypto";import z from"node:fs";import Ft from"node:path";import H3 from"fs";var U7=process.env.__FAKE_PLATFORM__||process.platform,K7=U7==="win32",{O_CREAT:k7,O_TRUNC:V7,O_WRONLY:N7}=H3.constants,L3=Number(process.env.__FAKE_FS_O_FILENAME__)||H3.constants.UV_FS_O_FILEMAP||0,F7=K7&&!!L3,b7=512*1024,P7=L3|V7|k7|N7,Ol=F7?t=>t<b7?P7:"w":()=>"w";import Ko from"node:fs";import Nr from"node:path";var Ul=(t,e,i)=>{try{return Ko.lchownSync(t,e,i)}catch(n){if(n?.code!=="ENOENT")throw n}},Uo=(t,e,i,n)=>{Ko.lchown(t,e,i,r=>{n(r&&r?.code!=="ENOENT"?r:null)})},Q7=(t,e,i,n,r)=>{if(e.isDirectory())Kl(Nr.resolve(t,e.name),i,n,s=>{if(s)return r(s);let o=Nr.resolve(t,e.name);Uo(o,i,n,r)});else{let s=Nr.resolve(t,e.name);Uo(s,i,n,r)}},Kl=(t,e,i,n)=>{Ko.readdir(t,{withFileTypes:!0},(r,s)=>{if(r){if(r.code==="ENOENT")return n();if(r.code!=="ENOTDIR"&&r.code!=="ENOTSUP")return n(r)}if(r||!s.length)return Uo(t,e,i,n);let o=s.length,c=null,l=u=>{if(!c){if(u)return n(c=u);if(--o===0)return Uo(t,e,i,n)}};for(let u of s)Q7(t,u,e,i,l)})},B7=(t,e,i,n)=>{e.isDirectory()&&kl(Nr.resolve(t,e.name),i,n),Ul(Nr.resolve(t,e.name),i,n)},kl=(t,e,i)=>{let n;try{n=Ko.readdirSync(t,{withFileTypes:!0})}catch(r){let s=r;if(s?.code==="ENOENT")return;if(s?.code==="ENOTDIR"||s?.code==="ENOTSUP")return Ul(t,e,i);throw s}for(let r of n)B7(t,r,e,i);return Ul(t,e,i)};import xe from"node:fs";import J7 from"node:fs/promises";import ko from"node:path";var Fr=class extends Error{path;code;syscall="chdir";constructor(e,i){super(`${i}: Cannot cd into '${e}'`),this.path=e,this.code=i}get name(){return"CwdError"}};var br=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,i){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=i}get name(){return"SymlinkError"}};var Z7=(t,e)=>{xe.stat(t,(i,n)=>{(i||!n.isDirectory())&&(i=new Fr(t,i?.code||"ENOTDIR")),e(i)})},_3=(t,e,i)=>{t=R(t);let n=e.umask??18,r=e.mode|448,s=(r&n)!==0,o=e.uid,c=e.gid,l=typeof o=="number"&&typeof c=="number"&&(o!==e.processUid||c!==e.processGid),u=e.preserve,m=e.unlink,p=R(e.cwd),d=(g,E)=>{g?i(g):E&&l?Kl(E,o,c,J=>d(J)):s?xe.chmod(t,r,i):i()};if(t===p)return Z7(t,d);if(u)return J7.mkdir(t,{mode:r,recursive:!0}).then(g=>d(null,g??void 0),d);let f=R(ko.relative(p,t)).split("/");Vl(p,f,r,m,p,void 0,d)},Vl=(t,e,i,n,r,s,o)=>{if(!e.length)return o(null,s);let c=e.shift(),l=R(ko.resolve(t+"/"+c));xe.mkdir(l,i,$3(l,e,i,n,r,s,o))},$3=(t,e,i,n,r,s,o)=>c=>{c?xe.lstat(t,(l,u)=>{if(l)l.path=l.path&&R(l.path),o(l);else if(u.isDirectory())Vl(t,e,i,n,r,s,o);else if(n)xe.unlink(t,m=>{if(m)return o(m);xe.mkdir(t,i,$3(t,e,i,n,r,s,o))});else{if(u.isSymbolicLink())return o(new br(t,t+"/"+e.join("/")));o(c)}}):(s=s||t,Vl(t,e,i,n,r,s,o))},y7=t=>{let e=!1,i;try{e=xe.statSync(t).isDirectory()}catch(n){i=n?.code}finally{if(!e)throw new Fr(t,i??"ENOTDIR")}},ev=(t,e)=>{t=R(t);let i=e.umask??18,n=e.mode|448,r=(n&i)!==0,s=e.uid,o=e.gid,c=typeof s=="number"&&typeof o=="number"&&(s!==e.processUid||o!==e.processGid),l=e.preserve,u=e.unlink,m=R(e.cwd),p=g=>{g&&c&&kl(g,s,o),r&&xe.chmodSync(t,n)};if(t===m)return y7(m),p();if(l)return p(xe.mkdirSync(t,{mode:n,recursive:!0})??void 0);let A=R(ko.relative(m,t)).split("/"),f;for(let g=A.shift(),E=m;g&&(E+="/"+g);g=A.shift()){E=R(ko.resolve(E));try{xe.mkdirSync(E,n),f=f||E}catch{let M=xe.lstatSync(E);if(M.isDirectory())continue;if(u){xe.unlinkSync(E),xe.mkdirSync(E,n),f=f||E;continue}else if(M.isSymbolicLink())return new br(E,E+"/"+A.join("/"))}}return p(f)};import{join as nv}from"node:path";var Nl=Object.create(null),tv=1e4,On=new Set,iv=t=>{On.has(t)?On.delete(t):Nl[t]=t.normalize("NFD"),On.add(t);let e=Nl[t],i=On.size-tv;if(i>tv/10){for(let n of On)if(On.delete(n),delete Nl[n],--i<=0)break}return e};var q7=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,w7=q7==="win32",D7=t=>t.split("/").slice(0,-1).reduce((i,n)=>{let r=i[i.length-1];return r!==void 0&&(n=nv(r,n)),i.push(n||"/"),i},[]),Vo=class{#e=new Map;#n=new Map;#i=new Set;reserve(e,i){e=w7?["win32 parallelization disabled"]:e.map(r=>oi(nv(iv(r))).toLowerCase());let n=new Set(e.map(r=>D7(r)).reduce((r,s)=>r.concat(s)));this.#n.set(i,{dirs:n,paths:e});for(let r of e){let s=this.#e.get(r);s?s.push(i):this.#e.set(r,[i])}for(let r of n){let s=this.#e.get(r);if(!s)this.#e.set(r,[new Set([i])]);else{let o=s[s.length-1];o instanceof Set?o.add(i):s.push(new Set([i]))}}return this.#a(i)}#r(e){let i=this.#n.get(e);if(!i)throw new Error("function does not have any path reservations");return{paths:i.paths.map(n=>this.#e.get(n)),dirs:[...i.dirs].map(n=>this.#e.get(n))}}check(e){let{paths:i,dirs:n}=this.#r(e);return i.every(r=>r&&r[0]===e)&&n.every(r=>r&&r[0]instanceof Set&&r[0].has(e))}#a(e){return this.#i.has(e)||!this.check(e)?!1:(this.#i.add(e),e(()=>this.#t(e)),!0)}#t(e){if(!this.#i.has(e))return!1;let i=this.#n.get(e);if(!i)throw new Error("invalid reservation");let{paths:n,dirs:r}=i,s=new Set;for(let o of n){let c=this.#e.get(o);if(!c||c?.[0]!==e)continue;let l=c[1];if(!l){this.#e.delete(o);continue}if(c.shift(),typeof l=="function")s.add(l);else for(let u of l)s.add(u)}for(let o of r){let c=this.#e.get(o),l=c?.[0];if(!(!c||!(l instanceof Set)))if(l.size===1&&c.length===1){this.#e.delete(o);continue}else if(l.size===1){c.shift();let u=c[0];typeof u=="function"&&s.add(u)}else l.delete(e)}return this.#i.delete(e),s.forEach(o=>this.#a(o)),!0}};var rv=Symbol("onEntry"),Pl=Symbol("checkFs"),sv=Symbol("checkFs2"),Ql=Symbol("isReusable"),Fe=Symbol("makeFs"),Bl=Symbol("file"),Jl=Symbol("directory"),bo=Symbol("link"),ov=Symbol("symlink"),av=Symbol("hardlink"),cv=Symbol("unsupported"),lv=Symbol("checkPath"),li=Symbol("mkdir"),ae=Symbol("onError"),No=Symbol("pending"),uv=Symbol("pend"),Un=Symbol("unpend"),Fl=Symbol("ended"),bl=Symbol("maybeClose"),Zl=Symbol("skip"),Pr=Symbol("doChown"),Qr=Symbol("uid"),Br=Symbol("gid"),Jr=Symbol("checkedCwd"),X7=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Zr=X7==="win32",H7=1024,L7=(t,e)=>{if(!Zr)return z.unlink(t,e);let i=t+".DELETE."+vv(16).toString("hex");z.rename(t,i,n=>{if(n)return e(n);z.unlink(i,e)})},_7=t=>{if(!Zr)return z.unlinkSync(t);let e=t+".DELETE."+vv(16).toString("hex");z.renameSync(t,e),z.unlinkSync(e)},mv=(t,e,i)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:i,Kn=class extends Nt{[Fl]=!1;[Jr]=!1;[No]=0;reservations=new Vo;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[Fl]=!0,this[bl]()},super(e),this.transform=e.transform,this.chmod=!!e.chmod,typeof e.uid=="number"||typeof e.gid=="number"){if(typeof e.uid!="number"||typeof e.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(e.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;e.preserveOwner===void 0&&typeof e.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:H7,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||Zr,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=R(Ft.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask=="number"?e.processUmask:process.umask():0,this.umask=typeof e.umask=="number"?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on("entry",i=>this[rv](i))}warn(e,i,n={}){return(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(n.recoverable=!1),super.warn(e,i,n)}[bl](){this[Fl]&&this[No]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[lv](e){let i=R(e.path),n=i.split("/");if(this.strip){if(n.length<this.strip)return!1;if(e.type==="Link"){let r=R(String(e.linkpath)).split("/");if(r.length>=this.strip)e.linkpath=r.slice(this.strip).join("/");else return!1}n.splice(0,this.strip),e.path=n.join("/")}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:i,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this.preservePaths){if(n.includes("..")||Zr&&/^[a-z]:\.\.$/i.test(n[0]??""))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:e,path:i}),!1;let[r,s]=Cr(i);r&&(e.path=String(s),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:e,path:i}))}if(Ft.isAbsolute(e.path)?e.absolute=R(Ft.resolve(e.path)):e.absolute=R(Ft.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute=="string"&&e.absolute.indexOf(this.cwd+"/")!==0&&e.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:R(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!=="Directory"&&e.type!=="GNUDumpDir")return!1;if(this.win32){let{root:r}=Ft.win32.parse(String(e.absolute));e.absolute=r+hl(String(e.absolute).slice(r.length));let{root:s}=Ft.win32.parse(e.path);e.path=s+hl(e.path.slice(s.length))}return!0}[rv](e){if(!this[lv](e))return e.resume();switch(T7.equal(typeof e.absolute,"string"),e.type){case"Directory":case"GNUDumpDir":e.mode&&(e.mode=e.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Pl](e);default:return this[cv](e)}}[ae](e,i){e.name==="CwdError"?this.emit("error",e):(this.warn("TAR_ENTRY_ERROR",e,{entry:i}),this[Un](),i.resume())}[li](e,i,n){_3(R(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:i},n)}[Pr](e){return this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Qr](e){return mv(this.uid,e.uid,this.processUid)}[Br](e){return mv(this.gid,e.gid,this.processGid)}[Bl](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,r=new Wt(String(e.absolute),{flags:Ol(e.size),mode:n,autoClose:!1});r.on("error",l=>{r.fd&&z.close(r.fd,()=>{}),r.write=()=>!0,this[ae](l,e),i()});let s=1,o=l=>{if(l){r.fd&&z.close(r.fd,()=>{}),this[ae](l,e),i();return}--s===0&&r.fd!==void 0&&z.close(r.fd,u=>{u?this[ae](u,e):this[Un](),i()})};r.on("finish",()=>{let l=String(e.absolute),u=r.fd;if(typeof u=="number"&&e.mtime&&!this.noMtime){s++;let m=e.atime||new Date,p=e.mtime;z.futimes(u,m,p,d=>d?z.utimes(l,m,p,A=>o(A&&d)):o())}if(typeof u=="number"&&this[Pr](e)){s++;let m=this[Qr](e),p=this[Br](e);typeof m=="number"&&typeof p=="number"&&z.fchown(u,m,p,d=>d?z.chown(l,m,p,A=>o(A&&d)):o())}o()});let c=this.transform&&this.transform(e)||e;c!==e&&(c.on("error",l=>{this[ae](l,e),i()}),e.pipe(c)),c.pipe(r)}[Jl](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.dmode;this[li](String(e.absolute),n,r=>{if(r){this[ae](r,e),i();return}let s=1,o=()=>{--s===0&&(i(),this[Un](),e.resume())};e.mtime&&!this.noMtime&&(s++,z.utimes(String(e.absolute),e.atime||new Date,e.mtime,o)),this[Pr](e)&&(s++,z.chown(String(e.absolute),Number(this[Qr](e)),Number(this[Br](e)),o)),o()})}[cv](e){e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[ov](e,i){this[bo](e,String(e.linkpath),"symlink",i)}[av](e,i){let n=R(Ft.resolve(this.cwd,String(e.linkpath)));this[bo](e,n,"link",i)}[uv](){this[No]++}[Un](){this[No]--,this[bl]()}[Zl](e){this[Un](),e.resume()}[Ql](e,i){return e.type==="File"&&!this.unlink&&i.isFile()&&i.nlink<=1&&!Zr}[Pl](e){this[uv]();let i=[e.path];e.linkpath&&i.push(e.linkpath),this.reservations.reserve(i,n=>this[sv](e,n))}[sv](e,i){let n=c=>{i(c)},r=()=>{this[li](this.cwd,this.dmode,c=>{if(c){this[ae](c,e),n();return}this[Jr]=!0,s()})},s=()=>{if(e.absolute!==this.cwd){let c=R(Ft.dirname(String(e.absolute)));if(c!==this.cwd)return this[li](c,this.dmode,l=>{if(l){this[ae](l,e),n();return}o()})}o()},o=()=>{z.lstat(String(e.absolute),(c,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(e.mtime??l.mtime))){this[Zl](e),n();return}if(c||this[Ql](e,l))return this[Fe](null,e,n);if(l.isDirectory()){if(e.type==="Directory"){let u=this.chmod&&e.mode&&(l.mode&4095)!==e.mode,m=p=>this[Fe](p??null,e,n);return u?z.chmod(String(e.absolute),Number(e.mode),m):m()}if(e.absolute!==this.cwd)return z.rmdir(String(e.absolute),u=>this[Fe](u??null,e,n))}if(e.absolute===this.cwd)return this[Fe](null,e,n);L7(String(e.absolute),u=>this[Fe](u??null,e,n))})};this[Jr]?s():r()}[Fe](e,i,n){if(e){this[ae](e,i),n();return}switch(i.type){case"File":case"OldFile":case"ContiguousFile":return this[Bl](i,n);case"Link":return this[av](i,n);case"SymbolicLink":return this[ov](i,n);case"Directory":case"GNUDumpDir":return this[Jl](i,n)}}[bo](e,i,n,r){z[n](i,String(e.absolute),s=>{s?this[ae](s,e):(this[Un](),e.resume()),r()})}},Fo=t=>{try{return[null,t()]}catch(e){return[e,null]}},yr=class extends Kn{sync=!0;[Fe](e,i){return super[Fe](e,i,()=>{})}[Pl](e){if(!this[Jr]){let s=this[li](this.cwd,this.dmode);if(s)return this[ae](s,e);this[Jr]=!0}if(e.absolute!==this.cwd){let s=R(Ft.dirname(String(e.absolute)));if(s!==this.cwd){let o=this[li](s,this.dmode);if(o)return this[ae](o,e)}}let[i,n]=Fo(()=>z.lstatSync(String(e.absolute)));if(n&&(this.keep||this.newer&&n.mtime>(e.mtime??n.mtime)))return this[Zl](e);if(i||this[Ql](e,n))return this[Fe](null,e);if(n.isDirectory()){if(e.type==="Directory"){let o=this.chmod&&e.mode&&(n.mode&4095)!==e.mode,[c]=o?Fo(()=>{z.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[Fe](c,e)}let[s]=Fo(()=>z.rmdirSync(String(e.absolute)));this[Fe](s,e)}let[r]=e.absolute===this.cwd?[]:Fo(()=>_7(String(e.absolute)));this[Fe](r,e)}[Bl](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,r=c=>{let l;try{z.closeSync(s)}catch(u){l=u}(c||l)&&this[ae](c||l,e),i()},s;try{s=z.openSync(String(e.absolute),Ol(e.size),n)}catch(c){return r(c)}let o=this.transform&&this.transform(e)||e;o!==e&&(o.on("error",c=>this[ae](c,e)),e.pipe(o)),o.on("data",c=>{try{z.writeSync(s,c,0,c.length)}catch(l){r(l)}}),o.on("end",()=>{let c=null;if(e.mtime&&!this.noMtime){let l=e.atime||new Date,u=e.mtime;try{z.futimesSync(s,l,u)}catch(m){try{z.utimesSync(String(e.absolute),l,u)}catch{c=m}}}if(this[Pr](e)){let l=this[Qr](e),u=this[Br](e);try{z.fchownSync(s,Number(l),Number(u))}catch(m){try{z.chownSync(String(e.absolute),Number(l),Number(u))}catch{c=c||m}}}r(c)})}[Jl](e,i){let n=typeof e.mode=="number"?e.mode&4095:this.dmode,r=this[li](String(e.absolute),n);if(r){this[ae](r,e),i();return}if(e.mtime&&!this.noMtime)try{z.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[Pr](e))try{z.chownSync(String(e.absolute),Number(this[Qr](e)),Number(this[Br](e)))}catch{}i(),e.resume()}[li](e,i){try{return ev(R(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:i})}catch(n){return n}}[bo](e,i,n,r){let s=`${n}Sync`;try{z[s](i,String(e.absolute)),r(),e.resume()}catch(o){return this[ae](o,e)}}};var $7=t=>{let e=new yr(t),i=t.file,n=pv.statSync(i),r=t.maxReadSize||16*1024*1024;new Bs(i,{readSize:r,size:n.size}).pipe(e)},eh=(t,e)=>{let i=new Kn(t),n=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((o,c)=>{i.on("error",c),i.on("close",o),pv.stat(r,(l,u)=>{if(l)c(l);else{let m=new Fi(r,{readSize:n,size:u.size});m.on("error",c),m.pipe(i)}})})},yl=vt($7,eh,t=>new yr(t),t=>new Kn(t),(t,e)=>{e?.length&&Al(t,e)});import Se from"node:fs";import Av from"node:path";var th=(t,e)=>{let i=new Hi(t),n=!0,r,s;try{try{r=Se.openSync(t.file,"r+")}catch(l){if(l?.code==="ENOENT")r=Se.openSync(t.file,"w+");else throw l}let o=Se.fstatSync(r),c=Buffer.alloc(512);e:for(s=0;s<o.size;s+=512){for(let m=0,p=0;m<512;m+=p){if(p=Se.readSync(r,c,m,c.length-m,s+m),s===0&&c[0]===31&&c[1]===139)throw new Error("cannot append to compressed archives");if(!p)break e}let l=new ze(c);if(!l.cksumValid)break;let u=512*Math.ceil((l.size||0)/512);if(s+u+512>o.size)break;s+=u,t.mtimeCache&&l.mtime&&t.mtimeCache.set(String(l.path),l.mtime)}n=!1,ih(t,i,s,r,e)}finally{if(n)try{Se.closeSync(r)}catch{}}},ih=(t,e,i,n,r)=>{let s=new En(t.file,{fd:n,start:i});e.pipe(s),rh(e,r)},nh=(t,e)=>{e=Array.from(e);let i=new ci(t),n=(s,o,c)=>{let l=(A,f)=>{A?Se.close(s,g=>c(A)):c(null,f)},u=0;if(o===0)return l(null,0);let m=0,p=Buffer.alloc(512),d=(A,f)=>{if(A||typeof f>"u")return l(A);if(m+=f,m<512&&f)return Se.read(s,p,m,p.length-m,u+m,d);if(u===0&&p[0]===31&&p[1]===139)return l(new Error("cannot append to compressed archives"));if(m<512)return l(null,u);let g=new ze(p);if(!g.cksumValid)return l(null,u);let E=512*Math.ceil((g.size??0)/512);if(u+E+512>o||(u+=E+512,u>=o))return l(null,u);t.mtimeCache&&g.mtime&&t.mtimeCache.set(String(g.path),g.mtime),m=0,Se.read(s,p,0,512,u,d)};Se.read(s,p,0,512,u,d)};return new Promise((s,o)=>{i.on("error",o);let c="r+",l=(u,m)=>{if(u&&u.code==="ENOENT"&&c==="r+")return c="w+",Se.open(t.file,c,l);if(u||!m)return o(u);Se.fstat(m,(p,d)=>{if(p)return Se.close(m,()=>o(p));n(m,d.size,(A,f)=>{if(A)return o(A);let g=new Wt(t.file,{fd:m,start:f});i.pipe(g),g.on("error",o),g.on("close",s),sh(i,e)})})};Se.open(t.file,c,l)})},rh=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Ti({file:Av.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(i)}),t.end()},sh=async(t,e)=>{for(let i=0;i<e.length;i++){let n=String(e[i]);n.charAt(0)==="@"?await Ti({file:Av.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:r=>t.add(r)}):t.add(n)}t.end()},Li=vt(th,nh,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!c3(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")});var oh=vt(Li.syncFile,Li.asyncFile,Li.syncNoFile,Li.asyncNoFile,(t,e=[])=>{Li.validate?.(t,e),ah(t)}),ah=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(i,n)=>e(i,n)&&!((t.mtimeCache?.get(i)??n.mtime??0)>(n.mtime??0)):(i,n)=>!((t.mtimeCache?.get(i)??n.mtime??0)>(n.mtime??0))};async function kn(t){let{source:e,destination:i,strip:n=1,filter:r}=t,s=[];if(!dv(e))return{success:!1,extractedFiles:[],error:`Source file not found: ${e}`};dv(i)||uh(i,{recursive:!0});try{return await mh(lh(e),vh(),yl({cwd:i,strip:n,filter:o=>r&&!r(o)?!1:(s.push(o),!0)})),{success:!0,extractedFiles:s}}catch(o){return{success:!1,extractedFiles:s,error:o instanceof Error?o.message:String(o)}}}k();import{existsSync as fv,readFileSync as ph,writeFileSync as Ah,mkdirSync as dh}from"fs";import{dirname as fh}from"path";function ui(t){let e=Sc(t);if(!fv(e))return null;try{let i=ph(e,"utf-8");return JSON.parse(i)}catch{return null}}function Po(t,e){let i=Sc(e),n=fh(i);fv(n)||dh(n,{recursive:!0}),Ah(i,JSON.stringify(t,null,2))}function hv(t,e,i){return{name:"gemkit",version:t,installedAt:new Date().toISOString(),scope:e,installedFiles:i,customizedFiles:[]}}function gv(t){return ui(t)!==null}var h=As(Rv(),1),Eh=t=>{let e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return`\x1B[38;2;${e};${i};${n}m`},qr=t=>e=>h.default.isColorSupported?`${Eh(t)}${e}\x1B[39m`:e,a={primary:qr("#4f46e5"),secondary:qr("#9333ea"),accent:qr("#06b6d4"),geminiBlue:qr("#1a73e8"),geminiPurple:qr("#8e24aa"),success:t=>h.default.green(t),error:t=>h.default.red(t),warn:t=>h.default.yellow(t),info:t=>h.default.cyan(t),dim:t=>h.default.dim(t)},G={line:(t=60)=>"\u2500".repeat(t),doubleLine:(t=60)=>"\u2550".repeat(t),statusIcon:t=>{switch(t){case"active":return a.success("\u25CF");case"completed":return a.dim("\u25CB");case"failed":return a.error("\u2717");default:return"?"}},checkIcon:(t,e=!1)=>t?a.success("\u2713"):e?a.warn("\u25CB"):a.error("\u2717"),header:t=>h.default.bold(a.geminiPurple(t)),section:(t,e=60)=>{console.log(),console.log("\u2500".repeat(e)),console.log(h.default.bold(a.geminiPurple(t))),console.log("\u2500".repeat(e)),console.log()}};var _S={success:a.success,error:a.error,warning:a.warn,info:a.info,dim:a.dim,primary:a.primary,secondary:a.secondary,bold:h.default.bold};var zv={debug:0,info:1,warn:2,error:3,silent:4},be={level:"info",verbose:!1,json:!1};function Jo(t){be={...be,...t}}function wr(t){return zv[t]>=zv[be.level]}function Rh(t,e){wr("debug")&&(be.json?console.log(JSON.stringify({level:"debug",message:t,data:e})):(console.log(a.dim(`[DEBUG] ${t}`)),e&&be.verbose&&console.log(a.dim(JSON.stringify(e,null,2)))))}function zh(t,e){wr("info")&&(be.json?console.log(JSON.stringify({level:"info",message:t,data:e})):(console.log(`${a.info("\u2139")} ${t}`),e&&be.verbose&&console.log(JSON.stringify(e,null,2))))}function jh(t,e){wr("info")&&(be.json?console.log(JSON.stringify({level:"success",message:t,data:e})):console.log(`${a.success("\u2713")} ${t}`))}function xh(t,e){wr("warn")&&(be.json?console.log(JSON.stringify({level:"warn",message:t,data:e})):console.log(`${a.warn("\u26A0")} ${t}`))}function Sh(t,e){wr("error")&&(be.json?console.error(JSON.stringify({level:"error",message:t,data:e})):(console.error(`${a.error("\u2717")} ${t}`),e&&be.verbose&&console.error(JSON.stringify(e,null,2))))}function Gh(t){be.json?console.log(JSON.stringify(t)):console.table(t)}function Mh(t){console.log(JSON.stringify(t,null,2))}var v={debug:Rh,info:zh,success:jh,warn:xh,error:Sh,table:Gh,json:Mh,configure:Jo};import{spawnSync as Uh}from"child_process";k();var Yh="https://registry.npmjs.org",Wh="npm-version",Ch=3600;async function Dr(t){let e=`${Wh}-${t}`,i=Ws(e);if(i)return i;try{let n=await fetch(`${Yh}/${t}/latest`,{headers:{Accept:"application/json","User-Agent":"gemkit-cli"}});if(!n.ok)return null;let r=await n.json(),s={name:r.name,version:r.version,description:r.description,publishedAt:r.time?.[r.version]};return Cs(e,s,Ch),s}catch{return null}}function Oh(t,e){let i=t.replace(/^v/,"").split(".").map(Number),n=e.replace(/^v/,"").split(".").map(Number);for(let r=0;r<Math.max(i.length,n.length);r++){let s=i[r]||0,o=n[r]||0;if(s>o)return 1;if(s<o)return-1}return 0}function Vn(t,e){return Oh(e,t)>0}import{readFileSync as Kh}from"fs";import{join as jv,dirname as kh}from"path";import{fileURLToPath as Vh}from"url";var Tr="gemkit-cli";function Nh(){try{let t=Vh(import.meta.url),e=kh(t),i=[jv(e,"..","package.json"),jv(e,"..","..","..","package.json")];for(let n of i)try{let r=JSON.parse(Kh(n,"utf-8"));if(r.name===Tr&&r.version)return r.version}catch{}}catch{}return"0.0.0"}var Pe=Nh();function xv(t){t.command("update","Update GemKit CLI and/or Kits to latest version").option("-f, --force","Force update even if already up to date").option("--no-backup","Disable backup before kits update").option("--cli","Update CLI only (npm package)").option("--kits","Update Kits only (.gemini folder)").action(async e=>{let i=e.cli===!0||!e.cli&&!e.kits,n=e.kits===!0||!e.cli&&!e.kits,r=!1,s=!1;i&&(r=await Fh(e.force)),n&&(s=await bh(e.force)),console.log(),r||s?v.success("Update complete!"):v.info("Everything is up to date.")})}async function Fh(t){console.log(),v.info(`${a.primary("CLI")} Checking for updates...`);let e=await Dr(Tr);if(!e)return v.warn("Failed to check npm registry for CLI updates."),!1;let i=Pe,n=e.version;return!Vn(i,n)&&!t?(v.success(`CLI is up to date (v${i})`),!1):(v.info(`Updating CLI: v${i} \u2192 v${n}`),Uh("npm",["install","-g",`${Tr}@latest`],{encoding:"utf-8",stdio:"inherit",shell:!0}).status!==0?(v.error("CLI update failed. Try running manually:"),v.info(` npm install -g ${Tr}@latest`),!1):(v.success(`CLI updated to v${n}`),!0))}async function bh(t){console.log(),v.info(`${a.primary("Kits")} Checking for updates...`);let e=ui();if(!e)return v.warn('GemKit not initialized. Run "gk init" first to install kits.'),!1;let i=await Ki();if(!i)return v.warn("Failed to check GitHub for kits updates."),!1;if(i.version===e.version&&!t)return v.success(`Kits are up to date (v${e.version})`),!1;v.info(`Updating Kits: v${e.version} \u2192 v${i.version}`);let n=await pn(i),r=Ms(),s=await kn({source:n,destination:r,strip:1});if(!s.success)return v.error(`Kits update failed: ${s.error}`),!1;let o={...e,version:i.version,installedAt:new Date().toISOString(),installedFiles:s.extractedFiles};return Po(o),v.success(`Kits updated to v${i.version}`),!0}async function Sv(){let t={cli:null,kits:null};try{let e=await Dr(Tr);e&&(t.cli={current:Pe,latest:e.version,available:Vn(Pe,e.version)})}catch{}try{let e=ui(),i=await Ki();e&&i&&(t.kits={current:e.version,latest:i.version,available:Vn(e.version,i.version)})}catch{}return t}var Gv="gemkit-cli";function Zh(t){return Jh("npm",["install","-g",`${Gv}@${t}`],{encoding:"utf-8",stdio:"pipe",shell:!0}).status===0}function yh(t){switch(t){case"gemini":return[".claude",".claude/**",".agent",".agent/**"];case"claude":return[".agent",".agent/**"];case"antigravity":return[".claude",".claude/**"];default:return[]}}function qh(t){switch(t){case"gemini":return"Gemini CLI (excludes .claude, .agent)";case"claude":return"Claude Code (excludes .agent)";case"antigravity":return"Antigravity (excludes .claude)";default:return"Full (all files)"}}function wh(t,e){let i=t.replace(/\\/g,"/");for(let n of e)if(n.includes("*")){if(n.endsWith("/**")){let r=n.slice(0,-3);if(i.startsWith(r+"/"))return!0}}else if(i===n||i.startsWith(n+"/"))return!0;return!1}function Dh(t){if(t.length!==0)return e=>!wh(e,t)}async function Th(){let t=Qh(".gemini","extensions","spawn-agent");return Ph(t)?new Promise(e=>{let i=Bh("gemini",["extensions","install",t],{stdio:["pipe","pipe","pipe"],shell:process.platform==="win32",cwd:process.cwd()}),n="",r="",s=!1,o=setTimeout(()=>{s||(s=!0,i.kill(),e({success:!1,error:"Extension installation timed out"}))},3e4);i.stdout?.on("data",c=>{n+=c.toString()}),i.stderr?.on("data",c=>{r+=c.toString()}),i.on("close",c=>{s||(s=!0,clearTimeout(o),e(c===0?{success:!0}:{success:!1,error:r||n||`Exit code: ${c}`}))}),i.on("error",c=>{s||(s=!0,clearTimeout(o),e({success:!1,error:`Failed to run gemini CLI: ${c.message}`}))})}):{success:!1,error:`Extension directory not found: ${t}`}}function Mv(t){t.command("init","Initialize GemKit in project").option("--version <ver>","Specific version to install").option("-f, --force","Overwrite existing installation").option("--exclude <patterns...>","File patterns to exclude").option("--skip-extension","Skip spawn-agent extension installation").option("--full","Install all files (default)").option("--gemini","Gemini CLI mode (excludes .claude, .agent folders)").option("--claude","Claude Code mode (excludes .agent folder)").option("--antigravity","Antigravity mode (excludes .claude folder)").action(async e=>{let i="full";if(e.gemini?i="gemini":e.claude?i="claude":e.antigravity?i="antigravity":e.full&&(i="full"),gv()&&!e.force){console.log(),v.warn("GemKit is already installed. Use --force to reinstall."),console.log();return}console.log(),console.log(h.default.bold(a.geminiPurple("Initializing GemKit"))),console.log(),console.log(` ${a.dim("Mode")} ${a.accent(qh(i))}`),console.log();let n=lt({text:"Checking CLI version...",color:"magenta"}).start();try{let f=await Dr(Gv);f&&Vn(Pe,f.version)?(n.text=`Updating CLI v${Pe} \u2192 v${f.version}...`,Zh(f.version)?n.succeed(`CLI updated v${a.primary(Pe)} \u2192 v${a.primary(f.version)}`):n.warn(`CLI v${a.primary(Pe)} (update to v${f.version} failed)`)):n.succeed(`CLI v${a.primary(Pe)}`)}catch{n.succeed(`CLI v${a.primary(Pe)}`)}let r=lt({text:"Fetching latest Kits release...",color:"magenta"}).start(),s=e.version?await _m(e.version):await Ki();s||(r.fail("No Kits release found"),console.log(),process.exit(1)),r.succeed(`Found Kits v${a.primary(s.version)}`);let o=lt({text:"Downloading Kits...",color:"magenta"}).start(),c;try{c=await pn(s),o.succeed("Kits downloaded")}catch(f){o.fail(`Kits download failed: ${f instanceof Error?f.message:String(f)}`),console.log(),process.exit(1)}let l=yh(i),u=lt({text:i==="full"?"Extracting Kits...":`Extracting Kits (${i} mode)...`,color:"magenta"}).start(),m=process.cwd(),p=await kn({source:c,destination:m,strip:1,filter:Dh(l)});p.success||(u.fail(`Kits extraction failed: ${p.error}`),console.log(),process.exit(1)),u.succeed(`Extracted ${p.extractedFiles.length} files`);let d=hv(s.version,"local",p.extractedFiles);if(Po(d),console.log(),v.success(`Kits v${a.primary(s.version)} installed successfully!`),!e.skipExtension&&(i==="full"||i==="gemini")){console.log();let f=lt({text:"Installing spawn-agent extension...",color:"magenta"}).start(),g=await Th();g.success?f.succeed("spawn-agent extension installed in Gemini CLI"):(f.warn(`Could not install spawn-agent extension: ${g.error}`),v.info(`You can manually install it with: ${a.primary("gemini extensions install .gemini/extensions/spawn-agent")}`))}else(i==="claude"||i==="antigravity")&&(console.log(),v.info(`Skipped Gemini extension (${i} mode).`));console.log(),v.info(`Run ${a.primary("gk doctor")} to verify installation.`),console.log()})}function Yv(t){t.command("versions","List available GemKit versions").alias("v").option("--json","Output as JSON").action(async e=>{let i=ui(),n=await Os();if(e.json){console.log(JSON.stringify({current:i?.version||null,available:n},null,2));return}console.log(),console.log(h.default.bold(a.geminiPurple("GemKit Versions"))),console.log(),console.log(i?` ${a.dim("Current:")} ${a.success(i.version)}`:` ${a.dim("Current:")} ${a.dim("Not installed")}`),console.log(),console.log(` ${h.default.bold("Available Releases:")}`);for(let r of n){let s=r.version===i?.version?a.success(" (current)"):"";console.log(` - ${a.primary(r.version)}${s}`)}console.log()})}import{existsSync as Zo}from"fs";import{join as Xh}from"path";import{spawn as Wv}from"child_process";k();async function Hh(){return new Promise(t=>{let e=Wv("gemini",["extensions","list"],{stdio:["pipe","pipe","pipe"],shell:process.platform==="win32"}),i="",n="",r=!1,s=setTimeout(()=>{r||(r=!0,e.kill(),t({installed:!1,error:"Check timed out"}))},2e4);e.stdout?.on("data",o=>{i+=o.toString()}),e.stderr?.on("data",o=>{n+=o.toString()}),e.on("close",o=>{if(!r)if(r=!0,clearTimeout(s),o===0){let c=i.toLowerCase().includes("spawn-agent");t({installed:c})}else t({installed:!1,error:n||"Failed to check extensions"})}),e.on("error",o=>{r||(r=!0,clearTimeout(s),t({installed:!1,error:`Gemini CLI not available: ${o.message}`}))})})}async function Lh(){return new Promise(t=>{let e=Wv("gemini",["--version"],{stdio:["pipe","pipe","pipe"],shell:process.platform==="win32"}),i="",n=!1,r=setTimeout(()=>{n||(n=!0,e.kill(),t({available:!1,error:"Timed out"}))},15e3);e.stdout?.on("data",s=>{i+=s.toString()}),e.on("close",s=>{if(!n)if(n=!0,clearTimeout(r),s===0){let o=i.trim().split(`
|
|
49
|
+
`)[0]||"unknown";t({available:!0,version:o})}else t({available:!1,error:"Command failed"})}),e.on("error",s=>{n||(n=!0,clearTimeout(r),t({available:!1,error:s.message}))})})}function Cv(t){t.command("doctor","Check installation health").option("--fix","Attempt to fix issues").action(async e=>{console.log(),console.log(h.default.bold(a.geminiPurple("GemKit Health Check"))),console.log();let i=0,n=0,r=[],s=process.version;parseInt(s.slice(1).split(".")[0],10)>=18?r.push({icon:a.success("\u2713"),message:`Node.js ${s}`}):(r.push({icon:a.error("\u2717"),message:`Node.js ${s} ${a.error("(requires >= 18)")}`}),i++);let c=lt({text:"Checking Gemini CLI...",color:"magenta"}).start(),l=await Lh();c.stop(),l.available?r.push({icon:a.success("\u2713"),message:`Gemini CLI ${a.dim(`(${l.version})`)}`}):(r.push({icon:a.error("\u2717"),message:`Gemini CLI not found ${a.dim(`(${l.error})`)}`}),i++);let u=Ms();Zo(u)?r.push({icon:a.success("\u2713"),message:".gemini directory exists"}):(r.push({icon:a.error("\u2717"),message:".gemini directory missing"}),i++);let m=ar();Zo(m)?r.push({icon:a.success("\u2713"),message:"Agents directory exists"}):(r.push({icon:a.warn("\u25CB"),message:"Agents directory missing"}),n++);let p=Ci();Zo(p)?r.push({icon:a.success("\u2713"),message:"Extensions directory exists"}):(r.push({icon:a.warn("\u25CB"),message:"Extensions directory missing"}),n++);let d=Xh(p,"spawn-agent");if(Zo(d)?r.push({icon:a.success("\u2713"),message:"spawn-agent extension files present"}):(r.push({icon:a.warn("\u25CB"),message:"spawn-agent extension files missing"}),n++),l.available){let f=lt({text:"Checking spawn-agent extension...",color:"magenta"}).start(),g=await Hh();f.stop(),g.installed?r.push({icon:a.success("\u2713"),message:"spawn-agent extension installed in Gemini"}):(r.push({icon:a.error("\u2717"),message:"spawn-agent extension NOT installed in Gemini",hint:g.error?`${g.error}
|
|
50
|
+
Run: gemini extensions install .gemini/extensions/spawn-agent`:"Run: gemini extensions install .gemini/extensions/spawn-agent"}),i++)}let A=ui();A?r.push({icon:a.success("\u2713"),message:`Installation metadata ${a.primary(`(v${A.version})`)}`}):(r.push({icon:a.warn("\u25CB"),message:"Installation metadata missing"}),n++);for(let f of r)if(console.log(` ${f.icon} ${f.message}`),f.hint)for(let g of f.hint.split(`
|
|
51
|
+
`))console.log(` ${a.dim(g)}`);console.log(),i===0&&n===0?console.log(a.success("All checks passed!")):i===0?console.log(a.success(`All critical checks passed! ${a.dim(`(${n} warning${n>1?"s":""})`)}`)):(console.log(a.error(`${i} issue(s) found.`)),n>0&&console.log(a.warn(`${n} warning(s).`)),console.log(),console.log("To fix issues:"),console.log(` ${a.dim("1.")} Run ${a.primary("gk init")} to install GemKit`),console.log(` ${a.dim("2.")} Run ${a.primary("gemini extensions install .gemini/extensions/spawn-agent")} to install extension`)),console.log()})}function _h(){console.log(),console.log(h.default.bold(a.geminiPurple("Configuration Management"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk config")} <subcommand> [options]`),console.log(),console.log("Subcommands:"),console.log(` ${a.primary("list")} Show all config (default)`),console.log(` ${a.primary("get")} <key> Get config value`),console.log(` ${a.primary("set")} <key> <val> Set config value`),console.log(` ${a.primary("reset")} Reset to defaults`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} [list] Output as JSON`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk config list")}`),console.log(` ${a.dim("gk config get spawn.defaultModel")}`),console.log(` ${a.dim("gk config set spawn.music true")}`),console.log(` ${a.dim("gk config reset")}`),console.log()}function Ov(t){t.command("config [subcommand] [key] [value]","Configuration management (list, get, set, reset)").alias("c").option("--json","[list] Output as JSON").action(async(e,i,n,r)=>{switch(e||"list"){case"list":await $h(r);break;case"get":i||(console.log(),v.error("Config key required"),console.log(a.dim("Usage: gk config get <key>")),console.log(),process.exit(1)),await eg(i);break;case"set":(!i||n===void 0)&&(console.log(),v.error("Config key and value required"),console.log(a.dim("Usage: gk config set <key> <value>")),console.log(),process.exit(1)),await tg(i,n);break;case"reset":await ig();break;default:_h()}})}async function $h(t){let e=Ie();if(t.json){console.log(JSON.stringify(e,null,2));return}console.log(),console.log(h.default.bold(a.geminiPurple("GemKit Configuration"))),console.log(),console.log(JSON.stringify(e,null,2)),console.log()}async function eg(t){let e=Jm(t);if(e===void 0){console.log(),v.error(`Config key not found: ${t}`),console.log();return}console.log(e)}async function tg(t,e){let i=e;e==="true"?i=!0:e==="false"?i=!1:isNaN(Number(e))||(i=Number(e));try{Zm(t,i),console.log(),v.success(`Config updated: ${a.primary(t)} = ${a.success(String(i))}`),console.log()}catch(n){console.log(),v.error(`Failed to set config: ${n instanceof Error?n.message:String(n)}`),console.log()}}async function ig(){ym(),console.log(),v.success("Configuration reset to defaults."),console.log()}function Uv(t){let e=t.command("cache <subcommand>","Cache management");e.example("gk cache stats # Show cache statistics"),e.example("gk cache clear # Clear all cache"),e.action(async i=>{let n=i||"stats";switch(n){case"stats":await ng();break;case"clear":await rg();break;default:console.log(),v.error(`Unknown subcommand: ${n}`),console.log(),process.exit(1)}})}async function ng(){let t=Hm();console.log(),console.log(h.default.bold(a.geminiPurple("Cache Statistics"))),console.log(),console.log(` ${a.dim("Entries:")} ${a.primary(String(t.entries))}`),console.log(` ${a.dim("Size:")} ${a.primary((t.size/1024).toFixed(2))} KB`),console.log()}async function rg(){let t=Xm();console.log(),v.success(`Cleared ${a.success(String(t))} cache entries.`),console.log()}import{existsSync as sg}from"fs";import{join as og}from"path";function Kv(t){t.command("new <name>","Create a new project from starter kit").action(async e=>{let i=og(process.cwd(),e);sg(i)&&(console.log(),v.error(`Directory already exists: ${e}`),console.log(),process.exit(1)),console.log(),console.log(h.default.bold(a.geminiPurple("Creating New Project"))),console.log(),v.info(`Name: ${a.primary(e)}`);let n=await Ki();n||(v.error("Failed to fetch latest starter kit."),console.log(),process.exit(1)),v.info(`Fetching latest starter kit (v${n.version})...`);let r=await pn(n),s=await kn({source:r,destination:i,strip:1});s.success?(console.log(),v.success(`Project ${a.primary(e)} created successfully!`),console.log(`
|
|
23
52
|
Next steps:
|
|
24
53
|
cd ${a.primary(e)}
|
|
25
54
|
gk init
|
|
26
|
-
`)):(
|
|
27
|
-
`);
|
|
28
|
-
`);if(i.length<2)return[];let n=i[0].split(",").map(o=>o.trim()),r=[];for(let o=1;o<i.length;o++){let s=AI(i[o]),c={};n.forEach((l,v)=>{c[l]=s[v]?.trim()||""}),r.push(c)}return r}function uI(t,e,i,n,r){if(!li(t))return[];let o=ac(t),s=o.map(A=>e.map(u=>String(A[u]||"")).join(" ")),c=new Mo;c.fit(s);let l=c.score(n),v=[];for(let[A,u]of l.slice(0,r))if(u>0){let I=o[A],E={};for(let f of i)f in I&&(E[f]=I[f]);E._score=Math.round(u*1e4)/1e4,v.push(E)}return v}function cc(){let t=Dn(sc,"synonyms.csv");if(!li(t))return new Map;let e=ac(t),i=new Map;for(let n of e){let r=(n.word||"").toLowerCase().trim(),o=(n.synonyms||"").toLowerCase().trim();r&&o&&i.set(r,o.split(",").map(s=>s.trim()))}return i}function Sv(t,e){e||(e=cc());let i=t.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/),n=new Set(i);for(let r of i){let o=e.get(r);o&&o.forEach(s=>n.add(s))}return Array.from(n).join(" ")}function lc(t){let e=t.toLowerCase();for(let[i,n]of Object.entries(lI))for(let r of n)if(e.includes(r))return i;return"standard"}function vc(t){let e=t.toLowerCase(),n=e.split(/\s+/)[0]||"",r=[[/system architecture/,"plan"],[/design.*architecture/,"plan"],[/architect.*system/,"plan"],[/create.*roadmap/,"plan"],[/build.*roadmap/,"plan"],[/create.*strategy/,"plan"],[/stunning/,"design"],[/gorgeous/,"design"],[/beautiful.*ui/,"design"],[/beautiful.*component/,"design"],[/beautiful.*page/,"design"],[/write.*documentation/,"docs"],[/write.*docs/,"docs"],[/create.*documentation/,"docs"],[/research.*codebase/,"research"],[/deep research/,"research"]];for(let[v,A]of r)if(typeof v=="string"?e.includes(v):v.test(e))return A;let o={implement:"execute",build:"execute",create:"execute",add:"execute",make:"execute",code:"execute",develop:"execute",write:"execute",setup:"execute",configure:"execute",test:"test",verify:"test",validate:"test",debug:"debug",fix:"debug",troubleshoot:"debug",review:"review",audit:"review",document:"docs",plan:"plan",design:"design",research:"research",analyze:"research",investigate:"research"};if(n in o)return o[n];let s=[["best practices","research"],["how does","research"],["how do","research"],["what is","research"],["why is","research"],["compare","research"],["investigate","research"],["research","research"],["understand","research"],["system architecture","plan"],["implementation plan","plan"],["roadmap","plan"],["strategy for","plan"],["blueprint","plan"],["fix the","debug"],["debug the","debug"],["not working","debug"],["is broken","debug"],["error in","debug"],["fix bug","debug"],["test the","test"],["run tests","test"],["verify the","test"],["review the","review"],["audit the","review"],["check code","review"],["document the","docs"],["write docs","docs"],["api documentation","docs"]];for(let[v,A]of s)if(e.includes(v))return A;let c={debug:["fix","debug","troubleshoot","error","issue","bug","broken","failing","crash"],review:["review","audit","assess","check code","pr review","security audit"],test:["test","verify","validate","qa","coverage","unit test","e2e test"],design:["beautiful","stunning","gorgeous","ui design","ux design","mockup","layout"],docs:["document","documentation","readme","api docs","technical writing"],git:["commit","push","pull","merge","branch","git","stage"],manage:["status","progress","track","milestone","sprint"],plan:["plan","architect","roadmap","strategy","architecture design"],execute:["implement","build","create","add","make","code","develop"],research:["research","investigate","explore","study","analyze","examine","learn"]},l={};for(let[v,A]of Object.entries(c)){let u=A.filter(I=>e.includes(I)).length;u>0&&(l[v]=u)}return Object.keys(l).length>0?Object.entries(l).sort((v,A)=>A[1]-v[1])[0][0]:"execute"}function Ac(t){let e=t.toLowerCase(),i=[["flutter","mobile"],["react native","mobile"],["swift","mobile"],["kotlin","mobile"],["ios app","mobile"],["android app","mobile"],["next.js","fullstack"],["nextjs","fullstack"],["nuxt","fullstack"],["sveltekit","fullstack"],["remix","fullstack"],["server component","fullstack"],["openai","ai"],["anthropic","ai"],["claude","ai"],["langchain","ai"],["llm","ai"],["chatbot","ai"],["rag","ai"],["embedding","ai"],["gpt","ai"],["angular","frontend"],["react","frontend"],["vue","frontend"],["svelte","frontend"],["tailwind","frontend"],["nestjs","backend"],["express","backend"],["fastify","backend"],["hono","backend"],["fastapi","backend"],["websocket","backend"],["shopify","ecommerce"],["product catalog","ecommerce"],["checkout flow","ecommerce"],["stripe","payment"],["paypal","payment"],["subscription","payment"],["billing","payment"],["oauth","auth"],["authentication","auth"],["login","auth"],["signup","auth"],["prisma","database"],["drizzle","database"],["postgresql","database"],["mongodb","database"],["mysql","database"],["pdf","media"],["image","media"],["video","media"],["audio","media"],["codebase","codebase"],["repository","codebase"]];for(let[o,s]of i)if(e.includes(o))return s;let n={auth:["login","signup","authentication","oauth","jwt","session","password","2fa"],payment:["payment","checkout","billing","stripe","subscription","invoice","cart"],database:["database","sql","query","migration","schema","prisma","postgresql"],frontend:["ui","component","react","vue","css","tailwind","button","form","modal"],backend:["api","endpoint","server","service","route","rest","graphql","middleware"],mobile:["mobile","ios","android","react native","flutter","app","native"],fullstack:["fullstack","nextjs","next.js","nuxt","sveltekit","app router"],ecommerce:["ecommerce","shopify","store","product","cart","checkout","order"],media:["image","video","audio","media","upload","file","ocr"],ai:["ai","llm","gpt","claude","machine learning","embedding","vector","openai"],quality:["code review","lint","test","coverage","quality","refactor"],codebase:["codebase","repository","repo","project structure"],general:[]},r={};for(let[o,s]of Object.entries(n)){let c=s.filter(l=>e.includes(l)).length;c>0&&(r[o]=c)}return Object.keys(r).length>0?Object.entries(r).sort((o,s)=>s[1]-o[1])[0][0]:"general"}function Yv(t,e=xv,i=!0){let n=Gv.combination,r=Dn(sc,n.file),o=t;if(i){let c=cc();o=Sv(t,c)}let s=uI(r,n.searchCols,n.outputCols,o,e);return{query:t,expandedQuery:i?o:void 0,detectedIntent:vc(t),detectedDomain:Ac(t),detectedComplexity:lc(t),count:s.length,results:s}}function rc(t,e,i,n=xv,r=!0){let o=Gv.combination,s=Dn(sc,o.file);if(!li(s))return{results:[],count:0};let c=ac(s);if(e&&(c=c.filter(E=>(E.intent||"").toLowerCase()===e.toLowerCase())),i&&(c=c.filter(E=>(E.domain||"").toLowerCase()===i.toLowerCase())),c.length===0)return{results:[],count:0};let l=t;if(r){let E=cc();l=Sv(t,E)}let v=c.map(E=>o.searchCols.map(f=>String(E[f]||"")).join(" ")),A=new Mo;A.fit(v);let u=A.score(l),I=[];for(let[E,f]of u.slice(0,n))if(f>0){let R=c[E],h={};for(let H of o.outputCols)H in R&&(h[H]=R[H]);h._score=Math.round(f*1e4)/1e4,I.push(h)}return{results:I,count:I.length}}function mI(t){let e=vc(t),i=Ac(t),n=lc(t);if(["debug","review","test","design","docs","research","plan"].includes(e)){let A=rc(t,e,void 0,1,!0);if(A.results.length>0){let u=A.results[0],E=(u.skills||"").split("|").map(f=>f.trim()).filter(Boolean);return{agent:nc[e]||u.agent||"code-executor",skills:E,intent:e,domain:u.domain||i,complexity:u.complexity||n,score:u._score||0,fallback:!1,description:u.description||"",useWhen:u.use_when||""}}}if(e==="execute"&&["mobile","ai","payment","ecommerce","media","auth","database","fullstack"].includes(i)){let A=rc(t,"execute",i,1,!0);if(A.results.length>0){let u=A.results[0];return{agent:"code-executor",skills:(u.skills||"").split("|").map(f=>f.trim()).filter(Boolean),intent:e,domain:i,complexity:u.complexity||n,score:u._score||0,fallback:!1,description:u.description||"",useWhen:u.use_when||""}}}let s=Yv(t,1,!0);if(s.count===0){let A=nc[e]||"code-executor",u=vI[i]||["research"];return{agent:A,skills:u,intent:e,domain:i,complexity:n,score:0,fallback:!0,description:`Fallback combination based on detected intent (${e}) and domain (${i})`}}let c=s.results[0],v=(c.skills||"").split("|").map(A=>A.trim()).filter(Boolean);return{agent:c.agent||"code-executor",skills:v,intent:c.intent||e,domain:c.domain||i,complexity:c.complexity||n,score:c._score||0,fallback:!1,description:c.description||"",useWhen:c.use_when||""}}function Wv(t,e){let{top:i=5,forceIntent:n,forceDomain:r,maxSkills:o}=e||{};if(n||r)return rc(t,n,r,i,!0).results.map(l=>{let A=(l.skills||"").split("|").map(u=>u.trim()).filter(Boolean);return o&&(A=A.slice(0,o)),{agent:n?nc[n]:l.agent||"code-executor",skills:A,intent:l.intent||n||vc(t),domain:l.domain||r||Ac(t),complexity:l.complexity||lc(t),score:l._score||0,fallback:!1,description:l.description||"",useWhen:l.use_when||""}});let s=Yv(t,i,!0);return s.count===0?[mI(t)]:s.results.map(c=>{let v=(c.skills||"").split("|").map(A=>A.trim()).filter(Boolean);return o&&(v=v.slice(0,o)),{agent:c.agent||"code-executor",skills:v,intent:c.intent||s.detectedIntent,domain:c.domain||s.detectedDomain,complexity:c.complexity||s.detectedComplexity,score:c._score||0,fallback:!1,description:c.description||"",useWhen:c.use_when||""}})}function Mv(t){let e=Bt(t),i=[];if(!li(e))return i;let n=cI(e,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>r.name);for(let r of n){let o=Dn(e,r,"SKILL.md");if(li(o)){let s=oc(o,"utf-8");i.push({name:r,path:o,content:s})}}return i}function Cv(t,e){let i=Bt(e),n=Dn(i,t,"SKILL.md");return li(n)?oc(n,"utf-8"):null}import{existsSync as EI,readFileSync as II}from"fs";function N(t=process.cwd()){let e={ACTIVE_GK_SESSION_ID:"",GK_PROJECT_HASH:"",PROJECT_DIR:"",ACTIVE_GEMINI_SESSION_ID:"",GEMINI_PROJECT_HASH:"",GEMINI_PARENT_ID:"",ACTIVE_PLAN:"",SUGGESTED_PLAN:"",PLAN_DATE_FORMAT:""},i=bt(t);if(!EI(i))return e;try{let n=II(i,"utf-8"),r=n.match(/^ACTIVE_GK_SESSION_ID=(.*)$/m);r&&(e.ACTIVE_GK_SESSION_ID=r[1].trim());let o=n.match(/^GK_PROJECT_HASH=(.*)$/m);o&&(e.GK_PROJECT_HASH=o[1].trim());let s=n.match(/^PROJECT_DIR=(.*)$/m);s&&(e.PROJECT_DIR=s[1].trim());let c=n.match(/^ACTIVE_GEMINI_SESSION_ID=(.*)$/m);c&&(e.ACTIVE_GEMINI_SESSION_ID=c[1].trim());let l=n.match(/^GEMINI_PROJECT_HASH=(.*)$/m);l&&(e.GEMINI_PROJECT_HASH=l[1].trim());let v=n.match(/^GEMINI_PARENT_ID=(.*)$/m);v&&(e.GEMINI_PARENT_ID=v[1].trim());let A=n.match(/^ACTIVE_PLAN=(.*)$/m);A&&(e.ACTIVE_PLAN=A[1].trim());let u=n.match(/^SUGGESTED_PLAN=(.*)$/m);u&&(e.SUGGESTED_PLAN=u[1].trim());let I=n.match(/^PLAN_DATE_FORMAT=(.*)$/m);I&&(e.PLAN_DATE_FORMAT=I[1].trim())}catch{}return e}function vi(t=process.cwd()){return N(t).ACTIVE_GK_SESSION_ID||void 0}function at(t=process.cwd()){let e=N(t);return e.PROJECT_DIR?e.PROJECT_DIR:rn(t)}function Co(t=process.cwd()){return N(t).GEMINI_PROJECT_HASH||void 0}function wn(t=process.cwd()){return N(t).ACTIVE_PLAN||void 0}import{existsSync as kv,mkdirSync as jI,writeFileSync as uc,readFileSync as gI,renameSync as xI,unlinkSync as GI}from"fs";import{execSync as SI}from"child_process";import{join as YI}from"path";import{createHash as pI}from"crypto";function fI(t){return pI("sha256").update(t).digest("hex")}function hI(t){return fI(t).substring(0,8)}function Ov(t){let e=t.replace(/\\/g,"/").toLowerCase();return hI(e)}function Oo(t,e){let i=Date.now().toString(36),n=Math.random().toString(36).substring(2,6);return`${t}-${e}-${i}-${n}`}import{existsSync as Uv,readFileSync as Kv,readdirSync as dI}from"fs";import{join as RI}from"path";function Ce(t,e){if(!t||!e)return null;let i=Zt(t,e);if(!Uv(i))return null;try{let n=Kv(i,"utf-8");return JSON.parse(n)}catch{return null}}function Vv(t,e={}){let{limit:i=10,status:n="all"}=e,r=we(t);if(!Uv(r))return[];let o=[];try{let s=dI(r).filter(c=>c.startsWith("gk-session-")&&c.endsWith(".json"));for(let c of s){let l=RI(r,c),v=Kv(l,"utf-8"),A=JSON.parse(v);n!=="all"&&(A.agents?.find(E=>E.agentType==="Main Agent")?.status||"active")!==n||o.push(A)}}catch{}return o.sort((s,c)=>new Date(c.initTimestamp).getTime()-new Date(s.initTimestamp).getTime()),o.slice(0,i)}function zI(t,e,i={}){let n=Ce(t,e);if(!n||!n.agents)return[];let r=n.agents;return i.agentType&&(r=r.filter(o=>o.agentType===i.agentType)),i.status&&(r=r.filter(o=>o.status===i.status)),r}function Nv(t,e){let i=zI(t,e),n={total:i.length,active:0,completed:0,failed:0,mainAgents:0,subAgents:0,totalDurationMs:0};return i.forEach(r=>{r.status==="active"?n.active++:r.status==="completed"?n.completed++:r.status==="failed"&&n.failed++,r.agentType==="Main Agent"?n.mainAgents++:n.subAgents++,r.startTime&&r.endTime&&(n.totalDurationMs+=new Date(r.endTime).getTime()-new Date(r.startTime).getTime())}),n}function WI(t){try{let e=`powershell -Command "$p = Get-CimInstance Win32_Process -Filter 'ProcessId=${t}'; Write-Output $p.ParentProcessId; Write-Output $p.Name"`,n=SI(e,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim().split(/\r?\n/),r=parseInt(n[0],10),o=n[1]||null;return{parentPid:!isNaN(r)&&r>0?r:null,processName:o}}catch{return{parentPid:null,processName:null}}}function MI(t){return t?["powershell.exe","pwsh.exe","cmd.exe","bash.exe","zsh.exe","sh.exe","fish.exe"].includes(t.toLowerCase()):!1}function CI(t){if(!t)return!1;let e=t.toLowerCase();return["code.exe","code - insiders.exe","cursor.exe","windsurf.exe","positron.exe","idea64.exe","idea.exe","webstorm64.exe","webstorm.exe","pycharm64.exe","pycharm.exe","phpstorm64.exe","phpstorm.exe","goland64.exe","goland.exe","rustrover64.exe","rustrover.exe","rider64.exe","rider.exe","clion64.exe","clion.exe","datagrip64.exe","datagrip.exe","fleet.exe","windowsterminal.exe","sublime_text.exe","zed.exe","terminal.app"].includes(e)}function mc(){let t=process.ppid;try{if(process.platform==="win32"){let e=t,i=null;for(let n=0;n<10;n++){let{parentPid:r,processName:o}=WI(e);if(MI(o)&&(i=e),CI(o)&&i)return i;if(!r||r<=4)break;e=r}return i||t}else return t}catch{}return t}function Uo(t){kv(t)||jI(t,{recursive:!0})}function OI(t){let{agents:e,...i}=t;return{...i,agents:e||[]}}function Ec(t,e,i){if(!t||!e)return!1;let n=we(t);Uo(n);let r=Zt(t,e),o=`${r}.tmp`;try{let s=OI(i);return uc(o,JSON.stringify(s,null,2),"utf8"),xI(o,r),!0}catch{try{GI(o)}catch{}return!1}}function Fv(t){try{let e=bt(),i=["# Auto-generated by gemkit-cli",`# Updated at: ${new Date().toISOString()}`,"","# GEMKIT IDs",`ACTIVE_GK_SESSION_ID=${t.gkSessionId||""}`,`GK_PROJECT_HASH=${t.gkProjectHash||""}`,`PROJECT_DIR=${t.projectDir||""}`,"","# GEMINI IDs (mapped)",`ACTIVE_GEMINI_SESSION_ID=${t.geminiSessionId||""}`,`GEMINI_PROJECT_HASH=${t.geminiProjectHash||""}`,"","# PLAN INFO",`ACTIVE_PLAN=${t.activePlan||""}`,`SUGGESTED_PLAN=${t.suggestedPlan||""}`,`PLAN_DATE_FORMAT=${t.planDateFormat||""}`,""].join(`
|
|
29
|
-
`)
|
|
30
|
-
`)}function Tv(){console.log(),console.log(p.default.bold(a.geminiPurple("Agent Management"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent")} <subcommand> [options]`),console.log(),console.log("Subcommands:"),console.log(` ${a.primary("list")} List all agent profiles`),console.log(` ${a.primary("info")} <name> Show agent profile details`),console.log(` ${a.primary("search")} "<task>" Find best agent+skills for a task`),console.log(` ${a.primary("spawn")} Spawn a sub-agent`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk agent list")}`),console.log(` ${a.dim("gk agent info researcher")}`),console.log(` ${a.dim('gk agent search "implement authentication"')}`),console.log(` ${a.dim('gk agent spawn -a researcher -p "research best practices"')}`),console.log(),console.log("Run with subcommand for specific help:"),console.log(` ${a.dim("gk agent list --help")}`),console.log(` ${a.dim("gk agent spawn --help")}`),console.log()}function DI(){console.log(),console.log(p.default.bold(a.geminiPurple("gk agent list"))),console.log(a.dim("List all available agent profiles")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent list")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log()}function wI(){console.log(),console.log(p.default.bold(a.geminiPurple("gk agent info"))),console.log(a.dim("Show detailed information about an agent profile")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent info")} <name> [options]`),console.log(),console.log("Arguments:"),console.log(` ${a.dim("<name>")} Agent profile name (without .md extension)`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log(),console.log("Example:"),console.log(` ${a.dim("gk agent info researcher")}`),console.log()}function TI(){console.log(),console.log(p.default.bold(a.geminiPurple("gk agent search"))),console.log(a.dim("Find best agent+skills combination for a task using BM25 search")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent search")} "<task>" [options]`),console.log(),console.log("Arguments:"),console.log(` ${a.dim("<task>")} Task description to search for`),console.log(),console.log("Options:"),console.log(` ${a.dim("-n, --limit <n>")} Number of results (default: 5)`),console.log(` ${a.dim("-i, --intent <i>")} Force intent: research|plan|execute|debug|review|test|design|docs`),console.log(` ${a.dim("-d, --domain <d>")} Force domain: frontend|backend|auth|payment|database|mobile|ai|etc.`),console.log(` ${a.dim("--max-skills <n>")} Maximum skills to include`),console.log(` ${a.dim("--json")} Output as JSON`),console.log(),console.log("Examples:"),console.log(` ${a.dim('gk agent search "implement user authentication"')}`),console.log(` ${a.dim('gk agent search "debug the login form" -i debug')}`),console.log(` ${a.dim('gk agent search "build a payment page" -d payment')}`),console.log()}function Xv(){console.log(),console.log(p.default.bold(a.geminiPurple("gk agent spawn"))),console.log(a.dim("Spawn a sub-agent with Gemini CLI")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent spawn")} -p "<prompt>" [options]`),console.log(),console.log("Required:"),console.log(` ${a.dim("-p, --prompt <text>")} Task prompt for the agent`),console.log(),console.log("Options:"),console.log(` ${a.dim("-a, --agent <name>")} Agent profile name (from .gemini/agents/)`),console.log(` ${a.dim("-s, --skills <list>")} Comma-separated skill names to inject`),console.log(` ${a.dim("-c, --context <files>")} Context files (@file syntax)`),console.log(` ${a.dim("-m, --model <model>")} Model override (default: from config)`),console.log(` ${a.dim("--music")} Play elevator music while waiting`),console.log(` ${a.dim("--no-music")} Disable elevator music`),console.log(` ${a.dim("--music-file <path>")} Custom music file path`),console.log(),console.log("Examples:"),console.log(` ${a.dim('gk agent spawn -p "fix the login bug"')}`),console.log(` ${a.dim('gk agent spawn -a researcher -p "research React best practices"')}`),console.log(` ${a.dim('gk agent spawn -a code-executor -s "frontend-design" -p "build a dashboard"')}`),console.log(` ${a.dim('gk agent spawn -p "implement auth" -m gemini-2.5-pro --music')}`),console.log()}function Hv(t){t.command("agent [subcommand] [arg]","Agent management (list, info, search, spawn)").alias("a").option("--json","[all] Output as JSON").option("-n, --limit <n>","[search] Number of results (default: 5)",{default:5}).option("-i, --intent <intent>","[search] Force intent: research|plan|execute|debug|review|test|design|docs").option("-d, --domain <domain>","[search] Force domain: frontend|backend|auth|payment|database|mobile|ai").option("--max-skills <n>","[search] Maximum skills to include").option("-a, --agent <name>","[spawn] Agent profile name from .gemini/agents/").option("-p, --prompt <text>","[spawn] Task prompt (required for spawn)").option("-s, --skills <list>","[spawn] Comma-separated skill names").option("-c, --context <files>","[spawn] Context files (@file syntax)").option("-m, --model <model>","[spawn] Model override").option("--music","[spawn] Play elevator music while waiting").option("--no-music","[spawn] Disable elevator music").option("--music-file <path>","[spawn] Custom music file path").action(async(e,i,n)=>{if(n.help||n.h)switch(e){case"list":DI();return;case"info":wI();return;case"search":TI();return;case"spawn":Xv();return;default:Tv();return}switch(e){case"list":await XI(n);break;case"info":i||(console.log(),m.error("Agent profile name required"),console.log(a.dim("Usage: gk agent info <name>")),console.log(),process.exit(1)),await HI(i,n);break;case"search":i||(console.log(),m.error("Search query required"),console.log(a.dim('Usage: gk agent search "<task>"')),console.log(),process.exit(1)),await LI(i,n);break;case"spawn":await _I(n);break;default:Tv()}})}async function XI(t){let e=Wo();if(t.json){console.log(JSON.stringify(e,null,2));return}if(console.log(),console.log(p.default.bold(a.geminiPurple("Available Agents"))),console.log(),e.length===0){m.warn('No agent profiles found. Run "gk init" first.'),console.log();return}for(let i of e)console.log(` ${a.primary(i.name)}`),console.log(` ${a.dim(i.description)}`),console.log(` ${a.dim("Model:")} ${i.model}`),i.skills&&i.skills.length>0&&console.log(` ${a.dim("Skills:")} ${i.skills.join(", ")}`),console.log("");console.log(a.dim(` Total: ${e.length} agents`)),console.log()}async function HI(t,e){let i=ic(t);if(i||(console.log(),m.error(`Agent profile not found: ${t}`),console.log(),process.exit(1)),e.json){console.log(JSON.stringify(i,null,2));return}console.log(),console.log(M.doubleLine()),console.log(p.default.bold(a.geminiPurple(`Agent: ${i.name}`))),console.log(M.doubleLine()),console.log(),console.log(` ${a.dim("Description:")} ${i.description}`),console.log(` ${a.dim("Model:")} ${i.model}`),i.skills?.length&&console.log(` ${a.dim("Skills:")} ${i.skills.join(", ")}`),console.log(` ${a.dim("Path:")} ${i.filePath}`),console.log(),console.log(a.dim("--- Profile Content ---")),console.log(),console.log(a.dim(i.content)),console.log()}async function LI(t,e){let i=Wv(t,{top:e.limit,forceIntent:e.intent,forceDomain:e.domain,maxSkills:e.maxSkills});if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),console.log(p.default.bold(a.geminiPurple(`Search results for: "${t}"`))),console.log(),i.length===0){m.warn("No matching agents found for task."),console.log();return}for(let n=0;n<i.length;n++){let r=i[n],o=r.fallback?a.warn(" [FALLBACK]"):"";console.log(` ${a.success(n+1+".")} ${a.primary(r.agent)}${o} ${a.dim(`(score: ${r.score})`)}`),console.log(` ${a.dim("Intent:")} ${r.intent} ${a.dim("Domain:")} ${r.domain} ${a.dim("Complexity:")} ${r.complexity}`),r.skills.length>0&&console.log(` ${a.dim("Skills:")} ${r.skills.join(" | ")}`),r.description&&console.log(` ${a.dim(r.description)}`),r.useWhen&&console.log(` ${a.dim("Use when:")} ${r.useWhen}`),console.log("")}if(i.length>0){let n=i[0],r=n.skills.length>0?` -s "${n.skills.join(",")}"`:"";console.log(a.dim(" Suggested command:")),console.log(` ${a.primary("gk")} agent spawn -a ${n.agent}${r} -p "${t}"`)}console.log()}async function _I(t){t.prompt||(console.log(),m.error("Prompt is required. Use -p or --prompt"),console.log(),Xv(),process.exit(1));let e=Ve(),i=N(),n=i.ACTIVE_GK_SESSION_ID||null,r=i.ACTIVE_GEMINI_SESSION_ID||null,o=i.ACTIVE_PLAN||null,s=i.SUGGESTED_PLAN||null,c=i.PLAN_DATE_FORMAT||null,l=i.PROJECT_DIR||null,v=null;t.agent&&(v=ic(t.agent),v||(console.log(),m.error(`Agent profile not found: ${t.agent}`),console.log(),process.exit(1)));let A=t.model||v?.model||e.spawn.defaultModel,I=process.argv.includes("--music")||process.argv.includes("--no-music")?t.music:e.spawn.music,E=t.musicFile||e.spawn.musicFile,f=t.skills?.split(",").map(d=>d.trim())||[],R=v?.skills||[],h=[...new Set([...R,...f])],H=t.context?t.context.split(",").flatMap(d=>d.trim().split(/\s+/).filter(G=>G)).filter(d=>d):[];async function ve(d){let G=d,De=!1;if(d.startsWith("@")){let Ae=d.substring(1),At=[Pi(process.cwd(),".docs",Ae),Pi(process.cwd(),".plans",Ae),Pi(process.cwd(),"docs",Ae),Pi(process.cwd(),"plans",Ae),Pi(process.cwd(),Ae)];for(let ut of At)try{await QI(ut),G=ut,De=!0;break}catch{continue}if(!De){let ut=At.map(ui=>` - ${ui}`).join(`
|
|
31
|
-
`);throw new Error(`Context file not found: ${d}
|
|
55
|
+
`)):(v.error(`Failed to create project: ${s.error}`),console.log())})}Xr();Lr();Nn();import{spawn as Jp}from"child_process";import{access as Zp,stat as yp,readdir as qp,readFile as Sa}from"fs/promises";import{join as Je,basename as wp,extname as Dp,relative as Wu}from"path";import{existsSync as Zv,readFileSync as Sg,writeFileSync as Gg,unlinkSync as Mg}from"fs";import{join as Yg}from"path";var Wg=".gk-interactive-session.json";function ru(t,e){let i=e?`.gk-interactive-session-${e}.json`:Wg;return Yg(t||process.cwd(),i)}function Ge(t,e){let i=ru(t,e);if(!Zv(i))return null;try{let n=Sg(i,"utf-8");return JSON.parse(n)}catch{return null}}function $i(t,e,i){let n=ru(e,i);Gg(n,JSON.stringify(t,null,2))}function et(t,e){let i=ru(t,e);Zv(i)&&Mg(i)}function bt(t,e){let i=Ge(t,e);if(!i)return!1;try{return process.kill(i.pid,0),!0}catch{return et(t,e),!1}}function yv(t,e){let i=Ge(t,e);i&&(i.isFirstSend=!1,$i(i,t,e))}au();Do();ju();it();k();en();it();import{existsSync as Cp,mkdirSync as jI,writeFileSync as xu,readFileSync as xI,renameSync as SI,unlinkSync as GI}from"fs";import{execSync as MI}from"child_process";import{join as YI}from"path";k();it();import{existsSync as Gp,readFileSync as Mp,readdirSync as EI}from"fs";import{join as RI}from"path";function nt(t,e){if(!t||!e)return null;let i=Oi(t,e);if(!Gp(i))return null;try{let n=Mp(i,"utf-8");return JSON.parse(n)}catch{return null}}function Yp(t,e={}){let{limit:i=10,status:n="all"}=e,r=xt(t);if(!Gp(r))return[];let s=[];try{let o=EI(r).filter(c=>c.startsWith("gk-session-")&&c.endsWith(".json"));for(let c of o){let l=RI(r,c),u=Mp(l,"utf-8"),m=JSON.parse(u);n!=="all"&&(m.agents?.find(A=>A.agentType==="Main Agent")?.status||"active")!==n||s.push(m)}}catch{}return s.sort((o,c)=>new Date(c.initTimestamp).getTime()-new Date(o.initTimestamp).getTime()),s.slice(0,i)}function zI(t,e,i={}){let n=nt(t,e);if(!n||!n.agents)return[];let r=n.agents;return i.agentType&&(r=r.filter(s=>s.agentType===i.agentType)),i.status&&(r=r.filter(s=>s.status===i.status)),r}function Wp(t,e){let i=zI(t,e),n={total:i.length,active:0,completed:0,failed:0,mainAgents:0,subAgents:0,totalDurationMs:0};return i.forEach(r=>{r.status==="active"?n.active++:r.status==="completed"?n.completed++:r.status==="failed"&&n.failed++,r.agentType==="Main Agent"?n.mainAgents++:n.subAgents++,r.startTime&&r.endTime&&(n.totalDurationMs+=new Date(r.endTime).getTime()-new Date(r.startTime).getTime())}),n}function WI(t){try{let e=`powershell -Command "$p = Get-CimInstance Win32_Process -Filter 'ProcessId=${t}'; Write-Output $p.ParentProcessId; Write-Output $p.Name"`,n=MI(e,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim().split(/\r?\n/),r=parseInt(n[0],10),s=n[1]||null;return{parentPid:!isNaN(r)&&r>0?r:null,processName:s}}catch{return{parentPid:null,processName:null}}}function CI(t){return t?["powershell.exe","pwsh.exe","cmd.exe","bash.exe","zsh.exe","sh.exe","fish.exe"].includes(t.toLowerCase()):!1}function OI(t){if(!t)return!1;let e=t.toLowerCase();return["code.exe","code - insiders.exe","cursor.exe","windsurf.exe","positron.exe","idea64.exe","idea.exe","webstorm64.exe","webstorm.exe","pycharm64.exe","pycharm.exe","phpstorm64.exe","phpstorm.exe","goland64.exe","goland.exe","rustrover64.exe","rustrover.exe","rider64.exe","rider.exe","clion64.exe","clion.exe","datagrip64.exe","datagrip.exe","fleet.exe","windowsterminal.exe","sublime_text.exe","zed.exe","terminal.app"].includes(e)}function Su(){let t=process.ppid;try{if(process.platform==="win32"){let e=t,i=null;for(let n=0;n<10;n++){let{parentPid:r,processName:s}=WI(e);if(CI(s)&&(i=e),OI(s)&&i)return i;if(!r||r<=4)break;e=r}return i||t}else return t}catch{}return t}function Ia(t){Cp(t)||jI(t,{recursive:!0})}function UI(t){let{agents:e,...i}=t;return{...i,agents:e||[]}}function Gu(t,e,i){if(!t||!e)return!1;let n=xt(t);Ia(n);let r=Oi(t,e),s=`${r}.tmp`;try{let o=UI(i);return xu(s,JSON.stringify(o,null,2),"utf8"),SI(s,r),!0}catch{try{GI(s)}catch{}return!1}}function Op(t){try{let e=Wi(),i=["# Auto-generated by gemkit-cli",`# Updated at: ${new Date().toISOString()}`,"","# GEMKIT IDs",`ACTIVE_GK_SESSION_ID=${t.gkSessionId||""}`,`GK_PROJECT_HASH=${t.gkProjectHash||""}`,`PROJECT_DIR=${t.projectDir||""}`,"","# GEMINI IDs (mapped)",`ACTIVE_GEMINI_SESSION_ID=${t.geminiSessionId||""}`,`GEMINI_PROJECT_HASH=${t.geminiProjectHash||""}`,"","# PLAN INFO",`ACTIVE_PLAN=${t.activePlan||""}`,`SUGGESTED_PLAN=${t.suggestedPlan||""}`,`PLAN_DATE_FORMAT=${t.planDateFormat||""}`,""].join(`
|
|
56
|
+
`),n=YI(process.cwd(),".gemini");return Ia(n),xu(e,i,"utf8"),!0}catch{return!1}}function KI(t,e){if(!t||!e)return null;let i=cr(t,e);if(!Cp(i))return null;try{let n=xI(i,"utf-8");return JSON.parse(n)}catch{return null}}function Up(t,e,i){if(!t||!e)return!1;let n=xt(t);Ia(n);let r=cr(t,e);try{return xu(r,JSON.stringify(i,null,2),"utf8"),!0}catch{return!1}}function Kp(t,e,i){let n=KI(t,e);return n||(n={gkProjectHash:e,projectDir:t,projectPath:i||process.cwd(),geminiProjectHash:null,initialized:!0,initTimestamp:new Date().toISOString(),lastActiveTimestamp:new Date().toISOString(),activeGkSessionId:null,sessions:[]},Up(t,e,n)),n}function kI(t,e,i){let n=Kp(t,e);n.activeGkSessionId=i.gkSessionId,n.lastActiveTimestamp=new Date().toISOString();let r=n.sessions.findIndex(s=>s.gkSessionId===i.gkSessionId);if(r>=0){let s=n.sessions[r];n.sessions[r]={gkSessionId:i.gkSessionId,pid:i.pid??s.pid,sessionType:i.sessionType||s.sessionType,appName:i.appName||s.appName,prompt:i.prompt??s.prompt??null,activePlan:i.activePlan??s.activePlan??null,startTime:i.startTime||s.startTime,endTime:i.endTime??s.endTime??null}}else n.sessions.push({gkSessionId:i.gkSessionId,pid:i.pid??null,sessionType:i.sessionType||"gemini",appName:i.appName||"gemini-main",prompt:i.prompt??null,activePlan:i.activePlan??null,startTime:i.startTime||new Date().toISOString(),endTime:i.endTime??null});return n.sessions.sort((s,o)=>{let c=new Date(s.startTime||0).getTime();return new Date(o.startTime||0).getTime()-c}),Up(t,e,n)}function Ea(t,e,i){let n=nt(t,e);if(!n)return!1;let r=i.gkSessionId||e;n.agents=n.agents||[];let s=n.agents.findIndex(o=>o.gkSessionId===r);if(s>=0){let o=n.agents[s];n.agents[s]={...o,model:o.model||i.model||null,prompt:o.prompt||i.prompt||null}}else{let o={gkSessionId:r,pid:i.pid||null,geminiSessionId:i.geminiSessionId||null,geminiProjectHash:i.geminiProjectHash||null,parentGkSessionId:i.parentGkSessionId||null,agentType:i.parentGkSessionId?"Sub Agent":"Main Agent",agentRole:i.agentRole||"main",prompt:i.prompt||null,model:i.model||null,tokenUsage:i.tokenUsage||null,retryCount:i.retryCount||0,resumeCount:i.resumeCount||0,generation:i.generation||0,injected:i.injected||null,startTime:new Date().toISOString(),endTime:null,status:"active",exitCode:null,error:null};n.agents.push(o)}return Gu(t,e,n)}function kp(t,e={}){let i=e.cwd||process.cwd(),n=ge(i),r=ep(i),s=Su(),o=Et(t,s),c={gkSessionId:o,gkProjectHash:r,projectDir:n,geminiSessionId:null,geminiParentId:null,geminiProjectHash:null,initialized:!0,initTimestamp:new Date().toISOString(),sessionType:"non-gemini",appName:t,pid:s,activePlan:e.activePlan||null,suggestedPlan:e.suggestedPlan||null,agents:[]};Ia(xt(n)),Gu(n,o,c),Kp(n,r,i),kI(n,r,{gkSessionId:o,pid:s,sessionType:"non-gemini",appName:t,startTime:c.initTimestamp,activePlan:c.activePlan});let l=B(),m=l.PROJECT_DIR===n&&l.GEMINI_PROJECT_HASH||"";return Op({gkSessionId:o,gkProjectHash:r,projectDir:n,geminiSessionId:"",geminiProjectHash:m,activePlan:c.activePlan||"",suggestedPlan:c.suggestedPlan||"",planDateFormat:""}),{session:c,gkSessionId:o,pid:s,projectDir:n,gkProjectHash:r}}function Vp(t,e,i){let n=nt(t,e);if(!n||(n.activePlan=i,n.suggestedPlan=null,!Gu(t,e,n)))return!1;let r=B();return Op({gkSessionId:e,gkProjectHash:n.gkProjectHash||r.GK_PROJECT_HASH,projectDir:t,geminiSessionId:n.geminiSessionId||r.ACTIVE_GEMINI_SESSION_ID,geminiProjectHash:n.geminiProjectHash||r.GEMINI_PROJECT_HASH,activePlan:i,suggestedPlan:"",planDateFormat:n.planDateFormat||r.PLAN_DATE_FORMAT})}function Np(t){if(!t)return null;let e=t.match(/^(.+)-(\d+)-([a-z0-9]+)-([a-z0-9]{4})$/);return e?{appName:e[1],pid:parseInt(e[2],10),timestamp:e[3],random:e[4]}:null}en();import{spawn as VI,exec as NI}from"child_process";import{existsSync as Ra,readFileSync as Mu,writeFileSync as Yu,unlinkSync as Fp}from"fs";import{join as ja}from"path";import{tmpdir as FI,platform as bp}from"os";var Rt=ja(FI(),"elevator-music.lock"),za=3e4,xa=class{audioFile;loop;volume;process=null;isPlaying=!1;loopInterval=null;hasLock=!1;lockRefreshInterval=null;triedFallback=!1;constructor(e={}){this.audioFile=e.audioFile||this.getDefaultAudioFile(),this.loop=e.loop!==!1,this.volume=e.volume||.5}tryAcquireLock(){let e={pid:process.pid,timestamp:Date.now()};try{return Yu(Rt,JSON.stringify(e),{flag:"wx"}),this.hasLock=!0,this.lockRefreshInterval=setInterval(()=>{this.refreshLock()},za/3),!0}catch(i){return i.code==="EEXIST"?this.tryTakeStaleLock(e):!1}}tryTakeStaleLock(e){try{let i=JSON.parse(Mu(Rt,"utf8"));if(Date.now()-i.timestamp<za&&i.pid!==process.pid)try{return process.kill(i.pid,0),!1}catch{}Fp(Rt);try{return Yu(Rt,JSON.stringify(e),{flag:"wx"}),this.hasLock=!0,this.lockRefreshInterval=setInterval(()=>{this.refreshLock()},za/3),!0}catch{return!1}}catch{return!1}}refreshLock(){if(this.hasLock)try{let e={pid:process.pid,timestamp:Date.now()};Yu(Rt,JSON.stringify(e),{flag:"w"})}catch{}}releaseLock(){if(this.lockRefreshInterval&&(clearInterval(this.lockRefreshInterval),this.lockRefreshInterval=null),!!this.hasLock){try{Ra(Rt)&&JSON.parse(Mu(Rt,"utf8")).pid===process.pid&&Fp(Rt)}catch{}this.hasLock=!1}}getDefaultAudioFile(){let e=[ja(process.cwd(),".gemini","extensions","spawn-agent","assets","golden-coast-melody.wav"),ja(process.cwd(),".gemini","assets","elevator_music.wav"),ja(process.cwd(),"assets","elevator_music.wav")];for(let i of e)if(Ra(i))return i;return null}getPlayCommand(){if(!this.audioFile)return null;switch(bp()){case"win32":return{command:"powershell",args:["-NoProfile","-Command",`$player = New-Object System.Media.SoundPlayer '${this.audioFile}'; $player.PlaySync()`],shell:!1};case"darwin":return{command:"afplay",args:["-v",String(this.volume),this.audioFile],shell:!1};case"linux":return{command:"paplay",args:["--volume",String(Math.round(this.volume*65536)),this.audioFile],shell:!1,fallback:{command:"aplay",args:["-q",this.audioFile],shell:!1}};default:return null}}start(e={}){if(!this.audioFile||!Ra(this.audioFile))return!1;if(this.isPlaying)return!0;if(!e.force&&!this.tryAcquireLock())return!1;let i=this.getPlayCommand();return i?(this.isPlaying=!0,this.playLoop(i),!0):(this.releaseLock(),!1)}playLoop(e){if(!this.isPlaying)return;let i=n=>{this.process=VI(n.command,n.args,{stdio:["ignore","ignore","pipe"],windowsHide:!0,shell:n.shell}),this.process.stderr?.on("data",()=>{n.fallback&&!this.triedFallback&&(this.triedFallback=!0,this.process?.kill(),i(n.fallback))}),this.process.on("close",()=>{this.isPlaying&&this.loop&&(this.loopInterval=setTimeout(()=>{this.playLoop(e)},100))}),this.process.on("error",()=>{n.fallback&&!this.triedFallback&&(this.triedFallback=!0,i(n.fallback))})};i(e)}stop(){this.isPlaying=!1,this.loopInterval&&(clearTimeout(this.loopInterval),this.loopInterval=null),this.process&&(bp()==="win32"?NI(`taskkill /pid ${this.process.pid} /T /F`,{windowsHide:!0}):this.process.kill("SIGTERM"),this.process=null),this.releaseLock()}get playing(){return this.isPlaying}static isAnyPlaying(){try{if(!Ra(Rt))return!1;let e=JSON.parse(Mu(Rt,"utf8"));if(Date.now()-e.timestamp>=za)return!1;try{return process.kill(e.pid,0),!0}catch{return!1}}catch{return!1}}};k();ga();var Pp=[{icon:"\u{1F4A9}",action:"Pooping out some code"},{icon:"\u{1F373}",action:"Cooking up solutions"},{icon:"\u{1F9E0}",action:"Brain cells working overtime"},{icon:"\u26A1",action:"Neurons firing rapidly"},{icon:"\u{1F52E}",action:"Consulting the crystal ball"},{icon:"\u{1F3B0}",action:"Rolling the dice on this one"},{icon:"\u{1F680}",action:"Launching into hyperthink"},{icon:"\u{1F32A}\uFE0F",action:"Brainstorming intensifies"},{icon:"\u{1F3AA}",action:"Juggling multiple thoughts"},{icon:"\u{1F527}",action:"Tightening the logic bolts"},{icon:"\u{1F3A8}",action:"Painting the solution"},{icon:"\u{1F3D7}\uFE0F",action:"Building something awesome"},{icon:"\u{1F52C}",action:"Analyzing under the microscope"},{icon:"\u{1F9EA}",action:"Mixing the secret sauce"},{icon:"\u{1F3AF}",action:"Aiming for perfection"},{icon:"\u{1F9D9}",action:"Casting coding spells"},{icon:"\u{1F419}",action:"Multitasking like an octopus"},{icon:"\u{1F9BE}",action:"Flexing the AI muscles"},{icon:"\u{1F308}",action:"Finding the pot of gold"},{icon:"\u{1F3B8}",action:"Rocking out some logic"}],Qp=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function bI(t){let e=0,i=0,n=0,r=process.stdout.isTTY,s=setInterval(()=>{n++,i++;let o=n%10===0;o&&e++;let c=Pp[e%Pp.length],u=`${Qp[i%Qp.length]} ${c.icon} ${c.action}... ${n}s`;r?process.stdout.write(`\r\x1B[K${u}`):(n===1||o)&&console.log(u)},1e3);return{interval:s,stop:()=>{clearInterval(s),r&&process.stdout.write("\r\x1B[K")}}}function PI(t){let{agentType:e="Sub Agent",agentRole:i="unknown",parentSessionId:n=null,activePlan:r=null,projectDir:s=null}=t,o=[`Agent Type: ${e}`,`Agent Role: ${i}`];return n&&o.push(`Parent Session: ${n.slice(0,8)}...`),s&&o.push(`Project: ${s}`),r&&o.push(`Active Plan: ${r}`),o.join(`
|
|
57
|
+
`)}function Bp(){console.log(),console.log(h.default.bold(a.geminiPurple("Agent Management"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent")} <subcommand> [options]`),console.log(),console.log("Subcommands:"),console.log(` ${a.primary("list")} List all agent profiles`),console.log(` ${a.primary("info")} <name> Show agent profile details`),console.log(` ${a.primary("search")} "<task>" Find best agent+skills for a task`),console.log(` ${a.primary("spawn")} Spawn a sub-agent (non-interactive)`),console.log(),console.log("Interactive Mode:"),console.log(` ${a.primary("start")} Start interactive session`),console.log(` ${a.primary("send")} "<prompt>" Send prompt to session`),console.log(` ${a.primary("wait")} [timeout] Wait for completion`),console.log(` ${a.primary("exchange")} Get structured output`),console.log(` ${a.primary("pending")} Check tool confirmations`),console.log(` ${a.primary("read")} [lines] Read raw output`),console.log(` ${a.primary("status")} Session status`),console.log(` ${a.primary("stop")} Stop session`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk agent list")}`),console.log(` ${a.dim('gk agent spawn -a researcher -p "research best practices"')}`),console.log(` ${a.dim("gk agent start -a researcher -s research")}`),console.log(` ${a.dim('gk agent send "analyze the codebase"')}`),console.log(),console.log("Run with subcommand for specific help:"),console.log(` ${a.dim("gk agent spawn --help")}`),console.log(` ${a.dim("gk agent start --help")}`),console.log()}function QI(){console.log(),console.log(h.default.bold(a.geminiPurple("gk agent list"))),console.log(a.dim("List all available agent profiles")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent list")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log()}function BI(){console.log(),console.log(h.default.bold(a.geminiPurple("gk agent info"))),console.log(a.dim("Show detailed information about an agent profile")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent info")} <name> [options]`),console.log(),console.log("Arguments:"),console.log(` ${a.dim("<name>")} Agent profile name (without .md extension)`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log(),console.log("Example:"),console.log(` ${a.dim("gk agent info researcher")}`),console.log()}function JI(){console.log(),console.log(h.default.bold(a.geminiPurple("gk agent search"))),console.log(a.dim("Find best agent+skills combination for a task using BM25 search")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent search")} "<task>" [options]`),console.log(),console.log("Arguments:"),console.log(` ${a.dim("<task>")} Task description to search for`),console.log(),console.log("Options:"),console.log(` ${a.dim("-n, --limit <n>")} Number of results (default: 5)`),console.log(` ${a.dim("-i, --intent <i>")} Force intent: research|plan|execute|debug|review|test|design|docs`),console.log(` ${a.dim("-d, --domain <d>")} Force domain: frontend|backend|auth|payment|database|mobile|ai|etc.`),console.log(` ${a.dim("--max-skills <n>")} Maximum skills to include`),console.log(` ${a.dim("--json")} Output as JSON`),console.log(),console.log("Examples:"),console.log(` ${a.dim('gk agent search "implement user authentication"')}`),console.log(` ${a.dim('gk agent search "debug the login form" -i debug')}`),console.log(` ${a.dim('gk agent search "build a payment page" -d payment')}`),console.log()}function Tp(){console.log(),console.log(h.default.bold(a.geminiPurple("gk agent spawn"))),console.log(a.dim("Spawn a sub-agent with Gemini or Claude CLI")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent spawn")} -p "<prompt>" [options]`),console.log(),console.log("Required:"),console.log(` ${a.dim("-p, --prompt <text>")} Task prompt for the agent`),console.log(),console.log("Options:"),console.log(` ${a.dim("-a, --agent <name>")} Agent profile name`),console.log(` ${a.dim("-s, --skills <list>")} Comma-separated skill names to inject`),console.log(` ${a.dim("-c, --context <files>")} Context files (@file syntax)`),console.log(` ${a.dim("-m, --model <model>")} Model override (default: from config)`),console.log(` ${a.dim("-t, --tools <list>")} Comma-separated tools to auto-approve`),console.log(` ${a.dim("--cli <provider>")} CLI provider: gemini (default) or claude`),console.log(` ${a.dim("--music")} Play elevator music while waiting`),console.log(` ${a.dim("--no-music")} Disable elevator music`),console.log(` ${a.dim("--music-file <path>")} Custom music file path`),console.log(),console.log("CLI Providers:"),console.log(` ${a.dim("gemini")} Uses Gemini CLI (default). Loads from .gemini/agents/, falls back to .claude/agents/`),console.log(` ${a.dim("claude")} Uses Claude CLI. Loads from .claude/agents/, falls back to .gemini/agents/`),console.log(` ${a.dim("Models and tools are automatically mapped between providers when using fallback.")}`),console.log(),console.log("Examples:"),console.log(` ${a.dim('gk agent spawn -p "fix the login bug"')}`),console.log(` ${a.dim('gk agent spawn -a researcher -p "research React best practices"')}`),console.log(` ${a.dim('gk agent spawn -a code-executor -s "frontend-design" -p "build a dashboard"')}`),console.log(` ${a.dim('gk agent spawn -p "implement auth" -m gemini-2.5-pro --music')}`),console.log(` ${a.dim('gk agent spawn -a researcher -t "list_directory,read_file,glob" -p "analyze code"')}`),console.log(` ${a.dim('gk agent spawn --cli claude -a researcher -p "analyze codebase"')}`),console.log(),console.log("Allowed Tools:"),console.log(` ${a.dim("Tools can be defined in agent frontmatter (tools: tool1, tool2)")}`),console.log(` ${a.dim("or passed via CLI. Both sources are merged and deduplicated.")}`),console.log(` ${a.dim("Gemini tools: list_directory, read_file, write_file, glob, run_shell_command(*)")}`),console.log(` ${a.dim("Claude tools: Read, Write, Edit, Bash, Glob, Grep, WebFetch, WebSearch")}`),console.log()}function ZI(){console.log(),console.log(h.default.bold(a.geminiPurple("gk agent start"))),console.log(a.dim("Start a single interactive AI session")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk agent start")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("-a, --agent <name>")} Agent profile name`),console.log(` ${a.dim("-s, --skills <list>")} Comma-separated skill names`),console.log(` ${a.dim("-c, --context <files>")} Context files (@file syntax)`),console.log(` ${a.dim("-m, --model <model>")} Model override`),console.log(` ${a.dim("-t, --tools <list>")} Comma-separated tools to allow`),console.log(` ${a.dim("--cli <provider>")} CLI provider: gemini (default) or claude`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk agent start -a researcher -s research")}`),console.log(` ${a.dim("gk agent start --cli claude -a code-executor")}`),console.log(` ${a.dim('gk agent start -m gemini-2.5-pro -t "read_file,write_file"')}`),console.log(),console.log("After starting:"),console.log(` ${a.dim('gk agent send "your prompt"')}`),console.log(` ${a.dim("gk agent wait")}`),console.log(` ${a.dim("gk agent exchange")}`),console.log(` ${a.dim("gk agent stop")}`),console.log(),console.log("For team mode, use: gk team start --name <agent>"),console.log()}function yI(){console.log(),console.log(h.default.bold(a.geminiPurple("Interactive Mode Commands"))),console.log(),console.log("Session:"),console.log(` ${a.primary("start")} [options] Start interactive session`),console.log(` ${a.primary("stop")} Stop interactive session`),console.log(` ${a.primary("status")} Check session status`),console.log(),console.log("Interaction:"),console.log(` ${a.primary("send")} "<prompt>" Send prompt to session`),console.log(` ${a.primary("wait")} [timeout] Wait for response completion`),console.log(` ${a.primary("exchange")} Get structured JSON output`),console.log(` ${a.primary("pending")} Check pending tool confirmations`),console.log(` ${a.primary("read")} [lines] Read raw output (debugging)`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk agent start -a researcher -s research")}`),console.log(` ${a.dim('gk agent send "research JWT best practices"')}`),console.log(` ${a.dim("gk agent wait")}`),console.log(` ${a.dim("gk agent pending")}`),console.log(` ${a.dim('gk agent send "1"')} ${a.dim("# approve tool")}`),console.log(` ${a.dim("gk agent exchange")}`),console.log(` ${a.dim("gk agent stop")}`),console.log()}function Xp(t){t.command("agent [subcommand] [arg]","Agent management (list, info, search, spawn)").alias("a").option("--json","[all] Output as JSON").option("-n, --limit <n>","[search] Number of results (default: 5)",{default:5}).option("-i, --intent <intent>","[search] Force intent: research|plan|execute|debug|review|test|design|docs").option("-d, --domain <domain>","[search] Force domain: frontend|backend|auth|payment|database|mobile|ai").option("--max-skills <n>","[search] Maximum skills to include").option("-a, --agent <name>","[spawn] Agent profile name").option("-p, --prompt <text>","[spawn] Task prompt (required for spawn)").option("-s, --skills <list>","[spawn] Comma-separated skill names").option("-c, --context <files>","[spawn] Context files (@file syntax)").option("-m, --model <model>","[spawn] Model override").option("-t, --tools <list>","[spawn] Comma-separated tools to auto-approve").option("--cli <provider>","[spawn] CLI provider: gemini (default) or claude").option("--music","[spawn] Play elevator music while waiting").option("--no-music","[spawn] Disable elevator music").option("--music-file <path>","[spawn] Custom music file path").action(async(e,i,n)=>{if(n.help||n.h)switch(e){case"list":QI();return;case"info":BI();return;case"search":JI();return;case"spawn":Tp();return;case"start":ZI();return;case"send":case"wait":case"exchange":case"pending":case"read":case"status":case"stop":yI();return;default:Bp();return}switch(e){case"list":await qI(n);break;case"info":i||(console.log(),v.error("Agent profile name required"),console.log(a.dim("Usage: gk agent info <name>")),console.log(),process.exit(1)),await wI(i,n);break;case"search":i||(console.log(),v.error("Search query required"),console.log(a.dim('Usage: gk agent search "<task>"')),console.log(),process.exit(1)),await DI(i,n);break;case"spawn":await TI(n);break;case"start":await XI(n);break;case"send":i||(console.log(),v.error("Prompt required"),console.log(a.dim('Usage: gk agent send "your prompt"')),console.log(),process.exit(1)),await LI(i);break;case"wait":await _I(i?parseInt(i):120);break;case"exchange":await $I();break;case"pending":await eE();break;case"read":await tE(i?parseInt(i):200);break;case"status":await iE();break;case"stop":await sE();break;case"_server":await HI();break;default:Bp()}})}async function qI(t){let e=qo();if(t.json){console.log(JSON.stringify(e,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Available Agents"))),console.log(),e.length===0){v.warn('No agent profiles found. Run "gk init" first.'),console.log();return}for(let i of e)console.log(` ${a.primary(i.name)}`),console.log(` ${a.dim(i.description)}`),console.log(` ${a.dim("Model:")} ${i.model}`),i.skills&&i.skills.length>0&&console.log(` ${a.dim("Skills:")} ${i.skills.join(", ")}`),console.log("");console.log(a.dim(` Total: ${e.length} agents`)),console.log()}async function wI(t,e){let i=Fv(t);if(i||(console.log(),v.error(`Agent profile not found: ${t}`),console.log(),process.exit(1)),e.json){console.log(JSON.stringify(i,null,2));return}console.log(),console.log(G.doubleLine()),console.log(h.default.bold(a.geminiPurple(`Agent: ${i.name}`))),console.log(G.doubleLine()),console.log(),console.log(` ${a.dim("Description:")} ${i.description}`),console.log(` ${a.dim("Model:")} ${i.model}`),i.skills?.length&&console.log(` ${a.dim("Skills:")} ${i.skills.join(", ")}`),console.log(` ${a.dim("Path:")} ${i.filePath}`),console.log(),console.log(a.dim("--- Profile Content ---")),console.log(),console.log(a.dim(i.content)),console.log()}async function DI(t,e){let i=nu(t,{top:e.limit,forceIntent:e.intent,forceDomain:e.domain,maxSkills:e.maxSkills});if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple(`Search results for: "${t}"`))),console.log(),i.length===0){v.warn("No matching agents found for task."),console.log();return}for(let n=0;n<i.length;n++){let r=i[n],s=r.fallback?a.warn(" [FALLBACK]"):"";console.log(` ${a.success(n+1+".")} ${a.primary(r.agent)}${s} ${a.dim(`(score: ${r.score})`)}`),console.log(` ${a.dim("Intent:")} ${r.intent} ${a.dim("Domain:")} ${r.domain} ${a.dim("Complexity:")} ${r.complexity}`),r.skills.length>0&&console.log(` ${a.dim("Skills:")} ${r.skills.join(" | ")}`),r.description&&console.log(` ${a.dim(r.description)}`),r.useWhen&&console.log(` ${a.dim("Use when:")} ${r.useWhen}`),console.log("")}if(i.length>0){let n=i[0],r=n.skills.length>0?` -s "${n.skills.join(",")}"`:"";console.log(a.dim(" Suggested command:")),console.log(` ${a.primary("gk")} agent spawn -a ${n.agent}${r} -p "${t}"`)}console.log()}async function TI(t){t.prompt||(console.log(),v.error("Prompt is required. Use -p or --prompt"),console.log(),Tp(),process.exit(1));let e=t.cli==="claude"?"claude":"gemini",i=Ie(),n=B(),r=n.ACTIVE_GK_SESSION_ID||null,s=n.ACTIVE_GEMINI_SESSION_ID||null,o=n.ACTIVE_PLAN||null,c=n.SUGGESTED_PLAN||null,l=n.PLAN_DATE_FORMAT||null,u=n.PROJECT_DIR||null,m=null;if(t.team){let I=ge(process.cwd()),j=Q(I,t.team);j||(console.log(),v.error(`Team not found: ${t.team}`),console.log(),process.exit(1));let he=t.name||t.agent||"agent",de=Et(`team-${he}`,process.pid),Oe=Jt(I,de,j.teamId,null);Oe||(console.log(),v.error("No ports available for team member"),console.log(),process.exit(1)),m={team:j,port:Oe,memberName:he,sanitizedProjectDir:I},v.info(`Spawning as team member: ${a.primary(he)}`),v.info(`Team: ${a.dim(j.teamName)} (${j.teamId.slice(0,12)}...)`),v.info(`Port: ${a.dim(Oe.toString())}`)}let p=null;t.agent&&(p=Fn(t.agent,e),p||(console.log(),v.error(`Agent profile not found: ${t.agent}`),console.log(a.dim(`Searched: .${e==="claude"?"claude":"gemini"}/agents/ and fallback folder`)),console.log(),process.exit(1)));let d=t.model||p?.model||i.spawn.defaultModel;d=mi(d,e);let f=process.argv.includes("--music")||process.argv.includes("--no-music")?t.music:i.spawn.music,g=t.musicFile||i.spawn.musicFile,E=t.skills?.split(",").map(I=>I.trim()).filter(Boolean)||[],J=p?.skills||[],M=[...new Set([...J,...E])],st=t.tools?.split(",").map(I=>I.trim()).filter(Boolean)||[],y=p?.tools||[],te=[...new Set([...y,...st])],U=vi(te,e),us=t.context?t.context.split(",").flatMap(I=>I.trim().split(/\s+/).filter(j=>j)).filter(I=>I):[];async function Ln(I){let j=I,he=!1;if(I.startsWith("@")){let de=I.substring(1),Oe=[Je(process.cwd(),".docs",de),Je(process.cwd(),".plans",de),Je(process.cwd(),"docs",de),Je(process.cwd(),"plans",de),Je(process.cwd(),de)];for(let Dt of Oe)try{await Zp(Dt),j=Dt,he=!0;break}catch{continue}if(!he){let Dt=Oe.map(sn=>` - ${sn}`).join(`
|
|
58
|
+
`);throw new Error(`Context file not found: ${I}
|
|
32
59
|
Searched paths:
|
|
33
|
-
${
|
|
34
|
-
Tip: Place file in .docs/, .plans/, docs/, plans/, or project root`)}}try{if((await
|
|
35
|
-
`;return
|
|
36
|
-
|
|
37
|
-
`,
|
|
38
|
-
`,
|
|
39
|
-
|
|
40
|
-
`}),
|
|
41
|
-
|
|
42
|
-
`,
|
|
43
|
-
`),
|
|
44
|
-
`),
|
|
45
|
-
`),
|
|
46
|
-
`)),
|
|
47
|
-
`);for(let
|
|
48
|
-
`))}
|
|
49
|
-
`)}
|
|
50
|
-
`),
|
|
60
|
+
${Dt}
|
|
61
|
+
Tip: Place file in .docs/, .plans/, docs/, plans/, or project root`)}}try{if((await yp(j)).isDirectory())return await ya(j,I);let Oe=await Sa(j,"utf-8");return{type:"context",name:wp(j),path:j,content:Oe.trim(),originalRef:I}}catch(de){throw new Error(`Failed to load context from ${I}: ${de.message}`)}}async function ya(I,j){let de=[".md",".txt",".json",".yaml",".yml"],Oe=[];async function Dt(sn,vs=0){if(vs>3)return;let NA=await qp(sn,{withFileTypes:!0});for(let on of NA){let er=Je(sn,on.name);if(!on.name.startsWith(".")){if(on.isDirectory())await Dt(er,vs+1);else if(on.isFile()){let FA=Dp(on.name).toLowerCase();if(de.includes(FA))try{let Ha=await Sa(er,"utf-8"),im=Wu(I,er);Oe.push({type:"context",name:on.name,path:er,relativePath:im,content:Ha.trim(),originalRef:`${j}/${im}`})}catch(Ha){console.warn(`Warning: Could not read ${er}: ${Ha.message}`)}}}}}return await Dt(I),Oe.sort((sn,vs)=>(sn.relativePath||"").localeCompare(vs.relativePath||"")),Oe}function qa(I){if(!I||I.length===0)return"";let j=`<context>
|
|
62
|
+
`;return j+=`The following documents provide additional context for this task:
|
|
63
|
+
|
|
64
|
+
`,I.forEach((he,de)=>{j+=`## Document ${de+1}: ${he.name}
|
|
65
|
+
`,j+=`Source: ${he.originalRef}
|
|
66
|
+
|
|
67
|
+
`}),j+=`</context>
|
|
68
|
+
|
|
69
|
+
`,j}let Ae=[];if(us&&us.length>0)for(let I of us)try{if(typeof I=="string"){let j=await Ln(I);Array.isArray(j)?Ae.push(...j):Ae.push(j)}else Ae.push(I)}catch(j){console.log(),v.error(j.message),console.log(),process.exit(1)}let ot=p?.name||t.agent||"Sub",K=[],ie=PI({agentType:"Sub Agent",agentRole:ot,parentSessionId:r,activePlan:o,projectDir:u});if(K.push("<subagent-context>"),K.push(ie),K.push(`</subagent-context>
|
|
70
|
+
`),K.push("<task>"),K.push(t.prompt),K.push(`</task>
|
|
71
|
+
`),p&&(K.push("<agent>"),K.push(`# Agent: ${p.name}
|
|
72
|
+
`),K.push("## Role & Responsibilities"),K.push(p.content),K.push(`</agent>
|
|
73
|
+
`)),M.length>0){K.push("<skills>"),K.push(`You have access to the following skills and capabilities:
|
|
74
|
+
`);for(let I=0;I<M.length;I++){let j=M[I],he=bn(j);he&&(K.push(`## Skill ${I+1}: ${j}`),K.push(he),K.push(`---
|
|
75
|
+
`))}K.push(`</skills>
|
|
76
|
+
`)}Ae.length>0&&K.push(qa(Ae));let Ze=K.join(`
|
|
77
|
+
`),at=t.prompt.length>150?t.prompt.substring(0,150):t.prompt;console.log(),v.info(`Spawning ${a.primary(ot)} agent with ${a.primary(e)} CLI`),v.info(`Model: ${a.primary(d)}`),r&&v.info(`Parent session: ${a.dim(r.slice(0,20)+"...")}`),o&&v.info(`Active plan: ${a.dim(o)}`),M.length>0&&v.info(`Injected skills: ${a.dim(M.join(", "))}`),Ae.length>0&&v.info(`Injected context: ${a.dim(Ae.map(I=>I.name).join(", "))}`),U.length>0&&v.info(`Allowed tools: ${a.dim(U.join(", "))}`),console.log(G.line()),console.log();let qt=null;f&&(qt=new xa({audioFile:g,loop:!0,volume:.3}),qt.start()&&(console.log(a.dim("Playing elevator music while waiting...")),console.log()));let ms=Ae.map(I=>I.path||I.name),jt=Et("gemini-sub",process.pid);r&&u&&Ea(u,r,{gkSessionId:jt,pid:process.pid,parentGkSessionId:r,agentRole:ot,prompt:t.prompt,model:d,injected:M.length>0||ms.length>0?{skills:M,context:ms}:null});let wa=bI(ot),Da,_n,$n;e==="claude"?(Da="claude",_n=["-p","--model",d],U.length>0&&_n.push("--allowedTools",U.join(",")),$n={...process.env,CLAUDE_TYPE:"sub-agent",GK_PARENT_SESSION_ID:r||"",GK_SUB_SESSION_ID:jt,CLAUDE_AGENT_ROLE:ot,CLAUDE_AGENT_PROMPT:at,CLAUDE_AGENT_MODEL:d||"",CLAUDE_AGENT_SKILLS:M.join(","),CLAUDE_AGENT_CONTEXT:ms.join(","),GK_ACTIVE_PLAN:o||"",GK_SUGGESTED_PLAN:c||"",GK_PLAN_DATE_FORMAT:l||""}):(Da="gemini",_n=["-m",d],U.length>0&&_n.push("--allowed-tools",JSON.stringify(U)),$n={...process.env,GEMINI_TYPE:"sub-agent",GEMINI_PARENT_SESSION_ID:s||"",GK_PARENT_SESSION_ID:r||"",GK_SUB_SESSION_ID:jt,GEMINI_AGENT_ROLE:ot,GEMINI_AGENT_PROMPT:at,GEMINI_AGENT_MODEL:d||"",GEMINI_AGENT_SKILLS:M.join(","),GEMINI_AGENT_CONTEXT:ms.join(","),GK_ACTIVE_PLAN:o||"",GK_SUGGESTED_PLAN:c||"",GK_PLAN_DATE_FORMAT:l||""}),m&&($n={...$n,GK_TEAM_ID:m.team.teamId,GK_TEAM_NAME:m.team.teamName,GK_TEAM_ROLE:"member",GK_TEAM_PORT:m.port.toString(),GK_TEAM_LEADER_PORT:m.team.leaderPort.toString(),GK_AGENT_NAME:m.memberName},gi(m.sanitizedProjectDir,m.team.teamId,{agentId:jt,name:m.memberName,agentType:t.agent||"default",role:"member",port:m.port,pid:null,status:"starting"}));let wt=Jp(Da,_n,{stdio:["pipe","pipe","pipe"],shell:process.platform==="win32",env:$n});m&&wt.pid&&Z(m.sanitizedProjectDir,m.team.teamId,jt,"ready");let Ta="",Xa="";wt.stdout.on("data",I=>{Ta+=I.toString()}),wt.stderr.on("data",I=>{Xa+=I.toString()}),wt.stdin.write(Ze),wt.stdin.end(),wt.on("close",I=>{wa.stop(),qt&&(qt.stop(),console.log(a.dim("Music stopped."))),m&&(Z(m.sanitizedProjectDir,m.team.teamId,jt,"shutdown"),Me(m.sanitizedProjectDir,jt)),console.log(),Ta&&console.log(Ta),Xa&&console.error(Xa),I===0?v.success(`${ot} agent completed successfully`):v.error(`${ot} agent exited with code: ${I}`),console.log(),process.exit(I||0)}),wt.on("error",I=>{wa.stop(),qt&&qt.stop(),m&&(Z(m.sanitizedProjectDir,m.team.teamId,jt,"shutdown"),Me(m.sanitizedProjectDir,jt)),console.log(),v.error(`Failed to spawn agent: ${I.message}`),console.log(),process.exit(1)}),process.on("SIGINT",()=>{wa.stop(),qt&&qt.stop(),wt.kill("SIGTERM"),process.exit(1)})}async function XI(t){bt()&&(console.log(),v.error('Session already running. Use "gk agent stop" first.'),console.log(),process.exit(1));let e=t.cli==="claude"?"claude":"gemini",i=Ie(),n=null;t.agent&&(n=Fn(t.agent,e),n||(console.log(),v.error(`Agent profile not found: ${t.agent}`),console.log(a.dim(`Searched: .${e==="claude"?"claude":"gemini"}/agents/ and fallback folder`)),console.log(),process.exit(1)));let r=t.model||n?.model||i.spawn.defaultModel;r=mi(r,e);let s=t.tools?.split(",").map(y=>y.trim()).filter(Boolean)||[],o=n?.tools||[],c=[...new Set([...o,...s])],l=vi(c,e),u=t.skills?.split(",").map(y=>y.trim()).filter(Boolean)||[],m=n?.skills||[],p=[...new Set([...m,...u])],d={};for(let y of p){let te=bn(y);te&&(d[y]=te)}let A=[];if(t.context){let y=t.context.split(",").flatMap(te=>te.trim().split(/\s+/).filter(U=>U)).filter(te=>te);for(let te of y)try{let U=await oE(te);Array.isArray(U)?A.push(...U):A.push(U)}catch(U){console.log(),v.error(U.message),console.log(),process.exit(1)}}let f=3377,g={provider:e,model:r,port:f,pid:0,isFirstSend:!0,context:{agentName:n?.name||null,agentContent:n?.content||null,skills:p,skillContents:d,contextFiles:A,tools:l},startedAt:new Date().toISOString()};$i(g),console.log(),v.info(`Starting ${a.primary(e)} interactive session...`),v.info(`Model: ${a.primary(r)}`),n&&v.info(`Agent: ${a.dim(n.name)}`),p.length>0&&v.info(`Skills: ${a.dim(p.join(", "))}`),l.length>0&&v.info(`Tools: ${a.dim(l.join(", "))}`),console.log();let E=process.argv[1],J=Jp(process.execPath,[E,"agent","_server"],{detached:!0,stdio:"ignore",windowsHide:!0,cwd:process.cwd(),env:process.env});J.unref(),g.pid=J.pid||0,$i(g),v.info(`Server started (PID: ${J.pid}, Port: ${f})`),v.info("Waiting for AI to initialize...");let M=new ee(g.port),st=120;for(let y=0;y<st;y++){await Cu(1e3);try{if((await M.status()).ready){console.log(),v.success("Session ready!"),console.log(),console.log("Usage:"),console.log(` ${a.dim('gk agent send "your prompt"')}`),console.log(` ${a.dim("gk agent wait")}`),console.log(` ${a.dim("gk agent exchange")}`),console.log(` ${a.dim("gk agent stop")}`),console.log();return}}catch{}process.stdout.write(".")}console.log(),v.warn("Server started but AI may still be initializing."),v.info("Check status with: gk agent status"),console.log()}async function HI(){let t=Ge();t||(console.error("[Server] No session state found"),process.exit(1));let e=new yn({provider:t.provider,model:t.model,tools:t.context.tools,sessionState:t,port:t.port,debug:!1});try{await e.start()}catch(i){console.error(`[Server] Failed to start: ${i.message}`),et(),process.exit(1)}process.on("SIGINT",async()=>{await e.stop(),et(),process.exit(0)}),process.on("SIGTERM",async()=>{await e.stop(),et(),process.exit(0)})}function Cu(t){return new Promise(e=>setTimeout(e,t))}async function LI(t){let e=Ge();(!e||!bt())&&(console.log(),v.error('No active session. Use "gk agent start" first.'),console.log(),process.exit(1));let i=new ee(e.port),n=t;e.isFirstSend&&(n=Dv(t,e),yv());try{let r=await i.send(n);r.ok?v.info(`Sent prompt${r.exchangeId?` (exchange: ${r.exchangeId.slice(0,8)}...)`:""}`):v.error(r.error||"Failed to send")}catch(r){v.error(`Failed to send: ${r.message}`),process.exit(1)}}async function _I(t){let e=Ge();(!e||!bt())&&(console.log(),v.error("No active session."),console.log(),process.exit(1));let i=new ee(e.port);console.log(`Waiting for completion (timeout: ${t}s)...`);let n=Date.now(),r=t*1e3;for(;Date.now()-n<r;){try{let s=await i.complete();if(s.complete){console.log(`
|
|
78
|
+
Complete!`);return}if(s.reason==="pending_tool"){console.log(`
|
|
79
|
+
`),v.warn("Tool confirmation required"),s.hint&&console.log(a.dim(s.hint)),console.log(a.dim("Use: gk agent pending"));return}}catch(s){v.error(s.message);return}await Cu(2e3),process.stdout.write(".")}console.log(""),v.warn("Timeout reached. AI may still be working.")}async function $I(){let t=Ge();(!t||!bt())&&(console.log(),v.error("No active session."),console.log(),process.exit(1));let e=new ee(t.port);try{let i=await e.exchange();console.log(JSON.stringify(i,null,2))}catch(i){v.error(i.message),process.exit(1)}}async function eE(){let t=Ge();(!t||!bt())&&(console.log(),v.error("No active session."),console.log(),process.exit(1));let e=new ee(t.port);try{let i=await e.pending();i.hasPending?(console.log(),v.warn("Tool confirmation required"),console.log(JSON.stringify(i,null,2)),console.log(),console.log("To approve: "+a.primary('gk agent send "1"')),console.log("To reject: "+a.primary('gk agent send "3"')),console.log()):console.log("No pending confirmations")}catch(i){v.error(i.message),process.exit(1)}}async function tE(t){let e=Ge();(!e||!bt())&&(console.log(),v.error("No active session."),console.log(),process.exit(1));let i=new ee(e.port);try{let n=await i.read(t);console.log(n)}catch(n){v.error(n.message),process.exit(1)}}async function iE(){let t=Ge();if(!t){console.log("No session file found.");return}if(!bt()){console.log("Session file exists but process not running."),console.log("Cleaning up..."),et();return}let e=new ee(t.port);try{let i=await e.status();console.log(),console.log(h.default.bold("Session: ")+a.success("ACTIVE")),console.log(`Provider: ${t.provider}`),console.log(`Model: ${t.model}`),console.log(`PID: ${t.pid}`),console.log(`Started: ${t.startedAt}`),console.log(`First send pending: ${t.isFirstSend}`),t.context.agentName&&console.log(`Agent: ${t.context.agentName}`),t.context.skills.length>0&&console.log(`Skills: ${t.context.skills.join(", ")}`),console.log(`Output buffer: ${i.outputLength} bytes`),console.log()}catch(i){v.error(i.message),process.exit(1)}}function nE(t){if(!t||t<=0)return!1;try{return process.kill(t,0),!0}catch{return!1}}function rE(t){if(!t||t<=0)return!1;try{if(process.platform==="win32"){let{execSync:e}=ZA("child_process");e(`cmd.exe /c taskkill /F /T /PID ${t}`,{stdio:["pipe","pipe","pipe"],timeout:5e3})}else process.kill(t,"SIGKILL");return!0}catch{try{return process.kill(t,"SIGKILL"),!0}catch{return!1}}}async function sE(){let t=Ge();if(!t){console.log("No active session.");return}let e=t.pid;if(bt())try{await new ee(t.port).stop(),v.info("Sent stop command to server..."),await Cu(2e3)}catch{}e&&nE(e)&&(v.info(`Force killing server process (PID: ${e})...`),rE(e)?v.info(`Process ${e} killed.`):v.warn(`Could not kill process ${e} (may already be dead).`)),et(),v.success("Session stopped.")}async function oE(t){let e=t;if(t.startsWith("@")){let r=t.substring(1),s=[Je(process.cwd(),".docs",r),Je(process.cwd(),".plans",r),Je(process.cwd(),"docs",r),Je(process.cwd(),"plans",r),Je(process.cwd(),r)],o=!1;for(let c of s)try{await Zp(c),e=c,o=!0;break}catch{continue}if(!o)throw new Error(`Context file not found: ${t}`)}if((await yp(e)).isDirectory()){let r=[],s=[".md",".txt",".json",".yaml",".yml"];async function o(c,l=0){if(l>3)return;let u=await qp(c,{withFileTypes:!0});for(let m of u){if(m.name.startsWith("."))continue;let p=Je(c,m.name);if(m.isDirectory())await o(p,l+1);else if(m.isFile()){let d=Dp(m.name).toLowerCase();if(s.includes(d)){let A=await Sa(p,"utf-8");r.push({type:"context",name:m.name,path:p,relativePath:Wu(e,p),content:A.trim(),originalRef:`${t}/${Wu(e,p)}`})}}}}return await o(e),r}let n=await Sa(e,"utf-8");return{type:"context",name:wp(e),path:e,content:n.trim(),originalRef:t}}it();k();function aE(){console.log(),console.log(h.default.bold(a.geminiPurple("Session Management"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk session")} <subcommand> [options]`),console.log(),console.log("Subcommands:"),console.log(` ${a.primary("status")} Show active session (default)`),console.log(` ${a.primary("list")} List recent sessions`),console.log(` ${a.primary("info")} <id> Show session details`),console.log(` ${a.primary("agents")} [id] List agents in session`),console.log(` ${a.primary("init")} [app] Initialize new session`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log(` ${a.dim("-n, --limit <n>")} Number of results for list (default: 10)`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk session status")}`),console.log(` ${a.dim("gk session list -n 20")}`),console.log(` ${a.dim("gk session info abc123")}`),console.log(` ${a.dim("gk session agents")}`),console.log(` ${a.dim("gk session init myapp")}`),console.log()}function Hp(t){t.command("session [subcommand] [id]","Session management (status, list, info, agents, init)").alias("s").option("--json","[all] Output as JSON").option("-n, --limit <n>","[list] Number of results",{default:10}).action(async(e,i,n)=>{switch(e||"status"){case"status":await cE(n);break;case"list":await lE(n);break;case"info":i||(console.log(),v.error("Session ID required"),console.log(a.dim("Usage: gk session info <id>")),console.log(),process.exit(1)),await uE(i,n);break;case"agents":await mE(i,n);break;case"init":await vE(i||"app",n);break;default:aE()}})}async function cE(t){let e=B(),i=Zt(),n=e.ACTIVE_GK_SESSION_ID;if(!n){t.json?console.log(JSON.stringify({active:!1,projectDir:i},null,2)):(console.log(),v.info("No active GemKit session."),console.log(a.dim(` Project: ${i}`)),console.log());return}let r=nt(i,n);if(t.json){console.log(JSON.stringify(r||{active:!1,gkSessionId:n},null,2));return}if(!r){console.log(),v.warn(`Session ID in .env but file not found: ${n}`),console.log(a.dim(` Project: ${i}`)),console.log();return}let s=Wp(i,n),c=r.agents?.find(l=>l.agentType==="Main Agent")?.status||"active";console.log(),console.log(h.default.bold(a.geminiPurple("Active Session"))),console.log(G.line()),console.log(),console.log(` ${a.dim("GK Session ID:")} ${a.primary(r.gkSessionId)}`),console.log(` ${a.dim("Gemini Session ID:")} ${r.geminiSessionId||a.dim("N/A")}`),console.log(` ${a.dim("Project Dir:")} ${r.projectDir}`),console.log(` ${a.dim("App Name:")} ${r.appName}`),console.log(` ${a.dim("PID:")} ${r.pid}`),console.log(` ${a.dim("Status:")} ${G.statusIcon(c)} ${c}`),console.log(` ${a.dim("Started:")} ${r.initTimestamp}`),r.activePlan&&console.log(` ${a.dim("Active Plan:")} ${a.primary(r.activePlan)}`),console.log(),console.log(` ${a.dim("Agents:")} ${s.total} total (${s.mainAgents} main, ${s.subAgents} sub)`),console.log(` ${a.success(String(s.completed))} completed, ${a.error(String(s.failed))} failed, ${s.active} active`),console.log()}async function lE(t){let e=Zt(),i=Yp(e,{limit:t.limit});if(t.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Recent Sessions"))),console.log(a.dim(` Project: ${e}`)),console.log(),i.length===0){v.info(" No sessions found."),console.log();return}for(let n of i){let r=new Date(n.initTimestamp).toLocaleString(),o=n.agents?.find(l=>l.agentType==="Main Agent")?.status||"active",c=n.gkSessionId.length>25?n.gkSessionId.slice(0,25)+"...":n.gkSessionId;console.log(` ${G.statusIcon(o)} ${a.primary(c)} ${a.dim(r)}`),n.activePlan&&console.log(` ${a.dim("Plan:")} ${n.activePlan}`)}console.log(),console.log(a.dim(` Showing ${i.length} sessions (limit: ${t.limit})`)),console.log()}async function uE(t,e){let i=Zt(),n=nt(i,t);if(n||(console.log(),v.error(`Session not found: ${t}`),console.log(a.dim(` Looked in: ~/.gemkit/projects/${i}/`)),console.log(),process.exit(1)),e.json){console.log(JSON.stringify(n,null,2));return}console.log(),console.log(h.default.bold(a.geminiPurple(`Session: ${n.gkSessionId}`))),console.log(G.line()),console.log(),console.log(JSON.stringify(n,null,2)),console.log()}async function mE(t,e){let i=Zt(),n=t||nn();n||(console.log(),v.error("No session ID provided and no active session found."),console.log(),process.exit(1));let r=nt(i,n);r||(console.log(),v.error(`Session not found: ${n}`),console.log(),process.exit(1));let s=r.agents||[];if(e.json){console.log(JSON.stringify(s,null,2));return}let o=n.length>30?n.slice(0,30)+"...":n;if(console.log(),console.log(h.default.bold(a.geminiPurple("Agents in Session"))),console.log(a.dim(` ${o}`)),console.log(),s.length===0){v.info(" No agents in this session."),console.log();return}for(let c=0;c<s.length;c++){let l=s[c],u=l.agentRole||"unknown",m=l.model||"default",p=l.agentType==="Main Agent"?a.primary("MAIN"):a.dim("SUB");if(console.log(` ${G.statusIcon(l.status)} [${p}] ${a.primary(u)} ${a.dim(`(${m})`)}`),l.prompt){let d=l.prompt.length>60?l.prompt.slice(0,60)+"...":l.prompt;console.log(` ${a.dim("Prompt:")} ${d}`)}l.tokenUsage&&console.log(` ${a.dim("Tokens:")} ${l.tokenUsage.total.toLocaleString()} total`),l.geminiSessionId&&console.log(` ${a.dim("Gemini ID:")} ${l.geminiSessionId.slice(0,8)}...`)}console.log(),console.log(a.dim(` Total: ${s.length} agents`)),console.log()}async function vE(t,e){let n=B().ACTIVE_GK_SESSION_ID;if(n){let l=Np(n),u=Zt();if(l){let m=Su();if(nt(u,n)&&l.pid===m){e.json?console.log(JSON.stringify({status:"existing",gkSessionId:n,pid:l.pid},null,2)):(console.log(),v.info(`GemKit session already active: ${a.primary(n.slice(0,30)+"...")}`),console.log(a.dim(` PID: ${l.pid}`)),console.log());return}}}let{session:r,gkSessionId:s,pid:o,projectDir:c}=kp(t);Ea(c,s,{gkSessionId:s,pid:o,geminiSessionId:null,parentGkSessionId:null,agentRole:"main",prompt:null,model:null}),e.json?console.log(JSON.stringify({status:"initialized",gkSessionId:s,pid:o,projectDir:c},null,2)):(console.log(),v.success(`GemKit session initialized: ${a.primary(s.slice(0,30)+"...")}`),console.log(a.dim(` PID: ${o}`)),console.log())}k();it();import{existsSync as as,readdirSync as pE,mkdirSync as Ga,writeFileSync as Ou,statSync as AE}from"fs";import{join as rn}from"path";function Uu(t){let e=vn(t);if(!as(e))return[];let i=os();return pE(e,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>r.name).map(r=>{let s=rn(e,r),o=rn(s,"plan.md"),c="";return as(o)&&(c=AE(o).birthtime.toISOString()),{name:r,path:s,createdAt:c,isActive:r===i}})}function Lp(t,e){let i=vn(e),n=rn(i,t);if(as(i)||Ga(i,{recursive:!0}),as(n))throw new Error(`Plan already exists: ${t}`);Ga(n,{recursive:!0}),Ga(rn(n,"research"),{recursive:!0}),Ga(rn(n,"artifacts"),{recursive:!0});let r=`# ${t}
|
|
51
80
|
|
|
52
81
|
## Overview
|
|
53
82
|
|
|
@@ -61,14 +90,14 @@ Tip: Place file in .docs/, .plans/, docs/, plans/, or project root`)}}try{if((aw
|
|
|
61
90
|
|
|
62
91
|
## Notes
|
|
63
92
|
|
|
64
|
-
`;return
|
|
65
|
-
`);return
|
|
66
|
-
`);return
|
|
67
|
-
${
|
|
68
|
-
${a.dim("Session ID:")} ${a.accent(t.sessionId)}`),console.log(` ${a.dim("Start Time:")} ${t.startTime||"N/A"}`),console.log(` ${a.dim("Duration:")} ${a.accent(t.duration?.formatted||"N/A")}`),console.log(` ${a.dim("Model:")} ${a.geminiBlue(t.modelsUsed.join(", "))}`),console.log(` ${a.dim("Messages:")} ${a.accent(String(t.messageCount))}`),console.log(
|
|
69
|
-
${
|
|
70
|
-
${
|
|
71
|
-
${a.dim("Tokens/msg:")} ${a.accent(
|
|
93
|
+
`;return Ou(rn(n,"plan.md"),r),{name:t,path:n,createdAt:new Date().toISOString(),isActive:!1}}function Ku(t,e){let i=nn();if(!i){let s=Wi(e),o=B(),c=["# Auto-generated by gemkit-cli",`# Updated at: ${new Date().toISOString()}`,"","# GEMKIT IDs",`ACTIVE_GK_SESSION_ID=${o.ACTIVE_GK_SESSION_ID||""}`,`GK_PROJECT_HASH=${o.GK_PROJECT_HASH||""}`,`PROJECT_DIR=${o.PROJECT_DIR||""}`,"","# GEMINI IDs (mapped)",`ACTIVE_GEMINI_SESSION_ID=${o.ACTIVE_GEMINI_SESSION_ID||""}`,`GEMINI_PROJECT_HASH=${o.GEMINI_PROJECT_HASH||""}`,"","# PLAN INFO",`ACTIVE_PLAN=${t}`,`SUGGESTED_PLAN=${o.SUGGESTED_PLAN||""}`,`PLAN_DATE_FORMAT=${o.PLAN_DATE_FORMAT||""}`,""].join(`
|
|
94
|
+
`);return Ou(s,c),!0}let n=Zt(e);if(!nt(n,i)){let s=Wi(e),o=B(),c=["# Auto-generated by gemkit-cli",`# Updated at: ${new Date().toISOString()}`,"","# GEMKIT IDs",`ACTIVE_GK_SESSION_ID=${o.ACTIVE_GK_SESSION_ID||""}`,`GK_PROJECT_HASH=${o.GK_PROJECT_HASH||""}`,`PROJECT_DIR=${o.PROJECT_DIR||""}`,"","# GEMINI IDs (mapped)",`ACTIVE_GEMINI_SESSION_ID=${o.ACTIVE_GEMINI_SESSION_ID||""}`,`GEMINI_PROJECT_HASH=${o.GEMINI_PROJECT_HASH||""}`,"","# PLAN INFO",`ACTIVE_PLAN=${t}`,`SUGGESTED_PLAN=${o.SUGGESTED_PLAN||""}`,`PLAN_DATE_FORMAT=${o.PLAN_DATE_FORMAT||""}`,""].join(`
|
|
95
|
+
`);return Ou(s,c),!0}return Vp(n,i,t)}function _p(t,e){let i=vn(e),n=rn(i,t);if(!as(n))return null;let r=os();return{name:t,path:n,createdAt:"",isActive:t===r}}it();function dE(){console.log(),console.log(h.default.bold(a.geminiPurple("Plan Management"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk plan")} <subcommand> [options]`),console.log(),console.log("Subcommands:"),console.log(` ${a.primary("list")} List all plans (default)`),console.log(` ${a.primary("status")} Show active plan status`),console.log(` ${a.primary("create")} <name> Create new plan`),console.log(` ${a.primary("set")} <name> Set active plan`),console.log(` ${a.primary("info")} Get plan info from .env`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log(` ${a.dim("-a, --active")} [info] Show only ACTIVE_PLAN value`),console.log(` ${a.dim("-s, --suggested")} [info] Show only SUGGESTED_PLAN value`),console.log(` ${a.dim("-f, --format")} [info] Show only PLAN_DATE_FORMAT value`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk plan list")}`),console.log(` ${a.dim("gk plan create my-feature")}`),console.log(` ${a.dim("gk plan set my-feature")}`),console.log(` ${a.dim("gk plan info --active")}`),console.log()}function $p(t){t.command("plan [subcommand] [name]","Plan management (list, status, create, set, info)").alias("p").option("--json","[all] Output as JSON").option("-a, --active","[info] Show only ACTIVE_PLAN value").option("-s, --suggested","[info] Show only SUGGESTED_PLAN value").option("-f, --format","[info] Show only PLAN_DATE_FORMAT value").action(async(e,i,n)=>{switch(e||"list"){case"list":await fE(n);break;case"status":await hE(n);break;case"create":i||(console.log(),v.error("Plan name required"),console.log(a.dim("Usage: gk plan create <name>")),console.log(),process.exit(1)),await gE(i);break;case"set":i||(console.log(),v.error("Plan name required"),console.log(a.dim("Usage: gk plan set <name>")),console.log(),process.exit(1)),await IE(i);break;case"info":await EE(n);break;default:dE()}})}async function fE(t){let e=Uu();if(t.json){console.log(JSON.stringify(e,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Project Plans"))),console.log(),e.length===0){v.info('No plans found. Create one with "gk plan create <name>".'),console.log();return}for(let i of e){let n=i.isActive?a.success("\u2192"):a.dim("\u25CB"),r=i.isActive?a.success(" (active)"):"";console.log(` ${n} ${a.primary(i.name)}${r}`),console.log(` ${a.dim("Created:")} ${a.dim(new Date(i.createdAt).toLocaleDateString())}`)}console.log()}async function hE(t){let e=os();if(!e){t.json?console.log(JSON.stringify({active:!1},null,2)):(console.log(),v.info("No active plan set."),console.log());return}let i=_p(e);if(t.json){console.log(JSON.stringify(i,null,2));return}console.log(),console.log(G.line()),console.log(h.default.bold(a.geminiPurple("Active Plan"))),console.log(G.line()),console.log(),console.log(` ${a.primary(e)}`),console.log()}async function gE(t){try{let e=Lp(t);console.log(),v.success(`Plan created: ${a.primary(t)}`),v.info(`Path: ${a.dim(e.path)}`),Ku(t),v.info("Set as active plan."),console.log()}catch(e){console.log(),v.error(`Failed to create plan: ${e instanceof Error?e.message:String(e)}`),console.log()}}async function IE(t){if(!Uu().some(s=>s.name===t)){console.log(),v.error(`Plan not found: ${t}`),console.log();return}if(!Ku(t)){console.log(),v.error("Failed to update session or env file"),console.log();return}let r=nn();console.log(),r&&v.success(`Session ${r.slice(0,20)}...: activePlan set to: ${a.primary(t)}`),v.info(`Environment updated: ACTIVE_PLAN = ${t}`),console.log(),v.success(`Active plan set to: ${a.primary(t)}`),console.log()}async function EE(t){let e=B(),i={activePlan:e.ACTIVE_PLAN||null,suggestedPlan:e.SUGGESTED_PLAN||null,planDateFormat:e.PLAN_DATE_FORMAT||null,gkSessionId:e.ACTIVE_GK_SESSION_ID||null,projectDir:e.PROJECT_DIR||null};if(t.active){t.json?console.log(JSON.stringify({activePlan:i.activePlan})):console.log(i.activePlan||"");return}if(t.suggested){t.json?console.log(JSON.stringify({suggestedPlan:i.suggestedPlan})):console.log(i.suggestedPlan||"");return}if(t.format){t.json?console.log(JSON.stringify({planDateFormat:i.planDateFormat})):console.log(i.planDateFormat||"");return}if(t.json)console.log(JSON.stringify({activePlan:i.activePlan,suggestedPlan:i.suggestedPlan,planDateFormat:i.planDateFormat,context:{gkSessionId:i.gkSessionId,projectDir:i.projectDir}},null,2));else{console.log(),console.log(G.line()),console.log(h.default.bold(a.geminiPurple("Plan Information"))),console.log(G.line()),console.log(),console.log(` ${a.dim("Active Plan:")} ${i.activePlan||a.dim("(not set)")}`),console.log(` ${a.dim("Suggested Plan:")} ${i.suggestedPlan||a.dim("(not set)")}`),console.log(` ${a.dim("Date Format:")} ${i.planDateFormat||a.dim("(not set)")}`),console.log(),console.log(G.line());let n=i.gkSessionId?i.gkSessionId.substring(0,25)+"...":a.dim("(no session)");console.log(` ${a.dim("Session:")} ${n}`),console.log(` ${a.dim("Project:")} ${i.projectDir||a.dim("(unknown)")}`),console.log()}}it();import{existsSync as RE,readFileSync as zE,readdirSync as jE}from"fs";import{join as eA}from"path";import{homedir as xE}from"os";async function tA(){let t=fa();return t?SE(t):null}function SE(t){let e=eA(xE(),".gemini","tmp",t,"chats");if(!RE(e))return null;let i=jE(e).filter(n=>n.startsWith("session-")&&n.endsWith(".json")).sort().reverse();if(i.length===0)return null;try{let n=eA(e,i[0]);return GE(n)}catch{return null}}function GE(t){try{let e=zE(t,"utf-8"),i=JSON.parse(e);if(!i.messages||i.messages.length===0)return null;let n=new Set,r=0,s=0,o=0,c,l=0;for(let E of i.messages)E.model&&n.add(E.model),E.tokens&&(r+=E.tokens.output||0,s+=E.tokens.thoughts||0,o+=E.tokens.tool||0,c=E.tokens,l++);if(!c||l===0)return null;let u=c.total||0,m=c.cached||0,p=u-r-s;p<0&&(p=0);let d={input:p,output:r,cached:m,thoughts:s,tool:o,total:u},A=null;if(i.startTime&&i.lastUpdated)try{let E=new Date(i.startTime),J=new Date(i.lastUpdated),M=Math.floor((J.getTime()-E.getTime())/1e3),st=Math.floor(M/60),y=M%60;A={seconds:M,formatted:`${st}m ${y}s`}}catch{}let f=Array.from(n),g=f[0]||"unknown";return{sessionId:i.sessionId,startTime:i.startTime||null,lastUpdated:i.lastUpdated||null,duration:A,model:g,modelsUsed:f,messageCount:l,tokens:d,averages:{outputPerMessage:l>0?Math.round(r/l):0,thoughtsPerMessage:l>0?Math.round(s/l):0,toolPerMessage:l>0?Math.round(o/l):0}}}catch{return null}}var cs={"gemini-3-pro-preview":{input:2,output:12,cached:.2,thoughts:12},"gemini-3-flash-preview":{input:.5,output:3,cached:.05,thoughts:3},"gemini-2.5-pro":{input:1.25,output:10,cached:.125,thoughts:10},"gemini-2.5-pro-preview":{input:1.25,output:10,cached:.125,thoughts:10},"gemini-2.5-flash":{input:.3,output:2.5,cached:.03,thoughts:2.5},"gemini-2.5-flash-lite":{input:.1,output:.4,cached:.01,thoughts:.4},"gemini-2.0-flash":{input:.1,output:.4,cached:.01,thoughts:.4},"gemini-2.0-flash-exp":{input:.1,output:.4,cached:.01,thoughts:.4},default:{input:.5,output:3,cached:.05,thoughts:3}};function ME(t){if(cs[t])return cs[t];for(let e of Object.keys(cs))if(e.includes(t)||t.includes(e))return cs[e];return cs.default}function ku(t,e="default"){let i=ME(e),n=t.input-t.cached;n<0&&(n=0);let r=n/1e6*i.input,s=t.output/1e6*i.output,o=t.cached/1e6*i.cached,c=t.thoughts/1e6*i.thoughts;return{input:r,output:s,cached:o,thoughts:c,total:r+s+o+c,model:e,pricing:i}}function Ei(t){return t>=1?`$${t.toFixed(2)}`:t>=.01?`$${t.toFixed(3)}`:t>=.001?`$${t.toFixed(4)}`:`$${t.toFixed(6)}`}function Vu(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}var zi={topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",middleLeft:"\u251C",middleRight:"\u2524"};function YE(t=75){return a.dim(`${zi.topLeft}${zi.horizontal.repeat(t-2)}${zi.topRight}`)}function WE(t=75){return a.dim(`${zi.bottomLeft}${zi.horizontal.repeat(t-2)}${zi.bottomRight}`)}function CE(t,e=75){let i=t.replace(/\x1b\[[0-9;]*m/g,"").length,n=Math.max(0,e-4-i);return`${a.dim(zi.vertical)} ${t}${" ".repeat(n)} ${a.dim(zi.vertical)}`}function Nu(t){return`
|
|
96
|
+
${h.default.bold(a.geminiPurple(`## ${t}`))}`}function rt(t,e){let i=t.replace(/\x1b\[[0-9;]*m/g,"").length,n=Math.max(0,e-i);return" ".repeat(n)+t}function Ri(t,e){let i=t.replace(/\x1b\[[0-9;]*m/g,"").length,n=Math.max(0,e-i);return t+" ".repeat(n)}function OE(t){let e=[],i=t.length;for(let n=0;n<i;n++){let r=n/Math.max(i-1,1),s=Math.round(26+116*r),o=Math.round(115+-79*r),c=Math.round(232+-62*r);e.push(`\x1B[38;2;${s};${o};${c}m${t[n]}`)}return e.join("")+"\x1B[0m"}function UE(t){let e=ku(t.tokens,t.model);console.log(),console.log(YE(75)),console.log(CE(`${OE("SESSION ANALYSIS")} ${a.dim("Cost:")} ${a.warn(Ei(e.total))}`,75)),console.log(WE(75)),console.log(`
|
|
97
|
+
${a.dim("Session ID:")} ${a.accent(t.sessionId)}`),console.log(` ${a.dim("Start Time:")} ${t.startTime||"N/A"}`),console.log(` ${a.dim("Duration:")} ${a.accent(t.duration?.formatted||"N/A")}`),console.log(` ${a.dim("Model:")} ${a.geminiBlue(t.modelsUsed.join(", "))}`),console.log(` ${a.dim("Messages:")} ${a.accent(String(t.messageCount))}`),console.log(Nu("Token Breakdown")),console.log(`
|
|
98
|
+
${Ri("Category",10)} ${rt("Count",14)} ${rt("Formatted",10)}`),console.log(` ${a.dim("\u2500".repeat(10))} ${a.dim("\u2500".repeat(14))} ${a.dim("\u2500".repeat(10))}`);let i=["input","output","cached","thoughts","tool"];for(let s of i){let o=t.tokens[s],c=rt(a.accent(o.toLocaleString()),14),l=rt(a.accent(Vu(o)),10);console.log(` ${Ri(s,10)} ${c} ${l}`)}console.log(` ${a.dim("\u2500".repeat(10))} ${a.dim("\u2500".repeat(14))} ${a.dim("\u2500".repeat(10))}`);let n=rt(a.success(t.tokens.total.toLocaleString()),14),r=rt(a.success(Vu(t.tokens.total)),10);if(console.log(` ${Ri(h.default.bold("total"),10)} ${n} ${r}`),console.log(Nu("Estimated Cost")),console.log(`
|
|
99
|
+
${Ri("Input",12)} ${rt(a.warn(Ei(e.input)),12)}`),console.log(` ${Ri("Output",12)} ${rt(a.warn(Ei(e.output)),12)}`),console.log(` ${Ri("Cached",12)} ${rt(a.warn(Ei(e.cached)),12)}`),console.log(` ${Ri("Thoughts",12)} ${rt(a.warn(Ei(e.thoughts)),12)}`),console.log(` ${a.dim("\u2500".repeat(24))}`),console.log(` ${Ri(h.default.bold("TOTAL"),12)} ${rt(h.default.bold(a.warn(Ei(e.total))),12)}`),t.messageCount>0){console.log(Nu("Averages"));let s=Math.round(t.tokens.total/t.messageCount),o=e.total/t.messageCount;console.log(`
|
|
100
|
+
${a.dim("Tokens/msg:")} ${a.accent(s.toLocaleString())}`),console.log(` ${a.dim("Cost/msg:")} ${a.warn(Ei(o))}`)}console.log()}function KE(t){let e=ku(t.tokens,t.model);console.log(JSON.stringify({sessionId:t.sessionId,startTime:t.startTime,duration:t.duration,model:t.model,modelsUsed:t.modelsUsed,messageCount:t.messageCount,tokens:t.tokens,averages:t.averages,cost:{input:e.input,output:e.output,cached:e.cached,thoughts:e.thoughts,total:e.total}},null,2))}function iA(t){t.command("tokens","Show token usage for current session").alias("t").option("--json","Output as JSON").action(async e=>{let i=await tA();if(!i){e.json?console.log(JSON.stringify({found:!1},null,2)):(console.log(),v.info("No token usage found for current session."),console.log());return}if(e.json){KE(i);return}UE(i)})}k();import{existsSync as kE,readdirSync as VE}from"fs";function nA(t){let e=t.command("extension <subcommand>","Extension management").alias("ext");e.example("gk extension list # List installed extensions"),e.action(async i=>{let n=i||"list";n==="list"?await NE():(console.log(),v.error(`Unknown subcommand: ${n}`),console.log(),process.exit(1))})}async function NE(){let t=Ci();if(!kE(t)){console.log(),v.info("No extensions directory found."),console.log();return}let e=VE(t,{withFileTypes:!0}).filter(i=>i.isDirectory()).map(i=>i.name);if(e.length===0){console.log(),v.info("No extensions installed."),console.log();return}console.log(),console.log(h.default.bold(a.geminiPurple("Installed Extensions"))),console.log();for(let i of e)console.log(` ${a.success("\u2713")} ${a.primary(i)}`);console.log(),console.log(a.dim(` Total: ${e.length} extensions`)),console.log()}Xr();Lr();Nn();function rA(t){t.command("catalog [subcommand]","Catalog of skills and agents").action(async i=>{let n=i||"skills";switch(n){case"skills":await FE();break;case"agents":await bE();break;default:console.log(),v.error(`Unknown subcommand: ${n}`),console.log(),process.exit(1)}})}async function FE(){let t=Jv();if(console.log(),console.log(h.default.bold(a.geminiPurple("Available Skills"))),console.log(),t.length===0){v.info(" No skills found."),console.log();return}for(let e of t)console.log(` ${a.success("\u2713")} ${a.primary(e.name)}`);console.log(),console.log(a.dim(` Total: ${t.length} skills`)),console.log()}async function bE(){let t=qo();if(console.log(),console.log(h.default.bold(a.geminiPurple("Available Agent Profiles"))),console.log(),t.length===0){v.info(" No agent profiles found."),console.log();return}for(let e of t)console.log(` ${a.success("\u25CF")} ${a.primary(e.name)}`),console.log(` ${a.dim(e.description)}`);console.log(),console.log(a.dim(` Total: ${t.length} profiles`)),console.log()}it();import{spawnSync as zt}from"child_process";import{existsSync as We,mkdirSync as sA,writeFileSync as PE,statSync as Fu,copyFileSync as Ma,readdirSync as QE}from"fs";import{join as Ye,extname as wn}from"path";import{homedir as qn}from"os";var BE="clipboard-image",JE="clipboard-video",oA=[".mp4",".webm",".mov",".avi",".mkv",".gif"],ZE=5;function aA(t){t.command("paste","Capture clipboard image or video for Gemini analysis").alias("p").option("--image","Capture image from clipboard (default)").option("--video","Capture video from clipboard or recent recordings").option("--format <fmt>","Image format (png, jpg)",{default:"png"}).option("--json","Output as JSON").action(async e=>{let i=e.video===!0,n=i?HE():qE(e),r=i?e9(n):XE(n);if(e.json)console.log(JSON.stringify(r,null,2));else{if(console.log(),r.success){let s=i?"Video":"Image";console.log(`${a.success("\u2713")} ${s} captured successfully`),console.log(),console.log(` ${a.dim("Path:")} ${a.primary(String(r.path))}`),console.log(` ${a.dim("Size:")} ${r.size}`),i&&r.format&&console.log(` ${a.dim("Format:")} ${r.format}`),r.sourceType&&r.sourceType!=="clipboard"&&console.log(` ${a.dim("Source:")} ${r.sourceType}`),console.log(` ${a.dim("Platform:")} ${r.platform}`)}else console.error(`${a.error("\u2717")} ${r.error}`),r.suggestion&&console.log(` ${a.dim("Hint:")} ${r.suggestion}`);console.log()}process.exit(n.success?0:1)})}function cA(){let t=fa();if(t){let i=Ye(qn(),".gemini","tmp",t);return We(i)||sA(i,{recursive:!0}),i}let e=Ye(process.cwd(),".gemini","tmp","clipboard");return We(e)||sA(e,{recursive:!0}),e}function yE(t="png"){let e=Date.now(),i=Math.random().toString(36).substring(2,8);return`${BE}-${e}-${i}.${t}`}function Ya(t=".mp4"){let e=Date.now(),i=Math.random().toString(36).substring(2,8),n=oA.includes(t.toLowerCase())?t:".mp4";return`${JE}-${e}-${i}${n}`}function bu(t){let e=wn(t).toLowerCase();return oA.includes(e)}function lA(t,e){for(let i of t)if(We(i))try{let n=QE(i).filter(r=>bu(r)).map(r=>{let s=Ye(i,r);return{name:r,path:s,mtime:Fu(s).mtime}}).sort((r,s)=>s.mtime.getTime()-r.mtime.getTime());if(n.length>0){let r=n[0];if((Date.now()-r.mtime.getTime())/6e4<=ZE){let o=wn(r.path),c=Ya(o),l=Ye(e,c);if(Ma(r.path,l),We(l))return{success:!0,path:l,sourcePath:r.path,sourceType:"recent-recording"}}}}catch{}return null}function qE(t){let e=t.format||"png",i=process.platform,n=cA(),r=yE(e),s=Ye(n,r),o;switch(i){case"win32":o=wE(s);break;case"darwin":o=DE(s);break;case"linux":o=TE(s);break;default:o={success:!1,error:`Unsupported platform: ${i}`}}return o.platform=i,o.tempDir=n,o}function wE(t){let e=t.replace(/\\/g,"\\\\"),i=`
|
|
72
101
|
Add-Type -AssemblyName System.Windows.Forms
|
|
73
102
|
Add-Type -AssemblyName System.Drawing
|
|
74
103
|
$clipboard = [System.Windows.Forms.Clipboard]::GetImage()
|
|
@@ -78,7 +107,7 @@ if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Ou
|
|
|
78
107
|
$clipboard.Save("${e}", [System.Drawing.Imaging.ImageFormat]::Png)
|
|
79
108
|
$clipboard.Dispose()
|
|
80
109
|
Write-Output "SUCCESS"
|
|
81
|
-
`.trim(),n=
|
|
110
|
+
`.trim(),n=zt("powershell",["-NoProfile","-NonInteractive","-Command",i],{encoding:"utf-8",windowsHide:!0});return n.stderr?.includes("NO_IMAGE")?{success:!1,error:"No image in clipboard. Copy an image first."}:n.status!==0?{success:!1,error:`Failed: ${n.stderr||n.stdout}`.trim()}:We(t)?{success:!0,path:t}:{success:!1,error:"File not created"}}function DE(t){return zt("which",["pngpaste"],{encoding:"utf-8"}).status===0&&zt("pngpaste",[t],{encoding:"utf-8"}).status===0&&We(t)?{success:!0,path:t}:{success:!1,error:"No image or pngpaste failed",suggestion:"brew install pngpaste"}}function TE(t){if(zt("which",["xclip"],{encoding:"utf-8"}).status!==0)return{success:!1,error:"xclip not installed",suggestion:"apt install xclip"};let i=zt("xclip",["-selection","clipboard","-t","TARGETS","-o"],{encoding:"utf-8"});if(!i.stdout?.includes("image/png")&&!i.stdout?.includes("image/jpeg"))return{success:!1,error:"No image in clipboard"};let n=i.stdout.includes("image/png")?"image/png":"image/jpeg",r=zt("xclip",["-selection","clipboard","-t",n,"-o"],{encoding:"buffer"});return r.status!==0||!r.stdout?.length?{success:!1,error:"Failed to read clipboard"}:(PE(t,r.stdout),We(t)?{success:!0,path:t}:{success:!1,error:"Save failed"})}function XE(t){if(t.success&&t.path){let e=Fu(t.path);return{success:!0,message:"Image captured",path:t.path,size:`${(e.size/1024).toFixed(1)} KB`,platform:t.platform}}return{success:!1,error:t.error,suggestion:t.suggestion,platform:t.platform}}function HE(){let t=process.platform,e=cA(),i;switch(t){case"win32":i=LE(e);break;case"darwin":i=_E(e);break;case"linux":i=$E(e);break;default:i={success:!1,error:`Unsupported platform: ${t}`,suggestion:"This tool supports Windows, macOS, and Linux only"}}return i.platform=t,i.tempDir=e,i}function LE(t){let e=`
|
|
82
111
|
Add-Type -AssemblyName System.Windows.Forms
|
|
83
112
|
|
|
84
113
|
# Try to get file drop list from clipboard (copied files)
|
|
@@ -145,7 +174,7 @@ if (Test-Path $videosFolder) {
|
|
|
145
174
|
|
|
146
175
|
Write-Error "NO_VIDEO_FOUND"
|
|
147
176
|
exit 1
|
|
148
|
-
`.trim();try{let i=
|
|
177
|
+
`.trim();try{let i=zt("powershell",["-NoProfile","-NonInteractive","-Command",e],{encoding:"utf-8",windowsHide:!0,timeout:1e4});if(i.error)return{success:!1,error:`PowerShell error: ${i.error.message}`};if(i.stderr?.includes("NO_VIDEO_FOUND"))return{success:!1,error:"No video found in clipboard or recent recordings.",suggestion:"Copy a video file or record with Snipping Tool (Win+Shift+R) first."};if(i.status!==0)return{success:!1,error:`Failed to capture: ${(i.stderr||i.stdout||"Unknown PowerShell error").trim()}`};let n=i.stdout.trim(),r=null,s="clipboard";if(n.startsWith("FILE:")?(r=n.substring(5),s="clipboard"):n.startsWith("SNIP:")&&(r=n.substring(5),s="snipping-tool"),!r||!We(r))return{success:!1,error:"Video file not found or inaccessible"};let o=wn(r),c=Ya(o),l=Ye(t,c);return Ma(r,l),We(l)?{success:!0,path:l,sourcePath:r,sourceType:s}:{success:!1,error:"Failed to copy video file"}}catch(i){return{success:!1,error:`Windows video capture error: ${i instanceof Error?i.message:String(i)}`}}}function _E(t){let e=`
|
|
149
178
|
use scripting additions
|
|
150
179
|
|
|
151
180
|
set thePath to ""
|
|
@@ -167,9 +196,9 @@ if thePath is not "" then
|
|
|
167
196
|
else
|
|
168
197
|
return "NO_FILE"
|
|
169
198
|
end if
|
|
170
|
-
`.trim();try{let i=
|
|
171
|
-
`),n.created.push(
|
|
172
|
-
`)+s;return t.replace(n,A)}function Kc(t,e={},i=process.cwd()){let n={skill:t,success:!1,created:[],skipped:[],errors:[]},r=Do(i),o=wo(i),s=W(r,`${t}.md`),c=W(o,`${t}.md`);if(!le(s))return n.errors.push(`Agent not found: ${t}`),n;if(Uc(t,i)&&!e.force)return n.skipped.push(`Agent already exists in .gemini/agents: ${t} (use --force to overwrite)`),n;let l;try{l=Bo(s,"utf-8")}catch(E){return n.errors.push(`Failed to read agent file: ${E instanceof Error?E.message:String(E)}`),n}let A=IA(l)?.model,u=_p(A),I=l;if(A&&u&&A!==u&&(I=$p(l,{model:u})),e.dryRun)return n.created.push(`[DRY RUN] Would create: ${c}`),A&&u&&A!==u&&n.created.push(`[DRY RUN] Would map model: ${A} -> ${u}`),n.success=!0,n;try{le(o)||Yc(o,{recursive:!0}),uA(c,I),n.created.push(c),A&&u&&A!==u&&n.created.push(`Model mapped: ${A} -> ${u}`),n.success=!0}catch(E){n.errors.push(`Failed to convert: ${E instanceof Error?E.message:String(E)}`)}return n}function pA(t={},e=process.cwd()){let i=To(e),n=[];for(let r of i){let o=Kc(r.name,t,e);n.push(o)}return n}function fA(){console.log(),console.log(p.default.bold(a.geminiPurple("Convert .claude to .gemini"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk convert")} <type> [name] [options]`),console.log(),console.log("Types:"),console.log(` ${a.primary("skill")} <name> Convert a single skill to extension`),console.log(` ${a.primary("skills")} Convert all skills to extensions`),console.log(` ${a.primary("agent")} <name> Convert a single agent`),console.log(` ${a.primary("agents")} Convert all agents`),console.log(),console.log("Options:"),console.log(` ${a.dim("--list")} List available items`),console.log(` ${a.dim("--force")} Overwrite existing items`),console.log(` ${a.dim("--dry-run")} Show what would be done without changes`),console.log(` ${a.dim("--json")} Output as JSON`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk convert skill --list")}`),console.log(` ${a.dim("gk convert skill my-skill")}`),console.log(` ${a.dim("gk convert skills --force")}`),console.log(` ${a.dim("gk convert agent --list")}`),console.log(` ${a.dim("gk convert agents --dry-run")}`),console.log()}function hA(t){t.command("convert [type] [name]","Convert .claude to .gemini resources").alias("cv").option("--all","[all] Convert all items").option("--list","[all] List available items").option("--force","[all] Overwrite existing items").option("--dry-run","[all] Show what would be done without making changes").option("--json","[all] Output as JSON").action(async(e,i,n)=>{if(!e){fA();return}if(e==="skill"||e==="skills"){if(n.list){await e9(n);return}if(n.all||e==="skills"){await i9(n);return}i||(console.log(),m.error("Skill name required"),console.log(a.dim("Usage: gk convert skill <name>")),console.log(a.dim(" gk convert skill --list (to see available skills)")),console.log(a.dim(" gk convert skills (to convert all)")),console.log(),process.exit(1)),await t9(i,n);return}if(e==="agent"||e==="agents"){if(n.list){await n9(n);return}if(n.all||e==="agents"){await o9(n);return}i||(console.log(),m.error("Agent name required"),console.log(a.dim("Usage: gk convert agent <name>")),console.log(a.dim(" gk convert agent --list (to see available agents)")),console.log(a.dim(" gk convert agents (to convert all)")),console.log(),process.exit(1)),await r9(i,n);return}fA()})}async function e9(t){let e=yo();if(t.json){console.log(JSON.stringify(e,null,2));return}if(console.log(),console.log(p.default.bold(a.geminiPurple("Available Claude Skills"))),console.log(a.dim(` Source: ${Po()}`)),console.log(),e.length===0){m.info("No skills found in .claude/skills/"),console.log();return}for(let i of e){let n=Mc(i.name),r=n?a.success("\u2713"):a.dim("\u25CB"),o=n?a.dim(" (converted)"):"";if(console.log(` ${r} ${a.primary(i.name)}${o}`),i.description){let s=i.description.length>70?i.description.slice(0,70)+"...":i.description;console.log(` ${a.dim(s)}`)}}console.log(),console.log(a.dim(` Total: ${e.length} skills`)),console.log()}async function t9(t,e){let i=Cc(t,{force:e.force,dryRun:e.dryRun});if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),i.errors.length>0){m.error(`Failed to convert skill: ${t}`);for(let n of i.errors)console.log(` ${a.error("\u2717")} ${n}`);console.log(),process.exit(1)}if(i.skipped.length>0){m.warn(`Skipped skill: ${t}`);for(let n of i.skipped)console.log(` ${a.dim("\u25CB")} ${n}`);console.log();return}if(e.dryRun){m.info(`[DRY RUN] Would convert skill: ${t}`);for(let n of i.created)console.log(` ${a.dim("\u2192")} ${n}`);console.log();return}m.success(`Converted skill: ${a.primary(t)}`),console.log(),console.log(` ${a.dim("Created files:")}`);for(let n of i.created.slice(0,5)){let r=n.replace(process.cwd(),".");console.log(` ${a.success("+")} ${r}`)}i.created.length>5&&console.log(` ${a.dim(`... and ${i.created.length-5} more`)}`),console.log(),console.log(a.dim(` Extension created at: ${qo()}/${t}`)),console.log()}async function i9(t){if(yo().length===0){t.json?console.log(JSON.stringify({results:[],summary:{total:0,success:0,skipped:0,failed:0}},null,2)):(console.log(),m.info("No skills found in .claude/skills/"),console.log());return}let i=EA({force:t.force,dryRun:t.dryRun}),n=Oc(i);if(t.json){console.log(JSON.stringify({results:i,summary:n},null,2));return}console.log(),t.dryRun?console.log(p.default.bold(a.geminiPurple("[DRY RUN] Skill Conversion Preview"))):console.log(p.default.bold(a.geminiPurple("Skill Conversion Results"))),console.log(M.line()),console.log();for(let r of i)if(r.errors.length>0){console.log(` ${a.error("\u2717")} ${r.skill}`);for(let o of r.errors)console.log(` ${a.dim(o)}`)}else if(r.skipped.length>0)console.log(` ${a.dim("\u25CB")} ${r.skill} ${a.dim("(skipped)")}`);else if(r.success){let o=t.dryRun?a.dim("\u2192"):a.success("\u2713");console.log(` ${o} ${r.skill}`)}console.log(),console.log(M.line()),console.log(),t.dryRun?(console.log(` ${a.dim("Would convert:")} ${n.success} skills`),console.log(` ${a.dim("Would skip:")} ${n.skipped} skills`),console.log(` ${a.dim("Would fail:")} ${n.failed} skills`)):(console.log(` ${a.success("Converted:")} ${n.success}`),console.log(` ${a.dim("Skipped:")} ${n.skipped}`),console.log(` ${a.error("Failed:")} ${n.failed}`)),console.log(),n.skipped>0&&!t.force&&(m.info("Use --force to overwrite existing extensions"),console.log())}async function n9(t){let e=To();if(t.json){console.log(JSON.stringify(e,null,2));return}if(console.log(),console.log(p.default.bold(a.geminiPurple("Available Claude Agents"))),console.log(a.dim(` Source: ${Do()}`)),console.log(),e.length===0){m.info("No agents found in .claude/agents/"),console.log();return}for(let i of e){let n=Uc(i.name),r=n?a.success("\u2713"):a.dim("\u25CB"),o=n?a.dim(" (converted)"):"";if(console.log(` ${r} ${a.primary(i.name)}${o}`),i.model&&console.log(` ${a.dim("Model:")} ${i.model}`),i.description){let s=i.description.length>60?i.description.slice(0,60)+"...":i.description;console.log(` ${a.dim(s)}`)}}console.log(),console.log(a.dim(` Total: ${e.length} agents`)),console.log()}async function r9(t,e){let i=Kc(t,{force:e.force,dryRun:e.dryRun});if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),i.errors.length>0){m.error(`Failed to convert agent: ${t}`);for(let n of i.errors)console.log(` ${a.error("\u2717")} ${n}`);console.log(),process.exit(1)}if(i.skipped.length>0){m.warn(`Skipped agent: ${t}`);for(let n of i.skipped)console.log(` ${a.dim("\u25CB")} ${n}`);console.log();return}if(e.dryRun){m.info(`[DRY RUN] Would convert agent: ${t}`);for(let n of i.created)console.log(` ${a.dim("\u2192")} ${n}`);console.log();return}m.success(`Converted agent: ${a.primary(t)}`),console.log();for(let n of i.created){let r=n.replace(process.cwd(),".");console.log(` ${a.success("+")} ${r}`)}console.log(),console.log(a.dim(` Agent created at: ${wo()}/${t}.md`)),console.log()}async function o9(t){if(To().length===0){t.json?console.log(JSON.stringify({results:[],summary:{total:0,success:0,skipped:0,failed:0}},null,2)):(console.log(),m.info("No agents found in .claude/agents/"),console.log());return}let i=pA({force:t.force,dryRun:t.dryRun}),n=Oc(i);if(t.json){console.log(JSON.stringify({results:i,summary:n},null,2));return}console.log(),t.dryRun?console.log(p.default.bold(a.geminiPurple("[DRY RUN] Agent Conversion Preview"))):console.log(p.default.bold(a.geminiPurple("Agent Conversion Results"))),console.log(M.line()),console.log();for(let r of i)if(r.errors.length>0){console.log(` ${a.error("\u2717")} ${r.skill}`);for(let o of r.errors)console.log(` ${a.dim(o)}`)}else if(r.skipped.length>0)console.log(` ${a.dim("\u25CB")} ${r.skill} ${a.dim("(skipped)")}`);else if(r.success){let o=t.dryRun?a.dim("\u2192"):a.success("\u2713");console.log(` ${o} ${r.skill}`)}console.log(),console.log(M.line()),console.log(),t.dryRun?(console.log(` ${a.dim("Would convert:")} ${n.success} agents`),console.log(` ${a.dim("Would skip:")} ${n.skipped} agents`),console.log(` ${a.dim("Would fail:")} ${n.failed} agents`)):(console.log(` ${a.success("Converted:")} ${n.success}`),console.log(` ${a.dim("Skipped:")} ${n.skipped}`),console.log(` ${a.error("Failed:")} ${n.failed}`)),console.log(),n.skipped>0&&!t.force&&(m.info("Use --force to overwrite existing agents"),console.log())}function Kt(){return{orchestrator:null,agents:new Map,sessionId:null,projectDir:null,activePlan:null,appName:null,currentNotification:null,inbox:[],documents:[],isActive:!1}}var s9=[[/research|search|analyze/i,"\u{1F50D}"],[/code|implement|execute|develop/i,"\u{1F4BB}"],[/plan|architect/i,"\u{1F4CB}"],[/debug|fix|troubleshoot/i,"\u{1F41B}"],[/test|qa|quality/i,"\u{1F9EA}"],[/design|ui|ux/i,"\u{1F3A8}"],[/review|audit|check/i,"\u2705"],[/doc|write|content/i,"\u{1F4DD}"]];function Xo(t,e=!1){if(e)return"\u{1F451}";for(let[i,n]of s9)if(i.test(t))return n;return"\u{1F916}"}function Vc(t){return t.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function kc(t){let e=t.toLowerCase();return e.includes("main")?"orchestrator":e.includes("research")||e.includes("scout")?"researcher":e.includes("code")||e.includes("executor")||e.includes("debug")?"coder":e.includes("plan")?"planner":e.includes("test")?"tester":e.includes("design")||e.includes("ui")||e.includes("ux")||e.includes("artist")?"designer":e.includes("doc")||e.includes("writer")?"writer":e.includes("manager")||e.includes("git")?"manager":"other"}function Nc(t,e){return t.agentType==="Main Agent"||t.parentGkSessionId===null||t.gkSessionId===e.gkSessionId}function a9(t,e){return t==="active"?"working":"idle"}function c9(t){if(t.status==="completed")return 100;if(t.status==="failed"||!t.startTime)return 0;let e=new Date(t.startTime).getTime(),n=Date.now()-e;return Math.min(100,Math.round(n/12e4*100))}function l9(t){return t.status==="completed"?"Task complete!":t.status==="failed"?"Task failed":t.injected?.skills?.length?`Working on ${t.injected.skills[0]}...`:null}function dA(t,e){let i=Nc(t,e),n=!!(t.injected?.skills?.length&&t.status==="active"),r=t.agentRole||"unknown",o={id:t.gkSessionId,agentType:i?"orchestrator":"sub-agent",role:r,characterType:kc(r),icon:Xo(r,i),state:a9(t.status,n),activeSkill:t.injected?.skills?.[0]||null,progress:c9(t),speechBubble:l9(t),hasFireEffect:n,gkSessionId:t.gkSessionId,parentSessionId:t.parentGkSessionId};if(i){let s=e.agents.filter(c=>!Nc(c,e));return{...o,agentType:"orchestrator",delegatedTo:s.filter(c=>c.status==="active").map(c=>c.gkSessionId),totalSubAgents:s.length,completedSubAgents:s.filter(c=>c.status==="completed").length}}return o}function RA(t){let e=t.endTime&&t.startTime?new Date(t.endTime).getTime()-new Date(t.startTime).getTime():0;return{id:`inbox-${t.gkSessionId}`,agentId:t.gkSessionId,agentRole:t.agentRole||"unknown",agentIcon:Xo(t.agentRole||""),timestamp:t.endTime?new Date(t.endTime).getTime():Date.now(),status:"unread",title:`${Vc(t.agentRole||"Agent")} completed`,preview:t.prompt?t.prompt.slice(0,100):"Task completed",fullContent:null,tokenUsage:t.tokenUsage?{input:t.tokenUsage.input,output:t.tokenUsage.output}:null,duration:e,skillsUsed:t.injected?.skills||[]}}function Di(t){let e=Kt();if(!t)return e;e.sessionId=t.gkSessionId,e.projectDir=t.projectDir,e.activePlan=t.activePlan,e.appName=t.appName||null,e.isActive=t.agents.some(i=>i.status==="active");for(let i of t.agents){let n=dA(i,t);n.agentType==="orchestrator"?e.orchestrator=n:e.agents.set(n.id,n),i.status==="completed"&&(e.inbox.find(o=>o.agentId===i.gkSessionId)||e.inbox.push(RA(i)))}return e.inbox.sort((i,n)=>n.timestamp-i.timestamp),e}import{existsSync as wi,readdirSync as Ho,statSync as Fc}from"fs";import{join as ct,basename as v9,extname as zA,relative as A9}from"path";import{createHash as u9}from"crypto";function m9(t,e){let i={plan:"\u{1F4CB}",phase:"\u{1F4D1}",research:"\u{1F50D}",artifact:"\u{1F4E6}",report:"\u{1F4CA}",other:"\u{1F4C4}"};return t==="artifact"?{sql:"\u{1F5C4}\uFE0F",json:"\u{1F4E6}",png:"\u{1F5BC}\uFE0F",jpg:"\u{1F5BC}\uFE0F",ts:"\u{1F4BB}",js:"\u{1F4BB}"}[e]||i.artifact:i[t]}function jA(t){let e=t.match(/^phase-(\d+)/);return e?parseInt(e[1],10):null}function E9(t,e){if(e==="phase"){let i=jA(t),n=t.replace(/^phase-\d+-?/,"").replace(/-/g," ");return i!==null?`Phase ${i}: ${n}`:t}return t.replace(/-/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function Ti(t,e,i){let n=Fc(t),r=v9(t,zA(t)),o=zA(t).slice(1);return{id:u9("md5").update(t).digest("hex").slice(0,8),name:r,displayName:E9(r,e),type:e,icon:m9(e,o),path:t,relativePath:A9(i,t),modifiedAt:n.mtimeMs,createdAt:n.birthtimeMs,size:n.size,extension:o,phaseNumber:jA(r)}}function Qc(t){if(!wi(t))return[];let e=[],i=ct(t,"plan.md");wi(i)&&e.push(Ti(i,"plan",t));let n=Ho(t);for(let c of n){let l=ct(t,c),v=Fc(l);if(c.startsWith("phase-"))if(v.isDirectory()){let A=ct(l,"phase.md");wi(A)&&e.push(Ti(A,"phase",t))}else c.endsWith(".md")&&e.push(Ti(l,"phase",t))}let r=ct(t,"research");if(wi(r)){let c=Ho(r).filter(l=>l.endsWith(".md"));for(let l of c)e.push(Ti(ct(r,l),"research",t))}let o=ct(t,"artifacts");if(wi(o)){let c=Ho(o);for(let l of c){let v=ct(o,l);Fc(v).isFile()&&e.push(Ti(v,"artifact",t))}}let s=ct(t,"reports");if(wi(s)){let c=Ho(s).filter(l=>l.endsWith(".md"));for(let l of c)e.push(Ti(ct(s,l),"report",t))}return e.sort((c,l)=>l.modifiedAt-c.modifiedAt),e}var I9=1e3,Vt=class{state;stateListeners=new Set;eventListeners=new Set;eventHistory=[];constructor(e){this.state=e}onStateChange(e){return this.stateListeners.add(e),e(this.state),()=>this.stateListeners.delete(e)}onEvent(e){return this.eventListeners.add(e),()=>this.eventListeners.delete(e)}emit(e){this.eventHistory.push(e),this.eventHistory.length>I9&&this.eventHistory.shift();for(let i of this.eventListeners)try{i(e)}catch(n){console.error("Event listener error:",n)}}setState(e){this.state=e;for(let i of this.stateListeners)try{i(this.state)}catch(n){console.error("State listener error:",n)}}getState(){return this.state}getHistory(){return[...this.eventHistory]}replay(e){return this.eventHistory.filter(i=>i.timestamp>=e)}dispose(){this.stateListeners.clear(),this.eventListeners.clear(),this.eventHistory=[]}};import{existsSync as p9,readFileSync as f9,statSync as gA}from"fs";var h9=200,Nt=class{pollInterval=null;previousSession=null;previousMtime=0;options;sessionPath=null;constructor(e){this.options=e}start(){let e=N(),i=e.PROJECT_DIR,n=e.ACTIVE_GK_SESSION_ID;if(!i||!n)return this.options.onError(new Error("No active session found")),!1;if(this.sessionPath=Zt(i,n),!p9(this.sessionPath))return this.options.onError(new Error(`Session file not found: ${this.sessionPath}`)),!1;try{let r=gA(this.sessionPath);this.previousMtime=r.mtimeMs}catch{}return this.loadSession(),this.pollInterval=setInterval(()=>{this.checkForChanges()},h9),!0}stop(){this.pollInterval&&(clearInterval(this.pollInterval),this.pollInterval=null)}checkForChanges(){if(this.sessionPath)try{let i=gA(this.sessionPath).mtimeMs;i>this.previousMtime&&(this.previousMtime=i,this.loadSession())}catch{}}loadSession(){if(this.sessionPath)try{let e=f9(this.sessionPath,"utf-8"),i=JSON.parse(e),n=this.previousSession?this.diffSessions(this.previousSession,i):[];this.previousSession=i,this.options.onSessionChange(i);for(let r of n)this.options.onEvent(r)}catch(e){this.options.onError(e)}}diffSessions(e,i){let n=[],r=Date.now(),o=new Map(e.agents.map(l=>[l.gkSessionId,l]));for(let l of i.agents){let v=o.get(l.gkSessionId);if(!v)n.push(this.createEvent("received_work",l,r)),l.injected?.skills?.length&&n.push(this.createEvent("skill_activated",l,r,l.injected.skills[0]));else{v.status==="active"&&l.status==="completed"&&(n.push(this.createEvent("task_complete",l,r)),n.push(this.createEvent("delivering",l,r)));let A=v.injected?.skills||[],I=(l.injected?.skills||[]).filter(E=>!A.includes(E));for(let E of I)n.push(this.createEvent("skill_activated",l,r,E))}}let s=i.agents.every(l=>l.status==="completed"||l.status==="failed"),c=e.agents.some(l=>l.status==="active");return s&&c&&i.agents.length>0&&n.push({type:"session_complete",agentId:i.gkSessionId,targetAgentId:null,skill:null,message:"All tasks completed",timestamp:r}),n}createEvent(e,i,n,r){let o={agent_idle:"Waiting for work",agent_working:"Working...",skill_activated:`Activated skill: ${r||"unknown"}`,handoff_start:"Passing work...",handoff_complete:"Handoff complete!",received_work:"Received work",delivering:"Delivering results...",task_complete:"Task complete!",session_complete:"All tasks completed"};return{type:e,agentId:i.gkSessionId,targetAgentId:i.parentGkSessionId,skill:r||i.injected?.skills?.[0]||null,message:o[e],timestamp:n,characterType:kc(i.agentRole||"coder")}}};import{exec as g9}from"child_process";import{join as x9}from"path";import{createServer as d9}from"http";import{WebSocketServer as R9,WebSocket as GA}from"ws";import{exec as z9}from"child_process";import{existsSync as SA}from"fs";import{resolve as j9}from"path";function xA(){return`<!DOCTYPE html>
|
|
199
|
+
`.trim();try{let i=zt("osascript",["-e",e],{encoding:"utf-8",timeout:5e3});if(i.stdout&&i.stdout.trim()!=="NO_FILE"){let r=i.stdout.trim();if(!bu(r))return{success:!1,error:"Clipboard does not contain a video file",suggestion:"Copy a video file (.mp4, .mov, .webm) to clipboard first"};if(!We(r))return{success:!1,error:"Video file not found"};let s=wn(r),o=Ya(s),c=Ye(t,o);if(Ma(r,c),We(c))return{success:!0,path:c,sourcePath:r,sourceType:"clipboard"}}let n=lA([Ye(qn(),"Movies"),Ye(qn(),"Desktop")],t);return n||{success:!1,error:"No video in clipboard or recent recordings",suggestion:"Copy a video file or use Cmd+Shift+5 to record screen"}}catch(i){return{success:!1,error:`macOS video capture error: ${i instanceof Error?i.message:String(i)}`}}}function $E(t){try{if(zt("which",["xclip"],{encoding:"utf-8"}).status!==0)return{success:!1,error:"xclip is not installed",suggestion:"Install with: sudo apt install xclip"};let i=zt("xclip",["-selection","clipboard","-t","text/uri-list","-o"],{encoding:"utf-8",timeout:5e3});if(i.status===0&&i.stdout){let r=i.stdout.trim(),s=r;if(r.startsWith("file://")&&(s=decodeURIComponent(r.replace("file://",""))),bu(s)&&We(s)){let o=wn(s),c=Ya(o),l=Ye(t,c);if(Ma(s,l),We(l))return{success:!0,path:l,sourcePath:s,sourceType:"clipboard"}}}let n=lA([Ye(qn(),"Videos"),Ye(qn(),"Screencasts"),Ye(qn(),"Desktop")],t);return n||{success:!1,error:"No video in clipboard or recent recordings",suggestion:"Copy a video file or use a screen recorder first"}}catch(e){return{success:!1,error:`Linux video capture error: ${e instanceof Error?e.message:String(e)}`}}}function e9(t){if(t.success&&t.path){let i=(Fu(t.path).size/(1024*1024)).toFixed(2),n=wn(t.path).toLowerCase();return{success:!0,message:`Video captured from ${t.sourceType}`,path:t.path,sourcePath:t.sourcePath,sourceType:t.sourceType,size:`${i} MB`,format:n.substring(1).toUpperCase(),platform:t.platform}}return{success:!1,error:t.error,suggestion:t.suggestion||"Record a video with Snipping Tool (Win+Shift+R) or copy a video file to clipboard",platform:t.platform}}var uA={"claude-3-opus":"gemini-2.5-pro","claude-3-sonnet":"gemini-2.5-flash","claude-3-haiku":"gemini-2.5-flash","claude-3.5-sonnet":"gemini-2.5-pro","claude-3.5-haiku":"gemini-2.5-flash","gemini-2.5-pro":"gemini-2.5-pro","gemini-2.5-flash":"gemini-2.5-flash","gemini-3-flash-preview":"gemini-3-flash-preview"};import{existsSync as Ce,readFileSync as Wa,readdirSync as Ca,mkdirSync as Bu,writeFileSync as mA,copyFileSync as Pu,statSync as vA}from"fs";import{join as O}from"path";var t9=".claude/skills",i9=".gemini/extensions",n9=".claude/agents",r9=".gemini/agents";function Ju(t){let e=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!e)return null;let i={name:"",description:""},n=e[1].split(/\r?\n/);for(let r of n){let s=r.indexOf(":");if(s===-1)continue;let o=r.slice(0,s).trim(),c=r.slice(s+1).trim();(c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),i[o]=c}return i}function Oa(t=process.cwd()){return O(t,t9)}function Ua(t=process.cwd()){return O(t,i9)}function Ka(t=process.cwd()){let e=Oa(t);if(!Ce(e))return[];let i=[];try{let n=Ca(e,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>r.name);for(let r of n){let s=O(e,r),o=O(s,"SKILL.md"),c=O(s,"references"),l=Ce(o),u=Ce(c)&&vA(c).isDirectory(),m;if(l)try{let p=Wa(o,"utf-8");m=Ju(p)?.description}catch{}i.push({name:r,path:s,hasSkillMd:l,hasReferences:u,description:m})}}catch{}return i.sort((n,r)=>n.name.localeCompare(r.name))}function Zu(t,e=process.cwd()){let i=O(Ua(e),t);return Ce(i)}function s9(t,e){let i=["SKILL.md"];return e&&i.push("references/*.md"),{name:t.name||"",version:"1.0.0",description:t.description||"",license:"MIT",contextFileName:i}}function Qu(t,e,i){Ce(e)||(Bu(e,{recursive:!0}),i.push(e));let n=Ca(t,{withFileTypes:!0});for(let r of n){let s=O(t,r.name),o=O(e,r.name);r.isDirectory()?Qu(s,o,i):(Pu(s,o),i.push(o))}}function yu(t,e={},i=process.cwd()){let n={skill:t,success:!1,created:[],skipped:[],errors:[]},r=Oa(i),s=Ua(i),o=O(r,t),c=O(s,t);if(!Ce(o))return n.errors.push(`Skill not found: ${t}`),n;let l=O(o,"SKILL.md");if(!Ce(l))return n.errors.push(`SKILL.md not found in ${t}`),n;if(Zu(t,i)&&!e.force)return n.skipped.push(`Extension already exists: ${t} (use --force to overwrite)`),n;let u=null;try{let A=Wa(l,"utf-8");u=Ju(A)}catch(A){return n.errors.push(`Failed to read SKILL.md: ${A instanceof Error?A.message:String(A)}`),n}(!u||!u.name)&&(u={name:t,description:""});let m=O(o,"references"),p=Ce(m)&&vA(m).isDirectory(),d=s9(u,p);if(e.dryRun)return n.created.push(`[DRY RUN] Would create: ${c}`),n.created.push(`[DRY RUN] Would create: ${O(c,"gemini-extension.json")}`),n.created.push("[DRY RUN] Would copy: SKILL.md"),p&&n.created.push("[DRY RUN] Would copy: references/"),n.success=!0,n;try{Ce(c)||(Bu(c,{recursive:!0}),n.created.push(c));let A=O(c,"gemini-extension.json");mA(A,JSON.stringify(d,null,2)+`
|
|
200
|
+
`),n.created.push(A);let f=O(c,"SKILL.md");if(Pu(l,f),n.created.push(f),p){let E=O(c,"references");Qu(m,E,n.created)}let g=Ca(o,{withFileTypes:!0});for(let E of g){if(E.name==="SKILL.md"||E.name==="references")continue;let J=O(o,E.name),M=O(c,E.name);E.isDirectory()?Qu(J,M,n.created):(Pu(J,M),n.created.push(M))}n.success=!0}catch(A){n.errors.push(`Failed to convert: ${A instanceof Error?A.message:String(A)}`)}return n}function pA(t={},e=process.cwd()){let i=Ka(e),n=[];for(let r of i){let s=yu(r.name,t,e);n.push(s)}return n}function qu(t){return{total:t.length,success:t.filter(e=>e.success&&e.errors.length===0&&e.skipped.length===0).length,skipped:t.filter(e=>e.skipped.length>0).length,failed:t.filter(e=>e.errors.length>0).length}}function ka(t=process.cwd()){return O(t,n9)}function Va(t=process.cwd()){return O(t,r9)}function AA(t){let e=Ju(t);return e?{name:e.name||"",description:e.description||"",model:e.model,skills:e.skills}:null}function Na(t=process.cwd()){let e=ka(t);if(!Ce(e))return[];let i=[];try{let n=Ca(e,{withFileTypes:!0}).filter(r=>r.isFile()&&r.name.endsWith(".md")).map(r=>r.name);for(let r of n){let s=O(e,r),o=r.replace(/\.md$/,""),c,l,u;try{let m=Wa(s,"utf-8"),p=AA(m);p&&(c=p.description,l=p.model,u=p.skills)}catch{}i.push({name:o,path:s,description:c,model:l,skills:u})}}catch{}return i.sort((n,r)=>n.name.localeCompare(r.name))}function wu(t,e=process.cwd()){let i=O(Va(e),`${t}.md`);return Ce(i)}function o9(t){if(t)return uA[t]||t}function a9(t,e){let i=t.match(/^(---\r?\n)([\s\S]*?)(\r?\n---)/);if(!i)return t;let[n,r,s,o]=i,c=s.split(/\r?\n/),l=[],u=new Set;for(let p of c){let d=p.indexOf(":");if(d===-1){l.push(p);continue}let A=p.slice(0,d).trim();A in e?(u.add(A),e[A]!==void 0&&l.push(`${A}: ${e[A]}`)):l.push(p)}for(let[p,d]of Object.entries(e))!u.has(p)&&d!==void 0&&l.push(`${p}: ${d}`);let m=r+l.join(`
|
|
201
|
+
`)+o;return t.replace(n,m)}function Du(t,e={},i=process.cwd()){let n={skill:t,success:!1,created:[],skipped:[],errors:[]},r=ka(i),s=Va(i),o=O(r,`${t}.md`),c=O(s,`${t}.md`);if(!Ce(o))return n.errors.push(`Agent not found: ${t}`),n;if(wu(t,i)&&!e.force)return n.skipped.push(`Agent already exists in .gemini/agents: ${t} (use --force to overwrite)`),n;let l;try{l=Wa(o,"utf-8")}catch(A){return n.errors.push(`Failed to read agent file: ${A instanceof Error?A.message:String(A)}`),n}let m=AA(l)?.model,p=o9(m),d=l;if(m&&p&&m!==p&&(d=a9(l,{model:p})),e.dryRun)return n.created.push(`[DRY RUN] Would create: ${c}`),m&&p&&m!==p&&n.created.push(`[DRY RUN] Would map model: ${m} -> ${p}`),n.success=!0,n;try{Ce(s)||Bu(s,{recursive:!0}),mA(c,d),n.created.push(c),m&&p&&m!==p&&n.created.push(`Model mapped: ${m} -> ${p}`),n.success=!0}catch(A){n.errors.push(`Failed to convert: ${A instanceof Error?A.message:String(A)}`)}return n}function dA(t={},e=process.cwd()){let i=Na(e),n=[];for(let r of i){let s=Du(r.name,t,e);n.push(s)}return n}function fA(){console.log(),console.log(h.default.bold(a.geminiPurple("Convert .claude to .gemini"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk convert")} <type> [name] [options]`),console.log(),console.log("Types:"),console.log(` ${a.primary("skill")} <name> Convert a single skill to extension`),console.log(` ${a.primary("skills")} Convert all skills to extensions`),console.log(` ${a.primary("agent")} <name> Convert a single agent`),console.log(` ${a.primary("agents")} Convert all agents`),console.log(),console.log("Options:"),console.log(` ${a.dim("--list")} List available items`),console.log(` ${a.dim("--force")} Overwrite existing items`),console.log(` ${a.dim("--dry-run")} Show what would be done without changes`),console.log(` ${a.dim("--json")} Output as JSON`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk convert skill --list")}`),console.log(` ${a.dim("gk convert skill my-skill")}`),console.log(` ${a.dim("gk convert skills --force")}`),console.log(` ${a.dim("gk convert agent --list")}`),console.log(` ${a.dim("gk convert agents --dry-run")}`),console.log()}function hA(t){t.command("convert [type] [name]","Convert .claude to .gemini resources").alias("cv").option("--all","[all] Convert all items").option("--list","[all] List available items").option("--force","[all] Overwrite existing items").option("--dry-run","[all] Show what would be done without making changes").option("--json","[all] Output as JSON").action(async(e,i,n)=>{if(!e){fA();return}if(e==="skill"||e==="skills"){if(n.list){await c9(n);return}if(n.all||e==="skills"){await u9(n);return}i||(console.log(),v.error("Skill name required"),console.log(a.dim("Usage: gk convert skill <name>")),console.log(a.dim(" gk convert skill --list (to see available skills)")),console.log(a.dim(" gk convert skills (to convert all)")),console.log(),process.exit(1)),await l9(i,n);return}if(e==="agent"||e==="agents"){if(n.list){await m9(n);return}if(n.all||e==="agents"){await p9(n);return}i||(console.log(),v.error("Agent name required"),console.log(a.dim("Usage: gk convert agent <name>")),console.log(a.dim(" gk convert agent --list (to see available agents)")),console.log(a.dim(" gk convert agents (to convert all)")),console.log(),process.exit(1)),await v9(i,n);return}fA()})}async function c9(t){let e=Ka();if(t.json){console.log(JSON.stringify(e,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Available Claude Skills"))),console.log(a.dim(` Source: ${Oa()}`)),console.log(),e.length===0){v.info("No skills found in .claude/skills/"),console.log();return}for(let i of e){let n=Zu(i.name),r=n?a.success("\u2713"):a.dim("\u25CB"),s=n?a.dim(" (converted)"):"";if(console.log(` ${r} ${a.primary(i.name)}${s}`),i.description){let o=i.description.length>70?i.description.slice(0,70)+"...":i.description;console.log(` ${a.dim(o)}`)}}console.log(),console.log(a.dim(` Total: ${e.length} skills`)),console.log()}async function l9(t,e){let i=yu(t,{force:e.force,dryRun:e.dryRun});if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),i.errors.length>0){v.error(`Failed to convert skill: ${t}`);for(let n of i.errors)console.log(` ${a.error("\u2717")} ${n}`);console.log(),process.exit(1)}if(i.skipped.length>0){v.warn(`Skipped skill: ${t}`);for(let n of i.skipped)console.log(` ${a.dim("\u25CB")} ${n}`);console.log();return}if(e.dryRun){v.info(`[DRY RUN] Would convert skill: ${t}`);for(let n of i.created)console.log(` ${a.dim("\u2192")} ${n}`);console.log();return}v.success(`Converted skill: ${a.primary(t)}`),console.log(),console.log(` ${a.dim("Created files:")}`);for(let n of i.created.slice(0,5)){let r=n.replace(process.cwd(),".");console.log(` ${a.success("+")} ${r}`)}i.created.length>5&&console.log(` ${a.dim(`... and ${i.created.length-5} more`)}`),console.log(),console.log(a.dim(` Extension created at: ${Ua()}/${t}`)),console.log()}async function u9(t){if(Ka().length===0){t.json?console.log(JSON.stringify({results:[],summary:{total:0,success:0,skipped:0,failed:0}},null,2)):(console.log(),v.info("No skills found in .claude/skills/"),console.log());return}let i=pA({force:t.force,dryRun:t.dryRun}),n=qu(i);if(t.json){console.log(JSON.stringify({results:i,summary:n},null,2));return}console.log(),t.dryRun?console.log(h.default.bold(a.geminiPurple("[DRY RUN] Skill Conversion Preview"))):console.log(h.default.bold(a.geminiPurple("Skill Conversion Results"))),console.log(G.line()),console.log();for(let r of i)if(r.errors.length>0){console.log(` ${a.error("\u2717")} ${r.skill}`);for(let s of r.errors)console.log(` ${a.dim(s)}`)}else if(r.skipped.length>0)console.log(` ${a.dim("\u25CB")} ${r.skill} ${a.dim("(skipped)")}`);else if(r.success){let s=t.dryRun?a.dim("\u2192"):a.success("\u2713");console.log(` ${s} ${r.skill}`)}console.log(),console.log(G.line()),console.log(),t.dryRun?(console.log(` ${a.dim("Would convert:")} ${n.success} skills`),console.log(` ${a.dim("Would skip:")} ${n.skipped} skills`),console.log(` ${a.dim("Would fail:")} ${n.failed} skills`)):(console.log(` ${a.success("Converted:")} ${n.success}`),console.log(` ${a.dim("Skipped:")} ${n.skipped}`),console.log(` ${a.error("Failed:")} ${n.failed}`)),console.log(),n.skipped>0&&!t.force&&(v.info("Use --force to overwrite existing extensions"),console.log())}async function m9(t){let e=Na();if(t.json){console.log(JSON.stringify(e,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Available Claude Agents"))),console.log(a.dim(` Source: ${ka()}`)),console.log(),e.length===0){v.info("No agents found in .claude/agents/"),console.log();return}for(let i of e){let n=wu(i.name),r=n?a.success("\u2713"):a.dim("\u25CB"),s=n?a.dim(" (converted)"):"";if(console.log(` ${r} ${a.primary(i.name)}${s}`),i.model&&console.log(` ${a.dim("Model:")} ${i.model}`),i.description){let o=i.description.length>60?i.description.slice(0,60)+"...":i.description;console.log(` ${a.dim(o)}`)}}console.log(),console.log(a.dim(` Total: ${e.length} agents`)),console.log()}async function v9(t,e){let i=Du(t,{force:e.force,dryRun:e.dryRun});if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),i.errors.length>0){v.error(`Failed to convert agent: ${t}`);for(let n of i.errors)console.log(` ${a.error("\u2717")} ${n}`);console.log(),process.exit(1)}if(i.skipped.length>0){v.warn(`Skipped agent: ${t}`);for(let n of i.skipped)console.log(` ${a.dim("\u25CB")} ${n}`);console.log();return}if(e.dryRun){v.info(`[DRY RUN] Would convert agent: ${t}`);for(let n of i.created)console.log(` ${a.dim("\u2192")} ${n}`);console.log();return}v.success(`Converted agent: ${a.primary(t)}`),console.log();for(let n of i.created){let r=n.replace(process.cwd(),".");console.log(` ${a.success("+")} ${r}`)}console.log(),console.log(a.dim(` Agent created at: ${Va()}/${t}.md`)),console.log()}async function p9(t){if(Na().length===0){t.json?console.log(JSON.stringify({results:[],summary:{total:0,success:0,skipped:0,failed:0}},null,2)):(console.log(),v.info("No agents found in .claude/agents/"),console.log());return}let i=dA({force:t.force,dryRun:t.dryRun}),n=qu(i);if(t.json){console.log(JSON.stringify({results:i,summary:n},null,2));return}console.log(),t.dryRun?console.log(h.default.bold(a.geminiPurple("[DRY RUN] Agent Conversion Preview"))):console.log(h.default.bold(a.geminiPurple("Agent Conversion Results"))),console.log(G.line()),console.log();for(let r of i)if(r.errors.length>0){console.log(` ${a.error("\u2717")} ${r.skill}`);for(let s of r.errors)console.log(` ${a.dim(s)}`)}else if(r.skipped.length>0)console.log(` ${a.dim("\u25CB")} ${r.skill} ${a.dim("(skipped)")}`);else if(r.success){let s=t.dryRun?a.dim("\u2192"):a.success("\u2713");console.log(` ${s} ${r.skill}`)}console.log(),console.log(G.line()),console.log(),t.dryRun?(console.log(` ${a.dim("Would convert:")} ${n.success} agents`),console.log(` ${a.dim("Would skip:")} ${n.skipped} agents`),console.log(` ${a.dim("Would fail:")} ${n.failed} agents`)):(console.log(` ${a.success("Converted:")} ${n.success}`),console.log(` ${a.dim("Skipped:")} ${n.skipped}`),console.log(` ${a.error("Failed:")} ${n.failed}`)),console.log(),n.skipped>0&&!t.force&&(v.info("Use --force to overwrite existing agents"),console.log())}function ji(){return{orchestrator:null,agents:new Map,sessionId:null,projectDir:null,activePlan:null,appName:null,currentNotification:null,inbox:[],documents:[],isActive:!1}}var A9=[[/research|search|analyze/i,"\u{1F50D}"],[/code|implement|execute|develop/i,"\u{1F4BB}"],[/plan|architect/i,"\u{1F4CB}"],[/debug|fix|troubleshoot/i,"\u{1F41B}"],[/test|qa|quality/i,"\u{1F9EA}"],[/design|ui|ux/i,"\u{1F3A8}"],[/review|audit|check/i,"\u2705"],[/doc|write|content/i,"\u{1F4DD}"]];function Fa(t,e=!1){if(e)return"\u{1F451}";for(let[i,n]of A9)if(i.test(t))return n;return"\u{1F916}"}function Tu(t){return t.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function Hu(t){let e=t.toLowerCase();return e.includes("main")?"orchestrator":e.includes("research")||e.includes("scout")?"researcher":e.includes("code")||e.includes("executor")||e.includes("debug")?"coder":e.includes("plan")?"planner":e.includes("test")?"tester":e.includes("design")||e.includes("ui")||e.includes("ux")||e.includes("artist")?"designer":e.includes("doc")||e.includes("writer")?"writer":e.includes("manager")||e.includes("git")?"manager":"other"}function Xu(t,e){return t.agentType==="Main Agent"||t.parentGkSessionId===null||t.gkSessionId===e.gkSessionId}function d9(t,e){return t==="active"?"working":"idle"}function f9(t){if(t.status==="completed")return 100;if(t.status==="failed"||!t.startTime)return 0;let e=new Date(t.startTime).getTime(),n=Date.now()-e;return Math.min(100,Math.round(n/12e4*100))}function h9(t){return t.status==="completed"?"Task complete!":t.status==="failed"?"Task failed":t.injected?.skills?.length?`Working on ${t.injected.skills[0]}...`:null}function gA(t,e){let i=Xu(t,e),n=!!(t.injected?.skills?.length&&t.status==="active"),r=t.agentRole||"unknown",s={id:t.gkSessionId,agentType:i?"orchestrator":"sub-agent",role:r,characterType:Hu(r),icon:Fa(r,i),state:d9(t.status,n),activeSkill:t.injected?.skills?.[0]||null,progress:f9(t),speechBubble:h9(t),hasFireEffect:n,gkSessionId:t.gkSessionId,parentSessionId:t.parentGkSessionId};if(i){let o=e.agents.filter(c=>!Xu(c,e));return{...s,agentType:"orchestrator",delegatedTo:o.filter(c=>c.status==="active").map(c=>c.gkSessionId),totalSubAgents:o.length,completedSubAgents:o.filter(c=>c.status==="completed").length}}return s}function IA(t){let e=t.endTime&&t.startTime?new Date(t.endTime).getTime()-new Date(t.startTime).getTime():0;return{id:`inbox-${t.gkSessionId}`,agentId:t.gkSessionId,agentRole:t.agentRole||"unknown",agentIcon:Fa(t.agentRole||""),timestamp:t.endTime?new Date(t.endTime).getTime():Date.now(),status:"unread",title:`${Tu(t.agentRole||"Agent")} completed`,preview:t.prompt?t.prompt.slice(0,100):"Task completed",fullContent:null,tokenUsage:t.tokenUsage?{input:t.tokenUsage.input,output:t.tokenUsage.output}:null,duration:e,skillsUsed:t.injected?.skills||[]}}function Dn(t){let e=ji();if(!t)return e;e.sessionId=t.gkSessionId,e.projectDir=t.projectDir,e.activePlan=t.activePlan,e.appName=t.appName||null,e.isActive=t.agents.some(i=>i.status==="active");for(let i of t.agents){let n=gA(i,t);n.agentType==="orchestrator"?e.orchestrator=n:e.agents.set(n.id,n),i.status==="completed"&&(e.inbox.find(s=>s.agentId===i.gkSessionId)||e.inbox.push(IA(i)))}return e.inbox.sort((i,n)=>n.timestamp-i.timestamp),e}import{existsSync as Tn,readdirSync as ba,statSync as Lu}from"fs";import{join as yt,basename as g9,extname as EA,relative as I9}from"path";import{createHash as E9}from"crypto";function R9(t,e){let i={plan:"\u{1F4CB}",phase:"\u{1F4D1}",research:"\u{1F50D}",artifact:"\u{1F4E6}",report:"\u{1F4CA}",other:"\u{1F4C4}"};return t==="artifact"?{sql:"\u{1F5C4}\uFE0F",json:"\u{1F4E6}",png:"\u{1F5BC}\uFE0F",jpg:"\u{1F5BC}\uFE0F",ts:"\u{1F4BB}",js:"\u{1F4BB}"}[e]||i.artifact:i[t]}function RA(t){let e=t.match(/^phase-(\d+)/);return e?parseInt(e[1],10):null}function z9(t,e){if(e==="phase"){let i=RA(t),n=t.replace(/^phase-\d+-?/,"").replace(/-/g," ");return i!==null?`Phase ${i}: ${n}`:t}return t.replace(/-/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function Xn(t,e,i){let n=Lu(t),r=g9(t,EA(t)),s=EA(t).slice(1);return{id:E9("md5").update(t).digest("hex").slice(0,8),name:r,displayName:z9(r,e),type:e,icon:R9(e,s),path:t,relativePath:I9(i,t),modifiedAt:n.mtimeMs,createdAt:n.birthtimeMs,size:n.size,extension:s,phaseNumber:RA(r)}}function _u(t){if(!Tn(t))return[];let e=[],i=yt(t,"plan.md");Tn(i)&&e.push(Xn(i,"plan",t));let n=ba(t);for(let c of n){let l=yt(t,c),u=Lu(l);if(c.startsWith("phase-"))if(u.isDirectory()){let m=yt(l,"phase.md");Tn(m)&&e.push(Xn(m,"phase",t))}else c.endsWith(".md")&&e.push(Xn(l,"phase",t))}let r=yt(t,"research");if(Tn(r)){let c=ba(r).filter(l=>l.endsWith(".md"));for(let l of c)e.push(Xn(yt(r,l),"research",t))}let s=yt(t,"artifacts");if(Tn(s)){let c=ba(s);for(let l of c){let u=yt(s,l);Lu(u).isFile()&&e.push(Xn(u,"artifact",t))}}let o=yt(t,"reports");if(Tn(o)){let c=ba(o).filter(l=>l.endsWith(".md"));for(let l of c)e.push(Xn(yt(o,l),"report",t))}return e.sort((c,l)=>l.modifiedAt-c.modifiedAt),e}var j9=1e3,xi=class{state;stateListeners=new Set;eventListeners=new Set;eventHistory=[];constructor(e){this.state=e}onStateChange(e){return this.stateListeners.add(e),e(this.state),()=>this.stateListeners.delete(e)}onEvent(e){return this.eventListeners.add(e),()=>this.eventListeners.delete(e)}emit(e){this.eventHistory.push(e),this.eventHistory.length>j9&&this.eventHistory.shift();for(let i of this.eventListeners)try{i(e)}catch(n){console.error("Event listener error:",n)}}setState(e){this.state=e;for(let i of this.stateListeners)try{i(this.state)}catch(n){console.error("State listener error:",n)}}getState(){return this.state}getHistory(){return[...this.eventHistory]}replay(e){return this.eventHistory.filter(i=>i.timestamp>=e)}dispose(){this.stateListeners.clear(),this.eventListeners.clear(),this.eventHistory=[]}};k();it();import{existsSync as x9,readFileSync as S9,statSync as zA}from"fs";var G9=200,Si=class{pollInterval=null;previousSession=null;previousMtime=0;options;sessionPath=null;constructor(e){this.options=e}start(){let e=B(),i=e.PROJECT_DIR,n=e.ACTIVE_GK_SESSION_ID;if(!i||!n)return this.options.onError(new Error("No active session found")),!1;if(this.sessionPath=Oi(i,n),!x9(this.sessionPath))return this.options.onError(new Error(`Session file not found: ${this.sessionPath}`)),!1;try{let r=zA(this.sessionPath);this.previousMtime=r.mtimeMs}catch{}return this.loadSession(),this.pollInterval=setInterval(()=>{this.checkForChanges()},G9),!0}stop(){this.pollInterval&&(clearInterval(this.pollInterval),this.pollInterval=null)}checkForChanges(){if(this.sessionPath)try{let i=zA(this.sessionPath).mtimeMs;i>this.previousMtime&&(this.previousMtime=i,this.loadSession())}catch{}}loadSession(){if(this.sessionPath)try{let e=S9(this.sessionPath,"utf-8"),i=JSON.parse(e),n=this.previousSession?this.diffSessions(this.previousSession,i):[];this.previousSession=i,this.options.onSessionChange(i);for(let r of n)this.options.onEvent(r)}catch(e){this.options.onError(e)}}diffSessions(e,i){let n=[],r=Date.now(),s=new Map(e.agents.map(l=>[l.gkSessionId,l]));for(let l of i.agents){let u=s.get(l.gkSessionId);if(!u)n.push(this.createEvent("received_work",l,r)),l.injected?.skills?.length&&n.push(this.createEvent("skill_activated",l,r,l.injected.skills[0]));else{u.status==="active"&&l.status==="completed"&&(n.push(this.createEvent("task_complete",l,r)),n.push(this.createEvent("delivering",l,r)));let m=u.injected?.skills||[],d=(l.injected?.skills||[]).filter(A=>!m.includes(A));for(let A of d)n.push(this.createEvent("skill_activated",l,r,A))}}let o=i.agents.every(l=>l.status==="completed"||l.status==="failed"),c=e.agents.some(l=>l.status==="active");return o&&c&&i.agents.length>0&&n.push({type:"session_complete",agentId:i.gkSessionId,targetAgentId:null,skill:null,message:"All tasks completed",timestamp:r}),n}createEvent(e,i,n,r){let s={agent_idle:"Waiting for work",agent_working:"Working...",skill_activated:`Activated skill: ${r||"unknown"}`,handoff_start:"Passing work...",handoff_complete:"Handoff complete!",received_work:"Received work",delivering:"Delivering results...",task_complete:"Task complete!",session_complete:"All tasks completed"};return{type:e,agentId:i.gkSessionId,targetAgentId:i.parentGkSessionId,skill:r||i.injected?.skills?.[0]||null,message:s[e],timestamp:n,characterType:Hu(i.agentRole||"coder")}}};import{exec as O9}from"child_process";import{join as U9}from"path";import{createServer as M9}from"http";import{WebSocketServer as Y9,WebSocket as xA}from"ws";import{exec as W9}from"child_process";import{existsSync as SA}from"fs";import{resolve as C9}from"path";function jA(){return`<!DOCTYPE html>
|
|
173
202
|
<html lang="en">
|
|
174
203
|
<head>
|
|
175
204
|
<meta charset="UTF-8">
|
|
@@ -3575,4 +3604,4 @@ hookStopAgentAnimation();
|
|
|
3575
3604
|
|
|
3576
3605
|
</script>
|
|
3577
3606
|
</body>
|
|
3578
|
-
</html>`}var Lo=class{server=null;wss=null;options;clients=new Set;constructor(e){this.options=e}async start(){return new Promise((e,i)=>{let n=this.options.port,r=0,o=10,s=()=>{this.server=d9((c,l)=>this.handleRequest(c,l)),this.server.on("error",c=>{c.code==="EADDRINUSE"&&r<o?(r++,n++,s()):i(c)}),this.server.listen(n,this.options.host||"localhost",()=>{this.wss=new R9({server:this.server}),this.setupWebSocket(),this.options.emitter.onStateChange(c=>{this.broadcastState(c)}),this.options.emitter.onEvent(c=>{this.broadcastEvent(c)}),e(n)})};s()})}stop(){if(this.wss){for(let e of this.clients)e.close();this.wss.close(),this.wss=null}this.server&&(this.server.close(),this.server=null),this.clients.clear()}handleRequest(e,i){let n=e.url||"/";if(n==="/api/state"){i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify(this.serializeState(this.options.emitter.getState())));return}if(n==="/api/history"){i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify(this.options.emitter.getHistory()));return}if(n.startsWith("/api/open-doc")){let s=new URL(n,`http://${e.headers.host}`).searchParams.get("path");if(!s){i.writeHead(400,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!1,error:"No path provided"}));return}let c=s;if(SA(c)||(c=j9(process.cwd(),s)),!SA(c)){i.writeHead(404,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!1,error:`File not found: ${s}`}));return}let l=process.env.EDITOR||process.env.VISUAL,A=this.options.emitter.getState().appName?.toLowerCase()||"",I=["code","cursor","windsurf","zed","vim","nvim","nano","subl","atom","idea","webstorm","notepad++","antigravity"].some(f=>A.includes(f)),E;l?(E=`"${l}" "${c}"`,console.log(`[Agent Office] Using IDE from EDITOR env: ${l}`)):A&&I?(E=`${A} "${c}"`,console.log(`[Agent Office] Using IDE from session: ${A}`)):(E=`code "${c}"`,console.log("[Agent Office] No IDE detected, defaulting to VS Code")),z9(E,f=>{f?(i.writeHead(500,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!1,error:f.message}))):(i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!0})))});return}let r=n.split("?")[0].split("#")[0];if(r==="/"||r==="/index.html"){i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(xA());return}i.writeHead(404),i.end("Not Found")}setupWebSocket(){this.wss&&this.wss.on("connection",e=>{this.clients.add(e);let i=this.options.emitter.getState();try{e.send(JSON.stringify({type:"state",data:this.serializeState(i)}))}catch{}e.on("message",n=>{try{let r=JSON.parse(n.toString());if(r.type==="ping"&&e.send(JSON.stringify({type:"pong"})),r.type==="replay"){let o=this.options.emitter.replay(r.fromTimestamp);e.send(JSON.stringify({type:"replay",data:o}))}}catch{}}),e.on("close",()=>{this.clients.delete(e)})})}broadcastState(e){let i=JSON.stringify({type:"state",data:this.serializeState(e)});for(let n of this.clients)if(n.readyState===GA.OPEN)try{n.send(i)}catch{}}broadcastEvent(e){let i=JSON.stringify({type:"event",data:e});for(let n of this.clients)if(n.readyState===GA.OPEN)try{n.send(i)}catch{}}serializeState(e){return{...e,agents:Object.fromEntries(e.agents)}}};var _o=class{server=null;emitter;watcher;options;constructor(e={}){this.options={port:3847,host:"localhost",autoOpen:!0,...e},this.emitter=new Vt(Kt()),this.watcher=new Nt({onSessionChange:i=>{let n=Di(i);if(n.activePlan)try{let r=di(),o=x9(r,n.activePlan);n.documents=Qc(o)}catch{}this.emitter.setState(n)},onEvent:i=>{this.emitter.emit(i)},onError:i=>{this.options.onError&&this.options.onError(i)}})}async start(){if(!this.watcher.start())throw new Error("No active session found");this.server=new Lo({port:this.options.port,host:this.options.host,emitter:this.emitter});let i=await this.server.start();return this.options.autoOpen&&this.openBrowser(`http://${this.options.host}:${i}`),this.options.onReady&&this.options.onReady(i),i}stop(){this.server&&(this.server.stop(),this.server=null),this.watcher.stop(),this.emitter.dispose()}openBrowser(e){let i=process.platform==="win32"?`start ${e}`:process.platform==="darwin"?`open ${e}`:`xdg-open ${e}`;g9(i,n=>{n&&console.log(`Open ${e} in your browser`)})}};async function Jc(t={}){let e=new _o(t);return await e.start(),e}function bc(){console.log(),console.log(p.default.bold(a.geminiPurple("Agent Office"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office")} <subcommand> [options]`),console.log(),console.log("Subcommands:"),console.log(` ${a.primary("start")} Start the visualization`),console.log(` ${a.primary("status")} Show current office state`),console.log(` ${a.primary("watch")} Watch office state changes`),console.log(),console.log("Options:"),console.log(` ${a.dim("-p, --port <n>")} [start] Web server port (default: 3847)`),console.log(` ${a.dim("--no-open")} [start] Don't auto-open browser`),console.log(` ${a.dim("--json")} [status/watch] Output as JSON`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk office start")}`),console.log(` ${a.dim("gk office start --port 4000")}`),console.log(` ${a.dim("gk office status --json")}`),console.log(` ${a.dim("gk office watch")}`),console.log()}function G9(){console.log(),console.log(p.default.bold(a.geminiPurple("gk office start"))),console.log(a.dim("Start the Agent Office web dashboard")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office start")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("-p, --port <n>")} Web server port (default: 3847)`),console.log(` ${a.dim("--no-open")} Don't auto-open browser`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk office start")}`),console.log(` ${a.dim("gk office start --port 4000")}`),console.log(` ${a.dim("gk office start --port 4000 --no-open")}`),console.log()}function S9(){console.log(),console.log(p.default.bold(a.geminiPurple("gk office status"))),console.log(a.dim("Show current Agent Office state")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office status")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log()}function Y9(){console.log(),console.log(p.default.bold(a.geminiPurple("gk office watch"))),console.log(a.dim("Watch Agent Office state changes in real-time")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office watch")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log()}async function W9(t){console.log(),m.info("Starting Agent Office..."),console.log();try{let e=await Jc({port:t.port||3847,autoOpen:t.open!==!1,onReady:i=>{m.success(`Dashboard running at ${a.primary(`http://localhost:${i}`)}`),console.log(a.dim(" Press Ctrl+C to stop")),console.log()},onError:i=>{m.error(`Error: ${i.message}`)}});process.on("SIGINT",()=>{e.stop(),console.log(),m.info("Agent Office stopped."),console.log(),process.exit(0)})}catch(e){e instanceof Error&&(e.message==="No active session found"?(console.log(),m.warn("No active session found."),console.log(a.dim(" Start a GemKit session first with: gk agent")),console.log()):m.error(`Failed to start: ${e.message}`)),process.exit(1)}}function M9(t){let e=new Vt(Kt()),i=new Nt({onSessionChange:r=>{let o=Di(r);if(t.json)console.log(JSON.stringify({...o,agents:Object.fromEntries(o.agents)},null,2));else{if(console.log(),console.log(p.default.bold(a.geminiPurple("Agent Office Status"))),console.log(M.line()),console.log(),console.log(` ${a.dim("Active Plan:")} ${o.activePlan?a.primary(o.activePlan):a.dim("(none)")}`),console.log(` ${a.dim("Agents:")} ${o.agents.size}`),console.log(` ${a.dim("Inbox Items:")} ${o.inbox.length}`),console.log(` ${a.dim("Documents:")} ${o.documents.length}`),o.agents.size>0){console.log(),console.log(a.dim(" Agents:"));for(let[s,c]of o.agents){let l=c.state==="working"?a.warn:c.state==="idle"?a.success:a.dim;console.log(` ${c.icon} ${a.primary(c.role)} ${l(`[${c.state}]`)}`)}}console.log()}i.stop(),e.dispose()},onEvent:()=>{},onError:r=>{console.log(),m.error(`Error: ${r.message}`),console.log(),process.exit(1)}});i.start()||(console.log(),m.warn("No active session found."),console.log(a.dim(" Start a GemKit session first with: gk agent")),console.log(),process.exit(1))}function C9(t){console.log(),m.info("Watching Agent Office state..."),console.log(a.dim(" Press Ctrl+C to stop")),console.log();let e=new Vt(Kt()),i=new Nt({onSessionChange:r=>{let o=Di(r);if(t.json)console.log(JSON.stringify({timestamp:new Date().toISOString(),...o,agents:Object.fromEntries(o.agents)}));else{let s=new Date().toLocaleTimeString();console.log(`${a.dim(s)} ${a.info("State:")} ${o.agents.size} agents, ${o.inbox.length} inbox items`)}},onEvent:r=>{if(t.json)console.log(JSON.stringify({type:"event",event:r}));else{let o=new Date().toLocaleTimeString();console.log(`${a.dim(o)} ${a.secondary("Event:")} ${r.type}`)}},onError:r=>{m.error(`Error: ${r.message}`)}});i.start()||(console.log(),m.warn("No active session found."),console.log(a.dim(" Start a GemKit session first with: gk agent")),console.log(),process.exit(1)),process.on("SIGINT",()=>{i.stop(),e.dispose(),console.log(),m.info("Stopped watching."),console.log(),process.exit(0)})}function YA(t){t.command("office [subcommand]","Agent Office visualization (start, status, watch)").option("-p, --port <port>","[start] Web server port",{default:3847}).option("--no-open","[start] Don't auto-open browser").option("--json","[status/watch] Output as JSON").action(async(e,i)=>{if(i.port&&(i.port=parseInt(String(i.port),10)),i.help||i.h)switch(e){case"start":G9();return;case"status":S9();return;case"watch":Y9();return;default:bc();return}switch(e){case"start":await W9(i);break;case"status":M9(i);break;case"watch":C9(i);break;case void 0:case"help":bc();break;default:console.log(),m.error(`Unknown subcommand: ${e}`),bc(),process.exit(1)}})}function WA(t){Ev(t),Av(t),Iv(t),fv(t),hv(t),dv(t),Rv(t),Hv(t),Lv(t),eA(t),nA(t),rA(t),oA(t),cA(t),hA(t),YA(t)}import{existsSync as MA,readFileSync as O9,writeFileSync as U9,mkdirSync as K9}from"fs";import{join as V9,dirname as N9}from"path";import{homedir as k9}from"os";var $o=V9(k9(),".gemkit","last-update-check.json");function CA(){try{return MA($o)?JSON.parse(O9($o,"utf-8")):null}catch{return null}}function F9(t){try{let e=N9($o);MA(e)||K9(e,{recursive:!0}),U9($o,JSON.stringify(t,null,2))}catch{}}function Q9(t){let e=CA();if(!e)return!0;let i=new Date(e.lastCheck);return(new Date().getTime()-i.getTime())/(1e3*60*60)>=t}async function OA(){let e=Ve().update;if(e?.autoCheck&&Q9(e.checkInterval))try{let i=await uv(),n=CA()||{lastCheck:""},r=[];i.cli?.available&&n.notifiedCli!==i.cli.latest&&(r.push(`${a.primary("CLI")} update available: v${i.cli.current} \u2192 v${i.cli.latest}`),n.notifiedCli=i.cli.latest),i.kits?.available&&n.notifiedKits!==i.kits.latest&&(r.push(`${a.primary("Kits")} update available: v${i.kits.current} \u2192 v${i.kits.latest}`),n.notifiedKits=i.kits.latest),r.length>0&&(console.log(),console.log(a.dim("\u2500".repeat(50))),console.log(`${a.warn("\u2B06")} Updates available:`),r.forEach(o=>console.log(` ${o}`)),console.log(` Run ${a.primary("gk update")} to update.`),console.log(a.dim("\u2500".repeat(50))),console.log()),n.lastCheck=new Date().toISOString(),F9(n)}catch{}}var kt=Xc("gk");kt.version(de);kt.help();kt.option("--verbose","Enable verbose output");kt.option("--json","Output as JSON");kt.option("--no-update-check","Skip auto-update check");var Bc=kt.parse(process.argv,{run:!1});Bc.options.verbose&&So({level:"debug",verbose:!0});Bc.options.json&&So({json:!0});WA(kt);Bc.options.updateCheck!==!1&&OA().catch(()=>{});kt.parse();
|
|
3607
|
+
</html>`}var Pa=class{server=null;wss=null;options;clients=new Set;constructor(e){this.options=e}async start(){return new Promise((e,i)=>{let n=this.options.port,r=0,s=10,o=()=>{this.server=M9((c,l)=>this.handleRequest(c,l)),this.server.on("error",c=>{c.code==="EADDRINUSE"&&r<s?(r++,n++,o()):i(c)}),this.server.listen(n,this.options.host||"localhost",()=>{this.wss=new Y9({server:this.server}),this.setupWebSocket(),this.options.emitter.onStateChange(c=>{this.broadcastState(c)}),this.options.emitter.onEvent(c=>{this.broadcastEvent(c)}),e(n)})};o()})}stop(){if(this.wss){for(let e of this.clients)e.close();this.wss.close(),this.wss=null}this.server&&(this.server.close(),this.server=null),this.clients.clear()}handleRequest(e,i){let n=e.url||"/";if(n==="/api/state"){i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify(this.serializeState(this.options.emitter.getState())));return}if(n==="/api/history"){i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify(this.options.emitter.getHistory()));return}if(n.startsWith("/api/open-doc")){let o=new URL(n,`http://${e.headers.host}`).searchParams.get("path");if(!o){i.writeHead(400,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!1,error:"No path provided"}));return}let c=o;if(SA(c)||(c=C9(process.cwd(),o)),!SA(c)){i.writeHead(404,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!1,error:`File not found: ${o}`}));return}let l=process.env.EDITOR||process.env.VISUAL,m=this.options.emitter.getState().appName?.toLowerCase()||"",d=["code","cursor","windsurf","zed","vim","nvim","nano","subl","atom","idea","webstorm","notepad++","antigravity"].some(f=>m.includes(f)),A;l?(A=`"${l}" "${c}"`,console.log(`[Agent Office] Using IDE from EDITOR env: ${l}`)):m&&d?(A=`${m} "${c}"`,console.log(`[Agent Office] Using IDE from session: ${m}`)):(A=`code "${c}"`,console.log("[Agent Office] No IDE detected, defaulting to VS Code")),W9(A,f=>{f?(i.writeHead(500,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!1,error:f.message}))):(i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({success:!0})))});return}let r=n.split("?")[0].split("#")[0];if(r==="/"||r==="/index.html"){i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(jA());return}i.writeHead(404),i.end("Not Found")}setupWebSocket(){this.wss&&this.wss.on("connection",e=>{this.clients.add(e);let i=this.options.emitter.getState();try{e.send(JSON.stringify({type:"state",data:this.serializeState(i)}))}catch{}e.on("message",n=>{try{let r=JSON.parse(n.toString());if(r.type==="ping"&&e.send(JSON.stringify({type:"pong"})),r.type==="replay"){let s=this.options.emitter.replay(r.fromTimestamp);e.send(JSON.stringify({type:"replay",data:s}))}}catch{}}),e.on("close",()=>{this.clients.delete(e)})})}broadcastState(e){let i=JSON.stringify({type:"state",data:this.serializeState(e)});for(let n of this.clients)if(n.readyState===xA.OPEN)try{n.send(i)}catch{}}broadcastEvent(e){let i=JSON.stringify({type:"event",data:e});for(let n of this.clients)if(n.readyState===xA.OPEN)try{n.send(i)}catch{}}serializeState(e){return{...e,agents:Object.fromEntries(e.agents)}}};k();var Qa=class{server=null;emitter;watcher;options;constructor(e={}){this.options={port:3847,host:"localhost",autoOpen:!0,...e},this.emitter=new xi(ji()),this.watcher=new Si({onSessionChange:i=>{let n=Dn(i);if(n.activePlan)try{let r=vn(),s=U9(r,n.activePlan);n.documents=_u(s)}catch{}this.emitter.setState(n)},onEvent:i=>{this.emitter.emit(i)},onError:i=>{this.options.onError&&this.options.onError(i)}})}async start(){if(!this.watcher.start())throw new Error("No active session found");this.server=new Pa({port:this.options.port,host:this.options.host,emitter:this.emitter});let i=await this.server.start();return this.options.autoOpen&&this.openBrowser(`http://${this.options.host}:${i}`),this.options.onReady&&this.options.onReady(i),i}stop(){this.server&&(this.server.stop(),this.server=null),this.watcher.stop(),this.emitter.dispose()}openBrowser(e){let i=process.platform==="win32"?`start ${e}`:process.platform==="darwin"?`open ${e}`:`xdg-open ${e}`;O9(i,n=>{n&&console.log(`Open ${e} in your browser`)})}};async function $u(t={}){let e=new Qa(t);return await e.start(),e}function em(){console.log(),console.log(h.default.bold(a.geminiPurple("Agent Office"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office")} <subcommand> [options]`),console.log(),console.log("Subcommands:"),console.log(` ${a.primary("start")} Start the visualization`),console.log(` ${a.primary("status")} Show current office state`),console.log(` ${a.primary("watch")} Watch office state changes`),console.log(),console.log("Options:"),console.log(` ${a.dim("-p, --port <n>")} [start] Web server port (default: 3847)`),console.log(` ${a.dim("--no-open")} [start] Don't auto-open browser`),console.log(` ${a.dim("--json")} [status/watch] Output as JSON`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk office start")}`),console.log(` ${a.dim("gk office start --port 4000")}`),console.log(` ${a.dim("gk office status --json")}`),console.log(` ${a.dim("gk office watch")}`),console.log()}function K9(){console.log(),console.log(h.default.bold(a.geminiPurple("gk office start"))),console.log(a.dim("Start the Agent Office web dashboard")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office start")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("-p, --port <n>")} Web server port (default: 3847)`),console.log(` ${a.dim("--no-open")} Don't auto-open browser`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk office start")}`),console.log(` ${a.dim("gk office start --port 4000")}`),console.log(` ${a.dim("gk office start --port 4000 --no-open")}`),console.log()}function k9(){console.log(),console.log(h.default.bold(a.geminiPurple("gk office status"))),console.log(a.dim("Show current Agent Office state")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office status")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log()}function V9(){console.log(),console.log(h.default.bold(a.geminiPurple("gk office watch"))),console.log(a.dim("Watch Agent Office state changes in real-time")),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk office watch")} [options]`),console.log(),console.log("Options:"),console.log(` ${a.dim("--json")} Output as JSON`),console.log()}async function N9(t){console.log(),v.info("Starting Agent Office..."),console.log();try{let e=await $u({port:t.port||3847,autoOpen:t.open!==!1,onReady:i=>{v.success(`Dashboard running at ${a.primary(`http://localhost:${i}`)}`),console.log(a.dim(" Press Ctrl+C to stop")),console.log()},onError:i=>{v.error(`Error: ${i.message}`)}});process.on("SIGINT",()=>{e.stop(),console.log(),v.info("Agent Office stopped."),console.log(),process.exit(0)})}catch(e){e instanceof Error&&(e.message==="No active session found"?(console.log(),v.warn("No active session found."),console.log(a.dim(" Start a GemKit session first with: gk agent")),console.log()):v.error(`Failed to start: ${e.message}`)),process.exit(1)}}function F9(t){let e=new xi(ji()),i=new Si({onSessionChange:r=>{let s=Dn(r);if(t.json)console.log(JSON.stringify({...s,agents:Object.fromEntries(s.agents)},null,2));else{if(console.log(),console.log(h.default.bold(a.geminiPurple("Agent Office Status"))),console.log(G.line()),console.log(),console.log(` ${a.dim("Active Plan:")} ${s.activePlan?a.primary(s.activePlan):a.dim("(none)")}`),console.log(` ${a.dim("Agents:")} ${s.agents.size}`),console.log(` ${a.dim("Inbox Items:")} ${s.inbox.length}`),console.log(` ${a.dim("Documents:")} ${s.documents.length}`),s.agents.size>0){console.log(),console.log(a.dim(" Agents:"));for(let[o,c]of s.agents){let l=c.state==="working"?a.warn:c.state==="idle"?a.success:a.dim;console.log(` ${c.icon} ${a.primary(c.role)} ${l(`[${c.state}]`)}`)}}console.log()}i.stop(),e.dispose()},onEvent:()=>{},onError:r=>{console.log(),v.error(`Error: ${r.message}`),console.log(),process.exit(1)}});i.start()||(console.log(),v.warn("No active session found."),console.log(a.dim(" Start a GemKit session first with: gk agent")),console.log(),process.exit(1))}function b9(t){console.log(),v.info("Watching Agent Office state..."),console.log(a.dim(" Press Ctrl+C to stop")),console.log();let e=new xi(ji()),i=new Si({onSessionChange:r=>{let s=Dn(r);if(t.json)console.log(JSON.stringify({timestamp:new Date().toISOString(),...s,agents:Object.fromEntries(s.agents)}));else{let o=new Date().toLocaleTimeString();console.log(`${a.dim(o)} ${a.info("State:")} ${s.agents.size} agents, ${s.inbox.length} inbox items`)}},onEvent:r=>{if(t.json)console.log(JSON.stringify({type:"event",event:r}));else{let s=new Date().toLocaleTimeString();console.log(`${a.dim(s)} ${a.secondary("Event:")} ${r.type}`)}},onError:r=>{v.error(`Error: ${r.message}`)}});i.start()||(console.log(),v.warn("No active session found."),console.log(a.dim(" Start a GemKit session first with: gk agent")),console.log(),process.exit(1)),process.on("SIGINT",()=>{i.stop(),e.dispose(),console.log(),v.info("Stopped watching."),console.log(),process.exit(0)})}function GA(t){t.command("office [subcommand]","Agent Office visualization (start, status, watch)").option("-p, --port <port>","[start] Web server port",{default:3847}).option("--no-open","[start] Don't auto-open browser").option("--json","[status/watch] Output as JSON").action(async(e,i)=>{if(i.port&&(i.port=parseInt(String(i.port),10)),i.help||i.h)switch(e){case"start":K9();return;case"status":k9();return;case"watch":V9();return;default:em();return}switch(e){case"start":await N9(i);break;case"status":F9(i);break;case"watch":b9(i);break;case void 0:case"help":em();break;default:console.log(),v.error(`Unknown subcommand: ${e}`),em(),process.exit(1)}})}k();ga();en();import{spawn as P9}from"child_process";import{access as Q9,stat as B9,readdir as J9,readFile as MA}from"fs/promises";import{join as Hn,basename as Z9,extname as y9,relative as YA}from"path";Do();Xr();Lr();Nn();function WA(){console.log(),console.log(h.default.bold(a.geminiPurple("Team Management"))),console.log(),console.log("Usage:"),console.log(` ${a.primary("gk team")} <subcommand> [options]`),console.log(),console.log("Team Operations:"),console.log(` ${a.primary("create")} <name> Create a new team`),console.log(` ${a.primary("list")} List all teams`),console.log(` ${a.primary("info")} [teamId] Show team details`),console.log(),console.log("Agent Spawning:"),console.log(` ${a.primary("start")} --name <agent> Start agent as team member`),console.log(` ${a.primary("add-member")} <name> Register member (no spawn)`),console.log(),console.log("Task Operations:"),console.log(` ${a.primary("task-create")} <subject> Create a task`),console.log(` ${a.primary("task-claim")} <taskId> Claim a task`),console.log(` ${a.primary("task-done")} <taskId> Mark task completed`),console.log(` ${a.primary("tasks")} [teamId] List all tasks`),console.log(),console.log("Messaging & Inbox:"),console.log(` ${a.primary("send")} <to> <message> Send message to member`),console.log(` ${a.primary("broadcast")} <message> Send to all members`),console.log(` ${a.primary("messages")} View central inbox (all activity)`),console.log(` ${a.primary("respond")} <msgId> Respond to approval request`),console.log(),console.log("Agent Interaction:"),console.log(` ${a.primary("exchange")} <agent> Get structured output from agent`),console.log(` ${a.primary("read")} <agent> Read raw output from agent`),console.log(),console.log("Maintenance:"),console.log(` ${a.primary("ports")} Show port allocations`),console.log(` ${a.primary("cleanup")} Clean up stale resources`),console.log(` ${a.primary("kill")} [teamId] Emergency shutdown`),console.log(` ${a.primary("reset")} Delete all team data`),console.log(),console.log("Examples:"),console.log(` ${a.dim("gk team create jwt-research")}`),console.log(` ${a.dim("gk team start --name researcher-1 -a researcher")}`),console.log(` ${a.dim("gk team start --name planner -a planner -c @plans/")}`),console.log(` ${a.dim('gk team task-create "Research JWT security"')}`),console.log(` ${a.dim('gk team send researcher-1 "Claim task X"')}`),console.log(` ${a.dim("gk team messages --pending")}`),console.log(` ${a.dim("gk team respond <msgId> --approve")}`),console.log()}function CA(t){t.command("team [subcommand] [arg] [arg2]","Team management (list, info, tasks)").option("--json","Output as JSON").option("--desc <description>","Description for team/task").option("--blocked-by <taskIds>","Comma-separated task IDs that block this task").option("--as <agentName>","Act as this agent (for testing)").option("--pending","[messages] Show only pending items").option("--type <type>","[messages] Filter by message type").option("--from <name>","[messages] Filter by sender name").option("--to <name>","[messages] Filter by recipient name").option("--limit <n>","[messages] Limit results").option("--approve","[respond] Approve the request").option("--reject <reason>","[respond] Reject with reason").option("--approve-all","[respond] Approve all pending requests").option("--name <memberName>","[start] Agent name in team (required)").option("--role <role>","[start] Role: leader or member (default: member)").option("-a, --agent <profile>","[start] Agent profile name").option("-s, --skills <list>","[start] Comma-separated skill names").option("-m, --model <model>","[start] Model override").option("-t, --tools <list>","[start] Comma-separated tools").option("-c, --context <files>","[start] Context files (@file syntax)").option("--cli <provider>","[start] CLI provider: gemini (default) or claude").action(async(e,i,n,r)=>{if(r.help||r.h){WA();return}let s=ge(process.cwd());switch(e){case"create":await _9(s,i,r);break;case"add-member":await $9(s,i,r);break;case"list":await q9(s,r);break;case"info":await w9(s,i,r);break;case"task-create":await eR(s,i,r);break;case"task-claim":await tR(s,i,r);break;case"task-done":await iR(s,i,r);break;case"tasks":await D9(s,i,r);break;case"send":await nR(s,i,n,r);break;case"broadcast":await rR(s,i,r);break;case"messages":await sR(s,r);break;case"respond":await oR(s,i,r);break;case"start":await aR(s,r);break;case"exchange":await lR(s,i,r);break;case"read":await uR(s,i);break;case"ports":await T9(s,r);break;case"cleanup":await X9(s);break;case"kill":await H9(s,i);break;case"reset":await L9(s);break;case"_server":await cR();break;default:WA()}})}async function q9(t,e){let i=It(t);if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Teams"))),console.log(),i.length===0){console.log(a.dim(" No teams found in this project.")),console.log();return}for(let n of i){let r=n.status==="active"?a.success:a.dim;console.log(` ${a.primary(n.teamName)} ${a.dim(`(${n.teamId.slice(0,12)}...)`)}`),console.log(` Status: ${r(n.status)}`),console.log(` Members: ${n.members.length}`),console.log(` Created: ${n.createdAt}`),console.log()}}async function w9(t,e,i){if(!e){let r=It(t).filter(s=>s.status==="active");if(r.length===0){v.error("No active team found. Specify team ID.");return}e=r[0].teamId}let n=Q(t,e);if(!n){v.error(`Team not found: ${e}`);return}if(i.json){console.log(JSON.stringify(n,null,2));return}console.log(),console.log(G.doubleLine()),console.log(h.default.bold(a.geminiPurple(`Team: ${n.teamName}`))),console.log(G.doubleLine()),console.log(),console.log(` ${a.dim("ID:")} ${n.teamId}`),console.log(` ${a.dim("Status:")} ${n.status}`),console.log(` ${a.dim("Description:")} ${n.description||"(none)"}`),console.log(` ${a.dim("Leader:")} ${n.leaderId.slice(0,20)}...`),console.log(` ${a.dim("Leader Port:")} ${n.leaderPort}`),console.log(` ${a.dim("Created:")} ${n.createdAt}`),console.log(),console.log(a.dim(" --- Members ---")),console.log();for(let r of n.members){let s={ready:a.success("\u25CF"),busy:a.warn("\u25CF"),idle:a.dim("\u25CF"),shutdown:a.error("\u25CF"),starting:a.dim("\u25CB")}[r.status]||a.dim("?");console.log(` ${s} ${a.primary(r.name)} (${r.role})`),console.log(` Agent ID: ${r.agentId.slice(0,20)}...`),console.log(` Port: ${r.port}, PID: ${r.pid||"N/A"}`),console.log(` Status: ${r.status}`),console.log()}}async function D9(t,e,i){if(!e){let s=It(t).filter(o=>o.status==="active");if(s.length===0){v.error("No active team found. Specify team ID.");return}e=s[0].teamId}let n=fi(t,e),r=da(t,e);if(i.json){console.log(JSON.stringify({...n,summary:r},null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Tasks"))),console.log(),console.log(` Total: ${r.total} | ${a.success("Completed:")} ${r.completed} | ${a.warn("In Progress:")} ${r.inProgress} | ${a.dim("Pending:")} ${r.pending} | ${a.error("Blocked:")} ${r.blocked}`),console.log(),n.tasks.length===0){console.log(a.dim(" No tasks.")),console.log();return}if(n.available.length>0){console.log(a.success(" Available (ready to claim):"));for(let s of n.available)console.log(` ${a.dim(s.taskId.slice(0,12))} ${s.subject}`);console.log()}if(n.inProgress.length>0){console.log(a.warn(" In Progress:"));for(let s of n.inProgress)console.log(` ${a.dim(s.taskId.slice(0,12))} ${s.subject} ${a.dim(`[${s.owner}]`)}`);console.log()}if(n.blocked.length>0){console.log(a.error(" Blocked:"));for(let s of n.blocked)console.log(` ${a.dim(s.taskId.slice(0,12))} ${s.subject}`),console.log(` ${a.dim("Waiting on:")} ${s.blockedBy.map(o=>o.slice(0,8)).join(", ")}`);console.log()}if(n.completed.length>0){console.log(a.success(" Completed:"));for(let s of n.completed.slice(-5))console.log(` ${a.dim(s.taskId.slice(0,12))} ${a.dim(s.subject)}`);n.completed.length>5&&console.log(a.dim(` ... and ${n.completed.length-5} more`)),console.log()}}async function T9(t,e){let i=gu(t);if(e.json){console.log(JSON.stringify(i,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Port Allocations"))),console.log(),console.log(` Range: 3377-3476 (${i.total} ports)`),console.log(` Used: ${i.used}`),console.log(` Available: ${i.available}`),console.log(),Object.keys(i.byTeam).length>0){console.log(a.dim(" By Team:"));for(let[n,r]of Object.entries(i.byTeam))console.log(` ${n.slice(0,20)}...: ${r} ports`);console.log()}}async function X9(t){console.log(),v.info("Cleaning up stale ports and orphaned members...");let e=await Ru(t);e.orphansFound>0&&v.success(`Found ${e.orphansFound} orphaned member(s), cleaned ${e.cleaned}.`);let i=await ss(t);i>0&&v.success(`Released ${i} additional stale port(s).`),e.orphansFound===0&&i===0&&v.info("No stale resources found."),console.log(),console.log(a.dim(` Teams checked: ${e.teamsChecked}`)),console.log(a.dim(` Members checked: ${e.membersChecked}`)),console.log()}async function H9(t,e){if(!e){let r=It(t).filter(c=>c.status==="active");if(r.length===0){console.log(),v.info("No active teams found."),console.log();return}console.log(),v.warn(`Emergency shutdown of ${r.length} team(s)...`);let s=0,o=0;for(let c of r){let l=await ha(t,c.teamId);s+=l.killed,o+=l.cleaned,v.info(` ${c.teamName}: killed ${l.killed}, cleaned ${l.cleaned}`)}console.log(),v.success(`Total: ${s} process(es) killed, ${o} member(s) cleaned up.`),console.log();return}let i=Q(t,e);if(!i){console.log(),v.error(`Team not found: ${e}`),console.log();return}console.log(),v.warn(`Emergency shutdown of team "${i.teamName}"...`);let n=await ha(t,e);v.success(`Killed ${n.killed} process(es), cleaned up ${n.cleaned} member(s).`),console.log()}async function L9(t){console.log(),v.warn("This will delete ALL team data for this project!"),v.warn("Teams, tasks, messages, and port allocations will be removed."),console.log(),Au(t)?v.success("All team data deleted."):v.error("Failed to delete team data."),console.log()}var Ba=null,Ja=null;function ls(t){return t.as?{agentId:`cli-${t.as}`,agentName:t.as}:Ba&&Ja?{agentId:Ba,agentName:Ja}:(Ba=`cli-leader-${Et("cli-leader",process.pid).slice(0,8)}`,Ja="leader",{agentId:Ba,agentName:Ja})}function Gi(t){let e=It(t).filter(i=>i.status==="active");return e.length>0?e[0].teamId:null}async function _9(t,e,i){if(!e){v.error("Team name required."),console.log(a.dim('Usage: gk team create <name> [--desc "description"]'));return}let{agentId:n,agentName:r}=ls({}),s=Jt(t,n,"pending");if(!s){v.error("No ports available");return}let o=_o({teamName:e,description:i.desc||"",leaderId:n,leaderPort:s,projectDir:t});o?(console.log(),v.success(`Team created: ${o.teamName}`),console.log(` Team ID: ${a.primary(o.teamId)}`),console.log(` Leader: ${r} (${n.slice(0,16)}...)`),console.log(` Port: ${s}`),console.log()):v.error("Failed to create team.")}async function $9(t,e,i){if(!e){v.error("Member name required."),console.log(a.dim("Usage: gk team add-member <name>"));return}let n=Gi(t);if(!n){v.error("No active team. Create one first with: gk team create <name>");return}let r=`cli-${e}-${Et("cli-member",process.pid).slice(0,8)}`,s=Jt(t,r,n);if(!s){v.error("No ports available");return}gi(t,n,{agentId:r,name:e,agentType:"cli-agent",role:"member",port:s,pid:null,status:"ready"})?(console.log(),v.success(`Added member: ${e}`),console.log(` Agent ID: ${r.slice(0,20)}...`),console.log(` Port: ${s}`),console.log()):v.error("Failed to add member.")}async function eR(t,e,i){if(!e){v.error("Task subject required."),console.log(a.dim('Usage: gk team task-create <subject> [--desc "..."] [--blocked-by "id1,id2"]'));return}let n=Gi(t);if(!n){v.error("No active team.");return}let{agentName:r}=ls({}),s=i.blockedBy?i.blockedBy.split(",").map(c=>c.trim()):void 0,o=va(t,n,e,i.desc||e,r,{blockedBy:s});o?(console.log(),v.success(`Task created: ${o.subject}`),console.log(` Task ID: ${a.primary(o.taskId)}`),s&&s.length>0&&console.log(` Blocked by: ${s.join(", ")}`),console.log()):v.error("Failed to create task.")}async function tR(t,e,i){if(!e){v.error("Task ID required."),console.log(a.dim("Usage: gk team task-claim <taskId> [--as <agentName>]"));return}let{agentName:n}=ls(i);pa(t,e,n)?v.success(`${n} claimed task: ${e}`):v.error(`Failed to claim task: ${e}`)}async function iR(t,e,i){if(!e){v.error("Task ID required."),console.log(a.dim("Usage: gk team task-done <taskId>"));return}await Aa(t,e)?v.success(`Task completed: ${e}`):v.error(`Failed to complete task: ${e}`)}async function nR(t,e,i,n){if(!e||!i){v.error("Recipient and message required."),console.log(a.dim("Usage: gk team send <to> <message> [--as <sender>]"));return}let r=Gi(t);if(!r){v.error("No active team.");return}let s=Q(t,r);if(!s){v.error("Team not found.");return}let o=s.members.find(m=>m.name===e);if(!o){v.error(`Member not found: ${e}`),console.log(` Available: ${s.members.map(m=>m.name).join(", ")}`);return}let{agentId:c,agentName:l}=ls(n);await la(t,r,c,l,o.agentId,o.name,i,i.slice(0,50))?v.success(`Message sent to ${e}`):v.error("Failed to send message.")}async function rR(t,e,i){if(!e){v.error("Message required."),console.log(a.dim("Usage: gk team broadcast <message> [--as <sender>]"));return}let n=Gi(t);if(!n){v.error("No active team.");return}let{agentId:r,agentName:s}=ls(i),o=await ua(t,n,r,s,e,e.slice(0,50));v.success(`Broadcast sent to ${o.length} member(s)`)}async function sR(t,e){let i=Gi(t);if(!i){v.error("No active team.");return}let n={};e.pending&&(n.status="pending"),e.type&&(n.type=e.type),e.from&&(n.from=e.from),e.to&&(n.to=e.to),e.limit&&(n.limit=parseInt(e.limit,10));let r=Qt(t,i,n);if(e.json){console.log(JSON.stringify(r,null,2));return}if(console.log(),console.log(h.default.bold(a.geminiPurple("Team Inbox"))),console.log(),r.length===0){console.log(a.dim(" No messages found.")),console.log();return}let s=r.filter(u=>u.status==="pending"),o=r.filter(u=>u.status==="delivered"),c=r.filter(u=>u.status==="processed");if(s.length>0){console.log(a.warn(` Pending (${s.length}):`));for(let u of s.slice(-10))console.log(` ${Jn(u)}`);console.log()}if(o.length>0&&!e.pending){console.log(a.primary(` Delivered (${o.length}):`));for(let u of o.slice(-5))console.log(` ${Jn(u)}`);console.log()}if(c.length>0&&!e.pending){console.log(a.success(` Processed (${c.length}):`));for(let u of c.slice(-5))console.log(` ${Jn(u)}`);console.log()}let l=r.filter(u=>u.type==="approval_request"&&u.status==="pending");l.length>0&&(console.log(a.warn(` \u{1F4A1} ${l.length} pending approval(s). Use:`)),console.log(a.dim(" gk team respond <msgId> --approve")),console.log())}async function oR(t,e,i){let n=Gi(t);if(!n){v.error("No active team.");return}if(i.approveAll){let c=$o(t,n);if(c.length===0){console.log(),v.info("No pending approval requests."),console.log();return}console.log(),v.info(`Processing ${c.length} pending approval(s)...`);let l=0,u=0;for(let m of c){let p=await ca(t,n,m.id,!0);p.success?(v.success(`Approved: ${m.summary}`),l++):(v.warn(`Failed: ${m.summary} - ${p.error}`),u++)}console.log(),v.info(`Results: ${l} approved, ${u} failed`),console.log();return}if(!e){console.log(),v.error("Message ID required."),console.log(a.dim("Usage: gk team respond <messageId> --approve")),console.log(a.dim(' gk team respond <messageId> --reject "reason"')),console.log(a.dim(" gk team respond --approve-all")),console.log();return}if(!i.approve&&!i.reject){console.log(),v.error('Must specify --approve or --reject "reason"'),console.log();return}let r=i.approve===!0,s=i.reject,o=await ca(t,n,e,r,s);console.log(),o.success?r?v.success(`Approved: ${o.action}`):v.info(`Rejected: ${o.action}`):v.error(o.error||"Failed to process response"),console.log()}async function aR(t,e){e.name||(console.log(),v.error("Agent name required. Use --name <agentName>"),console.log(a.dim("Usage: gk team start --name <agentName> [options]")),console.log(),process.exit(1));let i=Gi(t);i||(console.log(),v.error("No active team. Create one first: gk team create <name>"),console.log(),process.exit(1));let n=Q(t,i);n||(v.error("Team not found."),process.exit(1));let r=e.cli==="claude"?"claude":"gemini",s=Ie(),o=e.name,c=e.role==="leader"?"leader":"member",l=Et(`team-${o}`,process.pid),u=null,m=o.replace(/-\d+$/,""),p=e.agent||m;u=Fn(p,r),!u&&e.agent&&(console.log(),v.error(`Agent profile not found: ${e.agent}`),console.log(),process.exit(1));let d=e.model||u?.model||s.spawn.defaultModel;d=mi(d,r);let A=e.tools?.split(",").map(ie=>ie.trim()).filter(Boolean)||[],f=u?.tools||[],g=[...new Set([...f,...A])],E=vi(g,r),J=e.skills?.split(",").map(ie=>ie.trim()).filter(Boolean)||[],M=u?.skills||[],st=[...new Set([...M,...J])],y={};for(let ie of st){let Ze=bn(ie);Ze&&(y[ie]=Ze)}let te=[];if(e.context){let ie=e.context.split(",").flatMap(Ze=>Ze.trim().split(/\s+/).filter(at=>at)).filter(Ze=>Ze);for(let Ze of ie)try{let at=await vR(Ze);Array.isArray(at)?te.push(...at):te.push(at)}catch(at){console.log(),v.error(at.message),console.log(),process.exit(1)}}let U=Jt(t,l,i);U||(console.log(),v.error("No ports available for team member"),console.log(),process.exit(1)),gi(t,i,{agentId:l,name:o,agentType:e.agent||"default",role:c,port:U,pid:null,status:"starting"})||(Me(t,l),console.log(),v.error("Failed to register in team"),console.log(),process.exit(1));let Ln={provider:r,model:d,port:U,pid:0,isFirstSend:!0,context:{agentName:u?.name||null,agentContent:u?.content||null,skills:st,skillContents:y,contextFiles:te,tools:E},team:{teamId:i,teamName:n.teamName,role:c,agentId:l,agentName:o,leaderPort:n.leaderPort,projectDir:t},startedAt:new Date().toISOString()};if($i(Ln,void 0,o),console.log(),v.info(`Starting ${a.primary(o)} in team ${a.dim(n.teamName)}...`),v.info(`Provider: ${a.primary(r)}, Model: ${a.primary(d)}`),v.info(`Port: ${a.dim(U.toString())}`),u){let ie=e.agent?"":" (auto-derived)";v.info(`Agent: ${a.dim(u.name)}${a.dim(ie)}`)}st.length>0&&v.info(`Skills: ${a.dim(st.join(", "))}`),te.length>0&&v.info(`Context: ${a.dim(te.map(ie=>ie.name).join(", "))}`),E.length>0&&v.info(`Tools: ${a.dim(E.join(", "))}`),console.log();let ya={...process.env,GK_TEAM_ID:i,GK_TEAM_NAME:n.teamName,GK_TEAM_ROLE:c,GK_TEAM_PORT:U.toString(),GK_TEAM_LEADER_PORT:n.leaderPort.toString(),GK_AGENT_NAME:o,GK_SUB_SESSION_ID:l},qa=process.argv[1],Ae=P9(process.execPath,[qa,"team","_server"],{detached:!0,stdio:"ignore",windowsHide:!0,cwd:process.cwd(),env:ya});Ae.unref(),Ln.pid=Ae.pid||0,$i(Ln,void 0,o),Ae.pid&&(pu(t,i,l,Ae.pid),Z(t,i,l,"ready")),v.info(`Server started (PID: ${Ae.pid})`),v.info("Waiting for AI to initialize...");let ot=new ee(U),K=120;for(let ie=0;ie<K;ie++){await mR(1e3);try{if((await ot.status()).ready){console.log(),v.success(`${o} ready!`),console.log(),console.log("Monitor:"),console.log(` ${a.dim("gk team messages --pending")}`),console.log(` ${a.dim("gk team respond <msgId> --approve")}`),console.log(` ${a.dim("gk team respond --approve-all")}`),console.log(` ${a.dim(`gk team exchange ${o}`)}`),console.log(),console.log("Send messages:"),console.log(` ${a.dim(`gk team send ${o} "your message"`)}`),console.log();return}}catch{}process.stdout.write(".")}console.log(),v.warn("Server started but AI may still be initializing."),console.log()}async function cR(){let t=process.env.GK_AGENT_NAME;t||(console.error("[TeamServer] No agent name in environment"),process.exit(1));let e=Ge(void 0,t);e||(console.error("[TeamServer] No session state found"),process.exit(1));let{PtyServer:i}=await Promise.resolve().then(()=>(ju(),Sp)),n=new i({provider:e.provider,model:e.model,tools:e.context.tools,sessionState:e,port:e.port,debug:!1});try{await n.start()}catch(r){console.error(`[TeamServer] Failed to start: ${r.message}`),et(void 0,t),process.exit(1)}process.on("SIGINT",async()=>{await n.stop(),et(void 0,t),process.exit(0)}),process.on("SIGTERM",async()=>{await n.stop(),et(void 0,t),process.exit(0)})}async function lR(t,e,i){e||(console.log(),v.error("Agent name required."),console.log(a.dim("Usage: gk team exchange <agentName>")),console.log(),process.exit(1));let n=OA(t,e);n||(v.error(`Agent not found or not running: ${e}`),process.exit(1));let r=new ee(n);try{let s=await r.exchange();console.log(JSON.stringify(s,null,2))}catch(s){v.error(s.message),process.exit(1)}}async function uR(t,e){e||(console.log(),v.error("Agent name required."),console.log(a.dim("Usage: gk team read <agentName>")),console.log(),process.exit(1));let i=OA(t,e);i||(v.error(`Agent not found or not running: ${e}`),process.exit(1));let n=new ee(i);try{let r=await n.read(200);console.log(r)}catch(r){v.error(r.message),process.exit(1)}}function OA(t,e){let i=Gi(t);if(!i)return null;let n=Q(t,i);return n?n.members.find(s=>s.name===e)?.port??null:null}function mR(t){return new Promise(e=>setTimeout(e,t))}async function vR(t){let e=t;if(t.startsWith("@")){let r=t.substring(1),s=[Hn(process.cwd(),".docs",r),Hn(process.cwd(),".plans",r),Hn(process.cwd(),"docs",r),Hn(process.cwd(),"plans",r),Hn(process.cwd(),r)],o=!1;for(let c of s)try{await Q9(c),e=c,o=!0;break}catch{continue}if(!o)throw new Error(`Context file not found: ${t}`)}if((await B9(e)).isDirectory()){let r=[],s=[".md",".txt",".json",".yaml",".yml"];async function o(c,l=0){if(l>3)return;let u=await J9(c,{withFileTypes:!0});for(let m of u){if(m.name.startsWith("."))continue;let p=Hn(c,m.name);if(m.isDirectory())await o(p,l+1);else if(m.isFile()){let d=y9(m.name).toLowerCase();if(s.includes(d)){let A=await MA(p,"utf-8");r.push({type:"context",name:m.name,path:p,relativePath:YA(e,p),content:A.trim(),originalRef:`${t}/${YA(e,p)}`})}}}}return await o(e),r}let n=await MA(e,"utf-8");return{type:"context",name:Z9(e),path:e,content:n.trim(),originalRef:t}}function UA(t){Mv(t),xv(t),Yv(t),Cv(t),Ov(t),Uv(t),Kv(t),Xp(t),Hp(t),$p(t),iA(t),nA(t),rA(t),aA(t),hA(t),GA(t),CA(t)}import{existsSync as KA,readFileSync as pR,writeFileSync as AR,mkdirSync as dR}from"fs";import{join as fR,dirname as hR}from"path";import{homedir as gR}from"os";var Za=fR(gR(),".gemkit","last-update-check.json");function kA(){try{return KA(Za)?JSON.parse(pR(Za,"utf-8")):null}catch{return null}}function IR(t){try{let e=hR(Za);KA(e)||dR(e,{recursive:!0}),AR(Za,JSON.stringify(t,null,2))}catch{}}function ER(t){let e=kA();if(!e)return!0;let i=new Date(e.lastCheck);return(new Date().getTime()-i.getTime())/(1e3*60*60)>=t}async function VA(){let e=Ie().update;if(e?.autoCheck&&ER(e.checkInterval))try{let i=await Sv(),n=kA()||{lastCheck:""},r=[];i.cli?.available&&n.notifiedCli!==i.cli.latest&&(r.push(`${a.primary("CLI")} update available: v${i.cli.current} \u2192 v${i.cli.latest}`),n.notifiedCli=i.cli.latest),i.kits?.available&&n.notifiedKits!==i.kits.latest&&(r.push(`${a.primary("Kits")} update available: v${i.kits.current} \u2192 v${i.kits.latest}`),n.notifiedKits=i.kits.latest),r.length>0&&(console.log(),console.log(a.dim("\u2500".repeat(50))),console.log(`${a.warn("\u2B06")} Updates available:`),r.forEach(s=>console.log(` ${s}`)),console.log(` Run ${a.primary("gk update")} to update.`),console.log(a.dim("\u2500".repeat(50))),console.log()),n.lastCheck=new Date().toISOString(),IR(n)}catch{}}var Mi=cm("gk");Mi.version(Pe);Mi.help();Mi.option("--verbose","Enable verbose output");Mi.option("--json","Output as JSON");Mi.option("--no-update-check","Skip auto-update check");var tm=Mi.parse(process.argv,{run:!1});tm.options.verbose&&Jo({level:"debug",verbose:!0});tm.options.json&&Jo({json:!0});UA(Mi);tm.options.updateCheck!==!1&&VA().catch(()=>{});Mi.parse();
|