@cortexkit/opencode-openai-auth 1.8.0 → 1.8.2
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 +9 -9
- package/dist/{codex-request-DohnbsFR.d.ts → codex-request-GJkvxv4S.d.ts} +3 -57
- package/dist/index-03hs0rq7.js +2 -0
- package/dist/index-0dmg1yer.js +63 -0
- package/dist/{index-cxstwq02.js → index-7sa6ncxb.js} +1 -1
- package/dist/index-b0s5cty6.js +91 -0
- package/dist/{index-dtwgf694.js → index-c50p5mem.js} +1 -1
- package/dist/{index-g3d50jz0.js → index-ctch2vgj.js} +10 -10
- package/dist/{index-5d4y47h8.js → index-dw6yd976.js} +2 -2
- package/dist/index-fyrgwfx3.js +8 -0
- package/dist/{index-5dxpsa3t.js → index-g556s1mz.js} +2 -2
- package/dist/{index-x7jzcvqy.js → index-hpnj460b.js} +1 -1
- package/dist/{index-cbcka7sa.js → index-p8m4yh73.js} +1 -1
- package/dist/{index-th47aqez.js → index-yt52fztj.js} +2 -2
- package/dist/{index-dzaqj248.js → index-z36br4a0.js} +2 -2
- package/dist/index.d.ts +2 -12
- package/dist/index.js +1 -1
- package/dist/{port-file-DQ7-ItDK.d.ts → port-file-DXCxv8tU.d.ts} +0 -2
- package/dist/{protocol-CVQK-d3j.d.ts → protocol-BZZtDn5h.d.ts} +0 -4
- package/dist/rpc/port-file.d.ts +1 -3
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.d.ts +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.d.ts +0 -2
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/{rpc-client-BQfIKrXI.d.ts → rpc-client-CmaZW1by.d.ts} +2 -6
- package/dist/{sidebar-state-B1cq68UB.d.ts → sidebar-state-DkNebAiC.d.ts} +3 -11
- package/dist/sidebar-state.d.ts +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-gy442bba.js → token-3vtr29vt.js} +1 -1
- package/dist/token-util-erhrf24m.js +1 -0
- package/dist/tui-preferences.d.ts +0 -2
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +3 -7
- package/dist/v2/server.d.ts +2 -18
- package/dist/v2/server.js +2 -2
- package/package.json +7 -7
- package/src/tui-compiled/raw/shared/352d228be2832bd4-hub.js +86 -42
- package/src/tui-compiled/raw/shared/b9588ad4725c1d10-enrollment.js +15 -8
- package/src/tui-compiled/raw/shared/dbc61cd405941828-accounts.js +42 -0
- package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +175 -10
- package/src/tui-compiled/raw/sidebar-state.js +4 -2
- package/src/tui-compiled/raw/tui.tsx +7 -1
- package/src/tui-compiled/runtime/shared/352d228be2832bd4-hub.js +86 -42
- package/src/tui-compiled/runtime/shared/b9588ad4725c1d10-enrollment.js +15 -8
- package/src/tui-compiled/runtime/shared/dbc61cd405941828-accounts.js +42 -0
- package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +175 -10
- package/src/tui-compiled/runtime/sidebar-state.js +4 -2
- package/src/tui-compiled/runtime/tui.js +4 -1
- package/dist/index-3v868rnp.js +0 -63
- package/dist/index-8pk9savd.js +0 -8
- package/dist/index-n7fxqgfb.js +0 -2
- package/dist/index-tvban5vp.js +0 -91
- package/dist/token-util-rxy0p234.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`;try{G?.({channel:Q,level:I,message:S,data:K})}catch{}if(H===void 0)return;if(U.push(r),U.length>=50){let F=R(!1);if(F instanceof Promise)F.catch(()=>{})}else a()}catch{}}function n(Q){return{error:(I,X)=>x(Q,"error",I,X),warn:(I,X)=>x(Q,"warn",I,X),info:(I,X)=>x(Q,"info",I,X),debug:(I,X)=>x(Q,"debug",I,X),trace:(I,X)=>x(Q,"trace",I,X)}}function l(){if(q)N(()=>M(C)).catch(()=>{});if(j=void 0,U=[],V)clearTimeout(V),V=void 0;H=void 0,Z=void 0,$=void 0,B=T(),G=void 0}if(J)z(J);return{configure:z,createLogger:n,setLogLevel:s,flushLogs:R,reset:l}}var O=BJ();function L(J){O.configure(J);let{configure:H,createLogger:Z,setLogLevel:$,flushLogs:B}=O;return{configure:H,createLogger:Z,setLogLevel:$,flushLogs:B}}function v(J){O.setLogLevel(J)}function u(){return O.flushLogs()}function c(J){return O.createLogger(J)}function f(J){return J==="chatgptaccountid"||J==="email"||J==="orgname"||J==="organizationname"}var d=T({extraSecretKeys:f}),kJ=d.redact,pJ=d.redactStrings;function hJ(J){L({...J,extraSecretKeys:f})}function uJ(J){if(J instanceof Error)return J.message;if(typeof J==="string")return J;try{return JSON.stringify(J)}catch{return String(J)}}function fJ(J){return"notify"in J}import{basename as MJ,dirname as TJ,join as qJ}from"node:path";var AJ="openai-auth.json",xJ="openai-auth-state.json";function oJ(J){return MJ(J)===AJ?qJ(TJ(J),xJ):`${J}.state.json`}import{spawn as _J}from"node:child_process";function nJ(J,H=process.platform,Z=_J){try{if(H==="win32"){let B=`Start-Process '${J.replaceAll("'","''")}'`,G=Buffer.from(B,"utf16le").toString("base64"),U=Z("powershell.exe",["-NoProfile","-NonInteractive","-WindowStyle","Hidden","-EncodedCommand",G],{stdio:"ignore",windowsHide:!0});return U.on("error",()=>{}),U.unref(),U.pid!==void 0}let $=Z(H==="darwin"?"open":"xdg-open",[J],{stdio:"ignore"});return $.on("error",()=>{}),$.unref(),$.pid!==void 0}catch{return!1}}export{T as
|
|
1
|
+
import{if as q,kf as _,mf as A,nf as w,pf as k,rf as p}from"./index-g556s1mz.js";import{appendFileSync as QJ,chmodSync as UJ,existsSync as W,renameSync as g,statSync as ZJ}from"node:fs";import{open as $J}from"node:fs/promises";import{dirname as VJ,resolve as IJ}from"node:path";var i=/^(authorization|x-api-key|cookie|set-cookie|refresh|access|token)$/i,e=/\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b|ckh_[A-Za-z0-9_-]{20,}/g;function JJ(J){return J instanceof Error||Object.prototype.toString.call(J)==="[object Error]"}function T(J={}){let H=[e,...J.extraValuePatterns??[]].map((G)=>new RegExp(G.source,G.flags.includes("g")?G.flags:`${G.flags}g`));function Z(G){let U=G.toLowerCase().replace(/[-_]/g,"");return i.test(G)||U.includes("apikey")||U.endsWith("secret")||U.endsWith("password")||U.endsWith("token")&&!U.endsWith("tokens")||!!J.extraSecretKeys?.(U)}function $(G){let U=G,V=[["name",G.name],["message",G.message],["stack",G.stack]];for(let j of["code","status","cause"])if(U[j]!==void 0)V.push([j,U[j]]);let Y=new Set(V.map(([j])=>j));for(let j of Object.entries(G))if(!Y.has(j[0]))V.push(j);return V}function B(G,U,V,Y=0){if(typeof G==="string")return H.reduce((j,C)=>j.replace(C,"***REDACTED***"),G);if(!G||typeof G!=="object")return G;if(V.has(G))return"[Circular]";V.add(G);try{if(Array.isArray(G))return G.map((N)=>B(N,U,V,Y));let j=JJ(G);if(j&&Y>=8)return"[Truncated]";let C=j?Y+1:Y;return Object.fromEntries((j?$(G):Object.entries(G)).map(([N,z])=>[N,U&&Z(N)?"***REDACTED***":B(z,U,V,C)]))}finally{V.delete(G)}}return{redact:(G)=>B(G,!0,new WeakSet),redactStrings:(G)=>B(G,!1,new WeakSet)}}var E=T(),GJ=E.redact,HJ=E.redactStrings;var D={error:0,warn:1,info:2,debug:3,trace:4},h=5242880,m=3;function b(J){try{UJ(J,384)}catch{}}function jJ(J){try{if(!(W(J)&&ZJ(J).size>=h))return;for(let Z=m-1;Z>=1;Z--)if(W(`${J}.${Z}`)){let $=`${J}.${Z+1}`;g(`${J}.${Z}`,$),b($)}let H=`${J}.1`;g(J,H),b(H)}catch{}}async function M(J){let{file:H,handle:Z}=J;if(J.file=void 0,J.handle=void 0,H&&Z)await _(H,"log-close",()=>Z.close())}async function y(J,H){await w(VJ(H));try{await A(H,"file",!0)}catch(Z){if(Z.code!=="ENOENT")throw Z;try{await k(H,"")}catch($){if($.code!=="EEXIST")throw $;await A(H,"file",!0)}}return J.handle=await _(H,"log-open",()=>$J(H,"a")),J.file=H,J.handle}async function XJ(J,H,Z){H=IJ(H);try{if(J.file!==H)await M(J);let $=J.handle??await y(J,H);if((await _(H,"log-stat",()=>$.stat())).size>=h){await M(J);for(let G=m-1;G>=0;G--){let U=G===0?H:`${H}.${G}`,V=`${H}.${G+1}`;try{await A(U,"file",!0)}catch(Y){if(Y.code==="ENOENT")continue;throw Y}try{await A(V,"file",!0)}catch(Y){if(Y.code!=="ENOENT")throw Y}await p(U,V),await A(V,"file")}$=await y(J,H)}await _(H,"log-append",()=>$.appendFile(Z,"utf8"))}catch($){throw await M(J).catch(()=>{}),$}}function YJ(J){try{return` ${JSON.stringify(J)}`}catch{return" [unserializable]"}}function BJ(J){let H,Z,$,B=T(),G,U=[],V,Y=Promise.resolve(),j,C={};function N(Q){let I=Y.then(Q);return Y=I.catch((X)=>{j=X}),I}function z(Q){if(q&&Q.file!==H)N(()=>M(C)).catch(()=>{});H=Q.file,Z=Q.level,B=T(Q),G=Q.captureSink}function s(Q){if(Q===void 0||Q in D)$=Q}function o(){if(H===void 0)return;return(typeof H==="function"?H():H)||void 0}function t(){if($)return $;let Q=typeof Z==="function"?Z():Z;if(Q&&Q in D)return Q;return"info"}function R(Q=!0){if(V)clearTimeout(V),V=void 0;if(!U.length){if(q)return N(async()=>{if(Q)await M(C);if(j)throw j});return}let I;try{I=o()}catch{if(U=[],q&&Q)return N(()=>M(C));return}let X=U.join("");if(U=[],!I){if(q&&Q)return N(()=>M(C));return}if(q)return N(async()=>{try{await XJ(C,I,X)}finally{if(Q)await M(C)}});try{if(jJ(I),W(I))b(I);QJ(I,X,{encoding:"utf8",mode:384})}catch{}}function a(){if(!V)V=setTimeout(()=>{V=void 0;let Q=R(!1);if(Q instanceof Promise)Q.catch(()=>{})},500)}function x(Q,I,X,P){if(H===void 0&&G===void 0)return;try{if(D[I]>D[t()])return;let S=B.redactStrings(X),K;try{K=B.redact(P)}catch{K="[unserializable]"}let r=`[${new Date().toISOString()}] ${I.toUpperCase()} [${Q}] ${S}`+(P===void 0?"":YJ(K))+`
|
|
2
|
+
`;try{G?.({channel:Q,level:I,message:S,data:K})}catch{}if(H===void 0)return;if(U.push(r),U.length>=50){let F=R(!1);if(F instanceof Promise)F.catch(()=>{})}else a()}catch{}}function n(Q){return{error:(I,X)=>x(Q,"error",I,X),warn:(I,X)=>x(Q,"warn",I,X),info:(I,X)=>x(Q,"info",I,X),debug:(I,X)=>x(Q,"debug",I,X),trace:(I,X)=>x(Q,"trace",I,X)}}function l(){if(q)N(()=>M(C)).catch(()=>{});if(j=void 0,U=[],V)clearTimeout(V),V=void 0;H=void 0,Z=void 0,$=void 0,B=T(),G=void 0}if(J)z(J);return{configure:z,createLogger:n,setLogLevel:s,flushLogs:R,reset:l}}var O=BJ();function L(J){O.configure(J);let{configure:H,createLogger:Z,setLogLevel:$,flushLogs:B}=O;return{configure:H,createLogger:Z,setLogLevel:$,flushLogs:B}}function v(J){O.setLogLevel(J)}function u(){return O.flushLogs()}function c(J){return O.createLogger(J)}function f(J){return J==="chatgptaccountid"||J==="email"||J==="orgname"||J==="organizationname"}var d=T({extraSecretKeys:f}),kJ=d.redact,pJ=d.redactStrings;function hJ(J){L({...J,extraSecretKeys:f})}function uJ(J){if(J instanceof Error)return J.message;if(typeof J==="string")return J;try{return JSON.stringify(J)}catch{return String(J)}}function fJ(J){return"notify"in J}import{basename as MJ,dirname as TJ,join as qJ}from"node:path";var AJ="openai-auth.json",xJ="openai-auth-state.json";function oJ(J){return MJ(J)===AJ?qJ(TJ(J),xJ):`${J}.state.json`}import{spawn as _J}from"node:child_process";function nJ(J,H=process.platform,Z=_J){try{if(H==="win32"){let B=`Start-Process '${J.replaceAll("'","''")}'`,G=Buffer.from(B,"utf16le").toString("base64"),U=Z("powershell.exe",["-NoProfile","-NonInteractive","-WindowStyle","Hidden","-EncodedCommand",G],{stdio:"ignore",windowsHide:!0});return U.on("error",()=>{}),U.unref(),U.pid!==void 0}let $=Z(H==="darwin"?"open":"xdg-open",[J],{stdio:"ignore"});return $.on("error",()=>{}),$.unref(),$.pid!==void 0}catch{return!1}}export{T as Xe,GJ as Ye,v as Ze,u as _e,c as $e,pJ as af,hJ as bf,AJ as cf,xJ as df,oJ as ef,uJ as ff,fJ as gf,nJ as hf};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{if as Q,jf as q,kf as D0,mf as C,nf as w,of as R,pf as h,qf as F0,sf as O}from"./index-g556s1mz.js";import{randomUUID as M}from"node:crypto";import{lstat as v,mkdir as W0,open as V0,readFile as Y0,rename as Z0,rm as T,stat as L}from"node:fs/promises";import{dirname as P,join as _0}from"node:path";function H0($,f){return`${$}.${f}.lock`}class Q0 extends Error{details;constructor($){super(`Timed out acquiring ${$.name} lock for ${$.target}`);this.name="LockContentionError",this.details=$}}class I extends Error{details;constructor($){super(`Lost ${$.name} lock for ${$.target}`);this.name="LockOwnershipError",this.details=$}}async function E0($,f,G){let H=performance.now();for(;;){f.signal?.throwIfAborted();let W=await G0({path:$,name:f.name,ttlMs:f.ttlMs,renew:f.renew??!1,...f.onStep?{onStep:f.onStep}:{},...f.onRenewalTimer?{onRenewalTimer:f.onRenewalTimer}:{}});if(W)try{return f.signal?.throwIfAborted(),await G(W)}finally{await W.release()}let Y=f.timeoutMs-(performance.now()-H);if(Y<=0)throw new Q0({target:$,name:f.name,timeoutMs:f.timeoutMs});await new Promise((Z)=>setTimeout(Z,Math.min(25,Math.ceil(Y))))}}async function x0($,f){let G=await V0($,"wx",384),H;try{H=await G.stat()}catch{H=void 0}try{await G.writeFile(f,"utf8")}catch(W){try{let Y=await v($).catch(()=>{return});if(H&&Y&&Y.dev===H.dev&&Y.ino===H.ino)await T($,{force:!0}).catch(()=>{})}catch{}throw W}finally{await G.close()}}var q0=globalThis.setTimeout.bind(globalThis),C0=globalThis.clearTimeout.bind(globalThis);function R0($){let f=$?.code;return f==="ENOENT"||!Q&&(f==="EINVAL"||f==="ENOTDIR")}var J0;function S0($,f){if($.dev!==f.dev||$.ino!==f.ino)return!1;if($.ino===0&&$.birthtimeMs!==f.birthtimeMs)return!1;return!0}var I0=1000;function G0($){return T0({...$,now:Date.now})}async function T0($){let f=H0($.path,$.name),G=_0(f,"owner.json"),H=M(),W=$.now??Date.now,Y=null,Z=!1,g=!1,J,c,g0=new Promise((z)=>{c=z});function d(z){try{let K=$.onRenewalTimer?.(z);if(K&&(typeof K==="object"||typeof K==="function")&&"then"in K&&typeof K.then==="function")Promise.resolve(K).catch(()=>{})}catch{}}function a(){if(!Y)return;C0(Y),Y=null,d("cancelled")}function V(z,K){if(J||Z)return;J=Object.freeze({reason:z,expectedOwnerId:H,...typeof K?.ownerId==="string"?{observedOwnerId:K.ownerId}:{},...typeof K?.expiresAt==="number"?{observedExpiresAt:K.expiresAt}:{}}),a(),c(J)}let E,A=null,x=`${f}.evicting`,X=_0(x,"owner.json"),i=M(),s=5000,n=8;async function F(){if(Q)try{return JSON.parse(await R(f,!0))}catch(z){if(z.code!=="EISDIR"&&z.reason!=="wrong-kind")throw z;return await C(f,"directory",!0),JSON.parse(await R(G,!0))}try{return JSON.parse(await Y0(f,"utf8"))}catch(z){if(z.code!=="EISDIR")throw z;return JSON.parse(await Y0(G,"utf8"))}}async function U0(){if(Q){let B=await F(),_=Number(B?.expiresAt)-W();await O(f,`${JSON.stringify({ownerId:H,expiresAt:W()+$.ttlMs})}
|
|
2
|
+
`,{deadline:performance.now()+Math.max(0,_),beforeRename:async()=>{let j=await F();if(j?.ownerId!==H||!(Number(j?.expiresAt)>W())||!await D())throw new I({target:$.path,name:$.name})}});return}let z=`${f}.${M()}.tmp`,K,N=!1;try{K=await V0(z,"wx",384),N=!0,await K.writeFile(`${JSON.stringify({ownerId:H,expiresAt:W()+$.ttlMs})}
|
|
3
|
+
`,"utf8"),await K.chmod(384),await K.close(),K=void 0;let B=await F();if(B?.ownerId!==H||!(Number(B?.expiresAt)>W())||!await D())throw new I({target:$.path,name:$.name});await Z0(z,f),N=!1}finally{if(await K?.close().catch(()=>{}),N)await T(z,{force:!0}).catch(()=>{})}}async function t(){let z=`${JSON.stringify({ownerId:H,expiresAt:W()+$.ttlMs})}
|
|
4
|
+
`;if(Q)await h(f,z);else await x0(f,z)}async function o(z){let K=z.code;if(K!=="EEXIST"&&K!=="EISDIR")return!1;if(Q){if($.onStep)await $.onStep("lease-contention-read-ready");try{if(K==="EISDIR")await C(f,"directory",!0),await R(G,!0);else await F()}catch(N){if(N.code!=="ENOENT")throw N}}return!0}async function y(){if(Q)await w(P(f));try{return await t(),!0}catch(z){let K=z.code;if(await o(z))return!1;if(K==="ENOENT"){if(Q)await w(P(f));else await W0(P(f),{recursive:!0});try{return await t(),!0}catch(N){if(await o(N))return!1;throw N}}throw z}}async function m(){await new Promise((z)=>setTimeout(z,Math.floor(Math.random()*4)))}async function k(z=!0){if(z&&$.onStep)await $.onStep("lock-read-ready");let K;try{K=await F()}catch(B){if(Q&&B.code!=="ENOENT")throw B}let N=Number(K?.expiresAt);if(Number.isFinite(N)&&N>W())return{status:"live"};if(typeof K?.ownerId==="string"&&Number.isFinite(N))return{status:"stale",identity:{kind:"owner",ownerId:K.ownerId,expiresAt:N}};try{let B=await L(f),_=Number.isFinite(N)?N:B.mtimeMs+$.ttlMs;if(_>W())return{status:"live"};return{status:"stale",identity:{kind:"stat",dev:B.dev,ino:B.ino,mtimeMs:B.mtimeMs,expiresAt:_}}}catch(B){if(B.code==="ENOENT"){if($.onStep)await $.onStep("lock-missing");return{status:"missing"}}throw B}}function r(z,K){if(K.status!=="stale")return!1;let N=K.identity;if(z.kind==="owner"&&N.kind==="owner")return z.ownerId===N.ownerId&&z.expiresAt===N.expiresAt;return z.kind==="stat"&&N.kind==="stat"&&z.dev===N.dev&&z.ino===N.ino&&z.mtimeMs===N.mtimeMs&&z.expiresAt===N.expiresAt}async function D(){try{return JSON.parse(await R(X,Q))?.ownerId===i}catch(z){if(Q&&z.code!=="ENOENT")throw z;return!1}}async function S(z){if(Q)await D0(z,"remove",()=>T(z,{recursive:!0,force:!0}));else await T(z,{recursive:!0,force:!0}).catch(()=>{})}async function u(){if(await D())await S(x)}async function j0(z){if(!z)return!1;let K;try{let N=await v(x);K={dev:N.dev,ino:N.ino,birthtimeMs:N.birthtimeMs}}catch{return!1}if(!S0(z,K))return!1;try{return await L(X),!0}catch(N){if(N.code!=="ENOENT")return!0}try{await S(x)}catch{}return!0}async function e(){if(Q)await F0(x);else await W0(x);let z;try{let K=await v(x);z={dev:K.dev,ino:K.ino,birthtimeMs:K.birthtimeMs}}catch{z=void 0}try{await J0?.beforeOwnerWrite?.(x,X);let K=await J0?.failOwnerWrite?.(x,X);if(K!==void 0)throw K;let N=`${JSON.stringify({ownerId:i,createdAt:W()})}
|
|
5
|
+
`;if(Q)await h(X,N);else await x0(X,N)}catch(K){let N=await j0(z);if(R0(K)&&!N)return!1;try{await u()}catch{}throw K}if($.onStep)await $.onStep("eviction-marker-acquired");return!0}async function $0(){let z;try{z=await L(x)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if(Q)try{await C(x,"directory",!0)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if(z.mtimeMs+s>W()){let N=!0;try{await L(X)}catch(B){if(B.code==="ENOENT")N=!1;else return"fresh"}if(N)return"fresh";if(z.mtimeMs+I0>W())return"fresh"}if($.onStep)await $.onStep("stale-marker-stat");let K=`${x}.${M()}`;try{await Z0(x,K)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if($.onStep)await $.onStep("stale-marker-claimed");return await S(K),"recovered"}async function z0(z){try{if(!await e())return!1}catch(K){if(K.code==="EEXIST"){if(Q)try{await C(x,"directory",!0),await R(X,!0)}catch(N){if(N.code!=="ENOENT")throw N}return!1}throw K}try{await z()}finally{await u()}return!0}async function K0(){for(let z=0;z<n;z++){if($.onStep)await $.onStep("relinquish-read");let K;try{K=await F()}catch(N){if(Q)throw N;return}if(K?.ownerId!==H)return;try{await T(f,{recursive:!0,force:!0});return}catch(N){if(Q)throw N;await m()}}}function N0(){if(!$.renew||Z||J)return;let z=$.renewIntervalMs??Math.max(1000,Math.floor($.ttlMs/3));if(Y=q0(()=>{Y=null;let K=(async()=>{let N=!Z;try{if(!await z0(async()=>{let _=await F(),j=W();if(Z||J){N=!1;return}if(_?.ownerId!==H){V("taken-over",_),N=!1;return}if(!(Number(_?.expiresAt)>j)){V("expired",_),N=!1;return}if($.onStep)await $.onStep("renewal-owner-confirmed");if(Z||J){N=!1;return}if(!await D())return;if($.onStep)await $.onStep("renewal-write-fenced");if(Z||J){N=!1;return}if(!await D())return;if($.onStep)await $.onStep("renewal-write-ready");if(Z||J){N=!1;return}if(await U0(),$.onStep)await $.onStep("renewal-write-finished");if(!await D()){V("marker-lost"),N=!1,await K0();return}})&&$.onStep)await $.onStep("renewal-marker-unavailable")}catch(B){if(Q&&B instanceof q)E=B,V("renewal-failed"),N=!1;try{let _=await F();if(_?.ownerId!==H)V("taken-over",_);else if(!(Number(_?.expiresAt)>W()))V("expired",_)}catch{V("renewal-failed")}}finally{if($.onStep)try{await $.onStep("renewal-finished")}catch{}if(N&&!Z&&!J)N0()}})();A=K,K.finally(()=>{if(A===K)A=null})},z),"unref"in Y)Y.unref();d("scheduled")}function f0(){try{let z=$.onContended?.();if(z&&(typeof z==="object"||typeof z==="function")&&"then"in z&&typeof z.then==="function")Promise.resolve(z).catch(()=>{})}catch{}return null}let U=await y();if(!U)for(let z=0;z<n;z++){if(U=await y(),U)break;let K=await k();if(K.status==="live")return f0();if(K.status==="missing")continue;if($.onStep)await $.onStep("stale-lock-observed");try{if(!await e()){await m();continue}}catch(N){if(N.code!=="EEXIST")throw N;if(await $0()==="fresh")return null;await m();continue}try{let N=await k();if(N.status==="live")return f0();if(!r(K.identity,N))continue;if(!await D())return null;if($.onStep)await $.onStep("stale-lock-confirmed");if(!await D())return null;let B=await k(!1);if(!r(K.identity,B))continue;if(await S(f),!await D())return null;if($.onStep)await $.onStep("stale-lock-removed");if(U=await y(),!U)return null;if($.onStep)await $.onStep("stale-lock-recreated");if(!await D())return await K0(),U=!1,null;break}finally{await u()}}if(!U)return null;return N0(),{ownerId:H,whenLost:()=>g0,hasLost:()=>J!==void 0,assertOwned:async()=>{if(E)throw E;let z;try{let K=await F();if(z=K,!Z&&!J&&K?.ownerId===H&&Number(K?.expiresAt)>W())return;V(K?.ownerId!==H?"taken-over":"expired",K)}catch(K){if(V("unreadable"),Q&&K instanceof q)throw K}throw new I({target:$.path,name:$.name,expectedOwnerId:H,...typeof z?.ownerId==="string"?{observedOwnerId:z.ownerId}:{},...typeof z?.expiresAt==="number"?{observedExpiresAt:z.expiresAt}:{}})},release:async()=>{if(Q&&g)return;Z=!0,a(),await A;let z=performance.now()+s+1000,K=5;for(;;){try{let B=!1;if(await z0(async()=>{let j;try{j=await F()}catch(B0){if(Q&&B0.code==="ENOENT"){B=!0;return}throw B0}if(j?.ownerId!==H){B=!0;return}if($.onStep)await $.onStep("release-owner-confirmed");if(!await D())return;await S(f),B=!0})){if(Q&&!B)throw new q(f,"release-not-confirmed",{code:"EIO"});g=B;return}await $0()}catch(B){if(Q)throw B;return}let N=z-performance.now();if(N<=0)break;await new Promise((B)=>setTimeout(B,Math.min(K,N))),K=Math.min(K*2,50)}if(Q)throw new q(f,"release-not-confirmed",{code:"ETIMEDOUT"})}}}import{randomUUID as X0}from"node:crypto";import{mkdir as A0,open as b,rename as M0,rm as L0}from"node:fs/promises";import{dirname as p}from"node:path";class l extends Error{constructor($){super("file or directory sync failed",{cause:$});this.name="AtomicSyncError"}}async function d0($,f,G={}){await O0($,f,G)}async function O0($,f,G,H){if(Q)return O($,G.serialize?G.serialize(f):`${JSON.stringify(f,null,2)}
|
|
6
|
+
`,{beforeRename:G.beforeRename,stagePath:`${$}.${(G.stageName??X0)()}.tmp`,onRenamed:H,durable:G.durable,durability:G.durability,onOutcome:G.onOutcome});await A0(p($),{recursive:!0});let W=`${$}.${(G.stageName??X0)()}.tmp`,Y,Z=!1;try{if(Y=await b(W,"wx",384),Z=!0,await Y.writeFile(G.serialize?G.serialize(f):`${JSON.stringify(f,null,2)}
|
|
7
|
+
`,"utf8"),await Y.chmod(384),G.durable)try{await Y.sync()}catch(g){throw new l(g)}if(await Y.close(),Y=void 0,await G.beforeRename?.(),await M0(W,$),Z=!1,H?.(),G.durable){let g=await b(p($),"r");try{await g.sync()}catch(J){throw new l(J)}finally{await g.close()}}}finally{if(await Y?.close().catch(()=>{}),Z)await L0(W,{force:!0}).catch(()=>{})}}async function a0($){if(Q){await C($,"file");let H=new q($,"directory-sync-unsupported",{code:"ENOTSUP"});throw H.published=!0,H}let f=await b($,"r");try{await f.sync()}finally{await f.close()}let G=await b(p($),"r");try{await G.sync()}finally{await G.close()}}var s0=Object.freeze({sidebar:Object.freeze({name:"sidebar-write",ttlMs:1e4,timeoutMs:15000,renew:!0}),preferences:Object.freeze({name:"preferences",ttlMs:1e4,timeoutMs:2000,renew:!0})});
|
|
8
|
+
export{l as ze,d0 as Ae,O0 as Be,a0 as Ce,G0 as De,H0 as Ee,Q0 as Fe,I as Ge,E0 as He,s0 as Ie};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{O as
|
|
1
|
+
import{zf as F}from"./index-hpnj460b.js";import{randomUUID as k}from"node:crypto";import{lstat as N,readFile as f,rename as y,unlink as I}from"node:fs/promises";import{tmpdir as P}from"node:os";import{dirname as W,join as E,resolve as K}from"node:path";var O=process.platform==="win32",L=new Set;function V(j){if(j?.reason==="io-error"){if(j.win32Code===2||j.win32Code===3)return"ENOENT";if(j.win32Code===80||j.win32Code===183)return"EEXIST"}return j?.code??"ERR_PRIVATE_FILE"}var _;var v="native-addon-unavailable";function b(j){return Object.assign(Error("Windows private-files native addon is unavailable",{cause:j}),{code:"ERR_PRIVATE_FILES_UNAVAILABLE",reason:v})}function g(j,x){return x instanceof j.PrivateFilesUnavailableError||x?.code==="ERR_PRIVATE_FILES_UNAVAILABLE"}async function m(j){try{await j.verifyPrivatePath(E(P(),`.common-auth-private-files-probe-${k()}`),"file")}catch(x){if(g(j,x))throw b(x)}}function $(){return _??=import("@cortexkit/private-files").then(async(j)=>{if(O)await m(j);return j},(j)=>{throw O?b(j):j}),_}class Q extends Error{path;stage;code;win32Code;reason;published=!1;durabilityConfirmed=!1;fileDurable=!1;attempts=0;elapsedMs=0;orphanPath;constructor(j,x,z){let q=z;super(q?.code==="ERR_PRIVATE_FILES_UNAVAILABLE"?`Private file refused at ${x}: ${j} (${v}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`:`Private file refused at ${x}: ${j} (${q?.reason??q?.code??"io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`,{cause:z});this.path=j,this.stage=x,this.name="PrivateFileError",this.code=V(q),this.win32Code=q?.win32Code,this.reason=q?.reason}}async function T(j,x,z){try{return await z()}catch(q){if(q instanceof Q)throw q;throw new Q(j,x,q)}}var c;async function Y(j,x){j=K(j),x??=c,await T(j,"safe-parent",async()=>{let z=await(await $()).verifySafeParent(j,x);if(z.ok===!1){if(z.reason==="io-error"||z.reason==="wrong-kind")await N(j);throw new Q(z.level??z.path,"safe-parent",{...z,code:"ERR_PRIVATE_FILES_SECURITY"})}})}async function S(j,x,z=!1){if(j=K(j),x==="directory")return Y(j);await T(j,"verify",async()=>{let q=await $(),H=await q.verifyOwnerOnly(j),C=!1;if(!H.ok){let{reason:J}=H.refusal;if(J==="io-error")await q.verifyPrivatePath(j,x);if(z&&[q.EXTRA_ACE,q.NOT_PROTECTED,q.NULL_DACL,q.EMPTY_DACL].includes(J))await Y(W(j)),await q.securePrivatePath(j,x),C=!0;else throw Object.assign(Error("Owner-only verification refused"),{reason:J,code:"ERR_PRIVATE_FILES_SECURITY"})}if(await q.verifyPrivatePath(j,x),C&&!L.has(j))L.add(j),process.emitWarning(`Private permissions tightened: ${j}. This object may have been readable before; rotate credentials if needed.`,"PrivateFileMigration")})}async function w(j,x=!1,z){j=K(j),await T(j,"directory",async()=>{let q=await $();try{return await N(j),await Y(j,z)}catch(C){if(V(C)!=="ENOENT")throw C}let H=W(j);if(H===j)throw Object.assign(Error("Missing root"),{code:"ENOENT"});await w(H,!1,z);try{await q.createOwnerOnly(j,{kind:"dir"})}catch(C){if(V(C)!=="EEXIST")throw C}await Y(j,z)})}async function p(j,x=!1){if(!O)return f(j,"utf8");return(await u(j,x)).toString("utf8")}async function u(j,x=!1){if(!O)return f(j);if(j=K(j),x)await Y(W(j)),await S(j,"file",!0);return T(j,"read",async()=>(await $()).readOwnerOnly(j))}async function d(j,x){await Y(W(K(j))),await T(j,"create",async()=>{await(await $()).createPrivateFile(K(j),x)})}async function r(j){await Y(W(K(j))),await T(j,"directory-create",async()=>{await(await $()).createOwnerOnly(K(j),{kind:"dir"})})}async function l(j,x,z={}){j=K(j),x=K(x);let q=z.now??(()=>performance.now()),H=q(),C=z.deadline??1/0,J,Z=[0,10,20,40,80,100],U,G=0;for(let D of Z){let R=Math.min(J??1/0,C);if(q()>=R)break;if(D)await(z.sleep??((B)=>new Promise((X)=>setTimeout(X,B))))(Math.min(D,Math.max(0,R-q())));if(q()>=R)break;let A=q();if(await z.beforeRename?.(),J!==void 0)J+=q()-A;if(q()>=C)break;G++;try{return await(z.rename??y)(j,x),{attempts:G,elapsedMs:q()-H}}catch(B){U??=B;let X=B;if(!(X.win32Code!==void 0?X.win32Code===32||X.win32Code===33:["EBUSY","EPERM","EACCES"].includes(X.code??"")&&!X.reason))break;J??=q()+500}}let M=new Q(x,"rename",U??Object.assign(Error("Publication deadline expired"),{code:"ETIMEDOUT"}));throw M.attempts=G,M.elapsedMs=q()-H,M}async function e(j,x,z={}){j=K(j),await w(W(j));try{await S(j,"file",!0)}catch(G){if(G.code!=="ENOENT")throw G}let q=K(z.stagePath??`${j}.${k()}.tmp`);if(W(q)!==W(j))throw new Q(j,"stage-directory",{code:"EXDEV"});let H=!1,C=!1,J={attempts:0,elapsedMs:0},Z="stage-create",U=(G)=>{try{z.onOutcome?.({path:j,stage:G?.stage??"published",published:C,fileDurable:C,durabilityConfirmed:!1,attempts:G?.attempts??J.attempts,elapsedMs:G?.elapsedMs??J.elapsedMs,...G&&{code:G.code,win32Code:G.win32Code}})}catch{}};try{if(await d(q,x),H=!0,Z="before-rename",J=await l(q,j,z),H=!1,C=!0,Z="published-callback",z.onRenamed?.(),Z="published-verify",await S(j,"file"),z.durable&&z.durability!=="file-only-on-windows")throw new Q(j,"directory-sync-unsupported",{code:"ENOTSUP"});U()}catch(G){let M=G instanceof Q?G:new Q(j,Z,G);if(M.published=C,M.fileDurable=C,C)Object.assign(M,J);if(H){try{await I(q)}catch{M.orphanPath=q}H=!1}throw U(M),M}finally{if(H)await I(q).catch(()=>{})}}
|
|
2
|
+
export{O as if,Q as jf,T as kf,Y as lf,S as mf,w as nf,p as of,d as pf,r as qf,l as rf,e as sf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire as n}from"node:module";var k=Object.defineProperty;var q=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var l=(b)=>b;function m(b,a){this[b]=l.bind(null,a)}var r=(b,a)=>{for(var c in a)k(b,c,{get:a[c],enumerable:!0,configurable:!0,set:m.bind(a,c)})};var t=n(import.meta.url),o=Symbol.dispose||Symbol.for("Symbol.dispose"),p=Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose"),u=(b,a,c)=>{if(a!=null){if(typeof a!=="object"&&typeof a!=="function")throw TypeError('Object expected to be assigned to "using" declaration');var e;if(c)e=a[p];if(e===void 0)e=a[o];if(typeof e!=="function")throw TypeError("Object not disposable");b.push([c,e,a])}else if(c)b.push([c]);return a},v=(b,a,c)=>{var e=typeof SuppressedError==="function"?SuppressedError:function(d,i,f,g){return g=Error(f),g.name="SuppressedError",g.error=d,g.suppressed=i,g},j=(d)=>a=c?new e(d,a,"An error was suppressed during disposal"):(c=!0,d),h=(d)=>{while(d=b.pop())try{var i=d[1]&&d[1].call(d[2]);if(d[0])return Promise.resolve(i).then(h,(f)=>(j(f),h()))}catch(f){j(f)}if(c)throw a};return h()};
|
|
2
|
-
export{q as
|
|
2
|
+
export{q as xf,r as yf,t as zf,u as Af,v as Bf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{xf as Z,zf as W}from"./index-hpnj460b.js";var R=Z(($G,E)=>{var{defineProperty:N,getOwnPropertyDescriptor:Kz,getOwnPropertyNames:Qz}=Object,Wz=Object.prototype.hasOwnProperty,Xz=(z,G)=>{for(var H in G)N(z,H,{get:G[H],enumerable:!0})},Yz=(z,G,H,Q)=>{if(G&&typeof G==="object"||typeof G==="function"){for(let K of Qz(G))if(!Wz.call(z,K)&&K!==H)N(z,K,{get:()=>G[K],enumerable:!(Q=Kz(G,K))||Q.enumerable})}return z},Zz=(z)=>Yz(N({},"__esModule",{value:!0}),z),O={};Xz(O,{VercelOidcTokenError:()=>S});E.exports=Zz(O);class S extends Error{constructor(z,G){super(z);this.name="VercelOidcTokenError",this.cause=G}toString(){if(this.cause)return`${this.name}: ${this.message}: ${this.cause}`;return`${this.name}: ${this.message}`}}});var P=Z((qG,y)=>{var{create:$z,defineProperty:L,getOwnPropertyDescriptor:qz,getOwnPropertyNames:vz,getPrototypeOf:Bz}=Object,Fz=Object.prototype.hasOwnProperty,Uz=(z,G)=>{for(var H in G)L(z,H,{get:G[H],enumerable:!0})},C=(z,G,H,Q)=>{if(G&&typeof G==="object"||typeof G==="function"){for(let K of vz(G))if(!Fz.call(z,K)&&K!==H)L(z,K,{get:()=>G[K],enumerable:!(Q=qz(G,K))||Q.enumerable})}return z},I=(z,G,H)=>(H=z!=null?$z(Bz(z)):{},C(G||!z||!z.__esModule?L(H,"default",{value:z,enumerable:!0}):H,z)),Lz=(z)=>C(L({},"__esModule",{value:!0}),z),x={};Uz(x,{findRootDir:()=>Jz,getUserDataDir:()=>Nz});y.exports=Lz(x);var B=I(W("path")),bz=I(W("fs")),A=I(W("os")),Vz=R();function Jz(){try{let z=process.cwd();while(z!==B.default.dirname(z)){let G=B.default.join(z,".vercel");if(bz.default.existsSync(G))return z;z=B.default.dirname(z)}}catch(z){throw new Vz.VercelOidcTokenError("Token refresh only supported in node server environments")}return null}function Nz(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(A.default.platform()){case"darwin":return B.default.join(A.default.homedir(),"Library/Application Support");case"linux":return B.default.join(A.default.homedir(),".local/share");case"win32":if(process.env.LOCALAPPDATA)return process.env.LOCALAPPDATA;return null;default:return null}}});var i=Z((vG,c)=>{var{create:Rz,defineProperty:b,getOwnPropertyDescriptor:Az,getOwnPropertyNames:Iz,getPrototypeOf:Dz}=Object,wz=Object.prototype.hasOwnProperty,Tz=(z,G)=>{for(var H in G)b(z,H,{get:G[H],enumerable:!0})},u=(z,G,H,Q)=>{if(G&&typeof G==="object"||typeof G==="function"){for(let K of Iz(G))if(!wz.call(z,K)&&K!==H)b(z,K,{get:()=>G[K],enumerable:!(Q=Az(G,K))||Q.enumerable})}return z},l=(z,G,H)=>(H=z!=null?Rz(Dz(z)):{},u(G||!z||!z.__esModule?b(H,"default",{value:z,enumerable:!0}):H,z)),jz=(z)=>u(b({},"__esModule",{value:!0}),z),g={};Tz(g,{isValidAccessToken:()=>Ez,readAuthConfig:()=>Oz,writeAuthConfig:()=>Sz});c.exports=jz(g);var F=l(W("fs")),h=l(W("path")),Mz=f();function k(){let z=(0,Mz.getVercelDataDir)();if(!z)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(z,"auth.json")}function Oz(){try{let z=k();if(!F.existsSync(z))return null;let G=F.readFileSync(z,"utf8");if(!G)return null;return JSON.parse(G)}catch(z){return null}}function Sz(z){let G=k(),H=h.dirname(G);if(!F.existsSync(H))F.mkdirSync(H,{mode:504,recursive:!0});F.writeFileSync(G,JSON.stringify(z,null,2),{mode:384})}function Ez(z,G=0){if(!z.token)return!1;if(typeof z.expiresAt!=="number")return!0;let H=Math.floor(Date.now()/1000),Q=G/1000;return z.expiresAt>=H+Q}});var a=Z((BG,s)=>{var{defineProperty:T,getOwnPropertyDescriptor:Cz,getOwnPropertyNames:xz}=Object,yz=Object.prototype.hasOwnProperty,Pz=(z,G)=>{for(var H in G)T(z,H,{get:G[H],enumerable:!0})},uz=(z,G,H,Q)=>{if(G&&typeof G==="object"||typeof G==="function"){for(let K of xz(G))if(!yz.call(z,K)&&K!==H)T(z,K,{get:()=>G[K],enumerable:!(Q=Cz(G,K))||Q.enumerable})}return z},lz=(z)=>uz(T({},"__esModule",{value:!0}),z),d={};Pz(d,{processTokenResponse:()=>iz,refreshTokenRequest:()=>cz});s.exports=lz(d);var D=W("os"),gz="https://vercel.com",hz="cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp",p=`@vercel/oidc node-${process.version} ${(0,D.platform)()} (${(0,D.arch)()}) ${(0,D.hostname)()}`,w=null;async function kz(){if(w)return w;let z=`${gz}/.well-known/openid-configuration`,G=await fetch(z,{headers:{"user-agent":p}});if(!G.ok)throw Error("Failed to discover OAuth endpoints");let H=await G.json();if(!H||typeof H.token_endpoint!=="string")throw Error("Invalid OAuth discovery response");let Q=H.token_endpoint;return w=Q,Q}async function cz(z){let G=await kz();return await fetch(G,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","user-agent":p},body:new URLSearchParams({client_id:hz,grant_type:"refresh_token",...z})})}async function iz(z){let G=await z.json();if(!z.ok){let H=typeof G==="object"&&G&&"error"in G?String(G.error):"Token refresh failed";return[Error(H)]}if(typeof G!=="object"||G===null)return[Error("Invalid token response")];if(typeof G.access_token!=="string")return[Error("Missing access_token in response")];if(G.token_type!=="Bearer")return[Error("Invalid token_type in response")];if(typeof G.expires_in!=="number")return[Error("Missing expires_in in response")];return[null,G]}});var t=Z((FG,r)=>{var{defineProperty:j,getOwnPropertyDescriptor:fz,getOwnPropertyNames:dz}=Object,pz=Object.prototype.hasOwnProperty,sz=(z,G)=>{for(var H in G)j(z,H,{get:G[H],enumerable:!0})},az=(z,G,H,Q)=>{if(G&&typeof G==="object"||typeof G==="function"){for(let K of dz(G))if(!pz.call(z,K)&&K!==H)j(z,K,{get:()=>G[K],enumerable:!(Q=fz(G,K))||Q.enumerable})}return z},_z=(z)=>az(j({},"__esModule",{value:!0}),z),_={};sz(_,{AccessTokenMissingError:()=>m,RefreshAccessTokenFailedError:()=>n});r.exports=_z(_);class m extends Error{constructor(){super("No authentication found. Please log in with the Vercel CLI (vercel login).");this.name="AccessTokenMissingError"}}class n extends Error{constructor(z){super("Failed to refresh authentication token.",{cause:z});this.name="RefreshAccessTokenFailedError"}}});var f=Z((UG,Hz)=>{var{create:mz,defineProperty:V,getOwnPropertyDescriptor:nz,getOwnPropertyNames:rz,getPrototypeOf:tz}=Object,ez=Object.prototype.hasOwnProperty,oz=(z,G)=>{for(var H in G)V(z,H,{get:G[H],enumerable:!0})},o=(z,G,H,Q)=>{if(G&&typeof G==="object"||typeof G==="function"){for(let K of rz(G))if(!ez.call(z,K)&&K!==H)V(z,K,{get:()=>G[K],enumerable:!(Q=nz(G,K))||Q.enumerable})}return z},zz=(z,G,H)=>(H=z!=null?mz(tz(z)):{},o(G||!z||!z.__esModule?V(H,"default",{value:z,enumerable:!0}):H,z)),zG=(z)=>o(V({},"__esModule",{value:!0}),z),Gz={};oz(Gz,{assertVercelOidcTokenResponse:()=>M,findProjectInfo:()=>QG,getTokenPayload:()=>YG,getVercelDataDir:()=>GG,getVercelOidcToken:()=>KG,getVercelToken:()=>HG,isExpired:()=>ZG,loadToken:()=>XG,saveToken:()=>WG});Hz.exports=zG(Gz);var U=zz(W("path")),X=zz(W("fs")),v=R(),J=P(),$=i(),e=a(),q=t();function GG(){let G=(0,J.getUserDataDir)();if(!G)return null;return U.join(G,"com.vercel.cli")}async function HG(z){let G=(0,$.readAuthConfig)();if(!G?.token)throw new q.AccessTokenMissingError;if((0,$.isValidAccessToken)(G,z?.expirationBufferMs))return G.token;if(!G.refreshToken)throw(0,$.writeAuthConfig)({}),new q.RefreshAccessTokenFailedError("No refresh token available");try{let H=await(0,e.refreshTokenRequest)({refresh_token:G.refreshToken}),[Q,K]=await(0,e.processTokenResponse)(H);if(Q||!K)throw(0,$.writeAuthConfig)({}),new q.RefreshAccessTokenFailedError(Q);let Y={token:K.access_token,expiresAt:Math.floor(Date.now()/1000)+K.expires_in};if(K.refresh_token)Y.refreshToken=K.refresh_token;return(0,$.writeAuthConfig)(Y),Y.token}catch(H){if((0,$.writeAuthConfig)({}),H instanceof q.AccessTokenMissingError||H instanceof q.RefreshAccessTokenFailedError)throw H;throw new q.RefreshAccessTokenFailedError(H)}}async function KG(z,G,H){let Q=`https://api.vercel.com/v1/projects/${G}/token?source=vercel-oidc-refresh${H?`&teamId=${H}`:""}`,K=await fetch(Q,{method:"POST",headers:{Authorization:`Bearer ${z}`}});if(!K.ok)throw new v.VercelOidcTokenError(`Failed to refresh OIDC token: ${K.statusText}`);let Y=await K.json();return M(Y),Y}function M(z){if(!z||typeof z!=="object")throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!("token"in z)||typeof z.token!=="string")throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function QG(){let z=(0,J.findRootDir)();if(!z)throw new v.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let G=U.join(z,".vercel","project.json");if(!X.existsSync(G))throw new v.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let H=JSON.parse(X.readFileSync(G,"utf8"));if(typeof H.projectId!=="string"&&typeof H.orgId!=="string")throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:H.projectId,teamId:H.orgId}}function WG(z,G){let H=(0,J.getUserDataDir)();if(!H)throw new v.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let Q=U.join(H,"com.vercel.token",`${G}.json`),K=JSON.stringify(z);X.mkdirSync(U.dirname(Q),{mode:504,recursive:!0}),X.writeFileSync(Q,K),X.chmodSync(Q,432);return}function XG(z){let G=(0,J.getUserDataDir)();if(!G)throw new v.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");let H=U.join(G,"com.vercel.token",`${z}.json`);if(!X.existsSync(H))return null;let Q=JSON.parse(X.readFileSync(H,"utf8"));return M(Q),Q}function YG(z){let G=z.split(".");if(G.length!==3)throw new v.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let H=G[1].replace(/-/g,"+").replace(/_/g,"/"),Q=H.padEnd(H.length+(4-H.length%4)%4,"=");return JSON.parse(Buffer.from(Q,"base64").toString("utf8"))}function ZG(z,G=0){return z.exp*1000<Date.now()+G}});
|
|
2
2
|
export{R as a,f as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{if as O,jf as U,mf as b,nf as m,of as L,sf as y}from"./index-g556s1mz.js";import{createHash as Zz,randomUUID as v}from"node:crypto";import{chmod as t,mkdir as r,open as e,readdir as j,rename as zz,rmdir as Gz,stat as Jz,unlink as S}from"node:fs/promises";import{join as R,resolve as D}from"node:path";function l(z){return typeof z==="number"&&Number.isSafeInteger(z)&&z>0}function F(z){if(!l(z))return!1;try{return process.kill(z,0),!0}catch(J){return J.code==="EPERM"}}function Cz(z){return(J)=>Kz(J,z)}function Kz(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 Nz(z){let J=/^port-(\d+)\.json$/.exec(z);return J?Number(J[1]):void 0}function p(z,J){if(z===null||typeof z!=="object"||Array.isArray(z))return!1;let{pid:V,port:Q,token:K}=z;return l(V)&&Nz(J)===V&&typeof Q==="number"&&Number.isInteger(Q)&&Q>=1&&Q<=65535&&typeof K==="string"&&K.length>0}async function h(z,J){J?.debug("rpc corrupt port file",{pid:process.pid,portFile:z}),await S(z).catch(()=>{})}async function Az(z,J,V={}){let Q=async()=>{let K=R(z,`port-${J.pid}.json`);if(O)return await m(z,V.secureDir??!1),await V.beforeWrite?.(),await y(K,JSON.stringify({...J,startedAt:Date.now()}),{stagePath:`${K}.${(V.stageName??v)()}.tmp`}),K;if(await r(z,{recursive:!0,mode:V.secureDir?448:void 0}),V.secureDir)await t(z,448);await V.beforeWrite?.();let W={...J,startedAt:Date.now()},Y=`${K}.${(V.stageName??v)()}.tmp`,N,G=!1;try{N=await e(Y,"wx",384),G=!0,await N.writeFile(JSON.stringify(W),"utf8"),await N.chmod(384),await N.close(),N=void 0,await zz(Y,K),G=!1}finally{if(await N?.close().catch(()=>{}),G)await S(Y).catch(()=>{})}return K};try{return await Q()}catch(K){if(K.code==="ENOENT")return await Q();throw K}}async function Oz(z,J,V,Q){let K;try{K=await j(z,{withFileTypes:!0})}catch(Y){if(Y.code==="ENOENT")return;throw Y}let W=D(J);for(let Y of K){if(!Y.isDirectory()||!V(Y.name))continue;let N=R(z,Y.name),G;try{G=await j(N)}catch(X){if(X.code==="ENOENT")continue;throw X}for(let X of G){if(!X.startsWith("port-")||!X.endsWith(".json"))continue;let $=R(N,X),Z;try{Z=await L($)}catch(H){if(H instanceof U&&H.code!=="ENOENT")throw H;continue}if(Z===void 0)continue;let q;try{q=JSON.parse(Z)}catch{await h($,Q);continue}if(!p(q,X)){await h($,Q);continue}if(!F(q.pid))await S($).catch(()=>{})}if(D(N)!==W)await Gz(N).catch(()=>{})}}async function c(z,J){if(!F(J.pid))return null;let V=R(D(z),`port-${J.pid}.json`);try{if(O)await b(V,"file");let Q=await Jz(V);return`${V}:${Q.dev}:${Q.ino}:${Q.mtimeMs}:${Q.size}`}catch(Q){if(Q instanceof U&&Q.code!=="ENOENT")throw Q;return null}}async function a(z,J,V={}){let Q;try{if(O)await b(z,"directory");Q=await j(z)}catch(G){if(G instanceof U&&G.code!=="ENOENT")throw G;return null}let K=[];for(let G of Q){if(!G.startsWith("port-")||!G.endsWith(".json"))continue;try{let X=JSON.parse(await L(R(z,G)));if(p(X,G))if(F(X.pid))K.push(X);else await S(R(z,G)).catch(()=>{})}catch(X){if(X instanceof U&&X.code!=="ENOENT")throw X}}if(K.length===0)return null;let W=J!==void 0&&J>=1?K.filter((G)=>G.pid===J):[];if(V.exactPid===!0&&W.length===0)return null;let Y=W.length>0?W:K,N=(G)=>typeof G.startedAt==="number"&&Number.isFinite(G.startedAt)?G.startedAt:-1/0;return Y.sort((G,X)=>N(X)-N(G))[0]??null}import{open as Qz}from"node:fs/promises";import{connect as Vz}from"node:net";import{join as Wz,resolve as o}from"node:path";var i=2000,A=new Map,T=new Map;async function Xz(z,J){let V=Wz(o(z),`port-${J.pid}.json`);if(O){let K=JSON.parse(await L(V));if(K.pid!==J.pid||K.port!==J.port||K.token!==J.token)return null;return null}let Q;try{Q=await Qz(V,"r");let K=await Q.stat(),W=JSON.parse(await Q.readFile("utf8"));if(W.pid!==J.pid||W.port!==J.port||W.token!==J.token)return null;return`${V}:${K.dev}:${K.ino}:${K.mtimeMs}:${K.size}`}catch{return null}finally{await Q?.close().catch(()=>{})}}async function s(z,J,V,Q){let K=A.get(z);if(!O&&K&&await c(J,K.entry)===K.identity)return K;A.delete(z);let W=T.get(z);if(W)return W;let Y=(async()=>{let N=await(Q.discover??a)(J,V,Q);if(!N)return null;let G=await Xz(J,N);if(!G)return{entry:N,identity:""};let X={entry:N,identity:G};return A.set(z,X),X})();T.set(z,Y);try{return await Y}finally{if(T.get(z)===Y)T.delete(z)}}async function d(z,J,V,Q=i){return new Promise((K)=>{let W,Y=!1,N=!1,G=($,Z=!1)=>{if(Y)return;Y=!0,clearTimeout(X),W?.destroy(),K({value:$,stale:Z})},X=setTimeout(()=>G(null),Q);try{let $=JSON.stringify(V);W=Vz({host:"127.0.0.1",port:z.port}),W.on("connect",()=>{N=!0,W?.write(`POST /rpc/${J} HTTP/1.0\r
|
|
2
2
|
Host: 127.0.0.1:${z.port}\r
|
|
3
3
|
Connection: close\r
|
|
4
4
|
Content-Type: application/json\r
|
|
@@ -9,4 +9,4 @@ Authorization: Bearer ${z.token}\r
|
|
|
9
9
|
\r
|
|
10
10
|
`);if(B>=0)C=B+4;if((C??_.length)>16384)return G(null);if(C!==void 0){let x=_.subarray(0,B).toString("latin1").split(`\r
|
|
11
11
|
`),f=/^HTTP\/1\.[01] (\d{3})(?: |$)/.exec(x[0]??"");if(!f)return G(null);let w=Number(f[1]);if(w<200||w>=300)return G(null,[401,403,404,410].includes(w));for(let M of x.slice(1)){let k=M.indexOf(":"),u=M.slice(0,k).toLowerCase(),P=M.slice(k+1).trim();if(u==="transfer-encoding")return G(null);if(u==="content-length"){if(H!==void 0||!/^\d+$/.test(P))return G(null);if(H=Number(P),!Number.isSafeInteger(H)||H>8388608)return G(null)}}_=Buffer.alloc(0)}}let I=q-(C??q);if(I>8388608)return G(null);if(H!==void 0){if(I>H)return G(null);if(I===H)g()}}),W.on("end",()=>{if(H!==void 0&&q-(C??0)!==H)return G(null);g()}),W.on("error",()=>G(null,!N)),W.on("close",()=>G(null))}catch{G(null,!N)}})}async function n(z,J,V,Q,K,W,Y=i){let N=JSON.stringify([o(z),J??null,V.exactPid===!0]),G=await s(N,z,J,V);if(Q(G?.entry??null),!G)return null;let X=Date.now()+Y,$=await d(G.entry,K,W,Y);if(!$.stale)return $.value;if(A.get(N)===G)A.delete(N);let Z=await s(N,z,J,V);if(!Z||Date.now()>=X)return null;if(Z.entry.port===G.entry.port&&Z.entry.pid===G.entry.pid&&Z.entry.token===G.entry.token){if(A.get(N)===Z)A.delete(N);return null}let q=await d(Z.entry,K,W,X-Date.now());if(q.stale&&A.get(N)===Z)A.delete(N);return q.value}function Tz(z,J,V,Q={}){let K={exactPid:Q.exactPid,discover:Q.discover},W=!1,Y=(N)=>{if(W)return;V?.(N),W=!0};return{async pending(N,G,X){return(await n(z,J,K,Y,"pending-notifications",{lastReceivedId:N,sessionId:G},X))?.messages??[]},async apply(N,G){return await n(z,J,K,Y,"apply",{...N},G)??{text:"apply failed",knobs:{}}}}}
|
|
12
|
-
export{Cz as
|
|
12
|
+
export{Cz as Re,Az as Se,Oz as Te,a as Ue,i as Ve,Tz as We};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{i as
|
|
1
|
+
import{Re as w,Se as O,Te as k}from"./index-yt52fztj.js";import{jf as h,of as D}from"./index-g556s1mz.js";import{uf as j}from"./index-c50p5mem.js";class g extends Error{operation;constructor(f){super(`a ${f} on a strict notification scope needs a session id`);this.name="RpcSessionRequiredError",this.operation=f}}function M(f){return typeof f==="string"&&f.length>0}var U=new Map;function y(f){let x=JSON.stringify([f.rpcRoot,f.directoryPrefix,f.registrationSessionId,...f.requireSession===!0?["strict"]:[]]),z=U.get(x);if(!z)z={queue:[],nextId:1,lastDrainAtBySession:new Map,lastDrainAtAny:0},U.set(x,z);return z}var m=100,t=3000;function i(f,x,z){if(f.requireSession===!0&&!M(z))throw new g("push");let H=y(f);if(H.queue.push({id:H.nextId++,type:"open-dialog",payload:x,sessionId:z}),H.queue.length>m)H.queue=H.queue.slice(-m)}function n(f,x=0,z){if(f.requireSession===!0&&!M(z))throw new g("drain");let H=y(f),Y=Date.now();if(H.lastDrainAtAny=Y,z!==void 0)H.lastDrainAtBySession.set(z,Y);let Z=f.sessionlessDrain==="broadcast-only",L=(B)=>z===void 0?!Z||B.sessionId===void 0:B.sessionId===void 0||B.sessionId===z;if(x>0)H.queue=H.queue.filter((B)=>{if(B.id>x)return!0;if(z===void 0)return!Z||B.sessionId!==void 0;return B.sessionId!==z});return H.queue.filter((B)=>B.id>x&&L(B))}function a(f,x){let z=Date.now(),H=y(f),Y=x!==void 0?H.lastDrainAtBySession.get(x)??0:f.sessionlessDrain==="broadcast-only"?H.lastDrainAtAny:0;return Y>0&&z-Y<t}import{randomBytes as v,timingSafeEqual as q}from"node:crypto";import{unlink as u}from"node:fs/promises";import{createServer as I}from"node:http";import{join as l}from"node:path";class N 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 E=1e6;class _ extends Error{declaredOversize;constructor(f){super("body too large");this.declaredOversize=f}}function p(f){return new Promise((x,z)=>{let H=(B=!1)=>{f.removeAllListeners("data"),f.on("data",()=>{}),f.resume(),z(new _(B))},Y=Number(f.headers["content-length"]);if(Number.isFinite(Y)&&Y>E){H(!0);return}let Z=[],L=0;f.on("data",(B)=>{if(L+=B.length,L>E){H();return}Z.push(B)}),f.on("end",()=>x(Buffer.concat(Z).toString("utf8"))),f.on("error",z)})}class S extends Error{}async function c(f,x){let z,H=new Promise((Y,Z)=>{z=setTimeout(()=>Z(new S("apply deadline exceeded")),x),z.unref?.()});f.catch(()=>{});try{return await Promise.race([f,H])}finally{clearTimeout(z)}}function d(f,x){if(!f?.startsWith("Bearer "))return!1;let z=Buffer.from(f.slice(7)),H=Buffer.from(x);return z.length===H.length&&q(z,H)}async function Bf(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(){}},z=v(32).toString("hex"),H=f.timeoutMs??90000,Y=f.receiptTimeoutMs??2000,Z=!1,L=new Set,B=I((V,J)=>{V.setTimeout(H,()=>{V.socket.destroy()}),T(V,J)});B.on("connection",(V)=>{L.add(V),V.once("close",()=>L.delete(V))}),B.requestTimeout=Y,B.headersTimeout=Y;async function T(V,J){let G=(X,b,C={})=>{if(J.headersSent||J.writableEnded||J.destroyed)return;J.writeHead(X,{"content-type":"application/json",...C}),J.end(JSON.stringify(b))};try{let X=new URL(V.url??"/","http://127.0.0.1").pathname;if(V.method==="GET"&&X==="/health")return G(200,{ok:!0});if(V.method!=="POST"||!X.startsWith("/rpc/"))return G(404,{error:"not found"});if(!d(V.headers.authorization,z))return G(401,{error:"unauthorized"});let b=X.slice(5),C;try{C=await p(V)}catch($){if(!($ instanceof _))throw $;let P=V.socket;if(J.once("finish",()=>{P.end();let A=setTimeout(()=>P.destroy(),2000);if(A.unref(),V.once("end",()=>P.destroy()),P.once("close",()=>clearTimeout(A)),V.complete)P.destroy()}),!$.declaredOversize&&!V.complete){if(J.headersSent||J.writableEnded||J.destroyed)return;let A=JSON.stringify({error:"body too large"});J.writeHead(413,{"content-type":"application/json","content-length":Buffer.byteLength(A),connection:"close"}),J.write(A),V.once("end",()=>J.end());return}return G(413,{error:"body too large"},{connection:"close"})}let F;try{F=JSON.parse(C||"{}")}catch{return G(400,{error:"invalid json"})}if(b==="pending-notifications"){let $;try{if(f.parsePending)$=f.parsePending(F);else{if(!F||typeof F!=="object"||Array.isArray(F))throw Error("invalid params");let K=F;if(f.requireSession===!0&&!M(K.sessionId))return G(400,{error:"session required"});if("lastReceivedId"in K&&(typeof K.lastReceivedId!=="number"||!Number.isSafeInteger(K.lastReceivedId)||K.lastReceivedId<0)||"sessionId"in K&&typeof K.sessionId!=="string")throw Error("invalid params");$={lastReceivedId:Number(K.lastReceivedId??0),sessionId:typeof K.sessionId==="string"?K.sessionId:void 0}}}catch(K){if(K instanceof N)throw K;return G(400,{error:"invalid params"})}let{lastReceivedId:P,sessionId:A}=$;if(f.requireSession===!0&&!M(A))return G(400,{error:"session required"});if(A===void 0&&!Z)Z=!0,x.warn("rpc notification drain missing session id",{pid:process.pid});let W;if(f.drainAsync)try{W=await f.drainAsync(P,A)}catch(K){return x.warn("rpc notification drain failed",{pid:process.pid,error:K instanceof Error?K.message:String(K)}),G(500,{error:"drain failed"})}else W=f.drain?.(P,A);return G(200,{messages:W})}if(b==="apply"){let $=Promise.resolve(f.apply(F)),P=f.applyDeadlineMs===void 0?await $:await c($,f.applyDeadlineMs);return G(200,P)}return G(404,{error:"unknown method"})}catch(X){if(X instanceof N)return x.debug("rpc request refused",{pid:process.pid,status:X.status}),G(X.status,{error:X.message});if(X instanceof S)return x.warn("rpc apply deadline exceeded",{pid:process.pid,deadlineMs:f.applyDeadlineMs}),G(504,{error:"handler deadline exceeded"});x.warn("rpc request failed",{pid:process.pid,error:X instanceof Error?X.message:String(X)}),G(500,{error:"internal error"})}}let Q=await new Promise((V,J)=>{B.on("error",J),B.listen(0,"127.0.0.1",()=>{let G=B.address();if(G&&typeof G==="object")V(G.port);else J(Error("no port"))})});if(B.unref(),f.sweepRoot)try{await k(f.sweepRoot,f.dir,f.isManagedDir,x)}catch(V){x.warn("rpc state sweep failed",{pid:process.pid,error:V instanceof Error?V.message:String(V)})}try{await O(f.dir,{port:Q,token:z,pid:process.pid},{secureDir:f.secureDir}),x.debug("rpc server pid",{pid:process.pid,rpcPort:Q})}catch(V){throw await new Promise((J)=>B.close(()=>J())),V}return{port:Q,token:z,async stop(){await new Promise((G)=>{B.closeAllConnections?.(),B.close(()=>G());for(let X of L)X.destroy()});let V=l(f.dir,`port-${process.pid}.json`),J=await D(V).then((G)=>JSON.parse(G)).catch((G)=>{if(G instanceof h&&G.code!=="ENOENT")throw G;return});if(J?.port===Q&&J.token===z)await u(V).catch(()=>{})}}}async function Hf(f,x,z){let H=globalThis,Y=Symbol.for(f),Z=H[Y]??{servers:new Map,pending:new Map};H[Y]=Z;let{servers:L,pending:B}=Z,T=B.get(x)??Promise.resolve(),Q,V=T.catch(()=>{}).then(async()=>{let G=L.get(x);if(G){if(await G.stop(),L.get(x)===G)L.delete(x)}Q=await z(),L.set(x,Q)});B.set(x,V);try{await V}finally{if(B.get(x)===V)B.delete(x)}let J=Q;if(!J)throw Error("RPC server failed to start");return{server:J,release:async()=>{if(L.get(x)!==J)return;if(await J.stop(),L.get(x)===J)L.delete(x)}}}var R="1.8.2";function bf(f,x,z){let H={...x,version:R};return O(f,H,z)}var Cf=w(j);
|
|
2
|
+
export{i as Je,n as Ke,a as Le,Bf as Me,Hf as Ne,R as Oe,bf as Pe,Cf as Qe};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { _ as parseJwtClaims, a as RESPONSES_LITE_MODELS, g as extractAccountIdFromClaims, h as TokenResponse, l as ResetTargetIdentity, m as IdTokenClaims, n as CODEX_VERSION, o as RuntimeLayoutOptions, s as PoolLifecycleDeps, t as CODEX_USER_AGENT, u as OpenAiVault, v as AccountPaths } from "./codex-request-
|
|
2
|
-
import { S as SidebarState, y as SidebarMachineState } from "./sidebar-state-
|
|
1
|
+
import { _ as parseJwtClaims, a as RESPONSES_LITE_MODELS, g as extractAccountIdFromClaims, h as TokenResponse, l as ResetTargetIdentity, m as IdTokenClaims, n as CODEX_VERSION, o as RuntimeLayoutOptions, s as PoolLifecycleDeps, t as CODEX_USER_AGENT, u as OpenAiVault, v as AccountPaths } from "./codex-request-GJkvxv4S.js";
|
|
2
|
+
import { S as SidebarState, y as SidebarMachineState } from "./sidebar-state-DkNebAiC.js";
|
|
3
3
|
import { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
|
|
4
|
-
//#region ../core/dist/provider.d.ts
|
|
5
4
|
type QuotaWindowName = string;
|
|
6
5
|
type ProviderQuotaFn = (input: {
|
|
7
6
|
accessToken: string;
|
|
8
7
|
fetchImpl: typeof fetch;
|
|
9
8
|
now: () => number;
|
|
10
9
|
}) => Promise<OAuthQuotaSnapshot>;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region ../core/dist/quota-manager.d.ts
|
|
13
10
|
type QuotaEntry = {
|
|
14
11
|
quota: OAuthQuotaSnapshot;
|
|
15
12
|
refreshAfter: number;
|
|
@@ -180,8 +177,6 @@ declare class QuotaManager {
|
|
|
180
177
|
*/
|
|
181
178
|
private _handleFallbackFetchError;
|
|
182
179
|
}
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region ../core/dist/accounts.d.ts
|
|
185
180
|
type AccountQuotaWindow = {
|
|
186
181
|
usedPercent: number;
|
|
187
182
|
remainingPercent: number;
|
|
@@ -376,8 +371,6 @@ type AccountStorage = {
|
|
|
376
371
|
accounts: FallbackAccount[];
|
|
377
372
|
};
|
|
378
373
|
declare function loadAccounts(paths: AccountPaths): Promise<AccountStorage | null>;
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region src/core/background-quota-refresh.d.ts
|
|
381
374
|
type TimerHandle = ReturnType<typeof setInterval>;
|
|
382
375
|
interface BackgroundQuotaRefreshOptions {
|
|
383
376
|
setIntervalFn?: (callback: () => void, intervalMs: number) => TimerHandle;
|
|
@@ -399,8 +392,6 @@ declare class BackgroundQuotaRefresh {
|
|
|
399
392
|
stop(): void;
|
|
400
393
|
isStopped(): boolean;
|
|
401
394
|
}
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/index.d.ts
|
|
404
395
|
export declare const ALLOWED_MODELS: Set<string>;
|
|
405
396
|
export declare const DISALLOWED_MODELS: Set<string>;
|
|
406
397
|
/**
|
|
@@ -555,5 +546,4 @@ declare const _default: {
|
|
|
555
546
|
id: string;
|
|
556
547
|
server: Plugin;
|
|
557
548
|
};
|
|
558
|
-
//#endregion
|
|
559
549
|
export { CODEX_USER_AGENT, CODEX_VERSION, type IdTokenClaims, RESPONSES_LITE_MODELS, _default as default, extractAccountIdFromClaims, parseJwtClaims };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as x,J as f,K as g,L as h,M as i,N as j,O as k,P as l,Q as m,R as n,S as o,T as p,U as q,V as r,W as s,X as t,Y as u,Z as v,_ as w,aa as y,ba as z,ca as A,da as B,ea as C,fa as D,ga as E,ha as F,ia as G,j as c,k as d,l as e}from"./index-
|
|
1
|
+
import{$ as x,J as f,K as g,L as h,M as i,N as j,O as k,P as l,Q as m,R as n,S as o,T as p,U as q,V as r,W as s,X as t,Y as u,Z as v,_ as w,aa as y,ba as z,ca as A,da as B,ea as C,fa as D,ga as E,ha as F,ia as G,j as c,k as d,l as e}from"./index-0dmg1yer.js";import"./index-ctch2vgj.js";import"./index-03hs0rq7.js";import{dd as a,ed as b}from"./index-b0s5cty6.js";import"./index-fyrgwfx3.js";import"./index-z36br4a0.js";import"./index-yt52fztj.js";import"./index-dw6yd976.js";import"./index-g556s1mz.js";import"./index-c50p5mem.js";import"./index-hpnj460b.js";export{D as rewriteResponsesLiteBody,B as resolveSidebarSessionId,s as poolResetTarget,a as parseJwtClaims,y as mergePushedQuotaMetadata,l as getMainRefreshLockName,x as findCachekeepFallbackAccount,b as extractAccountIdFromClaims,G as default,t as createResetTargetResolver,j as codexOAuthModelVariantSource,h as codexOAuthModelListed,i as codexOAuthModelLimit,A as buildSidebarState,z as buildSidebarMachineState,u as buildResetRedemptionDeps,p as __resetBootQuotaSeedForTest,v as __menuContextForTest,o as __bootQuotaSeedPromiseForTest,r as ResetTargetResolutionError,c as RESPONSES_LITE_MODELS,w as POOL_MIGRATION_ENABLED,F as OpenAIAuthPlugin,C as MID_CONVERSATION_EFFORT_MODELS,m as MAIN_REFRESH_LOCK_TTL_MS,n as MAIN_REFRESH_LEASE_TTL_MS,k as EMPTY_BEARER_MESSAGE,g as DISALLOWED_MODELS,E as CodexAuthPlugin,d as CODEX_VERSION,e as CODEX_USER_AGENT,q as AuthPersistError,f as ALLOWED_MODELS};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.27.1+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/rpc/port-file.d.ts
|
|
2
1
|
interface PortFileEntry {
|
|
3
2
|
port: number;
|
|
4
3
|
token: string;
|
|
@@ -25,5 +24,4 @@ interface DiscoverPortFileOptions {
|
|
|
25
24
|
exactPid?: boolean;
|
|
26
25
|
}
|
|
27
26
|
declare function discoverPortFile(dir: string, expectedPid?: number, options?: DiscoverPortFileOptions): Promise<PortFileEntry | null>;
|
|
28
|
-
//#endregion
|
|
29
27
|
export { discoverPortFile as n, writePortFile as r, PortFileEntry as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.27.1+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/commands/model.d.ts
|
|
2
1
|
/** The section slots, in the one order every renderer shows them. */
|
|
3
2
|
declare const SECTION_SLOTS: readonly ['accounts', 'quota', 'routing', 'limits', 'cache', 'diagnostics', 'extra'];
|
|
4
3
|
type SectionSlot = (typeof SECTION_SLOTS)[number];
|
|
@@ -167,8 +166,6 @@ interface CommandApplyResult {
|
|
|
167
166
|
menu: CommandMenuModel;
|
|
168
167
|
}
|
|
169
168
|
type NotifyKind = 'info' | 'warning' | 'error';
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region ../core/dist/protocol.d.ts
|
|
172
169
|
/** The menu, as the slash command opens it in the TUI. */
|
|
173
170
|
type OpenDialogPayload = CommandDialogPayload;
|
|
174
171
|
/**
|
|
@@ -194,5 +191,4 @@ type ApplyRequest = CommandApplyRequest;
|
|
|
194
191
|
type ApplyResult = CommandApplyResult;
|
|
195
192
|
/** Whether a pushed notification is the menu itself or a message. */
|
|
196
193
|
declare function isNotifyPayload(payload: OpenDialogPayload | NotifyPayload): payload is NotifyPayload;
|
|
197
|
-
//#endregion
|
|
198
194
|
export { RpcNotification as a, OpenDialogPayload as i, ApplyResult as n, isNotifyPayload as o, NotifyPayload as r, ApplyRequest as t };
|
package/dist/rpc/port-file.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { n as discoverPortFile, r as writePortFile$1, t as PortFileEntry } from "../port-file-
|
|
2
|
-
//#region src/rpc/port-file.d.ts
|
|
1
|
+
import { n as discoverPortFile, r as writePortFile$1, t as PortFileEntry } from "../port-file-DXCxv8tU.js";
|
|
3
2
|
/** Stamp the record itself; a heartbeat with the same pid may be stale. */
|
|
4
3
|
export declare function writePortFile(dir: string, entry: Parameters<typeof writePortFile$1>[1], options?: Parameters<typeof writePortFile$1>[2]): Promise<string>;
|
|
5
4
|
export declare const isOpenaiRpcStateDir: (name: string) => boolean;
|
|
6
|
-
//#endregion
|
|
7
5
|
export { type PortFileEntry, discoverPortFile };
|
package/dist/rpc/port-file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Pe as b,Qe as c}from"../index-z36br4a0.js";import{Ue as a}from"../index-yt52fztj.js";import"../index-g556s1mz.js";import"../index-c50p5mem.js";import"../index-hpnj460b.js";export{b as writePortFile,c as isOpenaiRpcStateDir,a as discoverPortFile};
|
package/dist/rpc/protocol.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RpcNotification, i as OpenDialogPayload, n as ApplyResult, o as isNotifyPayload, r as NotifyPayload, t as ApplyRequest } from "../protocol-
|
|
1
|
+
import { a as RpcNotification, i as OpenDialogPayload, n as ApplyResult, o as isNotifyPayload, r as NotifyPayload, t as ApplyRequest } from "../protocol-BZZtDn5h.js";
|
|
2
2
|
export { type ApplyRequest, type ApplyResult, type NotifyPayload, type OpenDialogPayload, type RpcNotification, isNotifyPayload };
|
package/dist/rpc/protocol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{gf as b}from"../index-dw6yd976.js";import"../index-g556s1mz.js";import"../index-hpnj460b.js";export{b as isNotifyPayload};
|
package/dist/rpc/rpc-client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createRpcClient, r as DEFAULT_RPC_TIMEOUT_MS, t as RpcClient } from "../rpc-client-
|
|
1
|
+
import { n as createRpcClient, r as DEFAULT_RPC_TIMEOUT_MS, t as RpcClient } from "../rpc-client-CmaZW1by.js";
|
|
2
2
|
export { DEFAULT_RPC_TIMEOUT_MS, RpcClient, createRpcClient };
|
package/dist/rpc/rpc-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ve as F,We as f}from"../index-yt52fztj.js";import"../index-g556s1mz.js";import"../index-hpnj460b.js";function y(r,s,v){return f(r,s,v)}export{y as createRpcClient,F as DEFAULT_RPC_TIMEOUT_MS};
|
package/dist/rpc/rpc-dir.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { tmpdir } from "node:os";
|
|
2
|
-
//#region src/rpc/rpc-dir.d.ts
|
|
3
2
|
/** Name prefix of this plugin's per-project RPC state directories. */
|
|
4
3
|
export declare const RPC_DIRECTORY_PREFIX = "openai-auth-";
|
|
5
4
|
export interface RpcDirResolution {
|
|
@@ -9,5 +8,4 @@ export interface RpcDirResolution {
|
|
|
9
8
|
}
|
|
10
9
|
export declare function getRpcDir(projectDirectory: string): string;
|
|
11
10
|
export declare function resolveRpcDir(projectDirectory: string): Promise<RpcDirResolution>;
|
|
12
|
-
//#endregion
|
|
13
11
|
export { tmpdir };
|
package/dist/rpc/rpc-dir.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{tf as a,uf as b,vf as c,wf as d}from"../index-c50p5mem.js";import"../index-hpnj460b.js";export{a as tmpdir,d as resolveRpcDir,c as getRpcDir,b as RPC_DIRECTORY_PREFIX};
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { a as RpcNotification, n as ApplyResult, t as ApplyRequest } from "./protocol-
|
|
2
|
-
import { t as PortFileEntry } from "./port-file-
|
|
3
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.27.1+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/rpc/rpc-client.d.ts
|
|
1
|
+
import { a as RpcNotification, n as ApplyResult, t as ApplyRequest } from "./protocol-BZZtDn5h.js";
|
|
2
|
+
import { t as PortFileEntry } from "./port-file-DXCxv8tU.js";
|
|
4
3
|
declare const DEFAULT_RPC_TIMEOUT_MS = 2000;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/rpc/rpc-client.d.ts
|
|
7
4
|
interface RpcClient {
|
|
8
5
|
pending: (lastReceivedId: number, sessionId?: string, timeoutMs?: number) => Promise<RpcNotification[]>;
|
|
9
6
|
apply: (request: ApplyRequest, timeoutMs?: number) => Promise<ApplyResult>;
|
|
10
7
|
}
|
|
11
8
|
declare function createRpcClient(dir: string, expectedPid?: number, onSelected?: (entry: PortFileEntry | null) => void): RpcClient;
|
|
12
|
-
//#endregion
|
|
13
9
|
export { createRpcClient as n, DEFAULT_RPC_TIMEOUT_MS as r, RpcClient as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.27.1+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/logger/engine.d.ts
|
|
2
1
|
interface ChannelLogger {
|
|
3
2
|
error(message: string, data?: unknown): void;
|
|
4
3
|
warn(message: string, data?: unknown): void;
|
|
@@ -7,8 +6,6 @@ interface ChannelLogger {
|
|
|
7
6
|
trace(message: string, data?: unknown): void;
|
|
8
7
|
}
|
|
9
8
|
declare function createLogger(channel: string): ChannelLogger;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.27.1+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
|
|
12
9
|
interface QuotaReadingEntry {
|
|
13
10
|
scope: string;
|
|
14
11
|
label: string;
|
|
@@ -80,8 +77,6 @@ interface QuotaMap {
|
|
|
80
77
|
/** Absent means no observation has reported on prepaid credits yet. */
|
|
81
78
|
credits?: QuotaCredits;
|
|
82
79
|
}
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.27.1+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/quota/projection.d.ts
|
|
85
80
|
interface ProjectedLimit {
|
|
86
81
|
scope: string;
|
|
87
82
|
label: string;
|
|
@@ -133,8 +128,6 @@ interface ProjectedQuota {
|
|
|
133
128
|
*/
|
|
134
129
|
groups?: readonly QuotaGroup[];
|
|
135
130
|
}
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.27.1+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/sidebar-file/sidebar-file.d.ts
|
|
138
131
|
interface SidebarFileHooks {
|
|
139
132
|
/** Runs on the first merge attempt, before checking for older, unlocked writers. */
|
|
140
133
|
beforeRecheck?: () => void | Promise<void>;
|
|
@@ -143,8 +136,6 @@ interface SidebarFileHooks {
|
|
|
143
136
|
/** @internal Test seam after the rename, before ownership is checked again. */
|
|
144
137
|
afterRename?: () => Promise<void>;
|
|
145
138
|
}
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/sidebar-state.d.ts
|
|
148
139
|
interface QuotaWindow {
|
|
149
140
|
usedPercent: number;
|
|
150
141
|
remainingPercent: number;
|
|
@@ -290,6 +281,8 @@ interface SidebarState {
|
|
|
290
281
|
* account's email when the vault knows it, else the vault's label.
|
|
291
282
|
*/
|
|
292
283
|
vaultAccounts?: SidebarAccountState[];
|
|
284
|
+
/** Whether the vault supplied a roster snapshot, including an empty one. */
|
|
285
|
+
vaultDiscovered?: boolean;
|
|
293
286
|
}
|
|
294
287
|
declare const STICKY_ASSIGNMENT_MAX_AGE_MS: number;
|
|
295
288
|
declare const STICKY_ASSIGNMENT_MAX_ENTRIES = 256;
|
|
@@ -348,7 +341,7 @@ type SidebarMergeHooks = Pick<SidebarFileHooks, 'beforeRecheck'> & {
|
|
|
348
341
|
* Defaults to getSidebarStateFile() (per-call resolution).
|
|
349
342
|
*/
|
|
350
343
|
declare function setSidebarState(state: SidebarState, file?: string): Promise<void>;
|
|
351
|
-
type SidebarMachineState = Pick<SidebarState, 'main' | 'fallbacks' | 'planType' | 'lastUpdated' | 'accountPool' | 'vaultAccounts'> & {
|
|
344
|
+
type SidebarMachineState = Pick<SidebarState, 'main' | 'fallbacks' | 'planType' | 'lastUpdated' | 'accountPool' | 'vaultAccounts' | 'vaultDiscovered'> & {
|
|
352
345
|
route: string;
|
|
353
346
|
};
|
|
354
347
|
declare function setSidebarMachineState(machineState: SidebarMachineState, file?: string, hooks?: SidebarMergeHooks): Promise<void>;
|
|
@@ -544,5 +537,4 @@ interface QuotaPacing {
|
|
|
544
537
|
runsOutAt: string | null;
|
|
545
538
|
}
|
|
546
539
|
declare function computeQuotaPacing(window: QuotaWindow, windowMs: number, now: number): QuotaPacing | null;
|
|
547
|
-
//#endregion
|
|
548
540
|
export { planSidebarStickyAssignment as $, StickyPinOverlayEntry as A, exhaustedQuotaResetAt as B, SidebarStateCache as C, StickyAssignmentMap as D, StickyAssignmentChoice as E, computeQuotaPacing as F, getPresentQuotaWindows as G, formatWindowLabel as H, createSidebarBookkeepingQueue as I, hashSidebarSessionId as J, getSidebarState as K, createSidebarStateCache as L, accountServesOnCredits as M, applyStickyPinOverlay as N, StickyAssignmentPlan as O, clearSidebarStickyAssignment as P, persistSidebarStickyAssignment as Q, displayWidth as R, SidebarState as S, StickyAssignment as T, getCollapsedAccountLines as U, fitCollapsedLabel as V, getCollapsedQuotaSummary as W, isUsableRoutingEntry as X, isQuotaExhausted as Y, normalizeSidebarState as Z, SidebarAccountState as _, ActiveRoutingEntry as a, resolveActiveAccount as at, SidebarRoutingAccount as b, DEFAULT_SIDEBAR_STATE as c, resolveSidebarStickyAssignment as ct, QuotaPacing as d, setSidebarState as dt, planSidebarStickyAssignmentFromSnapshot as et, QuotaWindow as f, settleWithinBudget as ft, STICKY_ASSIGNMENT_MAX_ENTRIES as g, QuotaMap as gt, STICKY_ASSIGNMENT_MAX_AGE_MS as h, upsertSidebarActiveRouting as ht, AccountQuota as i, removeSidebarActiveRouting as it, accountCreditsText as j, StickyPinOverlay as k, HOT_PATH_READ_BUDGET_MS as l, setSidebarLegacyRouting as lt, ResolveStickyAssignmentInput as m, spendControlExhaustedResetAt as mt, ACTIVE_ROUTING_MAX_ENTRIES as n, pruneStickyAssignments as nt, ActiveRoutingMap as o, resolveSessionSidebarRouting as ot, QuotaWindowKey as p, sidebarQuotaProjection as pt, getSidebarStateFile as q, AccountCredits as r, rememberStickyPin as rt, CollapsedAccountLine as s, resolveSessionStickyAccount as st, ACTIVE_ROUTING_MAX_AGE_MS as t, pruneActiveRouting as tt, PresentQuotaWindow as u, setSidebarMachineState as ut, SidebarBookkeepingQueue as v, SpendControlReading as w, SidebarSnapshot as x, SidebarMachineState as y, drainSidebarWrites as z };
|
package/dist/sidebar-state.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as planSidebarStickyAssignment, A as StickyPinOverlayEntry, B as exhaustedQuotaResetAt, C as SidebarStateCache, D as StickyAssignmentMap, E as StickyAssignmentChoice, F as computeQuotaPacing, G as getPresentQuotaWindows, H as formatWindowLabel, I as createSidebarBookkeepingQueue, J as hashSidebarSessionId, K as getSidebarState, L as createSidebarStateCache, M as accountServesOnCredits, N as applyStickyPinOverlay, O as StickyAssignmentPlan, P as clearSidebarStickyAssignment, Q as persistSidebarStickyAssignment, R as displayWidth, S as SidebarState, T as StickyAssignment, U as getCollapsedAccountLines, V as fitCollapsedLabel, W as getCollapsedQuotaSummary, X as isUsableRoutingEntry, Y as isQuotaExhausted, Z as normalizeSidebarState, _ as SidebarAccountState, a as ActiveRoutingEntry, at as resolveActiveAccount, b as SidebarRoutingAccount, c as DEFAULT_SIDEBAR_STATE, ct as resolveSidebarStickyAssignment, d as QuotaPacing, dt as setSidebarState, et as planSidebarStickyAssignmentFromSnapshot, f as QuotaWindow, ft as settleWithinBudget, g as STICKY_ASSIGNMENT_MAX_ENTRIES, h as STICKY_ASSIGNMENT_MAX_AGE_MS, ht as upsertSidebarActiveRouting, i as AccountQuota, it as removeSidebarActiveRouting, j as accountCreditsText, k as StickyPinOverlay, l as HOT_PATH_READ_BUDGET_MS, lt as setSidebarLegacyRouting, m as ResolveStickyAssignmentInput, mt as spendControlExhaustedResetAt, n as ACTIVE_ROUTING_MAX_ENTRIES, nt as pruneStickyAssignments, o as ActiveRoutingMap, ot as resolveSessionSidebarRouting, p as QuotaWindowKey, pt as sidebarQuotaProjection, q as getSidebarStateFile, r as AccountCredits, rt as rememberStickyPin, s as CollapsedAccountLine, st as resolveSessionStickyAccount, t as ACTIVE_ROUTING_MAX_AGE_MS, tt as pruneActiveRouting, u as PresentQuotaWindow, ut as setSidebarMachineState, v as SidebarBookkeepingQueue, w as SpendControlReading, x as SidebarSnapshot, y as SidebarMachineState, z as drainSidebarWrites } from "./sidebar-state-
|
|
1
|
+
import { $ as planSidebarStickyAssignment, A as StickyPinOverlayEntry, B as exhaustedQuotaResetAt, C as SidebarStateCache, D as StickyAssignmentMap, E as StickyAssignmentChoice, F as computeQuotaPacing, G as getPresentQuotaWindows, H as formatWindowLabel, I as createSidebarBookkeepingQueue, J as hashSidebarSessionId, K as getSidebarState, L as createSidebarStateCache, M as accountServesOnCredits, N as applyStickyPinOverlay, O as StickyAssignmentPlan, P as clearSidebarStickyAssignment, Q as persistSidebarStickyAssignment, R as displayWidth, S as SidebarState, T as StickyAssignment, U as getCollapsedAccountLines, V as fitCollapsedLabel, W as getCollapsedQuotaSummary, X as isUsableRoutingEntry, Y as isQuotaExhausted, Z as normalizeSidebarState, _ as SidebarAccountState, a as ActiveRoutingEntry, at as resolveActiveAccount, b as SidebarRoutingAccount, c as DEFAULT_SIDEBAR_STATE, ct as resolveSidebarStickyAssignment, d as QuotaPacing, dt as setSidebarState, et as planSidebarStickyAssignmentFromSnapshot, f as QuotaWindow, ft as settleWithinBudget, g as STICKY_ASSIGNMENT_MAX_ENTRIES, h as STICKY_ASSIGNMENT_MAX_AGE_MS, ht as upsertSidebarActiveRouting, i as AccountQuota, it as removeSidebarActiveRouting, j as accountCreditsText, k as StickyPinOverlay, l as HOT_PATH_READ_BUDGET_MS, lt as setSidebarLegacyRouting, m as ResolveStickyAssignmentInput, mt as spendControlExhaustedResetAt, n as ACTIVE_ROUTING_MAX_ENTRIES, nt as pruneStickyAssignments, o as ActiveRoutingMap, ot as resolveSessionSidebarRouting, p as QuotaWindowKey, pt as sidebarQuotaProjection, q as getSidebarStateFile, r as AccountCredits, rt as rememberStickyPin, s as CollapsedAccountLine, st as resolveSessionStickyAccount, t as ACTIVE_ROUTING_MAX_AGE_MS, tt as pruneActiveRouting, u as PresentQuotaWindow, ut as setSidebarMachineState, v as SidebarBookkeepingQueue, w as SpendControlReading, x as SidebarSnapshot, y as SidebarMachineState, z as drainSidebarWrites } from "./sidebar-state-DkNebAiC.js";
|
|
2
2
|
export { ACTIVE_ROUTING_MAX_AGE_MS, ACTIVE_ROUTING_MAX_ENTRIES, AccountCredits, AccountQuota, ActiveRoutingEntry, ActiveRoutingMap, CollapsedAccountLine, DEFAULT_SIDEBAR_STATE, HOT_PATH_READ_BUDGET_MS, PresentQuotaWindow, QuotaPacing, QuotaWindow, QuotaWindowKey, ResolveStickyAssignmentInput, STICKY_ASSIGNMENT_MAX_AGE_MS, STICKY_ASSIGNMENT_MAX_ENTRIES, SidebarAccountState, SidebarBookkeepingQueue, SidebarMachineState, SidebarRoutingAccount, SidebarSnapshot, SidebarState, SidebarStateCache, SpendControlReading, StickyAssignment, StickyAssignmentChoice, StickyAssignmentMap, StickyAssignmentPlan, StickyPinOverlay, StickyPinOverlayEntry, accountCreditsText, accountServesOnCredits, applyStickyPinOverlay, clearSidebarStickyAssignment, computeQuotaPacing, createSidebarBookkeepingQueue, createSidebarStateCache, displayWidth, drainSidebarWrites, exhaustedQuotaResetAt, fitCollapsedLabel, formatWindowLabel, getCollapsedAccountLines, getCollapsedQuotaSummary, getPresentQuotaWindows, getSidebarState, getSidebarStateFile, hashSidebarSessionId, isQuotaExhausted, isUsableRoutingEntry, normalizeSidebarState, persistSidebarStickyAssignment, planSidebarStickyAssignment, planSidebarStickyAssignmentFromSnapshot, pruneActiveRouting, pruneStickyAssignments, rememberStickyPin, removeSidebarActiveRouting, resolveActiveAccount, resolveSessionSidebarRouting, resolveSessionStickyAccount, resolveSidebarStickyAssignment, setSidebarLegacyRouting, setSidebarMachineState, setSidebarState, settleWithinBudget, sidebarQuotaProjection, spendControlExhaustedResetAt, upsertSidebarActiveRouting };
|
package/dist/sidebar-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$b as p,Ac as Q,Bc as R,Cc as S,Dc as T,Mb as a,Nb as b,Ob as c,Pb as d,Qb as e,Rb as f,Sb as g,Tb as h,Ub as i,Vb as j,Wb as k,Xb as l,Yb as m,Zb as n,_b as o,ac as q,bc as r,cc as s,dc as t,ec as u,fc as v,gc as w,hc as x,ic as y,jc as z,kc as A,lc as B,mc as C,nc as D,oc as E,pc as F,qc as G,rc as H,sc as I,tc as J,uc as K,vc as L,wc as M,xc as N,yc as O,zc as P}from"./index-
|
|
1
|
+
import{$b as p,Ac as Q,Bc as R,Cc as S,Dc as T,Mb as a,Nb as b,Ob as c,Pb as d,Qb as e,Rb as f,Sb as g,Tb as h,Ub as i,Vb as j,Wb as k,Xb as l,Yb as m,Zb as n,_b as o,ac as q,bc as r,cc as s,dc as t,ec as u,fc as v,gc as w,hc as x,ic as y,jc as z,kc as A,lc as B,mc as C,nc as D,oc as E,pc as F,qc as G,rc as H,sc as I,tc as J,uc as K,vc as L,wc as M,xc as N,yc as O,zc as P}from"./index-03hs0rq7.js";import"./index-b0s5cty6.js";import"./index-fyrgwfx3.js";import"./index-dw6yd976.js";import"./index-g556s1mz.js";import"./index-hpnj460b.js";export{y as upsertSidebarActiveRouting,p as spendControlExhaustedResetAt,O as sidebarQuotaProjection,I as settleWithinBudget,w as setSidebarState,x as setSidebarMachineState,z as setSidebarLegacyRouting,e as setLegacySidebarStateFileForTest,C as resolveSidebarStickyAssignment,s as resolveSessionStickyAccount,t as resolveSessionSidebarRouting,N as resolveActiveAccount,A as removeSidebarActiveRouting,K as rememberStickyPin,v as pruneStickyAssignments,u as pruneActiveRouting,D as planSidebarStickyAssignmentFromSnapshot,B as planSidebarStickyAssignment,E as persistSidebarStickyAssignment,k as normalizeSidebarState,o as isUsableRoutingEntry,r as isQuotaExhausted,h as hashSidebarSessionId,i as getSidebarStateFile,l as getSidebarState,d as getPresentQuotaWindows,P as getCollapsedQuotaSummary,Q as getCollapsedAccountLines,c as formatWindowLabel,S as fitCollapsedLabel,q as exhaustedQuotaResetAt,G as drainSidebarWrites,R as displayWidth,J as createSidebarStateCache,M as createSidebarBookkeepingQueue,T as computeQuotaPacing,F as clearSidebarStickyAssignment,L as applyStickyPinOverlay,b as accountServesOnCredits,a as accountCreditsText,g as STICKY_ASSIGNMENT_MAX_ENTRIES,f as STICKY_ASSIGNMENT_MAX_AGE_MS,H as HOT_PATH_READ_BUDGET_MS,j as DEFAULT_SIDEBAR_STATE,n as ACTIVE_ROUTING_MAX_ENTRIES,m as ACTIVE_ROUTING_MAX_AGE_MS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as U,b as V}from"./index-
|
|
1
|
+
import{a as U,b as V}from"./index-p8m4yh73.js";import{xf as R}from"./index-hpnj460b.js";var E=R((M,Q)=>{var{defineProperty:H,getOwnPropertyDescriptor:W,getOwnPropertyNames:X}=Object,Y=Object.prototype.hasOwnProperty,Z=(z,q)=>{for(var B in q)H(z,B,{get:q[B],enumerable:!0})},$=(z,q,B,F)=>{if(q&&typeof q==="object"||typeof q==="function"){for(let v of X(q))if(!Y.call(z,v)&&v!==B)H(z,v,{get:()=>q[v],enumerable:!(F=W(q,v))||F.enumerable})}return z},A=(z)=>$(H({},"__esModule",{value:!0}),z),L={};Z(L,{refreshToken:()=>D});Q.exports=A(L);var K=U(),G=V();async function D(z){let q=z?.project,B=z?.team;if(!q&&!B){let v=(0,G.findProjectInfo)();q=v.projectId,B=v.teamId}else if(!q||!B){let v=(0,G.findProjectInfo)();q=q??v.projectId,B=B??v.teamId}if(!q)throw new K.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let F=(0,G.loadToken)(q);if(!F||(0,G.isExpired)((0,G.getTokenPayload)(F.token),z?.expirationBufferMs)){let v=await(0,G.getVercelToken)({expirationBufferMs:z?.expirationBufferMs});if(F=await(0,G.getVercelOidcToken)(v,q,B),!F)throw new K.VercelOidcTokenError("Failed to refresh OIDC token");(0,G.saveToken)(F,q)}process.env.VERCEL_OIDC_TOKEN=F.token;return}});export default E();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a}from"./index-p8m4yh73.js";import"./index-hpnj460b.js";export default a();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/tui-preferences.d.ts
|
|
2
1
|
export declare const TUI_PREFS_FILE_ENV = "OPENCODE_TUI_PREFERENCES_FILE";
|
|
3
2
|
export declare function getTuiPreferencesFile(): string;
|
|
4
3
|
export declare function readTuiPreferencesFile(): Promise<Record<string, unknown>>;
|
|
@@ -38,5 +37,4 @@ export declare function computeEffectiveOrder(root: Record<string, unknown>, plu
|
|
|
38
37
|
type JsonValue = string | number | boolean | null;
|
|
39
38
|
export declare function queueTuiPreferenceUpdate(pluginKey: string, path: string[], value: JsonValue): Promise<void>;
|
|
40
39
|
export declare function watchTuiPreferences(onChange: () => void): () => void;
|
|
41
|
-
//#endregion
|
|
42
40
|
export {};
|
package/dist/tui-preferences.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ae as h,He as u,Ie as P}from"./index-fyrgwfx3.js";import{if as M,jf as R,of as S}from"./index-g556s1mz.js";import"./index-hpnj460b.js";import{mkdir as Yq,writeFile as Vq}from"node:fs/promises";import{homedir as Wq}from"node:os";import{dirname as Dq,join as b}from"node:path";import{applyEdits as t,modify as r,parse as e}from"jsonc-parser";function qq(z){return z!==null&&typeof z==="object"&&!Array.isArray(z)}async function k(z){try{let q=[],H=e(await S(z,M),q,{allowTrailingComma:!0});return q.length===0&&qq(H)?H:{}}catch(q){if(q instanceof R&&q.code!=="ENOENT")throw q;return{}}}var zq=`// Shared preferences for TUI plugins.
|
|
2
2
|
// Plugins update individual keys in place and preserve comments.
|
|
3
3
|
{}
|
|
4
4
|
`;function g(z){let{file:q,pluginKey:H,beforeCommit:Q}=z,$={...P.preferences,timeoutMs:z.timeoutMs??P.preferences.timeoutMs},Z=Promise.resolve();async function X(U,j){await u(q,$,async(K)=>{let J;try{J=await S(q,M)}catch(G){if(G.code!=="ENOENT")throw G;J=""}if(J.trim()==="")J=zq;let B=t(J,r(J,[H,...U],j,{formattingOptions:{insertSpaces:!0,tabSize:2}}));await h(q,B,{serialize:(G)=>String(G),beforeRename:async()=>{await Q?.(),await K.assertOwned()}})})}return{queueTuiPreferenceUpdate(U,j){let K=[...U],J=structuredClone(j),B=Z.then(()=>X(K,J));return Z=B.catch(()=>{}),B}}}import{readFileSync as Hq,realpathSync as Qq,statSync as Xq,watch as Zq}from"node:fs";import{readFile as $q,stat as Bq}from"node:fs/promises";import{basename as p,dirname as s,join as Gq,resolve as Jq}from"node:path";import{clearTimeout as w,setTimeout as c}from"node:timers";function n(z){let q=Jq(z);if(M)return q;try{return Qq(q)}catch{let H=s(q);return H===q?q:Gq(n(H),p(q))}}function d(z){return z&&`${z.dev}:${z.ino}:${z.mtimeMs}:${z.size}`}function T(z,q,H={}){let Q=globalThis,$=Symbol.for("cortexkit.common-auth.tui-prefs.watchers.v1"),Z=Q[$]??new Map;Q[$]=Z;let X=n(z),U=Z.get(X);if(U)return U.subscribe(q);let j=p(X),K=M?(Y)=>S(Y):H.fs?.readFile??((Y)=>$q(Y,"utf8")),J=H.fs?.stat??Bq,B=null,G=null,x=null,C=null;if(!M)try{let Y=d((H.fs?.statSync??Xq)(X));C=(H.fs?.readFileSync??((V)=>Hq(V,"utf8")))(X),x=Y}catch{}let N=!1,L=new Set,E=Promise.resolve(),v=(Y)=>{return E=E.then(async()=>{if(N)return;let V=d(await J(X).catch(()=>null));if(!Y&&V===x)return;if(V===null){x=null;return}let I=await K(X).catch((W)=>{if(W instanceof R&&W.code!=="ENOENT")if(H.onError)H.onError(W);else process.emitWarning(W.message,W.name);return null});if(N)return;if(I===null)return;if(x=V,I===C)return;C=I;for(let W of[...L]){if(!L.has(W))continue;try{W.notify()}catch{}}}),E},i=()=>{if(N)return;if(B)w(B);B=c(()=>{B=null,v(!0)},150)},O=null;try{O=(H.watchDirectory??Zq)(s(X),(Y,V)=>{let I=V?.toString(),W=I===j||I?.startsWith(`${j}.`)&&I.endsWith(".tmp");if(I!=null&&!W)return;i()}),O.on("error",()=>{O?.close(),O=null})}catch{}let f=()=>{if(N||G)return;G=c(()=>{if(G=null,N)return;v(!1).finally(f)},1000),G.unref()},F={subscribe:(Y)=>{let V={notify:Y};return L.add(V),()=>{if(!L.delete(V)||L.size>0)return;if(N=!0,B)w(B);if(G)w(G);if(O?.close(),Z.get(X)===F)Z.delete(X)}}};return Z.set(X,F),f(),F.subscribe(q)}var Uq="OPENCODE_TUI_PREFERENCES_FILE",Iq="tui-preferences.jsonc";function m(){let z=process.env[Uq];if(z)return z;let q=process.env.OPENCODE_CONFIG_DIR||b(process.env.XDG_CONFIG_HOME||b(Wq(),".config"),"opencode");return b(q,Iq)}function _(z){return typeof z==="object"&&z!==null&&!Array.isArray(z)}function dq(){return k(m())}var Mq="openai-auth",Aq=160,l={forceToTop:!1,order:Aq,startCollapsed:!1,rememberCollapsed:!0,collapsed:null,pollMs:1500,refreshDebounceMs:200,header:{label:"OPENAI",showVersion:!0},sections:{quota:!0,fallbackAccounts:!0,routing:!0,health:!0,pacing:!0},appearance:{barWidth:10,barFilledChar:"█",barEmptyChar:"░",warnThreshold:50,errorThreshold:80}};function D(z,q){return typeof z==="boolean"?z:q}function A(z,q,H,Q){if(typeof z!=="number"||!Number.isFinite(z))return q;return Math.min(Math.max(Math.round(z),H),Q)}function jq(z,q,H){if(typeof z!=="string"||z.length===0)return q;return z.slice(0,H)}function o(z,q){if(typeof z!=="string")return q;return[...z][0]??q}function pq(z){let q=z[Mq];if(!_(q))return structuredClone(l);let H=l,Q=_(q.header)?q.header:{},$=_(q.sections)?q.sections:{},Z=_(q.appearance)?q.appearance:{},X=A(Z.warnThreshold,H.appearance.warnThreshold,0,99),U=Math.max(A(Z.errorThreshold,H.appearance.errorThreshold,0,100),Math.min(X+1,100));return{forceToTop:D(q.forceToTop,H.forceToTop),order:A(q.order,H.order,-1e4,1e4),startCollapsed:D(q.startCollapsed,H.startCollapsed),rememberCollapsed:D(q.rememberCollapsed,H.rememberCollapsed),collapsed:typeof q.collapsed==="boolean"?q.collapsed:null,pollMs:A(q.pollMs,H.pollMs,500,30000),refreshDebounceMs:A(q.refreshDebounceMs,H.refreshDebounceMs,50,5000),header:{label:jq(Q.label,H.header.label,20),showVersion:D(Q.showVersion,H.header.showVersion)},sections:{quota:D($.quota,H.sections.quota),fallbackAccounts:D($.fallbackAccounts,H.sections.fallbackAccounts),routing:D($.routing,H.sections.routing),health:D($.health,H.sections.health),pacing:D($.pacing,H.sections.pacing)},appearance:{barWidth:A(Z.barWidth,H.appearance.barWidth,4,40),barFilledChar:o(Z.barFilledChar,H.appearance.barFilledChar),barEmptyChar:o(Z.barEmptyChar,H.appearance.barEmptyChar),warnThreshold:X,errorThreshold:U}}}var Nq=-1e5;function sq(z,q,H){let Q=z[q];if(!_(Q))return H;if(Q.forceToTop===!0)return Nq+Object.keys(z).indexOf(q);return A(Q.order,H,-1e4,1e4)}var Kq=`// Shared preferences for opencode TUI plugins.
|
package/dist/tui.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { i as OpenDialogPayload, n as ApplyResult, t as ApplyRequest } from "./protocol-
|
|
2
|
-
import { S as SidebarState, d as QuotaPacing, f as QuotaWindow, i as AccountQuota, w as SpendControlReading } from "./sidebar-state-
|
|
3
|
-
import { t as RpcClient } from "./rpc-client-
|
|
1
|
+
import { i as OpenDialogPayload, n as ApplyResult, t as ApplyRequest } from "./protocol-BZZtDn5h.js";
|
|
2
|
+
import { S as SidebarState, d as QuotaPacing, f as QuotaWindow, i as AccountQuota, w as SpendControlReading } from "./sidebar-state-DkNebAiC.js";
|
|
3
|
+
import { t as RpcClient } from "./rpc-client-CmaZW1by.js";
|
|
4
4
|
import { Plugin } from "@opencode/plugin/tui";
|
|
5
5
|
import { TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui";
|
|
6
6
|
import { JSX } from "solid-js";
|
|
7
|
-
//#region src/tui/v2.d.ts
|
|
8
7
|
interface TuiTransportOptions {
|
|
9
8
|
/** Test-only label for proving that the host can render a sidebar component. */
|
|
10
9
|
sidebarText?: string;
|
|
@@ -24,8 +23,6 @@ interface TuiTransportOptions {
|
|
|
24
23
|
setIntervalImpl?: typeof globalThis.setInterval;
|
|
25
24
|
clearIntervalImpl?: typeof globalThis.clearInterval;
|
|
26
25
|
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/tui.d.ts
|
|
29
26
|
/** One drawer action as the RPC apply request carries it, with its session. */
|
|
30
27
|
export declare function buildApplyRequest(request: Omit<ApplyRequest, 'sessionId'>, sessionId?: string): ApplyRequest;
|
|
31
28
|
type Tone = 'ok' | 'warn' | 'err' | 'muted' | 'accent' | 'text';
|
|
@@ -132,5 +129,4 @@ declare const plugin: TuiPluginModule & {
|
|
|
132
129
|
id: string;
|
|
133
130
|
setup: typeof setup;
|
|
134
131
|
};
|
|
135
|
-
//#endregion
|
|
136
132
|
export { plugin as default };
|