@cortexkit/opencode-openai-auth 1.19.1 → 1.20.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.
Files changed (33) hide show
  1. package/dist/bin.js +8 -8
  2. package/dist/{codex-request-Bj3F3fFg.d.ts → codex-request-Dvj28zFK.d.ts} +9 -2
  3. package/dist/{index-3wr1ebxp.js → index-0jknjejt.js} +1 -1
  4. package/dist/index-2dxas810.js +64 -0
  5. package/dist/index-3898z307.js +101 -0
  6. package/dist/{index-hsrx1pkq.js → index-74mg470w.js} +1 -1
  7. package/dist/{index-nrkvrvpw.js → index-7tkppvqd.js} +1 -1
  8. package/dist/index-asjkhkty.js +2 -0
  9. package/dist/index-d5er9yht.js +75 -0
  10. package/dist/{index-kgzevj7y.js → index-pdsqgqng.js} +1 -1
  11. package/dist/{index-977gx5br.js → index-wy84wezx.js} +1 -1
  12. package/dist/{index-1ttg64ny.js → index-xbh03w1v.js} +1 -1
  13. package/dist/{index-mbxq1g4n.js → index-z1hz7e5y.js} +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/rpc/port-file.js +1 -1
  17. package/dist/rpc/protocol.js +1 -1
  18. package/dist/rpc/rpc-client.js +1 -1
  19. package/dist/sidebar-state.js +1 -1
  20. package/dist/tui-preferences.js +1 -1
  21. package/dist/v2/server.d.ts +1 -1
  22. package/dist/v2/server.js +3 -3
  23. package/package.json +2 -2
  24. package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +31 -14
  25. package/src/tui-compiled/raw/shared/375d9cca2def037d-private-files.js +8 -3
  26. package/src/tui-compiled/raw/shared/458b934e92490331-mutate.js +34 -13
  27. package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +31 -14
  28. package/src/tui-compiled/runtime/shared/375d9cca2def037d-private-files.js +8 -3
  29. package/src/tui-compiled/runtime/shared/458b934e92490331-mutate.js +34 -13
  30. package/dist/index-34r6y4jf.js +0 -64
  31. package/dist/index-8km6f9bq.js +0 -2
  32. package/dist/index-ckkhe4r4.js +0 -76
  33. package/dist/index-jk0zyyny.js +0 -101
@@ -1 +1 @@
1
- import{Hg as G,Jg as H}from"./index-1ttg64ny.js";function Q(x){return x==="chatgptaccountid"||x==="email"||x==="orgname"||x==="organizationname"}var S=G({extraSecretKeys:Q}),I=S.redact,N=S.redactStrings;function O(x){H({...x,extraSecretKeys:Q})}function C(x){if(x instanceof Error)return x.message;if(typeof x==="string")return x;try{return JSON.stringify(x)}catch{return String(x)}}function v(x){return"notify"in x}import{basename as X,dirname as Y,join as Z}from"node:path";var $="openai-auth.json",b="openai-auth-state.json";function p(x){return X(x)===$?Z(Y(x),b):`${x}.state.json`}import{spawn as j}from"node:child_process";function z(x,J=process.platform,q=j){try{if(J==="win32"){let U=`Start-Process '${x.replaceAll("'","''")}'`,V=Buffer.from(U,"utf16le").toString("base64"),T=q("powershell.exe",["-NoProfile","-NonInteractive","-WindowStyle","Hidden","-EncodedCommand",V],{stdio:"ignore",windowsHide:!0});return T.on("error",()=>{}),T.unref(),T.pid!==void 0}let u=q(J==="darwin"?"open":"xdg-open",[x],{stdio:"ignore"});return u.on("error",()=>{}),u.unref(),u.pid!==void 0}catch{return!1}}export{N as zg,O as Ag,$ as Bg,b as Cg,p as Dg,C as Eg,v as Fg,z as Gg};
1
+ import{Hg as G,Jg as H}from"./index-xbh03w1v.js";function Q(x){return x==="chatgptaccountid"||x==="email"||x==="orgname"||x==="organizationname"}var S=G({extraSecretKeys:Q}),I=S.redact,N=S.redactStrings;function O(x){H({...x,extraSecretKeys:Q})}function C(x){if(x instanceof Error)return x.message;if(typeof x==="string")return x;try{return JSON.stringify(x)}catch{return String(x)}}function v(x){return"notify"in x}import{basename as X,dirname as Y,join as Z}from"node:path";var $="openai-auth.json",b="openai-auth-state.json";function p(x){return X(x)===$?Z(Y(x),b):`${x}.state.json`}import{spawn as j}from"node:child_process";function z(x,J=process.platform,q=j){try{if(J==="win32"){let U=`Start-Process '${x.replaceAll("'","''")}'`,V=Buffer.from(U,"utf16le").toString("base64"),T=q("powershell.exe",["-NoProfile","-NonInteractive","-WindowStyle","Hidden","-EncodedCommand",V],{stdio:"ignore",windowsHide:!0});return T.on("error",()=>{}),T.unref(),T.pid!==void 0}let u=q(J==="darwin"?"open":"xdg-open",[x],{stdio:"ignore"});return u.on("error",()=>{}),u.unref(),u.pid!==void 0}catch{return!1}}export{N as zg,O as Ag,$ as Bg,b as Cg,p as Dg,C as Eg,v as Fg,z as Gg};
@@ -1,2 +1,2 @@
1
- import{sg as R,tg as T,ug as y,vg as D}from"./index-hsrx1pkq.js";import{Og as v,Ug as I}from"./index-8km6f9bq.js";import{_g as t}from"./index-62xhtkv8.js";class O extends Error{operation;constructor(f){super(`a ${f} on a strict notification scope needs a session id`);this.name="RpcSessionRequiredError",this.operation=f}}function S(f){return typeof f==="string"&&f.length>0}var g=new Map;function _(f){let x=JSON.stringify([f.rpcRoot,f.directoryPrefix,f.registrationSessionId,...f.requireSession===!0?["strict"]:[]]),P=g.get(x);if(!P)P={queue:[],nextId:1,lastDrainAtBySession:new Map,lastDrainAtAny:0},g.set(x,P);return P}var m=100,l=3000;function Vf(f,x,P){if(f.requireSession===!0&&!S(P))throw new O("push");let V=_(f);if(V.queue.push({id:V.nextId++,type:"open-dialog",payload:x,sessionId:P}),V.queue.length>m)V.queue=V.queue.slice(-m)}function Bf(f,x=0,P){if(f.requireSession===!0&&!S(P))throw new O("drain");let V=_(f),J=Date.now();if(V.lastDrainAtAny=J,P!==void 0)V.lastDrainAtBySession.set(P,J);let K=f.sessionlessDrain==="broadcast-only",H=(B)=>P===void 0?!K||B.sessionId===void 0:B.sessionId===void 0||B.sessionId===P;if(x>0)V.queue=V.queue.filter((B)=>{if(B.id>x)return!0;if(P===void 0)return!K||B.sessionId!==void 0;return B.sessionId!==P});return V.queue.filter((B)=>B.id>x&&H(B))}function Ff(f,x){let P=Date.now(),V=_(f),J=x!==void 0?V.lastDrainAtBySession.get(x)??0:f.sessionlessDrain==="broadcast-only"?V.lastDrainAtAny:0;return J>0&&P-J<l}import{randomBytes as a,timingSafeEqual as o}from"node:crypto";import{unlink as r}from"node:fs/promises";import{createServer as s}from"node:http";import{join as e}from"node:path";import{lstat as c}from"node:fs/promises";import{basename as d,dirname as i,resolve as k}from"node:path";var j=globalThis,w=Symbol.for("common-auth.rpc.startup-sweep");j[w]??={};var U=j[w],n=Date.now;async function q(f,x,P,V){let J=n();if(U.lastSweepAt!==void 0&&J-U.lastSweepAt<60000){let K=k(x);if(i(K)===k(f)&&P(d(K))&&(await c(K).catch((H)=>{if(H.code!=="ENOENT")throw H;return}))?.isDirectory())await D(K,V);return}U.lastSweepAt=J,await y(f,x,P,V)}class b extends Error{status;constructor(f,x){if(!Number.isInteger(f)||f<400||f>499)throw RangeError(`RpcRequestError status must be 4xx, got ${f}`);super(x);this.name="RpcRequestError",this.status=f}}var u=1e6;class E extends Error{declaredOversize;constructor(f){super("body too large");this.declaredOversize=f}}function ff(f){return new Promise((x,P)=>{let V=(B=!1)=>{f.removeAllListeners("data"),f.on("data",()=>{}),f.resume(),P(new E(B))},J=Number(f.headers["content-length"]);if(Number.isFinite(J)&&J>u){V(!0);return}let K=[],H=0;f.on("data",(B)=>{if(H+=B.length,H>u){V();return}K.push(B)}),f.on("end",()=>x(Buffer.concat(K).toString("utf8"))),f.on("error",P)})}class h extends Error{}async function xf(f,x){let P,V=new Promise((J,K)=>{P=setTimeout(()=>K(new h("apply deadline exceeded")),x),P.unref?.()});f.catch(()=>{});try{return await Promise.race([f,V])}finally{clearTimeout(P)}}function Pf(f,x){if(!f?.startsWith("Bearer "))return!1;let P=Buffer.from(f.slice(7)),V=Buffer.from(x);return P.length===V.length&&o(P,V)}async function Wf(f){if(typeof f.drain==="function"===(typeof f.drainAsync==="function"))throw TypeError("exactly one of drain or drainAsync must be provided");let x=f.log??{warn(){},debug(){}},P=a(32).toString("hex"),V=f.timeoutMs??90000,J=f.receiptTimeoutMs??2000,K=!1,H=new Set,B=s((z,G)=>{z.setTimeout(V,()=>{z.socket.destroy()}),M(z,G)});B.on("connection",(z)=>{H.add(z),z.once("close",()=>H.delete(z))}),B.requestTimeout=J,B.headersTimeout=J;async function M(z,G){let F=(X,W,C={})=>{if(G.headersSent||G.writableEnded||G.destroyed)return;G.writeHead(X,{"content-type":"application/json",...C}),G.end(JSON.stringify(W))};try{let X=new URL(z.url??"/","http://127.0.0.1").pathname;if(z.method==="GET"&&X==="/health")return F(200,{ok:!0});if(z.method!=="POST"||!X.startsWith("/rpc/"))return F(404,{error:"not found"});if(!Pf(z.headers.authorization,P))return F(401,{error:"unauthorized"});let W=X.slice(5),C;try{C=await ff(z)}catch(Y){if(!(Y instanceof E))throw Y;let Z=z.socket;if(G.once("finish",()=>{Z.end();let $=setTimeout(()=>Z.destroy(),2000);if($.unref(),z.once("end",()=>Z.destroy()),Z.once("close",()=>clearTimeout($)),z.complete)Z.destroy()}),!Y.declaredOversize&&!z.complete){if(G.headersSent||G.writableEnded||G.destroyed)return;let $=JSON.stringify({error:"body too large"});G.writeHead(413,{"content-type":"application/json","content-length":Buffer.byteLength($),connection:"close"}),G.write($),z.once("end",()=>G.end());return}return F(413,{error:"body too large"},{connection:"close"})}let Q;try{Q=JSON.parse(C||"{}")}catch{return F(400,{error:"invalid json"})}if(W==="pending-notifications"){let Y;try{if(f.parsePending)Y=f.parsePending(Q);else{if(!Q||typeof Q!=="object"||Array.isArray(Q))throw Error("invalid params");let L=Q;if(f.requireSession===!0&&!S(L.sessionId))return F(400,{error:"session required"});if("lastReceivedId"in L&&(typeof L.lastReceivedId!=="number"||!Number.isSafeInteger(L.lastReceivedId)||L.lastReceivedId<0)||"sessionId"in L&&typeof L.sessionId!=="string")throw Error("invalid params");Y={lastReceivedId:Number(L.lastReceivedId??0),sessionId:typeof L.sessionId==="string"?L.sessionId:void 0}}}catch(L){if(L instanceof b)throw L;return F(400,{error:"invalid params"})}let{lastReceivedId:Z,sessionId:$}=Y;if(f.requireSession===!0&&!S($))return F(400,{error:"session required"});if($===void 0&&!K)K=!0,x.warn("rpc notification drain missing session id",{pid:process.pid});let N;if(f.drainAsync)try{N=await f.drainAsync(Z,$)}catch(L){return x.warn("rpc notification drain failed",{pid:process.pid,error:L instanceof Error?L.message:String(L)}),F(500,{error:"drain failed"})}else N=f.drain?.(Z,$);return F(200,{messages:N})}if(W==="apply"){let Y=Promise.resolve(f.apply(Q)),Z=f.applyDeadlineMs===void 0?await Y:await xf(Y,f.applyDeadlineMs);return F(200,Z)}return F(404,{error:"unknown method"})}catch(X){if(X instanceof b)return x.debug("rpc request refused",{pid:process.pid,status:X.status}),F(X.status,{error:X.message});if(X instanceof h)return x.warn("rpc apply deadline exceeded",{pid:process.pid,deadlineMs:f.applyDeadlineMs}),F(504,{error:"handler deadline exceeded"});x.warn("rpc request failed",{pid:process.pid,error:X instanceof Error?X.message:String(X)}),F(500,{error:"internal error"})}}let A=await new Promise((z,G)=>{B.on("error",G),B.listen(0,"127.0.0.1",()=>{let F=B.address();if(F&&typeof F==="object")z(F.port);else G(Error("no port"))})});if(B.unref(),f.sweepRoot)try{await q(f.sweepRoot,f.dir,f.isManagedDir,x)}catch(z){x.warn("rpc state sweep failed",{pid:process.pid,error:z instanceof Error?z.message:String(z)})}try{await T(f.dir,{port:A,token:P,pid:process.pid},{secureDir:f.secureDir}),x.debug("rpc server pid",{pid:process.pid,rpcPort:A})}catch(z){throw await new Promise((G)=>B.close(()=>G())),z}return{port:A,token:P,async stop(){await new Promise((F)=>{B.closeAllConnections?.(),B.close(()=>F());for(let X of H)X.destroy()});let z=e(f.dir,`port-${process.pid}.json`),G=await I(z).then((F)=>JSON.parse(F)).catch((F)=>{if(F instanceof v&&F.code!=="ENOENT")throw F;return});if(G?.port===A&&G.token===P)await r(z).catch(()=>{})}}}async function Mf(f,x,P){let V=globalThis,J=Symbol.for(f),K=V[J]??{servers:new Map,pending:new Map};V[J]=K;let{servers:H,pending:B}=K,M=B.get(x)??Promise.resolve(),A,z=M.catch(()=>{}).then(async()=>{let F=H.get(x);if(F){if(await F.stop(),H.get(x)===F)H.delete(x)}A=await P(),H.set(x,A)});B.set(x,z);try{await z}finally{if(B.get(x)===z)B.delete(x)}let G=A;if(!G)throw Error("RPC server failed to start");return{server:G,release:async()=>{if(H.get(x)!==G)return;if(await G.stop(),H.get(x)===G)H.delete(x)}}}var p="1.19.1";function wf(f,x,P){let V={...x,version:p};return T(f,V,P)}var qf=R(t);
1
+ import{sg as R,tg as T,ug as y,vg as D}from"./index-74mg470w.js";import{Og as v,Ug as I}from"./index-asjkhkty.js";import{_g as t}from"./index-62xhtkv8.js";class O extends Error{operation;constructor(f){super(`a ${f} on a strict notification scope needs a session id`);this.name="RpcSessionRequiredError",this.operation=f}}function S(f){return typeof f==="string"&&f.length>0}var g=new Map;function _(f){let x=JSON.stringify([f.rpcRoot,f.directoryPrefix,f.registrationSessionId,...f.requireSession===!0?["strict"]:[]]),P=g.get(x);if(!P)P={queue:[],nextId:1,lastDrainAtBySession:new Map,lastDrainAtAny:0},g.set(x,P);return P}var m=100,l=3000;function Vf(f,x,P){if(f.requireSession===!0&&!S(P))throw new O("push");let V=_(f);if(V.queue.push({id:V.nextId++,type:"open-dialog",payload:x,sessionId:P}),V.queue.length>m)V.queue=V.queue.slice(-m)}function Bf(f,x=0,P){if(f.requireSession===!0&&!S(P))throw new O("drain");let V=_(f),J=Date.now();if(V.lastDrainAtAny=J,P!==void 0)V.lastDrainAtBySession.set(P,J);let K=f.sessionlessDrain==="broadcast-only",H=(B)=>P===void 0?!K||B.sessionId===void 0:B.sessionId===void 0||B.sessionId===P;if(x>0)V.queue=V.queue.filter((B)=>{if(B.id>x)return!0;if(P===void 0)return!K||B.sessionId!==void 0;return B.sessionId!==P});return V.queue.filter((B)=>B.id>x&&H(B))}function Ff(f,x){let P=Date.now(),V=_(f),J=x!==void 0?V.lastDrainAtBySession.get(x)??0:f.sessionlessDrain==="broadcast-only"?V.lastDrainAtAny:0;return J>0&&P-J<l}import{randomBytes as a,timingSafeEqual as o}from"node:crypto";import{unlink as r}from"node:fs/promises";import{createServer as s}from"node:http";import{join as e}from"node:path";import{lstat as c}from"node:fs/promises";import{basename as d,dirname as i,resolve as k}from"node:path";var j=globalThis,w=Symbol.for("common-auth.rpc.startup-sweep");j[w]??={};var U=j[w],n=Date.now;async function q(f,x,P,V){let J=n();if(U.lastSweepAt!==void 0&&J-U.lastSweepAt<60000){let K=k(x);if(i(K)===k(f)&&P(d(K))&&(await c(K).catch((H)=>{if(H.code!=="ENOENT")throw H;return}))?.isDirectory())await D(K,V);return}U.lastSweepAt=J,await y(f,x,P,V)}class b extends Error{status;constructor(f,x){if(!Number.isInteger(f)||f<400||f>499)throw RangeError(`RpcRequestError status must be 4xx, got ${f}`);super(x);this.name="RpcRequestError",this.status=f}}var u=1e6;class E extends Error{declaredOversize;constructor(f){super("body too large");this.declaredOversize=f}}function ff(f){return new Promise((x,P)=>{let V=(B=!1)=>{f.removeAllListeners("data"),f.on("data",()=>{}),f.resume(),P(new E(B))},J=Number(f.headers["content-length"]);if(Number.isFinite(J)&&J>u){V(!0);return}let K=[],H=0;f.on("data",(B)=>{if(H+=B.length,H>u){V();return}K.push(B)}),f.on("end",()=>x(Buffer.concat(K).toString("utf8"))),f.on("error",P)})}class h extends Error{}async function xf(f,x){let P,V=new Promise((J,K)=>{P=setTimeout(()=>K(new h("apply deadline exceeded")),x),P.unref?.()});f.catch(()=>{});try{return await Promise.race([f,V])}finally{clearTimeout(P)}}function Pf(f,x){if(!f?.startsWith("Bearer "))return!1;let P=Buffer.from(f.slice(7)),V=Buffer.from(x);return P.length===V.length&&o(P,V)}async function Wf(f){if(typeof f.drain==="function"===(typeof f.drainAsync==="function"))throw TypeError("exactly one of drain or drainAsync must be provided");let x=f.log??{warn(){},debug(){}},P=a(32).toString("hex"),V=f.timeoutMs??90000,J=f.receiptTimeoutMs??2000,K=!1,H=new Set,B=s((z,G)=>{z.setTimeout(V,()=>{z.socket.destroy()}),M(z,G)});B.on("connection",(z)=>{H.add(z),z.once("close",()=>H.delete(z))}),B.requestTimeout=J,B.headersTimeout=J;async function M(z,G){let F=(X,W,C={})=>{if(G.headersSent||G.writableEnded||G.destroyed)return;G.writeHead(X,{"content-type":"application/json",...C}),G.end(JSON.stringify(W))};try{let X=new URL(z.url??"/","http://127.0.0.1").pathname;if(z.method==="GET"&&X==="/health")return F(200,{ok:!0});if(z.method!=="POST"||!X.startsWith("/rpc/"))return F(404,{error:"not found"});if(!Pf(z.headers.authorization,P))return F(401,{error:"unauthorized"});let W=X.slice(5),C;try{C=await ff(z)}catch(Y){if(!(Y instanceof E))throw Y;let Z=z.socket;if(G.once("finish",()=>{Z.end();let $=setTimeout(()=>Z.destroy(),2000);if($.unref(),z.once("end",()=>Z.destroy()),Z.once("close",()=>clearTimeout($)),z.complete)Z.destroy()}),!Y.declaredOversize&&!z.complete){if(G.headersSent||G.writableEnded||G.destroyed)return;let $=JSON.stringify({error:"body too large"});G.writeHead(413,{"content-type":"application/json","content-length":Buffer.byteLength($),connection:"close"}),G.write($),z.once("end",()=>G.end());return}return F(413,{error:"body too large"},{connection:"close"})}let Q;try{Q=JSON.parse(C||"{}")}catch{return F(400,{error:"invalid json"})}if(W==="pending-notifications"){let Y;try{if(f.parsePending)Y=f.parsePending(Q);else{if(!Q||typeof Q!=="object"||Array.isArray(Q))throw Error("invalid params");let L=Q;if(f.requireSession===!0&&!S(L.sessionId))return F(400,{error:"session required"});if("lastReceivedId"in L&&(typeof L.lastReceivedId!=="number"||!Number.isSafeInteger(L.lastReceivedId)||L.lastReceivedId<0)||"sessionId"in L&&typeof L.sessionId!=="string")throw Error("invalid params");Y={lastReceivedId:Number(L.lastReceivedId??0),sessionId:typeof L.sessionId==="string"?L.sessionId:void 0}}}catch(L){if(L instanceof b)throw L;return F(400,{error:"invalid params"})}let{lastReceivedId:Z,sessionId:$}=Y;if(f.requireSession===!0&&!S($))return F(400,{error:"session required"});if($===void 0&&!K)K=!0,x.warn("rpc notification drain missing session id",{pid:process.pid});let N;if(f.drainAsync)try{N=await f.drainAsync(Z,$)}catch(L){return x.warn("rpc notification drain failed",{pid:process.pid,error:L instanceof Error?L.message:String(L)}),F(500,{error:"drain failed"})}else N=f.drain?.(Z,$);return F(200,{messages:N})}if(W==="apply"){let Y=Promise.resolve(f.apply(Q)),Z=f.applyDeadlineMs===void 0?await Y:await xf(Y,f.applyDeadlineMs);return F(200,Z)}return F(404,{error:"unknown method"})}catch(X){if(X instanceof b)return x.debug("rpc request refused",{pid:process.pid,status:X.status}),F(X.status,{error:X.message});if(X instanceof h)return x.warn("rpc apply deadline exceeded",{pid:process.pid,deadlineMs:f.applyDeadlineMs}),F(504,{error:"handler deadline exceeded"});x.warn("rpc request failed",{pid:process.pid,error:X instanceof Error?X.message:String(X)}),F(500,{error:"internal error"})}}let A=await new Promise((z,G)=>{B.on("error",G),B.listen(0,"127.0.0.1",()=>{let F=B.address();if(F&&typeof F==="object")z(F.port);else G(Error("no port"))})});if(B.unref(),f.sweepRoot)try{await q(f.sweepRoot,f.dir,f.isManagedDir,x)}catch(z){x.warn("rpc state sweep failed",{pid:process.pid,error:z instanceof Error?z.message:String(z)})}try{await T(f.dir,{port:A,token:P,pid:process.pid},{secureDir:f.secureDir}),x.debug("rpc server pid",{pid:process.pid,rpcPort:A})}catch(z){throw await new Promise((G)=>B.close(()=>G())),z}return{port:A,token:P,async stop(){await new Promise((F)=>{B.closeAllConnections?.(),B.close(()=>F());for(let X of H)X.destroy()});let z=e(f.dir,`port-${process.pid}.json`),G=await I(z).then((F)=>JSON.parse(F)).catch((F)=>{if(F instanceof v&&F.code!=="ENOENT")throw F;return});if(G?.port===A&&G.token===P)await r(z).catch(()=>{})}}}async function Mf(f,x,P){let V=globalThis,J=Symbol.for(f),K=V[J]??{servers:new Map,pending:new Map};V[J]=K;let{servers:H,pending:B}=K,M=B.get(x)??Promise.resolve(),A,z=M.catch(()=>{}).then(async()=>{let F=H.get(x);if(F){if(await F.stop(),H.get(x)===F)H.delete(x)}A=await P(),H.set(x,A)});B.set(x,z);try{await z}finally{if(B.get(x)===z)B.delete(x)}let G=A;if(!G)throw Error("RPC server failed to start");return{server:G,release:async()=>{if(H.get(x)!==G)return;if(await G.stop(),H.get(x)===G)H.delete(x)}}}var p="1.20.0";function wf(f,x,P){let V={...x,version:p};return T(f,V,P)}var qf=R(t);
2
2
  export{Vf as kg,Bf as lg,Ff as mg,Wf as ng,Mf as og,p as pg,wf as qg,qf as rg};
@@ -1,2 +1,2 @@
1
- import{Ng as K,Qg as T,Sg as A,Tg as y,Vg as m,Xg as h}from"./index-8km6f9bq.js";import{appendFileSync as r,chmodSync as i,existsSync as L,renameSync as F,statSync as e}from"node:fs";import{open as C0}from"node:fs/promises";import{dirname as G0,resolve as H0}from"node:path";var s=/^(authorization|x-api-key|cookie|set-cookie|refresh|access|token)$/i,o=/\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b|ckh_[A-Za-z0-9_-]{20,}/g;function t(C){return C instanceof Error||Object.prototype.toString.call(C)==="[object Error]"}function q(C={}){let H=[o,...C.extraValuePatterns??[]].map((G)=>new RegExp(G.source,G.flags.includes("g")?G.flags:`${G.flags}g`));function $(G){let J=G.toLowerCase().replace(/[-_]/g,"");return s.test(G)||J.includes("apikey")||J.endsWith("secret")||J.endsWith("password")||J.endsWith("token")&&!J.endsWith("tokens")||!!C.extraSecretKeys?.(J)}function U(G){let J=G,Q=[["name",G.name],["message",G.message],["stack",G.stack]];for(let V of["code","status","cause"])if(J[V]!==void 0)Q.push([V,J[V]]);let N=new Set(Q.map(([V])=>V));for(let V of Object.entries(G))if(!N.has(V[0]))Q.push(V);return Q}function B(G,J,Q,N=0){if(typeof G==="string")return H.reduce((V,X)=>V.replace(X,"***REDACTED***"),G);if(!G||typeof G!=="object")return G;if(Q.has(G))return"[Circular]";Q.add(G);try{if(Array.isArray(G))return G.map((Y)=>B(Y,J,Q,N));let V=t(G);if(V&&N>=8)return"[Truncated]";let X=V?N+1:N;return Object.fromEntries((V?U(G):Object.entries(G)).map(([Y,O])=>[Y,J&&$(Y)?"***REDACTED***":B(O,J,Q,X)]))}finally{Q.delete(G)}}return{redact:(G)=>B(G,!0,new WeakSet),redactStrings:(G)=>B(G,!1,new WeakSet)}}var E=q(),n=E.redact,l=E.redactStrings;var R={error:0,warn:1,info:2,debug:3,trace:4},w=5242880,p=3;function P(C){try{i(C,384)}catch{}}function I0(C){try{if(!(L(C)&&e(C).size>=w))return;for(let $=p-1;$>=1;$--)if(L(`${C}.${$}`)){let U=`${C}.${$+1}`;F(`${C}.${$}`,U),P(U)}let H=`${C}.1`;F(C,H),P(H)}catch{}}async function M(C){let{file:H,handle:$}=C;if(C.file=void 0,C.handle=void 0,H&&$)await T(H,"log-close",()=>$.close())}async function g(C,H){await y(G0(H));try{await A(H,"file",!0)}catch($){if($.code!=="ENOENT")throw $;try{await m(H,"")}catch(U){if(U.code!=="EEXIST")throw U;await A(H,"file",!0)}}return C.handle=await T(H,"log-open",()=>C0(H,"a")),C.file=H,C.handle}async function J0(C,H,$){H=H0(H);try{if(C.file!==H)await M(C);let U=C.handle??await g(C,H);if((await T(H,"log-stat",()=>U.stat())).size>=w){await M(C);for(let G=p-1;G>=0;G--){let J=G===0?H:`${H}.${G}`,Q=`${H}.${G+1}`;try{await A(J,"file",!0)}catch(N){if(N.code==="ENOENT")continue;throw N}try{await A(Q,"file",!0)}catch(N){if(N.code!=="ENOENT")throw N}await h(J,Q),await A(Q,"file")}U=await g(C,H)}await T(H,"log-append",()=>U.appendFile($,"utf8"))}catch(U){throw await M(C).catch(()=>{}),U}}function Q0(C){try{return` ${JSON.stringify(C)}`}catch{return" [unserializable]"}}function Z0(C){let H,$,U,B=q(),G,J=[],Q,N=Promise.resolve(),V,X={};function Y(I){let Z=N.then(I);return N=Z.catch((j)=>{V=j}),Z}function O(I){if(K&&I.file!==H)Y(()=>M(X)).catch(()=>{});H=I.file,$=I.level,B=q(I),G=I.captureSink}function k(I){if(I===void 0||I in R)U=I}function v(){if(H===void 0)return;return(typeof H==="function"?H():H)||void 0}function c(){if(U)return U;let I=typeof $==="function"?$():$;if(I&&I in R)return I;return"info"}function D(I=!0){if(Q)clearTimeout(Q),Q=void 0;if(!J.length){if(K)return Y(async()=>{if(I)await M(X);if(V)throw V});return}let Z;try{Z=v()}catch{if(J=[],K&&I)return Y(()=>M(X));return}let j=J.join("");if(J=[],!Z){if(K&&I)return Y(()=>M(X));return}if(K)return Y(async()=>{try{await J0(X,Z,j)}finally{if(I)await M(X)}});try{if(I0(Z),L(Z))P(Z);r(Z,j,{encoding:"utf8",mode:384})}catch{}}function f(){if(!Q)Q=setTimeout(()=>{Q=void 0;let I=D(!1);if(I instanceof Promise)I.catch(()=>{})},500)}function z(I,Z,j,W){if(H===void 0&&G===void 0)return;try{if(R[Z]>R[c()])return;let b=B.redactStrings(j),x;try{x=B.redact(W)}catch{x="[unserializable]"}let a=`[${new Date().toISOString()}] ${Z.toUpperCase()} [${I}] ${b}`+(W===void 0?"":Q0(x))+`
1
+ import{Ng as K,Qg as T,Sg as A,Tg as y,Vg as m,Xg as h}from"./index-asjkhkty.js";import{appendFileSync as r,chmodSync as i,existsSync as L,renameSync as F,statSync as e}from"node:fs";import{open as C0}from"node:fs/promises";import{dirname as G0,resolve as H0}from"node:path";var s=/^(authorization|x-api-key|cookie|set-cookie|refresh|access|token)$/i,o=/\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b|ckh_[A-Za-z0-9_-]{20,}/g;function t(C){return C instanceof Error||Object.prototype.toString.call(C)==="[object Error]"}function q(C={}){let H=[o,...C.extraValuePatterns??[]].map((G)=>new RegExp(G.source,G.flags.includes("g")?G.flags:`${G.flags}g`));function $(G){let J=G.toLowerCase().replace(/[-_]/g,"");return s.test(G)||J.includes("apikey")||J.endsWith("secret")||J.endsWith("password")||J.endsWith("token")&&!J.endsWith("tokens")||!!C.extraSecretKeys?.(J)}function U(G){let J=G,Q=[["name",G.name],["message",G.message],["stack",G.stack]];for(let V of["code","status","cause"])if(J[V]!==void 0)Q.push([V,J[V]]);let N=new Set(Q.map(([V])=>V));for(let V of Object.entries(G))if(!N.has(V[0]))Q.push(V);return Q}function B(G,J,Q,N=0){if(typeof G==="string")return H.reduce((V,X)=>V.replace(X,"***REDACTED***"),G);if(!G||typeof G!=="object")return G;if(Q.has(G))return"[Circular]";Q.add(G);try{if(Array.isArray(G))return G.map((Y)=>B(Y,J,Q,N));let V=t(G);if(V&&N>=8)return"[Truncated]";let X=V?N+1:N;return Object.fromEntries((V?U(G):Object.entries(G)).map(([Y,O])=>[Y,J&&$(Y)?"***REDACTED***":B(O,J,Q,X)]))}finally{Q.delete(G)}}return{redact:(G)=>B(G,!0,new WeakSet),redactStrings:(G)=>B(G,!1,new WeakSet)}}var E=q(),n=E.redact,l=E.redactStrings;var R={error:0,warn:1,info:2,debug:3,trace:4},w=5242880,p=3;function P(C){try{i(C,384)}catch{}}function I0(C){try{if(!(L(C)&&e(C).size>=w))return;for(let $=p-1;$>=1;$--)if(L(`${C}.${$}`)){let U=`${C}.${$+1}`;F(`${C}.${$}`,U),P(U)}let H=`${C}.1`;F(C,H),P(H)}catch{}}async function M(C){let{file:H,handle:$}=C;if(C.file=void 0,C.handle=void 0,H&&$)await T(H,"log-close",()=>$.close())}async function g(C,H){await y(G0(H));try{await A(H,"file",!0)}catch($){if($.code!=="ENOENT")throw $;try{await m(H,"")}catch(U){if(U.code!=="EEXIST")throw U;await A(H,"file",!0)}}return C.handle=await T(H,"log-open",()=>C0(H,"a")),C.file=H,C.handle}async function J0(C,H,$){H=H0(H);try{if(C.file!==H)await M(C);let U=C.handle??await g(C,H);if((await T(H,"log-stat",()=>U.stat())).size>=w){await M(C);for(let G=p-1;G>=0;G--){let J=G===0?H:`${H}.${G}`,Q=`${H}.${G+1}`;try{await A(J,"file",!0)}catch(N){if(N.code==="ENOENT")continue;throw N}try{await A(Q,"file",!0)}catch(N){if(N.code!=="ENOENT")throw N}await h(J,Q),await A(Q,"file")}U=await g(C,H)}await T(H,"log-append",()=>U.appendFile($,"utf8"))}catch(U){throw await M(C).catch(()=>{}),U}}function Q0(C){try{return` ${JSON.stringify(C)}`}catch{return" [unserializable]"}}function Z0(C){let H,$,U,B=q(),G,J=[],Q,N=Promise.resolve(),V,X={};function Y(I){let Z=N.then(I);return N=Z.catch((j)=>{V=j}),Z}function O(I){if(K&&I.file!==H)Y(()=>M(X)).catch(()=>{});H=I.file,$=I.level,B=q(I),G=I.captureSink}function k(I){if(I===void 0||I in R)U=I}function v(){if(H===void 0)return;return(typeof H==="function"?H():H)||void 0}function c(){if(U)return U;let I=typeof $==="function"?$():$;if(I&&I in R)return I;return"info"}function D(I=!0){if(Q)clearTimeout(Q),Q=void 0;if(!J.length){if(K)return Y(async()=>{if(I)await M(X);if(V)throw V});return}let Z;try{Z=v()}catch{if(J=[],K&&I)return Y(()=>M(X));return}let j=J.join("");if(J=[],!Z){if(K&&I)return Y(()=>M(X));return}if(K)return Y(async()=>{try{await J0(X,Z,j)}finally{if(I)await M(X)}});try{if(I0(Z),L(Z))P(Z);r(Z,j,{encoding:"utf8",mode:384})}catch{}}function f(){if(!Q)Q=setTimeout(()=>{Q=void 0;let I=D(!1);if(I instanceof Promise)I.catch(()=>{})},500)}function z(I,Z,j,W){if(H===void 0&&G===void 0)return;try{if(R[Z]>R[c()])return;let b=B.redactStrings(j),x;try{x=B.redact(W)}catch{x="[unserializable]"}let a=`[${new Date().toISOString()}] ${Z.toUpperCase()} [${I}] ${b}`+(W===void 0?"":Q0(x))+`
2
2
  `;try{G?.({channel:I,level:Z,message:b,data:x})}catch{}if(H===void 0)return;if(J.push(a),J.length>=50){let S=D(!1);if(S instanceof Promise)S.catch(()=>{})}else f()}catch{}}function u(I){return{error:(Z,j)=>z(I,"error",Z,j),warn:(Z,j)=>z(I,"warn",Z,j),info:(Z,j)=>z(I,"info",Z,j),debug:(Z,j)=>z(I,"debug",Z,j),trace:(Z,j)=>z(I,"trace",Z,j)}}function d(){if(K)Y(()=>M(X)).catch(()=>{});if(V=void 0,J=[],Q)clearTimeout(Q),Q=void 0;H=void 0,$=void 0,U=void 0,B=q(),G=void 0}if(C)O(C);return{configure:O,createLogger:u,setLogLevel:k,flushLogs:D,reset:d}}var _=Z0();function $0(C){_.configure(C);let{configure:H,createLogger:$,setLogLevel:U,flushLogs:B}=_;return{configure:H,createLogger:$,setLogLevel:U,flushLogs:B}}function U0(C){_.setLogLevel(C)}function V0(){return _.flushLogs()}function j0(C){return _.createLogger(C)}export{q as Hg,n as Ig,$0 as Jg,U0 as Kg,V0 as Lg,j0 as Mg};
@@ -1,3 +1,3 @@
1
- import{rc as X,tc as V}from"./index-ckkhe4r4.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)}
1
+ import{rc as X,tc as V}from"./index-d5er9yht.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};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as loadAccounts, _ as parseJwtClaims, a as RESPONSES_LITE_MODELS, b as OAuthAccount, 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 AccountStorage, w as QuotaManager, x as OAuthQuotaSnapshot, y as FallbackAccount } from "./codex-request-Bj3F3fFg.js";
1
+ import { S as loadAccounts, _ as parseJwtClaims, a as RESPONSES_LITE_MODELS, b as OAuthAccount, 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 AccountStorage, w as QuotaManager, x as OAuthQuotaSnapshot, y as FallbackAccount } from "./codex-request-Dvj28zFK.js";
2
2
  import { S as SidebarState, y as SidebarMachineState } from "./sidebar-state-CrRiE9hw.js";
3
3
  import { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
4
4
  type TimerHandle = ReturnType<typeof setInterval>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as s,T as m,U as n,V as o,W as p,X as q,_ as r,aa as t,ba as u,ca as v,da as w,ea as x,fa as y,ga as z,ha as A,ia as B,ja as C,ka as D,la as E,m as c,ma as F,n as d,na as G,o as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l}from"./index-34r6y4jf.js";import"./index-ckkhe4r4.js";import"./index-3wr1ebxp.js";import{xe as a,ye as b}from"./index-jk0zyyny.js";import"./index-nrkvrvpw.js";import"./index-977gx5br.js";import"./index-hsrx1pkq.js";import"./index-kgzevj7y.js";import"./index-1ttg64ny.js";import"./index-8km6f9bq.js";import"./index-62xhtkv8.js";import"./index-r6k6hh93.js";export{g as rewriteResponsesLiteBody,v as resolveSidebarSessionId,o as poolResetTarget,a as parseJwtClaims,s as mergePushedQuotaMetadata,x as getMainRefreshLockName,r as findCachekeepFallbackAccount,b as extractAccountIdFromClaims,G as default,p as createResetTargetResolver,l as codexOAuthModelVariantSource,j as codexOAuthModelListed,k as codexOAuthModelLimit,u as buildSidebarState,t as buildSidebarMachineState,q as buildResetRedemptionDeps,B as __resetBootQuotaSeedForTest,C as __menuContextForTest,A as __bootQuotaSeedPromiseForTest,n as ResetTargetResolutionError,c as RESPONSES_LITE_MODELS,D as POOL_MIGRATION_ENABLED,F as OpenAIAuthPlugin,f as MID_CONVERSATION_EFFORT_MODELS,y as MAIN_REFRESH_LOCK_TTL_MS,z as MAIN_REFRESH_LEASE_TTL_MS,w as EMPTY_BEARER_MESSAGE,i as DISALLOWED_MODELS,E as CodexAuthPlugin,d as CODEX_VERSION,e as CODEX_USER_AGENT,m as AuthPersistError,h as ALLOWED_MODELS};
1
+ import{$ as u,R as m,S as n,T as o,U as p,V as q,Y as r,Z as s,_ as t,aa as v,ea as w,fa as x,ga as y,ha as z,ia as A,ja as B,ka as C,la as D,m as c,ma as E,n as d,na as F,o as e,oa as G,r as f,s as g,t as h,u as i,v as j,w as k,x as l}from"./index-2dxas810.js";import"./index-d5er9yht.js";import"./index-0jknjejt.js";import{xe as a,ye as b}from"./index-3898z307.js";import"./index-7tkppvqd.js";import"./index-wy84wezx.js";import"./index-74mg470w.js";import"./index-pdsqgqng.js";import"./index-xbh03w1v.js";import"./index-asjkhkty.js";import"./index-62xhtkv8.js";import"./index-r6k6hh93.js";export{g as rewriteResponsesLiteBody,v as resolveSidebarSessionId,o as poolResetTarget,a as parseJwtClaims,s as mergePushedQuotaMetadata,x as getMainRefreshLockName,r as findCachekeepFallbackAccount,b as extractAccountIdFromClaims,G as default,p as createResetTargetResolver,l as codexOAuthModelVariantSource,j as codexOAuthModelListed,k as codexOAuthModelLimit,u as buildSidebarState,t as buildSidebarMachineState,q as buildResetRedemptionDeps,B as __resetBootQuotaSeedForTest,C as __menuContextForTest,A as __bootQuotaSeedPromiseForTest,n as ResetTargetResolutionError,c as RESPONSES_LITE_MODELS,D as POOL_MIGRATION_ENABLED,F as OpenAIAuthPlugin,f as MID_CONVERSATION_EFFORT_MODELS,y as MAIN_REFRESH_LOCK_TTL_MS,z as MAIN_REFRESH_LEASE_TTL_MS,w as EMPTY_BEARER_MESSAGE,i as DISALLOWED_MODELS,E as CodexAuthPlugin,d as CODEX_VERSION,e as CODEX_USER_AGENT,m as AuthPersistError,h as ALLOWED_MODELS};
@@ -1 +1 @@
1
- import{qg as b,rg as c}from"../index-977gx5br.js";import{wg as a}from"../index-hsrx1pkq.js";import"../index-8km6f9bq.js";import"../index-62xhtkv8.js";import"../index-r6k6hh93.js";export{b as writePortFile,c as isOpenaiRpcStateDir,a as discoverPortFile};
1
+ import{qg as b,rg as c}from"../index-wy84wezx.js";import{wg as a}from"../index-74mg470w.js";import"../index-asjkhkty.js";import"../index-62xhtkv8.js";import"../index-r6k6hh93.js";export{b as writePortFile,c as isOpenaiRpcStateDir,a as discoverPortFile};
@@ -1 +1 @@
1
- import{Fg as b}from"../index-kgzevj7y.js";import"../index-1ttg64ny.js";import"../index-8km6f9bq.js";import"../index-r6k6hh93.js";export{b as isNotifyPayload};
1
+ import{Fg as b}from"../index-pdsqgqng.js";import"../index-xbh03w1v.js";import"../index-asjkhkty.js";import"../index-r6k6hh93.js";export{b as isNotifyPayload};
@@ -1 +1 @@
1
- import{xg as F,yg as f}from"../index-hsrx1pkq.js";import"../index-8km6f9bq.js";import"../index-r6k6hh93.js";function y(r,s,v){return f(r,s,v)}export{y as createRpcClient,F as DEFAULT_RPC_TIMEOUT_MS};
1
+ import{xg as F,yg as f}from"../index-74mg470w.js";import"../index-asjkhkty.js";import"../index-r6k6hh93.js";function y(r,s,v){return f(r,s,v)}export{y as createRpcClient,F as DEFAULT_RPC_TIMEOUT_MS};
@@ -1 +1 @@
1
- import{$c as t,Ic as a,Jc as b,Kc as c,Lc as d,Mc as e,Nc as f,Oc as g,Pc as h,Qc as i,Rc as j,Sc as k,Tc as l,Uc as m,Vc as n,Wc as o,Xc as p,Yc as q,Zc as r,_c as s,ad as u,bd as v,cd as w,dd as x,ed as y,fd as z,gd as A,hd as B,id as C,jd as D,kd as E,ld as F,md as G,nd as H,od as I,pd as J,qd as K,rd as L,sd as M,td as N,ud as O,vd as P,wd as Q,xd as R,yd as S,zd as T}from"./index-3wr1ebxp.js";import"./index-jk0zyyny.js";import"./index-nrkvrvpw.js";import"./index-kgzevj7y.js";import"./index-1ttg64ny.js";import"./index-8km6f9bq.js";import"./index-r6k6hh93.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
+ import{$c as t,Ic as a,Jc as b,Kc as c,Lc as d,Mc as e,Nc as f,Oc as g,Pc as h,Qc as i,Rc as j,Sc as k,Tc as l,Uc as m,Vc as n,Wc as o,Xc as p,Yc as q,Zc as r,_c as s,ad as u,bd as v,cd as w,dd as x,ed as y,fd as z,gd as A,hd as B,id as C,jd as D,kd as E,ld as F,md as G,nd as H,od as I,pd as J,qd as K,rd as L,sd as M,td as N,ud as O,vd as P,wd as Q,xd as R,yd as S,zd as T}from"./index-0jknjejt.js";import"./index-3898z307.js";import"./index-7tkppvqd.js";import"./index-pdsqgqng.js";import"./index-xbh03w1v.js";import"./index-asjkhkty.js";import"./index-r6k6hh93.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,4 +1,4 @@
1
- import{Zf as _,fg as R,hg as I,ig as x}from"./index-nrkvrvpw.js";import"./index-1ttg64ny.js";import{Ng as N,Og as L,Ug as j}from"./index-8km6f9bq.js";import"./index-r6k6hh93.js";import{mkdir as T,writeFile as h}from"node:fs/promises";import{homedir as y}from"node:os";import{dirname as f,join as C}from"node:path";import{applyEdits as g,modify as k,parse as b}from"jsonc-parser";function E(z){return z!==null&&typeof z==="object"&&!Array.isArray(z)}async function S(z){try{let q=[],H=b(await j(z,N),q,{allowTrailingComma:!0});return q.length===0&&E(H)?H:{}}catch(q){if(q instanceof L&&q.code!=="ENOENT")throw q;return{}}}var w=`// Shared preferences for TUI plugins.
1
+ import{Zf as _,fg as R,hg as I,ig as x}from"./index-7tkppvqd.js";import"./index-xbh03w1v.js";import{Ng as N,Og as L,Ug as j}from"./index-asjkhkty.js";import"./index-r6k6hh93.js";import{mkdir as T,writeFile as h}from"node:fs/promises";import{homedir as y}from"node:os";import{dirname as f,join as C}from"node:path";import{applyEdits as g,modify as k,parse as b}from"jsonc-parser";function E(z){return z!==null&&typeof z==="object"&&!Array.isArray(z)}async function S(z){try{let q=[],H=b(await j(z,N),q,{allowTrailingComma:!0});return q.length===0&&E(H)?H:{}}catch(q){if(q instanceof L&&q.code!=="ENOENT")throw q;return{}}}var w=`// Shared preferences for TUI plugins.
2
2
  // Plugins update individual keys in place and preserve comments.
3
3
  {}
4
4
  `;function A(z){let{file:q,pluginKey:H,beforeCommit:Q}=z,X={...I.preferences,timeoutMs:z.timeoutMs??I.preferences.timeoutMs},$=Promise.resolve();async function V(J,D){await R(q,X,async(U)=>{let B;try{B=await j(q,N)}catch(M){if(M.code!=="ENOENT")throw M;B=""}if(B.trim()==="")B=w;let W=g(B,k(B,[H,...J],D,{formattingOptions:{insertSpaces:!0,tabSize:2}}));await _(q,W,{serialize:(M)=>String(M),beforeRename:async()=>{await Q?.(),await U.assertOwned()}})})}return{queueTuiPreferenceUpdate(J,D){let U=[...J],B=structuredClone(D),W=$.then(()=>V(U,B));return $=W.catch(()=>{}),W}}}var p="OPENCODE_TUI_PREFERENCES_FILE",c="tui-preferences.jsonc";function K(){let z=process.env[p];if(z)return z;let q=process.env.OPENCODE_CONFIG_DIR||C(process.env.XDG_CONFIG_HOME||C(y(),".config"),"opencode");return C(q,c)}function Y(z){return typeof z==="object"&&z!==null&&!Array.isArray(z)}function Jq(){return S(K())}var v="openai-auth",d=160,m={forceToTop:!1,order:d,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 Z(z,q){return typeof z==="boolean"?z:q}function G(z,q,H,Q){if(typeof z!=="number"||!Number.isFinite(z))return q;return Math.min(Math.max(Math.round(z),H),Q)}function u(z,q,H){if(typeof z!=="string"||z.length===0)return q;return z.slice(0,H)}function P(z,q){if(typeof z!=="string")return q;return[...z][0]??q}function Yq(z){let q=z[v];if(!Y(q))return structuredClone(m);let H=m,Q=Y(q.header)?q.header:{},X=Y(q.sections)?q.sections:{},$=Y(q.appearance)?q.appearance:{},V=G($.warnThreshold,H.appearance.warnThreshold,0,99),J=Math.max(G($.errorThreshold,H.appearance.errorThreshold,0,100),Math.min(V+1,100));return{forceToTop:Z(q.forceToTop,H.forceToTop),order:G(q.order,H.order,-1e4,1e4),startCollapsed:Z(q.startCollapsed,H.startCollapsed),rememberCollapsed:Z(q.rememberCollapsed,H.rememberCollapsed),collapsed:typeof q.collapsed==="boolean"?q.collapsed:null,pollMs:G(q.pollMs,H.pollMs,500,30000),refreshDebounceMs:G(q.refreshDebounceMs,H.refreshDebounceMs,50,5000),header:{label:u(Q.label,H.header.label,20),showVersion:Z(Q.showVersion,H.header.showVersion)},sections:{quota:Z(X.quota,H.sections.quota),fallbackAccounts:Z(X.fallbackAccounts,H.sections.fallbackAccounts),routing:Z(X.routing,H.sections.routing),health:Z(X.health,H.sections.health),pacing:Z(X.pacing,H.sections.pacing)},appearance:{barWidth:G($.barWidth,H.appearance.barWidth,4,40),barFilledChar:P($.barFilledChar,H.appearance.barFilledChar),barEmptyChar:P($.barEmptyChar,H.appearance.barEmptyChar),warnThreshold:V,errorThreshold:J}}}var s=-1e5;function Vq(z,q,H){let Q=z[q];if(!Y(Q))return H;if(Q.forceToTop===!0)return s+Object.keys(z).indexOf(q);return G(Q.order,H,-1e4,1e4)}var n=`// Shared preferences for opencode TUI plugins.
@@ -1,4 +1,4 @@
1
- import { C as AccountPaths, c as HostSlotAdapter, d as OpenAiVaultOptions, f as BeginAccountLoginOptions, i as CodexSessionMetadata, o as RuntimeLayoutOptions, p as BeginAccountLoginResult, r as CodexRequestRuntime, s as PoolLifecycleDeps } from "../codex-request-Bj3F3fFg.js";
1
+ import { C as AccountPaths, c as HostSlotAdapter, d as OpenAiVaultOptions, f as BeginAccountLoginOptions, i as CodexSessionMetadata, o as RuntimeLayoutOptions, p as BeginAccountLoginResult, r as CodexRequestRuntime, s as PoolLifecycleDeps } from "../codex-request-Dvj28zFK.js";
2
2
  import { i as OpenDialogPayload, n as ApplyResult } from "../protocol-BZZtDn5h.js";
3
3
  import { Plugin } from "@opencode/plugin";
4
4
  import "@opencode/plugin/promise/integration";