neural-loom 0.2.2 → 0.2.5
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/cache/.previewinfo +1 -1
- package/.next/cache/.rscinfo +1 -1
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__0d0pykb._.js +10 -10
- package/.next/server/chunks/[root-of-the-server]__0d0pykb._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/trace +1 -1
- package/.next/trace-build +1 -1
- package/package.json +1 -1
- package/src/lib/agents/AiderRunner.ts +7 -1
- package/src/lib/agents/ClaudeRunner.ts +8 -2
- package/src/lib/agents/DockerRunner.ts +7 -1
- package/src/lib/agents/SSHRunner.ts +7 -1
- /package/.next/static/{yb_z3YBguPNnBMLege_Cn → IIMVZJfpSSOtNcK7MPA4D}/_buildManifest.js +0 -0
- /package/.next/static/{yb_z3YBguPNnBMLege_Cn → IIMVZJfpSSOtNcK7MPA4D}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{yb_z3YBguPNnBMLege_Cn → IIMVZJfpSSOtNcK7MPA4D}/_ssgManifest.js +0 -0
|
@@ -12,7 +12,7 @@ f:I[68027,["/_next/static/chunks/0dbhjjzl8qfwv.js"],"default",1]
|
|
|
12
12
|
:HL["/_next/static/media/797e433ab948586e-s.p.08e28id.o-okb.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
|
13
13
|
:HL["/_next/static/media/caa3a2e1cccd8315-s.p.09~u27dqhyhd6.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
|
14
14
|
:HL["/_next/static/chunks/0q4suv6uexpud.css","style"]
|
|
15
|
-
0:{"P":null,"c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",16],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/139c54uo1w7.4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/_next/static/chunks/0dbhjjzl8qfwv.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","className":"geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L4",null,{"Component":"$5","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@6","$@7"]}}],[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/0q4suv6uexpud.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/_next/static/chunks/0di.tbc4b33wc.js","async":true,"nonce":"$undefined"}]],["$","$L8",null,{"children":["$","$9",null,{"name":"Next.MetadataOutlet","children":"$@a"}]}]]}],{},null,false,null]},null,false,null],["$","$1","h",{"children":[null,["$","$Lb",null,{"children":"$Lc"}],["$","div",null,{"hidden":true,"children":["$","$Ld",null,{"children":["$","$9",null,{"name":"Next.Metadata","children":"$Le"}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}],false]],"m":"$undefined","G":["$f",[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/139c54uo1w7.4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]]],"S":true,"h":null,"s":"$undefined","l":"$undefined","p":"$undefined","d":"$undefined","b":"
|
|
15
|
+
0:{"P":null,"c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",16],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/139c54uo1w7.4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/_next/static/chunks/0dbhjjzl8qfwv.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","className":"geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L4",null,{"Component":"$5","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@6","$@7"]}}],[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/0q4suv6uexpud.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/_next/static/chunks/0di.tbc4b33wc.js","async":true,"nonce":"$undefined"}]],["$","$L8",null,{"children":["$","$9",null,{"name":"Next.MetadataOutlet","children":"$@a"}]}]]}],{},null,false,null]},null,false,null],["$","$1","h",{"children":[null,["$","$Lb",null,{"children":"$Lc"}],["$","div",null,{"hidden":true,"children":["$","$Ld",null,{"children":["$","$9",null,{"name":"Next.Metadata","children":"$Le"}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}],false]],"m":"$undefined","G":["$f",[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/139c54uo1w7.4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]]],"S":true,"h":null,"s":"$undefined","l":"$undefined","p":"$undefined","d":"$undefined","b":"IIMVZJfpSSOtNcK7MPA4D"}
|
|
16
16
|
6:{}
|
|
17
17
|
7:"$0:f:0:1:1:children:0:props:children:0:props:serverProvidedParams:params"
|
|
18
18
|
c:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
3:I[97367,["/_next/static/chunks/0dbhjjzl8qfwv.js"],"MetadataBoundary"]
|
|
4
4
|
4:"$Sreact.suspense"
|
|
5
5
|
5:I[27201,["/_next/static/chunks/0dbhjjzl8qfwv.js"],"IconMark"]
|
|
6
|
-
0:{"rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"NeuralLoom - Unified AI Agent Orchestrator & Context Bridge"}],["$","meta","1",{"name":"description","content":"Advanced console dashboard and context staging manager for Claude Code and simulated AI agents."}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.0x3dzn~oxb6tn.ico","sizes":"256x256","type":"image/x-icon"}],["$","$L5","3",{}]]}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}],"isPartial":false,"staleTime":300,"varyParams":null,"buildId":"
|
|
6
|
+
0:{"rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"NeuralLoom - Unified AI Agent Orchestrator & Context Bridge"}],["$","meta","1",{"name":"description","content":"Advanced console dashboard and context staging manager for Claude Code and simulated AI agents."}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.0x3dzn~oxb6tn.ico","sizes":"256x256","type":"image/x-icon"}],["$","$L5","3",{}]]}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}],"isPartial":false,"staleTime":300,"varyParams":null,"buildId":"IIMVZJfpSSOtNcK7MPA4D"}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
2:I[39756,["/_next/static/chunks/0dbhjjzl8qfwv.js"],"default"]
|
|
3
3
|
3:I[37457,["/_next/static/chunks/0dbhjjzl8qfwv.js"],"default"]
|
|
4
4
|
:HL["/_next/static/chunks/139c54uo1w7.4.css","style"]
|
|
5
|
-
0:{"rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/139c54uo1w7.4.css","precedence":"next"}],["$","script","script-0",{"src":"/_next/static/chunks/0dbhjjzl8qfwv.js","async":true}]],["$","html",null,{"lang":"en","className":"geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]]}],"isPartial":false,"staleTime":300,"varyParams":null,"buildId":"
|
|
5
|
+
0:{"rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/139c54uo1w7.4.css","precedence":"next"}],["$","script","script-0",{"src":"/_next/static/chunks/0dbhjjzl8qfwv.js","async":true}]],["$","html",null,{"lang":"en","className":"geist_a71539c9-module__T19VSG__variable geist_mono_8d43a2aa-module__8Li5zG__variable","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]]}],"isPartial":false,"staleTime":300,"varyParams":null,"buildId":"IIMVZJfpSSOtNcK7MPA4D"}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
:HL["/_next/static/media/797e433ab948586e-s.p.08e28id.o-okb.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
|
3
3
|
:HL["/_next/static/media/caa3a2e1cccd8315-s.p.09~u27dqhyhd6.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
|
4
4
|
:HL["/_next/static/chunks/0q4suv6uexpud.css","style"]
|
|
5
|
-
0:{"tree":{"name":"","param":null,"prefetchHints":16,"slots":{"children":{"name":"__PAGE__","param":null,"prefetchHints":0,"slots":null}}},"staleTime":300,"buildId":"
|
|
5
|
+
0:{"tree":{"name":"","param":null,"prefetchHints":16,"slots":{"children":{"name":"__PAGE__","param":null,"prefetchHints":0,"slots":null}}},"staleTime":300,"buildId":"IIMVZJfpSSOtNcK7MPA4D"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
module.exports=[54799,(e,t,s)=>{t.exports=e.x("crypto",()=>require("crypto"))},27699,(e,t,s)=>{t.exports=e.x("events",()=>require("events"))},24836,(e,t,s)=>{t.exports=e.x("https",()=>require("https"))},21517,(e,t,s)=>{t.exports=e.x("http",()=>require("http"))},4446,(e,t,s)=>{t.exports=e.x("net",()=>require("net"))},55004,(e,t,s)=>{t.exports=e.x("tls",()=>require("tls"))},88947,(e,t,s)=>{t.exports=e.x("stream",()=>require("stream"))},92509,(e,t,s)=>{t.exports=e.x("url",()=>require("url"))},6461,(e,t,s)=>{t.exports=e.x("zlib",()=>require("zlib"))},74836,(e,t,s)=>{"use strict";let r=["nodebuffer","arraybuffer","fragments"],i="u">typeof Blob;i&&r.push("blob"),t.exports={BINARY_TYPES:r,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:i,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},97970,(e,t,s)=>{"use strict";let{EMPTY_BUFFER:r}=e.r(74836),i=Buffer[Symbol.species];function o(e,t,s,r,i){for(let o=0;o<i;o++)s[r+o]=e[o]^t[3&o]}function n(e,t){for(let s=0;s<e.length;s++)e[s]^=t[3&s]}function a(e){let t;return(a.readOnly=!0,Buffer.isBuffer(e))?e:(e instanceof ArrayBuffer?t=new i(e):ArrayBuffer.isView(e)?t=new i(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),a.readOnly=!1),t)}if(t.exports={concat:function(e,t){if(0===e.length)return r;if(1===e.length)return e[0];let s=Buffer.allocUnsafe(t),o=0;for(let t=0;t<e.length;t++){let r=e[t];s.set(r,o),o+=r.length}return o<t?new i(s.buffer,s.byteOffset,o):s},mask:o,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:a,unmask:n},!process.env.WS_NO_BUFFER_UTIL)try{let e=(()=>{let e=Error("Cannot find module 'bufferutil'");throw e.code="MODULE_NOT_FOUND",e})();t.exports.mask=function(t,s,r,i,n){n<48?o(t,s,r,i,n):e.mask(t,s,r,i,n)},t.exports.unmask=function(t,s){t.length<32?n(t,s):e.unmask(t,s)}}catch(e){}},62048,(e,t,s)=>{"use strict";let r=Symbol("kDone"),i=Symbol("kRun");t.exports=class{constructor(e){this[r]=()=>{this.pending--,this[i]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[i]()}[i](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[r])}}}},80295,(e,t,s)=>{"use strict";let r,i=e.r(6461),o=e.r(97970),n=e.r(62048),{kStatusCode:a}=e.r(74836),l=Buffer[Symbol.species],h=Buffer.from([0,0,255,255]),c=Symbol("permessage-deflate"),d=Symbol("total-length"),p=Symbol("callback"),u=Symbol("buffers"),f=Symbol("error");function m(e){this[u].push(e),this[d]+=e.length}function _(e){(this[d]+=e.length,this[c]._maxPayload<1||this[d]<=this[c]._maxPayload)?this[u].push(e):(this[f]=RangeError("Max payload size exceeded"),this[f].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[f][a]=1009,this.removeListener("data",_),this.reset())}function g(e){(this[c]._inflate=null,this[f])?this[p](this[f]):(e[a]=1007,this[p](e))}t.exports=class{constructor(e){this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._maxPayload=0|this._options.maxPayload,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,r||(r=new n(void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10))}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[p];this._deflate.close(),this._deflate=null,e&&e(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,s=e.find(e=>(!1!==t.serverNoContextTakeover||!e.server_no_context_takeover)&&(!e.server_max_window_bits||!1!==t.serverMaxWindowBits&&("number"!=typeof t.serverMaxWindowBits||!(t.serverMaxWindowBits>e.server_max_window_bits)))&&("number"!=typeof t.clientMaxWindowBits||!!e.client_max_window_bits));if(!s)throw Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:(!0===s.client_max_window_bits||!1===t.clientMaxWindowBits)&&delete s.client_max_window_bits,s}acceptAsClient(e){let t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let s=e[t];if(s.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){let e=+s;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){let e=+s;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if("client_no_context_takeover"===t||"server_no_context_takeover"===t){if(!0!==s)throw TypeError(`Invalid value for parameter "${t}": ${s}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=s})}),e}decompress(e,t,s){r.add(r=>{this._decompress(e,t,(e,t)=>{r(),s(e,t)})})}compress(e,t,s){r.add(r=>{this._compress(e,t,(e,t)=>{r(),s(e,t)})})}_decompress(e,t,s){let r=this._isServer?"client":"server";if(!this._inflate){let e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?i.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=i.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[d]=0,this._inflate[u]=[],this._inflate.on("error",g),this._inflate.on("data",_)}this._inflate[p]=s,this._inflate.write(e),t&&this._inflate.write(h),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,s(e);return}let i=o.concat(this._inflate[u],this._inflate[d]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[d]=0,this._inflate[u]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,i)})}_compress(e,t,s){let r=this._isServer?"server":"client";if(!this._deflate){let e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?i.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=i.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[d]=0,this._deflate[u]=[],this._deflate.on("data",m)}this._deflate[p]=s,this._deflate.write(e),this._deflate.flush(i.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=o.concat(this._deflate[u],this._deflate[d]);t&&(e=new l(e.buffer,e.byteOffset,e.length-4)),this._deflate[p]=null,this._deflate[d]=0,this._deflate[u]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)})}}},874,(e,t,s)=>{t.exports=e.x("buffer",()=>require("buffer"))},58739,(e,t,s)=>{"use strict";let{isUtf8:r}=e.r(874),{hasBlob:i}=e.r(74836);function o(e){let t=e.length,s=0;for(;s<t;)if((128&e[s])==0)s++;else if((224&e[s])==192){if(s+1===t||(192&e[s+1])!=128||(254&e[s])==192)return!1;s+=2}else if((240&e[s])==224){if(s+2>=t||(192&e[s+1])!=128||(192&e[s+2])!=128||224===e[s]&&(224&e[s+1])==128||237===e[s]&&(224&e[s+1])==160)return!1;s+=3}else{if((248&e[s])!=240||s+3>=t||(192&e[s+1])!=128||(192&e[s+2])!=128||(192&e[s+3])!=128||240===e[s]&&(240&e[s+1])==128||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}return!0}if(t.exports={isBlob:function(e){return i&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:o,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},r)t.exports.isValidUTF8=function(e){return e.length<24?o(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=(()=>{let e=Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e})();t.exports.isValidUTF8=function(t){return t.length<32?o(t):e(t)}}catch(e){}},29485,(e,t,s)=>{"use strict";let{Writable:r}=e.r(88947),i=e.r(80295),{BINARY_TYPES:o,EMPTY_BUFFER:n,kStatusCode:a,kWebSocket:l}=e.r(74836),{concat:h,toArrayBuffer:c,unmask:d}=e.r(97970),{isValidStatusCode:p,isValidUTF8:u}=e.r(58739),f=Buffer[Symbol.species];t.exports=class extends r{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=0|e.maxBufferedChunks,this._maxFragments=0|e.maxFragments,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[l]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){return 8===this._opcode&&0==this._state?s():this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks?void s(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS")):void(this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s))}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new f(t.buffer,t.byteOffset+e,t.length-e),new f(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let s=this._buffers[0],r=t.length-e;e>=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new f(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0)return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop)this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((48&t[0])!=0)return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"));let s=(64&t[0])==64;if(s&&!this._extensions[i.extensionName])return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._fin=(128&t[0])==128,this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(!this._fragmented)return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"));this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));this._compressed=s}else{if(!(this._opcode>7)||!(this._opcode<11))return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));if(!this._fin)return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"));if(s)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=(128&t[1])==128,this._isServer){if(!this._masked)return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}else if(this._masked)return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"));126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),s=t.readUInt32BE(0);s>2097151?e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=0x100000000*s+t.readUInt32BE(4),this.haveLength(e))}haveLength(e){this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)?e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")):this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=n;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!=0&&d(t,this._mask)}if(this._opcode>7)return void this.controlMessage(t,e);if(this._compressed){this._state=5,this.decompress(t,e);return}if(t.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void e(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._messageLength=this._totalPayloadLength,this._fragments.push(t)}this.dataMessage(e)}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,(e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return void t(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void t(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?h(s,t):"arraybuffer"===this._binaryType?c(h(s,t)):"blob"===this._binaryType?new Blob(s):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)}))}else{let r=h(s,t);if(!this._skipUTF8Validation&&!u(r))return void e(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(8===this._opcode){if(0===e.length)this._loop=!1,this.emit("conclude",1005,n),this.end();else{let s=e.readUInt16BE(0);if(!p(s))return void t(this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE"));let r=new f(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!u(r))return void t(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)}))}createError(e,t,s,r,i){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=i,o[a]=r,o}}},16735,(e,t,s)=>{"use strict";let r,{Duplex:i}=e.r(88947),{randomFillSync:o}=e.r(54799),{types:{isUint8Array:n}}=e.r(24361),a=e.r(80295),{EMPTY_BUFFER:l,kWebSocket:h,NOOP:c}=e.r(74836),{isBlob:d,isValidStatusCode:p}=e.r(58739),{mask:u,toBuffer:f}=e.r(97970),m=Symbol("kByteLength"),_=Buffer.alloc(4),g=8192;class y{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=c,this[h]=void 0}static frame(e,t){let s,i,n=!1,a=2,l=!1;t.mask&&(s=t.maskBuffer||_,t.generateMask?t.generateMask(s):(8192===g&&(void 0===r&&(r=Buffer.alloc(8192)),o(r,0,8192),g=0),s[0]=r[g++],s[1]=r[g++],s[2]=r[g++],s[3]=r[g++]),l=(s[0]|s[1]|s[2]|s[3])==0,a=6),"string"==typeof e?i=(!t.mask||l)&&void 0!==t[m]?t[m]:(e=Buffer.from(e)).length:(i=e.length,n=t.mask&&t.readOnly&&!l);let h=i;i>=65536?(a+=8,h=127):i>125&&(a+=2,h=126);let c=Buffer.allocUnsafe(n?i+a:a);return(c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=h,126===h?c.writeUInt16BE(i,2):127===h&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),t.mask)?(c[1]|=128,c[a-4]=s[0],c[a-3]=s[1],c[a-2]=s[2],c[a-1]=s[3],l)?[c,e]:n?(u(e,s,c,a,i),[c]):(u(e,s,e,0,i),[c,e]):[c,e]}close(e,t,s,r){let i;if(void 0===e)i=l;else if("number"==typeof e&&p(e))if(void 0!==t&&t.length){let s=Buffer.byteLength(t);if(s>123)throw RangeError("The message must not be greater than 123 bytes");if((i=Buffer.allocUnsafe(2+s)).writeUInt16BE(e,0),"string"==typeof t)i.write(t,2);else if(n(t))i.set(t,2);else throw TypeError("Second argument must be a string or a Uint8Array")}else(i=Buffer.allocUnsafe(2)).writeUInt16BE(e,0);else throw TypeError("First argument must be a valid error code number");let o={[m]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,i,!1,o,r]):this.sendFrame(y.frame(i,o),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):d(e)?(r=e.size,i=!1):(r=(e=f(e)).length,i=f.readOnly),r>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[m]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(y.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):d(e)?(r=e.size,i=!1):(r=(e=f(e)).length,i=f.readOnly),r>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[m]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(y.frame(e,o),s)}send(e,t,s){let r,i,o=this._extensions[a.extensionName],n=t.binary?2:1,l=t.compress;"string"==typeof e?(r=Buffer.byteLength(e),i=!1):d(e)?(r=e.size,i=!1):(r=(e=f(e)).length,i=f.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=r>=o._threshold),this._compress=l):(l=!1,n=0),t.fin&&(this._firstFragment=!0);let h={[m]:r,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:i,rsv1:l};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,h,s]):this.getBlobData(e,this._compress,h,s):0!==this._state?this.enqueue([this.dispatch,e,this._compress,h,s]):this.dispatch(e,this._compress,h,s)}getBlobData(e,t,s,r){this._bufferedBytes+=s[m],this._state=2,e.arrayBuffer().then(e=>{if(this._socket.destroyed){let e=Error("The socket was closed while the blob was being read");process.nextTick(b,this,e,r);return}this._bufferedBytes-=s[m];let i=f(e);t?this.dispatch(i,t,s,r):(this._state=0,this.sendFrame(y.frame(i,s),r),this.dequeue())}).catch(e=>{process.nextTick(S,this,e,r)})}dispatch(e,t,s,r){if(!t)return void this.sendFrame(y.frame(e,s),r);let i=this._extensions[a.extensionName];this._bufferedBytes+=s[m],this._state=1,i.compress(e,s.fin,(e,t)=>{this._socket.destroyed?b(this,Error("The socket was closed while data was being compressed"),r):(this._bufferedBytes-=s[m],this._state=0,s.readOnly=!1,this.sendFrame(y.frame(t,s),r),this.dequeue())})}dequeue(){for(;0===this._state&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][m],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][m],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}function b(e,t,s){"function"==typeof s&&s(t);for(let s=0;s<e._queue.length;s++){let r=e._queue[s],i=r[r.length-1];"function"==typeof i&&i(t)}}function S(e,t,s){b(e,t,s),e.onerror(t)}t.exports=y},70494,(e,t,s)=>{"use strict";let{kForOnEventAttribute:r,kListener:i}=e.r(74836),o=Symbol("kCode"),n=Symbol("kData"),a=Symbol("kError"),l=Symbol("kMessage"),h=Symbol("kReason"),c=Symbol("kTarget"),d=Symbol("kType"),p=Symbol("kWasClean");class u{constructor(e){this[c]=null,this[d]=e}get target(){return this[c]}get type(){return this[d]}}Object.defineProperty(u.prototype,"target",{enumerable:!0}),Object.defineProperty(u.prototype,"type",{enumerable:!0});class f extends u{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[h]=void 0===t.reason?"":t.reason,this[p]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[h]}get wasClean(){return this[p]}}Object.defineProperty(f.prototype,"code",{enumerable:!0}),Object.defineProperty(f.prototype,"reason",{enumerable:!0}),Object.defineProperty(f.prototype,"wasClean",{enumerable:!0});class m extends u{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[l]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[l]}}Object.defineProperty(m.prototype,"error",{enumerable:!0}),Object.defineProperty(m.prototype,"message",{enumerable:!0});class _ extends u{constructor(e,t={}){super(e),this[n]=void 0===t.data?null:t.data}get data(){return this[n]}}function g(e,t,s){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,s):e.call(t,s)}Object.defineProperty(_.prototype,"data",{enumerable:!0}),t.exports={CloseEvent:f,ErrorEvent:m,Event:u,EventTarget:{addEventListener(e,t,s={}){let o;for(let o of this.listeners(e))if(!s[r]&&o[i]===t&&!o[r])return;if("message"===e)o=function(e,s){let r=new _("message",{data:s?e:e.toString()});r[c]=this,g(t,this,r)};else if("close"===e)o=function(e,s){let r=new f("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[c]=this,g(t,this,r)};else if("error"===e)o=function(e){let s=new m("error",{error:e,message:e.message});s[c]=this,g(t,this,s)};else{if("open"!==e)return;o=function(){let e=new u("open");e[c]=this,g(t,this,e)}}o[r]=!!s[r],o[i]=t,s.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(let s of this.listeners(e))if(s[i]===t&&!s[r]){this.removeListener(e,s);break}}},MessageEvent:_}},96903,(e,t,s)=>{"use strict";let{tokenChars:r}=e.r(58739);function i(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}t.exports={format:function(e){return Object.keys(e).map(t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map(e=>[t].concat(Object.keys(e).map(t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map(e=>!0===e?t:`${t}=${e}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(e){let t,s,o=Object.create(null),n=Object.create(null),a=!1,l=!1,h=!1,c=-1,d=-1,p=-1,u=0;for(;u<e.length;u++)if(d=e.charCodeAt(u),void 0===t)if(-1===p&&1===r[d])-1===c&&(c=u);else if(0!==u&&(32===d||9===d))-1===p&&-1!==c&&(p=u);else if(59===d||44===d){if(-1===c)throw SyntaxError(`Unexpected character at index ${u}`);-1===p&&(p=u);let s=e.slice(c,p);44===d?(i(o,s,n),n=Object.create(null)):t=s,c=p=-1}else throw SyntaxError(`Unexpected character at index ${u}`);else if(void 0===s)if(-1===p&&1===r[d])-1===c&&(c=u);else if(32===d||9===d)-1===p&&-1!==c&&(p=u);else if(59===d||44===d){if(-1===c)throw SyntaxError(`Unexpected character at index ${u}`);-1===p&&(p=u),i(n,e.slice(c,p),!0),44===d&&(i(o,t,n),n=Object.create(null),t=void 0),c=p=-1}else if(61===d&&-1!==c&&-1===p)s=e.slice(c,u),c=p=-1;else throw SyntaxError(`Unexpected character at index ${u}`);else if(l){if(1!==r[d])throw SyntaxError(`Unexpected character at index ${u}`);-1===c?c=u:a||(a=!0),l=!1}else if(h)if(1===r[d])-1===c&&(c=u);else if(34===d&&-1!==c)h=!1,p=u;else if(92===d)l=!0;else throw SyntaxError(`Unexpected character at index ${u}`);else if(34===d&&61===e.charCodeAt(u-1))h=!0;else if(-1===p&&1===r[d])-1===c&&(c=u);else if(-1!==c&&(32===d||9===d))-1===p&&(p=u);else if(59===d||44===d){if(-1===c)throw SyntaxError(`Unexpected character at index ${u}`);-1===p&&(p=u);let r=e.slice(c,p);a&&(r=r.replace(/\\/g,""),a=!1),i(n,s,r),44===d&&(i(o,t,n),n=Object.create(null),t=void 0),s=void 0,c=p=-1}else throw SyntaxError(`Unexpected character at index ${u}`);if(-1===c||h||32===d||9===d)throw SyntaxError("Unexpected end of input");-1===p&&(p=u);let f=e.slice(c,p);return void 0===t?i(o,f,n):(void 0===s?i(n,f,!0):a?i(n,s,f.replace(/\\/g,"")):i(n,s,f),i(o,t,n)),o}}},35065,(e,t,s)=>{"use strict";let r=e.r(27699),i=e.r(24836),o=e.r(21517),n=e.r(4446),a=e.r(55004),{randomBytes:l,createHash:h}=e.r(54799),{Duplex:c,Readable:d}=e.r(88947),{URL:p}=e.r(92509),u=e.r(80295),f=e.r(29485),m=e.r(16735),{isBlob:_}=e.r(58739),{BINARY_TYPES:g,CLOSE_TIMEOUT:y,EMPTY_BUFFER:b,GUID:S,kForOnEventAttribute:x,kListener:k,kStatusCode:v,kWebSocket:w,NOOP:E}=e.r(74836),{EventTarget:{addEventListener:L,removeEventListener:O}}=e.r(70494),{format:P,parse:T}=e.r(96903),{toBuffer:C}=e.r(97970),A=Symbol("kAborted"),N=[8,13],R=["CONNECTING","OPEN","CLOSING","CLOSED"],I=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class M extends r{constructor(e,t,s){super(),this._binaryType=g[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=b,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=M.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(s=t,t=[]):t=[t]),function e(t,s,r,n){let a,c,d,f,m={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:y,protocolVersion:N[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=m.autoPong,t._closeTimeout=m.closeTimeout,!N.includes(m.protocolVersion))throw RangeError(`Unsupported protocol version: ${m.protocolVersion} (supported versions: ${N.join(", ")})`);if(s instanceof p)a=s;else try{a=new p(s)}catch{throw SyntaxError(`Invalid URL: ${s}`)}"http:"===a.protocol?a.protocol="ws:":"https:"===a.protocol&&(a.protocol="wss:"),t._url=a.href;let _="wss:"===a.protocol,g="ws+unix:"===a.protocol;if("ws:"===a.protocol||_||g?g&&!a.pathname?c="The URL's pathname is empty":a.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"',c){let e=SyntaxError(c);if(0!==t._redirects)return void U(t,e);throw e}let b=_?443:80,x=l(16).toString("base64"),k=_?i.request:o.request,v=new Set;if(m.createConnection=m.createConnection||(_?B:D),m.defaultPort=m.defaultPort||b,m.port=a.port||b,m.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,m.headers={...m.headers,"Sec-WebSocket-Version":m.protocolVersion,"Sec-WebSocket-Key":x,Connection:"Upgrade",Upgrade:"websocket"},m.path=a.pathname+a.search,m.timeout=m.handshakeTimeout,m.perMessageDeflate&&(d=new u({...m.perMessageDeflate,isServer:!1,maxPayload:m.maxPayload}),m.headers["Sec-WebSocket-Extensions"]=P({[u.extensionName]:d.offer()})),r.length){for(let e of r){if("string"!=typeof e||!I.test(e)||v.has(e))throw SyntaxError("An invalid or duplicated subprotocol was specified");v.add(e)}m.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(m.origin&&(m.protocolVersion<13?m.headers["Sec-WebSocket-Origin"]=m.origin:m.headers.Origin=m.origin),(a.username||a.password)&&(m.auth=`${a.username}:${a.password}`),g){let e=m.path.split(":");m.socketPath=e[0],m.path=e[1]}if(m.followRedirects){if(0===t._redirects){t._originalIpc=g,t._originalSecure=_,t._originalHostOrSocketPath=g?m.socketPath:a.host;let e=n&&n.headers;if(n={...n,headers:{}},e)for(let[t,s]of Object.entries(e))n.headers[t.toLowerCase()]=s}else if(0===t.listenerCount("redirect")){let e=g?!!t._originalIpc&&m.socketPath===t._originalHostOrSocketPath:!t._originalIpc&&a.host===t._originalHostOrSocketPath;e&&(!t._originalSecure||_)||(delete m.headers.authorization,delete m.headers.cookie,e||delete m.headers.host,m.auth=void 0)}m.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(m.auth).toString("base64")),f=t._req=k(m),t._redirects&&t.emit("redirect",t.url,f)}else f=t._req=k(m);m.timeout&&f.on("timeout",()=>{F(t,f,"Opening handshake has timed out")}),f.on("error",e=>{null===f||f[A]||(f=t._req=null,U(t,e))}),f.on("response",i=>{let o=i.headers.location,a=i.statusCode;if(o&&m.followRedirects&&a>=300&&a<400){let i;if(++t._redirects>m.maxRedirects)return void F(t,f,"Maximum redirects exceeded");f.abort();try{i=new p(o,s)}catch(e){U(t,SyntaxError(`Invalid URL: ${o}`));return}e(t,i,r,n)}else t.emit("unexpected-response",f,i)||F(t,f,`Unexpected server response: ${i.statusCode}`)}),f.on("upgrade",(e,s,r)=>{let i;if(t.emit("upgrade",e),t.readyState!==M.CONNECTING)return;f=t._req=null;let o=e.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void F(t,s,"Invalid Upgrade header");let n=h("sha1").update(x+S).digest("base64");if(e.headers["sec-websocket-accept"]!==n)return void F(t,s,"Invalid Sec-WebSocket-Accept header");let a=e.headers["sec-websocket-protocol"];if(void 0!==a?v.size?v.has(a)||(i="Server sent an invalid subprotocol"):i="Server sent a subprotocol but none was requested":v.size&&(i="Server sent no subprotocol"),i)return void F(t,s,i);a&&(t._protocol=a);let l=e.headers["sec-websocket-extensions"];if(void 0!==l){let e;if(!d)return void F(t,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");try{e=T(l)}catch(e){F(t,s,"Invalid Sec-WebSocket-Extensions header");return}let r=Object.keys(e);if(1!==r.length||r[0]!==u.extensionName)return void F(t,s,"Server indicated an extension that was not requested");try{d.accept(e[u.extensionName])}catch(e){F(t,s,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[u.extensionName]=d}t.setSocket(s,r,{allowSynchronousEvents:m.allowSynchronousEvents,generateMask:m.generateMask,maxBufferedChunks:m.maxBufferedChunks,maxFragments:m.maxFragments,maxPayload:m.maxPayload,skipUTF8Validation:m.skipUTF8Validation})}),m.finishRequest?m.finishRequest(f,t):f.end()}(this,e,t,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){g.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){let r=new f({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),i=new m(e,this._extensions,s.generateMask);this._receiver=r,this._sender=i,this._socket=e,r[w]=this,i[w]=this,e[w]=this,r.on("conclude",W),r.on("drain",G),r.on("error",j),r.on("message",q),r.on("ping",H),r.on("pong",z),i.onerror=Y,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",X),e.on("data",Z),e.on("end",Q),e.on("error",ee),this._readyState=M.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=M.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[u.extensionName]&&this._extensions[u.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=M.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==M.CLOSED){if(this.readyState===M.CONNECTING)return void F(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===M.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=M.CLOSING,this._sender.close(e,t,!this._isServer,e=>{!e&&(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),J(this)}}pause(){this.readyState!==M.CONNECTING&&this.readyState!==M.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===M.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==M.OPEN)?$(this,e,s):(void 0===t&&(t=!this._isServer),this._sender.ping(e||b,t,s))}pong(e,t,s){if(this.readyState===M.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==M.OPEN)?$(this,e,s):(void 0===t&&(t=!this._isServer),this._sender.pong(e||b,t,s))}resume(){this.readyState!==M.CONNECTING&&this.readyState!==M.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===M.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==M.OPEN)return void $(this,e,s);let r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[u.extensionName]||(r.compress=!1),this._sender.send(e||b,r,s)}terminate(){if(this.readyState!==M.CLOSED){if(this.readyState===M.CONNECTING)return void F(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=M.CLOSING,this._socket.destroy())}}}function U(e,t){e._readyState=M.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function D(e){return e.path=e.socketPath,n.connect(e)}function B(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=n.isIP(e.host)?"":e.host),a.connect(e)}function F(e,t,s){e._readyState=M.CLOSING;let r=Error(s);Error.captureStackTrace(r,F),t.setHeader?(t[A]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(U,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function $(e,t,s){if(t){let s=_(t)?t.size:C(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${R[e.readyState]})`);process.nextTick(s,t)}}function W(e,t){let s=this[w];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[w]&&(s._socket.removeListener("data",Z),process.nextTick(K,s._socket),1005===e?s.close():s.close(e,t))}function G(){let e=this[w];e.isPaused||e._socket.resume()}function j(e){let t=this[w];void 0!==t._socket[w]&&(t._socket.removeListener("data",Z),process.nextTick(K,t._socket),t.close(e[v])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function V(){this[w].emitClose()}function q(e,t){this[w].emit("message",e,t)}function H(e){let t=this[w];t._autoPong&&t.pong(e,!this._isServer,E),t.emit("ping",e)}function z(e){this[w].emit("pong",e)}function K(e){e.resume()}function Y(e){let t=this[w];t.readyState!==M.CLOSED&&(t.readyState===M.OPEN&&(t._readyState=M.CLOSING,J(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function J(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function X(){let e=this[w];if(this.removeListener("close",X),this.removeListener("data",Z),this.removeListener("end",Q),e._readyState=M.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&0!==this._readableState.length){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[w]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",V),e._receiver.on("finish",V))}function Z(e){this[w]._receiver.write(e)||this.pause()}function Q(){let e=this[w];e._readyState=M.CLOSING,e._receiver.end(),this.end()}function ee(){let e=this[w];this.removeListener("error",ee),this.on("error",E),e&&(e._readyState=M.CLOSING,this.destroy())}Object.defineProperty(M,"CONNECTING",{enumerable:!0,value:R.indexOf("CONNECTING")}),Object.defineProperty(M.prototype,"CONNECTING",{enumerable:!0,value:R.indexOf("CONNECTING")}),Object.defineProperty(M,"OPEN",{enumerable:!0,value:R.indexOf("OPEN")}),Object.defineProperty(M.prototype,"OPEN",{enumerable:!0,value:R.indexOf("OPEN")}),Object.defineProperty(M,"CLOSING",{enumerable:!0,value:R.indexOf("CLOSING")}),Object.defineProperty(M.prototype,"CLOSING",{enumerable:!0,value:R.indexOf("CLOSING")}),Object.defineProperty(M,"CLOSED",{enumerable:!0,value:R.indexOf("CLOSED")}),Object.defineProperty(M.prototype,"CLOSED",{enumerable:!0,value:R.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(M.prototype,e,{enumerable:!0})}),["open","error","close","message"].forEach(e=>{Object.defineProperty(M.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[x])return t[k];return null},set(t){for(let t of this.listeners(e))if(t[x]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[x]:!0})}})}),M.prototype.addEventListener=L,M.prototype.removeEventListener=O,t.exports=M},21365,(e,t,s)=>{"use strict";e.r(35065);let{Duplex:r}=e.r(88947);function i(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function n(e){this.removeListener("error",n),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}t.exports=function(e,t){let s=!0,a=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(t,s){let r=!s&&a._readableState.objectMode?t.toString():t;a.push(r)||e.pause()}),e.once("error",function(e){a.destroyed||(s=!1,a.destroy(e))}),e.once("close",function(){a.destroyed||a.push(null)}),a._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t),process.nextTick(i,a);return}let o=!1;e.once("error",function(e){o=!0,r(e)}),e.once("close",function(){o||r(t),process.nextTick(i,a)}),s&&e.terminate()},a._final=function(t){e.readyState===e.CONNECTING?e.once("open",function(){a._final(t)}):null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",function(){t()}),e.close()))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,s,r){e.readyState===e.CONNECTING?e.once("open",function(){a._write(t,s,r)}):e.send(t,r)},a.on("end",o),a.on("error",n),a}},42977,(e,t,s)=>{"use strict";let{tokenChars:r}=e.r(58739);t.exports={parse:function(e){let t=new Set,s=-1,i=-1,o=0;for(;o<e.length;o++){let n=e.charCodeAt(o);if(-1===i&&1===r[n])-1===s&&(s=o);else if(0!==o&&(32===n||9===n))-1===i&&-1!==s&&(i=o);else if(44===n){if(-1===s)throw SyntaxError(`Unexpected character at index ${o}`);-1===i&&(i=o);let r=e.slice(s,i);if(t.has(r))throw SyntaxError(`The "${r}" subprotocol is duplicated`);t.add(r),s=i=-1}else throw SyntaxError(`Unexpected character at index ${o}`)}if(-1===s||-1!==i)throw SyntaxError("Unexpected end of input");let n=e.slice(s,o);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);return t.add(n),t}}},17198,(e,t,s)=>{"use strict";let r=e.r(27699),i=e.r(21517),{Duplex:o}=e.r(88947),{createHash:n}=e.r(54799),a=e.r(96903),l=e.r(80295),h=e.r(42977),c=e.r(35065),{CLOSE_TIMEOUT:d,GUID:p,kWebSocket:u}=e.r(74836),f=/^[+/0-9A-Za-z]{22}==$/;function m(e){e._state=2,e.emit("close")}function _(){this.destroy()}function g(e,t,s,r){s=s||i.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r
|
|
2
|
-
`+Object.keys(r).map(e=>`${e}: ${r[e]}`).join("\r\n")+"\r\n\r\n"+s)}function y(e,t,s,r,i,o){if(e.listenerCount("wsClientError")){let r=Error(i);Error.captureStackTrace(r,y),e.emit("wsClientError",r,s,t)}else g(s,r,i,o)}t.exports=class extends r{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:d,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=i.createServer((e,t)=>{let s=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(let s of Object.keys(t))e.on(s,t[s]);return function(){for(let s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state){e&&this.once("close",()=>{e(Error("The server is not running"))}),process.nextTick(m,this);return}if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(m,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{m(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",_);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,n=+e.headers["sec-websocket-version"];if("GET"!==e.method)return void y(this,e,t,405,"Invalid HTTP method");if(void 0===o||"websocket"!==o.toLowerCase())return void y(this,e,t,400,"Invalid Upgrade header");if(void 0===i||!f.test(i))return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");if(13!==n&&8!==n)return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});if(!this.shouldHandle(e))return void g(t,400);let c=e.headers["sec-websocket-protocol"],d=new Set;if(void 0!==c)try{d=h.parse(c)}catch(s){y(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let p=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&void 0!==p){let s=new l({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=a.parse(p);e[l.extensionName]&&(s.accept(e[l.extensionName]),u[l.extensionName]=s)}catch(s){y(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let o={origin:e.headers[`${8===n?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,(o,n,a,l)=>{if(!o)return g(t,n||401,a,l);this.completeUpgrade(u,i,d,e,t,s,r)});if(!this.options.verifyClient(o))return g(t,401)}this.completeUpgrade(u,i,d,e,t,s,r)}completeUpgrade(e,t,s,r,i,o,h){if(!i.readable||!i.writable)return i.destroy();if(i[u])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return g(i,503);let c=n("sha1").update(t+p).digest("base64"),d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${c}`],f=new this.options.WebSocket(null,void 0,this.options);if(s.size){let e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(d.push(`Sec-WebSocket-Protocol: ${e}`),f._protocol=e)}if(e[l.extensionName]){let t=e[l.extensionName].params,s=a.format({[l.extensionName]:[t]});d.push(`Sec-WebSocket-Extensions: ${s}`),f._extensions=e}this.emit("headers",d,r),i.write(d.concat("\r\n").join("\r\n")),i.removeListener("error",_),f.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(m,this)})),h(f,r)}}},29307,e=>{"use strict";e.s(["SessionManager",()=>f],29307);var t=e.i(54799);class s{workspaceRoot;scopedDirs;tokenUsage={input:0,output:0,cost:0};parseTokenUsage(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),s=t.match(/(?:cost|estimated cost)[:\s]*\$([0-9.]+)/i);s&&(this.tokenUsage.cost=parseFloat(s[1]));let r=e=>(e=e.replace(/,/g,"").toLowerCase().trim()).endsWith("k")?1e3*parseFloat(e.slice(0,-1)):e.endsWith("m")?1e6*parseFloat(e.slice(0,-1)):parseInt(e,10)||0,i=t.match(/tokens?[:\s]*([0-9,.]+[km]?)\s*(?:sent|input|prompt)[^a-zA-Z0-9]+([0-9,.]+[km]?)\s*(?:received|output|completion)/i);if(i)this.tokenUsage.input=r(i[1]),this.tokenUsage.output=r(i[2]);else{let e=t.match(/([0-9,.]+[km]?)\s*(?:sent|input|prompt)\s*tokens?/i)||t.match(/tokens?\s*(?:sent|input|prompt)[:\s]*([0-9,.]+[km]?)/i);e&&(this.tokenUsage.input=r(e[1]));let s=t.match(/([0-9,.]+[km]?)\s*(?:received|output|completion)\s*tokens?/i)||t.match(/tokens?\s*(?:received|output|completion)[:\s]*([0-9,.]+[km]?)/i);s&&(this.tokenUsage.output=r(s[1]))}0===this.tokenUsage.cost&&(this.tokenUsage.input>0||this.tokenUsage.output>0)&&(this.tokenUsage.cost=3e-6*this.tokenUsage.input+15e-6*this.tokenUsage.output)}listeners=[];onOutput(e){this.listeners.push(e)}offOutput(e){this.listeners=this.listeners.filter(t=>t!==e)}emitOutput(e){this.listeners.forEach(t=>t(e))}}var r=e.i(22734),i=e.i(14747);class o{static workspaceRoot=process.cwd();static getSessionsDir(){let e=i.default.join(this.workspaceRoot,".ai","neural-loom","sessions");return r.default.existsSync(e)||r.default.mkdirSync(e,{recursive:!0}),e}static saveSession(e){try{let t=this.getSessionsDir(),s=i.default.join(t,`${e.id}.json`),o={id:e.id,name:e.name,type:e.type,status:"running"===e.status&&"mock"===e.type?"running":e.status,createdAt:e.createdAt,logs:e.logs,workspaceRoot:e.workspaceRoot,scopedDirs:e.scopedDirs};r.default.writeFileSync(s,JSON.stringify(o,null,2),"utf8")}catch(t){console.error(`[SessionPersister] Failed to save session ${e.id}:`,t)}}static loadAllSessions(){try{let e=this.getSessionsDir(),t=r.default.readdirSync(e),s=[];for(let o of t)if(o.endsWith(".json")){let t=i.default.join(e,o),n=r.default.readFileSync(t,"utf8"),a=JSON.parse(n);"running"===a.status&&"mock"!==a.type&&(a.status="stopped",a.logs.push("\r\n\x1b[1;31m[System] Server restarted. Terminal connection lost.\x1b[0m\r\n"),r.default.writeFileSync(t,JSON.stringify(a,null,2),"utf8")),s.push(a)}return s}catch(e){return console.error("[SessionPersister] Failed to load sessions:",e),[]}}static deleteSession(e){try{let t=this.getSessionsDir(),s=i.default.join(t,`${e}.json`);r.default.existsSync(s)&&r.default.unlinkSync(s)}catch(t){console.error(`[SessionPersister] Failed to delete session ${e}:`,t)}}}class n extends s{id;name;type="mock";status="idle";createdAt;logs=[];intervalId=null;mockSteps=["[NeuralLoom] Loading virtual PTY context...","[NeuralLoom] Spawning sandbox mock runtime environment...","[Mock Agent] Model online (v2.0-mock-flash). Dedicated memory allocated.","[Mock Agent] System rules parsed successfully from global context registry.","[Mock Agent] Awaiting developer commands. Type '/help' to list mock skills."];stepIndex=0;constructor(e,t){super(),this.id=e,this.name=t||`Mock Session ${e.substring(0,8)}`,this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.parseTokenUsage(e),this.emitOutput(e+"\r\n"),o.saveSession(this)}async start(){"running"!==this.status&&(this.status="running",this.appendLog("\x1b[1;35m==================================================\x1b[0m"),this.appendLog("\x1b[1;36m NEURALLOOM SIMULATED AGENT ENVIRONMENT \x1b[0m"),this.appendLog("\x1b[1;35m==================================================\x1b[0m"),this.stepIndex<this.mockSteps.length&&this.appendLog(this.mockSteps[this.stepIndex++]),this.intervalId=setInterval(()=>{if(this.tokenUsage.input+=Math.floor(50*Math.random())+10,this.tokenUsage.output+=Math.floor(20*Math.random())+5,this.tokenUsage.cost=3e-6*this.tokenUsage.input+15e-6*this.tokenUsage.output,this.stepIndex<this.mockSteps.length)this.appendLog(this.mockSteps[this.stepIndex++]);else{let e=new Date().toLocaleTimeString();this.appendLog(`[${e}] [Telemetry] CPU utilization 1.2% | Memory 142MB | Link stable.`)}},4e3))}async stop(){this.status="stopped",this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.appendLog("\x1b[1;31m[System] Process terminated. Connection closed.\x1b[0m")}async sendInput(e,t){"running"!==this.status?this.appendLog(`\x1b[1;31m[Error] Cannot write input: process is ${this.status}.\x1b[0m`):(this.appendLog(`\x1b[1;32m> ${e}\x1b[0m`),setTimeout(()=>{let t=e.trim().toLowerCase();"/help"===t?(this.appendLog("[Mock Agent] Available commands:"),this.appendLog(" /help - List available mock commands."),this.appendLog(" /status - Fetch current agent diagnostic metrics."),this.appendLog(" /context - View loaded staging files."),this.appendLog(" /clear - Flush terminal console buffer.")):"/status"===t?(this.appendLog("[Mock Agent] Diagnostics:"),this.appendLog(" - Connection Type: WebSocket gateway (mock)"),this.appendLog(` - Active Runtime: ${this.id}`),this.appendLog(" - Sandbox State: Healthy (0 warnings)")):"/context"===t?(this.appendLog("[Mock Agent] Loaded Workspace Context Files:"),this.appendLog(" - [Mounted] src/app/globals.css (Modified)"),this.appendLog(" - [Mounted] src/app/page.tsx")):"/clear"===t?(this.logs=[],this.appendLog("\x1b[1;33m[Console Cleared]\x1b[0m")):(this.appendLog(`[Mock Agent] Received command: "${e}". Processing...`),setTimeout(()=>{this.appendLog("[Mock Agent] Done. Task simulated successfully.")},1500))},400))}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,tokenUsage:this.tokenUsage}}}class a extends s{id;name;type="claude";status="idle";createdAt;logs=[];ptyProcess=null;ptyModule=null;constructor(e,t){super(),this.id=e,this.name=t||`Claude Session ${e.substring(0,8)}`,this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.logs.length>5e3&&this.logs.shift(),this.parseTokenUsage(e),this.emitOutput(e),o.saveSession(this)}async start(){let t,s,o;if("running"===this.status)return;let n=(t=process.env.PROGRAMFILES||"C:\\Program Files",s=process.env["PROGRAMFILES(X86)"]||"C:\\Program Files (x86)",o=process.env.LOCALAPPDATA||"",[process.env.WINGMAN_BASH_PATH,i.default.join(t,"Git","bin","bash.exe"),i.default.join(s,"Git","bin","bash.exe"),o?i.default.join(o,"Programs","Git","bin","bash.exe"):""].filter(e=>"string"==typeof e&&""!==e).find(e=>r.default.existsSync(e))||null);if(!n){this.status="stopped",this.appendLog("\x1b[1;31m[System Error] Git Bash not found. Please install Git for Windows.\x1b[0m\r\n");return}try{this.ptyModule||(this.ptyModule=await e.A(37661)),this.status="running",this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog("\x1b[1;36m NEURALLOOM ACTIVE CLAUDE TERMINAL ROUTE \x1b[0m\r\n"),this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog(`[System] Spawning Claude Code CLI process using Git Bash...\r
|
|
3
|
-
`);let
|
|
1
|
+
module.exports=[54799,(e,t,s)=>{t.exports=e.x("crypto",()=>require("crypto"))},27699,(e,t,s)=>{t.exports=e.x("events",()=>require("events"))},24836,(e,t,s)=>{t.exports=e.x("https",()=>require("https"))},21517,(e,t,s)=>{t.exports=e.x("http",()=>require("http"))},4446,(e,t,s)=>{t.exports=e.x("net",()=>require("net"))},55004,(e,t,s)=>{t.exports=e.x("tls",()=>require("tls"))},88947,(e,t,s)=>{t.exports=e.x("stream",()=>require("stream"))},92509,(e,t,s)=>{t.exports=e.x("url",()=>require("url"))},6461,(e,t,s)=>{t.exports=e.x("zlib",()=>require("zlib"))},74836,(e,t,s)=>{"use strict";let r=["nodebuffer","arraybuffer","fragments"],i="u">typeof Blob;i&&r.push("blob"),t.exports={BINARY_TYPES:r,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:i,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},97970,(e,t,s)=>{"use strict";let{EMPTY_BUFFER:r}=e.r(74836),i=Buffer[Symbol.species];function o(e,t,s,r,i){for(let o=0;o<i;o++)s[r+o]=e[o]^t[3&o]}function n(e,t){for(let s=0;s<e.length;s++)e[s]^=t[3&s]}function a(e){let t;return(a.readOnly=!0,Buffer.isBuffer(e))?e:(e instanceof ArrayBuffer?t=new i(e):ArrayBuffer.isView(e)?t=new i(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),a.readOnly=!1),t)}if(t.exports={concat:function(e,t){if(0===e.length)return r;if(1===e.length)return e[0];let s=Buffer.allocUnsafe(t),o=0;for(let t=0;t<e.length;t++){let r=e[t];s.set(r,o),o+=r.length}return o<t?new i(s.buffer,s.byteOffset,o):s},mask:o,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:a,unmask:n},!process.env.WS_NO_BUFFER_UTIL)try{let e=(()=>{let e=Error("Cannot find module 'bufferutil'");throw e.code="MODULE_NOT_FOUND",e})();t.exports.mask=function(t,s,r,i,n){n<48?o(t,s,r,i,n):e.mask(t,s,r,i,n)},t.exports.unmask=function(t,s){t.length<32?n(t,s):e.unmask(t,s)}}catch(e){}},62048,(e,t,s)=>{"use strict";let r=Symbol("kDone"),i=Symbol("kRun");t.exports=class{constructor(e){this[r]=()=>{this.pending--,this[i]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[i]()}[i](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[r])}}}},80295,(e,t,s)=>{"use strict";let r,i=e.r(6461),o=e.r(97970),n=e.r(62048),{kStatusCode:a}=e.r(74836),h=Buffer[Symbol.species],l=Buffer.from([0,0,255,255]),c=Symbol("permessage-deflate"),d=Symbol("total-length"),p=Symbol("callback"),u=Symbol("buffers"),f=Symbol("error");function m(e){this[u].push(e),this[d]+=e.length}function _(e){(this[d]+=e.length,this[c]._maxPayload<1||this[d]<=this[c]._maxPayload)?this[u].push(e):(this[f]=RangeError("Max payload size exceeded"),this[f].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[f][a]=1009,this.removeListener("data",_),this.reset())}function g(e){(this[c]._inflate=null,this[f])?this[p](this[f]):(e[a]=1007,this[p](e))}t.exports=class{constructor(e){this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._maxPayload=0|this._options.maxPayload,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,r||(r=new n(void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10))}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[p];this._deflate.close(),this._deflate=null,e&&e(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,s=e.find(e=>(!1!==t.serverNoContextTakeover||!e.server_no_context_takeover)&&(!e.server_max_window_bits||!1!==t.serverMaxWindowBits&&("number"!=typeof t.serverMaxWindowBits||!(t.serverMaxWindowBits>e.server_max_window_bits)))&&("number"!=typeof t.clientMaxWindowBits||!!e.client_max_window_bits));if(!s)throw Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:(!0===s.client_max_window_bits||!1===t.clientMaxWindowBits)&&delete s.client_max_window_bits,s}acceptAsClient(e){let t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let s=e[t];if(s.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){let e=+s;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){let e=+s;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if("client_no_context_takeover"===t||"server_no_context_takeover"===t){if(!0!==s)throw TypeError(`Invalid value for parameter "${t}": ${s}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=s})}),e}decompress(e,t,s){r.add(r=>{this._decompress(e,t,(e,t)=>{r(),s(e,t)})})}compress(e,t,s){r.add(r=>{this._compress(e,t,(e,t)=>{r(),s(e,t)})})}_decompress(e,t,s){let r=this._isServer?"client":"server";if(!this._inflate){let e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?i.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=i.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[d]=0,this._inflate[u]=[],this._inflate.on("error",g),this._inflate.on("data",_)}this._inflate[p]=s,this._inflate.write(e),t&&this._inflate.write(l),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,s(e);return}let i=o.concat(this._inflate[u],this._inflate[d]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[d]=0,this._inflate[u]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,i)})}_compress(e,t,s){let r=this._isServer?"server":"client";if(!this._deflate){let e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?i.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=i.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[d]=0,this._deflate[u]=[],this._deflate.on("data",m)}this._deflate[p]=s,this._deflate.write(e),this._deflate.flush(i.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=o.concat(this._deflate[u],this._deflate[d]);t&&(e=new h(e.buffer,e.byteOffset,e.length-4)),this._deflate[p]=null,this._deflate[d]=0,this._deflate[u]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)})}}},874,(e,t,s)=>{t.exports=e.x("buffer",()=>require("buffer"))},58739,(e,t,s)=>{"use strict";let{isUtf8:r}=e.r(874),{hasBlob:i}=e.r(74836);function o(e){let t=e.length,s=0;for(;s<t;)if((128&e[s])==0)s++;else if((224&e[s])==192){if(s+1===t||(192&e[s+1])!=128||(254&e[s])==192)return!1;s+=2}else if((240&e[s])==224){if(s+2>=t||(192&e[s+1])!=128||(192&e[s+2])!=128||224===e[s]&&(224&e[s+1])==128||237===e[s]&&(224&e[s+1])==160)return!1;s+=3}else{if((248&e[s])!=240||s+3>=t||(192&e[s+1])!=128||(192&e[s+2])!=128||(192&e[s+3])!=128||240===e[s]&&(240&e[s+1])==128||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}return!0}if(t.exports={isBlob:function(e){return i&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:o,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},r)t.exports.isValidUTF8=function(e){return e.length<24?o(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=(()=>{let e=Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e})();t.exports.isValidUTF8=function(t){return t.length<32?o(t):e(t)}}catch(e){}},29485,(e,t,s)=>{"use strict";let{Writable:r}=e.r(88947),i=e.r(80295),{BINARY_TYPES:o,EMPTY_BUFFER:n,kStatusCode:a,kWebSocket:h}=e.r(74836),{concat:l,toArrayBuffer:c,unmask:d}=e.r(97970),{isValidStatusCode:p,isValidUTF8:u}=e.r(58739),f=Buffer[Symbol.species];t.exports=class extends r{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=0|e.maxBufferedChunks,this._maxFragments=0|e.maxFragments,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[h]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,s){return 8===this._opcode&&0==this._state?s():this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks?void s(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS")):void(this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s))}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new f(t.buffer,t.byteOffset+e,t.length-e),new f(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let s=this._buffers[0],r=t.length-e;e>=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new f(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0)return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop)this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((48&t[0])!=0)return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"));let s=(64&t[0])==64;if(s&&!this._extensions[i.extensionName])return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._fin=(128&t[0])==128,this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(s)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(!this._fragmented)return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"));this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));this._compressed=s}else{if(!(this._opcode>7)||!(this._opcode<11))return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));if(!this._fin)return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"));if(s)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=(128&t[1])==128,this._isServer){if(!this._masked)return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}else if(this._masked)return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"));126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),s=t.readUInt32BE(0);s>2097151?e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=0x100000000*s+t.readUInt32BE(4),this.haveLength(e))}haveLength(e){this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)?e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")):this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=n;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!=0&&d(t,this._mask)}if(this._opcode>7)return void this.controlMessage(t,e);if(this._compressed){this._state=5,this.decompress(t,e);return}if(t.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void e(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._messageLength=this._totalPayloadLength,this._fragments.push(t)}this.dataMessage(e)}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,(e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return void t(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void t(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._fragments.push(s)}this.dataMessage(t),0===this._state&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let r;r="nodebuffer"===this._binaryType?l(s,t):"arraybuffer"===this._binaryType?c(l(s,t)):"blob"===this._binaryType?new Blob(s):s,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",r,!0),this._state=0,this.startLoop(e)}))}else{let r=l(s,t);if(!this._skipUTF8Validation&&!u(r))return void e(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));5===this._state||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(8===this._opcode){if(0===e.length)this._loop=!1,this.emit("conclude",1005,n),this.end();else{let s=e.readUInt16BE(0);if(!p(s))return void t(this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE"));let r=new f(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!u(r))return void t(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));this._loop=!1,this.emit("conclude",s,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)}))}createError(e,t,s,r,i){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=i,o[a]=r,o}}},16735,(e,t,s)=>{"use strict";let r,{Duplex:i}=e.r(88947),{randomFillSync:o}=e.r(54799),{types:{isUint8Array:n}}=e.r(24361),a=e.r(80295),{EMPTY_BUFFER:h,kWebSocket:l,NOOP:c}=e.r(74836),{isBlob:d,isValidStatusCode:p}=e.r(58739),{mask:u,toBuffer:f}=e.r(97970),m=Symbol("kByteLength"),_=Buffer.alloc(4),g=8192;class y{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=c,this[l]=void 0}static frame(e,t){let s,i,n=!1,a=2,h=!1;t.mask&&(s=t.maskBuffer||_,t.generateMask?t.generateMask(s):(8192===g&&(void 0===r&&(r=Buffer.alloc(8192)),o(r,0,8192),g=0),s[0]=r[g++],s[1]=r[g++],s[2]=r[g++],s[3]=r[g++]),h=(s[0]|s[1]|s[2]|s[3])==0,a=6),"string"==typeof e?i=(!t.mask||h)&&void 0!==t[m]?t[m]:(e=Buffer.from(e)).length:(i=e.length,n=t.mask&&t.readOnly&&!h);let l=i;i>=65536?(a+=8,l=127):i>125&&(a+=2,l=126);let c=Buffer.allocUnsafe(n?i+a:a);return(c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=l,126===l?c.writeUInt16BE(i,2):127===l&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),t.mask)?(c[1]|=128,c[a-4]=s[0],c[a-3]=s[1],c[a-2]=s[2],c[a-1]=s[3],h)?[c,e]:n?(u(e,s,c,a,i),[c]):(u(e,s,e,0,i),[c,e]):[c,e]}close(e,t,s,r){let i;if(void 0===e)i=h;else if("number"==typeof e&&p(e))if(void 0!==t&&t.length){let s=Buffer.byteLength(t);if(s>123)throw RangeError("The message must not be greater than 123 bytes");if((i=Buffer.allocUnsafe(2+s)).writeUInt16BE(e,0),"string"==typeof t)i.write(t,2);else if(n(t))i.set(t,2);else throw TypeError("Second argument must be a string or a Uint8Array")}else(i=Buffer.allocUnsafe(2)).writeUInt16BE(e,0);else throw TypeError("First argument must be a valid error code number");let o={[m]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,i,!1,o,r]):this.sendFrame(y.frame(i,o),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):d(e)?(r=e.size,i=!1):(r=(e=f(e)).length,i=f.readOnly),r>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[m]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(y.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):d(e)?(r=e.size,i=!1):(r=(e=f(e)).length,i=f.readOnly),r>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[m]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):0!==this._state?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(y.frame(e,o),s)}send(e,t,s){let r,i,o=this._extensions[a.extensionName],n=t.binary?2:1,h=t.compress;"string"==typeof e?(r=Buffer.byteLength(e),i=!1):d(e)?(r=e.size,i=!1):(r=(e=f(e)).length,i=f.readOnly),this._firstFragment?(this._firstFragment=!1,h&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(h=r>=o._threshold),this._compress=h):(h=!1,n=0),t.fin&&(this._firstFragment=!0);let l={[m]:r,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:i,rsv1:h};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,l,s]):this.getBlobData(e,this._compress,l,s):0!==this._state?this.enqueue([this.dispatch,e,this._compress,l,s]):this.dispatch(e,this._compress,l,s)}getBlobData(e,t,s,r){this._bufferedBytes+=s[m],this._state=2,e.arrayBuffer().then(e=>{if(this._socket.destroyed){let e=Error("The socket was closed while the blob was being read");process.nextTick(b,this,e,r);return}this._bufferedBytes-=s[m];let i=f(e);t?this.dispatch(i,t,s,r):(this._state=0,this.sendFrame(y.frame(i,s),r),this.dequeue())}).catch(e=>{process.nextTick(S,this,e,r)})}dispatch(e,t,s,r){if(!t)return void this.sendFrame(y.frame(e,s),r);let i=this._extensions[a.extensionName];this._bufferedBytes+=s[m],this._state=1,i.compress(e,s.fin,(e,t)=>{this._socket.destroyed?b(this,Error("The socket was closed while data was being compressed"),r):(this._bufferedBytes-=s[m],this._state=0,s.readOnly=!1,this.sendFrame(y.frame(t,s),r),this.dequeue())})}dequeue(){for(;0===this._state&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][m],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][m],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}function b(e,t,s){"function"==typeof s&&s(t);for(let s=0;s<e._queue.length;s++){let r=e._queue[s],i=r[r.length-1];"function"==typeof i&&i(t)}}function S(e,t,s){b(e,t,s),e.onerror(t)}t.exports=y},70494,(e,t,s)=>{"use strict";let{kForOnEventAttribute:r,kListener:i}=e.r(74836),o=Symbol("kCode"),n=Symbol("kData"),a=Symbol("kError"),h=Symbol("kMessage"),l=Symbol("kReason"),c=Symbol("kTarget"),d=Symbol("kType"),p=Symbol("kWasClean");class u{constructor(e){this[c]=null,this[d]=e}get target(){return this[c]}get type(){return this[d]}}Object.defineProperty(u.prototype,"target",{enumerable:!0}),Object.defineProperty(u.prototype,"type",{enumerable:!0});class f extends u{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[l]=void 0===t.reason?"":t.reason,this[p]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[l]}get wasClean(){return this[p]}}Object.defineProperty(f.prototype,"code",{enumerable:!0}),Object.defineProperty(f.prototype,"reason",{enumerable:!0}),Object.defineProperty(f.prototype,"wasClean",{enumerable:!0});class m extends u{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[h]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[h]}}Object.defineProperty(m.prototype,"error",{enumerable:!0}),Object.defineProperty(m.prototype,"message",{enumerable:!0});class _ extends u{constructor(e,t={}){super(e),this[n]=void 0===t.data?null:t.data}get data(){return this[n]}}function g(e,t,s){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,s):e.call(t,s)}Object.defineProperty(_.prototype,"data",{enumerable:!0}),t.exports={CloseEvent:f,ErrorEvent:m,Event:u,EventTarget:{addEventListener(e,t,s={}){let o;for(let o of this.listeners(e))if(!s[r]&&o[i]===t&&!o[r])return;if("message"===e)o=function(e,s){let r=new _("message",{data:s?e:e.toString()});r[c]=this,g(t,this,r)};else if("close"===e)o=function(e,s){let r=new f("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[c]=this,g(t,this,r)};else if("error"===e)o=function(e){let s=new m("error",{error:e,message:e.message});s[c]=this,g(t,this,s)};else{if("open"!==e)return;o=function(){let e=new u("open");e[c]=this,g(t,this,e)}}o[r]=!!s[r],o[i]=t,s.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(let s of this.listeners(e))if(s[i]===t&&!s[r]){this.removeListener(e,s);break}}},MessageEvent:_}},96903,(e,t,s)=>{"use strict";let{tokenChars:r}=e.r(58739);function i(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}t.exports={format:function(e){return Object.keys(e).map(t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map(e=>[t].concat(Object.keys(e).map(t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map(e=>!0===e?t:`${t}=${e}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(e){let t,s,o=Object.create(null),n=Object.create(null),a=!1,h=!1,l=!1,c=-1,d=-1,p=-1,u=0;for(;u<e.length;u++)if(d=e.charCodeAt(u),void 0===t)if(-1===p&&1===r[d])-1===c&&(c=u);else if(0!==u&&(32===d||9===d))-1===p&&-1!==c&&(p=u);else if(59===d||44===d){if(-1===c)throw SyntaxError(`Unexpected character at index ${u}`);-1===p&&(p=u);let s=e.slice(c,p);44===d?(i(o,s,n),n=Object.create(null)):t=s,c=p=-1}else throw SyntaxError(`Unexpected character at index ${u}`);else if(void 0===s)if(-1===p&&1===r[d])-1===c&&(c=u);else if(32===d||9===d)-1===p&&-1!==c&&(p=u);else if(59===d||44===d){if(-1===c)throw SyntaxError(`Unexpected character at index ${u}`);-1===p&&(p=u),i(n,e.slice(c,p),!0),44===d&&(i(o,t,n),n=Object.create(null),t=void 0),c=p=-1}else if(61===d&&-1!==c&&-1===p)s=e.slice(c,u),c=p=-1;else throw SyntaxError(`Unexpected character at index ${u}`);else if(h){if(1!==r[d])throw SyntaxError(`Unexpected character at index ${u}`);-1===c?c=u:a||(a=!0),h=!1}else if(l)if(1===r[d])-1===c&&(c=u);else if(34===d&&-1!==c)l=!1,p=u;else if(92===d)h=!0;else throw SyntaxError(`Unexpected character at index ${u}`);else if(34===d&&61===e.charCodeAt(u-1))l=!0;else if(-1===p&&1===r[d])-1===c&&(c=u);else if(-1!==c&&(32===d||9===d))-1===p&&(p=u);else if(59===d||44===d){if(-1===c)throw SyntaxError(`Unexpected character at index ${u}`);-1===p&&(p=u);let r=e.slice(c,p);a&&(r=r.replace(/\\/g,""),a=!1),i(n,s,r),44===d&&(i(o,t,n),n=Object.create(null),t=void 0),s=void 0,c=p=-1}else throw SyntaxError(`Unexpected character at index ${u}`);if(-1===c||l||32===d||9===d)throw SyntaxError("Unexpected end of input");-1===p&&(p=u);let f=e.slice(c,p);return void 0===t?i(o,f,n):(void 0===s?i(n,f,!0):a?i(n,s,f.replace(/\\/g,"")):i(n,s,f),i(o,t,n)),o}}},35065,(e,t,s)=>{"use strict";let r=e.r(27699),i=e.r(24836),o=e.r(21517),n=e.r(4446),a=e.r(55004),{randomBytes:h,createHash:l}=e.r(54799),{Duplex:c,Readable:d}=e.r(88947),{URL:p}=e.r(92509),u=e.r(80295),f=e.r(29485),m=e.r(16735),{isBlob:_}=e.r(58739),{BINARY_TYPES:g,CLOSE_TIMEOUT:y,EMPTY_BUFFER:b,GUID:S,kForOnEventAttribute:x,kListener:k,kStatusCode:v,kWebSocket:w,NOOP:E}=e.r(74836),{EventTarget:{addEventListener:L,removeEventListener:O}}=e.r(70494),{format:P,parse:T}=e.r(96903),{toBuffer:C}=e.r(97970),A=Symbol("kAborted"),N=[8,13],R=["CONNECTING","OPEN","CLOSING","CLOSED"],I=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class M extends r{constructor(e,t,s){super(),this._binaryType=g[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=b,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=M.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(s=t,t=[]):t=[t]),function e(t,s,r,n){let a,c,d,f,m={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:y,protocolVersion:N[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=m.autoPong,t._closeTimeout=m.closeTimeout,!N.includes(m.protocolVersion))throw RangeError(`Unsupported protocol version: ${m.protocolVersion} (supported versions: ${N.join(", ")})`);if(s instanceof p)a=s;else try{a=new p(s)}catch{throw SyntaxError(`Invalid URL: ${s}`)}"http:"===a.protocol?a.protocol="ws:":"https:"===a.protocol&&(a.protocol="wss:"),t._url=a.href;let _="wss:"===a.protocol,g="ws+unix:"===a.protocol;if("ws:"===a.protocol||_||g?g&&!a.pathname?c="The URL's pathname is empty":a.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"',c){let e=SyntaxError(c);if(0!==t._redirects)return void U(t,e);throw e}let b=_?443:80,x=h(16).toString("base64"),k=_?i.request:o.request,v=new Set;if(m.createConnection=m.createConnection||(_?B:D),m.defaultPort=m.defaultPort||b,m.port=a.port||b,m.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,m.headers={...m.headers,"Sec-WebSocket-Version":m.protocolVersion,"Sec-WebSocket-Key":x,Connection:"Upgrade",Upgrade:"websocket"},m.path=a.pathname+a.search,m.timeout=m.handshakeTimeout,m.perMessageDeflate&&(d=new u({...m.perMessageDeflate,isServer:!1,maxPayload:m.maxPayload}),m.headers["Sec-WebSocket-Extensions"]=P({[u.extensionName]:d.offer()})),r.length){for(let e of r){if("string"!=typeof e||!I.test(e)||v.has(e))throw SyntaxError("An invalid or duplicated subprotocol was specified");v.add(e)}m.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(m.origin&&(m.protocolVersion<13?m.headers["Sec-WebSocket-Origin"]=m.origin:m.headers.Origin=m.origin),(a.username||a.password)&&(m.auth=`${a.username}:${a.password}`),g){let e=m.path.split(":");m.socketPath=e[0],m.path=e[1]}if(m.followRedirects){if(0===t._redirects){t._originalIpc=g,t._originalSecure=_,t._originalHostOrSocketPath=g?m.socketPath:a.host;let e=n&&n.headers;if(n={...n,headers:{}},e)for(let[t,s]of Object.entries(e))n.headers[t.toLowerCase()]=s}else if(0===t.listenerCount("redirect")){let e=g?!!t._originalIpc&&m.socketPath===t._originalHostOrSocketPath:!t._originalIpc&&a.host===t._originalHostOrSocketPath;e&&(!t._originalSecure||_)||(delete m.headers.authorization,delete m.headers.cookie,e||delete m.headers.host,m.auth=void 0)}m.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(m.auth).toString("base64")),f=t._req=k(m),t._redirects&&t.emit("redirect",t.url,f)}else f=t._req=k(m);m.timeout&&f.on("timeout",()=>{F(t,f,"Opening handshake has timed out")}),f.on("error",e=>{null===f||f[A]||(f=t._req=null,U(t,e))}),f.on("response",i=>{let o=i.headers.location,a=i.statusCode;if(o&&m.followRedirects&&a>=300&&a<400){let i;if(++t._redirects>m.maxRedirects)return void F(t,f,"Maximum redirects exceeded");f.abort();try{i=new p(o,s)}catch(e){U(t,SyntaxError(`Invalid URL: ${o}`));return}e(t,i,r,n)}else t.emit("unexpected-response",f,i)||F(t,f,`Unexpected server response: ${i.statusCode}`)}),f.on("upgrade",(e,s,r)=>{let i;if(t.emit("upgrade",e),t.readyState!==M.CONNECTING)return;f=t._req=null;let o=e.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void F(t,s,"Invalid Upgrade header");let n=l("sha1").update(x+S).digest("base64");if(e.headers["sec-websocket-accept"]!==n)return void F(t,s,"Invalid Sec-WebSocket-Accept header");let a=e.headers["sec-websocket-protocol"];if(void 0!==a?v.size?v.has(a)||(i="Server sent an invalid subprotocol"):i="Server sent a subprotocol but none was requested":v.size&&(i="Server sent no subprotocol"),i)return void F(t,s,i);a&&(t._protocol=a);let h=e.headers["sec-websocket-extensions"];if(void 0!==h){let e;if(!d)return void F(t,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");try{e=T(h)}catch(e){F(t,s,"Invalid Sec-WebSocket-Extensions header");return}let r=Object.keys(e);if(1!==r.length||r[0]!==u.extensionName)return void F(t,s,"Server indicated an extension that was not requested");try{d.accept(e[u.extensionName])}catch(e){F(t,s,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[u.extensionName]=d}t.setSocket(s,r,{allowSynchronousEvents:m.allowSynchronousEvents,generateMask:m.generateMask,maxBufferedChunks:m.maxBufferedChunks,maxFragments:m.maxFragments,maxPayload:m.maxPayload,skipUTF8Validation:m.skipUTF8Validation})}),m.finishRequest?m.finishRequest(f,t):f.end()}(this,e,t,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){g.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){let r=new f({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),i=new m(e,this._extensions,s.generateMask);this._receiver=r,this._sender=i,this._socket=e,r[w]=this,i[w]=this,e[w]=this,r.on("conclude",W),r.on("drain",j),r.on("error",G),r.on("message",q),r.on("ping",H),r.on("pong",z),i.onerror=Y,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",X),e.on("data",Z),e.on("end",Q),e.on("error",ee),this._readyState=M.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=M.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[u.extensionName]&&this._extensions[u.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=M.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==M.CLOSED){if(this.readyState===M.CONNECTING)return void F(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===M.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=M.CLOSING,this._sender.close(e,t,!this._isServer,e=>{!e&&(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),J(this)}}pause(){this.readyState!==M.CONNECTING&&this.readyState!==M.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===M.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==M.OPEN)?$(this,e,s):(void 0===t&&(t=!this._isServer),this._sender.ping(e||b,t,s))}pong(e,t,s){if(this.readyState===M.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==M.OPEN)?$(this,e,s):(void 0===t&&(t=!this._isServer),this._sender.pong(e||b,t,s))}resume(){this.readyState!==M.CONNECTING&&this.readyState!==M.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===M.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==M.OPEN)return void $(this,e,s);let r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[u.extensionName]||(r.compress=!1),this._sender.send(e||b,r,s)}terminate(){if(this.readyState!==M.CLOSED){if(this.readyState===M.CONNECTING)return void F(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=M.CLOSING,this._socket.destroy())}}}function U(e,t){e._readyState=M.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function D(e){return e.path=e.socketPath,n.connect(e)}function B(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=n.isIP(e.host)?"":e.host),a.connect(e)}function F(e,t,s){e._readyState=M.CLOSING;let r=Error(s);Error.captureStackTrace(r,F),t.setHeader?(t[A]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(U,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function $(e,t,s){if(t){let s=_(t)?t.size:C(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${R[e.readyState]})`);process.nextTick(s,t)}}function W(e,t){let s=this[w];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[w]&&(s._socket.removeListener("data",Z),process.nextTick(K,s._socket),1005===e?s.close():s.close(e,t))}function j(){let e=this[w];e.isPaused||e._socket.resume()}function G(e){let t=this[w];void 0!==t._socket[w]&&(t._socket.removeListener("data",Z),process.nextTick(K,t._socket),t.close(e[v])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function V(){this[w].emitClose()}function q(e,t){this[w].emit("message",e,t)}function H(e){let t=this[w];t._autoPong&&t.pong(e,!this._isServer,E),t.emit("ping",e)}function z(e){this[w].emit("pong",e)}function K(e){e.resume()}function Y(e){let t=this[w];t.readyState!==M.CLOSED&&(t.readyState===M.OPEN&&(t._readyState=M.CLOSING,J(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function J(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function X(){let e=this[w];if(this.removeListener("close",X),this.removeListener("data",Z),this.removeListener("end",Q),e._readyState=M.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&0!==this._readableState.length){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[w]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",V),e._receiver.on("finish",V))}function Z(e){this[w]._receiver.write(e)||this.pause()}function Q(){let e=this[w];e._readyState=M.CLOSING,e._receiver.end(),this.end()}function ee(){let e=this[w];this.removeListener("error",ee),this.on("error",E),e&&(e._readyState=M.CLOSING,this.destroy())}Object.defineProperty(M,"CONNECTING",{enumerable:!0,value:R.indexOf("CONNECTING")}),Object.defineProperty(M.prototype,"CONNECTING",{enumerable:!0,value:R.indexOf("CONNECTING")}),Object.defineProperty(M,"OPEN",{enumerable:!0,value:R.indexOf("OPEN")}),Object.defineProperty(M.prototype,"OPEN",{enumerable:!0,value:R.indexOf("OPEN")}),Object.defineProperty(M,"CLOSING",{enumerable:!0,value:R.indexOf("CLOSING")}),Object.defineProperty(M.prototype,"CLOSING",{enumerable:!0,value:R.indexOf("CLOSING")}),Object.defineProperty(M,"CLOSED",{enumerable:!0,value:R.indexOf("CLOSED")}),Object.defineProperty(M.prototype,"CLOSED",{enumerable:!0,value:R.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(M.prototype,e,{enumerable:!0})}),["open","error","close","message"].forEach(e=>{Object.defineProperty(M.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[x])return t[k];return null},set(t){for(let t of this.listeners(e))if(t[x]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[x]:!0})}})}),M.prototype.addEventListener=L,M.prototype.removeEventListener=O,t.exports=M},21365,(e,t,s)=>{"use strict";e.r(35065);let{Duplex:r}=e.r(88947);function i(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function n(e){this.removeListener("error",n),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}t.exports=function(e,t){let s=!0,a=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(t,s){let r=!s&&a._readableState.objectMode?t.toString():t;a.push(r)||e.pause()}),e.once("error",function(e){a.destroyed||(s=!1,a.destroy(e))}),e.once("close",function(){a.destroyed||a.push(null)}),a._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t),process.nextTick(i,a);return}let o=!1;e.once("error",function(e){o=!0,r(e)}),e.once("close",function(){o||r(t),process.nextTick(i,a)}),s&&e.terminate()},a._final=function(t){e.readyState===e.CONNECTING?e.once("open",function(){a._final(t)}):null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",function(){t()}),e.close()))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,s,r){e.readyState===e.CONNECTING?e.once("open",function(){a._write(t,s,r)}):e.send(t,r)},a.on("end",o),a.on("error",n),a}},42977,(e,t,s)=>{"use strict";let{tokenChars:r}=e.r(58739);t.exports={parse:function(e){let t=new Set,s=-1,i=-1,o=0;for(;o<e.length;o++){let n=e.charCodeAt(o);if(-1===i&&1===r[n])-1===s&&(s=o);else if(0!==o&&(32===n||9===n))-1===i&&-1!==s&&(i=o);else if(44===n){if(-1===s)throw SyntaxError(`Unexpected character at index ${o}`);-1===i&&(i=o);let r=e.slice(s,i);if(t.has(r))throw SyntaxError(`The "${r}" subprotocol is duplicated`);t.add(r),s=i=-1}else throw SyntaxError(`Unexpected character at index ${o}`)}if(-1===s||-1!==i)throw SyntaxError("Unexpected end of input");let n=e.slice(s,o);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);return t.add(n),t}}},17198,(e,t,s)=>{"use strict";let r=e.r(27699),i=e.r(21517),{Duplex:o}=e.r(88947),{createHash:n}=e.r(54799),a=e.r(96903),h=e.r(80295),l=e.r(42977),c=e.r(35065),{CLOSE_TIMEOUT:d,GUID:p,kWebSocket:u}=e.r(74836),f=/^[+/0-9A-Za-z]{22}==$/;function m(e){e._state=2,e.emit("close")}function _(){this.destroy()}function g(e,t,s,r){s=s||i.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r
|
|
2
|
+
`+Object.keys(r).map(e=>`${e}: ${r[e]}`).join("\r\n")+"\r\n\r\n"+s)}function y(e,t,s,r,i,o){if(e.listenerCount("wsClientError")){let r=Error(i);Error.captureStackTrace(r,y),e.emit("wsClientError",r,s,t)}else g(s,r,i,o)}t.exports=class extends r{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:d,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=i.createServer((e,t)=>{let s=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(let s of Object.keys(t))e.on(s,t[s]);return function(){for(let s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state){e&&this.once("close",()=>{e(Error("The server is not running"))}),process.nextTick(m,this);return}if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(m,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{m(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",_);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,n=+e.headers["sec-websocket-version"];if("GET"!==e.method)return void y(this,e,t,405,"Invalid HTTP method");if(void 0===o||"websocket"!==o.toLowerCase())return void y(this,e,t,400,"Invalid Upgrade header");if(void 0===i||!f.test(i))return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");if(13!==n&&8!==n)return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});if(!this.shouldHandle(e))return void g(t,400);let c=e.headers["sec-websocket-protocol"],d=new Set;if(void 0!==c)try{d=l.parse(c)}catch(s){y(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let p=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&void 0!==p){let s=new h({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=a.parse(p);e[h.extensionName]&&(s.accept(e[h.extensionName]),u[h.extensionName]=s)}catch(s){y(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let o={origin:e.headers[`${8===n?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,(o,n,a,h)=>{if(!o)return g(t,n||401,a,h);this.completeUpgrade(u,i,d,e,t,s,r)});if(!this.options.verifyClient(o))return g(t,401)}this.completeUpgrade(u,i,d,e,t,s,r)}completeUpgrade(e,t,s,r,i,o,l){if(!i.readable||!i.writable)return i.destroy();if(i[u])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return g(i,503);let c=n("sha1").update(t+p).digest("base64"),d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${c}`],f=new this.options.WebSocket(null,void 0,this.options);if(s.size){let e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(d.push(`Sec-WebSocket-Protocol: ${e}`),f._protocol=e)}if(e[h.extensionName]){let t=e[h.extensionName].params,s=a.format({[h.extensionName]:[t]});d.push(`Sec-WebSocket-Extensions: ${s}`),f._extensions=e}this.emit("headers",d,r),i.write(d.concat("\r\n").join("\r\n")),i.removeListener("error",_),f.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(m,this)})),l(f,r)}}},29307,e=>{"use strict";e.s(["SessionManager",()=>m],29307);var t=e.i(54799);class s{workspaceRoot;scopedDirs;tokenUsage={input:0,output:0,cost:0};parseTokenUsage(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),s=t.match(/(?:cost|estimated cost)[:\s]*\$([0-9.]+)/i);s&&(this.tokenUsage.cost=parseFloat(s[1]));let r=e=>(e=e.replace(/,/g,"").toLowerCase().trim()).endsWith("k")?1e3*parseFloat(e.slice(0,-1)):e.endsWith("m")?1e6*parseFloat(e.slice(0,-1)):parseInt(e,10)||0,i=t.match(/tokens?[:\s]*([0-9,.]+[km]?)\s*(?:sent|input|prompt)[^a-zA-Z0-9]+([0-9,.]+[km]?)\s*(?:received|output|completion)/i);if(i)this.tokenUsage.input=r(i[1]),this.tokenUsage.output=r(i[2]);else{let e=t.match(/([0-9,.]+[km]?)\s*(?:sent|input|prompt)\s*tokens?/i)||t.match(/tokens?\s*(?:sent|input|prompt)[:\s]*([0-9,.]+[km]?)/i);e&&(this.tokenUsage.input=r(e[1]));let s=t.match(/([0-9,.]+[km]?)\s*(?:received|output|completion)\s*tokens?/i)||t.match(/tokens?\s*(?:received|output|completion)[:\s]*([0-9,.]+[km]?)/i);s&&(this.tokenUsage.output=r(s[1]))}0===this.tokenUsage.cost&&(this.tokenUsage.input>0||this.tokenUsage.output>0)&&(this.tokenUsage.cost=3e-6*this.tokenUsage.input+15e-6*this.tokenUsage.output)}listeners=[];onOutput(e){this.listeners.push(e)}offOutput(e){this.listeners=this.listeners.filter(t=>t!==e)}emitOutput(e){this.listeners.forEach(t=>t(e))}}var r=e.i(22734),i=e.i(14747);class o{static workspaceRoot=process.cwd();static getSessionsDir(){let e=i.default.join(this.workspaceRoot,".ai","neural-loom","sessions");return r.default.existsSync(e)||r.default.mkdirSync(e,{recursive:!0}),e}static saveSession(e){try{let t=this.getSessionsDir(),s=i.default.join(t,`${e.id}.json`),o={id:e.id,name:e.name,type:e.type,status:"running"===e.status&&"mock"===e.type?"running":e.status,createdAt:e.createdAt,logs:e.logs,workspaceRoot:e.workspaceRoot,scopedDirs:e.scopedDirs};r.default.writeFileSync(s,JSON.stringify(o,null,2),"utf8")}catch(t){console.error(`[SessionPersister] Failed to save session ${e.id}:`,t)}}static loadAllSessions(){try{let e=this.getSessionsDir(),t=r.default.readdirSync(e),s=[];for(let o of t)if(o.endsWith(".json")){let t=i.default.join(e,o),n=r.default.readFileSync(t,"utf8"),a=JSON.parse(n);"running"===a.status&&"mock"!==a.type&&(a.status="stopped",a.logs.push("\r\n\x1b[1;31m[System] Server restarted. Terminal connection lost.\x1b[0m\r\n"),r.default.writeFileSync(t,JSON.stringify(a,null,2),"utf8")),s.push(a)}return s}catch(e){return console.error("[SessionPersister] Failed to load sessions:",e),[]}}static deleteSession(e){try{let t=this.getSessionsDir(),s=i.default.join(t,`${e}.json`);r.default.existsSync(s)&&r.default.unlinkSync(s)}catch(t){console.error(`[SessionPersister] Failed to delete session ${e}:`,t)}}}class n extends s{id;name;type="mock";status="idle";createdAt;logs=[];intervalId=null;mockSteps=["[NeuralLoom] Loading virtual PTY context...","[NeuralLoom] Spawning sandbox mock runtime environment...","[Mock Agent] Model online (v2.0-mock-flash). Dedicated memory allocated.","[Mock Agent] System rules parsed successfully from global context registry.","[Mock Agent] Awaiting developer commands. Type '/help' to list mock skills."];stepIndex=0;constructor(e,t){super(),this.id=e,this.name=t||`Mock Session ${e.substring(0,8)}`,this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.parseTokenUsage(e),this.emitOutput(e+"\r\n"),o.saveSession(this)}async start(){"running"!==this.status&&(this.status="running",this.appendLog("\x1b[1;35m==================================================\x1b[0m"),this.appendLog("\x1b[1;36m NEURALLOOM SIMULATED AGENT ENVIRONMENT \x1b[0m"),this.appendLog("\x1b[1;35m==================================================\x1b[0m"),this.stepIndex<this.mockSteps.length&&this.appendLog(this.mockSteps[this.stepIndex++]),this.intervalId=setInterval(()=>{if(this.tokenUsage.input+=Math.floor(50*Math.random())+10,this.tokenUsage.output+=Math.floor(20*Math.random())+5,this.tokenUsage.cost=3e-6*this.tokenUsage.input+15e-6*this.tokenUsage.output,this.stepIndex<this.mockSteps.length)this.appendLog(this.mockSteps[this.stepIndex++]);else{let e=new Date().toLocaleTimeString();this.appendLog(`[${e}] [Telemetry] CPU utilization 1.2% | Memory 142MB | Link stable.`)}},4e3))}async stop(){this.status="stopped",this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.appendLog("\x1b[1;31m[System] Process terminated. Connection closed.\x1b[0m")}async sendInput(e,t){"running"!==this.status?this.appendLog(`\x1b[1;31m[Error] Cannot write input: process is ${this.status}.\x1b[0m`):(this.appendLog(`\x1b[1;32m> ${e}\x1b[0m`),setTimeout(()=>{let t=e.trim().toLowerCase();"/help"===t?(this.appendLog("[Mock Agent] Available commands:"),this.appendLog(" /help - List available mock commands."),this.appendLog(" /status - Fetch current agent diagnostic metrics."),this.appendLog(" /context - View loaded staging files."),this.appendLog(" /clear - Flush terminal console buffer.")):"/status"===t?(this.appendLog("[Mock Agent] Diagnostics:"),this.appendLog(" - Connection Type: WebSocket gateway (mock)"),this.appendLog(` - Active Runtime: ${this.id}`),this.appendLog(" - Sandbox State: Healthy (0 warnings)")):"/context"===t?(this.appendLog("[Mock Agent] Loaded Workspace Context Files:"),this.appendLog(" - [Mounted] src/app/globals.css (Modified)"),this.appendLog(" - [Mounted] src/app/page.tsx")):"/clear"===t?(this.logs=[],this.appendLog("\x1b[1;33m[Console Cleared]\x1b[0m")):(this.appendLog(`[Mock Agent] Received command: "${e}". Processing...`),setTimeout(()=>{this.appendLog("[Mock Agent] Done. Task simulated successfully.")},1500))},400))}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,tokenUsage:this.tokenUsage}}}function a(){if("u"<typeof process)return!1;let e=Object.keys(process).find(e=>e.startsWith("plat")&&e.endsWith("form"));return!!e&&"win32"===process[e]}class h extends s{id;name;type="claude";status="idle";createdAt;logs=[];ptyProcess=null;ptyModule=null;constructor(e,t){super(),this.id=e,this.name=t||`Claude Session ${e.substring(0,8)}`,this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.logs.length>5e3&&this.logs.shift(),this.parseTokenUsage(e),this.emitOutput(e),o.saveSession(this)}async start(){if("running"===this.status)return;let t=function(){if(!a())return"bash";let e=process.env.PROGRAMFILES||"C:\\Program Files",t=process.env["PROGRAMFILES(X86)"]||"C:\\Program Files (x86)",s=process.env.LOCALAPPDATA||"";return[process.env.WINGMAN_BASH_PATH,i.default.join(e,"Git","bin","bash.exe"),i.default.join(t,"Git","bin","bash.exe"),s?i.default.join(s,"Programs","Git","bin","bash.exe"):""].filter(e=>"string"==typeof e&&""!==e).find(e=>r.default.existsSync(e))||null}();if(!t){this.status="stopped",this.appendLog("\x1b[1;31m[System Error] Git Bash not found. Please install Git for Windows.\x1b[0m\r\n");return}try{this.ptyModule||(this.ptyModule=await e.A(37661)),this.status="running",this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog("\x1b[1;36m NEURALLOOM ACTIVE CLAUDE TERMINAL ROUTE \x1b[0m\r\n"),this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog(`[System] Spawning Claude Code CLI process using Git Bash...\r
|
|
3
|
+
`);let s=this.workspaceRoot&&r.default.existsSync(this.workspaceRoot)?this.workspaceRoot:process.cwd();this.ptyProcess=this.ptyModule.spawn(t,["-c","claude --agents-md"],{name:"xterm-256color",cols:120,rows:30,cwd:s,env:{...process.env,TERM:"xterm-256color",COLORTERM:"truecolor",...a()?{PATH:"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VisualStudio\\NodeJs;"+process.env.PATH}:{}}}),this.ptyProcess.onData(e=>{this.appendLog(e)}),this.ptyProcess.onExit(({exitCode:e,signal:t})=>{this.status="stopped",this.appendLog(`\r
|
|
4
4
|
\x1b[1;31m[System] Claude Code PTY process exited (code=${e}, signal=${t}).\x1b[0m\r
|
|
5
5
|
`),this.ptyProcess=null})}catch(t){let e=t instanceof Error?t.message:"Unknown error";this.status="stopped",this.appendLog(`\x1b[1;31m[System Error] Failed to initialize node-pty runner: ${e}\x1b[0m\r
|
|
6
6
|
`),console.error("Failed to start Claude PTY runner:",t)}}async stop(){if(this.status="stopped",this.ptyProcess){try{this.ptyProcess.kill()}catch(e){console.error("Error killing PTY process:",e)}this.ptyProcess=null}this.appendLog("\r\n\x1b[1;31m[System] Terminal bridge terminated.\x1b[0m\r\n")}async sendInput(e,t=!1){"running"===this.status&&this.ptyProcess?this.ptyProcess.write(t?e:e+"\r"):this.appendLog(`\r
|
|
7
7
|
\x1b[1;31m[Error] Cannot write: session process is ${this.status}.\x1b[0m\r
|
|
8
|
-
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}class l extends s{id;name;type="claude-docker";status="idle";createdAt;logs=[];ptyProcess=null;ptyModule=null;constructor(e,t){super(),this.id=e,this.name=t||`Docker Session ${e.substring(0,8)}`,this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.logs.length>5e3&&this.logs.shift(),this.parseTokenUsage(e),this.emitOutput(e),o.saveSession(this)}async start(){
|
|
8
|
+
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}class l extends s{id;name;type="claude-docker";status="idle";createdAt;logs=[];ptyProcess=null;ptyModule=null;constructor(e,t){super(),this.id=e,this.name=t||`Docker Session ${e.substring(0,8)}`,this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.logs.length>5e3&&this.logs.shift(),this.parseTokenUsage(e),this.emitOutput(e),o.saveSession(this)}async start(){if("running"===this.status)return;this.status="running",this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog("\x1b[1;36m NEURALLOOM DOCKER SANDBOX RUNTIME BRIDGE \x1b[0m\r\n"),this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog("[System] Verifying Docker environment accessibility...\r\n");let t=function(){if(!function(){if("u"<typeof process)return!1;let e=Object.keys(process).find(e=>e.startsWith("plat")&&e.endsWith("form"));return!!e&&"win32"===process[e]}())return"bash";let e=process.env.PROGRAMFILES||"C:\\Program Files",t=process.env["PROGRAMFILES(X86)"]||"C:\\Program Files (x86)",s=process.env.LOCALAPPDATA||"";return[process.env.WINGMAN_BASH_PATH,i.default.join(e,"Git","bin","bash.exe"),i.default.join(t,"Git","bin","bash.exe"),s?i.default.join(s,"Programs","Git","bin","bash.exe"):""].filter(e=>"string"==typeof e&&""!==e).find(e=>r.default.existsSync(e))||null}();if(!t){this.status="stopped",this.appendLog("\x1b[1;31m[System Error] Git Bash not found. Cannot bootstrap PTY sandbox.\x1b[0m\r\n");return}try{this.ptyModule||(this.ptyModule=await e.A(37661));let s=this.workspaceRoot&&r.default.existsSync(this.workspaceRoot)?this.workspaceRoot:process.cwd(),o=this.ptyModule.spawn(t,["-c","docker --version"],{name:"xterm-256color",cols:80,rows:10,cwd:s}),n=!1;if(o.onData(e=>{e.toLowerCase().includes("docker version")&&(n=!0)}),await new Promise(e=>setTimeout(e,800)),o.kill(),!n){this.status="stopped",this.appendLog("\x1b[1;31m[Dependency Warning] Docker command not recognized in local PATH.\x1b[0m\r\n"),this.appendLog("\x1b[1;33mPlease install Docker Desktop (https://www.docker.com/products/docker-desktop) and ensure the daemon is running.\x1b[0m\r\n"),this.appendLog("\x1b[1;31m[System] Sandbox launch aborted.\x1b[0m\r\n");return}this.appendLog("[System] Docker detected. Initializing container mount...\r\n");let a=[`-v "${s}:/workspace"`];this.scopedDirs&&Array.isArray(this.scopedDirs)&&this.scopedDirs.forEach(e=>{if(r.default.existsSync(e)){let t=i.default.basename(e).replace(/[^a-zA-Z0-9-_]/g,"_");a.push(`-v "${e}:/scoped/${t}"`)}});let h=a.join(" "),l=`docker run -it --name neural-loom-session-${this.id} --rm ${h} -w /workspace node:20-alpine npx -y @anthropic-ai/claude-code --agents-md`;this.ptyProcess=this.ptyModule.spawn(t,["-c",l],{name:"xterm-256color",cols:120,rows:30,cwd:s,env:{...process.env,TERM:"xterm-256color",COLORTERM:"truecolor"}}),this.ptyProcess.onData(e=>{this.appendLog(e)}),this.ptyProcess.onExit(({exitCode:e,signal:t})=>{this.status="stopped",this.appendLog(`\r
|
|
9
9
|
\x1b[1;31m[System] Docker Sandbox exited (code=${e}, signal=${t}).\x1b[0m\r
|
|
10
10
|
`),this.ptyProcess=null})}catch(t){let e=t instanceof Error?t.message:"Unknown error";this.status="stopped",this.appendLog(`\x1b[1;31m[System Error] Failed to launch Docker runner: ${e}\x1b[0m\r
|
|
11
11
|
`)}}async stop(){if(this.status="stopped",this.ptyProcess){try{this.ptyProcess.kill()}catch(e){console.error("Error killing Docker PTY process:",e)}this.ptyProcess=null}this.appendLog("\r\n\x1b[1;31m[System] Docker container stopped and unmounted.\x1b[0m\r\n")}async sendInput(e,t=!1){"running"===this.status&&this.ptyProcess?this.ptyProcess.write(t?e:e+"\r"):this.appendLog(`\r
|
|
12
12
|
\x1b[1;31m[Error] Cannot write: Docker container is ${this.status}.\x1b[0m\r
|
|
13
|
-
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}class
|
|
14
|
-
`),this.appendLog("\x1b[1;36mTemplate structure:\x1b[0m\r\n"),this.appendLog(JSON.stringify({host:"your.remote.host.com",username:"dave",privateKeyPath:"C:\\\\Users\\\\Dave\\\\.ssh\\\\id_rsa",port:22},null,2).replace(/\n/g,"\r\n")+"\r\n"),this.appendLog("\x1b[1;31m[System] SSH startup aborted.\x1b[0m\r\n");return}try{let
|
|
15
|
-
`);let
|
|
13
|
+
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}class c extends s{id;name;type="claude-ssh";status="idle";createdAt;logs=[];ptyProcess=null;ptyModule=null;constructor(e,t){super(),this.id=e,this.name=t||`SSH Session ${e.substring(0,8)}`,this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.logs.length>5e3&&this.logs.shift(),this.parseTokenUsage(e),this.emitOutput(e),o.saveSession(this)}async start(){if("running"===this.status)return;this.status="running",this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog("\x1b[1;36m NEURALLOOM REMOTE VM (SSH) ROUTE BRIDGE \x1b[0m\r\n"),this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog("[System] Loading SSH configuration...\r\n");let t=function(){if(!function(){if("u"<typeof process)return!1;let e=Object.keys(process).find(e=>e.startsWith("plat")&&e.endsWith("form"));return!!e&&"win32"===process[e]}())return"bash";let e=process.env.PROGRAMFILES||"C:\\Program Files",t=process.env["PROGRAMFILES(X86)"]||"C:\\Program Files (x86)",s=process.env.LOCALAPPDATA||"";return[process.env.WINGMAN_BASH_PATH,i.default.join(e,"Git","bin","bash.exe"),i.default.join(t,"Git","bin","bash.exe"),s?i.default.join(s,"Programs","Git","bin","bash.exe"):""].filter(e=>"string"==typeof e&&""!==e).find(e=>r.default.existsSync(e))||null}();if(!t){this.status="stopped",this.appendLog("\x1b[1;31m[System Error] Git Bash not found. Cannot bootstrap SSH terminal.\x1b[0m\r\n");return}let s=i.default.join(process.cwd(),".ai","neural-loom","ssh.json");if(!r.default.existsSync(s)){this.status="stopped",this.appendLog("\x1b[1;31m[Configuration Error] ssh.json not found!\x1b[0m\r\n"),this.appendLog(`\x1b[1;33mPlease create the SSH credentials file at: ${s}\x1b[0m\r
|
|
14
|
+
`),this.appendLog("\x1b[1;36mTemplate structure:\x1b[0m\r\n"),this.appendLog(JSON.stringify({host:"your.remote.host.com",username:"dave",privateKeyPath:"C:\\\\Users\\\\Dave\\\\.ssh\\\\id_rsa",port:22},null,2).replace(/\n/g,"\r\n")+"\r\n"),this.appendLog("\x1b[1;31m[System] SSH startup aborted.\x1b[0m\r\n");return}try{let i=r.default.readFileSync(s,"utf8"),o=JSON.parse(i);if(!o.host||!o.username){this.status="stopped",this.appendLog("\x1b[1;31m[System Error] Invalid ssh.json configuration. 'host' and 'username' are required.\x1b[0m\r\n");return}this.ptyModule||(this.ptyModule=await e.A(37661)),this.appendLog(`[System] Connecting to ${o.username}@${o.host}...\r
|
|
15
|
+
`);let n=o.port?`-p ${o.port}`:"",a=o.privateKeyPath?`-i "${o.privateKeyPath}"`:"",h=`ssh -t ${a} ${n} ${o.username}@${o.host} "claude --agents-md"`;this.ptyProcess=this.ptyModule.spawn(t,["-c",h],{name:"xterm-256color",cols:120,rows:30,cwd:process.cwd(),env:{...process.env,TERM:"xterm-256color",COLORTERM:"truecolor"}}),this.ptyProcess.onData(e=>{this.appendLog(e)}),this.ptyProcess.onExit(({exitCode:e,signal:t})=>{this.status="stopped",this.appendLog(`\r
|
|
16
16
|
\x1b[1;31m[System] SSH Session exited (code=${e}, signal=${t}).\x1b[0m\r
|
|
17
17
|
`),this.ptyProcess=null})}catch(t){let e=t instanceof Error?t.message:"Unknown error";this.status="stopped",this.appendLog(`\x1b[1;31m[System Error] SSH connection failed: ${e}\x1b[0m\r
|
|
18
18
|
`)}}async stop(){if(this.status="stopped",this.ptyProcess){try{this.ptyProcess.kill()}catch(e){console.error("Error killing SSH PTY process:",e)}this.ptyProcess=null}this.appendLog("\r\n\x1b[1;31m[System] SSH Connection terminated.\x1b[0m\r\n")}async sendInput(e,t=!1){"running"===this.status&&this.ptyProcess?this.ptyProcess.write(t?e:e+"\r"):this.appendLog(`\r
|
|
19
19
|
\x1b[1;31m[Error] Cannot write: SSH session is ${this.status}.\x1b[0m\r
|
|
20
|
-
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}class
|
|
21
|
-
`),this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n");let
|
|
20
|
+
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}class d extends s{id;name;type;status="idle";createdAt;logs=[];ptyProcess=null;ptyModule=null;constructor(e,t,s){super(),this.id=e,this.type=t,this.name=s||("aider-docker"===t?`Aider Docker ${e.substring(0,8)}`:`Aider Session ${e.substring(0,8)}`),this.createdAt=new Date().toISOString()}appendLog(e){this.logs.push(e),this.logs.length>5e3&&this.logs.shift(),this.parseTokenUsage(e),this.emitOutput(e),o.saveSession(this)}async start(){if("running"===this.status)return;this.status="running",this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n"),this.appendLog(`\x1b[1;36m NEURALLOOM AIDER AGENT ROUTE (${this.type.toUpperCase()}) \x1b[0m\r
|
|
21
|
+
`),this.appendLog("\x1b[1;35m==================================================\x1b[0m\r\n");let t=function(){if(!function(){if("u"<typeof process)return!1;let e=Object.keys(process).find(e=>e.startsWith("plat")&&e.endsWith("form"));return!!e&&"win32"===process[e]}())return"bash";let e=process.env.PROGRAMFILES||"C:\\Program Files",t=process.env["PROGRAMFILES(X86)"]||"C:\\Program Files (x86)",s=process.env.LOCALAPPDATA||"";return[process.env.WINGMAN_BASH_PATH,i.default.join(e,"Git","bin","bash.exe"),i.default.join(t,"Git","bin","bash.exe"),s?i.default.join(s,"Programs","Git","bin","bash.exe"):""].filter(e=>"string"==typeof e&&""!==e).find(e=>r.default.existsSync(e))||null}();if(!t){this.status="stopped",this.appendLog("\x1b[1;31m[System Error] Git Bash not found. Cannot spawn terminal.\x1b[0m\r\n");return}try{this.ptyModule||(this.ptyModule=await e.A(37661));let s={openaiApiKey:"",anthropicApiKey:"",geminiApiKey:"",model:"claude-3-5-sonnet",extraFlags:""},o=i.default.join(process.cwd(),".ai","neural-loom","aider.json");if(r.default.existsSync(o))try{s=JSON.parse(r.default.readFileSync(o,"utf8"))}catch(e){console.error("Failed to parse Aider configuration:",e)}let n={...process.env,TERM:"xterm-256color",COLORTERM:"truecolor"};s.openaiApiKey&&(n.OPENAI_API_KEY=s.openaiApiKey),s.anthropicApiKey&&(n.ANTHROPIC_API_KEY=s.anthropicApiKey),s.geminiApiKey&&(n.GEMINI_API_KEY=s.geminiApiKey);let a=s.model?`--model ${s.model}`:"",h=s.extraFlags||"",l=this.workspaceRoot&&r.default.existsSync(this.workspaceRoot)?this.workspaceRoot:process.cwd();if("aider-docker"===this.type){this.appendLog("[System] Verifying Docker environment accessibility...\r\n");let e=this.ptyModule.spawn(t,["-c","docker --version"],{name:"xterm-256color",cols:80,rows:10,cwd:l}),o=!1;if(e.onData(e=>{e.toLowerCase().includes("docker version")&&(o=!0)}),await new Promise(e=>setTimeout(e,800)),e.kill(),!o){this.status="stopped",this.appendLog("\x1b[1;31m[Dependency Warning] Docker command not recognized in local PATH.\x1b[0m\r\n"),this.appendLog("\x1b[1;33mPlease install Docker Desktop and ensure the daemon is running.\x1b[0m\r\n");return}this.appendLog("[System] Spawning Aider container environment...\r\n");let c=[];s.openaiApiKey&&c.push("-e OPENAI_API_KEY"),s.anthropicApiKey&&c.push("-e ANTHROPIC_API_KEY"),s.geminiApiKey&&c.push("-e GEMINI_API_KEY");let d=c.join(" "),p=[`-v "${l}:/workspace"`];this.scopedDirs&&Array.isArray(this.scopedDirs)&&this.scopedDirs.forEach(e=>{if(r.default.existsSync(e)){let t=i.default.basename(e).replace(/[^a-zA-Z0-9-_]/g,"_");p.push(`-v "${e}:/scoped/${t}"`)}});let u=p.join(" "),f=`docker run -it --name neural-loom-session-${this.id} --rm ${u} -w /workspace ${d} paulgauthier/aider ${a} ${h}`.trim();this.ptyProcess=this.ptyModule.spawn(t,["-c",f],{name:"xterm-256color",cols:120,rows:30,cwd:l,env:n})}else{this.appendLog("[System] Verifying 'aider' command availability in local PATH...\r\n");let e=this.ptyModule.spawn(t,["-c","aider --version"],{name:"xterm-256color",cols:80,rows:10,cwd:l}),s=!1;if(e.onData(e=>{e.toLowerCase().includes("aider")&&(s=!0)}),await new Promise(e=>setTimeout(e,800)),e.kill(),!s){this.status="stopped",this.appendLog("\x1b[1;31m[Dependency Warning] 'aider' executable not found on local PATH.\x1b[0m\r\n"),this.appendLog("\x1b[1;33mPlease install Aider globally via pip:\r\n pip install aider-chat\x1b[0m\r\n");return}this.appendLog("[System] Spawning local Aider CLI...\r\n");let r=`aider ${a} ${h}`.trim();this.ptyProcess=this.ptyModule.spawn(t,["-c",r],{name:"xterm-256color",cols:120,rows:30,cwd:l,env:n})}this.ptyProcess.onData(e=>{this.appendLog(e)}),this.ptyProcess.onExit(({exitCode:e,signal:t})=>{this.status="stopped",this.appendLog(`\r
|
|
22
22
|
\x1b[1;31m[System] Aider process exited (code=${e}, signal=${t}).\x1b[0m\r
|
|
23
23
|
`),this.ptyProcess=null})}catch(t){let e=t instanceof Error?t.message:"Unknown error";this.status="stopped",this.appendLog(`\x1b[1;31m[System Error] Failed to launch Aider: ${e}\x1b[0m\r
|
|
24
24
|
`)}}async stop(){if(this.status="stopped",this.ptyProcess){try{this.ptyProcess.kill()}catch(e){console.error("Error killing Aider PTY process:",e)}this.ptyProcess=null}this.appendLog("\r\n\x1b[1;31m[System] Aider session terminated.\x1b[0m\r\n")}async sendInput(e,t=!1){"running"===this.status&&this.ptyProcess?this.ptyProcess.write(t?e:e+"\r"):this.appendLog(`\r
|
|
25
25
|
\x1b[1;31m[Error] Cannot write: Aider process is ${this.status}.\x1b[0m\r
|
|
26
|
-
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}e.i(21365),e.i(96903),e.i(80295),e.i(29485),e.i(16735),e.i(42977);var
|
|
26
|
+
`)}getStatus(){return{id:this.id,name:this.name,type:this.type,status:this.status,createdAt:this.createdAt,logsCount:this.logs.length,workspaceRoot:this.workspaceRoot,scopedDirs:this.scopedDirs,tokenUsage:this.tokenUsage}}}e.i(21365),e.i(96903),e.i(80295),e.i(29485),e.i(16735),e.i(42977);var p=e.i(35065),u=e.i(17198);p.default;var f=e.i(46619);class m{static instance=null;sessions=new Map;constructor(){f.ContextManager.initializeStaging(),f.ContextManager.compileGlobalRules();try{for(const e of o.loadAllSessions()){let t;(t="mock"===e.type?new n(e.id,e.name):"claude-docker"===e.type?new l(e.id,e.name):"claude-ssh"===e.type?new c(e.id,e.name):"aider"===e.type||"aider-docker"===e.type?new d(e.id,e.type,e.name):new h(e.id,e.name)).status=e.status,t.createdAt=e.createdAt,t.logs=e.logs,t.workspaceRoot=e.workspaceRoot,t.scopedDirs=e.scopedDirs,"mock"===e.type&&"running"===e.status&&t.start(),this.sessions.set(e.id,t)}}catch(e){console.error("[SessionManager] Failed to reload saved sessions:",e)}}static getInstance(){return m.instance||(m.instance=new m,!function(t=3001){if(e.g.wss)return console.log("[WebSocketServer] WebSocket Server already active on port 3001 (cached).");console.log(`[WebSocketServer] Launching NeuralLoom WebSocket Gateway on port ${t}...`);try{let s=new u.default({port:t});e.g.wss=s,s.on("connection",e=>{console.log("[WebSocketServer] New client connected via gateway.");let t=null,s=null,r="";e.on("message",async i=>{try{let o=JSON.parse(i.toString());if("handshake"===o.type){let{sessionId:r}=o,i=m.getInstance().getSession(r);i?(t=r,e.sessionId=r,console.log(`[WebSocketServer] Client connected to active session: ${r}`),s=t=>{e.readyState===p.default.OPEN&&e.send(JSON.stringify({type:"output",data:t}))},i.onOutput(s),e.send(JSON.stringify({type:"handshake-ack",sessionId:r,history:i.logs.join("")}))):e.send(JSON.stringify({type:"error",message:"Requested session not found"}))}if("input"===o.type&&t){let s=m.getInstance().getSession(t);if(s&&"running"===s.status)if("mock"===s.type){let t=o.data;if("\r"===t||"\r\n"===t){e.send(JSON.stringify({type:"output",data:"\r\n"}));let t=r;r="",await s.sendInput(t)}else""===t||"\b"===t?r.length>0&&(r=r.slice(0,-1),e.send(JSON.stringify({type:"output",data:"\b \b"}))):(r+=t,e.send(JSON.stringify({type:"output",data:t})))}else await s.sendInput(o.data,!0)}}catch(e){console.error("[WebSocketServer] Error processing socket packet:",e)}}),e.on("close",()=>{if(t&&s){let e=m.getInstance().getSession(t);e&&e.offOutput(s)}console.log("[WebSocketServer] Client connection closed.")}),e.on("error",e=>{console.error("[WebSocketServer] Socket error:",e)})}),console.log(`[WebSocketServer] WebSocket gateway successfully listening on port ${t}.`)}catch(t){let e=t instanceof Error?t.message:"Unknown error";console.error(`[WebSocketServer] Failed to initialize WebSocket Server: ${e}`)}}(3001)),m.instance}generateId(){return t.default.randomUUID()}async createSession(e,t,s,r){let i,a=this.generateId();return(i="mock"===e?new n(a,t):"claude-docker"===e?new l(a,t):"claude-ssh"===e?new c(a,t):"aider"===e||"aider-docker"===e?new d(a,e,t):new h(a,t)).workspaceRoot=s,i.scopedDirs=r,await i.start(),this.sessions.set(a,i),o.saveSession(i),i}getSession(e){return this.sessions.get(e)}listSessions(){return Array.from(this.sessions.values()).map(e=>e.getStatus())}async stopSession(e){let t=this.sessions.get(e);return!!t&&(await t.stop(),o.saveSession(t),!0)}async deleteSession(e){let t=this.sessions.get(e);return t&&await t.stop(),o.deleteSession(e),this.sessions.delete(e)}async injectCommand(e,t){let s=this.sessions.get(e);if(!s||"running"!==s.status)return!1;let r=s.workspaceRoot||process.cwd();("/ccc"===t||"/ccp"===t)&&f.ContextManager.compileSessionContext(r,s.scopedDirs);let i=t;return("aider"===s.type||"aider-docker"===s.type)&&("/ccc"===t?i="/read .ai/neural-loom/ccontext.md":"/ccp"===t&&(i="/read .ai/neural-loom/cprompt.md")),await s.sendInput("\x15"+i+"\r",!0),!0}}}];
|
|
27
27
|
|
|
28
28
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0d0pykb._.js.map
|