@cortexkit/opencode-openai-auth 1.17.2 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +8 -8
- package/dist/{codex-request-DYqSE0ti.d.ts → codex-request-Bj3F3fFg.d.ts} +324 -324
- package/dist/{index-emcf633z.js → index-12gxtre8.js} +1 -1
- package/dist/index-3b9e26wv.js +12 -0
- package/dist/index-6tgra34y.js +2 -0
- package/dist/index-7ztbemxe.js +64 -0
- package/dist/{index-qjh3h3wr.js → index-a4cgsngv.js} +3 -3
- package/dist/index-aew7mcfy.js +2 -0
- package/dist/{index-t09qaj5w.js → index-cawk490s.js} +2 -2
- package/dist/{index-srdm5a4d.js → index-gqnca0gh.js} +1 -1
- package/dist/{index-6pakkcrn.js → index-h7xxfm12.js} +1 -1
- package/dist/{index-vjk4wv2b.js → index-hnb97ydy.js} +1 -1
- package/dist/{index-b2pc3ze2.js → index-hrv1msdb.js} +1 -1
- package/dist/{index-y1b9ka54.js → index-r3vc66vz.js} +21 -21
- package/dist/{index-2dqwctzp.js → index-raj3tyyz.js} +1 -1
- package/dist/{index-7ea4dbe9.js → index-v2wvavef.js} +7 -7
- package/dist/index.d.ts +24 -24
- package/dist/index.js +1 -1
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-6ya278eg.js → token-kdjmv82a.js} +1 -1
- package/dist/token-util-71r7z2vr.js +1 -0
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +1 -1
- package/dist/v2/server.d.ts +1 -1
- package/dist/v2/server.js +3 -2
- package/package.json +2 -2
- package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +1 -1
- package/src/tui-compiled/raw/shared/375d9cca2def037d-private-files.js +6 -2
- package/src/tui-compiled/raw/shared/54eba94fd64c8c3c-index.js +1 -1
- package/src/tui-compiled/raw/shared/836fc615de6afbd9-settings.js +14 -4
- package/src/tui-compiled/raw/shared/94f53cfd572ba4bb-availability.js +1 -1
- package/src/tui-compiled/raw/shared/c14988621dc60a75-port-file.js +55 -49
- package/src/tui-compiled/raw/shared/cf4c37f3975c3a8d-canonical-file-path.js +6 -2
- package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +1 -1
- package/src/tui-compiled/runtime/shared/375d9cca2def037d-private-files.js +6 -2
- package/src/tui-compiled/runtime/shared/54eba94fd64c8c3c-index.js +1 -1
- package/src/tui-compiled/runtime/shared/836fc615de6afbd9-settings.js +14 -4
- package/src/tui-compiled/runtime/shared/94f53cfd572ba4bb-availability.js +1 -1
- package/src/tui-compiled/runtime/shared/c14988621dc60a75-port-file.js +55 -49
- package/src/tui-compiled/runtime/shared/cf4c37f3975c3a8d-canonical-file-path.js +6 -2
- package/dist/index-4thkhwyp.js +0 -12
- package/dist/index-h8ychf80.js +0 -2
- package/dist/index-jmzh060w.js +0 -64
- package/dist/index-q7d43xxn.js +0 -2
- package/dist/token-util-ynanp4np.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Gg as G,Ig as H}from"./index-cawk490s.js";function Q(x){return x==="chatgptaccountid"||x==="email"||x==="orgname"||x==="organizationname"}var S=G({extraSecretKeys:Q}),I=S.redact,N=S.redactStrings;function O(x){H({...x,extraSecretKeys:Q})}function C(x){if(x instanceof Error)return x.message;if(typeof x==="string")return x;try{return JSON.stringify(x)}catch{return String(x)}}function v(x){return"notify"in x}import{basename as X,dirname as Y,join as Z}from"node:path";var $="openai-auth.json",b="openai-auth-state.json";function p(x){return X(x)===$?Z(Y(x),b):`${x}.state.json`}import{spawn as j}from"node:child_process";function z(x,J=process.platform,q=j){try{if(J==="win32"){let U=`Start-Process '${x.replaceAll("'","''")}'`,V=Buffer.from(U,"utf16le").toString("base64"),T=q("powershell.exe",["-NoProfile","-NonInteractive","-WindowStyle","Hidden","-EncodedCommand",V],{stdio:"ignore",windowsHide:!0});return T.on("error",()=>{}),T.unref(),T.pid!==void 0}let u=q(J==="darwin"?"open":"xdg-open",[x],{stdio:"ignore"});return u.on("error",()=>{}),u.unref(),u.pid!==void 0}catch{return!1}}export{N as yg,O as zg,$ as Ag,b as Bg,p as Cg,C as Dg,v as Eg,z as Fg};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{Mg as _,Ng as U,Rg as g,Sg as p,Tg as E,Xg as c}from"./index-aew7mcfy.js";import{createHash as Oz,randomUUID as y}from"node:crypto";import{chmod as zz,mkdir as Gz,open as Jz,readdir as F,rename as Kz,rmdir as Nz,stat as T,unlink as I}from"node:fs/promises";import{uptime as Qz}from"node:os";import{join as A,resolve as b}from"node:path";function S(z){return(z.now??Date.now)()-(z.uptime??Qz)()*1000-300000}function x(z,J,Q){let X=z.startedAt===void 0?J?.mtimeMs:z.startedAt;return typeof X==="number"&&Number.isFinite(X)&&X<Q}async function Vz(z,J,Q,X){if(!Q)return;await X?.(z);try{let K=await E(z),G=await T(z);if(K===J&&G.dev===Q.dev&&G.ino===Q.ino&&G.mtimeMs===Q.mtimeMs&&G.size===Q.size)await I(z).catch(()=>{})}catch(K){if(K instanceof U&&K.code!=="ENOENT")throw K}}function a(z){return typeof z==="number"&&Number.isSafeInteger(z)&&z>0}function k(z){if(!a(z))return!1;try{return process.kill(z,0),!0}catch(J){return J.code==="EPERM"}}function Ez(z){return(J)=>Wz(J,z)}function Wz(z,J){if(/^[0-9a-f]{16}$/.test(z))return!0;return z.startsWith(J)&&/^[0-9a-f]{16}$/.test(z.slice(J.length))}function Xz(z){let J=/^port-(\d+)\.json$/.exec(z);return J?Number(J[1]):void 0}function s(z,J){if(z===null||typeof z!=="object"||Array.isArray(z))return!1;let{pid:Q,port:X,token:K}=z;return a(Q)&&Xz(J)===Q&&typeof X==="number"&&Number.isInteger(X)&&X>=1&&X<=65535&&typeof K==="string"&&K.length>0}async function l(z,J){J?.debug("rpc corrupt port file",{pid:process.pid,portFile:z}),await I(z).catch(()=>{})}async function Lz(z,J,Q={}){let X=async()=>{let K=A(z,`port-${J.pid}.json`);if(_)return await p(z,Q.secureDir??!1),await Q.beforeWrite?.(),await c(K,JSON.stringify({...J,startedAt:Date.now()}),{stagePath:`${K}.${(Q.stageName??y)()}.tmp`}),K;if(await Gz(z,{recursive:!0,mode:Q.secureDir?448:void 0}),Q.secureDir)await zz(z,448);await Q.beforeWrite?.();let G={...J,startedAt:Date.now()},Y=`${K}.${(Q.stageName??y)()}.tmp`,V,N=!1;try{V=await Jz(Y,"wx",384),N=!0,await V.writeFile(JSON.stringify(G),"utf8"),await V.chmod(384),await V.close(),V=void 0,await Kz(Y,K),N=!1}finally{if(await V?.close().catch(()=>{}),N)await I(Y).catch(()=>{})}return K};for(let K=1;;K+=1)try{return await X()}catch(G){if(G.code!=="ENOENT"||K===5)throw G;await new Promise((Y)=>setTimeout(Y,25))}}async function Iz(z,J,Q,X,K={}){let G=S(K),Y;try{Y=await F(z,{withFileTypes:!0})}catch(N){if(N.code==="ENOENT")return;throw N}let V=b(J);for(let N of Y){if(!N.isDirectory()||!Q(N.name))continue;let W=A(z,N.name);if(!await Yz(W,X,K,G))continue;if(b(W)!==V)await Nz(W).catch(()=>{})}}async function Yz(z,J,Q={},X=S(Q)){let K;try{K=await F(z)}catch(G){if(G.code==="ENOENT")return!1;throw G}for(let G of K){if(!G.startsWith("port-")||!G.endsWith(".json"))continue;let Y=A(z,G),V=await T(Y).catch(()=>{return}),N;try{N=await E(Y)}catch($){if($ instanceof U&&$.code!=="ENOENT")throw $;continue}if(N===void 0)continue;let W;try{W=JSON.parse(N)}catch{await l(Y,J);continue}if(!s(W,G)){await l(Y,J);continue}let Z=W;if(!k(Z.pid))await I(Y).catch(()=>{});else if(x(Z,V,X))await Vz(Y,N,V,Q.beforeRemove)}return!0}async function d(z,J,Q={}){let X=S(Q);if(!k(J.pid))return null;let K=A(b(z),`port-${J.pid}.json`);try{if(_)await g(K,"file");let G=await T(K);if(x(J,G,X))return null;return`${K}:${G.dev}:${G.ino}:${G.mtimeMs}:${G.size}`}catch(G){if(G instanceof U&&G.code!=="ENOENT")throw G;return null}}async function n(z,J,Q={}){let X=S(Q),K;try{if(_)await g(z,"directory");K=await F(z)}catch(W){if(W instanceof U&&W.code!=="ENOENT")throw W;return null}let G=[];for(let W of K){if(!W.startsWith("port-")||!W.endsWith(".json"))continue;try{let Z=JSON.parse(await E(A(z,W)));if(s(Z,W))if(k(Z.pid)){let $=Z.startedAt===void 0?await T(A(z,W)).catch(()=>{return}):void 0;if(!x(Z,$,X))G.push(Z)}else await I(A(z,W)).catch(()=>{})}catch(Z){if(Z instanceof U&&Z.code!=="ENOENT")throw Z}}if(G.length===0)return null;let Y=J!==void 0&&J>=1?G.filter((W)=>W.pid===J):[];if(Q.exactPid===!0&&Y.length===0)return null;let V=Y.length>0?Y:G,N=(W)=>typeof W.startedAt==="number"&&Number.isFinite(W.startedAt)?W.startedAt:-1/0;return V.sort((W,Z)=>N(Z)-N(W))[0]??null}import{open as Zz}from"node:fs/promises";import{connect as $z}from"node:net";import{join as Hz,resolve as t}from"node:path";var e=2000,q=new Map,B=new Map;async function qz(z,J){let Q=Hz(t(z),`port-${J.pid}.json`);if(_){let K=JSON.parse(await E(Q));if(K.pid!==J.pid||K.port!==J.port||K.token!==J.token)return null;return null}let X;try{X=await Zz(Q,"r");let K=await X.stat(),G=JSON.parse(await X.readFile("utf8"));if(G.pid!==J.pid||G.port!==J.port||G.token!==J.token)return null;return`${Q}:${K.dev}:${K.ino}:${K.mtimeMs}:${K.size}`}catch{return null}finally{await X?.close().catch(()=>{})}}async function i(z,J,Q,X){let K=q.get(z);if(!_&&K&&await d(J,K.entry)===K.identity)return K;q.delete(z);let G=B.get(z);if(G)return G;let Y=(async()=>{let V=await(X.discover??n)(J,Q,X);if(!V)return null;let N=await qz(J,V);if(!N)return{entry:V,identity:""};let W={entry:V,identity:N};return q.set(z,W),W})();B.set(z,Y);try{return await Y}finally{if(B.get(z)===Y)B.delete(z)}}async function o(z,J,Q,X=e){return new Promise((K)=>{let G,Y=!1,V=!1,N=(Z,$=!1)=>{if(Y)return;Y=!0,clearTimeout(W),G?.destroy(),K({value:Z,stale:$})},W=setTimeout(()=>N(null),X);try{let Z=JSON.stringify(Q);G=$z({host:"127.0.0.1",port:z.port}),G.on("connect",()=>{V=!0,G?.write(`POST /rpc/${J} HTTP/1.0\r
|
|
2
|
+
Host: 127.0.0.1:${z.port}\r
|
|
3
|
+
Connection: close\r
|
|
4
|
+
Content-Type: application/json\r
|
|
5
|
+
Content-Length: ${Buffer.byteLength(Z)}\r
|
|
6
|
+
Authorization: Bearer ${z.token}\r
|
|
7
|
+
\r
|
|
8
|
+
`+Z)});let $=[],O=0,C,H,R=Buffer.alloc(0),P=()=>{if(C===void 0)return N(null);try{let L=Buffer.concat($).subarray(C);N(JSON.parse(L.toString("utf8")))}catch{N(null)}};G.on("data",(L)=>{if(Y)return;if(O+=L.length,$.push(L),C===void 0){R=Buffer.concat([R,L]);let j=R.indexOf(`\r
|
|
9
|
+
\r
|
|
10
|
+
`);if(j>=0)C=j+4;if((C??R.length)>16384)return N(null);if(C!==void 0){let u=R.subarray(0,j).toString("latin1").split(`\r
|
|
11
|
+
`),v=/^HTTP\/1\.[01] (\d{3})(?: |$)/.exec(u[0]??"");if(!v)return N(null);let w=Number(v[1]);if(w<200||w>=300)return N(null,[401,403,404,410].includes(w));for(let D of u.slice(1)){let f=D.indexOf(":"),h=D.slice(0,f).toLowerCase(),m=D.slice(f+1).trim();if(h==="transfer-encoding")return N(null);if(h==="content-length"){if(H!==void 0||!/^\d+$/.test(m))return N(null);if(H=Number(m),!Number.isSafeInteger(H)||H>8388608)return N(null)}}R=Buffer.alloc(0)}}let M=O-(C??O);if(M>8388608)return N(null);if(H!==void 0){if(M>H)return N(null);if(M===H)P()}}),G.on("end",()=>{if(H!==void 0&&O-(C??0)!==H)return N(null);P()}),G.on("error",()=>N(null,!V)),G.on("close",()=>N(null))}catch{N(null,!V)}})}async function r(z,J,Q,X,K,G,Y=e){let V=JSON.stringify([t(z),J??null,Q.exactPid===!0]),N=await i(V,z,J,Q);if(X(N?.entry??null),!N)return null;let W=Date.now()+Y,Z=await o(N.entry,K,G,Y);if(!Z.stale)return Z.value;if(q.get(V)===N)q.delete(V);let $=await i(V,z,J,Q);if(!$||Date.now()>=W)return null;if($.entry.port===N.entry.port&&$.entry.pid===N.entry.pid&&$.entry.token===N.entry.token){if(q.get(V)===$)q.delete(V);return null}let O=await o($.entry,K,G,W-Date.now());if(O.stale&&q.get(V)===$)q.delete(V);return O.value}function Dz(z,J,Q,X={}){let K={exactPid:X.exactPid,discover:X.discover},G=!1,Y=(V)=>{if(G)return;Q?.(V),G=!0};return{async pending(V,N,W){return(await r(z,J,K,Y,"pending-notifications",{lastReceivedId:V,sessionId:N},W))?.messages??[]},async apply(V,N){return await r(z,J,K,Y,"apply",{...V},N)??{text:"apply failed",knobs:{}}}}}
|
|
12
|
+
export{Ez as rg,Lz as sg,Iz as tg,Yz as ug,n as vg,e as wg,Dz as xg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{rg as R,sg as T,tg as y,ug as D}from"./index-3b9e26wv.js";import{Ng as v,Tg as I}from"./index-aew7mcfy.js";import{Zg as t}from"./index-hrv1msdb.js";class O extends Error{operation;constructor(f){super(`a ${f} on a strict notification scope needs a session id`);this.name="RpcSessionRequiredError",this.operation=f}}function S(f){return typeof f==="string"&&f.length>0}var g=new Map;function _(f){let x=JSON.stringify([f.rpcRoot,f.directoryPrefix,f.registrationSessionId,...f.requireSession===!0?["strict"]:[]]),P=g.get(x);if(!P)P={queue:[],nextId:1,lastDrainAtBySession:new Map,lastDrainAtAny:0},g.set(x,P);return P}var m=100,l=3000;function Vf(f,x,P){if(f.requireSession===!0&&!S(P))throw new O("push");let V=_(f);if(V.queue.push({id:V.nextId++,type:"open-dialog",payload:x,sessionId:P}),V.queue.length>m)V.queue=V.queue.slice(-m)}function Bf(f,x=0,P){if(f.requireSession===!0&&!S(P))throw new O("drain");let V=_(f),J=Date.now();if(V.lastDrainAtAny=J,P!==void 0)V.lastDrainAtBySession.set(P,J);let K=f.sessionlessDrain==="broadcast-only",H=(B)=>P===void 0?!K||B.sessionId===void 0:B.sessionId===void 0||B.sessionId===P;if(x>0)V.queue=V.queue.filter((B)=>{if(B.id>x)return!0;if(P===void 0)return!K||B.sessionId!==void 0;return B.sessionId!==P});return V.queue.filter((B)=>B.id>x&&H(B))}function Ff(f,x){let P=Date.now(),V=_(f),J=x!==void 0?V.lastDrainAtBySession.get(x)??0:f.sessionlessDrain==="broadcast-only"?V.lastDrainAtAny:0;return J>0&&P-J<l}import{randomBytes as a,timingSafeEqual as o}from"node:crypto";import{unlink as r}from"node:fs/promises";import{createServer as s}from"node:http";import{join as e}from"node:path";import{lstat as c}from"node:fs/promises";import{basename as d,dirname as i,resolve as k}from"node:path";var j=globalThis,w=Symbol.for("common-auth.rpc.startup-sweep");j[w]??={};var U=j[w],n=Date.now;async function q(f,x,P,V){let J=n();if(U.lastSweepAt!==void 0&&J-U.lastSweepAt<60000){let K=k(x);if(i(K)===k(f)&&P(d(K))&&(await c(K).catch((H)=>{if(H.code!=="ENOENT")throw H;return}))?.isDirectory())await D(K,V);return}U.lastSweepAt=J,await y(f,x,P,V)}class b extends Error{status;constructor(f,x){if(!Number.isInteger(f)||f<400||f>499)throw RangeError(`RpcRequestError status must be 4xx, got ${f}`);super(x);this.name="RpcRequestError",this.status=f}}var u=1e6;class E extends Error{declaredOversize;constructor(f){super("body too large");this.declaredOversize=f}}function ff(f){return new Promise((x,P)=>{let V=(B=!1)=>{f.removeAllListeners("data"),f.on("data",()=>{}),f.resume(),P(new E(B))},J=Number(f.headers["content-length"]);if(Number.isFinite(J)&&J>u){V(!0);return}let K=[],H=0;f.on("data",(B)=>{if(H+=B.length,H>u){V();return}K.push(B)}),f.on("end",()=>x(Buffer.concat(K).toString("utf8"))),f.on("error",P)})}class h extends Error{}async function xf(f,x){let P,V=new Promise((J,K)=>{P=setTimeout(()=>K(new h("apply deadline exceeded")),x),P.unref?.()});f.catch(()=>{});try{return await Promise.race([f,V])}finally{clearTimeout(P)}}function Pf(f,x){if(!f?.startsWith("Bearer "))return!1;let P=Buffer.from(f.slice(7)),V=Buffer.from(x);return P.length===V.length&&o(P,V)}async function Wf(f){if(typeof f.drain==="function"===(typeof f.drainAsync==="function"))throw TypeError("exactly one of drain or drainAsync must be provided");let x=f.log??{warn(){},debug(){}},P=a(32).toString("hex"),V=f.timeoutMs??90000,J=f.receiptTimeoutMs??2000,K=!1,H=new Set,B=s((z,G)=>{z.setTimeout(V,()=>{z.socket.destroy()}),M(z,G)});B.on("connection",(z)=>{H.add(z),z.once("close",()=>H.delete(z))}),B.requestTimeout=J,B.headersTimeout=J;async function M(z,G){let F=(X,W,C={})=>{if(G.headersSent||G.writableEnded||G.destroyed)return;G.writeHead(X,{"content-type":"application/json",...C}),G.end(JSON.stringify(W))};try{let X=new URL(z.url??"/","http://127.0.0.1").pathname;if(z.method==="GET"&&X==="/health")return F(200,{ok:!0});if(z.method!=="POST"||!X.startsWith("/rpc/"))return F(404,{error:"not found"});if(!Pf(z.headers.authorization,P))return F(401,{error:"unauthorized"});let W=X.slice(5),C;try{C=await ff(z)}catch(Y){if(!(Y instanceof E))throw Y;let Z=z.socket;if(G.once("finish",()=>{Z.end();let $=setTimeout(()=>Z.destroy(),2000);if($.unref(),z.once("end",()=>Z.destroy()),Z.once("close",()=>clearTimeout($)),z.complete)Z.destroy()}),!Y.declaredOversize&&!z.complete){if(G.headersSent||G.writableEnded||G.destroyed)return;let $=JSON.stringify({error:"body too large"});G.writeHead(413,{"content-type":"application/json","content-length":Buffer.byteLength($),connection:"close"}),G.write($),z.once("end",()=>G.end());return}return F(413,{error:"body too large"},{connection:"close"})}let Q;try{Q=JSON.parse(C||"{}")}catch{return F(400,{error:"invalid json"})}if(W==="pending-notifications"){let Y;try{if(f.parsePending)Y=f.parsePending(Q);else{if(!Q||typeof Q!=="object"||Array.isArray(Q))throw Error("invalid params");let L=Q;if(f.requireSession===!0&&!S(L.sessionId))return F(400,{error:"session required"});if("lastReceivedId"in L&&(typeof L.lastReceivedId!=="number"||!Number.isSafeInteger(L.lastReceivedId)||L.lastReceivedId<0)||"sessionId"in L&&typeof L.sessionId!=="string")throw Error("invalid params");Y={lastReceivedId:Number(L.lastReceivedId??0),sessionId:typeof L.sessionId==="string"?L.sessionId:void 0}}}catch(L){if(L instanceof b)throw L;return F(400,{error:"invalid params"})}let{lastReceivedId:Z,sessionId:$}=Y;if(f.requireSession===!0&&!S($))return F(400,{error:"session required"});if($===void 0&&!K)K=!0,x.warn("rpc notification drain missing session id",{pid:process.pid});let N;if(f.drainAsync)try{N=await f.drainAsync(Z,$)}catch(L){return x.warn("rpc notification drain failed",{pid:process.pid,error:L instanceof Error?L.message:String(L)}),F(500,{error:"drain failed"})}else N=f.drain?.(Z,$);return F(200,{messages:N})}if(W==="apply"){let Y=Promise.resolve(f.apply(Q)),Z=f.applyDeadlineMs===void 0?await Y:await xf(Y,f.applyDeadlineMs);return F(200,Z)}return F(404,{error:"unknown method"})}catch(X){if(X instanceof b)return x.debug("rpc request refused",{pid:process.pid,status:X.status}),F(X.status,{error:X.message});if(X instanceof h)return x.warn("rpc apply deadline exceeded",{pid:process.pid,deadlineMs:f.applyDeadlineMs}),F(504,{error:"handler deadline exceeded"});x.warn("rpc request failed",{pid:process.pid,error:X instanceof Error?X.message:String(X)}),F(500,{error:"internal error"})}}let A=await new Promise((z,G)=>{B.on("error",G),B.listen(0,"127.0.0.1",()=>{let F=B.address();if(F&&typeof F==="object")z(F.port);else G(Error("no port"))})});if(B.unref(),f.sweepRoot)try{await q(f.sweepRoot,f.dir,f.isManagedDir,x)}catch(z){x.warn("rpc state sweep failed",{pid:process.pid,error:z instanceof Error?z.message:String(z)})}try{await T(f.dir,{port:A,token:P,pid:process.pid},{secureDir:f.secureDir}),x.debug("rpc server pid",{pid:process.pid,rpcPort:A})}catch(z){throw await new Promise((G)=>B.close(()=>G())),z}return{port:A,token:P,async stop(){await new Promise((F)=>{B.closeAllConnections?.(),B.close(()=>F());for(let X of H)X.destroy()});let z=e(f.dir,`port-${process.pid}.json`),G=await I(z).then((F)=>JSON.parse(F)).catch((F)=>{if(F instanceof v&&F.code!=="ENOENT")throw F;return});if(G?.port===A&&G.token===P)await r(z).catch(()=>{})}}}async function Mf(f,x,P){let V=globalThis,J=Symbol.for(f),K=V[J]??{servers:new Map,pending:new Map};V[J]=K;let{servers:H,pending:B}=K,M=B.get(x)??Promise.resolve(),A,z=M.catch(()=>{}).then(async()=>{let F=H.get(x);if(F){if(await F.stop(),H.get(x)===F)H.delete(x)}A=await P(),H.set(x,A)});B.set(x,z);try{await z}finally{if(B.get(x)===z)B.delete(x)}let G=A;if(!G)throw Error("RPC server failed to start");return{server:G,release:async()=>{if(H.get(x)!==G)return;if(await G.stop(),H.get(x)===G)H.delete(x)}}}var p="1.19.0";function wf(f,x,P){let V={...x,version:p};return T(f,V,P)}var qf=R(t);
|
|
2
|
+
export{Vf as jg,Bf as kg,Ff as lg,Wf as mg,Mf as ng,p as og,wf as pg,qf as qg};
|