openpond 0.2.53 → 0.2.54
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/dist/app-server.d.ts +1 -1
- package/dist/app-server.js +1 -1
- package/dist/chunks/{app-server-runtime-KZP2LB5X.js → app-server-runtime-7AXV6JZI.js} +1 -1
- package/dist/chunks/{chunk-XGE2XI6M.js → chunk-37DXASQL.js} +115 -115
- package/dist/chunks/chunk-4EEH7MEC.js +2 -0
- package/dist/chunks/{chunk-3LX6RU3C.js → chunk-UE3DMPGM.js} +1 -1
- package/dist/chunks/{hosted-profile-compiler-OZAOZ2ES.js → hosted-profile-compiler-SCVJI2CP.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-inspection-SJIDXPHI.js → hosted-profile-evaluation-inspection-OC4XNGL2.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-preparation-26EI5LJR.js → hosted-profile-evaluation-preparation-ZD4FM3FD.js} +1 -1
- package/dist/chunks/{src-P3VYLFLI.js → src-NE6R4XC6.js} +1 -1
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-AFUDIT36.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{Fa as O}from"./chunk-2JO2KWT3.js";import{n as _,o as k,r as q,u as U,w as j,x as L}from"./chunk-WV2APYWG.js";import{Y as C,h as b,i as x}from"./chunk-PJM2G7SG.js";import{i as T,m as u,n as M}from"./chunk-NNF6KCHD.js";import{b as R}from"./chunk-ES2ISFJC.js";import{a as I}from"./chunk-FTQLQJQV.js";var y=R.object({sessionId:R.string().trim().min(1).max(500),turnId:R.string().trim().min(1).max(500)}).strict();async function Q(e){U(e.manifest,e.taskset,e.catalog),L(e.taskset,e.metricSource);let n=e.manifest.profileEvaluation,o=e.catalog.definitions.find(a=>a.id===n.definitionId),i=new Map(e.taskset.tasks.map(a=>[a.id,a])),p=[],t=[];for(let a of e.manifest.population){e.signal?.throwIfAborted();let l=i.get(a.taskId),s=await e.loadCompletedMember?.(a)??null;if(s){let{receipt:h,grade:g}=s,{contentHash:H,...v}=b.parse(g);if(!k(h)||H!==u(v)||h.id!==a.receiptId||h.runManifest.id!==e.manifest.id||h.runManifest.contentHash!==e.manifest.contentHash||h.taskId!==a.taskId||h.seed!==a.seed||h.graderEvidenceRefs.length!==1||h.graderEvidenceRefs[0]?.contentHash!==H||g.taskHash!==u(l)||g.graderSetHash!==u(e.taskset.graders)||h.metadata.score!==g.score||h.metadata.passed!==g.passed)throw new Error(`Retained Profile evaluation member ${a.receiptId} differs from its admitted evidence.`);t.push(g),p.push(h);continue}let d=await e.execute({task:C(l),seed:a.seed,source:n,...e.signal?{signal:e.signal}:{}});e.signal?.throwIfAborted();let c=await x({task:l,evidence:d.evidence,graders:e.taskset.graders,...e.modelJudge?{modelJudge:e.modelJudge}:{},...e.customVerifier?{customVerifier:e.customVerifier}:{},...e.signal?{signal:e.signal}:{}}),w=T.parse(await e.saveGrade(c));if(w.contentHash!==c.contentHash)throw new Error("Stored Profile evaluation grade differs from its graded evidence.");let E=d.failureClass??c.failureClass,P=_({schemaVersion:"openpond.attemptReceipt.v1",id:a.receiptId,runManifest:{id:e.manifest.id,contentHash:e.manifest.contentHash},taskId:a.taskId,seed:a.seed,terminal:d.terminal,failureClass:E,outputHash:d.evidence.infrastructureError?null:u(d.evidence.output),traceHash:d.traceHash,artifactRefs:d.artifactRefs,graderEvidenceRefs:[w],startedAt:d.startedAt,completedAt:d.completedAt,latencyMs:d.latencyMs,costUsd:d.costUsd,metadata:{gradingRole:"evaluation",score:c.score,passed:c.passed,rewardEligible:c.rewardEligible,sourceRevision:n.sourceRevision,definitionHash:n.definitionHash,environmentHash:n.environmentHash,...d.retainedEvidenceRef?{retainedEvidenceRef:y.parse(d.retainedEvidenceRef)}:{}}});await e.saveReceipt(P),t.push(c),p.push(P)}let r=await j({manifest:e.manifest,taskset:e.taskset,receipts:p,...e.metricSource!==void 0?{source:e.metricSource}:{},...e.signal?{signal:e.signal}:{}},e.metricExecutor),f=t.filter(a=>a.passed).length/t.length;return{receipts:p,grades:t,metric:r,passRate:f,passed:f>=o.criterion.minimumPassRate&&(!o.criterion.requireComplete||p.every(a=>a.terminal))}}I(Q,"executeProfileEvaluationRun");function $(e,n,o){if(n==="agent_action"){let i=e.find(p=>p.name==="workspace_action_result"&&p.action==="profile_workflow_action")?.output;if(typeof i!="string")throw new Error("Profile Agent action evaluation did not produce a released action result.");return i}if(o==="completed"){let t=[...e].reverse().find(f=>f.name==="turn.completed")?.data?.providerResponse;if(typeof t?.requestId!="string"||!t.requestId||typeof t.contentHash!="string")throw new Error("Profile evaluation has no retained final provider response.");let r=e.filter(f=>f.name==="assistant.delta"&&f.data?.providerRequestId===t.requestId).map(f=>f.output??"").join("");if(u(r)!==t.contentHash)throw new Error("Profile evaluation final provider response differs from its retained trace.");return r}return e.filter(i=>i.name==="assistant.delta"&&typeof i.output=="string").map(i=>i.output??"").join("")}I($,"profileEvaluationOutput");async function V(e){let{store:n,manifest:o,receipt:i}=e;if(!i.metadata.retainedEvidenceRef)return null;let p=y.parse(i.metadata.retainedEvidenceRef),[t,r]=await Promise.all([n.getSession(p.sessionId),n.getTurn(p.turnId)]),f=t?.metadata?.profileEvaluationRun,a=o.profileEvaluation;if(!t||!r||r.sessionId!==t.id||!a||!t.currentProfile||u(t.currentProfile)!==u(e.profileRef)||u(f)!==u({id:o.id,contentHash:o.contentHash})||t.metadata?.taskId!==i.taskId||t.metadata?.seed!==i.seed||!r.completedAt||r.completedAt!==i.completedAt||r.startedAt!==i.startedAt||!r.harnessSnapshot||r.harnessSnapshot.harnessRelease.id!==a.harnessRelease.id||r.harnessSnapshot.harnessRelease.contentHash!==a.harnessRelease.contentHash||o.policy.kind!=="model"||!r.modelRef||r.modelRef.providerId!==o.policy.model.provider||r.modelRef.modelId!==o.policy.model.model)throw new Error("Retained Profile policy turn differs from its admitted case.");let l=await n.runtimeEventsForTurn(r.id);if(l.some(g=>g.turnId!==r.id)||u(l)!==i.traceHash)throw new Error("Retained Profile policy trace differs from its immutable receipt.");let s=$(l,a.target.kind,r.status);if(i.outputHash!==null&&u({text:s})!==i.outputHash)throw new Error("Retained Profile output differs from its immutable receipt.");let d=i.artifactRefs.flatMap(g=>{let H=l.filter(m=>(m.action==="work_output_save"||m.action==="sandbox_save_output")&&m.status==="completed").flatMap(m=>{let z=m.data&&typeof m.data=="object"?m.data:{},A=O.safeParse(z.outputRef);return A.success?[A.data]:[]}).filter(m=>m.sourceTaskId===t.id&&m.sourceTurnId===r.id&&`${t.id}/${m.id}/${m.revision}/${m.title}`===g.id&&m.sha256===g.contentHash&&m.sizeBytes===g.sizeBytes&&m.contentType===g.mediaType);if(H.length!==1)throw new Error("The case output has no unique sealed saved-file identity.");let v=H[0];if(v.location.kind!=="managed")return[];let S=`/api/work/outputs/${encodeURIComponent(v.location.fileId)}`;if(v.location.downloadPath!==S)throw new Error("The saved output has no canonical managed download route.");return[{id:v.id,title:v.title,revision:v.revision,contentType:v.contentType,sizeBytes:v.sizeBytes,sha256:v.sha256,downloadPath:S}]}),c=await n.listModelUsageRecords({sessionId:t.id,turnId:r.id,limit:1e4}),w=e.eventAfterId?l.findIndex(g=>g.id===e.eventAfterId):-1;if(e.eventAfterId&&w<0)throw new Error("Profile trace cursor is unavailable in this case.");let E=w+1,P=Math.max(1,Math.min(250,e.eventLimit??100)),h=l.slice(E,E+P);return{ref:p,prompt:r.prompt,output:i.outputHash===null?null:{text:s},partialOutput:i.outputHash===null&&s?{text:s}:null,error:r.error,events:h,eventCount:l.length,nextEventCursor:E+h.length<l.length?h.at(-1).id:null,files:d,usage:c,usageCoverage:c.length===1e4?"partial":"complete"}}I(V,"readProfileEvaluationPolicyEvidence");var oe=R.object({runId:R.string().trim().min(1).max(240),receiptId:R.string().trim().min(1).max(500).optional(),eventAfterId:R.string().trim().min(1).max(500).optional(),eventLimit:R.number().int().min(1).max(250).optional(),manifest:q.optional()}).strict().refine(e=>e.receiptId||!e.eventAfterId&&!e.eventLimit,"Select a case before requesting its trace page.").refine(e=>!e.manifest||e.receiptId,"Interrupted-run inspection requires one exact case.");async function de(e){let n=await e.store.getProfileEvaluationRun(e.runId);if(n&&u(n.profileRef)!==u(e.profileRef))throw new Error("Profile evaluation run is unavailable in the selected Profile.");let o=n?.manifest??e.manifest;if(!o||!n&&!e.receiptId)throw new Error("Profile evaluation run is unavailable in the selected Profile.");if(n){if(e.manifest&&e.manifest.contentHash!==n.manifest.contentHash)throw new Error("Profile evaluation run differs from its pinned manifest.")}else if(M(o,"Interrupted Profile evaluation manifest"),o.id!==e.runId||o.profileEvaluation?.profileId!==e.profileRef.profileId||e.profileRef.source==="openpond_git"&&o.metadata.profileRepositoryId!==e.profileRef.repositoryId)throw new Error("Profile evaluation run is unavailable in the selected Profile.");let i=o.population.map((t,r)=>({member:t,index:r})).filter(({member:t})=>!e.receiptId||t.receiptId===e.receiptId);if(e.receiptId&&i.length!==1)throw new Error("Profile evaluation case is unavailable in the selected run.");let p=await Promise.all(i.map(async({member:t,index:r})=>{let f=n?null:await e.store.getProfileEvaluationReceipt(t.receiptId),a=n?.receiptRefs[r]??(f?{id:f.id,contentHash:f.contentHash}:null),l=n?.gradeRefs[r]??f?.graderEvidenceRefs[0];if(!a||!l)throw new Error("Profile evaluation run has incomplete case evidence.");let[s,d]=await Promise.all([e.store.getProfileEvaluationReceipt(a.id),e.store.getProfileEvaluationGrade(l.contentHash)]);if(!s||!n&&!k(s)||s.contentHash!==a.contentHash||s.id!==t.receiptId||s.taskId!==t.taskId||s.seed!==t.seed||s.runManifest.id!==o.id||s.runManifest.contentHash!==o.contentHash||!d||d.contentHash!==l.contentHash||!s.graderEvidenceRefs.some(c=>c.id===l.id&&c.contentHash===l.contentHash))throw new Error("Profile evaluation case evidence differs from its retained run.");return{taskId:t.taskId,seed:t.seed,receiptId:s.id,receiptHash:s.contentHash,traceHash:s.traceHash,outputHash:s.outputHash,score:d.score,passed:d.passed,gradingStatus:d.gradingStatus,failureClass:d.failureClass,artifactCount:s.artifactRefs.length,latencyMs:s.latencyMs,costUsd:s.costUsd,terminal:s.terminal,feedback:d.components.map(c=>({graderId:c.graderId,graderVersion:c.graderVersion,score:c.score,passed:c.passed,feedback:c.feedback})),...e.receiptId?{receipt:s,evidence:await V({store:e.store,profileRef:e.profileRef,manifest:o,receipt:s,eventAfterId:e.eventAfterId,eventLimit:e.eventLimit})}:{}}}));return{runId:o.id,sourceRevision:o.profileEvaluation?.sourceRevision??null,cases:p}}I(de,"inspectProfileEvaluationRun");export{Q as a,$ as b,oe as c,de as d};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
2
|
import{na as l,ra as c}from"./chunk-4TZHH5FC.js";import{N as n}from"./chunk-HA7EFTPF.js";import{a as t}from"./chunk-FTQLQJQV.js";import{mkdir as f}from"node:fs/promises";import p from"node:path";import a from"node:path";function d(e,o){let i=a.resolve(e),r=a.resolve(o);return r===i||r.startsWith(`${i}${a.sep}`)}t(d,"isHostedProfileSourceWithinRepo");async function u(e){if(!p.isAbsolute(e.repoPath)||!p.isAbsolute(e.outputDir)||!/^[a-f0-9]{40,64}$/.test(e.sourceRevision)||!e.workspaceId.trim()||!e.repositoryId.trim()||!e.profileId.trim())throw new Error("Hosted Profile compile request is invalid.");let o=await n({repoPath:e.repoPath,profileId:e.profileId});if(o.error||o.mode!=="local"||o.activeProfile!==e.profileId||!o.sourcePath||!d(e.repoPath,o.sourcePath))throw new Error("Hosted Profile source is unavailable.");await f(e.outputDir,{recursive:!0});let i=await l({storeDir:e.outputDir,workspaceId:e.workspaceId,name:e.profileId,profile:o,sourceRevision:e.sourceRevision,repositoryId:e.repositoryId}),r=i.harnessRelease.metadata.profile;if(!r||typeof r!="object"||r.id!==e.profileId||r.sourceRevision!==e.sourceRevision||r.repositoryId!==e.repositoryId)throw new Error("Hosted Profile release provenance is invalid.");let s=await c({storeDir:e.outputDir,workspaceId:e.workspaceId,compiled:i,createdAt:new Date().toISOString()});return{workspaceId:e.workspaceId,sourceRevision:s.sourceRevision,harnessRelease:s.harnessRelease,agentSnapshot:s.agentSnapshot,bundlePath:s.bundlePath}}t(u,"compileHostedProfileRelease");async function H(e){if(e.length!==1||e[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(e[0]))throw new Error("Hosted Profile compile argument is invalid.");let o=JSON.parse(Buffer.from(e[0],"base64url").toString("utf8")),i=await u(o);process.stdout.write(`${JSON.stringify(i)}
|
|
3
|
-
`)}t(H,"runHostedProfileCompilerCli");async function y(e){await(await import("./hosted-profile-evaluation-preparation-
|
|
3
|
+
`)}t(H,"runHostedProfileCompilerCli");async function y(e){await(await import("./hosted-profile-evaluation-preparation-ZD4FM3FD.js")).runHostedProfileEvaluationCli(e)}t(y,"runHostedProfileEvaluationCli");async function k(e){await(await import("./hosted-profile-evaluation-inspection-OC4XNGL2.js")).runHostedProfileInspectionCli(e)}t(k,"runHostedProfileInspectionCli");export{u as a,H as b,y as c,k as d};
|
package/dist/chunks/{hosted-profile-compiler-OZAOZ2ES.js → hosted-profile-compiler-SCVJI2CP.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-UE3DMPGM.js";import"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import"./chunk-5CMKGD43.js";import"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import"./chunk-7QEE4PBI.js";import"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as compileHostedProfileRelease,b as runHostedProfileCompilerCli,c as runHostedProfileEvaluationCli,d as runHostedProfileInspectionCli};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{c as R,d as P}from"./chunk-
|
|
2
|
+
import{c as R,d as P}from"./chunk-4EEH7MEC.js";import{a as E}from"./chunk-4SHKI3BH.js";import{L as v,M as S,N as w,Y as y,a as h}from"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import{k as g}from"./chunk-WV2APYWG.js";import{h as m}from"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import{b as s}from"./chunk-ES2ISFJC.js";import{a as n}from"./chunk-FTQLQJQV.js";var I=s.object({profileRef:v,inspection:R,run:E.nullable(),receipts:s.array(g).max(1e4),grades:s.array(m).max(1e4),sessions:s.array(S).max(1e4),turns:s.array(w).max(1e4),events:s.array(h).max(1e4),usage:s.array(y).max(1e4)}).strict();async function x(c){let t=I.parse(c),o=n((e,i)=>{let f=new Map;for(let p of e){let d=i(p);if(f.has(d))throw new Error("Hosted evaluation inspection has duplicate evidence identities.");f.set(d,p)}return f},"map"),r=o(t.receipts,e=>e.id),u=o(t.grades,e=>e.contentHash),l=o(t.sessions,e=>e.id),a=o(t.turns,e=>e.id);return P({profileRef:t.profileRef,...t.inspection,store:{getProfileEvaluationRun:n(async e=>t.run?.manifest.id===e?t.run:null,"getProfileEvaluationRun"),getProfileEvaluationReceipt:n(async e=>r.get(e)??null,"getProfileEvaluationReceipt"),getProfileEvaluationGrade:n(async e=>u.get(e)??null,"getProfileEvaluationGrade"),getSession:n(async e=>l.get(e)??null,"getSession"),getTurn:n(async e=>a.get(e)??null,"getTurn"),runtimeEventsForTurn:n(async e=>t.events.filter(i=>i.turnId===e),"runtimeEventsForTurn"),listModelUsageRecords:n(async e=>t.usage.filter(i=>(!e?.sessionId||i.sessionId===e.sessionId)&&(!e?.turnId||i.turnId===e.turnId)),"listModelUsageRecords")}})}n(x,"inspectHostedProfileEvaluation");async function B(c){if(c.length!==0)throw new Error("Hosted evaluation inspection uses bounded standard input.");let t=[],o=0;for await(let l of process.stdin){let a=Buffer.from(l);if(o+=a.length,o>32*1024*1024)throw new Error("Hosted evaluation inspection input is too large.");t.push(a)}let r=JSON.parse(Buffer.concat(t).toString("utf8")),u=r.action==="compare"||r.action==="report"?await(await import("./hosted-profile-evaluation-control-RJ6XJZCS.js")).controlHostedProfileEvaluation(r):await x(r);process.stdout.write(`${JSON.stringify(u)}
|
|
3
3
|
`)}n(B,"runHostedProfileInspectionCli");export{x as inspectHostedProfileEvaluation,B as runHostedProfileInspectionCli};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as V}from"./chunk-
|
|
2
|
+
import{a as V}from"./chunk-UE3DMPGM.js";import{c as I,f as j,h as D}from"./chunk-5TNDPNS3.js";import{k as x}from"./chunk-6VF3Q6QJ.js";import{a as E}from"./chunk-T5LE6R5S.js";import"./chunk-USKE34VR.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-7ZG3IT7C.js";import{ha as b,qa as C}from"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import"./chunk-5CMKGD43.js";import"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import"./chunk-7QEE4PBI.js";import"./chunk-2JO2KWT3.js";import{ta as m}from"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import{Ca as S}from"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import{ma as H}from"./chunk-PJM2G7SG.js";import{Ga as y,j as P,m as R}from"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import{m as d}from"./chunk-NNF6KCHD.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as s}from"./chunk-FTQLQJQV.js";import{readFile as h,realpath as z,lstat as T}from"node:fs/promises";import l from"node:path";var B=e.object({compile:e.object({repoPath:e.string(),profileId:e.string(),repositoryId:e.string(),sourceRevision:e.string(),workspaceId:e.string(),outputDir:e.string()}).strict(),externalDatasetPackage:e.string().regex(/^external-dataset-[a-f0-9-]+\.json$/).optional(),sourceCandidate:H.optional(),action:e.enum(["catalog","prepare"]),request:e.unknown().optional()}).strict();async function G(t){let o=await V(t.compile);if(t.sourceCandidate){let a=await C({workspaceId:typeof o.agentSnapshot.metadata.workspaceId=="string"?o.agentSnapshot.metadata.workspaceId:o.workspaceId,sourceDir:l.join(o.bundlePath,"source")});if(d(t.sourceCandidate.harnessRelease)!==d({id:o.harnessRelease.id,contentHash:o.harnessRelease.contentHash})||E(a).protectedClosureHash!==t.sourceCandidate.protectedClosureHash)throw new Error("Private candidate source differs from its actual frozen compiled release.")}let g={release:b.parse({schemaVersion:"openpond.localHarnessReleaseRecord.v1",workspaceId:o.workspaceId,sourceRevision:o.sourceRevision,agentSnapshot:P.parse(o.agentSnapshot),harnessRelease:R.parse(o.harnessRelease),bundlePath:o.bundlePath,createdAt:new Date().toISOString()})},p={source:"openpond_git",profileId:t.compile.profileId,repositoryId:t.compile.repositoryId},f=t.compile.sourceRevision,c={id:o.harnessRelease.id,contentHash:o.harnessRelease.contentHash},w=s(async a=>x({...a,runtime:g}),"loadCatalog"),q=await w({ref:p,sourceRevision:f,harnessRelease:c}),k=l.join(o.bundlePath,"source"),v=o.harnessRelease.files.some(a=>a.path==="workflows/catalog.json")?await(async()=>{let a=y({agentSnapshot:o.agentSnapshot,harnessRelease:o.harnessRelease,catalogBytes:await h(l.join(k,"workflows/catalog.json")),actionBytes:await h(l.join(k,"workflows/actions.json"))});return a.catalog.workflows.map(r=>({workflow:r,binding:{schemaVersion:"openpond.profileWorkflowBinding.v1",profileId:p.profileId,sourceRevision:f,harnessRelease:c,catalogHash:a.catalogHash,workflowId:r.id}}))})():[],A={profileRef:p,sourceRevision:f,harnessRelease:c,workflows:v};if(t.action==="catalog")return{...q,workflows:v};let u=t.externalDatasetPackage?await(async()=>{let a=await z(t.compile.outputDir),r=l.join(a,t.externalDatasetPackage),i=await T(r);if(!i.isFile()||i.isSymbolicLink()||i.size>32*1024*1024||await z(r)!==r)throw new Error("External Dataset cache is outside its bounded verifier storage.");let n=e.object({packageValue:e.unknown(),graders:e.array(e.object({id:e.string(),version:e.string(),contentHash:e.string(),feedbackKey:e.string(),release:e.object({id:e.string(),revision:e.union([e.string(),e.number()]),contentHash:e.string()}).strict().nullable()}).strict()).max(100)}).strict().parse(JSON.parse(await h(r,"utf8")));return{packageValue:S(n.packageValue),graders:n.graders}})():null;return D({privateGradingPreflight:s(a=>I(a,!1),"privateGradingPreflight"),sourceCandidate:t.sourceCandidate,resolveExternalDataset:u?async a=>{let r=m({binding:a,...u}),i=d(o.harnessRelease.files.filter(n=>n.visibility!=="policy").map(n=>({path:n.path,asset:n})));if(a.protectedProfileClosureHash!==i)throw new Error("The selected Profile's protected evaluator closure changed.");return{binding:a,packageValue:r,authorize:s(async()=>{m({binding:a,...u})},"authorize")}}:void 0,loadCatalog:w,selectedWorkflows:s(async()=>A,"selectedWorkflows"),placement:"remote",boundedWorkComputeAvailable:!0,loadTasksetPackage:s(async a=>{let r=await j({runtime:g,definition:a,harnessRelease:c});if(!r)throw new Error("Hosted evaluation Taskset is absent from its published Profile release.");return r},"loadTasksetPackage"),modelConfigurationHash:s(async(a,r)=>{if(a.providerId!=="openpond"||!r.hostModelConfigurationHash)throw new Error("Hosted evaluation preparation requires a trusted model configuration receipt.");return r.hostModelConfigurationHash},"modelConfigurationHash")})(t.request)}s(G,"prepareHostedProfileEvaluation");async function ae(t){if(t.length!==1||t[0].length>48e3||!/^[A-Za-z0-9_-]+$/.test(t[0]))throw new Error("Hosted Profile evaluation preparation argument is invalid.");let o=B.parse(JSON.parse(Buffer.from(t[0],"base64url").toString("utf8")));process.stdout.write(`${JSON.stringify(await G(o))}
|
|
3
3
|
`)}s(ae,"runHostedProfileEvaluationCli");export{G as prepareHostedProfileEvaluation,ae as runHostedProfileEvaluationCli};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
3
|
-
import{a as QC,b as WA,c as VA,d as GA,e as XA,f as QA,g as ZA,h as e0,i as t0,j as r0}from"./chunk-YD55Z5H3.js";import{a as _t,b as wd,c as Zn,d as om,e as am,f as zo}from"./chunk-H2VT22JK.js";import{a as wj,b as yj,c as vj,d as H,e as bj,f as Jo,g as W,h as km,j as kj}from"./chunk-6JAN4RMN.js";import{$ as Wo,$a as AM,$b as za,A as g0,Aa as iM,Ab as QM,B as h0,Ba as sM,Bb as ZM,C as w0,Ca as cM,Cb as Uy,D as y0,Da as dM,Db as ej,E as v0,Ea as lM,Eb as tj,F as b0,Fa as uM,Fb as rj,G as P0,Ga as pM,Gb as nj,H as R0,Ha as mM,Hb as oj,I as ws,Ia as fM,Ib as Go,J as ys,Ja as gM,Jb as to,K as x0,Ka as Dr,Kb as qy,L as lm,La as Lr,Lb as aj,M as _0,Ma as Se,Mb as ij,N as T0,Na as hM,Nb as Fy,O as um,Oa as wM,Ob as sj,P as E0,Pa as yM,Pb as cj,Q as C0,Qa as vM,Qb as dj,R as A0,Ra as IM,Rb as Fa,S as M0,Sa as SM,Sb as lj,T as j0,Ta as PM,Tb as Br,U as H0,Ua as RM,Ub as wm,V as O0,Va as xM,Vb as bs,W as D0,Wa as _M,Wb as uj,X as Id,Xa as $y,Xb as ym,Y as L0,Ya as TM,Yb as vm,Z as B0,Za as EM,Zb as bm,_ as $0,_a as CM,_b as cn,a as o0,aa as N0,ab as MM,ac as zy,b as im,ba as U0,bb as jM,bc as Wy,c as sm,ca as q0,cb as HM,cc as Sd,d as cm,da as F0,db as sn,dc as Vy,e as a0,ea as z0,eb as OM,ec as pj,f as i0,fa as W0,fb as hm,fc as mj,g as s0,ga as V0,gb as DM,gc as fj,h as c0,ha as G0,hb as LM,hc as gj,i as Oy,ia as vs,ib as er,j as Ua,ja as J0,jb as qa,jc as hj,k as Dy,ka as K0,kb as BM,l as yd,la as Y0,lb as eo,m as vd,ma as X0,mb as $M,n as hs,na as pm,nb as NM,o as dm,oa as Q0,ob as UM,p as Ly,pa as Z0,pb as qM,q as bd,qa as eM,qb as FM,r as d0,ra as tM,rb as zM,s as se,sa as rM,sb as WM,t as l0,ta as mm,tb as Ny,u as kd,ua as nM,ub as VM,v as u0,va as Vo,vb as GM,w as p0,wa as je,wb as JM,x as nJ,xa as oM,xb as KM,y as m0,ya as we,yb as YM,z as f0,za as aM,zb as XM}from"./chunk-XGE2XI6M.js";import{A as cA,B as Xn,C as Vp,D as dA,E as Uo,F as Gp,G as lA,Ga as Cy,Ha as Ay,K as uA,La as OA,M as pA,N as mA,Na as DA,O as Jp,Oa as LA,P as Kp,Q as fA,Qa as My,Ra as BA,S as Z,Sa as $A,T as Yp,U as Xp,Ua as NA,V as qo,Va as jy,W as gA,X as hA,Xa as UA,Ya as qA,Za as FA,_a as zA,a as Hw,ab as nm,b as hR,ba as wA,c as wR,ca as Fo,d as yR,e as vR,ea as yA,f as bR,fa as vA,fb as KA,g as kR,ga as xy,gb as Qn,h as xa,hb as YA,i as IR,j as SR,k as Au,l as PR,m as RR,ob as n0,p as YC,pa as jA,pb as Hy,q as qp,u as XC,ua as HA,v as fs,y as Wp,ya as rm,z as Cn}from"./chunk-NHFGEVVH.js";import{b as JA}from"./chunk-EMKZVP7Z.js";import{a as Ye,b as k0,c as I0,d as S0,h as By,i as bM,j as fm,k as gm,l as kM}from"./chunk-PQHTZ5CP.js";import"./chunk-GCOUYYHG.js";import{a as Zt,b as ZC,c as eA,d as Fp,e as zp,g as tA,h as No,j as rA,k as nA,l as oA,m as aA,n as iA,o as sA}from"./chunk-FPUUZQUP.js";import{a as $C,d as NC,e as $a,h as VC}from"./chunk-5TNDPNS3.js";import{f as Bp,i as BC,j as an}from"./chunk-6VF3Q6QJ.js";import{a as on,b as $p,c as Py,d as UC}from"./chunk-T5LE6R5S.js";import{d as qC,e as FC,f as zC,g as Np,h as WC}from"./chunk-USKE34VR.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{d as LC}from"./chunk-7ZG3IT7C.js";import{a as Up,b as KC,c as Ry}from"./chunk-XM26DGML.js";import{c as GC,d as JC}from"./chunk-AFUDIT36.js";import{$ as fd,A as _C,B as TC,C as EC,R as Hp,U as Op,X as CC,Y as AC,Z as ps,_ as Dp,ba as gd,ca as Ba,da as MC,ea as jC,fa as HC,ga as Lp,h as gC,ma as OC,na as DC,o as Yn,p as yC,q as vC,qa as ms,r as bC,ra as Sy,s as kC,t as IC,u as SC,v as PC,w as RC,x as xC,y as md,z as $o}from"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import{A as RA,C as em,F as tm,G as An,H as xA,I as _y,J as _A,K as Ty,N as TA,O as Ey,P as EA,Q as CA,R as AA,S as MA,T as Na,b as Qp,d as bA,e as kA,h as IA,m as gs,n as SA,p as Zp,q as PA,s as hd}from"./chunk-USMZT5FZ.js";import{a as hC,b as jp,d as de,e as ft,f as us,g as ae,i as wC}from"./chunk-5CMKGD43.js";import"./chunk-XEOEKFG6.js";import{A as aC,B as Ap,C as iC,D as Iy,E as sC,F as cC,G as xt,H as dC,I as Je,J as tt,K as lC,L as uC,M as pd,N as Mp,O as pC,Q as mC,R as fC,S as nn,c as GE,l as JE,m as KE,n as YE,r as XE,s as QE,t as ZE,u as eC,v as ky,w as tC,x as rC,y as nC,z as oC}from"./chunk-HA7EFTPF.js";import{b as WE,c as VE}from"./chunk-L3KS6MOV.js";import{a as qE,d as FE,f as zE}from"./chunk-7QEE4PBI.js";import{$ as C_,$a as sT,$b as VT,$c as mE,Aa as Q_,Ab as ET,Ba as ay,Bb as CT,Ca as up,Cb as AT,Da as Z_,Ea as rn,Eb as hp,F as k_,Fa as pp,Fb as DT,Ga as iy,H as I_,Ha as mp,Hb as LT,I as oy,Ib as od,Ja as fp,Jb as fy,Jd as PE,K as Ke,Ka as td,L as Jn,Ld as ME,M as ns,Ma as eT,Mb as wp,Mc as Da,Md as dd,N as S_,Nc as iE,Nd as jE,Ob as gy,Oc as Kn,Od as ld,P as P_,Pa as tT,Pb as BT,Pc as sE,Pd as HE,Qa as rT,Qb as $T,Qc as cE,Qd as by,Ra as nT,Rc as dE,Rd as OE,Sc as Lo,Sd as ud,T as R_,Ta as os,Tb as yp,Tc as ds,Td as DE,Ua as oT,Ub as NT,Uc as Sp,Ud as Ep,V as cp,Vb as hy,Vc as lE,Vd as LE,W as x_,Wa as rd,Wb as Tn,Wc as uE,Wd as BE,Xa as gp,Xb as UT,Xc as pE,Xd as $E,Y as __,Ya as aT,Yb as qT,Yc as sd,Yd as NE,Z as T_,Za as sy,Zb as wy,Zc as ls,Zd as Cp,_ as E_,_a as iT,_b as id,_c as Pp,_d as UE,aa as A_,ab as cy,ac as kp,ad as Rp,ba as M_,bb as cT,bc as GT,bd as Bo,ca as j_,cb as dT,cc as JT,cd as fE,d as c_,da as dp,db as lT,dc as ss,dd as gE,ea as H_,eb as uT,ec as KT,ed as hE,f as ap,fa as _n,fb as pT,fc as Ip,fd as xp,gb as mT,gc as YT,gd as wE,h as p_,ha as O_,hb as fT,hc as XT,hd as cd,ia as D_,ib as dy,ic as yy,id as yE,ja as L_,jb as gT,jd as vE,k as ry,ka as B_,kb as hT,kc as QT,l as f_,lb as wT,lc as zt,m as Qt,ma as $_,mb as yT,n as ja,na as lp,nb as ly,nc as ZT,o as Ha,oa as N_,ob as vT,oc as eE,p as ny,pa as U_,pb as bT,pc as tE,q as g_,qa as q_,qb as kT,qc as vy,r as h_,ra as F_,rb as IT,rc as rE,s as w_,sa as z_,sb as ST,sc as nE,sd as _p,t as y_,ta as W_,tb as PT,tc as oE,td as bE,u as v_,ua as V_,ub as RT,ud as kE,v as b_,va as G_,vb as xT,vc as cs,vd as En,w as ip,wa as J_,wb as _T,wc as aE,wd as IE,xa as K_,xb as TT,xd as La,y as sp,ya as Y_,yb as uy,yd as SE,za as X_,zb as Oa}from"./chunk-2JO2KWT3.js";import{M as as,N as nd,O as jT,P as HT,Q as OT,S as py,U as my,V as ad,aa as FT,da as zT,e as a_,ga as is,ha as WT,i as i_,j as s_,ja as vp,k as d_,l as l_,m as Hr,n as np,na as bp,pa as RE,q as Ma,qa as Or,r as ed,ra as xE,s as ty,sa as _E,t as op,ta as Tp,u as u_,ua as TE,y as m_}from"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import{$b as Yx,Aa as Uu,Ab as zx,Ac as CE,Ba as Ax,Ca as Ue,Cb as Wx,D as Uw,Dc as AE,Ea as Mx,Fb as Yu,G as xn,Ha as jx,Hb as Xu,Ia as Xt,Ib as Qu,Jb as ts,Kb as Vw,Lb as Gw,Mb as Zu,Nb as Jw,Ob as Kw,Pb as Yw,Q as hx,Qa as Ho,Qb as Xw,R as wx,Ra as Hx,Rb as Qw,S as yx,Sa as qu,Sb as Zw,T as vx,Ta as tn,Tb as Vx,U as bx,Ub as Gx,V as Nu,Va as Fu,Vb as rs,W as qw,Wb as Jx,X as kx,Xb as Kx,Y as Ix,Yb as ep,Z as Sx,Zb as tp,_b as rp,a as Bu,ac as ey,b as Aa,bc as Xx,ca as Px,d as ux,db as zu,dc as Qx,ea as Zi,eb as Fw,ec as Zx,fb as Ox,fc as e_,ga as Rx,gb as Dx,gc as t_,h as px,hb as Wu,hc as r_,ia as xx,ib as Lx,ic as Oo,j as $w,jb as Vu,jc as n_,k as Ft,ka as _x,kc as o_,l as Yc,lb as es,lc as dr,m as jr,ma as Tx,mb as Bx,mc as MT,na as Ex,nb as $x,ob as Gu,pb as Ju,pc as Do,q as mx,qb as zw,rb as Ww,sb as Nx,t as Xc,tc as EE,u as fx,ua as Cx,ub as Ux,v as $u,vb as qx,x as gx,xa as jo,xb as Ku,y as Nw,ya as Qc,yb as Fx,z as Mo}from"./chunk-QRWPEW3Z.js";import{a as Zc}from"./chunk-6FA3GG5B.js";import{b as hu,e as bP,f as kP,g as IP,l as Vi,m as SP,n as PP,p as RP,q as wu,r as yu}from"./chunk-PYABBF53.js";import{b as lR,c as pR}from"./chunk-YL6VFJ4P.js";import{j as lx}from"./chunk-Z3D4C7BG.js";import{A as uR,D as mR,K as fR,V as gR,Y as xR,Z as Mu,aa as Ow,ba as _R,ca as TR,da as ER,ea as ju,fa as CR,ga as AR,ha as MR,i as GP,ia as jR,k as Gi,n as JP,o as Tu,t as KP}from"./chunk-WV2APYWG.js";import{$ as DP,Aa as qP,B as CP,Bd as dR,C as AP,Da as _u,G as Rw,H as xw,I as _w,J as Tw,Jb as rR,K as Ew,Ka as FP,L as Cw,La as zP,Lb as Eu,M as Aw,Ma as WP,N as Mw,Na as VP,Q as MP,Qa as YP,Ta as XP,U as jP,Uc as nR,Va as QP,Vc as Ao,W as HP,Wa as ZP,Wc as Ze,Xc as oR,Y as OP,_ as Pu,_c as aR,a as xe,aa as LP,b as Co,ba as BP,ea as Ru,g as xP,ga as Gc,gd as Ji,hd as Vn,i as _P,id as Ki,ja as $P,la as Mr,n as TP,nd as iR,o as vu,p as bu,pa as xu,pb as eR,pd as sR,q as ku,qa as NP,r as Iu,u as Su,ua as jw,ud as cR,v as Pw,vb as Oe,w as Pa,wb as mt,x as Ra,ya as UP,yb as tR,z as EP,zc as Cu}from"./chunk-PJM2G7SG.js";import{Ba as wP,Ia as rJ,Ja as yP,Ka as Iw,La as Sw,Na as vP,S as kw,ra as hP,sa as Eo,xa as gu}from"./chunk-SDEDAHV6.js";import{C as ex,D as tx,I as nx,K as Lw,L as Bw,M as ox,Z as ax,_ as ix,ca as sx,da as cx,f as BR,fa as Ca,ga as dx,ha as Lu,v as Xi,x as Kc}from"./chunk-DALJMSJG.js";import{H as KR,L as Yi,N as YR,P as XR,Q as QR,R as ZR,a as Ta,b as $R,c as Jc,d as Gn,e as NR,f as UR,g as qR,h as FR,i as Hu,k as zR,l as WR,m as VR,n as GR,o as JR,y as Dw}from"./chunk-TGIB24K4.js";import{b as zi,c as Wi,d as vw,e as pu,f as pt,g as bw,h as fP,k as Ge,l as ke,m as E,n as mu,p as gP,q as fu,r as qt}from"./chunk-NNF6KCHD.js";import{a as Rt,b}from"./chunk-ES2ISFJC.js";import{a as HR,c as _a,f as OR,h as DR,i as LR,n as Ou,p as Qi,q as rx,r as Ea,s as Du}from"./chunk-H7IWJN7L.js";import{a as i,b as Ee,c as Me,e as en}from"./chunk-FTQLQJQV.js";var yo=Me((IFe,gU)=>{"use strict";var mU=["nodebuffer","arraybuffer","fragments"],fU=typeof Blob<"u";fU&&mU.push("blob");gU.exports={BINARY_TYPES:mU,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:fU,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:i(()=>{},"NOOP")}});var wl=Me((PFe,Rg)=>{"use strict";var{EMPTY_BUFFER:ZZ}=yo(),hk=Buffer[Symbol.species];function eee(e,t){if(e.length===0)return ZZ;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),n=0;for(let o=0;o<e.length;o++){let a=e[o];r.set(a,n),n+=a.length}return n<t?new hk(r.buffer,r.byteOffset,n):r}i(eee,"concat");function hU(e,t,r,n,o){for(let a=0;a<o;a++)r[n+a]=e[a]^t[a&3]}i(hU,"_mask");function wU(e,t){for(let r=0;r<e.length;r++)e[r]^=t[r&3]}i(wU,"_unmask");function tee(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}i(tee,"toArrayBuffer");function wk(e){if(wk.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new hk(e):ArrayBuffer.isView(e)?t=new hk(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),wk.readOnly=!1),t}i(wk,"toBuffer");Rg.exports={concat:eee,mask:hU,toArrayBuffer:tee,toBuffer:wk,unmask:wU};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=Ee("bufferutil");Rg.exports.mask=function(t,r,n,o,a){a<48?hU(t,r,n,o,a):e.mask(t,r,n,o,a)},Rg.exports.unmask=function(t,r){t.length<32?wU(t,r):e.unmask(t,r)}}catch{}});var bU=Me((xFe,vU)=>{"use strict";var yU=Symbol("kDone"),yk=Symbol("kRun"),vk=class{static{i(this,"Limiter")}constructor(t){this[yU]=()=>{this.pending--,this[yk]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[yk]()}[yk](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[yU])}}};vU.exports=vk});var pc=Me((TFe,PU)=>{"use strict";var yl=Ee("zlib"),kU=wl(),ree=bU(),{kStatusCode:IU}=yo(),nee=Buffer[Symbol.species],oee=Buffer.from([0,0,255,255]),_g=Symbol("permessage-deflate"),vo=Symbol("total-length"),lc=Symbol("callback"),ua=Symbol("buffers"),uc=Symbol("error"),xg,bk=class{static{i(this,"PerMessageDeflate")}constructor(t){if(this._options=t||{},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,!xg){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;xg=new ree(r)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[lc];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let r=this._options,n=t.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(t){let r=t[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(t){return t.forEach(r=>{Object.keys(r).forEach(n=>{let o=r[n];if(o.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(o=o[0],n==="client_max_window_bits"){if(o!==!0){let a=+o;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${n}": ${o}`);o=a}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else if(n==="server_max_window_bits"){let a=+o;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${n}": ${o}`);o=a}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=o})}),t}decompress(t,r,n){xg.add(o=>{this._decompress(t,r,(a,s)=>{o(),n(a,s)})})}compress(t,r,n){xg.add(o=>{this._compress(t,r,(a,s)=>{o(),n(a,s)})})}_decompress(t,r,n){let o=this._isServer?"client":"server";if(!this._inflate){let a=`${o}_max_window_bits`,s=typeof this.params[a]!="number"?yl.Z_DEFAULT_WINDOWBITS:this.params[a];this._inflate=yl.createInflateRaw({...this._options.zlibInflateOptions,windowBits:s}),this._inflate[_g]=this,this._inflate[vo]=0,this._inflate[ua]=[],this._inflate.on("error",iee),this._inflate.on("data",SU)}this._inflate[lc]=n,this._inflate.write(t),r&&this._inflate.write(oee),this._inflate.flush(()=>{let a=this._inflate[uc];if(a){this._inflate.close(),this._inflate=null,n(a);return}let s=kU.concat(this._inflate[ua],this._inflate[vo]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[vo]=0,this._inflate[ua]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,s)})}_compress(t,r,n){let o=this._isServer?"server":"client";if(!this._deflate){let a=`${o}_max_window_bits`,s=typeof this.params[a]!="number"?yl.Z_DEFAULT_WINDOWBITS:this.params[a];this._deflate=yl.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:s}),this._deflate[vo]=0,this._deflate[ua]=[],this._deflate.on("data",aee)}this._deflate[lc]=n,this._deflate.write(t),this._deflate.flush(yl.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let a=kU.concat(this._deflate[ua],this._deflate[vo]);r&&(a=new nee(a.buffer,a.byteOffset,a.length-4)),this._deflate[lc]=null,this._deflate[vo]=0,this._deflate[ua]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),n(null,a)})}};PU.exports=bk;function aee(e){this[ua].push(e),this[vo]+=e.length}i(aee,"deflateOnData");function SU(e){if(this[vo]+=e.length,this[_g]._maxPayload<1||this[vo]<=this[_g]._maxPayload){this[ua].push(e);return}this[uc]=new RangeError("Max payload size exceeded"),this[uc].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[uc][IU]=1009,this.removeListener("data",SU),this.reset()}i(SU,"inflateOnData");function iee(e){if(this[_g]._inflate=null,this[uc]){this[lc](this[uc]);return}e[IU]=1007,this[lc](e)}i(iee,"inflateOnError")});var mc=Me((CFe,Tg)=>{"use strict";var{isUtf8:RU}=Ee("buffer"),{hasBlob:see}=yo(),cee=[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 dee(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}i(dee,"isValidStatusCode");function kk(e){let t=e.length,r=0;for(;r<t;)if((e[r]&128)===0)r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return!1;r+=2}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return!1;r+=3}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return!1;r+=4}else return!1;return!0}i(kk,"_isValidUTF8");function lee(e){return see&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}i(lee,"isBlob");Tg.exports={isBlob:lee,isValidStatusCode:dee,isValidUTF8:kk,tokenChars:cee};if(RU)Tg.exports.isValidUTF8=function(e){return e.length<24?kk(e):RU(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=Ee("utf-8-validate");Tg.exports.isValidUTF8=function(t){return t.length<32?kk(t):e(t)}}catch{}});var xk=Me((MFe,MU)=>{"use strict";var{Writable:uee}=Ee("stream"),xU=pc(),{BINARY_TYPES:pee,EMPTY_BUFFER:_U,kStatusCode:mee,kWebSocket:fee}=yo(),{concat:Ik,toArrayBuffer:gee,unmask:hee}=wl(),{isValidStatusCode:wee,isValidUTF8:TU}=mc(),Eg=Buffer[Symbol.species],Wr=0,EU=1,CU=2,AU=3,Sk=4,Pk=5,Cg=6,Rk=class extends uee{static{i(this,"Receiver")}constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||pee[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxBufferedChunks=t.maxBufferedChunks|0,this._maxFragments=t.maxFragments|0,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[fee]=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=Wr}_write(t,r,n){if(this._opcode===8&&this._state==Wr)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(n)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new Eg(n.buffer,n.byteOffset+t,n.length-t),new Eg(n.buffer,n.byteOffset,t)}let r=Buffer.allocUnsafe(t);do{let n=this._buffers[0],o=r.length-t;t>=n.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,t),o),this._buffers[0]=new Eg(n.buffer,n.byteOffset+t,n.length-t)),t-=n.length}while(t>0);return r}startLoop(t){this._loop=!0;do switch(this._state){case Wr:this.getInfo(t);break;case EU:this.getPayloadLength16(t);break;case CU:this.getPayloadLength64(t);break;case AU:this.getMask();break;case Sk:this.getData(t);break;case Pk:case Cg:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(o);return}let n=(r[0]&64)===64;if(n&&!this._extensions[xU.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(o);return}if(n){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(o);return}this._payloadLength===126?this._state=EU:this._payloadLength===127?this._state=CU:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(o);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(t)}haveLength(t){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");t(r);return}this._masked?this._state=AU:this._state=Sk}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Sk}getData(t){let r=_U;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&&hee(r,this._mask)}if(this._opcode>7){this.controlMessage(r,t);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");t(n);return}if(this._compressed){this._state=Pk,this.decompress(r,t);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(t)}decompress(t,r){this._extensions[xU.extensionName].decompress(t,this._fin,(o,a)=>{if(o)return r(o);if(a.length){if(this._messageLength+=a.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(s);return}this._fragments.push(a)}this.dataMessage(r),this._state===Wr&&this.startLoop(r)})}dataMessage(t){if(!this._fin){this._state=Wr;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Ik(n,r):this._binaryType==="arraybuffer"?o=gee(Ik(n,r)):this._binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=Wr):(this._state=Cg,setImmediate(()=>{this.emit("message",o,!0),this._state=Wr,this.startLoop(t)}))}else{let o=Ik(n,r);if(!this._skipUTF8Validation&&!TU(o)){let a=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(a);return}this._state===Pk||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=Wr):(this._state=Cg,setImmediate(()=>{this.emit("message",o,!1),this._state=Wr,this.startLoop(t)}))}}controlMessage(t,r){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,_U),this.end();else{let n=t.readUInt16BE(0);if(!wee(n)){let a=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(a);return}let o=new Eg(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!TU(o)){let a=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(a);return}this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=Wr;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Wr):(this._state=Cg,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Wr,this.startLoop(r)}))}createError(t,r,n,o,a){this._loop=!1,this._errored=!0;let s=new t(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(s,this.createError),s.code=a,s[mee]=o,s}};MU.exports=Rk});var Ek=Me((OFe,OU)=>{"use strict";var{Duplex:HFe}=Ee("stream"),{randomFillSync:yee}=Ee("crypto"),{types:{isUint8Array:vee}}=Ee("util"),jU=pc(),{EMPTY_BUFFER:bee,kWebSocket:kee,NOOP:Iee}=yo(),{isBlob:fc,isValidStatusCode:See}=mc(),{mask:HU,toBuffer:fi}=wl(),Vr=Symbol("kByteLength"),Pee=Buffer.alloc(4),Ag=8*1024,gi,gc=Ag,hn=0,Ree=1,xee=2,_k=class e{static{i(this,"Sender")}constructor(t,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=hn,this.onerror=Iee,this[kee]=void 0}static frame(t,r){let n,o=!1,a=2,s=!1;r.mask&&(n=r.maskBuffer||Pee,r.generateMask?r.generateMask(n):(gc===Ag&&(gi===void 0&&(gi=Buffer.alloc(Ag)),yee(gi,0,Ag),gc=0),n[0]=gi[gc++],n[1]=gi[gc++],n[2]=gi[gc++],n[3]=gi[gc++]),s=(n[0]|n[1]|n[2]|n[3])===0,a=6);let c;typeof t=="string"?(!r.mask||s)&&r[Vr]!==void 0?c=r[Vr]:(t=Buffer.from(t),c=t.length):(c=t.length,o=r.mask&&r.readOnly&&!s);let d=c;c>=65536?(a+=8,d=127):c>125&&(a+=2,d=126);let l=Buffer.allocUnsafe(o?c+a:a);return l[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(c,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(c,4,6)),r.mask?(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],s?[l,t]:o?(HU(t,n,l,a,c),[l]):(HU(t,n,t,0,c),[l,t])):[l,t]}close(t,r,n,o){let a;if(t===void 0)a=bee;else{if(typeof t!="number"||!See(t))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)a=Buffer.allocUnsafe(2),a.writeUInt16BE(t,0);else{let c=Buffer.byteLength(r);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");if(a=Buffer.allocUnsafe(2+c),a.writeUInt16BE(t,0),typeof r=="string")a.write(r,2);else if(vee(r))a.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let s={[Vr]:a.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==hn?this.enqueue([this.dispatch,a,!1,s,o]):this.sendFrame(e.frame(a,s),o)}ping(t,r,n){let o,a;if(typeof t=="string"?(o=Buffer.byteLength(t),a=!1):fc(t)?(o=t.size,a=!1):(t=fi(t),o=t.length,a=fi.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let s={[Vr]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};fc(t)?this._state!==hn?this.enqueue([this.getBlobData,t,!1,s,n]):this.getBlobData(t,!1,s,n):this._state!==hn?this.enqueue([this.dispatch,t,!1,s,n]):this.sendFrame(e.frame(t,s),n)}pong(t,r,n){let o,a;if(typeof t=="string"?(o=Buffer.byteLength(t),a=!1):fc(t)?(o=t.size,a=!1):(t=fi(t),o=t.length,a=fi.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let s={[Vr]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};fc(t)?this._state!==hn?this.enqueue([this.getBlobData,t,!1,s,n]):this.getBlobData(t,!1,s,n):this._state!==hn?this.enqueue([this.dispatch,t,!1,s,n]):this.sendFrame(e.frame(t,s),n)}send(t,r,n){let o=this._extensions[jU.extensionName],a=r.binary?2:1,s=r.compress,c,d;typeof t=="string"?(c=Buffer.byteLength(t),d=!1):fc(t)?(c=t.size,d=!1):(t=fi(t),c=t.length,d=fi.readOnly),this._firstFragment?(this._firstFragment=!1,s&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(s=c>=o._threshold),this._compress=s):(s=!1,a=0),r.fin&&(this._firstFragment=!0);let l={[Vr]:c,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:d,rsv1:s};fc(t)?this._state!==hn?this.enqueue([this.getBlobData,t,this._compress,l,n]):this.getBlobData(t,this._compress,l,n):this._state!==hn?this.enqueue([this.dispatch,t,this._compress,l,n]):this.dispatch(t,this._compress,l,n)}getBlobData(t,r,n,o){this._bufferedBytes+=n[Vr],this._state=xee,t.arrayBuffer().then(a=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(Tk,this,c,o);return}this._bufferedBytes-=n[Vr];let s=fi(a);r?this.dispatch(s,r,n,o):(this._state=hn,this.sendFrame(e.frame(s,n),o),this.dequeue())}).catch(a=>{process.nextTick(_ee,this,a,o)})}dispatch(t,r,n,o){if(!r){this.sendFrame(e.frame(t,n),o);return}let a=this._extensions[jU.extensionName];this._bufferedBytes+=n[Vr],this._state=Ree,a.compress(t,n.fin,(s,c)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Tk(this,d,o);return}this._bufferedBytes-=n[Vr],this._state=hn,n.readOnly=!1,this.sendFrame(e.frame(c,n),o),this.dequeue()})}dequeue(){for(;this._state===hn&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][Vr],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][Vr],this._queue.push(t)}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this._socket.uncork()):this._socket.write(t[0],r)}};OU.exports=_k;function Tk(e,t,r){typeof r=="function"&&r(t);for(let n=0;n<e._queue.length;n++){let o=e._queue[n],a=o[o.length-1];typeof a=="function"&&a(t)}}i(Tk,"callCallbacks");function _ee(e,t,r){Tk(e,t,r),e.onerror(t)}i(_ee,"onError")});var zU=Me((LFe,FU)=>{"use strict";var{kForOnEventAttribute:vl,kListener:Ck}=yo(),DU=Symbol("kCode"),LU=Symbol("kData"),BU=Symbol("kError"),$U=Symbol("kMessage"),NU=Symbol("kReason"),hc=Symbol("kTarget"),UU=Symbol("kType"),qU=Symbol("kWasClean"),bo=class{static{i(this,"Event")}constructor(t){this[hc]=null,this[UU]=t}get target(){return this[hc]}get type(){return this[UU]}};Object.defineProperty(bo.prototype,"target",{enumerable:!0});Object.defineProperty(bo.prototype,"type",{enumerable:!0});var hi=class extends bo{static{i(this,"CloseEvent")}constructor(t,r={}){super(t),this[DU]=r.code===void 0?0:r.code,this[NU]=r.reason===void 0?"":r.reason,this[qU]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[DU]}get reason(){return this[NU]}get wasClean(){return this[qU]}};Object.defineProperty(hi.prototype,"code",{enumerable:!0});Object.defineProperty(hi.prototype,"reason",{enumerable:!0});Object.defineProperty(hi.prototype,"wasClean",{enumerable:!0});var wc=class extends bo{static{i(this,"ErrorEvent")}constructor(t,r={}){super(t),this[BU]=r.error===void 0?null:r.error,this[$U]=r.message===void 0?"":r.message}get error(){return this[BU]}get message(){return this[$U]}};Object.defineProperty(wc.prototype,"error",{enumerable:!0});Object.defineProperty(wc.prototype,"message",{enumerable:!0});var bl=class extends bo{static{i(this,"MessageEvent")}constructor(t,r={}){super(t),this[LU]=r.data===void 0?null:r.data}get data(){return this[LU]}};Object.defineProperty(bl.prototype,"data",{enumerable:!0});var Tee={addEventListener(e,t,r={}){for(let o of this.listeners(e))if(!r[vl]&&o[Ck]===t&&!o[vl])return;let n;if(e==="message")n=i(function(a,s){let c=new bl("message",{data:s?a:a.toString()});c[hc]=this,Mg(t,this,c)},"onMessage");else if(e==="close")n=i(function(a,s){let c=new hi("close",{code:a,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[hc]=this,Mg(t,this,c)},"onClose");else if(e==="error")n=i(function(a){let s=new wc("error",{error:a,message:a.message});s[hc]=this,Mg(t,this,s)},"onError");else if(e==="open")n=i(function(){let a=new bo("open");a[hc]=this,Mg(t,this,a)},"onOpen");else return;n[vl]=!!r[vl],n[Ck]=t,r.once?this.once(e,n):this.on(e,n)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[Ck]===t&&!r[vl]){this.removeListener(e,r);break}}};FU.exports={CloseEvent:hi,ErrorEvent:wc,Event:bo,EventTarget:Tee,MessageEvent:bl};function Mg(e,t,r){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}i(Mg,"callListener")});var jg=Me(($Fe,WU)=>{"use strict";var{tokenChars:kl}=mc();function Bn(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}i(Bn,"push");function Eee(e){let t=Object.create(null),r=Object.create(null),n=!1,o=!1,a=!1,s,c,d=-1,l=-1,u=-1,p=0;for(;p<e.length;p++)if(l=e.charCodeAt(p),s===void 0)if(u===-1&&kl[l]===1)d===-1&&(d=p);else if(p!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let w=e.slice(d,u);l===44?(Bn(t,w,r),r=Object.create(null)):s=w,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(c===void 0)if(u===-1&&kl[l]===1)d===-1&&(d=p);else if(l===32||l===9)u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p),Bn(r,e.slice(d,u),!0),l===44&&(Bn(t,s,r),r=Object.create(null),s=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)c=e.slice(d,p),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o){if(kl[l]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1?d=p:n||(n=!0),o=!1}else if(a)if(kl[l]===1)d===-1&&(d=p);else if(l===34&&d!==-1)a=!1,u=p;else if(l===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===34&&e.charCodeAt(p-1)===61)a=!0;else if(u===-1&&kl[l]===1)d===-1&&(d=p);else if(d!==-1&&(l===32||l===9))u===-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let w=e.slice(d,u);n&&(w=w.replace(/\\/g,""),n=!1),Bn(r,c,w),l===44&&(Bn(t,s,r),r=Object.create(null),s=void 0),c=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(d===-1||a||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=p);let m=e.slice(d,u);return s===void 0?Bn(t,m,r):(c===void 0?Bn(r,m,!0):n?Bn(r,c,m.replace(/\\/g,"")):Bn(r,c,m),Bn(t,s,r)),t}i(Eee,"parse");function Cee(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(n=>[t].concat(Object.keys(n).map(o=>{let a=n[o];return Array.isArray(a)||(a=[a]),a.map(s=>s===!0?o:`${o}=${s}`).join("; ")})).join("; ")).join(", ")}).join(", ")}i(Cee,"format");WU.exports={format:Cee,parse:Eee}});var Lg=Me((FFe,nq)=>{"use strict";var Aee=Ee("events"),Mee=Ee("https"),jee=Ee("http"),JU=Ee("net"),Hee=Ee("tls"),{randomBytes:Oee,createHash:Dee}=Ee("crypto"),{Duplex:UFe,Readable:qFe}=Ee("stream"),{URL:Ak}=Ee("url"),pa=pc(),Lee=xk(),Bee=Ek(),{isBlob:$ee}=mc(),{BINARY_TYPES:VU,CLOSE_TIMEOUT:Nee,EMPTY_BUFFER:Hg,GUID:Uee,kForOnEventAttribute:Mk,kListener:qee,kStatusCode:Fee,kWebSocket:vt,NOOP:KU}=yo(),{EventTarget:{addEventListener:zee,removeEventListener:Wee}}=zU(),{format:Vee,parse:Gee}=jg(),{toBuffer:Jee}=wl(),YU=Symbol("kAborted"),jk=[8,13],ko=["CONNECTING","OPEN","CLOSING","CLOSED"],Kee=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Xe=class e extends Aee{static{i(this,"WebSocket")}constructor(t,r,n){super(),this._binaryType=VU[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Hg,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),XU(this,t,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){VU.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}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(t,r,n){let o=new Lee({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),a=new Bee(t,this._extensions,n.generateMask);this._receiver=o,this._sender=a,this._socket=t,o[vt]=this,a[vt]=this,t[vt]=this,o.on("conclude",Qee),o.on("drain",Zee),o.on("error",ete),o.on("message",tte),o.on("ping",rte),o.on("pong",nte),a.onerror=ote,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",eq),t.on("data",Dg),t.on("end",tq),t.on("error",rq),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[pa.extensionName]&&this._extensions[pa.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,r){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Pr(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ZU(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Hk(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||Hg,r,n)}pong(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Hk(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||Hg,r,n)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Hk(this,t,n);return}let o={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[pa.extensionName]||(o.compress=!1),this._sender.send(t||Hg,o,n)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Pr(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Xe,"CONNECTING",{enumerable:!0,value:ko.indexOf("CONNECTING")});Object.defineProperty(Xe.prototype,"CONNECTING",{enumerable:!0,value:ko.indexOf("CONNECTING")});Object.defineProperty(Xe,"OPEN",{enumerable:!0,value:ko.indexOf("OPEN")});Object.defineProperty(Xe.prototype,"OPEN",{enumerable:!0,value:ko.indexOf("OPEN")});Object.defineProperty(Xe,"CLOSING",{enumerable:!0,value:ko.indexOf("CLOSING")});Object.defineProperty(Xe.prototype,"CLOSING",{enumerable:!0,value:ko.indexOf("CLOSING")});Object.defineProperty(Xe,"CLOSED",{enumerable:!0,value:ko.indexOf("CLOSED")});Object.defineProperty(Xe.prototype,"CLOSED",{enumerable:!0,value:ko.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Xe.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Xe.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[Mk])return t[qee];return null},set(t){for(let r of this.listeners(e))if(r[Mk]){this.removeListener(e,r);break}typeof t=="function"&&this.addEventListener(e,t,{[Mk]:!0})}})});Xe.prototype.addEventListener=zee;Xe.prototype.removeEventListener=Wee;nq.exports=Xe;function XU(e,t,r,n){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Nee,protocolVersion:jk[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!jk.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${jk.join(", ")})`);let a;if(t instanceof Ak)a=t;else try{a=new Ak(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}a.protocol==="http:"?a.protocol="ws:":a.protocol==="https:"&&(a.protocol="wss:"),e._url=a.href;let s=a.protocol==="wss:",c=a.protocol==="ws+unix:",d;if(a.protocol!=="ws:"&&!s&&!c?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!a.pathname?d="The URL's pathname is empty":a.hash&&(d="The URL contains a fragment identifier"),d){let h=new SyntaxError(d);if(e._redirects===0)throw h;Og(e,h);return}let l=s?443:80,u=Oee(16).toString("base64"),p=s?Mee.request:jee.request,m=new Set,w;if(o.createConnection=o.createConnection||(s?Xee:Yee),o.defaultPort=o.defaultPort||l,o.port=a.port||l,o.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=a.pathname+a.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(w=new pa({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Vee({[pa.extensionName]:w.offer()})),r.length){for(let h of r){if(typeof h!="string"||!Kee.test(h)||m.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(h)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(a.username||a.password)&&(o.auth=`${a.username}:${a.password}`),c){let h=o.path.split(":");o.socketPath=h[0],o.path=h[1]}let g;if(o.followRedirects){if(e._redirects===0){e._originalIpc=c,e._originalSecure=s,e._originalHostOrSocketPath=c?o.socketPath:a.host;let h=n&&n.headers;if(n={...n,headers:{}},h)for(let[y,f]of Object.entries(h))n.headers[y.toLowerCase()]=f}else if(e.listenerCount("redirect")===0){let h=c?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:a.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!s)&&(delete o.headers.authorization,delete o.headers.cookie,h||delete o.headers.host,o.auth=void 0)}o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),g=e._req=p(o),e._redirects&&e.emit("redirect",e.url,g)}else g=e._req=p(o);o.timeout&&g.on("timeout",()=>{Pr(e,g,"Opening handshake has timed out")}),g.on("error",h=>{g===null||g[YU]||(g=e._req=null,Og(e,h))}),g.on("response",h=>{let y=h.headers.location,f=h.statusCode;if(y&&o.followRedirects&&f>=300&&f<400){if(++e._redirects>o.maxRedirects){Pr(e,g,"Maximum redirects exceeded");return}g.abort();let S;try{S=new Ak(y,t)}catch{let k=new SyntaxError(`Invalid URL: ${y}`);Og(e,k);return}XU(e,S,r,n)}else e.emit("unexpected-response",g,h)||Pr(e,g,`Unexpected server response: ${h.statusCode}`)}),g.on("upgrade",(h,y,f)=>{if(e.emit("upgrade",h),e.readyState!==Xe.CONNECTING)return;g=e._req=null;let S=h.headers.upgrade;if(S===void 0||S.toLowerCase()!=="websocket"){Pr(e,y,"Invalid Upgrade header");return}let I=Dee("sha1").update(u+Uee).digest("base64");if(h.headers["sec-websocket-accept"]!==I){Pr(e,y,"Invalid Sec-WebSocket-Accept header");return}let k=h.headers["sec-websocket-protocol"],v;if(k!==void 0?m.size?m.has(k)||(v="Server sent an invalid subprotocol"):v="Server sent a subprotocol but none was requested":m.size&&(v="Server sent no subprotocol"),v){Pr(e,y,v);return}k&&(e._protocol=k);let R=h.headers["sec-websocket-extensions"];if(R!==void 0){if(!w){Pr(e,y,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Gee(R)}catch{Pr(e,y,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(C);if(P.length!==1||P[0]!==pa.extensionName){Pr(e,y,"Server indicated an extension that was not requested");return}try{w.accept(C[pa.extensionName])}catch{Pr(e,y,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[pa.extensionName]=w}e.setSocket(y,f,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(g,e):g.end()}i(XU,"initAsClient");function Og(e,t){e._readyState=Xe.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}i(Og,"emitErrorAndClose");function Yee(e){return e.path=e.socketPath,JU.connect(e)}i(Yee,"netConnect");function Xee(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=JU.isIP(e.host)?"":e.host),Hee.connect(e)}i(Xee,"tlsConnect");function Pr(e,t,r){e._readyState=Xe.CLOSING;let n=new Error(r);Error.captureStackTrace(n,Pr),t.setHeader?(t[YU]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Og,e,n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}i(Pr,"abortHandshake");function Hk(e,t,r){if(t){let n=$ee(t)?t.size:Jee(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${e.readyState} (${ko[e.readyState]})`);process.nextTick(r,n)}}i(Hk,"sendAfterClose");function Qee(e,t){let r=this[vt];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,r._socket[vt]!==void 0&&(r._socket.removeListener("data",Dg),process.nextTick(QU,r._socket),e===1005?r.close():r.close(e,t))}i(Qee,"receiverOnConclude");function Zee(){let e=this[vt];e.isPaused||e._socket.resume()}i(Zee,"receiverOnDrain");function ete(e){let t=this[vt];t._socket[vt]!==void 0&&(t._socket.removeListener("data",Dg),process.nextTick(QU,t._socket),t.close(e[Fee])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}i(ete,"receiverOnError");function GU(){this[vt].emitClose()}i(GU,"receiverOnFinish");function tte(e,t){this[vt].emit("message",e,t)}i(tte,"receiverOnMessage");function rte(e){let t=this[vt];t._autoPong&&t.pong(e,!this._isServer,KU),t.emit("ping",e)}i(rte,"receiverOnPing");function nte(e){this[vt].emit("pong",e)}i(nte,"receiverOnPong");function QU(e){e.resume()}i(QU,"resume");function ote(e){let t=this[vt];t.readyState!==Xe.CLOSED&&(t.readyState===Xe.OPEN&&(t._readyState=Xe.CLOSING,ZU(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}i(ote,"senderOnError");function ZU(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}i(ZU,"setCloseTimer");function eq(){let e=this[vt];if(this.removeListener("close",eq),this.removeListener("data",Dg),this.removeListener("end",tq),e._readyState=Xe.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[vt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",GU),e._receiver.on("finish",GU))}i(eq,"socketOnClose");function Dg(e){this[vt]._receiver.write(e)||this.pause()}i(Dg,"socketOnData");function tq(){let e=this[vt];e._readyState=Xe.CLOSING,e._receiver.end(),this.end()}i(tq,"socketOnEnd");function rq(){let e=this[vt];this.removeListener("error",rq),this.on("error",KU),e&&(e._readyState=Xe.CLOSING,this.destroy())}i(rq,"socketOnError")});var sq=Me((VFe,iq)=>{"use strict";var WFe=Lg(),{Duplex:ate}=Ee("stream");function oq(e){e.emit("close")}i(oq,"emitClose");function ite(){!this.destroyed&&this._writableState.finished&&this.destroy()}i(ite,"duplexOnEnd");function aq(e){this.removeListener("error",aq),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}i(aq,"duplexOnError");function ste(e,t){let r=!0,n=new ate({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",i(function(a,s){let c=!s&&n._readableState.objectMode?a.toString():a;n.push(c)||e.pause()},"message")),e.once("error",i(function(a){n.destroyed||(r=!1,n.destroy(a))},"error")),e.once("close",i(function(){n.destroyed||n.push(null)},"close")),n._destroy=function(o,a){if(e.readyState===e.CLOSED){a(o),process.nextTick(oq,n);return}let s=!1;e.once("error",i(function(d){s=!0,a(d)},"error")),e.once("close",i(function(){s||a(o),process.nextTick(oq,n)},"close")),r&&e.terminate()},n._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",i(function(){n._final(o)},"open"));return}e._socket!==null&&(e._socket._writableState.finished?(o(),n._readableState.endEmitted&&n.destroy()):(e._socket.once("finish",i(function(){o()},"finish")),e.close()))},n._read=function(){e.isPaused&&e.resume()},n._write=function(o,a,s){if(e.readyState===e.CONNECTING){e.once("open",i(function(){n._write(o,a,s)},"open"));return}e.send(o,s)},n.on("end",ite),n.on("error",aq),n}i(ste,"createWebSocketStream");iq.exports=ste});var Ok=Me((JFe,cq)=>{"use strict";var{tokenChars:cte}=mc();function dte(e){let t=new Set,r=-1,n=-1,o=0;for(o;o<e.length;o++){let s=e.charCodeAt(o);if(n===-1&&cte[s]===1)r===-1&&(r=o);else if(o!==0&&(s===32||s===9))n===-1&&r!==-1&&(n=o);else if(s===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);n===-1&&(n=o);let c=e.slice(r,n);if(t.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);t.add(c),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let a=e.slice(r,o);if(t.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);return t.add(a),t}i(dte,"parse");cq.exports={parse:dte}});var gq=Me((XFe,fq)=>{"use strict";var lte=Ee("events"),Bg=Ee("http"),{Duplex:YFe}=Ee("stream"),{createHash:ute}=Ee("crypto"),dq=jg(),wi=pc(),pte=Ok(),mte=Lg(),{CLOSE_TIMEOUT:fte,GUID:gte,kWebSocket:hte}=yo(),wte=/^[+/0-9A-Za-z]{22}==$/,lq=0,uq=1,mq=2,Dk=class extends lte{static{i(this,"WebSocketServer")}constructor(t,r){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:fte,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:mte,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=Bg.createServer((n,o)=>{let a=Bg.STATUS_CODES[426];o.writeHead(426,{"Content-Length":a.length,"Content-Type":"text/plain"}),o.end(a)}),this._server.listen(t.port,t.host,t.backlog,r)):t.server&&(this._server=t.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=yte(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:i((o,a,s)=>{this.handleUpgrade(o,a,s,n)},"upgrade")})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=lq}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===mq){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(Il,this);return}if(t&&this.once("close",t),this._state!==uq)if(this._state=uq,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(Il,this):process.nextTick(Il,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Il(this)})}}shouldHandle(t){if(this.options.path){let r=t.url.indexOf("?");if((r!==-1?t.url.slice(0,r):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,r,n,o){r.on("error",pq);let a=t.headers["sec-websocket-key"],s=t.headers.upgrade,c=+t.headers["sec-websocket-version"];if(t.method!=="GET"){yi(this,t,r,405,"Invalid HTTP method");return}if(s===void 0||s.toLowerCase()!=="websocket"){yi(this,t,r,400,"Invalid Upgrade header");return}if(a===void 0||!wte.test(a)){yi(this,t,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){yi(this,t,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Sl(r,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=pte.parse(d)}catch{yi(this,t,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&u!==void 0){let m=new wi({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let w=dq.parse(u);w[wi.extensionName]&&(m.accept(w[wi.extensionName]),p[wi.extensionName]=m)}catch{yi(this,t,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:t.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(w,g,h,y)=>{if(!w)return Sl(r,g||401,h,y);this.completeUpgrade(p,a,l,t,r,n,o)});return}if(!this.options.verifyClient(m))return Sl(r,401)}this.completeUpgrade(p,a,l,t,r,n,o)}completeUpgrade(t,r,n,o,a,s,c){if(!a.readable||!a.writable)return a.destroy();if(a[hte])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>lq)return Sl(a,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ute("sha1").update(r+gte).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let p=this.options.handleProtocols?this.options.handleProtocols(n,o):n.values().next().value;p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),u._protocol=p)}if(t[wi.extensionName]){let p=t[wi.extensionName].params,m=dq.format({[wi.extensionName]:[p]});l.push(`Sec-WebSocket-Extensions: ${m}`),u._extensions=t}this.emit("headers",l,o),a.write(l.concat(`\r
|
|
3
|
+
import{a as QC,b as WA,c as VA,d as GA,e as XA,f as QA,g as ZA,h as e0,i as t0,j as r0}from"./chunk-YD55Z5H3.js";import{a as _t,b as wd,c as Zn,d as om,e as am,f as zo}from"./chunk-H2VT22JK.js";import{a as wj,b as yj,c as vj,d as H,e as bj,f as Jo,g as W,h as km,j as kj}from"./chunk-6JAN4RMN.js";import{$ as Wo,$a as AM,$b as za,A as g0,Aa as iM,Ab as QM,B as h0,Ba as sM,Bb as ZM,C as w0,Ca as cM,Cb as Uy,D as y0,Da as dM,Db as ej,E as v0,Ea as lM,Eb as tj,F as b0,Fa as uM,Fb as rj,G as P0,Ga as pM,Gb as nj,H as R0,Ha as mM,Hb as oj,I as ws,Ia as fM,Ib as Go,J as ys,Ja as gM,Jb as to,K as x0,Ka as Dr,Kb as qy,L as lm,La as Lr,Lb as aj,M as _0,Ma as Se,Mb as ij,N as T0,Na as hM,Nb as Fy,O as um,Oa as wM,Ob as sj,P as E0,Pa as yM,Pb as cj,Q as C0,Qa as vM,Qb as dj,R as A0,Ra as IM,Rb as Fa,S as M0,Sa as SM,Sb as lj,T as j0,Ta as PM,Tb as Br,U as H0,Ua as RM,Ub as wm,V as O0,Va as xM,Vb as bs,W as D0,Wa as _M,Wb as uj,X as Id,Xa as $y,Xb as ym,Y as L0,Ya as TM,Yb as vm,Z as B0,Za as EM,Zb as bm,_ as $0,_a as CM,_b as cn,a as o0,aa as N0,ab as MM,ac as zy,b as im,ba as U0,bb as jM,bc as Wy,c as sm,ca as q0,cb as HM,cc as Sd,d as cm,da as F0,db as sn,dc as Vy,e as a0,ea as z0,eb as OM,ec as pj,f as i0,fa as W0,fb as hm,fc as mj,g as s0,ga as V0,gb as DM,gc as fj,h as c0,ha as G0,hb as LM,hc as gj,i as Oy,ia as vs,ib as er,j as Ua,ja as J0,jb as qa,jc as hj,k as Dy,ka as K0,kb as BM,l as yd,la as Y0,lb as eo,m as vd,ma as X0,mb as $M,n as hs,na as pm,nb as NM,o as dm,oa as Q0,ob as UM,p as Ly,pa as Z0,pb as qM,q as bd,qa as eM,qb as FM,r as d0,ra as tM,rb as zM,s as se,sa as rM,sb as WM,t as l0,ta as mm,tb as Ny,u as kd,ua as nM,ub as VM,v as u0,va as Vo,vb as GM,w as p0,wa as je,wb as JM,x as nJ,xa as oM,xb as KM,y as m0,ya as we,yb as YM,z as f0,za as aM,zb as XM}from"./chunk-37DXASQL.js";import{A as cA,B as Xn,C as Vp,D as dA,E as Uo,F as Gp,G as lA,Ga as Cy,Ha as Ay,K as uA,La as OA,M as pA,N as mA,Na as DA,O as Jp,Oa as LA,P as Kp,Q as fA,Qa as My,Ra as BA,S as Z,Sa as $A,T as Yp,U as Xp,Ua as NA,V as qo,Va as jy,W as gA,X as hA,Xa as UA,Ya as qA,Za as FA,_a as zA,a as Hw,ab as nm,b as hR,ba as wA,c as wR,ca as Fo,d as yR,e as vR,ea as yA,f as bR,fa as vA,fb as KA,g as kR,ga as xy,gb as Qn,h as xa,hb as YA,i as IR,j as SR,k as Au,l as PR,m as RR,ob as n0,p as YC,pa as jA,pb as Hy,q as qp,u as XC,ua as HA,v as fs,y as Wp,ya as rm,z as Cn}from"./chunk-NHFGEVVH.js";import{b as JA}from"./chunk-EMKZVP7Z.js";import{a as Ye,b as k0,c as I0,d as S0,h as By,i as bM,j as fm,k as gm,l as kM}from"./chunk-PQHTZ5CP.js";import"./chunk-GCOUYYHG.js";import{a as Zt,b as ZC,c as eA,d as Fp,e as zp,g as tA,h as No,j as rA,k as nA,l as oA,m as aA,n as iA,o as sA}from"./chunk-FPUUZQUP.js";import{a as $C,d as NC,e as $a,h as VC}from"./chunk-5TNDPNS3.js";import{f as Bp,i as BC,j as an}from"./chunk-6VF3Q6QJ.js";import{a as on,b as $p,c as Py,d as UC}from"./chunk-T5LE6R5S.js";import{d as qC,e as FC,f as zC,g as Np,h as WC}from"./chunk-USKE34VR.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{d as LC}from"./chunk-7ZG3IT7C.js";import{a as Up,b as KC,c as Ry}from"./chunk-XM26DGML.js";import{c as GC,d as JC}from"./chunk-4EEH7MEC.js";import{$ as fd,A as _C,B as TC,C as EC,R as Hp,U as Op,X as CC,Y as AC,Z as ps,_ as Dp,ba as gd,ca as Ba,da as MC,ea as jC,fa as HC,ga as Lp,h as gC,ma as OC,na as DC,o as Yn,p as yC,q as vC,qa as ms,r as bC,ra as Sy,s as kC,t as IC,u as SC,v as PC,w as RC,x as xC,y as md,z as $o}from"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import{A as RA,C as em,F as tm,G as An,H as xA,I as _y,J as _A,K as Ty,N as TA,O as Ey,P as EA,Q as CA,R as AA,S as MA,T as Na,b as Qp,d as bA,e as kA,h as IA,m as gs,n as SA,p as Zp,q as PA,s as hd}from"./chunk-USMZT5FZ.js";import{a as hC,b as jp,d as de,e as ft,f as us,g as ae,i as wC}from"./chunk-5CMKGD43.js";import"./chunk-XEOEKFG6.js";import{A as aC,B as Ap,C as iC,D as Iy,E as sC,F as cC,G as xt,H as dC,I as Je,J as tt,K as lC,L as uC,M as pd,N as Mp,O as pC,Q as mC,R as fC,S as nn,c as GE,l as JE,m as KE,n as YE,r as XE,s as QE,t as ZE,u as eC,v as ky,w as tC,x as rC,y as nC,z as oC}from"./chunk-HA7EFTPF.js";import{b as WE,c as VE}from"./chunk-L3KS6MOV.js";import{a as qE,d as FE,f as zE}from"./chunk-7QEE4PBI.js";import{$ as C_,$a as sT,$b as VT,$c as mE,Aa as Q_,Ab as ET,Ba as ay,Bb as CT,Ca as up,Cb as AT,Da as Z_,Ea as rn,Eb as hp,F as k_,Fa as pp,Fb as DT,Ga as iy,H as I_,Ha as mp,Hb as LT,I as oy,Ib as od,Ja as fp,Jb as fy,Jd as PE,K as Ke,Ka as td,L as Jn,Ld as ME,M as ns,Ma as eT,Mb as wp,Mc as Da,Md as dd,N as S_,Nc as iE,Nd as jE,Ob as gy,Oc as Kn,Od as ld,P as P_,Pa as tT,Pb as BT,Pc as sE,Pd as HE,Qa as rT,Qb as $T,Qc as cE,Qd as by,Ra as nT,Rc as dE,Rd as OE,Sc as Lo,Sd as ud,T as R_,Ta as os,Tb as yp,Tc as ds,Td as DE,Ua as oT,Ub as NT,Uc as Sp,Ud as Ep,V as cp,Vb as hy,Vc as lE,Vd as LE,W as x_,Wa as rd,Wb as Tn,Wc as uE,Wd as BE,Xa as gp,Xb as UT,Xc as pE,Xd as $E,Y as __,Ya as aT,Yb as qT,Yc as sd,Yd as NE,Z as T_,Za as sy,Zb as wy,Zc as ls,Zd as Cp,_ as E_,_a as iT,_b as id,_c as Pp,_d as UE,aa as A_,ab as cy,ac as kp,ad as Rp,ba as M_,bb as cT,bc as GT,bd as Bo,ca as j_,cb as dT,cc as JT,cd as fE,d as c_,da as dp,db as lT,dc as ss,dd as gE,ea as H_,eb as uT,ec as KT,ed as hE,f as ap,fa as _n,fb as pT,fc as Ip,fd as xp,gb as mT,gc as YT,gd as wE,h as p_,ha as O_,hb as fT,hc as XT,hd as cd,ia as D_,ib as dy,ic as yy,id as yE,ja as L_,jb as gT,jd as vE,k as ry,ka as B_,kb as hT,kc as QT,l as f_,lb as wT,lc as zt,m as Qt,ma as $_,mb as yT,n as ja,na as lp,nb as ly,nc as ZT,o as Ha,oa as N_,ob as vT,oc as eE,p as ny,pa as U_,pb as bT,pc as tE,q as g_,qa as q_,qb as kT,qc as vy,r as h_,ra as F_,rb as IT,rc as rE,s as w_,sa as z_,sb as ST,sc as nE,sd as _p,t as y_,ta as W_,tb as PT,tc as oE,td as bE,u as v_,ua as V_,ub as RT,ud as kE,v as b_,va as G_,vb as xT,vc as cs,vd as En,w as ip,wa as J_,wb as _T,wc as aE,wd as IE,xa as K_,xb as TT,xd as La,y as sp,ya as Y_,yb as uy,yd as SE,za as X_,zb as Oa}from"./chunk-2JO2KWT3.js";import{M as as,N as nd,O as jT,P as HT,Q as OT,S as py,U as my,V as ad,aa as FT,da as zT,e as a_,ga as is,ha as WT,i as i_,j as s_,ja as vp,k as d_,l as l_,m as Hr,n as np,na as bp,pa as RE,q as Ma,qa as Or,r as ed,ra as xE,s as ty,sa as _E,t as op,ta as Tp,u as u_,ua as TE,y as m_}from"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import{$b as Yx,Aa as Uu,Ab as zx,Ac as CE,Ba as Ax,Ca as Ue,Cb as Wx,D as Uw,Dc as AE,Ea as Mx,Fb as Yu,G as xn,Ha as jx,Hb as Xu,Ia as Xt,Ib as Qu,Jb as ts,Kb as Vw,Lb as Gw,Mb as Zu,Nb as Jw,Ob as Kw,Pb as Yw,Q as hx,Qa as Ho,Qb as Xw,R as wx,Ra as Hx,Rb as Qw,S as yx,Sa as qu,Sb as Zw,T as vx,Ta as tn,Tb as Vx,U as bx,Ub as Gx,V as Nu,Va as Fu,Vb as rs,W as qw,Wb as Jx,X as kx,Xb as Kx,Y as Ix,Yb as ep,Z as Sx,Zb as tp,_b as rp,a as Bu,ac as ey,b as Aa,bc as Xx,ca as Px,d as ux,db as zu,dc as Qx,ea as Zi,eb as Fw,ec as Zx,fb as Ox,fc as e_,ga as Rx,gb as Dx,gc as t_,h as px,hb as Wu,hc as r_,ia as xx,ib as Lx,ic as Oo,j as $w,jb as Vu,jc as n_,k as Ft,ka as _x,kc as o_,l as Yc,lb as es,lc as dr,m as jr,ma as Tx,mb as Bx,mc as MT,na as Ex,nb as $x,ob as Gu,pb as Ju,pc as Do,q as mx,qb as zw,rb as Ww,sb as Nx,t as Xc,tc as EE,u as fx,ua as Cx,ub as Ux,v as $u,vb as qx,x as gx,xa as jo,xb as Ku,y as Nw,ya as Qc,yb as Fx,z as Mo}from"./chunk-QRWPEW3Z.js";import{a as Zc}from"./chunk-6FA3GG5B.js";import{b as hu,e as bP,f as kP,g as IP,l as Vi,m as SP,n as PP,p as RP,q as wu,r as yu}from"./chunk-PYABBF53.js";import{b as lR,c as pR}from"./chunk-YL6VFJ4P.js";import{j as lx}from"./chunk-Z3D4C7BG.js";import{A as uR,D as mR,K as fR,V as gR,Y as xR,Z as Mu,aa as Ow,ba as _R,ca as TR,da as ER,ea as ju,fa as CR,ga as AR,ha as MR,i as GP,ia as jR,k as Gi,n as JP,o as Tu,t as KP}from"./chunk-WV2APYWG.js";import{$ as DP,Aa as qP,B as CP,Bd as dR,C as AP,Da as _u,G as Rw,H as xw,I as _w,J as Tw,Jb as rR,K as Ew,Ka as FP,L as Cw,La as zP,Lb as Eu,M as Aw,Ma as WP,N as Mw,Na as VP,Q as MP,Qa as YP,Ta as XP,U as jP,Uc as nR,Va as QP,Vc as Ao,W as HP,Wa as ZP,Wc as Ze,Xc as oR,Y as OP,_ as Pu,_c as aR,a as xe,aa as LP,b as Co,ba as BP,ea as Ru,g as xP,ga as Gc,gd as Ji,hd as Vn,i as _P,id as Ki,ja as $P,la as Mr,n as TP,nd as iR,o as vu,p as bu,pa as xu,pb as eR,pd as sR,q as ku,qa as NP,r as Iu,u as Su,ua as jw,ud as cR,v as Pw,vb as Oe,w as Pa,wb as mt,x as Ra,ya as UP,yb as tR,z as EP,zc as Cu}from"./chunk-PJM2G7SG.js";import{Ba as wP,Ia as rJ,Ja as yP,Ka as Iw,La as Sw,Na as vP,S as kw,ra as hP,sa as Eo,xa as gu}from"./chunk-SDEDAHV6.js";import{C as ex,D as tx,I as nx,K as Lw,L as Bw,M as ox,Z as ax,_ as ix,ca as sx,da as cx,f as BR,fa as Ca,ga as dx,ha as Lu,v as Xi,x as Kc}from"./chunk-DALJMSJG.js";import{H as KR,L as Yi,N as YR,P as XR,Q as QR,R as ZR,a as Ta,b as $R,c as Jc,d as Gn,e as NR,f as UR,g as qR,h as FR,i as Hu,k as zR,l as WR,m as VR,n as GR,o as JR,y as Dw}from"./chunk-TGIB24K4.js";import{b as zi,c as Wi,d as vw,e as pu,f as pt,g as bw,h as fP,k as Ge,l as ke,m as E,n as mu,p as gP,q as fu,r as qt}from"./chunk-NNF6KCHD.js";import{a as Rt,b}from"./chunk-ES2ISFJC.js";import{a as HR,c as _a,f as OR,h as DR,i as LR,n as Ou,p as Qi,q as rx,r as Ea,s as Du}from"./chunk-H7IWJN7L.js";import{a as i,b as Ee,c as Me,e as en}from"./chunk-FTQLQJQV.js";var yo=Me((IFe,gU)=>{"use strict";var mU=["nodebuffer","arraybuffer","fragments"],fU=typeof Blob<"u";fU&&mU.push("blob");gU.exports={BINARY_TYPES:mU,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:fU,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:i(()=>{},"NOOP")}});var wl=Me((PFe,Rg)=>{"use strict";var{EMPTY_BUFFER:ZZ}=yo(),hk=Buffer[Symbol.species];function eee(e,t){if(e.length===0)return ZZ;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),n=0;for(let o=0;o<e.length;o++){let a=e[o];r.set(a,n),n+=a.length}return n<t?new hk(r.buffer,r.byteOffset,n):r}i(eee,"concat");function hU(e,t,r,n,o){for(let a=0;a<o;a++)r[n+a]=e[a]^t[a&3]}i(hU,"_mask");function wU(e,t){for(let r=0;r<e.length;r++)e[r]^=t[r&3]}i(wU,"_unmask");function tee(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}i(tee,"toArrayBuffer");function wk(e){if(wk.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new hk(e):ArrayBuffer.isView(e)?t=new hk(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),wk.readOnly=!1),t}i(wk,"toBuffer");Rg.exports={concat:eee,mask:hU,toArrayBuffer:tee,toBuffer:wk,unmask:wU};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=Ee("bufferutil");Rg.exports.mask=function(t,r,n,o,a){a<48?hU(t,r,n,o,a):e.mask(t,r,n,o,a)},Rg.exports.unmask=function(t,r){t.length<32?wU(t,r):e.unmask(t,r)}}catch{}});var bU=Me((xFe,vU)=>{"use strict";var yU=Symbol("kDone"),yk=Symbol("kRun"),vk=class{static{i(this,"Limiter")}constructor(t){this[yU]=()=>{this.pending--,this[yk]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[yk]()}[yk](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[yU])}}};vU.exports=vk});var pc=Me((TFe,PU)=>{"use strict";var yl=Ee("zlib"),kU=wl(),ree=bU(),{kStatusCode:IU}=yo(),nee=Buffer[Symbol.species],oee=Buffer.from([0,0,255,255]),_g=Symbol("permessage-deflate"),vo=Symbol("total-length"),lc=Symbol("callback"),ua=Symbol("buffers"),uc=Symbol("error"),xg,bk=class{static{i(this,"PerMessageDeflate")}constructor(t){if(this._options=t||{},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,!xg){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;xg=new ree(r)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[lc];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let r=this._options,n=t.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(t){let r=t[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(t){return t.forEach(r=>{Object.keys(r).forEach(n=>{let o=r[n];if(o.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(o=o[0],n==="client_max_window_bits"){if(o!==!0){let a=+o;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${n}": ${o}`);o=a}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else if(n==="server_max_window_bits"){let a=+o;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${n}": ${o}`);o=a}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=o})}),t}decompress(t,r,n){xg.add(o=>{this._decompress(t,r,(a,s)=>{o(),n(a,s)})})}compress(t,r,n){xg.add(o=>{this._compress(t,r,(a,s)=>{o(),n(a,s)})})}_decompress(t,r,n){let o=this._isServer?"client":"server";if(!this._inflate){let a=`${o}_max_window_bits`,s=typeof this.params[a]!="number"?yl.Z_DEFAULT_WINDOWBITS:this.params[a];this._inflate=yl.createInflateRaw({...this._options.zlibInflateOptions,windowBits:s}),this._inflate[_g]=this,this._inflate[vo]=0,this._inflate[ua]=[],this._inflate.on("error",iee),this._inflate.on("data",SU)}this._inflate[lc]=n,this._inflate.write(t),r&&this._inflate.write(oee),this._inflate.flush(()=>{let a=this._inflate[uc];if(a){this._inflate.close(),this._inflate=null,n(a);return}let s=kU.concat(this._inflate[ua],this._inflate[vo]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[vo]=0,this._inflate[ua]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,s)})}_compress(t,r,n){let o=this._isServer?"server":"client";if(!this._deflate){let a=`${o}_max_window_bits`,s=typeof this.params[a]!="number"?yl.Z_DEFAULT_WINDOWBITS:this.params[a];this._deflate=yl.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:s}),this._deflate[vo]=0,this._deflate[ua]=[],this._deflate.on("data",aee)}this._deflate[lc]=n,this._deflate.write(t),this._deflate.flush(yl.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let a=kU.concat(this._deflate[ua],this._deflate[vo]);r&&(a=new nee(a.buffer,a.byteOffset,a.length-4)),this._deflate[lc]=null,this._deflate[vo]=0,this._deflate[ua]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),n(null,a)})}};PU.exports=bk;function aee(e){this[ua].push(e),this[vo]+=e.length}i(aee,"deflateOnData");function SU(e){if(this[vo]+=e.length,this[_g]._maxPayload<1||this[vo]<=this[_g]._maxPayload){this[ua].push(e);return}this[uc]=new RangeError("Max payload size exceeded"),this[uc].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[uc][IU]=1009,this.removeListener("data",SU),this.reset()}i(SU,"inflateOnData");function iee(e){if(this[_g]._inflate=null,this[uc]){this[lc](this[uc]);return}e[IU]=1007,this[lc](e)}i(iee,"inflateOnError")});var mc=Me((CFe,Tg)=>{"use strict";var{isUtf8:RU}=Ee("buffer"),{hasBlob:see}=yo(),cee=[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 dee(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}i(dee,"isValidStatusCode");function kk(e){let t=e.length,r=0;for(;r<t;)if((e[r]&128)===0)r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return!1;r+=2}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return!1;r+=3}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return!1;r+=4}else return!1;return!0}i(kk,"_isValidUTF8");function lee(e){return see&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}i(lee,"isBlob");Tg.exports={isBlob:lee,isValidStatusCode:dee,isValidUTF8:kk,tokenChars:cee};if(RU)Tg.exports.isValidUTF8=function(e){return e.length<24?kk(e):RU(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=Ee("utf-8-validate");Tg.exports.isValidUTF8=function(t){return t.length<32?kk(t):e(t)}}catch{}});var xk=Me((MFe,MU)=>{"use strict";var{Writable:uee}=Ee("stream"),xU=pc(),{BINARY_TYPES:pee,EMPTY_BUFFER:_U,kStatusCode:mee,kWebSocket:fee}=yo(),{concat:Ik,toArrayBuffer:gee,unmask:hee}=wl(),{isValidStatusCode:wee,isValidUTF8:TU}=mc(),Eg=Buffer[Symbol.species],Wr=0,EU=1,CU=2,AU=3,Sk=4,Pk=5,Cg=6,Rk=class extends uee{static{i(this,"Receiver")}constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||pee[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxBufferedChunks=t.maxBufferedChunks|0,this._maxFragments=t.maxFragments|0,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[fee]=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=Wr}_write(t,r,n){if(this._opcode===8&&this._state==Wr)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(n)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new Eg(n.buffer,n.byteOffset+t,n.length-t),new Eg(n.buffer,n.byteOffset,t)}let r=Buffer.allocUnsafe(t);do{let n=this._buffers[0],o=r.length-t;t>=n.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,t),o),this._buffers[0]=new Eg(n.buffer,n.byteOffset+t,n.length-t)),t-=n.length}while(t>0);return r}startLoop(t){this._loop=!0;do switch(this._state){case Wr:this.getInfo(t);break;case EU:this.getPayloadLength16(t);break;case CU:this.getPayloadLength64(t);break;case AU:this.getMask();break;case Sk:this.getData(t);break;case Pk:case Cg:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(o);return}let n=(r[0]&64)===64;if(n&&!this._extensions[xU.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(o);return}if(n){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(o);return}this._payloadLength===126?this._state=EU:this._payloadLength===127?this._state=CU:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(o);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(t)}haveLength(t){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");t(r);return}this._masked?this._state=AU:this._state=Sk}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Sk}getData(t){let r=_U;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&&hee(r,this._mask)}if(this._opcode>7){this.controlMessage(r,t);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");t(n);return}if(this._compressed){this._state=Pk,this.decompress(r,t);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(t)}decompress(t,r){this._extensions[xU.extensionName].decompress(t,this._fin,(o,a)=>{if(o)return r(o);if(a.length){if(this._messageLength+=a.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(s);return}this._fragments.push(a)}this.dataMessage(r),this._state===Wr&&this.startLoop(r)})}dataMessage(t){if(!this._fin){this._state=Wr;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Ik(n,r):this._binaryType==="arraybuffer"?o=gee(Ik(n,r)):this._binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=Wr):(this._state=Cg,setImmediate(()=>{this.emit("message",o,!0),this._state=Wr,this.startLoop(t)}))}else{let o=Ik(n,r);if(!this._skipUTF8Validation&&!TU(o)){let a=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(a);return}this._state===Pk||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=Wr):(this._state=Cg,setImmediate(()=>{this.emit("message",o,!1),this._state=Wr,this.startLoop(t)}))}}controlMessage(t,r){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,_U),this.end();else{let n=t.readUInt16BE(0);if(!wee(n)){let a=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(a);return}let o=new Eg(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!TU(o)){let a=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(a);return}this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=Wr;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Wr):(this._state=Cg,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Wr,this.startLoop(r)}))}createError(t,r,n,o,a){this._loop=!1,this._errored=!0;let s=new t(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(s,this.createError),s.code=a,s[mee]=o,s}};MU.exports=Rk});var Ek=Me((OFe,OU)=>{"use strict";var{Duplex:HFe}=Ee("stream"),{randomFillSync:yee}=Ee("crypto"),{types:{isUint8Array:vee}}=Ee("util"),jU=pc(),{EMPTY_BUFFER:bee,kWebSocket:kee,NOOP:Iee}=yo(),{isBlob:fc,isValidStatusCode:See}=mc(),{mask:HU,toBuffer:fi}=wl(),Vr=Symbol("kByteLength"),Pee=Buffer.alloc(4),Ag=8*1024,gi,gc=Ag,hn=0,Ree=1,xee=2,_k=class e{static{i(this,"Sender")}constructor(t,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=hn,this.onerror=Iee,this[kee]=void 0}static frame(t,r){let n,o=!1,a=2,s=!1;r.mask&&(n=r.maskBuffer||Pee,r.generateMask?r.generateMask(n):(gc===Ag&&(gi===void 0&&(gi=Buffer.alloc(Ag)),yee(gi,0,Ag),gc=0),n[0]=gi[gc++],n[1]=gi[gc++],n[2]=gi[gc++],n[3]=gi[gc++]),s=(n[0]|n[1]|n[2]|n[3])===0,a=6);let c;typeof t=="string"?(!r.mask||s)&&r[Vr]!==void 0?c=r[Vr]:(t=Buffer.from(t),c=t.length):(c=t.length,o=r.mask&&r.readOnly&&!s);let d=c;c>=65536?(a+=8,d=127):c>125&&(a+=2,d=126);let l=Buffer.allocUnsafe(o?c+a:a);return l[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(c,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(c,4,6)),r.mask?(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],s?[l,t]:o?(HU(t,n,l,a,c),[l]):(HU(t,n,t,0,c),[l,t])):[l,t]}close(t,r,n,o){let a;if(t===void 0)a=bee;else{if(typeof t!="number"||!See(t))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)a=Buffer.allocUnsafe(2),a.writeUInt16BE(t,0);else{let c=Buffer.byteLength(r);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");if(a=Buffer.allocUnsafe(2+c),a.writeUInt16BE(t,0),typeof r=="string")a.write(r,2);else if(vee(r))a.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let s={[Vr]:a.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==hn?this.enqueue([this.dispatch,a,!1,s,o]):this.sendFrame(e.frame(a,s),o)}ping(t,r,n){let o,a;if(typeof t=="string"?(o=Buffer.byteLength(t),a=!1):fc(t)?(o=t.size,a=!1):(t=fi(t),o=t.length,a=fi.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let s={[Vr]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};fc(t)?this._state!==hn?this.enqueue([this.getBlobData,t,!1,s,n]):this.getBlobData(t,!1,s,n):this._state!==hn?this.enqueue([this.dispatch,t,!1,s,n]):this.sendFrame(e.frame(t,s),n)}pong(t,r,n){let o,a;if(typeof t=="string"?(o=Buffer.byteLength(t),a=!1):fc(t)?(o=t.size,a=!1):(t=fi(t),o=t.length,a=fi.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let s={[Vr]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};fc(t)?this._state!==hn?this.enqueue([this.getBlobData,t,!1,s,n]):this.getBlobData(t,!1,s,n):this._state!==hn?this.enqueue([this.dispatch,t,!1,s,n]):this.sendFrame(e.frame(t,s),n)}send(t,r,n){let o=this._extensions[jU.extensionName],a=r.binary?2:1,s=r.compress,c,d;typeof t=="string"?(c=Buffer.byteLength(t),d=!1):fc(t)?(c=t.size,d=!1):(t=fi(t),c=t.length,d=fi.readOnly),this._firstFragment?(this._firstFragment=!1,s&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(s=c>=o._threshold),this._compress=s):(s=!1,a=0),r.fin&&(this._firstFragment=!0);let l={[Vr]:c,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:d,rsv1:s};fc(t)?this._state!==hn?this.enqueue([this.getBlobData,t,this._compress,l,n]):this.getBlobData(t,this._compress,l,n):this._state!==hn?this.enqueue([this.dispatch,t,this._compress,l,n]):this.dispatch(t,this._compress,l,n)}getBlobData(t,r,n,o){this._bufferedBytes+=n[Vr],this._state=xee,t.arrayBuffer().then(a=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(Tk,this,c,o);return}this._bufferedBytes-=n[Vr];let s=fi(a);r?this.dispatch(s,r,n,o):(this._state=hn,this.sendFrame(e.frame(s,n),o),this.dequeue())}).catch(a=>{process.nextTick(_ee,this,a,o)})}dispatch(t,r,n,o){if(!r){this.sendFrame(e.frame(t,n),o);return}let a=this._extensions[jU.extensionName];this._bufferedBytes+=n[Vr],this._state=Ree,a.compress(t,n.fin,(s,c)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Tk(this,d,o);return}this._bufferedBytes-=n[Vr],this._state=hn,n.readOnly=!1,this.sendFrame(e.frame(c,n),o),this.dequeue()})}dequeue(){for(;this._state===hn&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][Vr],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][Vr],this._queue.push(t)}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this._socket.uncork()):this._socket.write(t[0],r)}};OU.exports=_k;function Tk(e,t,r){typeof r=="function"&&r(t);for(let n=0;n<e._queue.length;n++){let o=e._queue[n],a=o[o.length-1];typeof a=="function"&&a(t)}}i(Tk,"callCallbacks");function _ee(e,t,r){Tk(e,t,r),e.onerror(t)}i(_ee,"onError")});var zU=Me((LFe,FU)=>{"use strict";var{kForOnEventAttribute:vl,kListener:Ck}=yo(),DU=Symbol("kCode"),LU=Symbol("kData"),BU=Symbol("kError"),$U=Symbol("kMessage"),NU=Symbol("kReason"),hc=Symbol("kTarget"),UU=Symbol("kType"),qU=Symbol("kWasClean"),bo=class{static{i(this,"Event")}constructor(t){this[hc]=null,this[UU]=t}get target(){return this[hc]}get type(){return this[UU]}};Object.defineProperty(bo.prototype,"target",{enumerable:!0});Object.defineProperty(bo.prototype,"type",{enumerable:!0});var hi=class extends bo{static{i(this,"CloseEvent")}constructor(t,r={}){super(t),this[DU]=r.code===void 0?0:r.code,this[NU]=r.reason===void 0?"":r.reason,this[qU]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[DU]}get reason(){return this[NU]}get wasClean(){return this[qU]}};Object.defineProperty(hi.prototype,"code",{enumerable:!0});Object.defineProperty(hi.prototype,"reason",{enumerable:!0});Object.defineProperty(hi.prototype,"wasClean",{enumerable:!0});var wc=class extends bo{static{i(this,"ErrorEvent")}constructor(t,r={}){super(t),this[BU]=r.error===void 0?null:r.error,this[$U]=r.message===void 0?"":r.message}get error(){return this[BU]}get message(){return this[$U]}};Object.defineProperty(wc.prototype,"error",{enumerable:!0});Object.defineProperty(wc.prototype,"message",{enumerable:!0});var bl=class extends bo{static{i(this,"MessageEvent")}constructor(t,r={}){super(t),this[LU]=r.data===void 0?null:r.data}get data(){return this[LU]}};Object.defineProperty(bl.prototype,"data",{enumerable:!0});var Tee={addEventListener(e,t,r={}){for(let o of this.listeners(e))if(!r[vl]&&o[Ck]===t&&!o[vl])return;let n;if(e==="message")n=i(function(a,s){let c=new bl("message",{data:s?a:a.toString()});c[hc]=this,Mg(t,this,c)},"onMessage");else if(e==="close")n=i(function(a,s){let c=new hi("close",{code:a,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[hc]=this,Mg(t,this,c)},"onClose");else if(e==="error")n=i(function(a){let s=new wc("error",{error:a,message:a.message});s[hc]=this,Mg(t,this,s)},"onError");else if(e==="open")n=i(function(){let a=new bo("open");a[hc]=this,Mg(t,this,a)},"onOpen");else return;n[vl]=!!r[vl],n[Ck]=t,r.once?this.once(e,n):this.on(e,n)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[Ck]===t&&!r[vl]){this.removeListener(e,r);break}}};FU.exports={CloseEvent:hi,ErrorEvent:wc,Event:bo,EventTarget:Tee,MessageEvent:bl};function Mg(e,t,r){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}i(Mg,"callListener")});var jg=Me(($Fe,WU)=>{"use strict";var{tokenChars:kl}=mc();function Bn(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}i(Bn,"push");function Eee(e){let t=Object.create(null),r=Object.create(null),n=!1,o=!1,a=!1,s,c,d=-1,l=-1,u=-1,p=0;for(;p<e.length;p++)if(l=e.charCodeAt(p),s===void 0)if(u===-1&&kl[l]===1)d===-1&&(d=p);else if(p!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let w=e.slice(d,u);l===44?(Bn(t,w,r),r=Object.create(null)):s=w,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(c===void 0)if(u===-1&&kl[l]===1)d===-1&&(d=p);else if(l===32||l===9)u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p),Bn(r,e.slice(d,u),!0),l===44&&(Bn(t,s,r),r=Object.create(null),s=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)c=e.slice(d,p),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o){if(kl[l]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1?d=p:n||(n=!0),o=!1}else if(a)if(kl[l]===1)d===-1&&(d=p);else if(l===34&&d!==-1)a=!1,u=p;else if(l===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===34&&e.charCodeAt(p-1)===61)a=!0;else if(u===-1&&kl[l]===1)d===-1&&(d=p);else if(d!==-1&&(l===32||l===9))u===-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let w=e.slice(d,u);n&&(w=w.replace(/\\/g,""),n=!1),Bn(r,c,w),l===44&&(Bn(t,s,r),r=Object.create(null),s=void 0),c=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(d===-1||a||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=p);let m=e.slice(d,u);return s===void 0?Bn(t,m,r):(c===void 0?Bn(r,m,!0):n?Bn(r,c,m.replace(/\\/g,"")):Bn(r,c,m),Bn(t,s,r)),t}i(Eee,"parse");function Cee(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(n=>[t].concat(Object.keys(n).map(o=>{let a=n[o];return Array.isArray(a)||(a=[a]),a.map(s=>s===!0?o:`${o}=${s}`).join("; ")})).join("; ")).join(", ")}).join(", ")}i(Cee,"format");WU.exports={format:Cee,parse:Eee}});var Lg=Me((FFe,nq)=>{"use strict";var Aee=Ee("events"),Mee=Ee("https"),jee=Ee("http"),JU=Ee("net"),Hee=Ee("tls"),{randomBytes:Oee,createHash:Dee}=Ee("crypto"),{Duplex:UFe,Readable:qFe}=Ee("stream"),{URL:Ak}=Ee("url"),pa=pc(),Lee=xk(),Bee=Ek(),{isBlob:$ee}=mc(),{BINARY_TYPES:VU,CLOSE_TIMEOUT:Nee,EMPTY_BUFFER:Hg,GUID:Uee,kForOnEventAttribute:Mk,kListener:qee,kStatusCode:Fee,kWebSocket:vt,NOOP:KU}=yo(),{EventTarget:{addEventListener:zee,removeEventListener:Wee}}=zU(),{format:Vee,parse:Gee}=jg(),{toBuffer:Jee}=wl(),YU=Symbol("kAborted"),jk=[8,13],ko=["CONNECTING","OPEN","CLOSING","CLOSED"],Kee=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Xe=class e extends Aee{static{i(this,"WebSocket")}constructor(t,r,n){super(),this._binaryType=VU[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Hg,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),XU(this,t,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){VU.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}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(t,r,n){let o=new Lee({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),a=new Bee(t,this._extensions,n.generateMask);this._receiver=o,this._sender=a,this._socket=t,o[vt]=this,a[vt]=this,t[vt]=this,o.on("conclude",Qee),o.on("drain",Zee),o.on("error",ete),o.on("message",tte),o.on("ping",rte),o.on("pong",nte),a.onerror=ote,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",eq),t.on("data",Dg),t.on("end",tq),t.on("error",rq),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[pa.extensionName]&&this._extensions[pa.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,r){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Pr(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ZU(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Hk(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||Hg,r,n)}pong(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Hk(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||Hg,r,n)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Hk(this,t,n);return}let o={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[pa.extensionName]||(o.compress=!1),this._sender.send(t||Hg,o,n)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Pr(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Xe,"CONNECTING",{enumerable:!0,value:ko.indexOf("CONNECTING")});Object.defineProperty(Xe.prototype,"CONNECTING",{enumerable:!0,value:ko.indexOf("CONNECTING")});Object.defineProperty(Xe,"OPEN",{enumerable:!0,value:ko.indexOf("OPEN")});Object.defineProperty(Xe.prototype,"OPEN",{enumerable:!0,value:ko.indexOf("OPEN")});Object.defineProperty(Xe,"CLOSING",{enumerable:!0,value:ko.indexOf("CLOSING")});Object.defineProperty(Xe.prototype,"CLOSING",{enumerable:!0,value:ko.indexOf("CLOSING")});Object.defineProperty(Xe,"CLOSED",{enumerable:!0,value:ko.indexOf("CLOSED")});Object.defineProperty(Xe.prototype,"CLOSED",{enumerable:!0,value:ko.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Xe.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Xe.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[Mk])return t[qee];return null},set(t){for(let r of this.listeners(e))if(r[Mk]){this.removeListener(e,r);break}typeof t=="function"&&this.addEventListener(e,t,{[Mk]:!0})}})});Xe.prototype.addEventListener=zee;Xe.prototype.removeEventListener=Wee;nq.exports=Xe;function XU(e,t,r,n){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Nee,protocolVersion:jk[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!jk.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${jk.join(", ")})`);let a;if(t instanceof Ak)a=t;else try{a=new Ak(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}a.protocol==="http:"?a.protocol="ws:":a.protocol==="https:"&&(a.protocol="wss:"),e._url=a.href;let s=a.protocol==="wss:",c=a.protocol==="ws+unix:",d;if(a.protocol!=="ws:"&&!s&&!c?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!a.pathname?d="The URL's pathname is empty":a.hash&&(d="The URL contains a fragment identifier"),d){let h=new SyntaxError(d);if(e._redirects===0)throw h;Og(e,h);return}let l=s?443:80,u=Oee(16).toString("base64"),p=s?Mee.request:jee.request,m=new Set,w;if(o.createConnection=o.createConnection||(s?Xee:Yee),o.defaultPort=o.defaultPort||l,o.port=a.port||l,o.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=a.pathname+a.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(w=new pa({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Vee({[pa.extensionName]:w.offer()})),r.length){for(let h of r){if(typeof h!="string"||!Kee.test(h)||m.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(h)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(a.username||a.password)&&(o.auth=`${a.username}:${a.password}`),c){let h=o.path.split(":");o.socketPath=h[0],o.path=h[1]}let g;if(o.followRedirects){if(e._redirects===0){e._originalIpc=c,e._originalSecure=s,e._originalHostOrSocketPath=c?o.socketPath:a.host;let h=n&&n.headers;if(n={...n,headers:{}},h)for(let[y,f]of Object.entries(h))n.headers[y.toLowerCase()]=f}else if(e.listenerCount("redirect")===0){let h=c?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:a.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!s)&&(delete o.headers.authorization,delete o.headers.cookie,h||delete o.headers.host,o.auth=void 0)}o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),g=e._req=p(o),e._redirects&&e.emit("redirect",e.url,g)}else g=e._req=p(o);o.timeout&&g.on("timeout",()=>{Pr(e,g,"Opening handshake has timed out")}),g.on("error",h=>{g===null||g[YU]||(g=e._req=null,Og(e,h))}),g.on("response",h=>{let y=h.headers.location,f=h.statusCode;if(y&&o.followRedirects&&f>=300&&f<400){if(++e._redirects>o.maxRedirects){Pr(e,g,"Maximum redirects exceeded");return}g.abort();let S;try{S=new Ak(y,t)}catch{let k=new SyntaxError(`Invalid URL: ${y}`);Og(e,k);return}XU(e,S,r,n)}else e.emit("unexpected-response",g,h)||Pr(e,g,`Unexpected server response: ${h.statusCode}`)}),g.on("upgrade",(h,y,f)=>{if(e.emit("upgrade",h),e.readyState!==Xe.CONNECTING)return;g=e._req=null;let S=h.headers.upgrade;if(S===void 0||S.toLowerCase()!=="websocket"){Pr(e,y,"Invalid Upgrade header");return}let I=Dee("sha1").update(u+Uee).digest("base64");if(h.headers["sec-websocket-accept"]!==I){Pr(e,y,"Invalid Sec-WebSocket-Accept header");return}let k=h.headers["sec-websocket-protocol"],v;if(k!==void 0?m.size?m.has(k)||(v="Server sent an invalid subprotocol"):v="Server sent a subprotocol but none was requested":m.size&&(v="Server sent no subprotocol"),v){Pr(e,y,v);return}k&&(e._protocol=k);let R=h.headers["sec-websocket-extensions"];if(R!==void 0){if(!w){Pr(e,y,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=Gee(R)}catch{Pr(e,y,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(C);if(P.length!==1||P[0]!==pa.extensionName){Pr(e,y,"Server indicated an extension that was not requested");return}try{w.accept(C[pa.extensionName])}catch{Pr(e,y,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[pa.extensionName]=w}e.setSocket(y,f,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(g,e):g.end()}i(XU,"initAsClient");function Og(e,t){e._readyState=Xe.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}i(Og,"emitErrorAndClose");function Yee(e){return e.path=e.socketPath,JU.connect(e)}i(Yee,"netConnect");function Xee(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=JU.isIP(e.host)?"":e.host),Hee.connect(e)}i(Xee,"tlsConnect");function Pr(e,t,r){e._readyState=Xe.CLOSING;let n=new Error(r);Error.captureStackTrace(n,Pr),t.setHeader?(t[YU]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Og,e,n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}i(Pr,"abortHandshake");function Hk(e,t,r){if(t){let n=$ee(t)?t.size:Jee(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${e.readyState} (${ko[e.readyState]})`);process.nextTick(r,n)}}i(Hk,"sendAfterClose");function Qee(e,t){let r=this[vt];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,r._socket[vt]!==void 0&&(r._socket.removeListener("data",Dg),process.nextTick(QU,r._socket),e===1005?r.close():r.close(e,t))}i(Qee,"receiverOnConclude");function Zee(){let e=this[vt];e.isPaused||e._socket.resume()}i(Zee,"receiverOnDrain");function ete(e){let t=this[vt];t._socket[vt]!==void 0&&(t._socket.removeListener("data",Dg),process.nextTick(QU,t._socket),t.close(e[Fee])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}i(ete,"receiverOnError");function GU(){this[vt].emitClose()}i(GU,"receiverOnFinish");function tte(e,t){this[vt].emit("message",e,t)}i(tte,"receiverOnMessage");function rte(e){let t=this[vt];t._autoPong&&t.pong(e,!this._isServer,KU),t.emit("ping",e)}i(rte,"receiverOnPing");function nte(e){this[vt].emit("pong",e)}i(nte,"receiverOnPong");function QU(e){e.resume()}i(QU,"resume");function ote(e){let t=this[vt];t.readyState!==Xe.CLOSED&&(t.readyState===Xe.OPEN&&(t._readyState=Xe.CLOSING,ZU(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}i(ote,"senderOnError");function ZU(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}i(ZU,"setCloseTimer");function eq(){let e=this[vt];if(this.removeListener("close",eq),this.removeListener("data",Dg),this.removeListener("end",tq),e._readyState=Xe.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[vt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",GU),e._receiver.on("finish",GU))}i(eq,"socketOnClose");function Dg(e){this[vt]._receiver.write(e)||this.pause()}i(Dg,"socketOnData");function tq(){let e=this[vt];e._readyState=Xe.CLOSING,e._receiver.end(),this.end()}i(tq,"socketOnEnd");function rq(){let e=this[vt];this.removeListener("error",rq),this.on("error",KU),e&&(e._readyState=Xe.CLOSING,this.destroy())}i(rq,"socketOnError")});var sq=Me((VFe,iq)=>{"use strict";var WFe=Lg(),{Duplex:ate}=Ee("stream");function oq(e){e.emit("close")}i(oq,"emitClose");function ite(){!this.destroyed&&this._writableState.finished&&this.destroy()}i(ite,"duplexOnEnd");function aq(e){this.removeListener("error",aq),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}i(aq,"duplexOnError");function ste(e,t){let r=!0,n=new ate({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",i(function(a,s){let c=!s&&n._readableState.objectMode?a.toString():a;n.push(c)||e.pause()},"message")),e.once("error",i(function(a){n.destroyed||(r=!1,n.destroy(a))},"error")),e.once("close",i(function(){n.destroyed||n.push(null)},"close")),n._destroy=function(o,a){if(e.readyState===e.CLOSED){a(o),process.nextTick(oq,n);return}let s=!1;e.once("error",i(function(d){s=!0,a(d)},"error")),e.once("close",i(function(){s||a(o),process.nextTick(oq,n)},"close")),r&&e.terminate()},n._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",i(function(){n._final(o)},"open"));return}e._socket!==null&&(e._socket._writableState.finished?(o(),n._readableState.endEmitted&&n.destroy()):(e._socket.once("finish",i(function(){o()},"finish")),e.close()))},n._read=function(){e.isPaused&&e.resume()},n._write=function(o,a,s){if(e.readyState===e.CONNECTING){e.once("open",i(function(){n._write(o,a,s)},"open"));return}e.send(o,s)},n.on("end",ite),n.on("error",aq),n}i(ste,"createWebSocketStream");iq.exports=ste});var Ok=Me((JFe,cq)=>{"use strict";var{tokenChars:cte}=mc();function dte(e){let t=new Set,r=-1,n=-1,o=0;for(o;o<e.length;o++){let s=e.charCodeAt(o);if(n===-1&&cte[s]===1)r===-1&&(r=o);else if(o!==0&&(s===32||s===9))n===-1&&r!==-1&&(n=o);else if(s===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);n===-1&&(n=o);let c=e.slice(r,n);if(t.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);t.add(c),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let a=e.slice(r,o);if(t.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);return t.add(a),t}i(dte,"parse");cq.exports={parse:dte}});var gq=Me((XFe,fq)=>{"use strict";var lte=Ee("events"),Bg=Ee("http"),{Duplex:YFe}=Ee("stream"),{createHash:ute}=Ee("crypto"),dq=jg(),wi=pc(),pte=Ok(),mte=Lg(),{CLOSE_TIMEOUT:fte,GUID:gte,kWebSocket:hte}=yo(),wte=/^[+/0-9A-Za-z]{22}==$/,lq=0,uq=1,mq=2,Dk=class extends lte{static{i(this,"WebSocketServer")}constructor(t,r){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:fte,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:mte,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=Bg.createServer((n,o)=>{let a=Bg.STATUS_CODES[426];o.writeHead(426,{"Content-Length":a.length,"Content-Type":"text/plain"}),o.end(a)}),this._server.listen(t.port,t.host,t.backlog,r)):t.server&&(this._server=t.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=yte(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:i((o,a,s)=>{this.handleUpgrade(o,a,s,n)},"upgrade")})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=lq}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===mq){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(Il,this);return}if(t&&this.once("close",t),this._state!==uq)if(this._state=uq,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(Il,this):process.nextTick(Il,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Il(this)})}}shouldHandle(t){if(this.options.path){let r=t.url.indexOf("?");if((r!==-1?t.url.slice(0,r):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,r,n,o){r.on("error",pq);let a=t.headers["sec-websocket-key"],s=t.headers.upgrade,c=+t.headers["sec-websocket-version"];if(t.method!=="GET"){yi(this,t,r,405,"Invalid HTTP method");return}if(s===void 0||s.toLowerCase()!=="websocket"){yi(this,t,r,400,"Invalid Upgrade header");return}if(a===void 0||!wte.test(a)){yi(this,t,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){yi(this,t,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Sl(r,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=pte.parse(d)}catch{yi(this,t,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&u!==void 0){let m=new wi({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let w=dq.parse(u);w[wi.extensionName]&&(m.accept(w[wi.extensionName]),p[wi.extensionName]=m)}catch{yi(this,t,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:t.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(w,g,h,y)=>{if(!w)return Sl(r,g||401,h,y);this.completeUpgrade(p,a,l,t,r,n,o)});return}if(!this.options.verifyClient(m))return Sl(r,401)}this.completeUpgrade(p,a,l,t,r,n,o)}completeUpgrade(t,r,n,o,a,s,c){if(!a.readable||!a.writable)return a.destroy();if(a[hte])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>lq)return Sl(a,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ute("sha1").update(r+gte).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let p=this.options.handleProtocols?this.options.handleProtocols(n,o):n.values().next().value;p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),u._protocol=p)}if(t[wi.extensionName]){let p=t[wi.extensionName].params,m=dq.format({[wi.extensionName]:[p]});l.push(`Sec-WebSocket-Extensions: ${m}`),u._extensions=t}this.emit("headers",l,o),a.write(l.concat(`\r
|
|
4
4
|
`).join(`\r
|
|
5
5
|
`)),a.removeListener("error",pq),u.setSocket(a,s,{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(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Il,this)})),c(u,o)}};fq.exports=Dk;function yte(e,t){for(let r of Object.keys(t))e.on(r,t[r]);return i(function(){for(let n of Object.keys(t))e.removeListener(n,t[n])},"removeListeners")}i(yte,"addListeners");function Il(e){e._state=mq,e.emit("close")}i(Il,"emitClose");function pq(){this.destroy()}i(pq,"socketOnError");function Sl(e,t,r,n){r=r||Bg.STATUS_CODES[t],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${Bg.STATUS_CODES[t]}\r
|
|
6
6
|
`+Object.keys(n).map(o=>`${o}: ${n[o]}`).join(`\r
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
3
|
-
import{a as m,b as l}from"./chunks/chunk-BSHAIAXY.js";import"./chunks/chunk-XWPC3AN4.js";import{b as u}from"./chunks/chunk-YJ4PNAST.js";import{a as c,j as d}from"./chunks/chunk-AH22RHPS.js";import{f as s}from"./chunks/chunk-3M53YXEI.js";import"./chunks/chunk-GLUWATL5.js";import{a as n}from"./chunks/chunk-FTQLQJQV.js";function f(e){return!e.command&&s(e.options.version)?"version":s(e.options.checkUpdate)?"check-update":!e.command&&s(e.options.help)?"help":!e.command&&s(e.options.tui)?"tui":e.command?"command":"ui"}n(f,"resolveCliTopLevelAction");async function C(e=process.argv.slice(2)){if(await w(e))return;let{command:t,options:o,rest:r}=u(e);typeof o.home=="string"&&(process.env.OPENPOND_HOME=(await import("./chunks/dist-4HV2W6V4.js")).resolveOpenPondHome({home:o.home}));let i=f({command:t,options:o});if(i==="version"){console.log(c());return}if(i==="check-update"){await(await import("./chunks/core-commands-MTV4EKXY.js")).runCheckUpdate();return}if(i==="help"){(await import("./chunks/help-WLKSACLZ.js")).printHelp();return}let a=m(o),p=l(o);if(a&&(process.env.OPENPOND_ACCOUNT=a),p&&(process.env.OPENPOND_BASE_URL=p),i==="tui"){await(await import("./chunks/app-layer-I7MZYVLL.js")).runOpenPondTerminalCommand(o,r);return}if(i==="ui"){await(await import("./chunks/app-layer-I7MZYVLL.js")).runOpenPondServerCommand("web",o,r);return}await d({command:t,options:o,rest:r})||((await import("./chunks/help-WLKSACLZ.js")).printHelp(),process.exit(1))}n(C,"runOpenPondCli");async function w(e){if(e[0]==="__inspect-hosted-profile-evaluation")return await(await import("./chunks/hosted-profile-compiler-
|
|
3
|
+
import{a as m,b as l}from"./chunks/chunk-BSHAIAXY.js";import"./chunks/chunk-XWPC3AN4.js";import{b as u}from"./chunks/chunk-YJ4PNAST.js";import{a as c,j as d}from"./chunks/chunk-AH22RHPS.js";import{f as s}from"./chunks/chunk-3M53YXEI.js";import"./chunks/chunk-GLUWATL5.js";import{a as n}from"./chunks/chunk-FTQLQJQV.js";function f(e){return!e.command&&s(e.options.version)?"version":s(e.options.checkUpdate)?"check-update":!e.command&&s(e.options.help)?"help":!e.command&&s(e.options.tui)?"tui":e.command?"command":"ui"}n(f,"resolveCliTopLevelAction");async function C(e=process.argv.slice(2)){if(await w(e))return;let{command:t,options:o,rest:r}=u(e);typeof o.home=="string"&&(process.env.OPENPOND_HOME=(await import("./chunks/dist-4HV2W6V4.js")).resolveOpenPondHome({home:o.home}));let i=f({command:t,options:o});if(i==="version"){console.log(c());return}if(i==="check-update"){await(await import("./chunks/core-commands-MTV4EKXY.js")).runCheckUpdate();return}if(i==="help"){(await import("./chunks/help-WLKSACLZ.js")).printHelp();return}let a=m(o),p=l(o);if(a&&(process.env.OPENPOND_ACCOUNT=a),p&&(process.env.OPENPOND_BASE_URL=p),i==="tui"){await(await import("./chunks/app-layer-I7MZYVLL.js")).runOpenPondTerminalCommand(o,r);return}if(i==="ui"){await(await import("./chunks/app-layer-I7MZYVLL.js")).runOpenPondServerCommand("web",o,r);return}await d({command:t,options:o,rest:r})||((await import("./chunks/help-WLKSACLZ.js")).printHelp(),process.exit(1))}n(C,"runOpenPondCli");async function w(e){if(e[0]==="__inspect-hosted-profile-evaluation")return await(await import("./chunks/hosted-profile-compiler-SCVJI2CP.js")).runHostedProfileInspectionCli(e.slice(1)),!0;if(e[0]==="__prepare-hosted-profile-evaluation")return await(await import("./chunks/hosted-profile-compiler-SCVJI2CP.js")).runHostedProfileEvaluationCli(e.slice(1)),!0;if(e[0]==="__hosted-experiment-improvement")return await(await import("./chunks/hosted-experiment-improvement-HAB3UE6A.js")).runHostedExperimentImprovementCli(e.slice(1)),!0;if(e[0]==="__compile-hosted-profile-candidate")return await(await import("./chunks/hosted-profile-candidate-EOBGKQAS.js")).runHostedProfileCandidateCli(e.slice(1)),!0;if(e[0]==="__compile-hosted-profile")return await(await import("./chunks/hosted-profile-compiler-SCVJI2CP.js")).runHostedProfileCompilerCli(e.slice(1)),!0;if(e[0]==="__app-server"){process.argv=[process.execPath,"openpond-app-server",...e.slice(1)];let[{createOpenPondAppServer:t},{runOpenPondAppServerCli:o}]=await Promise.all([import("./chunks/app-server-runtime-7AXV6JZI.js"),import("./chunks/cli-JVB345H2.js")]);return await o(t),!0}if(e[0]==="__server"){process.argv=[process.execPath,"openpond-server",...e.slice(1)];let[{createOpenPondServer:t},{runOpenPondServerCli:o}]=await Promise.all([import("./chunks/src-NE6R4XC6.js"),import("./chunks/cli-JVB345H2.js")]),{createOpenPondAppServer:r}=await import("./chunks/app-server-runtime-7AXV6JZI.js");return await o({createOpenPondServer:t,createOpenPondAppServer:r}),!0}return e[0]==="__terminal"?(await(await import("./chunks/src-CR6UZYTX.js")).runOpenPondTerminalCli(e.slice(1)),!0):!1}n(w,"runEmbeddedCompanion");C().catch(e=>{let t=e instanceof Error?e.message:String(e),o=e.issue;if(process.argv.includes("--json")&&!(e instanceof Error&&e.name==="OpenPondChildProcessExitError"))console.log(JSON.stringify({error:o??{code:"CLI_ERROR",message:t}}));else if(o&&typeof o=="object"){let i=o;console.error(`${i.code}: ${i.message}
|
|
4
4
|
${i.path}
|
|
5
5
|
${i.action}`)}else console.error(t);let r=typeof e.exitCode=="number"?e.exitCode:1;process.exit(r)});export{C as runOpenPondCli};
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{Fa as j}from"./chunk-2JO2KWT3.js";import{n as _,o as k,r as U,u as L,w as O,x as V}from"./chunk-WV2APYWG.js";import{Y as C,h as b,i as x}from"./chunk-PJM2G7SG.js";import{i as M,m as p,n as T}from"./chunk-NNF6KCHD.js";import{b as v}from"./chunk-ES2ISFJC.js";import{a as I}from"./chunk-FTQLQJQV.js";var y=v.object({sessionId:v.string().trim().min(1).max(500),turnId:v.string().trim().min(1).max(500)}).strict();async function Q(e){L(e.manifest,e.taskset,e.catalog),V(e.taskset,e.metricSource);let o=e.manifest.profileEvaluation,t=e.catalog.definitions.find(a=>a.id===o.definitionId),d=new Map(e.taskset.tasks.map(a=>[a.id,a])),h=[],r=[];for(let a of e.manifest.population){e.signal?.throwIfAborted();let l=d.get(a.taskId),s=await e.loadCompletedMember?.(a)??null;if(s){let{receipt:m,grade:u}=s,{contentHash:H,...g}=b.parse(u);if(!k(m)||H!==p(g)||m.id!==a.receiptId||m.runManifest.id!==e.manifest.id||m.runManifest.contentHash!==e.manifest.contentHash||m.taskId!==a.taskId||m.seed!==a.seed||m.graderEvidenceRefs.length!==1||m.graderEvidenceRefs[0]?.contentHash!==H||u.taskHash!==p(l)||u.graderSetHash!==p(e.taskset.graders)||m.metadata.score!==u.score||m.metadata.passed!==u.passed)throw new Error(`Retained Profile evaluation member ${a.receiptId} differs from its admitted evidence.`);r.push(u),h.push(m);continue}let n=await e.execute({task:C(l),seed:a.seed,source:o,...e.signal?{signal:e.signal}:{}});e.signal?.throwIfAborted();let c=await x({task:l,evidence:n.evidence,graders:e.taskset.graders,...e.modelJudge?{modelJudge:e.modelJudge}:{},...e.customVerifier?{customVerifier:e.customVerifier}:{},...e.signal?{signal:e.signal}:{}}),E=M.parse(await e.saveGrade(c));if(E.contentHash!==c.contentHash)throw new Error("Stored Profile evaluation grade differs from its graded evidence.");let w=n.failureClass??c.failureClass,P=_({schemaVersion:"openpond.attemptReceipt.v1",id:a.receiptId,runManifest:{id:e.manifest.id,contentHash:e.manifest.contentHash},taskId:a.taskId,seed:a.seed,terminal:n.terminal,failureClass:w,outputHash:n.evidence.infrastructureError?null:p(n.evidence.output),traceHash:n.traceHash,artifactRefs:n.artifactRefs,graderEvidenceRefs:[E],startedAt:n.startedAt,completedAt:n.completedAt,latencyMs:n.latencyMs,costUsd:n.costUsd,metadata:{gradingRole:"evaluation",score:c.score,passed:c.passed,rewardEligible:c.rewardEligible,sourceRevision:o.sourceRevision,definitionHash:o.definitionHash,environmentHash:o.environmentHash,...n.retainedEvidenceRef?{retainedEvidenceRef:y.parse(n.retainedEvidenceRef)}:{}}});await e.saveReceipt(P),r.push(c),h.push(P)}let i=await O({manifest:e.manifest,taskset:e.taskset,receipts:h,...e.metricSource!==void 0?{source:e.metricSource}:{},...e.signal?{signal:e.signal}:{}},e.metricExecutor),R=r.filter(a=>a.passed).length/r.length;return{receipts:h,grades:r,metric:i,passRate:R,passed:R>=t.criterion.minimumPassRate&&(!t.criterion.requireComplete||h.every(a=>a.terminal))}}I(Q,"executeProfileEvaluationRun");function q(e,o){if(o==="agent_action"){let t=e.find(d=>d.name==="workspace_action_result"&&d.action==="profile_workflow_action")?.output;if(typeof t!="string")throw new Error("Profile Agent action evaluation did not produce a released action result.");return t}return e.filter(t=>t.name==="assistant.delta"&&typeof t.output=="string").map(t=>t.output??"").join("")}I(q,"profileEvaluationOutput");async function z(e){let{store:o,manifest:t,receipt:d}=e;if(!d.metadata.retainedEvidenceRef)return null;let h=y.parse(d.metadata.retainedEvidenceRef),[r,i]=await Promise.all([o.getSession(h.sessionId),o.getTurn(h.turnId)]),R=r?.metadata?.profileEvaluationRun,a=t.profileEvaluation;if(!r||!i||i.sessionId!==r.id||!a||!r.currentProfile||p(r.currentProfile)!==p(e.profileRef)||p(R)!==p({id:t.id,contentHash:t.contentHash})||r.metadata?.taskId!==d.taskId||r.metadata?.seed!==d.seed||!i.completedAt||i.completedAt!==d.completedAt||i.startedAt!==d.startedAt||!i.harnessSnapshot||i.harnessSnapshot.harnessRelease.id!==a.harnessRelease.id||i.harnessSnapshot.harnessRelease.contentHash!==a.harnessRelease.contentHash||t.policy.kind!=="model"||!i.modelRef||i.modelRef.providerId!==t.policy.model.provider||i.modelRef.modelId!==t.policy.model.model)throw new Error("Retained Profile policy turn differs from its admitted case.");let l=await o.runtimeEventsForTurn(i.id);if(l.some(u=>u.turnId!==i.id)||p(l)!==d.traceHash)throw new Error("Retained Profile policy trace differs from its immutable receipt.");let s=q(l,a.target.kind);if(d.outputHash!==null&&p({text:s})!==d.outputHash)throw new Error("Retained Profile output differs from its immutable receipt.");let n=d.artifactRefs.flatMap(u=>{let H=l.filter(f=>(f.action==="work_output_save"||f.action==="sandbox_save_output")&&f.status==="completed").flatMap(f=>{let $=f.data&&typeof f.data=="object"?f.data:{},A=j.safeParse($.outputRef);return A.success?[A.data]:[]}).filter(f=>f.sourceTaskId===r.id&&f.sourceTurnId===i.id&&`${r.id}/${f.id}/${f.revision}/${f.title}`===u.id&&f.sha256===u.contentHash&&f.sizeBytes===u.sizeBytes&&f.contentType===u.mediaType);if(H.length!==1)throw new Error("The case output has no unique sealed saved-file identity.");let g=H[0];if(g.location.kind!=="managed")return[];let S=`/api/work/outputs/${encodeURIComponent(g.location.fileId)}`;if(g.location.downloadPath!==S)throw new Error("The saved output has no canonical managed download route.");return[{id:g.id,title:g.title,revision:g.revision,contentType:g.contentType,sizeBytes:g.sizeBytes,sha256:g.sha256,downloadPath:S}]}),c=await o.listModelUsageRecords({sessionId:r.id,turnId:i.id,limit:1e4}),E=e.eventAfterId?l.findIndex(u=>u.id===e.eventAfterId):-1;if(e.eventAfterId&&E<0)throw new Error("Profile trace cursor is unavailable in this case.");let w=E+1,P=Math.max(1,Math.min(250,e.eventLimit??100)),m=l.slice(w,w+P);return{ref:h,prompt:i.prompt,output:d.outputHash===null?null:{text:s},partialOutput:d.outputHash===null&&s?{text:s}:null,error:i.error,events:m,eventCount:l.length,nextEventCursor:w+m.length<l.length?m.at(-1).id:null,files:n,usage:c,usageCoverage:c.length===1e4?"partial":"complete"}}I(z,"readProfileEvaluationPolicyEvidence");var ne=v.object({runId:v.string().trim().min(1).max(240),receiptId:v.string().trim().min(1).max(500).optional(),eventAfterId:v.string().trim().min(1).max(500).optional(),eventLimit:v.number().int().min(1).max(250).optional(),manifest:U.optional()}).strict().refine(e=>e.receiptId||!e.eventAfterId&&!e.eventLimit,"Select a case before requesting its trace page.").refine(e=>!e.manifest||e.receiptId,"Interrupted-run inspection requires one exact case.");async function de(e){let o=await e.store.getProfileEvaluationRun(e.runId);if(o&&p(o.profileRef)!==p(e.profileRef))throw new Error("Profile evaluation run is unavailable in the selected Profile.");let t=o?.manifest??e.manifest;if(!t||!o&&!e.receiptId)throw new Error("Profile evaluation run is unavailable in the selected Profile.");if(o){if(e.manifest&&e.manifest.contentHash!==o.manifest.contentHash)throw new Error("Profile evaluation run differs from its pinned manifest.")}else if(T(t,"Interrupted Profile evaluation manifest"),t.id!==e.runId||t.profileEvaluation?.profileId!==e.profileRef.profileId||e.profileRef.source==="openpond_git"&&t.metadata.profileRepositoryId!==e.profileRef.repositoryId)throw new Error("Profile evaluation run is unavailable in the selected Profile.");let d=t.population.map((r,i)=>({member:r,index:i})).filter(({member:r})=>!e.receiptId||r.receiptId===e.receiptId);if(e.receiptId&&d.length!==1)throw new Error("Profile evaluation case is unavailable in the selected run.");let h=await Promise.all(d.map(async({member:r,index:i})=>{let R=o?null:await e.store.getProfileEvaluationReceipt(r.receiptId),a=o?.receiptRefs[i]??(R?{id:R.id,contentHash:R.contentHash}:null),l=o?.gradeRefs[i]??R?.graderEvidenceRefs[0];if(!a||!l)throw new Error("Profile evaluation run has incomplete case evidence.");let[s,n]=await Promise.all([e.store.getProfileEvaluationReceipt(a.id),e.store.getProfileEvaluationGrade(l.contentHash)]);if(!s||!o&&!k(s)||s.contentHash!==a.contentHash||s.id!==r.receiptId||s.taskId!==r.taskId||s.seed!==r.seed||s.runManifest.id!==t.id||s.runManifest.contentHash!==t.contentHash||!n||n.contentHash!==l.contentHash||!s.graderEvidenceRefs.some(c=>c.id===l.id&&c.contentHash===l.contentHash))throw new Error("Profile evaluation case evidence differs from its retained run.");return{taskId:r.taskId,seed:r.seed,receiptId:s.id,receiptHash:s.contentHash,traceHash:s.traceHash,outputHash:s.outputHash,score:n.score,passed:n.passed,gradingStatus:n.gradingStatus,failureClass:n.failureClass,artifactCount:s.artifactRefs.length,latencyMs:s.latencyMs,costUsd:s.costUsd,terminal:s.terminal,feedback:n.components.map(c=>({graderId:c.graderId,graderVersion:c.graderVersion,score:c.score,passed:c.passed,feedback:c.feedback})),...e.receiptId?{receipt:s,evidence:await z({store:e.store,profileRef:e.profileRef,manifest:t,receipt:s,eventAfterId:e.eventAfterId,eventLimit:e.eventLimit})}:{}}}));return{runId:t.id,sourceRevision:t.profileEvaluation?.sourceRevision??null,cases:h}}I(de,"inspectProfileEvaluationRun");export{Q as a,q as b,ne as c,de as d};
|