@cortexkit/opencode-openai-auth 1.0.4 → 1.1.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 +9 -8
- package/dist/{pool-lifecycle-DqKq8Eej.d.ts → codex-request-BXDXToyt.d.ts} +158 -27
- package/dist/index-0yh85bwb.js +69 -0
- package/dist/{index-jye6vccc.js → index-4c8yw54k.js} +2 -2
- package/dist/{index-k4eacw7x.js → index-7c6sxtd6.js} +2 -2
- package/dist/index-7eb3dw37.js +90 -0
- package/dist/index-8re8rprk.js +2 -0
- package/dist/{index-bgq9d21h.js → index-csky2xpg.js} +1 -1
- package/dist/index-edbdscy7.js +65 -0
- package/dist/{index-45qgkb0m.js → index-f2fmb596.js} +1 -1
- package/dist/{index-envpbt0k.js → index-j8v2xwq6.js} +1 -1
- package/dist/{index-egrty6tz.js → index-k6cydkgt.js} +2 -2
- package/dist/{index-dryydk6b.js → index-m5qmvr6c.js} +2 -2
- package/dist/index-msx2m78k.js +8 -0
- package/dist/{index-yeyp8t0k.js → index-zpm95mt5.js} +1 -1
- package/dist/index.d.ts +15 -7
- package/dist/index.js +1 -1
- package/dist/{map-CCbSZIhT.d.ts → map-Buq-GW7l.d.ts} +1 -1
- package/dist/{protocol-CSIDDBDf.d.ts → model-YRg7Uowo.d.ts} +67 -25
- package/dist/{port-file-CZ9MIdy2.d.ts → port-file-CxEpgSHY.d.ts} +1 -1
- package/dist/protocol-CDV1Pc6h.d.ts +29 -0
- package/dist/rpc/port-file.d.ts +1 -1
- 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 +3 -3
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/{sidebar-state-BCxFpH68.d.ts → sidebar-state-DjTWUbmf.d.ts} +15 -9
- package/dist/sidebar-state.d.ts +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-vykm9bxh.js → token-rz4t3ay6.js} +1 -1
- package/dist/token-util-tpy2c7h6.js +1 -0
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +20 -2
- package/dist/v2/server.d.ts +73 -1
- package/dist/v2/server.js +3 -3
- package/package.json +2 -2
- package/src/tui-compiled/raw/shared/0332701351b3eeec-format.js +78 -42
- package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +354 -0
- package/src/tui-compiled/raw/shared/134b008900698fe0-backoff.js +92 -0
- package/src/tui-compiled/raw/shared/169b2b4bf30909bc-consumer.js +393 -0
- package/src/tui-compiled/raw/shared/2577ec69f9973ae9-quota-normalize.js +154 -0
- package/src/tui-compiled/raw/shared/2dce6e9613993329-quota-manager.js +473 -0
- package/src/tui-compiled/raw/shared/30f5bc480f31f51c-roster.js +566 -0
- package/src/tui-compiled/raw/shared/43fc9e6b994519c7-refresh-lock.js +0 -1
- package/src/tui-compiled/raw/shared/4593a4d71edf69fd-tombstone.js +25 -0
- package/src/tui-compiled/raw/shared/4d05c2d7a531aece-oauth.js +500 -0
- package/src/tui-compiled/raw/shared/6371b24a0573d79e-any-signal.js +42 -0
- package/src/tui-compiled/raw/shared/7c140680fc81be92-interlock.js +29 -0
- package/src/tui-compiled/raw/shared/85512cc5263ba259-provider.js +87 -0
- package/src/tui-compiled/raw/shared/abd062d633e29fd2-pool-routing.js +192 -0
- package/src/tui-compiled/raw/shared/b9588ad4725c1d10-enrollment.js +806 -0
- package/src/tui-compiled/raw/shared/bfbdd0f9aae56b47-pool-quota.js +85 -0
- package/src/tui-compiled/raw/shared/c852a15cfe489d12-pool.js +0 -1
- package/src/tui-compiled/raw/shared/ca0fccaba1d87af4-errors.js +8 -0
- package/src/tui-compiled/raw/shared/d0f0b6be200311af-insula.js +152 -0
- package/src/tui-compiled/raw/shared/d5a8f1061ee2f114-index.js +1 -1
- package/src/tui-compiled/raw/shared/d9d2892a4c371301-host-slot.js +72 -0
- package/src/tui-compiled/raw/shared/dbc61cd405941828-accounts.js +1470 -0
- package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +26 -12
- package/src/tui-compiled/raw/shared/e8d3c8da776ef9cd-index.js +24 -0
- package/src/tui-compiled/raw/sidebar-state.js +41 -14
- package/src/tui-compiled/raw/tui/command-dialogs.tsx +3 -34
- package/src/tui-compiled/raw/tui/section-text.js +21 -0
- package/src/tui-compiled/raw/tui/v2-dialog.js +137 -0
- package/src/tui-compiled/raw/tui/v2.tsx +133 -0
- package/src/tui-compiled/raw/tui.tsx +146 -40
- package/src/tui-compiled/runtime/shared/0332701351b3eeec-format.js +78 -42
- package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +354 -0
- package/src/tui-compiled/runtime/shared/134b008900698fe0-backoff.js +92 -0
- package/src/tui-compiled/runtime/shared/169b2b4bf30909bc-consumer.js +393 -0
- package/src/tui-compiled/runtime/shared/2577ec69f9973ae9-quota-normalize.js +154 -0
- package/src/tui-compiled/runtime/shared/2dce6e9613993329-quota-manager.js +473 -0
- package/src/tui-compiled/runtime/shared/30f5bc480f31f51c-roster.js +566 -0
- package/src/tui-compiled/runtime/shared/43fc9e6b994519c7-refresh-lock.js +0 -1
- package/src/tui-compiled/runtime/shared/4593a4d71edf69fd-tombstone.js +25 -0
- package/src/tui-compiled/runtime/shared/4d05c2d7a531aece-oauth.js +500 -0
- package/src/tui-compiled/runtime/shared/6371b24a0573d79e-any-signal.js +42 -0
- package/src/tui-compiled/runtime/shared/7c140680fc81be92-interlock.js +29 -0
- package/src/tui-compiled/runtime/shared/85512cc5263ba259-provider.js +87 -0
- package/src/tui-compiled/runtime/shared/abd062d633e29fd2-pool-routing.js +192 -0
- package/src/tui-compiled/runtime/shared/b9588ad4725c1d10-enrollment.js +806 -0
- package/src/tui-compiled/runtime/shared/bfbdd0f9aae56b47-pool-quota.js +85 -0
- package/src/tui-compiled/runtime/shared/c852a15cfe489d12-pool.js +0 -1
- package/src/tui-compiled/runtime/shared/ca0fccaba1d87af4-errors.js +8 -0
- package/src/tui-compiled/runtime/shared/d0f0b6be200311af-insula.js +152 -0
- package/src/tui-compiled/runtime/shared/d5a8f1061ee2f114-index.js +1 -1
- package/src/tui-compiled/runtime/shared/d9d2892a4c371301-host-slot.js +72 -0
- package/src/tui-compiled/runtime/shared/dbc61cd405941828-accounts.js +1470 -0
- package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +26 -12
- package/src/tui-compiled/runtime/shared/e8d3c8da776ef9cd-index.js +24 -0
- package/src/tui-compiled/runtime/sidebar-state.js +41 -14
- package/src/tui-compiled/runtime/tui/command-dialogs.js +3 -15
- package/src/tui-compiled/runtime/tui/section-text.js +21 -0
- package/src/tui-compiled/runtime/tui/v2-dialog.js +137 -0
- package/src/tui-compiled/runtime/tui/v2.js +95 -0
- package/src/tui-compiled/runtime/tui.js +255 -163
- package/dist/index-2hch7e8n.js +0 -8
- package/dist/index-5dg931q0.js +0 -65
- package/dist/index-99esnzg0.js +0 -157
- package/dist/index-9reyazwh.js +0 -2
- package/dist/index-yf6arn5w.js +0 -2
- package/dist/token-util-gmn5yaqc.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as B}from"node:crypto";import{homedir as G,tmpdir as W}from"node:os";import{dirname as J,join as w,resolve as z}from"node:path";var A="OPENCODE_OPENAI_AUTH_RPC_DIR",K="openai-auth-";function L(k){return B("sha256").update(k).digest("hex").slice(0,16)}function M(){let k=process.env.XDG_STATE_HOME||w(G(),".local","state");return w(k,"cortexkit","openai-auth","rpc")}function Q(k){let q=process.env[A]?.trim();if(q)return z(k,q);return w(M(),`${K}${L(k)}`)}async function $(k){let q=process.env[A]?.trim();if(q)return{dir:z(k,q),secureDir:!1};let x=Q(k);return{dir:x,secureDir:!0,sweepRoot:J(x)}}export{W as
|
|
1
|
+
import{createHash as B}from"node:crypto";import{homedir as G,tmpdir as W}from"node:os";import{dirname as J,join as w,resolve as z}from"node:path";var A="OPENCODE_OPENAI_AUTH_RPC_DIR",K="openai-auth-";function L(k){return B("sha256").update(k).digest("hex").slice(0,16)}function M(){let k=process.env.XDG_STATE_HOME||w(G(),".local","state");return w(k,"cortexkit","openai-auth","rpc")}function Q(k){let q=process.env[A]?.trim();if(q)return z(k,q);return w(M(),`${K}${L(k)}`)}async function $(k){let q=process.env[A]?.trim();if(q)return{dir:z(k,q),secureDir:!1};let x=Q(k);return{dir:x,secureDir:!0,sweepRoot:J(x)}}export{W as Qe,K as Re,Q as Se,$ as Te};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{vb as X,xb as V}from"./index-0yh85bwb.js";import{randomUUID as Z}from"node:crypto";import{chmod as $,mkdir as G,readFile as H,rename as L,rm as T,stat as f,writeFile as g}from"node:fs/promises";import{dirname as k,resolve as w}from"node:path";var x="(no OpenCode 1 logins on this machine)";function C(b=process.env){return X(b)}async function Q(b){let z;try{z=await H(b,"utf8")}catch(q){if(q.code==="ENOENT")return;throw q}let j=JSON.parse(z);if(!j||typeof j!=="object"||Array.isArray(j))throw Error(`${b} does not hold a JSON object`);return j}function R(b){return b===void 0?void 0:JSON.stringify(b)}async function D(b){try{return(await f(b)).mode&511}catch(z){if(z.code==="ENOENT")return;throw z}}function _(b=C()){let z=new Map;return{path:w(b),async get(j){let q=(await Q(b))?.[j.path.id];return z.set(j.path.id,R(q)),q},async set(j){let q=j.path.id,W=await D(b),J=await Q(b)??{};if(!z.has(q)||z.get(q)!==R(J[q]))throw new V;J[q]=j.body,await G(k(b),{recursive:!0});let B=`${b}.${Z()}.tmp`;try{await g(B,`${JSON.stringify(J,null,2)}
|
|
2
2
|
`,{mode:W??384}),await $(B,W??384),await L(B,b)}catch(Y){throw await T(B,{force:!0}).catch(()=>{}),Y}return z.set(q,R(j.body)),!0},async all(){let j=await Q(b);if(!j||Object.keys(j).length===0)return{[x]:!0};return j}}}
|
|
3
3
|
export{_ as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fe as O,Ge as U,Je as b,Ke as m,Le as L,Pe as y}from"./index-m5qmvr6c.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 ne,Az as oe,Oz as pe,a as qe,i as re,Tz as se};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{S as
|
|
1
|
+
import{We as O}from"./index-csky2xpg.js";import{randomUUID as w}from"node:crypto";import{lstat as N,readFile as B,rename as b,unlink as U}from"node:fs/promises";import{dirname as V,resolve as L}from"node:path";var S=process.platform==="win32",W=new Set;function I(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 C;function q(){return C??=import("@cortexkit/private-files"),C}class R extends Error{path;stage;code;win32Code;reason;published=!1;durabilityConfirmed=!1;fileDurable=!1;attempts=0;elapsedMs=0;orphanPath;constructor(j,G,A){let z=A;super(`Private file refused at ${G}: ${j} (${z?.reason??z?.code??"io-error"}). Use a safe parent directory. Repair only a named secret file in safe ancestry whose owner the published policy trusts, without changing its owner or any existing directory. Previously exposed credentials may need rotation. Windows requires the private-files native prebuild and an ACL-persisting local filesystem such as NTFS.`,{cause:A});this.path=j,this.stage=G,this.name="PrivateFileError",this.code=I(z),this.win32Code=z?.win32Code,this.reason=z?.reason}}async function x(j,G,A){try{return await A()}catch(z){if(z instanceof R)throw z;throw new R(j,G,z)}}var E;async function _(j,G){j=L(j),G??=E,await x(j,"safe-parent",async()=>{let A=await(await q()).verifySafeParent(j,G);if(A.ok===!1){if(A.reason==="io-error"||A.reason==="wrong-kind")await N(j);throw new R(A.level??A.path,"safe-parent",{...A,code:"ERR_PRIVATE_FILES_SECURITY"})}})}async function T(j,G,A=!1){if(j=L(j),G==="directory")return _(j);await x(j,"verify",async()=>{let z=await q(),K=await z.verifyOwnerOnly(j),H=!1;if(!K.ok){let{reason:M}=K.refusal;if(M==="io-error")await z.verifyPrivatePath(j,G);if(A&&[z.EXTRA_ACE,z.NOT_PROTECTED,z.NULL_DACL,z.EMPTY_DACL].includes(M))await _(V(j)),await z.securePrivatePath(j,G),H=!0;else throw Object.assign(Error("Owner-only verification refused"),{reason:M,code:"ERR_PRIVATE_FILES_SECURITY"})}if(await z.verifyPrivatePath(j,G),H&&!W.has(j))W.add(j),process.emitWarning(`Private permissions tightened: ${j}. This object may have been readable before; rotate credentials if needed.`,"PrivateFileMigration")})}async function D(j,G=!1,A){j=L(j),await x(j,"directory",async()=>{let z=await q();try{return await N(j),await _(j,A)}catch(H){if(I(H)!=="ENOENT")throw H}let K=V(j);if(K===j)throw Object.assign(Error("Missing root"),{code:"ENOENT"});await D(K,!1,A);try{await z.createOwnerOnly(j,{kind:"dir"})}catch(H){if(I(H)!=="EEXIST")throw H}await _(j,A)})}async function m(j,G=!1){if(!S)return B(j,"utf8");return(await k(j,G)).toString("utf8")}async function k(j,G=!1){if(!S)return B(j);if(j=L(j),G)await _(V(j)),await T(j,"file",!0);return x(j,"read",async()=>(await q()).readOwnerOnly(j))}async function F(j,G){await _(V(L(j))),await x(j,"create",async()=>{await(await q()).createPrivateFile(L(j),G)})}async function c(j){await _(V(L(j))),await x(j,"directory-create",async()=>{await(await q()).createOwnerOnly(L(j),{kind:"dir"})})}async function g(j,G,A={}){j=L(j),G=L(G);let z=A.now??(()=>performance.now()),K=z(),H=Math.min(K+500,A.deadline??1/0),M=[0,10,20,40,80,100],Y,$=0;for(let Q of M){if(z()>=H)break;if(Q)await(A.sleep??((X)=>new Promise((Z)=>setTimeout(Z,X))))(Math.min(Q,Math.max(0,H-z())));if(z()>=H)break;if(await A.beforeRename?.(),z()>=H)break;$++;try{return await(A.rename??b)(j,G),{attempts:$,elapsedMs:z()-K}}catch(X){Y??=X;let Z=X;if(!(Z.win32Code!==void 0?Z.win32Code===32||Z.win32Code===33:["EBUSY","EPERM","EACCES"].includes(Z.code??"")&&!Z.reason))break}}let J=new R(G,"rename",Y??Object.assign(Error("Publication deadline expired"),{code:"ETIMEDOUT"}));throw J.attempts=$,J.elapsedMs=z()-K,J}async function v(j,G,A={}){j=L(j),await D(V(j));try{await T(j,"file",!0)}catch(J){if(J.code!=="ENOENT")throw J}let z=L(A.stagePath??`${j}.${w()}.tmp`);if(V(z)!==V(j))throw new R(j,"stage-directory",{code:"EXDEV"});let K=!1,H=!1,M={attempts:0,elapsedMs:0},Y="stage-create",$=(J)=>{try{A.onOutcome?.({path:j,stage:J?.stage??"published",published:H,fileDurable:H,durabilityConfirmed:!1,attempts:J?.attempts??M.attempts,elapsedMs:J?.elapsedMs??M.elapsedMs,...J&&{code:J.code,win32Code:J.win32Code}})}catch{}};try{if(await F(z,G),K=!0,Y="before-rename",M=await g(z,j,A),K=!1,H=!0,Y="published-callback",A.onRenamed?.(),Y="published-verify",await T(j,"file"),A.durable&&A.durability!=="file-only-on-windows")throw new R(j,"directory-sync-unsupported",{code:"ENOTSUP"});$()}catch(J){let Q=J instanceof R?J:new R(j,Y,J);if(Q.published=H,Q.fileDurable=H,H)Object.assign(Q,M);if(K){try{await U(z)}catch{Q.orphanPath=z}K=!1}throw $(Q),Q}finally{if(K)await U(z).catch(()=>{})}}
|
|
2
|
+
export{S as Fe,R as Ge,x as He,_ as Ie,T as Je,D as Ke,m as Le,F as Me,c as Ne,g as Oe,v as Pe};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{Fe as H,Ge as q,He as V0,Je as x,Ke as h,Le as S,Me as v,Ne as _0,Pe as b}from"./index-m5qmvr6c.js";import{randomUUID as I}from"node:crypto";import{mkdir as H0,open as B0,readFile as Q0,rename as W0,rm as L,stat as Y0}from"node:fs/promises";import{dirname as P,join as Z0}from"node:path";function N0($,G){return`${$}.${G}.lock`}class G0 extends Error{details;constructor($){super(`Timed out acquiring ${$.name} lock for ${$.target}`);this.name="LockContentionError",this.details=$}}class R extends Error{details;constructor($){super(`Lost ${$.name} lock for ${$.target}`);this.name="LockOwnershipError",this.details=$}}async function A0($,G,Q){let Y=performance.now();for(;;){let Z=await K0({path:$,name:G.name,ttlMs:G.ttlMs,renew:G.renew??!1,...G.onStep?{onStep:G.onStep}:{},...G.onRenewalTimer?{onRenewalTimer:G.onRenewalTimer}:{}});if(Z)try{return await Q(Z)}finally{await Z.release()}let J=G.timeoutMs-(performance.now()-Y);if(J<=0)throw new G0({target:$,name:G.name,timeoutMs:G.timeoutMs});await new Promise((_)=>setTimeout(_,Math.min(25,Math.ceil(J))))}}async function J0($,G){let Q=await B0($,"wx",384);try{await Q.writeFile(G,"utf8")}finally{await Q.close()}}var D0=globalThis.setTimeout.bind(globalThis),U0=globalThis.clearTimeout.bind(globalThis);function q0($){let G=$?.code;return G==="ENOENT"||!H&&(G==="EINVAL"||G==="ENOTDIR")}function K0($){return x0({...$,now:Date.now})}async function x0($){let G=N0($.path,$.name),Q=Z0(G,"owner.json"),Y=I(),Z=$.now??Date.now,J=null,_=!1,D=!1,B,l,j0=new Promise((z)=>{l=z});function p(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 d(){if(!J)return;U0(J),J=null,p("cancelled")}function C(z,K){if(B||_)return;B=Object.freeze({reason:z,expectedOwnerId:Y,...typeof K?.ownerId==="string"?{observedOwnerId:K.ownerId}:{},...typeof K?.expiresAt==="number"?{observedExpiresAt:K.expiresAt}:{}}),d(),l(B)}let E,M=null,g=`${G}.evicting`,f=Z0(g,"owner.json"),a=I(),C0=5000,y=8;async function j(){if(H)try{return JSON.parse(await S(G,!0))}catch(z){if(z.code!=="EISDIR"&&z.reason!=="wrong-kind")throw z;return await x(G,"directory",!0),JSON.parse(await S(Q,!0))}try{return JSON.parse(await Q0(G,"utf8"))}catch(z){if(z.code!=="EISDIR")throw z;return JSON.parse(await Q0(Q,"utf8"))}}async function g0(){if(H){let W=await j(),V=Number(W?.expiresAt)-Z();await b(G,`${JSON.stringify({ownerId:Y,expiresAt:Z()+$.ttlMs})}
|
|
2
|
+
`,{deadline:performance.now()+Math.max(0,V),beforeRename:async()=>{let T=await j();if(T?.ownerId!==Y||!(Number(T?.expiresAt)>Z())||!await X())throw new R({target:$.path,name:$.name})}});return}let z=`${G}.${I()}.tmp`,K,N=!1;try{K=await B0(z,"wx",384),N=!0,await K.writeFile(`${JSON.stringify({ownerId:Y,expiresAt:Z()+$.ttlMs})}
|
|
3
|
+
`,"utf8"),await K.chmod(384),await K.close(),K=void 0;let W=await j();if(W?.ownerId!==Y||!(Number(W?.expiresAt)>Z())||!await X())throw new R({target:$.path,name:$.name});await W0(z,G),N=!1}finally{if(await K?.close().catch(()=>{}),N)await L(z,{force:!0}).catch(()=>{})}}async function s(){let z=`${JSON.stringify({ownerId:Y,expiresAt:Z()+$.ttlMs})}
|
|
4
|
+
`;if(H)await v(G,z);else await J0(G,z)}async function n(z){let K=z.code;if(K==="EEXIST"){if(H)await j();return!0}if(K==="EISDIR"){if(H)await x(G,"directory",!0),await S(Q,!0);return!0}return!1}async function k(){if(H)await h(P(G));try{return await s(),!0}catch(z){let K=z.code;if(await n(z))return!1;if(K==="ENOENT"){if(H)await h(P(G));else await H0(P(G),{recursive:!0});try{return await s(),!0}catch(N){if(await n(N))return!1;throw N}}throw z}}async function O(){await new Promise((z)=>setTimeout(z,Math.floor(Math.random()*4)))}async function m(z=!0){if(z&&$.onStep)await $.onStep("lock-read-ready");let K;try{K=await j()}catch(W){if(H&&W.code!=="ENOENT")throw W}let N=Number(K?.expiresAt);if(Number.isFinite(N)&&N>Z())return{status:"live"};if(typeof K?.ownerId==="string"&&Number.isFinite(N))return{status:"stale",identity:{kind:"owner",ownerId:K.ownerId,expiresAt:N}};try{let W=await Y0(G),V=Number.isFinite(N)?N:W.mtimeMs+$.ttlMs;if(V>Z())return{status:"live"};return{status:"stale",identity:{kind:"stat",dev:W.dev,ino:W.ino,mtimeMs:W.mtimeMs,expiresAt:V}}}catch(W){if(W.code==="ENOENT"){if($.onStep)await $.onStep("lock-missing");return{status:"missing"}}throw W}}function i(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 X(){try{return JSON.parse(await S(f,H))?.ownerId===a}catch(z){if(H&&z.code!=="ENOENT")throw z;return!1}}async function A(z){if(H)await V0(z,"remove",()=>L(z,{recursive:!0,force:!0}));else await L(z,{recursive:!0,force:!0}).catch(()=>{})}async function u(){if(await X())await A(g)}async function t(){if(H)await _0(g);else await H0(g);try{let z=`${JSON.stringify({ownerId:a,createdAt:Z()})}
|
|
5
|
+
`;if(H)await v(f,z);else await J0(f,z)}catch(z){if(q0(z))return!1;throw await u(),z}if($.onStep)await $.onStep("eviction-marker-acquired");return!0}async function r(){let z;try{z=await Y0(g)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if(H)await x(g,"directory",!0);if(z.mtimeMs+C0>Z())return"fresh";if($.onStep)await $.onStep("stale-marker-stat");let K=`${g}.${I()}`;try{await W0(g,K)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if($.onStep)await $.onStep("stale-marker-claimed");return await A(K),"recovered"}async function o(z){try{if(!await t())return!1}catch(K){if(K.code==="EEXIST"){if(H){await x(g,"directory",!0);try{await S(f,!0)}catch(N){if(N.code!=="ENOENT")throw N}}return!1}throw K}try{await z()}finally{await u()}return!0}async function e(){for(let z=0;z<y;z++){if($.onStep)await $.onStep("relinquish-read");let K;try{K=await j()}catch(N){if(H)throw N;return}if(K?.ownerId!==Y)return;try{await L(G,{recursive:!0,force:!0});return}catch(N){if(H)throw N;await O()}}}function $0(){if(!$.renew||_||B)return;let z=$.renewIntervalMs??Math.max(1000,Math.floor($.ttlMs/3));if(J=D0(()=>{J=null;let K=(async()=>{let N=!_;try{if(!await o(async()=>{let V=await j(),T=Z();if(_||B){N=!1;return}if(V?.ownerId!==Y){C("taken-over",V),N=!1;return}if(!(Number(V?.expiresAt)>T)){C("expired",V),N=!1;return}if($.onStep)await $.onStep("renewal-owner-confirmed");if(_||B){N=!1;return}if(!await X())return;if($.onStep)await $.onStep("renewal-write-fenced");if(_||B){N=!1;return}if(!await X())return;if($.onStep)await $.onStep("renewal-write-ready");if(_||B){N=!1;return}if(await g0(),$.onStep)await $.onStep("renewal-write-finished");if(!await X()){C("marker-lost"),N=!1,await e();return}})&&$.onStep)await $.onStep("renewal-marker-unavailable")}catch(W){if(H&&W instanceof q)E=W,C("renewal-failed"),N=!1;try{let V=await j();if(V?.ownerId!==Y)C("taken-over",V);else if(!(Number(V?.expiresAt)>Z()))C("expired",V)}catch{C("renewal-failed")}}finally{if($.onStep)try{await $.onStep("renewal-finished")}catch{}if(N&&!_&&!B)$0()}})();M=K,K.finally(()=>{if(M===K)M=null})},z),"unref"in J)J.unref();p("scheduled")}function z0(){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 k();if(!U)for(let z=0;z<y;z++){if(U=await k(),U)break;let K=await m();if(K.status==="live")return z0();if(K.status==="missing")continue;if($.onStep)await $.onStep("stale-lock-observed");try{if(!await t()){await O();continue}}catch(N){if(N.code!=="EEXIST")throw N;if(await r()==="fresh")return null;await O();continue}try{let N=await m();if(N.status==="live")return z0();if(!i(K.identity,N))continue;if(!await X())return null;if($.onStep)await $.onStep("stale-lock-confirmed");if(!await X())return null;let W=await m(!1);if(!i(K.identity,W))continue;if(await A(G),!await X())return null;if($.onStep)await $.onStep("stale-lock-removed");if(U=await k(),!U)return null;if($.onStep)await $.onStep("stale-lock-recreated");if(!await X())return await e(),U=!1,null;break}finally{await u()}}if(!U)return null;return $0(),{ownerId:Y,whenLost:()=>j0,hasLost:()=>B!==void 0,assertOwned:async()=>{if(E)throw E;let z;try{let K=await j();if(z=K,!_&&!B&&K?.ownerId===Y&&Number(K?.expiresAt)>Z())return;C(K?.ownerId!==Y?"taken-over":"expired",K)}catch(K){if(C("unreadable"),H&&K instanceof q)throw K}throw new R({target:$.path,name:$.name,expectedOwnerId:Y,...typeof z?.ownerId==="string"?{observedOwnerId:z.ownerId}:{},...typeof z?.expiresAt==="number"?{observedExpiresAt:z.expiresAt}:{}})},release:async()=>{if(H&&D)return;_=!0,d(),await M;for(let z=0;z<y;z++){try{let K=!1;if(await o(async()=>{let W;try{W=await j()}catch(V){if(H&&V.code==="ENOENT"){K=!0;return}throw V}if(W?.ownerId!==Y){K=!0;return}if($.onStep)await $.onStep("release-owner-confirmed");if(!await X())return;await A(G),K=!0})){if(H&&!K)throw new q(G,"release-not-confirmed",{code:"EIO"});D=K;return}await r()}catch(K){if(H)throw K;return}await O()}if(H)throw new q(G,"release-not-confirmed",{code:"ETIMEDOUT"})}}}import{randomUUID as X0}from"node:crypto";import{mkdir as S0,open as F,rename as R0,rm as M0}from"node:fs/promises";import{dirname as w}from"node:path";class c extends Error{constructor($){super("file or directory sync failed",{cause:$});this.name="AtomicSyncError"}}async function h0($,G,Q={}){await f0($,G,Q)}async function f0($,G,Q,Y){if(H)return b($,Q.serialize?Q.serialize(G):`${JSON.stringify(G,null,2)}
|
|
6
|
+
`,{beforeRename:Q.beforeRename,stagePath:`${$}.${(Q.stageName??X0)()}.tmp`,onRenamed:Y,durable:Q.durable,durability:Q.durability,onOutcome:Q.onOutcome});await S0(w($),{recursive:!0});let Z=`${$}.${(Q.stageName??X0)()}.tmp`,J,_=!1;try{if(J=await F(Z,"wx",384),_=!0,await J.writeFile(Q.serialize?Q.serialize(G):`${JSON.stringify(G,null,2)}
|
|
7
|
+
`,"utf8"),await J.chmod(384),Q.durable)try{await J.sync()}catch(D){throw new c(D)}if(await J.close(),J=void 0,await Q.beforeRename?.(),await R0(Z,$),_=!1,Y?.(),Q.durable){let D=await F(w($),"r");try{await D.sync()}catch(B){throw new c(B)}finally{await D.close()}}}finally{if(await J?.close().catch(()=>{}),_)await M0(Z,{force:!0}).catch(()=>{})}}async function v0($){if(H){await x($,"file");let Y=new q($,"directory-sync-unsupported",{code:"ENOTSUP"});throw Y.published=!0,Y}let G=await F($,"r");try{await G.sync()}finally{await G.close()}let Q=await F(w($),"r");try{await Q.sync()}finally{await Q.close()}}var c0=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{c as _d,h0 as $d,f0 as ae,v0 as be,K0 as ce,G0 as de,R as ee,A0 as fe,c0 as ge};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ue as Z,We as W}from"./index-csky2xpg.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};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { _ as SidebarMachineState, b as SidebarState } from "./sidebar-state-
|
|
1
|
+
import { S as PoolStore, _ as TokenResponse, a as RESPONSES_LITE_MODELS, b as parseJwtClaims, c as CacheKeepManager, d as ResetTargetIdentity, f as OpenAiVault, g as IdTokenClaims, l as MenuMigrationState, n as CODEX_VERSION, o as PoolLifecycleDeps, t as CODEX_USER_AGENT, u as OpenAiMenuOptions, v as beginAccountLogin, x as AccountPaths, y as extractAccountIdFromClaims } from "./codex-request-BXDXToyt.js";
|
|
2
|
+
import { _ as SidebarMachineState, b as SidebarState } from "./sidebar-state-DjTWUbmf.js";
|
|
3
3
|
import { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
|
|
4
4
|
//#region ../core/dist/provider.d.ts
|
|
5
5
|
type QuotaWindowName = string;
|
|
@@ -389,12 +389,21 @@ interface RefreshAllQuotaResult {
|
|
|
389
389
|
//#region src/commands.d.ts
|
|
390
390
|
/** What the `/openai` menu reads and changes in this process. */
|
|
391
391
|
interface OpenCodeMenuContext {
|
|
392
|
+
readOnly?: boolean;
|
|
393
|
+
allowAction?: OpenAiMenuOptions['allowAction'];
|
|
394
|
+
unavailableSections?: OpenAiMenuOptions['unavailableSections'];
|
|
392
395
|
accountStoragePath: string;
|
|
393
396
|
/** Runtime-state file that goes with `accountStoragePath`. */
|
|
394
397
|
accountStatePath: string;
|
|
395
398
|
/** Host package version, sent as the version half of the OAuth `User-Agent`. */
|
|
396
399
|
packageVersion: string;
|
|
397
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Each account's saved quota windows and applicable reset-credit count, and
|
|
402
|
+
* whether it is rate limited now: what the Reset credits section judges
|
|
403
|
+
* eligibility and reports a redemption with. OpenCode 2 backs it with its
|
|
404
|
+
* account pool instead of a `QuotaManager`.
|
|
405
|
+
*/
|
|
406
|
+
quotaManager?: Pick<QuotaManager, 'isRateLimited' | 'getMain' | 'getFallback'>;
|
|
398
407
|
loadAccounts: typeof loadAccounts;
|
|
399
408
|
/** The pool store the accounts live in. */
|
|
400
409
|
store: () => PoolStore;
|
|
@@ -480,9 +489,6 @@ export declare function codexOAuthModelLimit(modelId: string): {
|
|
|
480
489
|
* transport log.
|
|
481
490
|
*/
|
|
482
491
|
export declare const EMPTY_BEARER_MESSAGE = "Refusing to send a request with no access token. This is a defect in the plugin, not a problem with the provider or the account; the transport log names the account and the path that produced it.";
|
|
483
|
-
export declare const RESPONSES_LITE_MODELS: ReadonlySet<string>;
|
|
484
|
-
export declare const CODEX_VERSION = "0.159.0";
|
|
485
|
-
export declare const CODEX_USER_AGENT = "codex_exec/0.159.0 (Debian 12.0.0; aarch64) unknown (codex_exec; 0.159.0)";
|
|
486
492
|
export declare const getMainRefreshLockName: () => string;
|
|
487
493
|
export declare const MAIN_REFRESH_LOCK_TTL_MS: number;
|
|
488
494
|
export declare const MAIN_REFRESH_LEASE_TTL_MS = 90000;
|
|
@@ -537,6 +543,8 @@ export interface PoolResetAccess {
|
|
|
537
543
|
};
|
|
538
544
|
token?: string;
|
|
539
545
|
}
|
|
546
|
+
/** The reset target for a pool row, or the refusal the legacy resolver gives. */
|
|
547
|
+
export declare function poolResetTarget(accountKey: string, pooled: PoolResetAccess): ResetTargetIdentity;
|
|
540
548
|
export declare function createResetTargetResolver(deps: ResetTargetResolverDeps): (accountKey: string) => Promise<ResetTargetIdentity>;
|
|
541
549
|
export declare function buildResetRedemptionDeps(): {
|
|
542
550
|
fetchImpl: typeof fetch;
|
|
@@ -611,4 +619,4 @@ declare const _default: {
|
|
|
611
619
|
server: Plugin;
|
|
612
620
|
};
|
|
613
621
|
//#endregion
|
|
614
|
-
export { type IdTokenClaims, _default as default, extractAccountIdFromClaims, parseJwtClaims };
|
|
622
|
+
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
|
|
1
|
+
import{$ as u,M as f,N as g,O as h,P as i,Q as j,R as k,S as l,T as m,U as n,V as o,W as p,X as q,Y as r,Z as s,_ as t,aa as v,ba as w,ca as x,da as y,ea as z,fa as A,ga as B,ha as C,ia as D,ja as E,ka as F,m as c,n as d,o as e}from"./index-edbdscy7.js";import"./index-0yh85bwb.js";import"./index-8re8rprk.js";import{Ic as a,Jc as b}from"./index-7eb3dw37.js";import"./index-msx2m78k.js";import"./index-4c8yw54k.js";import"./index-k6cydkgt.js";import"./index-7c6sxtd6.js";import"./index-m5qmvr6c.js";import"./index-f2fmb596.js";import"./index-csky2xpg.js";export{C as rewriteResponsesLiteBody,A as resolveSidebarSessionId,r as poolResetTarget,a as parseJwtClaims,x as mergePushedQuotaMetadata,k as getMainRefreshLockName,w as findCachekeepFallbackAccount,b as extractAccountIdFromClaims,F as default,s as createResetTargetResolver,h as codexOAuthModelListed,i as codexOAuthModelLimit,z as buildSidebarState,y as buildSidebarMachineState,t as buildResetRedemptionDeps,o as __resetBootQuotaSeedForTest,u as __menuContextForTest,n as __bootQuotaSeedPromiseForTest,q as ResetTargetResolutionError,c as RESPONSES_LITE_MODELS,v as POOL_MIGRATION_ENABLED,E as OpenAIAuthPlugin,B as MID_CONVERSATION_EFFORT_MODELS,l as MAIN_REFRESH_LOCK_TTL_MS,m as MAIN_REFRESH_LEASE_TTL_MS,j as EMPTY_BEARER_MESSAGE,g as DISALLOWED_MODELS,D as CodexAuthPlugin,d as CODEX_VERSION,e as CODEX_USER_AGENT,p as AuthPersistError,f as ALLOWED_MODELS};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.18.0+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
|
|
2
2
|
interface QuotaReadingEntry {
|
|
3
3
|
scope: string;
|
|
4
4
|
label: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.18.0+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/commands/model.d.ts
|
|
2
2
|
/** The section slots, in the one order every renderer shows them. */
|
|
3
3
|
declare const SECTION_SLOTS: readonly ['accounts', 'quota', 'routing', 'limits', 'cache', 'diagnostics', 'extra'];
|
|
4
4
|
type SectionSlot = (typeof SECTION_SLOTS)[number];
|
|
@@ -167,32 +167,74 @@ interface CommandApplyResult {
|
|
|
167
167
|
menu: CommandMenuModel;
|
|
168
168
|
}
|
|
169
169
|
type NotifyKind = 'info' | 'warning' | 'error';
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region ../core/dist/protocol.d.ts
|
|
172
|
-
/** The menu, as the slash command opens it in the TUI. */
|
|
173
|
-
type OpenDialogPayload = CommandDialogPayload;
|
|
174
170
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
171
|
+
* The per-invocation context of one slash-command call. The library reads
|
|
172
|
+
* both fields once, when the call starts, and keeps that copy for any work
|
|
173
|
+
* the call leaves running (a login completing later, for example), so a host
|
|
174
|
+
* that reuses one context object across sessions cannot reroute feedback.
|
|
177
175
|
*/
|
|
178
|
-
interface
|
|
179
|
-
command: string;
|
|
180
|
-
notify: {
|
|
181
|
-
message: string;
|
|
182
|
-
kind: NotifyKind;
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
interface RpcNotification {
|
|
186
|
-
id: number;
|
|
187
|
-
type: 'open-dialog';
|
|
188
|
-
payload: OpenDialogPayload | NotifyPayload;
|
|
176
|
+
interface CommandInvocation {
|
|
189
177
|
sessionId?: string;
|
|
178
|
+
notify(message: string, kind?: NotifyKind): void;
|
|
179
|
+
}
|
|
180
|
+
interface ActionOutcome {
|
|
181
|
+
ok: boolean;
|
|
182
|
+
text: string;
|
|
183
|
+
/** The failure's stable code; a failure without one is `refused`. */
|
|
184
|
+
code?: string;
|
|
185
|
+
}
|
|
186
|
+
interface ActionInput {
|
|
187
|
+
values: KnobValues;
|
|
188
|
+
/** The item the action sits on; absent for a section-level action. */
|
|
189
|
+
itemId?: string;
|
|
190
|
+
invocation: CommandInvocation;
|
|
191
|
+
}
|
|
192
|
+
type ActionBase = {
|
|
193
|
+
id: string;
|
|
194
|
+
label: string;
|
|
195
|
+
description?: string;
|
|
196
|
+
/** The header a section-level action is listed under; see `MenuSection`. */
|
|
197
|
+
group?: string;
|
|
198
|
+
knobs?: MenuKnob[];
|
|
199
|
+
run(input: ActionInput): Promise<string | ActionOutcome>;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* An action and its body. An irreversible action must name its
|
|
203
|
+
* confirmation; a reversible one may.
|
|
204
|
+
*/
|
|
205
|
+
type ActionDefinition = ActionBase & ({
|
|
206
|
+
irreversible: true;
|
|
207
|
+
confirm: string;
|
|
208
|
+
} | {
|
|
209
|
+
irreversible?: false;
|
|
210
|
+
confirm?: string;
|
|
211
|
+
});
|
|
212
|
+
interface ItemDefinition {
|
|
213
|
+
id: string;
|
|
214
|
+
label: string;
|
|
215
|
+
detail?: string;
|
|
216
|
+
/** The header the item is listed under; see `MenuSection`. */
|
|
217
|
+
group?: string;
|
|
218
|
+
/** A short value shown right-aligned beside the label. */
|
|
219
|
+
status?: string;
|
|
220
|
+
facts?: Record<string, unknown>;
|
|
221
|
+
actions?: ActionDefinition[];
|
|
222
|
+
}
|
|
223
|
+
interface SectionContent {
|
|
224
|
+
/** Read-only text; renderers never make a line selectable. */
|
|
225
|
+
lines?: string[];
|
|
226
|
+
items?: ItemDefinition[];
|
|
227
|
+
actions?: ActionDefinition[];
|
|
228
|
+
facts?: Record<string, unknown>;
|
|
229
|
+
}
|
|
230
|
+
/** A section a plugin supplies for one of its slots. */
|
|
231
|
+
interface PluginSection {
|
|
232
|
+
title: string;
|
|
233
|
+
build(invocation: CommandInvocation): SectionContent | Promise<SectionContent>;
|
|
234
|
+
}
|
|
235
|
+
/** A provider extra: a plugin section shown after the fixed slots. */
|
|
236
|
+
interface PluginExtraSection extends PluginSection {
|
|
237
|
+
id: string;
|
|
190
238
|
}
|
|
191
|
-
/** One action applied from the drawer. */
|
|
192
|
-
type ApplyRequest = CommandApplyRequest;
|
|
193
|
-
/** Its message and the refreshed menu. */
|
|
194
|
-
type ApplyResult = CommandApplyResult;
|
|
195
|
-
/** Whether a pushed notification is the menu itself or a message. */
|
|
196
|
-
declare function isNotifyPayload(payload: OpenDialogPayload | NotifyPayload): payload is NotifyPayload;
|
|
197
239
|
//#endregion
|
|
198
|
-
export {
|
|
240
|
+
export { KnobValues as a, PluginExtraSection as c, CommandInvocation as i, PluginSection as l, CommandApplyResult as n, MenuKnob as o, CommandDialogPayload as r, NotifyKind as s, CommandApplyRequest as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.18.0+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/rpc/port-file.d.ts
|
|
2
2
|
interface PortFileEntry {
|
|
3
3
|
port: number;
|
|
4
4
|
token: string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { n as CommandApplyResult, r as CommandDialogPayload, s as NotifyKind, t as CommandApplyRequest } from "./model-YRg7Uowo.js";
|
|
2
|
+
//#region ../core/dist/protocol.d.ts
|
|
3
|
+
/** The menu, as the slash command opens it in the TUI. */
|
|
4
|
+
type OpenDialogPayload = CommandDialogPayload;
|
|
5
|
+
/**
|
|
6
|
+
* A message for the user from work a menu action left running (a login that
|
|
7
|
+
* finishes after the action returned).
|
|
8
|
+
*/
|
|
9
|
+
interface NotifyPayload {
|
|
10
|
+
command: string;
|
|
11
|
+
notify: {
|
|
12
|
+
message: string;
|
|
13
|
+
kind: NotifyKind;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface RpcNotification {
|
|
17
|
+
id: number;
|
|
18
|
+
type: 'open-dialog';
|
|
19
|
+
payload: OpenDialogPayload | NotifyPayload;
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
}
|
|
22
|
+
/** One action applied from the drawer. */
|
|
23
|
+
type ApplyRequest = CommandApplyRequest;
|
|
24
|
+
/** Its message and the refreshed menu. */
|
|
25
|
+
type ApplyResult = CommandApplyResult;
|
|
26
|
+
/** Whether a pushed notification is the menu itself or a message. */
|
|
27
|
+
declare function isNotifyPayload(payload: OpenDialogPayload | NotifyPayload): payload is NotifyPayload;
|
|
28
|
+
//#endregion
|
|
29
|
+
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,4 +1,4 @@
|
|
|
1
|
-
import { n as discoverPortFile, r as writePortFile, t as PortFileEntry } from "../port-file-
|
|
1
|
+
import { n as discoverPortFile, r as writePortFile, t as PortFileEntry } from "../port-file-CxEpgSHY.js";
|
|
2
2
|
//#region src/rpc/port-file.d.ts
|
|
3
3
|
export declare const isOpenaiRpcStateDir: (name: string) => boolean;
|
|
4
4
|
//#endregion
|
package/dist/rpc/port-file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{me as c}from"../index-4c8yw54k.js";import{oe as a,qe as b}from"../index-k6cydkgt.js";import"../index-m5qmvr6c.js";import"../index-f2fmb596.js";import"../index-csky2xpg.js";export{a as writePortFile,c as isOpenaiRpcStateDir,b 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-CDV1Pc6h.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{De as b}from"../index-7c6sxtd6.js";import"../index-m5qmvr6c.js";import"../index-csky2xpg.js";export{b as isNotifyPayload};
|
package/dist/rpc/rpc-client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.
|
|
1
|
+
import { a as RpcNotification, n as ApplyResult, t as ApplyRequest } from "../protocol-CDV1Pc6h.js";
|
|
2
|
+
import { t as PortFileEntry } from "../port-file-CxEpgSHY.js";
|
|
3
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.18.0+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/rpc/rpc-client.d.ts
|
|
4
4
|
export declare const DEFAULT_RPC_TIMEOUT_MS = 2000;
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/rpc/rpc-client.d.ts
|
package/dist/rpc/rpc-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{re as F,se as f}from"../index-k6cydkgt.js";import"../index-m5qmvr6c.js";import"../index-csky2xpg.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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Qe as a,Re as b,Se as c,Te as d}from"../index-f2fmb596.js";import"../index-csky2xpg.js";export{a as tmpdir,d as resolveRpcDir,c as getRpcDir,b as RPC_DIRECTORY_PREFIX};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as QuotaCounter } from "./map-
|
|
2
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1
|
+
import { t as QuotaCounter } from "./map-Buq-GW7l.js";
|
|
2
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.18.0+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/logger/engine.d.ts
|
|
3
3
|
interface ChannelLogger {
|
|
4
4
|
error(message: string, data?: unknown): void;
|
|
5
5
|
warn(message: string, data?: unknown): void;
|
|
@@ -9,7 +9,7 @@ interface ChannelLogger {
|
|
|
9
9
|
}
|
|
10
10
|
declare function createLogger(channel: string): ChannelLogger;
|
|
11
11
|
//#endregion
|
|
12
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
12
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.18.0+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/quota/projection.d.ts
|
|
13
13
|
interface ProjectedLimit {
|
|
14
14
|
scope: string;
|
|
15
15
|
label: string;
|
|
@@ -44,7 +44,7 @@ interface ProjectedQuota {
|
|
|
44
44
|
counters?: Record<string, QuotaCounter>;
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
47
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.18.0+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/sidebar-file/sidebar-file.d.ts
|
|
48
48
|
interface SidebarFileHooks {
|
|
49
49
|
/** Runs on the first merge attempt, before checking for older, unlocked writers. */
|
|
50
50
|
beforeRecheck?: () => void | Promise<void>;
|
|
@@ -92,12 +92,17 @@ interface PresentQuotaWindow {
|
|
|
92
92
|
declare function getPresentQuotaWindows(quota: AccountQuota | null): PresentQuotaWindow[];
|
|
93
93
|
interface SidebarAccountState {
|
|
94
94
|
id: string;
|
|
95
|
+
/** Vault credential name, used only to identify its default OpenAI account. */
|
|
96
|
+
credentialId?: string;
|
|
95
97
|
label: string | undefined;
|
|
96
98
|
/** ChatGPT identity of the account this quota belongs to. */
|
|
97
99
|
accountId?: string;
|
|
98
100
|
quota: AccountQuota | null;
|
|
99
101
|
killed: boolean;
|
|
100
102
|
enabled: boolean;
|
|
103
|
+
/** Whether the vault can serve this row now; `enabled` is the /openai toggle. */
|
|
104
|
+
routable?: boolean;
|
|
105
|
+
vaultState?: 'needs sign-in' | 'turned off in vault' | 'unavailable';
|
|
101
106
|
resetCredits?: number;
|
|
102
107
|
}
|
|
103
108
|
interface ActiveRoutingEntry {
|
|
@@ -158,13 +163,13 @@ interface SidebarState {
|
|
|
158
163
|
*/
|
|
159
164
|
accountPool?: boolean;
|
|
160
165
|
/**
|
|
161
|
-
* Present while the host
|
|
162
|
-
*
|
|
166
|
+
* Present while the host uses the credential vault instead of local logins:
|
|
167
|
+
* the vault accounts that serve instead of the local accounts, in
|
|
163
168
|
* the vault's order. `main` then carries no account and `fallbacks` is
|
|
164
169
|
* empty, so a reader that does not know this field shows no local account.
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
170
|
+
* `enabled` is the host's own toggle, while `routable` and `vaultState`
|
|
171
|
+
* describe vault availability independently. Each entry's `label` is the
|
|
172
|
+
* account's email when the vault knows it, else the vault's label.
|
|
168
173
|
*/
|
|
169
174
|
vaultAccounts?: SidebarAccountState[];
|
|
170
175
|
}
|
|
@@ -192,6 +197,7 @@ type SidebarRoutingAccount = {
|
|
|
192
197
|
id: string;
|
|
193
198
|
enabled?: boolean;
|
|
194
199
|
killed?: boolean;
|
|
200
|
+
routable?: boolean;
|
|
195
201
|
};
|
|
196
202
|
declare function isUsableRoutingEntry(entry: ActiveRoutingEntry, accounts: readonly SidebarRoutingAccount[] | undefined, now?: number): boolean;
|
|
197
203
|
declare function spendControlExhaustedResetAt(quota: AccountQuota | null | undefined, now?: number): {
|
package/dist/sidebar-state.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as resolveSessionSidebarRouting, A as clearSidebarStickyAssignment, B as getSidebarStateFile, C as StickyAssignment, D as StickyPinOverlay, E as StickyAssignmentPlan, F as exhaustedQuotaResetAt, G as persistSidebarStickyAssignment, H as isQuotaExhausted, I as formatWindowLabel, J as pruneActiveRouting, K as planSidebarStickyAssignment, L as getCollapsedQuotaSummary, M as createSidebarBookkeepingQueue, N as createSidebarStateCache, O as StickyPinOverlayEntry, P as drainSidebarWrites, Q as resolveActiveAccount, R as getPresentQuotaWindows, S as SpendControlReading, T as StickyAssignmentMap, U as isUsableRoutingEntry, V as hashSidebarSessionId, W as normalizeSidebarState, X as rememberStickyPin, Y as pruneStickyAssignments, Z as removeSidebarActiveRouting, _ as SidebarMachineState, a as ActiveRoutingMap, at as setSidebarState, b as SidebarState, c as PresentQuotaWindow, ct as spendControlExhaustedResetAt, d as QuotaWindowKey, et as resolveSessionStickyAccount, f as ResolveStickyAssignmentInput, g as SidebarBookkeepingQueue, h as SidebarAccountState, i as ActiveRoutingEntry, it as setSidebarMachineState, j as computeQuotaPacing, k as applyStickyPinOverlay, l as QuotaPacing, lt as upsertSidebarActiveRouting, m as STICKY_ASSIGNMENT_MAX_ENTRIES, n as ACTIVE_ROUTING_MAX_ENTRIES, nt as setLegacySidebarStateFileForTest, o as DEFAULT_SIDEBAR_STATE, ot as settleWithinBudget, p as STICKY_ASSIGNMENT_MAX_AGE_MS, q as planSidebarStickyAssignmentFromSnapshot, r as AccountQuota, rt as setSidebarLegacyRouting, s as HOT_PATH_READ_BUDGET_MS, st as sidebarQuotaProjection, t as ACTIVE_ROUTING_MAX_AGE_MS, tt as resolveSidebarStickyAssignment, u as QuotaWindow, v as SidebarRoutingAccount, w as StickyAssignmentChoice, x as SidebarStateCache, y as SidebarSnapshot, z as getSidebarState } from "./sidebar-state-
|
|
1
|
+
import { $ as resolveSessionSidebarRouting, A as clearSidebarStickyAssignment, B as getSidebarStateFile, C as StickyAssignment, D as StickyPinOverlay, E as StickyAssignmentPlan, F as exhaustedQuotaResetAt, G as persistSidebarStickyAssignment, H as isQuotaExhausted, I as formatWindowLabel, J as pruneActiveRouting, K as planSidebarStickyAssignment, L as getCollapsedQuotaSummary, M as createSidebarBookkeepingQueue, N as createSidebarStateCache, O as StickyPinOverlayEntry, P as drainSidebarWrites, Q as resolveActiveAccount, R as getPresentQuotaWindows, S as SpendControlReading, T as StickyAssignmentMap, U as isUsableRoutingEntry, V as hashSidebarSessionId, W as normalizeSidebarState, X as rememberStickyPin, Y as pruneStickyAssignments, Z as removeSidebarActiveRouting, _ as SidebarMachineState, a as ActiveRoutingMap, at as setSidebarState, b as SidebarState, c as PresentQuotaWindow, ct as spendControlExhaustedResetAt, d as QuotaWindowKey, et as resolveSessionStickyAccount, f as ResolveStickyAssignmentInput, g as SidebarBookkeepingQueue, h as SidebarAccountState, i as ActiveRoutingEntry, it as setSidebarMachineState, j as computeQuotaPacing, k as applyStickyPinOverlay, l as QuotaPacing, lt as upsertSidebarActiveRouting, m as STICKY_ASSIGNMENT_MAX_ENTRIES, n as ACTIVE_ROUTING_MAX_ENTRIES, nt as setLegacySidebarStateFileForTest, o as DEFAULT_SIDEBAR_STATE, ot as settleWithinBudget, p as STICKY_ASSIGNMENT_MAX_AGE_MS, q as planSidebarStickyAssignmentFromSnapshot, r as AccountQuota, rt as setSidebarLegacyRouting, s as HOT_PATH_READ_BUDGET_MS, st as sidebarQuotaProjection, t as ACTIVE_ROUTING_MAX_AGE_MS, tt as resolveSidebarStickyAssignment, u as QuotaWindow, v as SidebarRoutingAccount, w as StickyAssignmentChoice, x as SidebarStateCache, y as SidebarSnapshot, z as getSidebarState } from "./sidebar-state-DjTWUbmf.js";
|
|
2
2
|
export { ACTIVE_ROUTING_MAX_AGE_MS, ACTIVE_ROUTING_MAX_ENTRIES, AccountQuota, ActiveRoutingEntry, ActiveRoutingMap, 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, applyStickyPinOverlay, clearSidebarStickyAssignment, computeQuotaPacing, createSidebarBookkeepingQueue, createSidebarStateCache, drainSidebarWrites, exhaustedQuotaResetAt, formatWindowLabel, getCollapsedQuotaSummary, getPresentQuotaWindows, getSidebarState, getSidebarStateFile, hashSidebarSessionId, isQuotaExhausted, isUsableRoutingEntry, normalizeSidebarState, persistSidebarStickyAssignment, planSidebarStickyAssignment, planSidebarStickyAssignmentFromSnapshot, pruneActiveRouting, pruneStickyAssignments, rememberStickyPin, removeSidebarActiveRouting, resolveActiveAccount, resolveSessionSidebarRouting, resolveSessionStickyAccount, resolveSidebarStickyAssignment, setLegacySidebarStateFileForTest, setSidebarLegacyRouting, setSidebarMachineState, setSidebarState, settleWithinBudget, sidebarQuotaProjection, spendControlExhaustedResetAt, upsertSidebarActiveRouting };
|
package/dist/sidebar-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$
|
|
1
|
+
import{$b as C,Ab as b,Bb as c,Cb as d,Db as e,Eb as f,Fb as g,Gb as h,Hb as i,Ib as j,Jb as k,Kb as l,Lb as m,Mb as n,Nb as o,Ob as p,Pb as q,Qb as r,Rb as s,Sb as t,Tb as u,Ub as v,Vb as w,Wb as x,Xb as y,Yb as z,Zb as A,_b as B,ac as D,bc as E,cc as F,dc as G,ec as H,fc as I,gc as J,hc as K,ic as L,jc as M,kc as N,lc as O,zb as a}from"./index-8re8rprk.js";import"./index-7eb3dw37.js";import"./index-msx2m78k.js";import"./index-7c6sxtd6.js";import"./index-m5qmvr6c.js";import"./index-csky2xpg.js";export{w as upsertSidebarActiveRouting,n as spendControlExhaustedResetAt,M as sidebarQuotaProjection,G as settleWithinBudget,u as setSidebarState,v as setSidebarMachineState,x as setSidebarLegacyRouting,c as setLegacySidebarStateFileForTest,A as resolveSidebarStickyAssignment,q as resolveSessionStickyAccount,r as resolveSessionSidebarRouting,L as resolveActiveAccount,y as removeSidebarActiveRouting,I as rememberStickyPin,t as pruneStickyAssignments,s as pruneActiveRouting,B as planSidebarStickyAssignmentFromSnapshot,z as planSidebarStickyAssignment,C as persistSidebarStickyAssignment,i as normalizeSidebarState,m as isUsableRoutingEntry,p as isQuotaExhausted,f as hashSidebarSessionId,g as getSidebarStateFile,j as getSidebarState,b as getPresentQuotaWindows,N as getCollapsedQuotaSummary,a as formatWindowLabel,o as exhaustedQuotaResetAt,E as drainSidebarWrites,H as createSidebarStateCache,K as createSidebarBookkeepingQueue,O as computeQuotaPacing,D as clearSidebarStickyAssignment,J as applyStickyPinOverlay,e as STICKY_ASSIGNMENT_MAX_ENTRIES,d as STICKY_ASSIGNMENT_MAX_AGE_MS,F as HOT_PATH_READ_BUDGET_MS,h as DEFAULT_SIDEBAR_STATE,l as ACTIVE_ROUTING_MAX_ENTRIES,k 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-zpm95mt5.js";import{Ue as R}from"./index-csky2xpg.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-zpm95mt5.js";import"./index-csky2xpg.js";export default a();
|
package/dist/tui-preferences.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{$d as h,fe as u,ge as P}from"./index-msx2m78k.js";import{Fe as M,Ge as R,Le as S}from"./index-m5qmvr6c.js";import"./index-csky2xpg.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.
|