@maincode-ai/matilda-code 0.21.12 → 0.21.13
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/bundled/mainy/docs/configuration/model-providers.md +0 -82
- package/bundled/mainy/docs/configuration/settings.md +30 -2
- package/bundled/mainy/docs/features/auto-mode.md +1 -1
- package/bundled/mainy/docs/features/channels/_meta.ts +0 -3
- package/bundled/mainy/docs/features/channels/overview.md +8 -16
- package/bundled/mainy/docs/features/commands.md +4 -4
- package/bundled/mainy/docs/features/hooks.md +9 -7
- package/bundled/mainy/docs/features/language.md +2 -29
- package/bundled/mainy/docs/features/worktree.md +0 -2
- package/bundled/mainy/docs/integration-github-action.md +3 -3
- package/bundled/mainy/docs/quickstart.md +2 -2
- package/bundled/mainy/docs/support/troubleshooting.md +1 -1
- package/chunks/agent-SRAIVZEE.js +3 -0
- package/chunks/agent-headless-XRDOZESG.js +3 -0
- package/chunks/{anthropicContentGenerator-VKFTAIU3.js → anthropicContentGenerator-LLDIKDMQ.js} +3 -3
- package/chunks/{askUserQuestion-2QI4NSFJ.js → askUserQuestion-BNSWGD26.js} +1 -1
- package/chunks/{ca-I2HEEIL7.js → ca-NPYL24ME.js} +2 -2
- package/chunks/{chunk-YJAKOETP.js → chunk-27HUYW23.js} +2 -2
- package/chunks/{chunk-EQGA7LH7.js → chunk-3B2HABK7.js} +1 -1
- package/chunks/{chunk-CSJTA7NE.js → chunk-3MTZTNAU.js} +18 -18
- package/chunks/{chunk-YRQP3SLC.js → chunk-5OHGYMKP.js} +1 -1
- package/chunks/chunk-6I6VGTKD.js +8 -0
- package/chunks/{chunk-MCQUPLRE.js → chunk-6M5G5FBH.js} +1 -1
- package/chunks/chunk-7ZODGQO6.js +4 -0
- package/chunks/chunk-AOOZREGV.js +9 -0
- package/chunks/chunk-DHDD5YJC.js +207 -0
- package/chunks/{chunk-WV3IUPZS.js → chunk-EZDV7A76.js} +1 -1
- package/chunks/{chunk-QVCGLQCI.js → chunk-IJEGHQ7Z.js} +3 -3
- package/chunks/{chunk-5C2RJ5RR.js → chunk-LWARA7JY.js} +1 -1
- package/chunks/{chunk-VTGICC67.js → chunk-MEV5XQI2.js} +1 -1
- package/chunks/{chunk-DOOFGSRV.js → chunk-P5TG5CON.js} +1 -1
- package/chunks/{chunk-JRECUFB3.js → chunk-PEKAUGYV.js} +552 -561
- package/chunks/chunk-PGUG43HG.js +24 -0
- package/chunks/{chunk-CZGZ3KK7.js → chunk-QZI2ZGZY.js} +1 -1
- package/chunks/chunk-RI54U73U.js +56 -0
- package/chunks/chunk-RPFSFS7Z.js +39 -0
- package/chunks/chunk-SOEIVSM5.js +113 -0
- package/chunks/{chunk-4J6DC24J.js → chunk-SVSY6AWS.js} +1 -1
- package/chunks/{chunk-6E766NPX.js → chunk-TWJLOEAI.js} +1 -1
- package/chunks/{chunk-HYVP4472.js → chunk-V6UPUMP3.js} +1 -1
- package/chunks/chunk-W4QSMIWO.js +9 -0
- package/chunks/chunk-ZX34M2GF.js +14 -0
- package/chunks/{computer-use-WKDNUTLD.js → computer-use-J4GAM4M6.js} +1 -1
- package/chunks/contextCommand-5F5M7NA4.js +3 -0
- package/chunks/{cron-create-F2LXM2OA.js → cron-create-IDWSZENI.js} +1 -1
- package/chunks/{cron-delete-DE6Q2S2L.js → cron-delete-NQCDZDUI.js} +1 -1
- package/chunks/{cron-list-IAQEJVV7.js → cron-list-Z4XMC3TO.js} +1 -1
- package/chunks/{de-AQXFJYZI.js → de-34YZHGC6.js} +2 -2
- package/chunks/{devtools-5JRKK3E7.js → devtools-XRQ4YJ5S.js} +1 -1
- package/chunks/{dist-P6SLWL5V.js → dist-PH6JW7XD.js} +1 -1
- package/chunks/{edit-QQNJZ55P.js → edit-X2S2ZXRN.js} +1 -1
- package/chunks/{en-EJLDYIBM.js → en-QLGMD6OS.js} +3 -3
- package/chunks/{enter-worktree-5X5SAMBJ.js → enter-worktree-TUCGNCLO.js} +1 -1
- package/chunks/{enterPlanMode-HP35SPLN.js → enterPlanMode-SQEZAAIR.js} +1 -1
- package/chunks/{exit-worktree-SRKZBEYF.js → exit-worktree-7FLITFZI.js} +1 -1
- package/chunks/{exitPlanMode-WSPTGGVN.js → exitPlanMode-O5UUJ3GM.js} +1 -1
- package/chunks/{fr-6TDHK7F2.js → fr-EDNBQACJ.js} +3 -3
- package/chunks/geminiContentGenerator-FIZFLPU3.js +8 -0
- package/chunks/glob-GSFTYAS2.js +22 -0
- package/chunks/{goal-tools-C6BSBHCF.js → goal-tools-YQOA6OKU.js} +1 -1
- package/chunks/{grep-MVCOBUYW.js → grep-VAB2VSXM.js} +1 -1
- package/chunks/{ja-GGNJR7AR.js → ja-LV4RLM3M.js} +2 -2
- package/chunks/{ls-JYJXFSXN.js → ls-IZJ3CKZY.js} +1 -1
- package/chunks/{lsp-DYDK6XCS.js → lsp-NGLDRHZU.js} +1 -1
- package/chunks/matildaAgentContentGenerator-QQHPCFJ5.js +8 -0
- package/chunks/matildaContentGenerator-W7Z33ONU.js +8 -0
- package/chunks/mcp-client-DXUNIEIB.js +3 -0
- package/chunks/monitor-4PFIGAGG.js +32 -0
- package/chunks/notebook-edit-MWJYAATJ.js +17 -0
- package/chunks/{openaiContentGenerator-2EALAM3U.js → openaiContentGenerator-NDVJL6QL.js} +1 -1
- package/chunks/{pt-D6L2QTDM.js → pt-5SQ4DGL7.js} +2 -2
- package/chunks/read-file-WPZKPXWA.js +3 -0
- package/chunks/ripGrep-7LZDZFTX.js +3 -0
- package/chunks/{ru-BNJCHDYO.js → ru-7K24S53N.js} +2 -2
- package/chunks/scheduler-DK2MVKXX.js +8 -0
- package/chunks/{send-message-P3SMWNEE.js → send-message-TCPX5UDU.js} +1 -1
- package/chunks/{serve-FXH6EBQ6.js → serve-GSZPJI2O.js} +59 -48
- package/chunks/shell-PRS47PDP.js +3 -0
- package/chunks/{skill-HZPFEAPF.js → skill-ETQM5NI3.js} +1 -1
- package/chunks/src-UB7DZRYK.js +3 -0
- package/chunks/{symbol-search-EAIZPWN7.js → symbol-search-HARHZ5AH.js} +1 -1
- package/chunks/{syntheticOutput-432LXITX.js → syntheticOutput-WZDPECYS.js} +1 -1
- package/chunks/task-create-XRNIDT4T.js +3 -0
- package/chunks/{task-detach-XMSJ3HBM.js → task-detach-TBAVUOTC.js} +1 -1
- package/chunks/task-list-Z6BDZZID.js +9 -0
- package/chunks/{task-stop-NTS62FLG.js → task-stop-HDSARSJ6.js} +1 -1
- package/chunks/{task-update-AR26UFYZ.js → task-update-MW2VT2XV.js} +1 -1
- package/chunks/{team-create-PYXFVIR5.js → team-create-VMYNLZCC.js} +1 -1
- package/chunks/team-delete-F7QDC2TE.js +8 -0
- package/chunks/{todoWrite-5NZ7CHTC.js → todoWrite-SCF5M24M.js} +1 -1
- package/chunks/{tool-search-RKZDSRYS.js → tool-search-WX6FOE35.js} +1 -1
- package/chunks/{web-fetch-VW3SVDQ6.js → web-fetch-CKYBHGLF.js} +1 -1
- package/chunks/{web-search-XQUIZARL.js → web-search-67DFNS5V.js} +1 -1
- package/chunks/{workflow-YXNXDRWZ.js → workflow-WBSRQG3N.js} +2 -2
- package/chunks/write-file-S5FAX4JJ.js +15 -0
- package/cli.js +436 -439
- package/locales/ca.js +0 -3
- package/locales/de.js +0 -3
- package/locales/en.js +0 -3
- package/locales/fr.js +0 -3
- package/locales/ja.js +0 -3
- package/locales/pt.js +0 -3
- package/locales/ru.js +0 -3
- package/package.json +2 -2
- package/sandbox-macos-permissive-closed.sb +0 -1
- package/sandbox-macos-permissive-open.sb +0 -1
- package/sandbox-macos-permissive-proxied.sb +0 -1
- package/sandbox-macos-restrictive-closed.sb +0 -1
- package/sandbox-macos-restrictive-open.sb +0 -1
- package/sandbox-macos-restrictive-proxied.sb +0 -1
- package/bundled/mainy/docs/features/channels/dingtalk.md +0 -134
- package/bundled/mainy/docs/features/channels/feishu.md +0 -186
- package/bundled/mainy/docs/features/channels/weixin.md +0 -106
- package/chunks/agent-WM63A6NK.js +0 -3
- package/chunks/agent-headless-QIUBDKPW.js +0 -3
- package/chunks/chunk-2MOGYHWM.js +0 -8
- package/chunks/chunk-3IRGBRSP.js +0 -113
- package/chunks/chunk-6GBNB5Z2.js +0 -3
- package/chunks/chunk-6Z2MV7ZY.js +0 -186
- package/chunks/chunk-BVOCFLC4.js +0 -56
- package/chunks/chunk-FPO57O66.js +0 -39
- package/chunks/chunk-LJR4RZZ2.js +0 -3
- package/chunks/chunk-MO2HXJG5.js +0 -9
- package/chunks/chunk-PA6532AY.js +0 -6
- package/chunks/chunk-S3CWEVTS.js +0 -15
- package/chunks/chunk-U347OO7S.js +0 -9
- package/chunks/chunk-UIRBHC5X.js +0 -3
- package/chunks/chunk-WVY2P6WH.js +0 -26
- package/chunks/chunk-WZ75OGYY.js +0 -14
- package/chunks/chunk-XMZIY7XX.js +0 -13
- package/chunks/contextCommand-DAB3HOHY.js +0 -3
- package/chunks/dist-ME6647DQ.js +0 -195
- package/chunks/dist-VG3ZDJ2A.js +0 -28
- package/chunks/dist-YTCHM57U.js +0 -23
- package/chunks/geminiContentGenerator-RJ73DQAP.js +0 -8
- package/chunks/glob-QQ6LGKDX.js +0 -22
- package/chunks/matildaAgentContentGenerator-YUYS4336.js +0 -8
- package/chunks/matildaContentGenerator-O4Z2QPCP.js +0 -8
- package/chunks/mcp-client-RXVQU5VI.js +0 -3
- package/chunks/monitor-77KXDXPR.js +0 -32
- package/chunks/notebook-edit-TKJD2EQZ.js +0 -17
- package/chunks/read-file-3KUAH6ND.js +0 -3
- package/chunks/ripGrep-U2PLKXMY.js +0 -3
- package/chunks/scheduler-J7VU2V5Y.js +0 -8
- package/chunks/shell-PXR2AXDD.js +0 -3
- package/chunks/src-RFAEPLY7.js +0 -3
- package/chunks/task-create-Z3QRCMX4.js +0 -3
- package/chunks/task-list-GXAJW3JP.js +0 -9
- package/chunks/team-delete-OMYVUAQU.js +0 -8
- package/chunks/write-file-XDDLTGSG.js +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{g as o,i as a,p as u,q as n}from"./chunk-
|
|
3
|
+
import{g as o,i as a,p as u,q as n}from"./chunk-TWJLOEAI.js";import{b as s}from"./chunk-GZPNIYVZ.js";s();var i=`Submit your final answer as structured JSON that conforms to the provided schema.
|
|
4
4
|
|
|
5
5
|
CRITICAL: In structured-output mode, this is the ONLY way to deliver the final result. Call this tool to deliver the final result; the first call with valid arguments ends the session. Do not emit the final answer as plain text \u2014 it will be discarded. Use other tools (Read, Grep, etc.) to gather the information you need before calling this tool.
|
|
6
6
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{f as T}from"./chunk-ZX34M2GF.js";import{b as X}from"./chunk-7ZODGQO6.js";import{b as P}from"./chunk-TISQNFB5.js";import{c as g}from"./chunk-LUNDTQ3G.js";import{b as l,ba as $}from"./chunk-27Q5KW3A.js";import{b as _}from"./chunk-GZPNIYVZ.js";import{f as W}from"./chunk-OWGSC52X.js";_();var R=W(X(),1);import*as d from"node:fs/promises";import{constants as B}from"node:fs";import*as b from"node:path";var f=$("AGENTS_TEAM_TASKS"),v=32768,A=16;function C(r){if(!r)return;let e=Buffer.byteLength(JSON.stringify(r),"utf-8");if(e>v)throw new Error(`Task metadata is too large (${e} bytes; max ${v}). Trim the payload or store the bulk content elsewhere.`)}var K={retries:{retries:30,minTimeout:5,maxTimeout:100,factor:2,randomize:!0},stale:5e3,onCompromised:r=>{f.warn("task lock compromised:",r?.message??r)}},j=new Map;function q(r){let e=j.get(r);return e||(e=new P,j.set(r,e)),e}async function h(r,e,t){return q(r).runExclusive(async()=>{let a;try{a=await R.default.lock(r,K)}catch(o){if(l(o)&&o.code==="ENOENT")return t();throw o}try{return await e()}finally{await a()}})}var z="__reciprocal__",L=new Map;function Y(r){let e=L.get(r);return e||(e=new P,L.set(r,e)),e}function G(r){if(!/^[1-9]\d*$/.test(r))throw new Error(`Invalid task ID "${r}". Task IDs must be positive integers.`)}function m(r,e){return G(e),b.join(T(r),`${e}.json`)}var O=new Set;function ie(r){return O.add(r),()=>{O.delete(r)}}function k(r){for(let e of O)try{e(r)}catch(t){f.warn(`task update listener failed: ${t}`)}}async function oe(r,e){C(e.metadata);let t=T(r);await d.mkdir(t,{recursive:!0});let a=15;for(let o=0;o<a;o++){let c=await I(t),s={id:c,subject:e.subject,description:e.description,activeForm:e.activeForm,owner:e.owner,status:"pending",blocks:[],blockedBy:[],metadata:e.metadata},n=b.join(t,`${c}.json`);try{await(await d.open(n,B.O_WRONLY|B.O_CREAT|B.O_EXCL)).close()}catch(i){if(l(i)&&i.code==="EEXIST")continue;throw i}try{await g(n,s)}catch(i){throw await d.unlink(n).catch(()=>{}),i}return k(r),s}throw new Error(`Failed to create task after ${a} attempts (ID contention).`)}async function ce(r,e){let t=m(r,e);try{let a=await d.readFile(t,"utf-8");return JSON.parse(a)}catch(a){if(l(a)&&a.code==="ENOENT")return;throw a}}var p=class extends Error{constructor(t,a,o){super(`Task #${t} is owned by "${o}". Only the leader or the owner can change status / owner / subject / description / blocks.`);this.taskId=t;this.callerName=a;this.actualOwner=o;this.name="TaskOwnershipError"}};async function F(r,e,t,a){let o=m(r,e);return h(o,async()=>{let c;try{c=await d.readFile(o,"utf-8")}catch(n){if(l(n)&&n.code==="ENOENT")return;throw n}let s=JSON.parse(c);if(a?.callerName!==void 0&&a.callerName!==z&&(t.status!==void 0||t.owner!==void 0||t.subject!==void 0||t.description!==void 0||(t.addBlocks?.length??0)>0||(t.addBlockedBy?.length??0)>0)&&s.owner&&s.owner!==a.callerName)throw new p(e,a.callerName,s.owner);if(t.addBlocks?.length){let n=new Set(s.blocks);for(let i of t.addBlocks)n.add(i);s.blocks=Array.from(n)}if(t.addBlockedBy?.length){let n=new Set(s.blockedBy);for(let i of t.addBlockedBy)n.add(i);s.blockedBy=Array.from(n)}if(t.status!==void 0&&(s.status=t.status,t.status==="completed"&&s.blocks.length>0&&await V(r,e,s.blocks)),t.owner!==void 0&&(s.owner=t.owner?t.owner:void 0),t.subject!==void 0&&(s.subject=t.subject),t.description!==void 0&&(s.description=t.description),t.activeForm!==void 0&&(s.activeForm=t.activeForm??void 0),t.metadata!==void 0){s.metadata=s.metadata??{};for(let[n,i]of Object.entries(t.metadata))n==="__proto__"||n==="constructor"||n==="prototype"||(i===null?delete s.metadata[n]:s.metadata[n]=i);Object.keys(s.metadata).length===0&&(s.metadata=void 0),C(s.metadata)}return await g(o,s),k(r),s},()=>{})}async function de(r,e,t){let a=m(r,e),o=await h(a,async()=>{let s;try{let i=await d.readFile(a,"utf-8");s=JSON.parse(i)}catch(i){if(l(i)&&i.code==="ENOENT")return null;throw i}if(t?.callerName!==void 0&&s.owner&&s.owner!==t.callerName)throw new p(e,t.callerName,s.owner);let n=new Set([...s.blocks,...s.blockedBy]);n.delete(e);try{await d.unlink(a)}catch(i){if(l(i)&&i.code==="ENOENT")return null;throw i}return n},()=>null);if(o===null)return!1;let c=await Promise.allSettled(Array.from(o).map(s=>Q(r,s,e)));for(let s of c)s.status==="rejected"&&f.warn(`deleteTask(${e}): edge cleanup failed: ${s.reason}`);return k(r),!0}async function Q(r,e,t){let a=m(r,e);await h(a,async()=>{try{let o=await d.readFile(a,"utf-8"),c=JSON.parse(o),s=c.blocks.length,n=c.blockedBy.length;if(c.blocks=c.blocks.filter(i=>i!==t),c.blockedBy=c.blockedBy.filter(i=>i!==t),c.blocks.length===s&&c.blockedBy.length===n)return;await g(a,c)}catch(o){if(l(o)&&o.code==="ENOENT")return;throw o}},()=>{})}async function x(r,e){let t=T(r),a;try{a=await d.readdir(t)}catch(n){if(l(n)&&n.code==="ENOENT")return[];let i=n instanceof Error?n.message:String(n);throw f.warn(`Failed to list tasks dir ${t}: ${i}`),n instanceof Error?n:new Error(i)}let o=a.filter(n=>n.endsWith(".json")),c=[];for(let n=0;n<o.length;n+=A){let i=o.slice(n,n+A),w=await Promise.all(i.map(async D=>{let y=b.join(t,D),S;try{S=await d.readFile(y,"utf-8")}catch(u){if(l(u)&&u.code==="ENOENT")return;let E=u instanceof Error?u.message:String(u);f.warn(`Failed to read task file ${y}: ${E}`);return}if(S.trim()!=="")try{return JSON.parse(S)}catch(u){let E=u instanceof Error?u.message:String(u);f.warn(`Quarantining corrupt task file ${y}: ${E}`);let J=`${y}.corrupt-${Date.now()}`;try{await d.rename(y,J)}catch(N){let U=N instanceof Error?N.message:String(N);f.warn(`Failed to quarantine ${y}: ${U}`)}return}}));c.push(...w)}let s=c.filter(n=>n!==void 0);return s.sort((n,i)=>Number(n.id)-Number(i.id)),e?s.filter(n=>!(e.status!==void 0&&n.status!==e.status||e.owner!==void 0&&n.owner!==e.owner||e.blockedBy!==void 0&&!n.blockedBy.includes(e.blockedBy))):s}async function le(r){let e=T(r);await d.rm(e,{recursive:!0,force:!0}),k(r)}async function V(r,e,t){let a=await Promise.allSettled(t.map(async o=>{let c=m(r,o);await h(c,async()=>{let s;try{s=await d.readFile(c,"utf-8")}catch(w){if(l(w)&&w.code==="ENOENT")return;throw w}let n=JSON.parse(s),i=n.blockedBy.length;n.blockedBy=n.blockedBy.filter(w=>w!==e),n.blockedBy.length!==i&&await g(c,n)},()=>{})}));for(let o of a)o.status==="rejected"&&f.warn(`unblockDependents(${e}): ${o.reason}`);k(r)}async function ue(r,e,t){await F(r,e,{addBlocks:[t]}),await F(r,t,{addBlockedBy:[e]})}async function fe(r,e,t,a){return a?.checkAgentBusy?Y(t).runExclusive(()=>M(r,e,t,a,!0)):M(r,e,t,a,!1)}async function M(r,e,t,a,o){if(o&&await H(r,t))return;let c=m(r,e);return h(c,async()=>{let s;try{s=await d.readFile(c,"utf-8")}catch(i){if(l(i)&&i.code==="ENOENT")return;throw i}let n=JSON.parse(s);if(n.status==="pending"&&!n.owner)return n.owner=a?.ownerName??t,n.status="in_progress",await g(c,n),k(r),n},()=>{})}async function H(r,e){let t=await x(r,{status:"in_progress"}),a=e.split("@")[0];return t.some(o=>o.owner===e||o.owner===a)}async function Z(r,e,t){let a=m(r,e);return h(a,async()=>{let o;try{o=await d.readFile(a,"utf-8")}catch(s){if(l(s)&&s.code==="ENOENT")return!1;throw s}let c=JSON.parse(o);return c.status!=="in_progress"||c.owner!==t?!1:(c.owner=void 0,c.status="pending",await g(a,c),!0)},()=>!1)}async function we(r,e){let t=e.split("@")[0],o=(await x(r,{status:"in_progress"})).filter(i=>i.owner===e||i.owner===t),c=await Promise.allSettled(o.map(i=>Z(r,i.id,i.owner))),s=c.filter(i=>i.status==="rejected");s.length>0&&f.warn(`unassignTeammateTasks: ${s.length}/${o.length} task(s) failed to unassign for ${e}`);let n=c.filter(i=>i.status==="fulfilled"&&i.value===!0).length;return n>0&&k(r),n}async function ge(r){let e=await x(r),t=new Map;for(let a of e){if(!a.owner)continue;let o=t.get(a.owner)??{inProgress:0,completed:0};a.status==="in_progress"?o.inProgress++:a.status==="completed"&&o.completed++,t.set(a.owner,o)}return t}async function I(r){let e;try{e=await d.readdir(r)}catch{return"1"}let t=0;for(let a of e){if(!a.endsWith(".json"))continue;let o=parseInt(a.replace(".json",""),10);!isNaN(o)&&o>t&&(t=o)}return String(t+1)}export{z as a,G as b,m as c,ie as d,k as e,oe as f,ce as g,p as h,F as i,de as j,x as k,le as l,ue as m,fe as n,Z as o,we as p,ge as q};
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2025 Matilda
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as c}from"./chunk-4F4DA5UI.js";import{k as i}from"./chunk-SDTWBD62.js";import{e as l}from"./chunk-
|
|
3
|
+
import{a as c}from"./chunk-4F4DA5UI.js";import{k as i}from"./chunk-SDTWBD62.js";import{e as l}from"./chunk-TWJLOEAI.js";import{b as g}from"./chunk-GZPNIYVZ.js";g();import{readFile as y}from"node:fs/promises";function S(t){return t?`side-query:${t}`:"side-query"}function T(t,e){return e??t.getFastModel?.()??t.getModel()??c}function x(t){let e=t?.thinkingConfig;return{...t??{},thinkingConfig:e?{includeThoughts:!1,...e}:{includeThoughts:!1}}}async function h(t){let e=t.getOutputLanguageFilePath?.();if(e)try{let n=(await y(e,"utf8")).trim();return n?["Follow the user-visible output language preference below for this side query.",n].join(`
|
|
4
4
|
|
|
5
5
|
`):void 0}catch{return}}function C(t,e){return e?t===void 0?e:typeof t=="string"?`${t}
|
|
6
6
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{b as S}from"./chunk-GZPNIYVZ.js";import{a as j,d as k}from"./chunk-OWGSC52X.js";var De=k((Gt,Le)=>{S();var U=j("constants"),ot=process.cwd,te=null,at=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return te||(te=ot.call(process)),te};try{process.cwd()}catch{}typeof process.chdir=="function"&&(me=process.chdir,process.chdir=function(e){te=null,me.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,me));var me;Le.exports=ct;function ct(e){U.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=u(e.chmodSync),e.fchmodSync=u(e.fchmodSync),e.lchmodSync=u(e.lchmodSync),e.stat=m(e.stat),e.fstat=m(e.fstat),e.lstat=m(e.lstat),e.statSync=E(e.statSync),e.fstatSync=E(e.fstatSync),e.lstatSync=E(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(i,h,c){c&&process.nextTick(c)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(i,h,c,a){a&&process.nextTick(a)},e.lchownSync=function(){}),at==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:function(i){function h(c,a,l){var _=Date.now(),d=0;i(c,a,function O(C){if(C&&(C.code==="EACCES"||C.code==="EPERM"||C.code==="EBUSY")&&Date.now()-_<6e4){setTimeout(function(){e.stat(a,function(P,X){P&&P.code==="ENOENT"?i(c,a,O):l(C)})},d),d<100&&(d+=10);return}l&&l(C)})}return Object.setPrototypeOf&&Object.setPrototypeOf(h,i),h}(e.rename)),e.read=typeof e.read!="function"?e.read:function(i){function h(c,a,l,_,d,O){var C;if(O&&typeof O=="function"){var P=0;C=function(X,Ie,Fe){if(X&&X.code==="EAGAIN"&&P<10)return P++,i.call(e,c,a,l,_,d,C);O.apply(this,arguments)}}return i.call(e,c,a,l,_,d,C)}return Object.setPrototypeOf&&Object.setPrototypeOf(h,i),h}(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:function(i){return function(h,c,a,l,_){for(var d=0;;)try{return i.call(e,h,c,a,l,_)}catch(O){if(O.code==="EAGAIN"&&d<10){d++;continue}throw O}}}(e.readSync);function t(i){i.lchmod=function(h,c,a){i.open(h,U.O_WRONLY|U.O_SYMLINK,c,function(l,_){if(l){a&&a(l);return}i.fchmod(_,c,function(d){i.close(_,function(O){a&&a(d||O)})})})},i.lchmodSync=function(h,c){var a=i.openSync(h,U.O_WRONLY|U.O_SYMLINK,c),l=!0,_;try{_=i.fchmodSync(a,c),l=!1}finally{if(l)try{i.closeSync(a)}catch{}else i.closeSync(a)}return _}}function r(i){U.hasOwnProperty("O_SYMLINK")&&i.futimes?(i.lutimes=function(h,c,a,l){i.open(h,U.O_SYMLINK,function(_,d){if(_){l&&l(_);return}i.futimes(d,c,a,function(O){i.close(d,function(C){l&&l(O||C)})})})},i.lutimesSync=function(h,c,a){var l=i.openSync(h,U.O_SYMLINK),_,d=!0;try{_=i.futimesSync(l,c,a),d=!1}finally{if(d)try{i.closeSync(l)}catch{}else i.closeSync(l)}return _}):i.futimes&&(i.lutimes=function(h,c,a,l){l&&process.nextTick(l)},i.lutimesSync=function(){})}function n(i){return i&&function(h,c,a){return i.call(e,h,c,function(l){F(l)&&(l=null),a&&a.apply(this,arguments)})}}function u(i){return i&&function(h,c){try{return i.call(e,h,c)}catch(a){if(!F(a))throw a}}}function o(i){return i&&function(h,c,a,l){return i.call(e,h,c,a,function(_){F(_)&&(_=null),l&&l.apply(this,arguments)})}}function s(i){return i&&function(h,c,a){try{return i.call(e,h,c,a)}catch(l){if(!F(l))throw l}}}function m(i){return i&&function(h,c,a){typeof c=="function"&&(a=c,c=null);function l(_,d){d&&(d.uid<0&&(d.uid+=4294967296),d.gid<0&&(d.gid+=4294967296)),a&&a.apply(this,arguments)}return c?i.call(e,h,c,l):i.call(e,h,l)}}function E(i){return i&&function(h,c){var a=c?i.call(e,h,c):i.call(e,h);return a&&(a.uid<0&&(a.uid+=4294967296),a.gid<0&&(a.gid+=4294967296)),a}}function F(i){if(!i||i.code==="ENOSYS")return!0;var h=!process.getuid||process.getuid()!==0;return!!(h&&(i.code==="EINVAL"||i.code==="EPERM"))}}});var Me=k((jt,be)=>{S();var Ne=j("stream").Stream;be.exports=ft;function ft(e){return{ReadStream:t,WriteStream:r};function t(n,u){if(!(this instanceof t))return new t(n,u);Ne.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,u=u||{};for(var s=Object.keys(u),m=0,E=s.length;m<E;m++){var F=s[m];this[F]=u[F]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(i,h){if(i){o.emit("error",i),o.readable=!1;return}o.fd=h,o.emit("open",h),o._read()})}function r(n,u){if(!(this instanceof r))return new r(n,u);Ne.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,u=u||{};for(var o=Object.keys(u),s=0,m=o.length;s<m;s++){var E=o[s];this[E]=u[E]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Pe=k((At,Re)=>{"use strict";S();Re.exports=st;var lt=Object.getPrototypeOf||function(e){return e.__proto__};function st(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:lt(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var ve=k(($t,de)=>{S();var x=j("fs"),ht=De(),mt=Me(),pt=Pe(),re=j("util"),R,ie;typeof Symbol=="function"&&typeof Symbol.for=="function"?(R=Symbol.for("graceful-fs.queue"),ie=Symbol.for("graceful-fs.previous")):(R="___graceful-fs.queue",ie="___graceful-fs.previous");function yt(){}function Ge(e,t){Object.defineProperty(e,R,{get:function(){return t}})}var W=yt;re.debuglog?W=re.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(W=function(){var e=re.format.apply(re,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
4
|
+
GFS4: `),console.error(e)});x[R]||(Ce=globalThis[R]||[],Ge(x,Ce),x.close=function(e){function t(r,n){return e.call(x,r,function(u){u||ke(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,ie,{value:e}),t}(x.close),x.closeSync=function(e){function t(r){e.apply(x,arguments),ke()}return Object.defineProperty(t,ie,{value:e}),t}(x.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){W(x[R]),j("assert").equal(x[R].length,0)}));var Ce;globalThis[R]||Ge(globalThis,x[R]);de.exports=pe(pt(x));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!x.__patched&&(de.exports=pe(x),x.__patched=!0);function pe(e){ht(e),e.gracefulify=pe,e.createReadStream=Ie,e.createWriteStream=Fe;var t=e.readFile;e.readFile=r;function r(f,y,p){return typeof y=="function"&&(p=y,y=null),N(f,y,p);function N(b,L,g,I){return t(b,L,function(v){v&&(v.code==="EMFILE"||v.code==="ENFILE")?B([N,[b,L,g],v,I||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=u;function u(f,y,p,N){return typeof p=="function"&&(N=p,p=null),b(f,y,p,N);function b(L,g,I,v,M){return n(L,g,I,function(w){w&&(w.code==="EMFILE"||w.code==="ENFILE")?B([b,[L,g,I,v],w,M||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(f,y,p,N){return typeof p=="function"&&(N=p,p=null),b(f,y,p,N);function b(L,g,I,v,M){return o(L,g,I,function(w){w&&(w.code==="EMFILE"||w.code==="ENFILE")?B([b,[L,g,I,v],w,M||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var m=e.copyFile;m&&(e.copyFile=E);function E(f,y,p,N){return typeof p=="function"&&(N=p,p=0),b(f,y,p,N);function b(L,g,I,v,M){return m(L,g,I,function(w){w&&(w.code==="EMFILE"||w.code==="ENFILE")?B([b,[L,g,I,v],w,M||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var F=e.readdir;e.readdir=h;var i=/^v[0-5]\./;function h(f,y,p){typeof y=="function"&&(p=y,y=null);var N=i.test(process.version)?function(g,I,v,M){return F(g,b(g,I,v,M))}:function(g,I,v,M){return F(g,I,b(g,I,v,M))};return N(f,y,p);function b(L,g,I,v){return function(M,w){M&&(M.code==="EMFILE"||M.code==="ENFILE")?B([N,[L,g,I],M,v||Date.now(),Date.now()]):(w&&w.sort&&w.sort(),typeof I=="function"&&I.call(this,M,w))}}}if(process.version.substr(0,4)==="v0.8"){var c=mt(e);O=c.ReadStream,P=c.WriteStream}var a=e.ReadStream;a&&(O.prototype=Object.create(a.prototype),O.prototype.open=C);var l=e.WriteStream;l&&(P.prototype=Object.create(l.prototype),P.prototype.open=X),Object.defineProperty(e,"ReadStream",{get:function(){return O},set:function(f){O=f},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return P},set:function(f){P=f},enumerable:!0,configurable:!0});var _=O;Object.defineProperty(e,"FileReadStream",{get:function(){return _},set:function(f){_=f},enumerable:!0,configurable:!0});var d=P;Object.defineProperty(e,"FileWriteStream",{get:function(){return d},set:function(f){d=f},enumerable:!0,configurable:!0});function O(f,y){return this instanceof O?(a.apply(this,arguments),this):O.apply(Object.create(O.prototype),arguments)}function C(){var f=this;he(f.path,f.flags,f.mode,function(y,p){y?(f.autoClose&&f.destroy(),f.emit("error",y)):(f.fd=p,f.emit("open",p),f.read())})}function P(f,y){return this instanceof P?(l.apply(this,arguments),this):P.apply(Object.create(P.prototype),arguments)}function X(){var f=this;he(f.path,f.flags,f.mode,function(y,p){y?(f.destroy(),f.emit("error",y)):(f.fd=p,f.emit("open",p))})}function Ie(f,y){return new e.ReadStream(f,y)}function Fe(f,y){return new e.WriteStream(f,y)}var ut=e.open;e.open=he;function he(f,y,p,N){return typeof p=="function"&&(N=p,p=null),b(f,y,p,N);function b(L,g,I,v,M){return ut(L,g,I,function(w,kt){w&&(w.code==="EMFILE"||w.code==="ENFILE")?B([b,[L,g,I,v],w,M||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}return e}function B(e){W("ENQUEUE",e[0].name,e[1]),x[R].push(e),ye()}var ne;function ke(){for(var e=Date.now(),t=0;t<x[R].length;++t)x[R][t].length>2&&(x[R][t][3]=e,x[R][t][4]=e);ye()}function ye(){if(clearTimeout(ne),ne=void 0,x[R].length!==0){var e=x[R].shift(),t=e[0],r=e[1],n=e[2],u=e[3],o=e[4];if(u===void 0)W("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-u>=6e4){W("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var m=Date.now()-o,E=Math.max(o-u,1),F=Math.min(E*1.2,100);m>=F?(W("RETRY",t.name,r),t.apply(null,r.concat([u]))):x[R].push(e)}ne===void 0&&(ne=setTimeout(ye,0))}}});var je=k((Kt,qe)=>{S();function G(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}qe.exports=G;G.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};G.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};G.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,u=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&u.unref(),!0};G.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};G.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};G.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};G.prototype.start=G.prototype.try;G.prototype.errors=function(){return this._errors};G.prototype.attempts=function(){return this._attempts};G.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var u=this._errors[n],o=u.message,s=(e[o]||0)+1;e[o]=s,s>=r&&(t=u,r=s)}return t}});var Ue=k($=>{S();var dt=je();$.operation=function(e){var t=$.timeouts(e);return new dt(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};$.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],u=0;u<t.retries;u++)n.push(this.createTimeout(u,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(u,t)),n.sort(function(o,s){return o-s}),n};$.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};$.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var n in e)typeof e[n]=="function"&&r.push(n)}for(var u=0;u<r.length;u++){var o=r[u],s=e[o];e[o]=function(E){var F=$.operation(t),i=Array.prototype.slice.call(arguments,1),h=i.pop();i.push(function(c){F.retry(c)||(c&&(arguments[0]=F.mainError()),h.apply(this,arguments))}),F.attempt(function(){E.apply(e,i)})}.bind(e,s),e[o].options=t}}});var We=k((Ht,Ae)=>{S();Ae.exports=Ue()});var $e=k((Xt,ue)=>{S();ue.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&ue.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ue.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var ze=k((Zt,H)=>{S();var T=globalThis.process,Y=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};Y(T)?(Ye=j("assert"),Q=$e(),Ke=/^win/i.test(T.platform),J=j("events"),typeof J!="function"&&(J=J.EventEmitter),T.__signal_exit_emitter__?D=T.__signal_exit_emitter__:(D=T.__signal_exit_emitter__=new J,D.count=0,D.emitted={}),D.infinite||(D.setMaxListeners(1/0),D.infinite=!0),H.exports=function(e,t){if(!Y(globalThis.process))return function(){};Ye.equal(typeof e,"function","a callback must be provided for exit handler"),z===!1&&Se();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){D.removeListener(r,e),D.listeners("exit").length===0&&D.listeners("afterexit").length===0&&oe()};return D.on(r,e),n},oe=function(){!z||!Y(globalThis.process)||(z=!1,Q.forEach(function(t){try{T.removeListener(t,ae[t])}catch{}}),T.emit=ce,T.reallyExit=_e,D.count-=1)},H.exports.unload=oe,K=function(t,r,n){D.emitted[t]||(D.emitted[t]=!0,D.emit(t,r,n))},ae={},Q.forEach(function(e){ae[e]=function(){if(Y(globalThis.process)){var r=T.listeners(e);r.length===D.count&&(oe(),K("exit",null,e),K("afterexit",null,e),Ke&&e==="SIGHUP"&&(e="SIGINT"),T.kill(T.pid,e))}}}),H.exports.signals=function(){return Q},z=!1,Se=function(){z||!Y(globalThis.process)||(z=!0,D.count+=1,Q=Q.filter(function(t){try{return T.on(t,ae[t]),!0}catch{return!1}}),T.emit=Qe,T.reallyExit=Be)},H.exports.load=Se,_e=T.reallyExit,Be=function(t){Y(globalThis.process)&&(T.exitCode=t||0,K("exit",T.exitCode,null),K("afterexit",T.exitCode,null),_e.call(T,T.exitCode))},ce=T.emit,Qe=function(t,r){if(t==="exit"&&Y(globalThis.process)){r!==void 0&&(T.exitCode=r);var n=ce.apply(this,arguments);return K("exit",T.exitCode,null),K("afterexit",T.exitCode,null),n}else return ce.apply(this,arguments)}):H.exports=function(){return function(){}};var Ye,Q,Ke,J,D,oe,K,ae,z,Se,_e,Be,ce,Qe});var Ve=k((tr,we)=>{"use strict";S();var He=Symbol();function vt(e,t,r){let n=t[He];if(n)return t.stat(e,(o,s)=>{if(o)return r(o);r(null,s.mtime,n)});let u=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,u,u,o=>{if(o)return r(o);t.stat(e,(s,m)=>{if(s)return r(s);let E=m.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(t,He,{value:E}),r(null,m.mtime,E)})})}function St(e){let t=Date.now();return e==="s"&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}we.exports.probe=vt;we.exports.getMtime=St});var tt=k((nr,ee)=>{"use strict";S();var _t=j("path"),Oe=ve(),wt=We(),Tt=ze(),Xe=Ve(),q={};function Z(e,t){return t.lockfilePath||`${e}.lock`}function ge(e,t,r){if(!t.realpath)return r(null,_t.resolve(e));t.fs.realpath(e,r)}function Ee(e,t,r){let n=Z(e,t);t.fs.mkdir(n,u=>{if(!u)return Xe.probe(n,t.fs,(o,s,m)=>{if(o)return t.fs.rmdir(n,()=>{}),r(o);r(null,s,m)});if(u.code!=="EEXIST")return r(u);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));t.fs.stat(n,(o,s)=>{if(o)return o.code==="ENOENT"?Ee(e,{...t,stale:0},r):r(o);if(!Je(s,t))return r(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));Ze(e,t,m=>{if(m)return r(m);Ee(e,{...t,stale:0},r)})})})}function Je(e,t){return e.mtime.getTime()<Date.now()-t.stale}function Ze(e,t,r){t.fs.rmdir(Z(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function fe(e,t){let r=q[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{r.updateTimeout=null,t.fs.stat(r.lockfilePath,(n,u)=>{let o=r.lastUpdate+t.stale<Date.now();if(n)return n.code==="ENOENT"||o?Te(e,r,Object.assign(n,{code:"ECOMPROMISED"})):(r.updateDelay=1e3,fe(e,t));if(!(r.mtime.getTime()===u.mtime.getTime()))return Te(e,r,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let m=Xe.getMtime(r.mtimePrecision);t.fs.utimes(r.lockfilePath,m,m,E=>{let F=r.lastUpdate+t.stale<Date.now();if(!r.released){if(E)return E.code==="ENOENT"||F?Te(e,r,Object.assign(E,{code:"ECOMPROMISED"})):(r.updateDelay=1e3,fe(e,t));r.mtime=m,r.lastUpdate=Date.now(),r.updateDelay=null,fe(e,t)}})})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function Te(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),q[e]===t&&delete q[e],t.options.onCompromised(r)}function Et(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:Oe,onCompromised:n=>{throw n},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),ge(e,t,(n,u)=>{if(n)return r(n);let o=wt.operation(t.retries);o.attempt(()=>{Ee(u,t,(s,m,E)=>{if(o.retry(s))return;if(s)return r(o.mainError());let F=q[u]={lockfilePath:Z(u,t),mtime:m,mtimePrecision:E,options:t,lastUpdate:Date.now()};fe(u,t),r(null,i=>{if(F.released)return i&&i(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));et(u,{...t,realpath:!1},i)})})})})}function et(e,t,r){t={fs:Oe,realpath:!0,...t},ge(e,t,(n,u)=>{if(n)return r(n);let o=q[u];if(!o)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete q[u],Ze(u,t,r)})}function Ot(e,t,r){t={stale:1e4,realpath:!0,fs:Oe,...t},t.stale=Math.max(t.stale||0,2e3),ge(e,t,(n,u)=>{if(n)return r(n);t.fs.stat(Z(u,t),(o,s)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!Je(s,t)))})}function gt(){return q}Tt(()=>{for(let e in q){let t=q[e].options;try{t.fs.rmdirSync(Z(e,t))}catch{}}});ee.exports.lock=Et;ee.exports.unlock=et;ee.exports.check=Ot;ee.exports.getLocks=gt});var nt=k((ur,rt)=>{"use strict";S();var xt=ve();function It(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...u)=>{let o=u.pop(),s;try{s=e[`${n}Sync`](...u)}catch(m){return o(m)}o(null,s)}}),r}function Ft(e){return(...t)=>new Promise((r,n)=>{t.push((u,o)=>{u?n(u):r(o)}),e(...t)})}function Lt(e){return(...t)=>{let r,n;if(t.push((u,o)=>{r=u,n=o}),e(...t),r)throw r;return n}}function Dt(e){if(e={...e},e.fs=It(e.fs||xt),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}rt.exports={toPromise:Ft,toSync:Lt,toSyncOptions:Dt}});var Ct=k((ar,A)=>{"use strict";S();var V=tt(),{toPromise:le,toSync:se,toSyncOptions:xe}=nt();async function it(e,t){let r=await le(V.lock)(e,t);return le(r)}function Nt(e,t){let r=se(V.lock)(e,xe(t));return se(r)}function bt(e,t){return le(V.unlock)(e,t)}function Mt(e,t){return se(V.unlock)(e,xe(t))}function Rt(e,t){return le(V.check)(e,t)}function Pt(e,t){return se(V.check)(e,xe(t))}A.exports=it;A.exports.lock=it;A.exports.unlock=bt;A.exports.lockSync=Nt;A.exports.unlockSync=Mt;A.exports.check=Rt;A.exports.checkSync=Pt});export{ve as a,Ct as b};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{b as d}from"./chunk-GZPNIYVZ.js";import{a as g,d as E,f as P}from"./chunk-OWGSC52X.js";var k=E((vr,ze)=>{"use strict";d();var je=["nodebuffer","arraybuffer","fragments"],Ve=typeof Blob<"u";Ve&&je.push("blob");ze.exports={BINARY_TYPES:je,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Ve,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Z=E((wr,ie)=>{"use strict";d();var{EMPTY_BUFFER:Kt}=k(),Se=Buffer[Symbol.species];function Xt(t,e){if(t.length===0)return Kt;if(t.length===1)return t[0];let s=Buffer.allocUnsafe(e),r=0;for(let i=0;i<t.length;i++){let n=t[i];s.set(n,r),r+=n.length}return r<e?new Se(s.buffer,s.byteOffset,r):s}function He(t,e,s,r,i){for(let n=0;n<i;n++)s[r+n]=t[n]^e[n&3]}function Ye(t,e){for(let s=0;s<t.length;s++)t[s]^=e[s&3]}function Zt(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ee(t){if(Ee.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Se(t):ArrayBuffer.isView(t)?e=new Se(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ee.readOnly=!1),e}ie.exports={concat:Xt,mask:He,toArrayBuffer:Zt,toBuffer:Ee,unmask:Ye};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=g("bufferutil");ie.exports.mask=function(e,s,r,i,n){n<48?He(e,s,r,i,n):t.mask(e,s,r,i,n)},ie.exports.unmask=function(e,s){e.length<32?Ye(e,s):t.unmask(e,s)}}catch{}});var Ze=E((Tr,Xe)=>{"use strict";d();var Ke=Symbol("kDone"),ve=Symbol("kRun"),be=class{constructor(e){this[Ke]=()=>{this.pending--,this[ve]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ve]()}[ve](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ke])}}};Xe.exports=be});var $=E((Cr,tt)=>{"use strict";d();var Q=g("zlib"),Qe=Z(),Qt=Ze(),{kStatusCode:Je}=k(),Jt=Buffer[Symbol.species],es=Buffer.from([0,0,255,255]),oe=Symbol("permessage-deflate"),C=Symbol("total-length"),q=Symbol("callback"),B=Symbol("buffers"),G=Symbol("error"),ne,we=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,!ne){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ne=new Qt(s)}}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[q];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,r=e.find(i=>!(s.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>i.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(r.server_no_context_takeover=!0),s.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(r.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?r.client_max_window_bits=s.clientMaxWindowBits:(r.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(r=>{let i=s[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="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 "${r}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);s[r]=i})}),e}decompress(e,s,r){ne.add(i=>{this._decompress(e,s,(n,o)=>{i(),r(n,o)})})}compress(e,s,r){ne.add(i=>{this._compress(e,s,(n,o)=>{i(),r(n,o)})})}_decompress(e,s,r){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Q.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Q.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[oe]=this,this._inflate[C]=0,this._inflate[B]=[],this._inflate.on("error",ss),this._inflate.on("data",et)}this._inflate[q]=r,this._inflate.write(e),s&&this._inflate.write(es),this._inflate.flush(()=>{let n=this._inflate[G];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Qe.concat(this._inflate[B],this._inflate[C]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[C]=0,this._inflate[B]=[],s&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,s,r){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Q.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Q.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[C]=0,this._deflate[B]=[],this._deflate.on("data",ts)}this._deflate[q]=r,this._deflate.write(e),this._deflate.flush(Q.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Qe.concat(this._deflate[B],this._deflate[C]);s&&(n=new Jt(n.buffer,n.byteOffset,n.length-4)),this._deflate[q]=null,this._deflate[C]=0,this._deflate[B]=[],s&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};tt.exports=we;function ts(t){this[B].push(t),this[C]+=t.length}function et(t){if(this[C]+=t.length,this[oe]._maxPayload<1||this[C]<=this[oe]._maxPayload){this[B].push(t);return}this[G]=new RangeError("Max payload size exceeded"),this[G].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[G][Je]=1009,this.removeListener("data",et),this.reset()}function ss(t){if(this[oe]._inflate=null,this[G]){this[q](this[G]);return}t[Je]=1007,this[q](t)}});var j=E((Nr,ae)=>{"use strict";d();var{isUtf8:st}=g("buffer"),{hasBlob:rs}=k(),is=[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 ns(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Oe(t){let e=t.length,s=0;for(;s<e;)if((t[s]&128)===0)s++;else if((t[s]&224)===192){if(s+1===e||(t[s+1]&192)!==128||(t[s]&254)===192)return!1;s+=2}else if((t[s]&240)===224){if(s+2>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||t[s]===224&&(t[s+1]&224)===128||t[s]===237&&(t[s+1]&224)===160)return!1;s+=3}else if((t[s]&248)===240){if(s+3>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||(t[s+3]&192)!==128||t[s]===240&&(t[s+1]&240)===128||t[s]===244&&t[s+1]>143||t[s]>244)return!1;s+=4}else return!1;return!0}function os(t){return rs&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}ae.exports={isBlob:os,isValidStatusCode:ns,isValidUTF8:Oe,tokenChars:is};if(st)ae.exports.isValidUTF8=function(t){return t.length<24?Oe(t):st(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=g("utf-8-validate");ae.exports.isValidUTF8=function(e){return e.length<32?Oe(e):t(e)}}catch{}});var Ne=E((Br,lt)=>{"use strict";d();var{Writable:as}=g("stream"),rt=$(),{BINARY_TYPES:fs,EMPTY_BUFFER:it,kStatusCode:ls,kWebSocket:hs}=k(),{concat:Te,toArrayBuffer:cs,unmask:us}=Z(),{isValidStatusCode:ds,isValidUTF8:nt}=j(),fe=Buffer[Symbol.species],b=0,ot=1,at=2,ft=3,ke=4,Ce=5,le=6,Le=class extends as{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||fs[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[hs]=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=b}_write(e,s,r){if(this._opcode===8&&this._state==b)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(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(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new fe(r.buffer,r.byteOffset+e,r.length-e),new fe(r.buffer,r.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=s.length-e;e>=r.length?s.set(this._buffers.shift(),i):(s.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new fe(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case b:this.getInfo(e);break;case ot:this.getPayloadLength16(e);break;case at:this.getPayloadLength64(e);break;case ft:this.getMask();break;case ke:this.getData(e);break;case Ce:case le:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[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 r=(s[0]&64)===64;if(r&&!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=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(r){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=r}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(r){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=(s[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=ot:this._payloadLength===127?this._state=at: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 s=this.consume(8),r=s.readUInt32BE(0);if(r>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=r*Math.pow(2,32)+s.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 s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=ft:this._state=ke}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ke}getData(e){let s=it;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&us(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=Ce,this.decompress(s,e);return}if(s.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}this._messageLength=this._totalPayloadLength,this._fragments.push(s)}this.dataMessage(e)}decompress(e,s){this._extensions[rt.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return s(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");s(o);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let o=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");s(o);return}this._fragments.push(n)}this.dataMessage(s),this._state===b&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=b;return}let s=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Te(r,s):this._binaryType==="arraybuffer"?i=cs(Te(r,s)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=b):(this._state=le,setImmediate(()=>{this.emit("message",i,!0),this._state=b,this.startLoop(e)}))}else{let i=Te(r,s);if(!this._skipUTF8Validation&&!nt(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===Ce||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=b):(this._state=le,setImmediate(()=>{this.emit("message",i,!1),this._state=b,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,it),this.end();else{let r=e.readUInt16BE(0);if(!ds(r)){let n=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(n);return}let i=new fe(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!nt(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(n);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=b;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=b):(this._state=le,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=b,this.startLoop(s)}))}createError(e,s,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(o,this.createError),o.code=n,o[ls]=i,o}};lt.exports=Le});var Re=E((Ir,ut)=>{"use strict";d();var{Duplex:Ur}=g("stream"),{randomFillSync:_s}=g("crypto"),{types:{isUint8Array:ms}}=g("util"),ht=$(),{EMPTY_BUFFER:ps,kWebSocket:gs,NOOP:ys}=k(),{isBlob:V,isValidStatusCode:xs}=j(),{mask:ct,toBuffer:U}=Z(),w=Symbol("kByteLength"),Ss=Buffer.alloc(4),he=8*1024,I,z=he,O=0,Es=1,vs=2,Pe=class t{constructor(e,s,r){this._extensions=s||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=O,this.onerror=ys,this[gs]=void 0}static frame(e,s){let r,i=!1,n=2,o=!1;s.mask&&(r=s.maskBuffer||Ss,s.generateMask?s.generateMask(r):(z===he&&(I===void 0&&(I=Buffer.alloc(he)),_s(I,0,he),z=0),r[0]=I[z++],r[1]=I[z++],r[2]=I[z++],r[3]=I[z++]),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let f;typeof e=="string"?(!s.mask||o)&&s[w]!==void 0?f=s[w]:(e=Buffer.from(e),f=e.length):(f=e.length,i=s.mask&&s.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]=s.fin?s.opcode|128:s.opcode,s.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)),s.mask?(a[1]|=128,a[n-4]=r[0],a[n-3]=r[1],a[n-2]=r[2],a[n-1]=r[3],o?[a,e]:i?(ct(e,r,a,n,f),[a]):(ct(e,r,e,0,f),[a,e])):[a,e]}close(e,s,r,i){let n;if(e===void 0)n=ps;else{if(typeof e!="number"||!xs(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let f=Buffer.byteLength(s);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 s=="string")n.write(s,2);else if(ms(s))n.set(s,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[w]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==O?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):V(e)?(i=e.size,n=!1):(e=U(e),i=e.length,n=U.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[w]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};V(e)?this._state!==O?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==O?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):V(e)?(i=e.size,n=!1):(e=U(e),i=e.length,n=U.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[w]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};V(e)?this._state!==O?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==O?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,s,r){let i=this._extensions[ht.extensionName],n=s.binary?2:1,o=s.compress,f,l;typeof e=="string"?(f=Buffer.byteLength(e),l=!1):V(e)?(f=e.size,l=!1):(e=U(e),f=e.length,l=U.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),s.fin&&(this._firstFragment=!0);let a={[w]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};V(e)?this._state!==O?this.enqueue([this.getBlobData,e,this._compress,a,r]):this.getBlobData(e,this._compress,a,r):this._state!==O?this.enqueue([this.dispatch,e,this._compress,a,r]):this.dispatch(e,this._compress,a,r)}getBlobData(e,s,r,i){this._bufferedBytes+=r[w],this._state=vs,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Be,this,f,i);return}this._bufferedBytes-=r[w];let o=U(n);s?this.dispatch(o,s,r,i):(this._state=O,this.sendFrame(t.frame(o,r),i),this.dequeue())}).catch(n=>{process.nextTick(bs,this,n,i)})}dispatch(e,s,r,i){if(!s){this.sendFrame(t.frame(e,r),i);return}let n=this._extensions[ht.extensionName];this._bufferedBytes+=r[w],this._state=Es,n.compress(e,r.fin,(o,f)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Be(this,l,i);return}this._bufferedBytes-=r[w],this._state=O,r.readOnly=!1,this.sendFrame(t.frame(f,r),i),this.dequeue()})}dequeue(){for(;this._state===O&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][w],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][w],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};ut.exports=Pe;function Be(t,e,s){typeof s=="function"&&s(e);for(let r=0;r<t._queue.length;r++){let i=t._queue[r],n=i[i.length-1];typeof n=="function"&&n(e)}}function bs(t,e,s){Be(t,e,s),t.onerror(e)}});var Et=E((Mr,St)=>{"use strict";d();var{kForOnEventAttribute:J,kListener:Ue}=k(),dt=Symbol("kCode"),_t=Symbol("kData"),mt=Symbol("kError"),pt=Symbol("kMessage"),gt=Symbol("kReason"),H=Symbol("kTarget"),yt=Symbol("kType"),xt=Symbol("kWasClean"),L=class{constructor(e){this[H]=null,this[yt]=e}get target(){return this[H]}get type(){return this[yt]}};Object.defineProperty(L.prototype,"target",{enumerable:!0});Object.defineProperty(L.prototype,"type",{enumerable:!0});var D=class extends L{constructor(e,s={}){super(e),this[dt]=s.code===void 0?0:s.code,this[gt]=s.reason===void 0?"":s.reason,this[xt]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[dt]}get reason(){return this[gt]}get wasClean(){return this[xt]}};Object.defineProperty(D.prototype,"code",{enumerable:!0});Object.defineProperty(D.prototype,"reason",{enumerable:!0});Object.defineProperty(D.prototype,"wasClean",{enumerable:!0});var Y=class extends L{constructor(e,s={}){super(e),this[mt]=s.error===void 0?null:s.error,this[pt]=s.message===void 0?"":s.message}get error(){return this[mt]}get message(){return this[pt]}};Object.defineProperty(Y.prototype,"error",{enumerable:!0});Object.defineProperty(Y.prototype,"message",{enumerable:!0});var ee=class extends L{constructor(e,s={}){super(e),this[_t]=s.data===void 0?null:s.data}get data(){return this[_t]}};Object.defineProperty(ee.prototype,"data",{enumerable:!0});var ws={addEventListener(t,e,s={}){for(let i of this.listeners(t))if(!s[J]&&i[Ue]===e&&!i[J])return;let r;if(t==="message")r=function(n,o){let f=new ee("message",{data:o?n:n.toString()});f[H]=this,ce(e,this,f)};else if(t==="close")r=function(n,o){let f=new D("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[H]=this,ce(e,this,f)};else if(t==="error")r=function(n){let o=new Y("error",{error:n,message:n.message});o[H]=this,ce(e,this,o)};else if(t==="open")r=function(){let n=new L("open");n[H]=this,ce(e,this,n)};else return;r[J]=!!s[J],r[Ue]=e,s.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let s of this.listeners(t))if(s[Ue]===e&&!s[J]){this.removeListener(t,s);break}}};St.exports={CloseEvent:D,ErrorEvent:Y,Event:L,EventTarget:ws,MessageEvent:ee};function ce(t,e,s){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,s):t.call(e,s)}});var ue=E((Ar,vt)=>{"use strict";d();var{tokenChars:te}=j();function T(t,e,s){t[e]===void 0?t[e]=[s]:t[e].push(s)}function Os(t){let e=Object.create(null),s=Object.create(null),r=!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&&te[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 y=t.slice(l,h);a===44?(T(e,y,s),s=Object.create(null)):o=y,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===void 0)if(h===-1&&te[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),T(s,t.slice(l,h),!0),a===44&&(T(e,o,s),s=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(te[a]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:r||(r=!0),i=!1}else if(n)if(te[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&&te[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 y=t.slice(l,h);r&&(y=y.replace(/\\/g,""),r=!1),T(s,f,y),a===44&&(T(e,o,s),s=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 m=t.slice(l,h);return o===void 0?T(e,m,s):(f===void 0?T(s,m,!0):r?T(s,f,m.replace(/\\/g,"")):T(s,f,m),T(e,o,s)),e}function Ts(t){return Object.keys(t).map(e=>{let s=t[e];return Array.isArray(s)||(s=[s]),s.map(r=>[e].concat(Object.keys(r).map(i=>{let n=r[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}vt.exports={format:Ts,parse:Os}});var pe=E(($r,Ut)=>{"use strict";d();var ks=g("events"),Cs=g("https"),Ls=g("http"),Ot=g("net"),Ns=g("tls"),{randomBytes:Ps,createHash:Bs}=g("crypto"),{Duplex:qr,Readable:Gr}=g("stream"),{URL:Ie}=g("url"),R=$(),Rs=Ne(),Us=Re(),{isBlob:Is}=j(),{BINARY_TYPES:bt,CLOSE_TIMEOUT:Ds,EMPTY_BUFFER:de,GUID:Ms,kForOnEventAttribute:De,kListener:Fs,kStatusCode:As,kWebSocket:x,NOOP:Tt}=k(),{EventTarget:{addEventListener:Ws,removeEventListener:qs}}=Et(),{format:Gs,parse:$s}=ue(),{toBuffer:js}=Z(),kt=Symbol("kAborted"),Me=[8,13],N=["CONNECTING","OPEN","CLOSING","CLOSED"],Vs=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,_=class t extends ks{constructor(e,s,r){super(),this._binaryType=bt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=de,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,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(r=s,s=[]):s=[s]),Ct(this,e,s,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){bt.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,s,r){let i=new Rs({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new Us(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[x]=this,n[x]=this,e[x]=this,i.on("conclude",Ys),i.on("drain",Ks),i.on("error",Xs),i.on("message",Zs),i.on("ping",Qs),i.on("pong",Js),n.onerror=er,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Pt),e.on("data",me),e.on("end",Bt),e.on("error",Rt),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[R.extensionName]&&this._extensions[R.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){v(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._readyState=t.CLOSING,this._sender.close(e,s,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Nt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Fe(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||de,s,r)}pong(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Fe(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||de,s,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(r=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Fe(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[R.extensionName]||(i.compress=!1),this._sender.send(e||de,i,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){v(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(_,"CONNECTING",{enumerable:!0,value:N.indexOf("CONNECTING")});Object.defineProperty(_.prototype,"CONNECTING",{enumerable:!0,value:N.indexOf("CONNECTING")});Object.defineProperty(_,"OPEN",{enumerable:!0,value:N.indexOf("OPEN")});Object.defineProperty(_.prototype,"OPEN",{enumerable:!0,value:N.indexOf("OPEN")});Object.defineProperty(_,"CLOSING",{enumerable:!0,value:N.indexOf("CLOSING")});Object.defineProperty(_.prototype,"CLOSING",{enumerable:!0,value:N.indexOf("CLOSING")});Object.defineProperty(_,"CLOSED",{enumerable:!0,value:N.indexOf("CLOSED")});Object.defineProperty(_.prototype,"CLOSED",{enumerable:!0,value:N.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(_.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(_.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[De])return e[Fs];return null},set(e){for(let s of this.listeners(t))if(s[De]){this.removeListener(t,s);break}typeof e=="function"&&this.addEventListener(t,e,{[De]:!0})}})});_.prototype.addEventListener=Ws;_.prototype.removeEventListener=qs;Ut.exports=_;function Ct(t,e,s,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Ds,protocolVersion:Me[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,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=i.autoPong,t._closeTimeout=i.closeTimeout,!Me.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Me.join(", ")})`);let n;if(e instanceof Ie)n=e;else try{n=new Ie(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;_e(t,u);return}let a=o?443:80,h=Ps(16).toString("base64"),c=o?Cs.request:Ls.request,m=new Set,y;if(i.createConnection=i.createConnection||(o?Hs:zs),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&&(y=new R({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=Gs({[R.extensionName]:y.offer()})),s.length){for(let u of s){if(typeof u!="string"||!Vs.test(u)||m.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(u)}i.headers["Sec-WebSocket-Protocol"]=s.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 p;if(i.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=o,t._originalHostOrSocketPath=f?i.socketPath:n.host;let u=r&&r.headers;if(r={...r,headers:{}},u)for(let[S,A]of Object.entries(u))r.headers[S.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&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),p=t._req=c(i),t._redirects&&t.emit("redirect",t.url,p)}else p=t._req=c(i);i.timeout&&p.on("timeout",()=>{v(t,p,"Opening handshake has timed out")}),p.on("error",u=>{p===null||p[kt]||(p=t._req=null,_e(t,u))}),p.on("response",u=>{let S=u.headers.location,A=u.statusCode;if(S&&i.followRedirects&&A>=300&&A<400){if(++t._redirects>i.maxRedirects){v(t,p,"Maximum redirects exceeded");return}p.abort();let K;try{K=new Ie(S,e)}catch{let W=new SyntaxError(`Invalid URL: ${S}`);_e(t,W);return}Ct(t,K,s,r)}else t.emit("unexpected-response",p,u)||v(t,p,`Unexpected server response: ${u.statusCode}`)}),p.on("upgrade",(u,S,A)=>{if(t.emit("upgrade",u),t.readyState!==_.CONNECTING)return;p=t._req=null;let K=u.headers.upgrade;if(K===void 0||K.toLowerCase()!=="websocket"){v(t,S,"Invalid Upgrade header");return}let qe=Bs("sha1").update(h+Ms).digest("base64");if(u.headers["sec-websocket-accept"]!==qe){v(t,S,"Invalid Sec-WebSocket-Accept header");return}let W=u.headers["sec-websocket-protocol"],X;if(W!==void 0?m.size?m.has(W)||(X="Server sent an invalid subprotocol"):X="Server sent a subprotocol but none was requested":m.size&&(X="Server sent no subprotocol"),X){v(t,S,X);return}W&&(t._protocol=W);let Ge=u.headers["sec-websocket-extensions"];if(Ge!==void 0){if(!y){v(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ye;try{ye=$s(Ge)}catch{v(t,S,"Invalid Sec-WebSocket-Extensions header");return}let $e=Object.keys(ye);if($e.length!==1||$e[0]!==R.extensionName){v(t,S,"Server indicated an extension that was not requested");return}try{y.accept(ye[R.extensionName])}catch{v(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[R.extensionName]=y}t.setSocket(S,A,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(p,t):p.end()}function _e(t,e){t._readyState=_.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function zs(t){return t.path=t.socketPath,Ot.connect(t)}function Hs(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ot.isIP(t.host)?"":t.host),Ns.connect(t)}function v(t,e,s){t._readyState=_.CLOSING;let r=new Error(s);Error.captureStackTrace(r,v),e.setHeader?(e[kt]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(_e,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Fe(t,e,s){if(e){let r=Is(e)?e.size:js(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(s){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${N[t.readyState]})`);process.nextTick(s,r)}}function Ys(t,e){let s=this[x];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=t,s._socket[x]!==void 0&&(s._socket.removeListener("data",me),process.nextTick(Lt,s._socket),t===1005?s.close():s.close(t,e))}function Ks(){let t=this[x];t.isPaused||t._socket.resume()}function Xs(t){let e=this[x];e._socket[x]!==void 0&&(e._socket.removeListener("data",me),process.nextTick(Lt,e._socket),e.close(t[As])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function wt(){this[x].emitClose()}function Zs(t,e){this[x].emit("message",t,e)}function Qs(t){let e=this[x];e._autoPong&&e.pong(t,!this._isServer,Tt),e.emit("ping",t)}function Js(t){this[x].emit("pong",t)}function Lt(t){t.resume()}function er(t){let e=this[x];e.readyState!==_.CLOSED&&(e.readyState===_.OPEN&&(e._readyState=_.CLOSING,Nt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Nt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Pt(){let t=this[x];if(this.removeListener("close",Pt),this.removeListener("data",me),this.removeListener("end",Bt),t._readyState=_.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[x]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",wt),t._receiver.on("finish",wt))}function me(t){this[x]._receiver.write(t)||this.pause()}function Bt(){let t=this[x];t._readyState=_.CLOSING,t._receiver.end(),this.end()}function Rt(){let t=this[x];this.removeListener("error",Rt),this.on("error",Tt),t&&(t._readyState=_.CLOSING,this.destroy())}});var Ft=E((zr,Mt)=>{"use strict";d();var Vr=pe(),{Duplex:tr}=g("stream");function It(t){t.emit("close")}function sr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Dt(t){this.removeListener("error",Dt),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function rr(t,e){let s=!0,r=new tr({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let f=!o&&r._readableState.objectMode?n.toString():n;r.push(f)||t.pause()}),t.once("error",function(n){r.destroyed||(s=!1,r.destroy(n))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(It,r);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(It,r)}),s&&t.terminate()},r._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(i,n,o)});return}t.send(i,o)},r.on("end",sr),r.on("error",Dt),r}Mt.exports=rr});var Ae=E((Yr,At)=>{"use strict";d();var{tokenChars:ir}=j();function nr(t){let e=new Set,s=-1,r=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(r===-1&&ir[o]===1)s===-1&&(s=i);else if(i!==0&&(o===32||o===9))r===-1&&s!==-1&&(r=i);else if(o===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let f=t.slice(s,r);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),s=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(s===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(s,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}At.exports={parse:nr}});var zt=E((Zr,Vt)=>{"use strict";d();var or=g("events"),ge=g("http"),{Duplex:Xr}=g("stream"),{createHash:ar}=g("crypto"),Wt=ue(),M=$(),fr=Ae(),lr=pe(),{CLOSE_TIMEOUT:hr,GUID:cr,kWebSocket:ur}=k(),dr=/^[+/0-9A-Za-z]{22}==$/,qt=0,Gt=1,jt=2,We=class extends or{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:hr,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:lr,...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=ge.createServer((r,i)=>{let n=ge.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,s)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=_r(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=qt}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===jt){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(se,this);return}if(e&&this.once("close",e),this._state!==Gt)if(this._state=Gt,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(se,this):process.nextTick(se,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{se(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,r,i){s.on("error",$t);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){F(this,e,s,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){F(this,e,s,400,"Invalid Upgrade header");return}if(n===void 0||!dr.test(n)){F(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){F(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){re(s,400);return}let l=e.headers["sec-websocket-protocol"],a=new Set;if(l!==void 0)try{a=fr.parse(l)}catch{F(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let m=new M({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=Wt.parse(h);y[M.extensionName]&&(m.accept(y[M.extensionName]),c[M.extensionName]=m)}catch{F(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={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(m,(y,p,u,S)=>{if(!y)return re(s,p||401,u,S);this.completeUpgrade(c,n,a,e,s,r,i)});return}if(!this.options.verifyClient(m))return re(s,401)}this.completeUpgrade(c,n,a,e,s,r,i)}completeUpgrade(e,s,r,i,n,o,f){if(!n.readable||!n.writable)return n.destroy();if(n[ur])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>qt)return re(n,503);let a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ar("sha1").update(s+cr).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(a.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[M.extensionName]){let c=e[M.extensionName].params,m=Wt.format({[M.extensionName]:[c]});a.push(`Sec-WebSocket-Extensions: ${m}`),h._extensions=e}this.emit("headers",a,i),n.write(a.concat(`\r
|
|
4
|
+
`).join(`\r
|
|
5
|
+
`)),n.removeListener("error",$t),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(se,this)})),f(h,i)}};Vt.exports=We;function _r(t,e){for(let s of Object.keys(e))t.on(s,e[s]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function se(t){t._state=jt,t.emit("close")}function $t(){this.destroy()}function re(t,e,s,r){s=s||ge.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${ge.STATUS_CODES[e]}\r
|
|
6
|
+
`+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
|
|
7
|
+
`)+`\r
|
|
8
|
+
\r
|
|
9
|
+
`+s)}function F(t,e,s,r,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,F),t.emit("wsClientError",o,s,e)}else re(s,r,i,n)}});d();var mr=P(Ft(),1),pr=P(ue(),1),gr=P($(),1),yr=P(Ne(),1),xr=P(Re(),1),Sr=P(Ae(),1),Ht=P(pe(),1),Er=P(zt(),1);var Jr=Ht.default;export{Ht as a,Er as b,Jr as c};
|