@yukino.js/yukino 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -64
- package/dist/acp-U7GA5YRP.js +14 -0
- package/dist/anthropic-3TRLGKHZ.js +4 -0
- package/dist/{bwrap-MLSZLWHD.js → bwrap-BZ7Q2A5B.js} +1 -1
- package/dist/chunk-3OULXPVI.js +5 -0
- package/dist/chunk-E7FXB7TA.js +61 -0
- package/dist/{chunk-GYBJR2RB.js → chunk-IW5L5276.js} +2 -2
- package/dist/chunk-KILUTRHM.js +4 -0
- package/dist/chunk-ME5UYXP4.js +1031 -0
- package/dist/chunk-NAQRFHUX.js +4 -0
- package/dist/chunk-P6DHMU7R.js +4 -0
- package/dist/{chunk-JNCMSXQZ.js → chunk-SYLHBECV.js} +2 -2
- package/dist/chunk-TPWRDFEX.js +4 -0
- package/dist/chunk-VM4YKTHC.js +10 -0
- package/dist/chunk-WVT2D5AR.js +4 -0
- package/dist/chunk-XFVM5ZZL.js +241 -0
- package/dist/{devtools-YWVUN4HX.js → devtools-UVGRIXO2.js} +1 -1
- package/dist/esm-5V3TYPZK.js +229 -0
- package/dist/lib/{anthropic-MSGL4VBM.js → anthropic-GAD2PGEN.js} +2 -5
- package/dist/lib/{bwrap-2OL7VPSO.js → bwrap-STOJ4TEH.js} +1 -1
- package/dist/lib/chunk-3ONNRNKQ.js +1335 -0
- package/dist/lib/{chunk-FLKB4BK7.js → chunk-6NYUYSER.js} +16 -4
- package/dist/lib/{chunk-P3HXGEQQ.js → chunk-CBBSDV2D.js} +1 -1
- package/dist/lib/{chunk-ENTAZT2J.js → chunk-D3SXNTPZ.js} +449 -60
- package/dist/lib/{chunk-YIWNQ7OA.js → chunk-MGPT7DWP.js} +1 -0
- package/dist/lib/{chunk-24L3QT3J.js → chunk-OYQY3Q45.js} +68 -27
- package/dist/lib/{chunk-E6VFL5IO.js → chunk-RVSLQCZ5.js} +101 -59
- package/dist/lib/index.d.ts +3390 -2240
- package/dist/lib/index.js +19719 -13372
- package/dist/lib/{openai-DL5VBJR4.js → openai-BYOGAZU5.js} +2 -3
- package/dist/lib/{providers-SMRZVJ7O.js → providers-YHVXG3PP.js} +1 -1
- package/dist/lib/{seatbelt-WO7YWKLR.js → seatbelt-VE3I3EGH.js} +1 -1
- package/dist/lib/{tool-filter-PY6XY254.js → tool-filter-HUVHJN3O.js} +3 -3
- package/dist/main.js +203 -194
- package/dist/{openai-AQNX24XU.js → openai-PYPO6SKD.js} +15 -15
- package/dist/{providers-FZUDVU4M.js → providers-6UOA2HYN.js} +1 -1
- package/dist/{seatbelt-JOCANLYS.js → seatbelt-3YN3GMQO.js} +1 -1
- package/dist/server-NXQ6REG3.js +4 -0
- package/dist/tool-filter-XZ7I6KU7.js +4 -0
- package/package.json +69 -32
- package/dist/acp-JCR6GVC3.js +0 -14
- package/dist/agent-56R4TACG.js +0 -4
- package/dist/anthropic-CEUDAJL2.js +0 -4
- package/dist/chunk-6DXHDARX.js +0 -607
- package/dist/chunk-77W2UPS2.js +0 -4
- package/dist/chunk-7DLUKIPE.js +0 -5
- package/dist/chunk-HLE7243Q.js +0 -4
- package/dist/chunk-K4BYVVW7.js +0 -5
- package/dist/chunk-L2BWSPCF.js +0 -10
- package/dist/chunk-OFC2GD5K.js +0 -4
- package/dist/chunk-RCXKUD3Y.js +0 -4
- package/dist/chunk-SAJCBGHL.js +0 -4
- package/dist/chunk-U2CS2E2F.js +0 -237
- package/dist/chunk-UPNNYP7M.js +0 -60
- package/dist/chunk-XO7ITAWR.js +0 -4
- package/dist/chunk-ZETIYALB.js +0 -164
- package/dist/esm-NCEEJIH3.js +0 -229
- package/dist/lib/agent-INEHZXP3.js +0 -16
- package/dist/lib/chunk-6AKRDUQF.js +0 -259
- package/dist/lib/chunk-7SU77J32.js +0 -599
- package/dist/lib/chunk-BMODZ6SU.js +0 -673
- package/dist/lib/chunk-DF3ITW4K.js +0 -3470
- package/dist/lib/chunk-F2YJG72O.js +0 -150
- package/dist/lib/chunk-MDX24JQ5.js +0 -619
- package/dist/lib/permissions-Q4FBU5VD.js +0 -19
- package/dist/permissions-VCDMNX3L.js +0 -4
- package/dist/server-VLJWUETV.js +0 -4
- package/dist/tool-filter-BQZDV3TF.js +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
+
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
+
import{B as P,a as d,d as u,f as C,g as S,i as g,u as v}from"./chunk-E7FXB7TA.js";import{D as o}from"./chunk-IW5L5276.js";import{existsSync as E,readFileSync as $}from"fs";import{join as Y}from"path";var m=P({module:"config"}),A={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY","openai-compat":"OPENAI_API_KEY"};function J(r){return b.has(r)}var b=new Set(Object.keys(A)),a=class extends Error{constructor(n){super(n),this.name="ConfigError"}};function X(r){if(r.api_key)return r.api_key;let n=J(r.protocol)?A[r.protocol]:"";return n?process.env[n]??"":""}var j=o.object({name:o.string(),command:o.string().optional(),args:o.array(o.string()).optional(),url:o.string().optional(),transport:o.string().optional(),headers:o.record(o.string(),o.string()).optional(),env:o.record(o.string(),o.string()).optional()}),I=o.object({id:o.string().optional(),event:o.string(),condition:o.string().optional(),action:o.object({type:o.string(),command:o.string().optional(),url:o.string().optional(),method:o.string().optional(),prompt:o.string().optional()}),reject:o.boolean().optional(),once:o.boolean().optional(),async:o.boolean().optional(),on_error:o.string().optional()}),O=o.object({enabled:o.boolean().optional(),backend:o.enum(["native","sandbox-runtime"]).optional(),auto_allow:o.boolean().optional(),network_enabled:o.boolean().optional()}),K=o.looseObject({default_provider:o.number().default(0),providers:o.array(g),permission_mode:o.string().optional(),mcp_servers:o.array(j).default([]),hooks:o.array(I).default([]),sandbox:O.optional(),enable_coordinator_mode:o.boolean().optional(),enable_fork:o.boolean().optional(),memory:o.boolean().optional()});function Z(r){return r.enable_fork!==!1}function oo(r){return r.memory!==!1}function N(r){return typeof r=="object"&&r!==null}function k(r){let n=$(r,"utf-8"),e=C.load(n);if(!N(e))return m.error({path:r},"invalid yaml"),{default_provider:0,providers:[],mcp_servers:[],hooks:[]};let t=d(K,e);if(t.success){let s=t.data;return{...s,providers:s.providers.map(v)}}m.error({error:t.error},"config error");let i=0,p=[],c,l=[],f=[],_,h=!1,y=!0,w=!0;if("default_provider"in e){let s=d(o.number(),e.default_provider);s.success&&(i=s.data)}if("providers"in e){let s=d(o.array(g),e.providers);if(s.success)p=s.data.map(v);else throw new a(`Invalid provider configuration in ${r}: ${u(s.error)}`)}if("permission_mode"in e&&typeof e.permission_mode=="string"&&(c=e.permission_mode),"mcp_servers"in e){let s=d(o.array(j),e.mcp_servers);if(s.success)l=s.data;else throw new a(`Invalid MCP server configuration in ${r}: ${u(s.error)}`)}if("hooks"in e){let s=d(o.array(I),e.hooks);if(s.success)f=s.data;else throw new a(`Invalid hooks configuration in ${r}: ${u(s.error)}`)}if("sandbox"in e){let s=d(O,e.sandbox);if(s.success)_=s.data;else throw new a(`Invalid sandbox configuration in ${r}: ${u(s.error)}`)}return"enable_coordinator_mode"in e&&(h=!!e.enable_coordinator_mode),"enable_fork"in e&&(y=!!e.enable_fork),"memory"in e&&(w=!!e.memory),{default_provider:i,providers:p,permission_mode:c,mcp_servers:l,hooks:f,sandbox:_,enable_coordinator_mode:h,enable_fork:y,memory:w}}function M(r){if(r.providers.length===0)throw new a("At least one provider MUST be configured.");let n=["name","protocol","base_url","model"],e=new Map;for(let t=0;t<r.providers.length;t++){let i=r.providers[t],p={name:i.name,protocol:i.protocol,base_url:i.base_url,model:i.model},c=n.filter(f=>!p[f].trim());if(c.length>0)throw new a(`Provider #${String(t+1)}: missing fields: ${c.join(", ")}`);if(!b.has(i.protocol))throw new a(`Provider #${String(t+1)}: invalid protocol '${i.protocol}', MUST be one of: ${Array.from(b).join(", ")}`);let l=e.get(i.base_url);if(l!==void 0)throw new a(`Provider #${String(t+1)}: duplicate base_url '${i.base_url}' (already used by provider #${String(l+1)}).`);e.set(i.base_url,t)}}function x(r){let n=new Map;for(let e=0;e<r.mcp_servers.length;e++){let t=r.mcp_servers[e],i=`MCP server #${String(e+1)}`;if(!t.name.trim())throw new a(`${i}: name must not be empty.`);let p=n.get(t.name);if(p!==void 0)throw new a(`${i}: duplicate name '${t.name}' (already used by MCP server #${String(p+1)}).`);n.set(t.name,e);let c=!!t.command?.trim(),l=!!t.url?.trim();if(c===l)throw new a(`${i} '${t.name}': configure exactly one of command or url.`);if(c&&t.transport&&t.transport!=="stdio")throw new a(`${i} '${t.name}': command servers must use stdio.`);if(l&&t.transport&&!["http","sse"].includes(t.transport))throw new a(`${i} '${t.name}': URL transport must be http or sse.`)}}var F=".mcp.json",z=o.looseObject({command:o.string().optional(),args:o.array(o.string()).optional(),env:o.record(o.string(),o.string()).optional(),type:o.enum(["stdio","sse","http"]).optional(),url:o.string().optional(),headers:o.record(o.string(),o.string()).optional()}),L=o.looseObject({mcpServers:o.record(o.string(),o.unknown()).default({})});function R(r,n){let e=n.type??(n.command!==void 0?"stdio":"http");return e==="stdio"?!n.command||n.url!==void 0?null:{name:r,command:n.command,args:n.args,env:n.env}:!n.url||n.command!==void 0?null:{name:r,url:n.url,transport:e,headers:n.headers}}function T(r){let n=Y(r,F);if(!E(n))return[];let e;try{e=JSON.parse($(n,"utf-8"))}catch(p){return m.error({err:p,path:n},"invalid .mcp.json"),[]}let t=d(L,e);if(!t.success)return m.error({error:t.error,path:n},"invalid .mcp.json"),[];let i=[];for(let[p,c]of Object.entries(t.data.mcpServers)){let l=d(z,c);if(!p.trim()||!l.success){m.warn({name:p,path:n,error:l.success?void 0:l.error},"skipping invalid .mcp.json server entry");continue}let f=R(p,l.data);f?i.push(f):m.warn({name:p,path:n},"skipping invalid .mcp.json server entry")}return i}function eo(r,n){let e=T(n);if(e.length===0)return r;let t=new Set(r.mcp_servers.map(i=>i.name));return{...r,mcp_servers:[...r.mcp_servers,...e.filter(i=>!t.has(i.name))]}}function ro(r,n={}){if(r){let i=k(r);return x(i),(!n.allowEmptyProviders||i.providers.length>0)&&M(i),i}let e=S();if(!E(e)){if(n.allowEmptyProviders)return{default_provider:0,providers:[],mcp_servers:[],hooks:[]};throw new a(`No config file found, expected ${e}.`)}let t=k(e);return x(t),(!n.allowEmptyProviders||t.providers.length>0)&&M(t),t}export{X as a,Z as b,oo as c,eo as d,ro as e};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
+
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
+
import{a as p,c as S,e as N}from"./chunk-7MKA3SHV.js";var T=S((Es,Ve)=>{"use strict";var $e=["nodebuffer","arraybuffer","fragments"],je=typeof Blob<"u";je&&$e.push("blob");Ve.exports={BINARY_TYPES:$e,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:je,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var X=S((vs,se)=>{"use strict";var{EMPTY_BUFFER:Yt}=T(),xe=Buffer[Symbol.species];function Kt(t,e){if(t.length===0)return Yt;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let i=0;i<t.length;i++){let n=t[i];r.set(n,s),s+=n.length}return s<e?new xe(r.buffer,r.byteOffset,s):r}function ze(t,e,r,s,i){for(let n=0;n<i;n++)r[s+n]=t[n]^e[n&3]}function He(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Xt(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Se(t){if(Se.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xe(t):ArrayBuffer.isView(t)?e=new xe(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Se.readOnly=!1),e}se.exports={concat:Kt,mask:ze,toArrayBuffer:Xt,toBuffer:Se,unmask:He};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=p("bufferutil");se.exports.mask=function(e,r,s,i,n){n<48?ze(e,r,s,i,n):t.mask(e,r,s,i,n)},se.exports.unmask=function(e,r){e.length<32?He(e,r):t.unmask(e,r)}}catch{}});var Xe=S((bs,Ke)=>{"use strict";var Ye=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Ye]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ye])}}};Ke.exports=ve});var G=S((ws,et)=>{"use strict";var Z=p("zlib"),Ze=X(),Zt=Xe(),{kStatusCode:Qe}=T(),Qt=Buffer[Symbol.species],Jt=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),P=Symbol("buffers"),q=Symbol("error"),ie,be=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ie){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new Zt(r)}}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:this._options.clientMaxWindowBits==null&&(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[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?r.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let i=r[s];if(i.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(i=i[0],s==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else if(s==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=i})}),e}decompress(e,r,s){ie.add(i=>{this._decompress(e,r,(n,o)=>{i(),s(n,o)})})}compress(e,r,s){ie.add(i=>{this._compress(e,r,(n,o)=>{i(),s(n,o)})})}_decompress(e,r,s){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Z.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[P]=[],this._inflate.on("error",tr),this._inflate.on("data",Je)}this._inflate[W]=s,this._inflate.write(e),r&&this._inflate.write(Jt),this._inflate.flush(()=>{let n=this._inflate[q];if(n){this._inflate.close(),this._inflate=null,s(n);return}let o=Ze.concat(this._inflate[P],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[P]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),s(null,o)})}_compress(e,r,s){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Z.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[P]=[],this._deflate.on("data",er)}this._deflate[W]=s,this._deflate.write(e),this._deflate.flush(Z.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Ze.concat(this._deflate[P],this._deflate[k]);r&&(n=new Qt(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[P]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),s(null,n)})}};et.exports=be;function er(t){this[P].push(t),this[k]+=t.length}function Je(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[P].push(t);return}this[q]=new RangeError("Max payload size exceeded"),this[q].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[q][Qe]=1009,this.removeListener("data",Je),this.reset()}function tr(t){if(this[ne]._inflate=null,this[q]){this[W](this[q]);return}t[Qe]=1007,this[W](t)}});var $=S((Os,oe)=>{"use strict";var{isUtf8:tt}=p("buffer"),{hasBlob:rr}=T(),sr=[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];function ir(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function nr(t){return rr&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:nr,isValidStatusCode:ir,isValidUTF8:we,tokenChars:sr};if(tt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):tt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=p("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=S((Ts,ft)=>{"use strict";var{Writable:or}=p("stream"),rt=G(),{BINARY_TYPES:ar,EMPTY_BUFFER:st,kStatusCode:fr,kWebSocket:lr}=T(),{concat:Oe,toArrayBuffer:hr,unmask:cr}=X(),{isValidStatusCode:ur,isValidUTF8:it}=$(),ae=Buffer[Symbol.species],v=0,nt=1,ot=2,at=3,Te=4,ke=5,fe=6,Ce=class extends or{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||ar[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[lr]=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._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,r,s){if(this._opcode===8&&this._state==v)return s();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){s(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}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 s=this._buffers[0];return this._buffers[0]=new ae(s.buffer,s.byteOffset+e,s.length-e),new ae(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],i=r.length-e;e>=s.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),i),this._buffers[0]=new ae(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case nt:this.getPayloadLength16(e);break;case ot:this.getPayloadLength64(e);break;case at:this.getMask();break;case Te:this.getData(e);break;case ke:case fe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let s=(r[0]&64)===64;if(s&&!this._extensions[rt.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=nt:this._payloadLength===127?this._state=ot: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 r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=at:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let r=st;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&cr(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let s=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(s);return}if(this._compressed){this._state=ke,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[rt.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return r(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}this._fragments.push(n)}this.dataMessage(r),this._state===v&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=v;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(s,r):this._binaryType==="arraybuffer"?i=hr(Oe(s,r)):this._binaryType==="blob"?i=new Blob(s):i=s,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(s,r);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,st),this.end();else{let s=e.readUInt16BE(0);if(!ur(s)){let n=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(n);return}this._loop=!1,this.emit("conclude",s,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=fe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(r)}))}createError(e,r,s,i,n){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=n,o[fr]=i,o}};ft.exports=Ce});var Be=S((Cs,ct)=>{"use strict";var{Duplex:ks}=p("stream"),{randomFillSync:dr}=p("crypto"),{types:{isUint8Array:_r}}=p("util"),lt=G(),{EMPTY_BUFFER:mr,kWebSocket:pr,NOOP:gr}=T(),{isBlob:j,isValidStatusCode:yr}=$(),{mask:ht,toBuffer:R}=X(),b=Symbol("kByteLength"),xr=Buffer.alloc(4),le=8*1024,U,V=le,w=0,Sr=1,Er=2,Ne=class t{constructor(e,r,s){this._extensions=r||{},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=w,this.onerror=gr,this[pr]=void 0}static frame(e,r){let s,i=!1,n=2,o=!1;r.mask&&(s=r.maskBuffer||xr,r.generateMask?r.generateMask(s):(V===le&&(U===void 0&&(U=Buffer.alloc(le)),dr(U,0,le),V=0),s[0]=U[V++],s[1]=U[V++],s[2]=U[V++],s[3]=U[V++]),o=(s[0]|s[1]|s[2]|s[3])===0,n=6);let f;typeof e=="string"?(!r.mask||o)&&r[b]!==void 0?f=r[b]:(e=Buffer.from(e),f=e.length):(f=e.length,i=r.mask&&r.readOnly&&!o);let l=f;f>=65536?(n+=8,l=127):f>125&&(n+=2,l=126);let a=Buffer.allocUnsafe(i?f+n:n);return a[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(a[0]|=64),a[1]=l,l===126?a.writeUInt16BE(f,2):l===127&&(a[2]=a[3]=0,a.writeUIntBE(f,4,6)),r.mask?(a[1]|=128,a[n-4]=s[0],a[n-3]=s[1],a[n-2]=s[2],a[n-1]=s[3],o?[a,e]:i?(ht(e,s,a,n,f),[a]):(ht(e,s,e,0,f),[a,e])):[a,e]}close(e,r,s,i){let n;if(e===void 0)n=mr;else{if(typeof e!="number"||!yr(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let f=Buffer.byteLength(r);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+f),n.writeUInt16BE(e,0),typeof r=="string")n.write(r,2);else if(_r(r))n.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==w?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}pong(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==w?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}send(e,r,s){let i=this._extensions[lt.extensionName],n=r.binary?2:1,o=r.compress,f,l;typeof e=="string"?(f=Buffer.byteLength(e),l=!1):j(e)?(f=e.size,l=!1):(e=R(e),f=e.length,l=R.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=f>=i._threshold),this._compress=o):(o=!1,n=0),r.fin&&(this._firstFragment=!0);let a={[b]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,a,s]):this.getBlobData(e,this._compress,a,s):this._state!==w?this.enqueue([this.dispatch,e,this._compress,a,s]):this.dispatch(e,this._compress,a,s)}getBlobData(e,r,s,i){this._bufferedBytes+=s[b],this._state=Er,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,f,i);return}this._bufferedBytes-=s[b];let o=R(n);r?this.dispatch(o,r,s,i):(this._state=w,this.sendFrame(t.frame(o,s),i),this.dequeue())}).catch(n=>{process.nextTick(vr,this,n,i)})}dispatch(e,r,s,i){if(!r){this.sendFrame(t.frame(e,s),i);return}let n=this._extensions[lt.extensionName];this._bufferedBytes+=s[b],this._state=Sr,n.compress(e,s.fin,(o,f)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Pe(this,l,i);return}this._bufferedBytes-=s[b],this._state=w,s.readOnly=!1,this.sendFrame(t.frame(f,s),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};ct.exports=Ne;function Pe(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let i=t._queue[s],n=i[i.length-1];typeof n=="function"&&n(e)}}function vr(t,e,r){Pe(t,e,r),t.onerror(e)}});var St=S((Ls,xt)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),ut=Symbol("kCode"),dt=Symbol("kData"),_t=Symbol("kError"),mt=Symbol("kMessage"),pt=Symbol("kReason"),z=Symbol("kTarget"),gt=Symbol("kType"),yt=Symbol("kWasClean"),C=class{constructor(e){this[z]=null,this[gt]=e}get target(){return this[z]}get type(){return this[gt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,r={}){super(e),this[ut]=r.code===void 0?0:r.code,this[pt]=r.reason===void 0?"":r.reason,this[yt]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[ut]}get reason(){return this[pt]}get wasClean(){return this[yt]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var H=class extends C{constructor(e,r={}){super(e),this[_t]=r.error===void 0?null:r.error,this[mt]=r.message===void 0?"":r.message}get error(){return this[_t]}get message(){return this[mt]}};Object.defineProperty(H.prototype,"error",{enumerable:!0});Object.defineProperty(H.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,r={}){super(e),this[dt]=r.data===void 0?null:r.data}get data(){return this[dt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var br={addEventListener(t,e,r={}){for(let i of this.listeners(t))if(!r[Q]&&i[Re]===e&&!i[Q])return;let s;if(t==="message")s=function(n,o){let f=new J("message",{data:o?n:n.toString()});f[z]=this,he(e,this,f)};else if(t==="close")s=function(n,o){let f=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[z]=this,he(e,this,f)};else if(t==="error")s=function(n){let o=new H("error",{error:n,message:n.message});o[z]=this,he(e,this,o)};else if(t==="open")s=function(){let n=new C("open");n[z]=this,he(e,this,n)};else return;s[Q]=!!r[Q],s[Re]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Re]===e&&!r[Q]){this.removeListener(t,r);break}}};xt.exports={CloseEvent:I,ErrorEvent:H,Event:C,EventTarget:br,MessageEvent:J};function he(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ce=S((Ns,Et)=>{"use strict";var{tokenChars:ee}=$();function O(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function wr(t){let e=Object.create(null),r=Object.create(null),s=!1,i=!1,n=!1,o,f,l=-1,a=-1,h=-1,c=0;for(;c<t.length;c++)if(a=t.charCodeAt(c),o===void 0)if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(c!==0&&(a===32||a===9))h===-1&&l!==-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);a===44?(O(e,g,r),r=Object.create(null)):o=g,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===void 0)if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(a===32||a===9)h===-1&&l!==-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(r,t.slice(l,h),!0),a===44&&(O(e,o,r),r=Object.create(null),o=void 0),l=h=-1}else if(a===61&&l!==-1&&h===-1)f=t.slice(l,c),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[a]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:s||(s=!0),i=!1}else if(n)if(ee[a]===1)l===-1&&(l=c);else if(a===34&&l!==-1)n=!1,h=c;else if(a===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(l!==-1&&(a===32||a===9))h===-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);s&&(g=g.replace(/\\/g,""),s=!1),O(r,f,g),a===44&&(O(e,o,r),r=Object.create(null),o=void 0),f=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(l===-1||n||a===32||a===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(l,h);return o===void 0?O(e,_,r):(f===void 0?O(r,_,!0):s?O(r,f,_.replace(/\\/g,"")):O(r,f,_),O(e,o,r)),e}function Or(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(i=>{let n=s[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Et.exports={format:Or,parse:wr}});var me=S((Rs,Rt)=>{"use strict";var Tr=p("events"),kr=p("https"),Cr=p("http"),wt=p("net"),Lr=p("tls"),{randomBytes:Nr,createHash:Pr}=p("crypto"),{Duplex:Ps,Readable:Bs}=p("stream"),{URL:Ue}=p("url"),B=G(),Br=Le(),Rr=Be(),{isBlob:Ur}=$(),{BINARY_TYPES:vt,CLOSE_TIMEOUT:Ir,EMPTY_BUFFER:ue,GUID:Dr,kForOnEventAttribute:Ie,kListener:Mr,kStatusCode:Ar,kWebSocket:y,NOOP:Ot}=T(),{EventTarget:{addEventListener:Fr,removeEventListener:Wr}}=St(),{format:qr,parse:Gr}=ce(),{toBuffer:$r}=X(),Tt=Symbol("kAborted"),De=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],jr=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Tr{constructor(e,r,s){super(),this._binaryType=vt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ue,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?!s||s.protocols===void 0?r=[]:Array.isArray(s.protocols)?r=s.protocols:r=[s.protocols]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,s.protocols===void 0?r=[]:Array.isArray(s.protocols)?r=s.protocols:r=[s.protocols]):r=[r]),kt(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){vt.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,r,s){let i=new Br({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),n=new Rr(e,this._extensions,s.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Hr),i.on("drain",Yr),i.on("error",Kr),i.on("message",Xr),i.on("ping",Zr),i.on("pong",Qr),n.onerror=Jr,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Nt),e.on("data",_e),e.on("end",Pt),e.on("error",Bt),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[B.extensionName]&&this._extensions[B.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,Lt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||ue,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||ue,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,s);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[B.extensionName]||(i.compress=!1),this._sender.send(e||ue,i,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ie])return e[Mr];return null},set(e){for(let r of this.listeners(t))if(r[Ie]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Ie]:!0})}})});d.prototype.addEventListener=Fr;d.prototype.removeEventListener=Wr;Rt.exports=d;function kt(t,e,r,s){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Ir,protocolVersion:De[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!De.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${De.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",f=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!f?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let u=new SyntaxError(l);if(t._redirects===0)throw u;de(t,u);return}let a=o?443:80,h=Nr(16).toString("base64"),c=o?kr.request:Cr.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?zr:Vr),i.defaultPort=i.defaultPort||a,i.port=n.port||a,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new B({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=qr({[B.extensionName]:g.offer()})),r.length){for(let u of r){if(typeof u!="string"||!jr.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),f){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let m;if(i.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=o,t._originalHostOrSocketPath=f?i.socketPath:n.host;let u=s&&s.headers;if(s={...s,headers:{}},u)for(let[x,A]of Object.entries(u))s.headers[x.toLowerCase()]=A}else if(t.listenerCount("redirect")===0){let u=f?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=t._req=c(i),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=c(i);i.timeout&&m.on("timeout",()=>{E(t,m,"Opening handshake has timed out")}),m.on("error",u=>{m===null||m[Tt]||(m=t._req=null,de(t,u))}),m.on("response",u=>{let x=u.headers.location,A=u.statusCode;if(x&&i.followRedirects&&A>=300&&A<400){if(++t._redirects>i.maxRedirects){E(t,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new Ue(x,e)}catch{let F=new SyntaxError(`Invalid URL: ${x}`);de(t,F);return}kt(t,Y,r,s)}else t.emit("unexpected-response",m,u)||E(t,m,`Unexpected server response: ${u.statusCode}`)}),m.on("upgrade",(u,x,A)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;m=t._req=null;let Y=u.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){E(t,x,"Invalid Upgrade header");return}let We=Pr("sha1").update(h+Dr).digest("base64");if(u.headers["sec-websocket-accept"]!==We){E(t,x,"Invalid Sec-WebSocket-Accept header");return}let F=u.headers["sec-websocket-protocol"],K;if(F!==void 0?_.size?_.has(F)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){E(t,x,K);return}F&&(t._protocol=F);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=Gr(qe)}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==B.extensionName){E(t,x,"Server indicated an extension that was not requested");return}try{g.accept(ge[B.extensionName])}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[B.extensionName]=g}t.setSocket(x,A,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,t):m.end()}function de(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Vr(t){return t.path=t.socketPath,wt.connect(t)}function zr(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=wt.isIP(t.host)?"":t.host),Lr.connect(t)}function E(t,e,r){t._readyState=d.CLOSING;let s=new Error(r);Error.captureStackTrace(s,E),e.setHeader?(e[Tt]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(de,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Me(t,e,r){if(e){let s=Ur(e)?e.size:$r(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(r,s)}}function Hr(t,e){let r=this[y];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[y]!==void 0&&(r._socket.removeListener("data",_e),process.nextTick(Ct,r._socket),t===1005?r.close():r.close(t,e))}function Yr(){let t=this[y];t.isPaused||t._socket.resume()}function Kr(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",_e),process.nextTick(Ct,e._socket),e.close(t[Ar])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function bt(){this[y].emitClose()}function Xr(t,e){this[y].emit("message",t,e)}function Zr(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,Ot),e.emit("ping",t)}function Qr(t){this[y].emit("pong",t)}function Ct(t){t.resume()}function Jr(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Lt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Lt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Nt(){let t=this[y];if(this.removeListener("close",Nt),this.removeListener("data",_e),this.removeListener("end",Pt),t._readyState=d.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",bt),t._receiver.on("finish",bt))}function _e(t){this[y]._receiver.write(t)||this.pause()}function Pt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Bt(){let t=this[y];this.removeListener("error",Bt),this.on("error",Ot),t&&(t._readyState=d.CLOSING,this.destroy())}});var Mt=S((Is,Dt)=>{"use strict";var Us=me(),{Duplex:es}=p("stream");function Ut(t){t.emit("close")}function ts(){!this.destroyed&&this._writableState.finished&&this.destroy()}function It(t){this.removeListener("error",It),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function rs(t,e){let r=!0,s=new es({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let f=!o&&s._readableState.objectMode?n.toString():n;s.push(f)||t.pause()}),t.once("error",function(n){s.destroyed||(r=!1,s.destroy(n))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(Ut,s);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(Ut,s)}),r&&t.terminate()},s._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(i,n,o)});return}t.send(i,o)},s.on("end",ts),s.on("error",It),s}Dt.exports=rs});var Ae=S((Ds,At)=>{"use strict";var{tokenChars:ss}=$();function is(t){let e=new Set,r=-1,s=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(s===-1&&ss[o]===1)r===-1&&(r=i);else if(i!==0&&(o===32||o===9))s===-1&&r!==-1&&(s=i);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${i}`);s===-1&&(s=i);let f=t.slice(r,s);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(r,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}At.exports={parse:is}});var Vt=S((As,jt)=>{"use strict";var ns=p("events"),pe=p("http"),{Duplex:Ms}=p("stream"),{createHash:os}=p("crypto"),Ft=ce(),D=G(),as=Ae(),fs=me(),{CLOSE_TIMEOUT:ls,GUID:hs,kWebSocket:cs}=T(),us=/^[+/0-9A-Za-z]{22}==$/,Wt=0,qt=1,$t=2,Fe=class extends ns{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:ls,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:fs,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((s,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=ds(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Wt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===$t){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==qt)if(this._state=qt,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(te,this):process.nextTick(te,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,i){r.on("error",Gt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){M(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){M(this,e,r,400,"Invalid Upgrade header");return}if(n===void 0||!us.test(n)){M(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){M(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){re(r,400);return}let l=e.headers["sec-websocket-protocol"],a=new Set;if(l!==void 0)try{a=as.parse(l)}catch{M(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new D({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let g=Ft.parse(h);g[D.extensionName]&&(_.accept(g[D.extensionName]),c[D.extensionName]=_)}catch{M(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,m,u,x)=>{if(!g)return re(r,m||401,u,x);this.completeUpgrade(c,n,a,e,r,s,i)});return}if(!this.options.verifyClient(_))return re(r,401)}this.completeUpgrade(c,n,a,e,r,s,i)}completeUpgrade(e,r,s,i,n,o,f){if(!n.readable||!n.writable)return n.destroy();if(n[cs])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Wt)return re(n,503);let a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${os("sha1").update(r+hs).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(s.size){let c=this.options.handleProtocols?this.options.handleProtocols(s,i):s.values().next().value;c&&(a.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[D.extensionName]){let c=e[D.extensionName].params,_=Ft.format({[D.extensionName]:[c]});a.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",a,i),n.write(a.concat(`\r
|
|
5
|
+
`).join(`\r
|
|
6
|
+
`)),n.removeListener("error",Gt),h.setSocket(n,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(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(te,this)})),f(h,i)}};jt.exports=Fe;function ds(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function te(t){t._state=$t,t.emit("close")}function Gt(){this.destroy()}function re(t,e,r,s){r=r||pe.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${pe.STATUS_CODES[e]}\r
|
|
7
|
+
`+Object.keys(s).map(i=>`${i}: ${s[i]}`).join(`\r
|
|
8
|
+
`)+`\r
|
|
9
|
+
\r
|
|
10
|
+
`+r)}function M(t,e,r,s,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,M),t.emit("wsClientError",o,r,e)}else re(r,s,i,n)}});var _s=N(Mt(),1),ms=N(ce(),1),ps=N(G(),1),gs=N(Le(),1),ys=N(Be(),1),xs=N(Ae(),1),zt=N(me(),1),Ss=N(Vt(),1);var Fs=zt.default;export{zt as a,Ss as b,Fs as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
+
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
+
import{B as x,M as f,O as k,T as u}from"./chunk-E7FXB7TA.js";function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var _=new Set(["image/jpeg","image/png","image/gif","image/webp"]);function b(e){return _.has(e)}function d(e){return g(e)&&e.type==="text"&&typeof e.text=="string"?{type:"text",text:e.text}:null}function C(e){return!g(e)||e.type!=="image"||!g(e.source)?null:e.source.type==="url"&&typeof e.source.url=="string"?{type:"image",source:{type:"url",url:e.source.url}}:e.source.type==="base64"&&typeof e.source.media_type=="string"&&b(e.source.media_type)&&typeof e.source.data=="string"?{type:"image",source:{type:"base64",media_type:e.source.media_type,data:e.source.data}}:null}function A(e){if(e.type!=="document"||!g(e.source))return null;let t=null;if(e.source.type==="url"&&typeof e.source.url=="string")t={type:"url",url:e.source.url};else if(e.source.type==="base64"&&e.source.media_type==="application/pdf"&&typeof e.source.data=="string")t={type:"base64",media_type:"application/pdf",data:e.source.data};else if(e.source.type==="text"&&e.source.media_type==="text/plain"&&typeof e.source.data=="string")t={type:"text",media_type:"text/plain",data:e.source.data};else if(e.source.type==="content"){if(typeof e.source.content=="string")t={type:"content",content:e.source.content};else if(Array.isArray(e.source.content)){let o=[];for(let r of e.source.content){let i=d(r)??C(r);if(!i)return null;o.push(i)}t={type:"content",content:o}}}return t?{type:"document",source:t,...typeof e.title=="string"||e.title===null?{title:e.title}:{},...typeof e.context=="string"||e.context===null?{context:e.context}:{}}:null}function q(e){let t=d(e);if(t)return t;let o=C(e);if(o)return o;if(!g(e))return null;if(e.type==="tool_reference"&&typeof e.tool_name=="string")return{type:"tool_reference",tool_name:e.tool_name};if(e.type==="search_result"&&typeof e.source=="string"&&typeof e.title=="string"&&Array.isArray(e.content)){let r=[];for(let i of e.content){let n=d(i);if(!n)return null;r.push(n)}return{type:"search_result",source:e.source,title:e.title,content:r}}return A(e)}var H=new Set([".agents",".git",".yukino",".next",".venv",".mypy_cache","__pycache__","dist","node_modules"]);var M=x({module:"mcp"}),l="mcp__",m="__";function a(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function P(e){return l+a(e)+m}function h(e,t){return P(e)+a(t)}var R=class{name;description;category="command";deferred=!0;mcpServerName;client;originalName;inputSchema;constructor(t,o,r){this.name=h(o,r.name),this.description=r.description,this.originalName=r.name,this.client=t,this.inputSchema=r.inputSchema,this.mcpServerName=o}mcpInputSchema(){return this.inputSchema??{}}setDeferLoading(t){this.deferred=t}schema(){return{name:this.name,description:this.description,input_schema:this.inputSchema}}async execute(t,o){try{return await this.client.callTool(this.originalName,o,t.abortSignal)}catch(r){return M.error({err:r},"mcp operation failed"),{output:`MCP tool error: ${k(r)}`,isError:!0}}}};function w(e,t){if(t==="string"&&typeof e=="number"&&Number.isFinite(e))return String(e);if((t==="integer"||t==="number")&&typeof e=="string"){let o=e.trim();if(o===""||!(t==="integer"?/^[+-]?\d+$/:/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/).test(o))return e;let i=t==="integer"?Number.parseInt(o,10):Number.parseFloat(o);return Number.isFinite(i)?i:e}if(t==="boolean"&&typeof e=="string"){let o=e.trim().toLowerCase();if(o==="true")return!0;if(o==="false")return!1}return e}function T(e,t){if(typeof t!="object"||t===null)return e;let o=f(t),r=u(o,"type","");if(r==="object"&&typeof e=="object"&&e!==null&&!Array.isArray(e)){let i=f(o.properties??{}),n={};for(let[s,c]of Object.entries(e))n[s]=s in i?T(c,i[s]):c;return n}if(r==="array"){let i=o.items??{},n=e;if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let s=Object.values(n);s.length===1&&Array.isArray(s[0])&&(n=s[0])}else typeof n=="string"&&(n=n.split(",").map(s=>s.trim()).filter(s=>s!==""));return Array.isArray(n)?n.map(s=>T(s,i)):n}return r!==""?w(e,r):e}function V(e,t){if(t.startsWith(l)){let o=t.slice(l.length),r=o.indexOf(m);if(r>=0)return a(o.slice(0,r))+m+a(o.slice(r+m.length))}return a(e)+m+a(t)}function y(e){return"mcpInputSchema"in e&&typeof e.mcpInputSchema=="function"}var S=class{constructor(t){this.registry=t}registry;name="McpCall";description="Invoke a tool on a connected MCP server. Call ToolSearch first to load the tool's schema, then pass its arguments here exactly as that schema requires, using the same JSON types.";category="command";deferred=!1;schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{server:{type:"string",description:"MCP server name, e.g. 'linear'."},tool:{type:"string",description:"Full tool name as returned by ToolSearch, e.g. 'mcp__linear__create_issue'."},arguments:{type:"object",description:"The target tool's arguments. Must match that tool's input_schema exactly, including JSON types: bare numbers for integer fields, bare true/false for boolean fields, quoted strings for string fields, and plain JSON arrays for array fields."}},required:["server","tool","arguments"]}}}resolveTarget(t){let o=u(t,"server"),r=u(t,"tool");if(!o||!r)return;let i=r.startsWith(l)?r:h(o,r),n=this.registry.get(i);return n&&y(n)&&a(n.mcpServerName)===a(o)?n:void 0}availableNames(){return this.registry.listTools().filter(t=>t.name.startsWith(l)).map(t=>t.name).sort()}async execute(t,o){let r=u(o,"server",""),i=u(o,"tool","");if(i==="")return{output:"McpCall requires a 'tool' name",isError:!0};let n=this.resolveTarget(o);if(!n){let c=this.availableNames(),p=c.length>0?c.join(", "):"(none connected)";return{output:`Unknown MCP tool '${i}' on server '${r}'. Available tools: ${p}`,isError:!0}}if(typeof o.arguments!="object"||o.arguments===null||Array.isArray(o.arguments))return{output:"McpCall requires an 'arguments' object matching the target schema",isError:!0};let s=f(o.arguments);if(y(n)){let c=n.mcpInputSchema();if(Object.keys(c).length>0){let p=T(s,c);typeof p=="object"&&p!==null&&!Array.isArray(p)&&(s=f(p))}}return t.abortSignal?.throwIfAborted(),n.execute(t,s)}};var I=10,E=2.5,Z="advanced-tool-use-2025-11-20",N=new Set(["api.anthropic.com"]),O="YUKINO_MCP_LOADING";function L(e){if(!e)return!0;try{return N.has(new URL(e).hostname.toLowerCase())}catch{return!1}}function j(e){return Math.floor(e/E)}function B(e,t,o,r,i=I){let n=(process.env[O]??"").trim().toLowerCase();if(n==="eager"||n==="native"||n==="dispatch")return n==="native"&&t!=="anthropic"?"dispatch":n;if(r<=0)return"eager";let s=o*i/100;return j(r)<s?"eager":t==="anthropic"&&L(e)?"native":"dispatch"}function D(e){let t=0;for(let o of e.listTools())if(o.name.startsWith(l))try{t+=JSON.stringify(o.schema()).length}catch{t+=o.name.length+(o.description?.length??0)}return t}function F(e,t){e.mcpLoadingMode=t;let o=t==="eager";for(let r of e.listTools())y(r)&&typeof r.setDeferLoading=="function"&&r.setDeferLoading(!o);e.exposeToolSearch=!o,e.exposeMcpCall=t==="dispatch"}function Q(e,t,o,r){let i=B(t,o,r,D(e));return F(e,i),i}export{q as a,H as b,l as c,R as d,V as e,S as f,Z as g,L as h,F as i,Q as j};
|