@cortexkit/opencode-anthropic-auth 1.16.0 → 1.17.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/cli.js +1 -1
- package/dist/{index-5xsc5gwa.js → index-63keqwnf.js} +1 -1
- package/dist/{index-z9dywmf2.js → index-am5pq04s.js} +1 -1
- package/dist/{index-dbczmr1v.js → index-f5r96vyv.js} +1 -1
- package/dist/index-gj7emmj5.js +2 -0
- package/dist/index-xvfesm3w.js +422 -0
- package/dist/{index-epg96jpt.js → index-y2n9h7p6.js} +1 -1
- package/dist/index.js +12 -12
- package/dist/{logger-ta3qm0a2.js → logger-ywfmddsw.js} +1 -1
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state.d.ts +52 -2
- package/dist/sidebar-state.js +1 -1
- package/dist/tui/command-dialogs.d.ts +12 -0
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +2 -0
- package/package.json +2 -2
- package/src/sidebar-state.ts +381 -4
- package/src/tui/command-dialogs.tsx +22 -11
- package/src/tui-compiled/sidebar-state.ts +381 -4
- package/src/tui-compiled/tui/command-dialogs.tsx +12 -8
- package/src/tui-compiled/tui.tsx +147 -104
- package/src/tui.tsx +34 -2
- package/dist/index-0z4mmpxy.js +0 -2
- package/dist/index-sgwz35qx.js +0 -422
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{C as z,D as N,F as P,H as L,J as E,L as K,Lb as T,M as S,Nb as q,ya as U}from"./index-xvfesm3w.js";import"./index-y2n9h7p6.js";import{rc as w}from"./index-f5r96vyv.js";import{stdin as x,stdout as v}from"node:process";import{createInterface as y}from"node:readline/promises";function R(){return{version:1,main:{type:"opencode",provider:"anthropic"},fallbackOn:[401,403,429],refresh:{enabled:!0,intervalMinutes:10,refreshBeforeExpiryMinutes:240},quota:{enabled:!0,checkIntervalMinutes:5,minimumRemaining:{five_hour:10,seven_day:20},failClosedOnUnknownQuota:!0},accounts:[]}}function _(){console.log(`Usage:
|
|
3
3
|
opencode-anthropic-auth login [label]
|
|
4
4
|
opencode-anthropic-auth api add [label]
|
|
5
5
|
opencode-anthropic-auth list
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as z}from"node:crypto";import{homedir as F,tmpdir as O}from"node:os";import{join as q,resolve as G}from"node:path";var J="OPENCODE_ANTHROPIC_AUTH_RPC_DIR";function T(g){let k=process.env[J]?.trim();if(k)return G(g,k);let w=z("sha256").update(g).digest("hex").slice(0,16),x=process.env.XDG_STATE_HOME||q(F(),".local","state");return q(x,"cortexkit","anthropic-auth","rpc",w)}export{O as
|
|
1
|
+
import{createHash as z}from"node:crypto";import{homedir as F,tmpdir as O}from"node:os";import{join as q,resolve as G}from"node:path";var J="OPENCODE_ANTHROPIC_AUTH_RPC_DIR";function T(g){let k=process.env[J]?.trim();if(k)return G(g,k);let w=z("sha256").update(g).digest("hex").slice(0,16),x=process.env.XDG_STATE_HOME||q(F(),".local","state");return q(x,"cortexkit","anthropic-auth","rpc",w)}export{O as nc,T as oc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{mkdir as l,readdir as u,readFile as c,rename as p,unlink as m,writeFile as d}from"node:fs/promises";import{join as a}from"node:path";function f(t){try{return process.kill(t,0),!0}catch(r){return r.code==="EPERM"}}async function b(t,r){await l(t,{recursive:!0});let s={...r,startedAt:Date.now()},e=a(t,`port-${r.pid}.json`),i=`${e}.${process.pid}.tmp`;return await d(i,JSON.stringify(s),{encoding:"utf8",mode:384}),await p(i,e),e}async function h(t,r){let s;try{s=await u(t)}catch{return null}let e=[];for(let n of s){if(!n.startsWith("port-")||!n.endsWith(".json"))continue;try{let o=JSON.parse(await c(a(t,n),"utf8"));if(Number.isFinite(o.port))if(f(o.pid))e.push(o);else m(a(t,n)).catch(()=>{})}catch{}}if(e.length===0)return null;let i=r&&r>=1?e.filter((n)=>n.pid===r):[];return(i.length>0?i:e).sort((n,o)=>o.startedAt-n.startedAt)[0]??null}
|
|
2
|
-
export{b as
|
|
2
|
+
export{b as lc,h as mc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire as q}from"node:module";var j=Object.create;var{getPrototypeOf:k,defineProperty:i,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,r=(a,b,d)=>{var f=a!=null&&typeof a==="object";if(f){var g=b?o??=new WeakMap:p??=new WeakMap,h=g.get(a);if(h)return h}d=a!=null?j(k(a)):{};let c=b||!a||!a.__esModule?i(d,"default",{value:a,enumerable:!0}):d;for(let e of l(a))if(!m.call(c,e))i(c,e,{get:n.bind(a,e),enumerable:!0});if(f)g.set(a,c);return c};var s=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var u=q(import.meta.url);
|
|
2
|
-
export{r as
|
|
2
|
+
export{r as pc,s as qc,u as rc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ic as Q}from"./index-y2n9h7p6.js";import{randomUUID as f}from"node:crypto";import{mkdir as P,readFile as D,rename as b,rm as O,rmdir as T,stat as U,unlink as p,writeFile as E}from"node:fs/promises";import{tmpdir as k}from"node:os";import{dirname as S,join as W}from"node:path";var F="OPENCODE_ANTHROPIC_AUTH_SIDEBAR_STATE_FILE",m=W(k(),"opencode-anthropic-auth"),y=W(m,"sidebar-state.json");function R(){return process.env[F]||y}var C={main:{quota:null},fallbacks:[],activeId:void 0,route:"main",relay:null,fastMode:!1,lastUpdated:0};function N(J){return J!==null&&typeof J==="object"&&!Array.isArray(J)}function q(J){if(!N(J))return;let $=Number(J.usedPercent),V=Number(J.remainingPercent);if(!Number.isFinite($)||!Number.isFinite(V))return;return{usedPercent:$,remainingPercent:V,resetsAt:typeof J.resetsAt==="string"?J.resetsAt:void 0}}function I(J){if(!N(J))return null;let $={},V=q(J.five_hour),x=q(J.seven_day);if(V)$.five_hour=V;if(x)$.seven_day=x;if(Array.isArray(J.scoped)){let G=J.scoped.map((X)=>{if(!N(X))return;let Z=q(X);if(!Z)return;if(typeof X.id!=="string"||!X.id.trim())return;if(typeof X.title!=="string"||!X.title.trim())return;if(typeof X.modelName!=="string"||!X.modelName.trim())return;let j=typeof X.modelId==="string"&&X.modelId.trim()?X.modelId.trim():void 0;return{...Z,id:X.id.trim(),title:X.title.trim(),...j&&{modelId:j},modelName:X.modelName.trim()}}).filter((X)=>X!=null);$.scoped=G}if(N(J.extraUsage)){let G=L(J.extraUsage.used),X=L(J.extraUsage.limit);if(G&&X&&typeof J.extraUsage.exhausted==="boolean")$.extraUsage={used:G,limit:X,...typeof J.extraUsage.utilizationPercent==="number"&&Number.isFinite(J.extraUsage.utilizationPercent)&&{utilizationPercent:J.extraUsage.utilizationPercent},...typeof J.extraUsage.severity==="string"&&{severity:J.extraUsage.severity},exhausted:J.extraUsage.exhausted}}if(typeof J.bindingWindow==="string"&&J.bindingWindow.trim())$.bindingWindow=J.bindingWindow.trim();if(typeof J.fallbackAdvised==="boolean")$.fallbackAdvised=J.fallbackAdvised;return Object.keys($).length?$:null}function L(J){if(!N(J))return;if(!Number.isInteger(J.amountMinor)||typeof J.currency!=="string"||!/^[A-Za-z]{3}$/.test(J.currency.trim())||!Number.isInteger(J.exponent)||J.exponent<0||J.exponent>20)return;return{amountMinor:J.amountMinor,currency:J.currency.trim(),exponent:J.exponent}}function w(J){if(!N(J))return{...C};let $={quota:null};if(N(J.main)){let Z=J.main;if($.quota=I(Z.quota),typeof Z.tierLabel==="string"&&Z.tierLabel.trim())$.tierLabel=Z.tierLabel.trim();if(typeof Z.quotaBackedOff==="boolean")$.quotaBackedOff=Z.quotaBackedOff;if(typeof Z.quotaBackoffUntil==="number")$.quotaBackoffUntil=Z.quotaBackoffUntil;if(typeof Z.refreshBackedOff==="boolean")$.refreshBackedOff=Z.refreshBackedOff;if(typeof Z.refreshBackoffUntil==="number")$.refreshBackoffUntil=Z.refreshBackoffUntil}let V=Array.isArray(J.fallbacks)?J.fallbacks.filter(N).filter((Z)=>typeof Z.id==="string").map((Z)=>({id:Z.id,label:typeof Z.label==="string"?Z.label:void 0,quota:I(Z.quota),enabled:typeof Z.enabled==="boolean"?Z.enabled:!1,needsReauth:typeof Z.needsReauth==="boolean"?Z.needsReauth:!1,tierLabel:typeof Z.tierLabel==="string"&&Z.tierLabel.trim()?Z.tierLabel.trim():void 0})):[],x=null;if(N(J.relay)){let Z=J.relay;if(typeof Z.enabled==="boolean"&&typeof Z.transport==="string")x={enabled:Z.enabled,transport:Z.transport}}let G;if(N(J.cacheKeep)){let Z=J.cacheKeep;if(typeof Z.enabled==="boolean")G={enabled:Z.enabled,window:typeof Z.window==="string"?Z.window:void 0,trackedSessions:typeof Z.trackedSessions==="number"?Z.trackedSessions:void 0}}let X=Array.isArray(J.fableRecoveries)?J.fableRecoveries.filter(N).flatMap((Z)=>{if(typeof Z.sessionId!=="string"||Z.mode!=="opus"&&Z.mode!=="fable"||typeof Z.remaining!=="number"||!Number.isFinite(Z.remaining)||typeof Z.changedAt!=="number"||!Number.isFinite(Z.changedAt))return[];return[{sessionId:Z.sessionId,mode:Z.mode,remaining:Math.max(0,Math.floor(Z.remaining)),changedAt:Z.changedAt}]}):[];return{main:$,fallbacks:V,activeId:typeof J.activeId==="string"?J.activeId:void 0,route:typeof J.route==="string"?J.route:C.route,relay:x,fastMode:typeof J.fastMode==="boolean"?J.fastMode:C.fastMode,cacheKeep:G,fableRecoveries:X.length>0?X:void 0,lastUpdated:typeof J.lastUpdated==="number"?J.lastUpdated:0}}var h=Promise.resolve(),v=1000,d=2000,c=5,u=15,z=null;function $J(J){z=J}var _=null;function VJ(J){_=J}function XJ(){return _}function l(J){return new Promise(($)=>setTimeout($,J))}async function A(J){let $=`${J}.lock`,V=z?.lockBudgetMs??v,x=z?.lockRetryMinMs??c,G=z?.lockRetryMaxMs??u,X=Date.now()+V;while(!0){try{await P($);let Y=f(),K=W($,Y);return await E(K,"",{encoding:"utf8",mode:384,flag:"wx"}),await z?.onLockAcquired?.($),{ownsLock:async()=>{try{return await U(K),!0}catch{return!1}},release:async()=>{try{await p(K)}catch{return}await z?.beforeReleaseDirectoryRemoval?.($),await T($).catch(()=>{})}}}catch(Y){if(Y.code!=="EEXIST")return Q.trace("sidebar","state lock unavailable; write skipped",{stateFile:J,error:Y instanceof Error?Y.message:String(Y)}),null}try{let Y=await U($);if(Date.now()-Y.mtimeMs>d){await z?.afterStaleLockStat?.($);let K=`${$}.evict-${process.pid}-${f()}`;try{await b($,K)}catch(B){if(B.code==="ENOENT")continue;throw B}await z?.onStaleLockClaimed?.($),await O(K,{recursive:!0,force:!0}).catch(()=>{});continue}}catch(Y){if(Y.code==="ENOENT")continue;return Q.trace("sidebar","state lock inspection failed; write skipped",{stateFile:J,error:Y instanceof Error?Y.message:String(Y)}),null}let Z=X-Date.now();if(Z<=0)return Q.warn("sidebar","lock budget exhausted, write skipped",{stateFile:J,budgetMs:V}),null;let j=x+Math.floor(Math.random()*(G-x+1));await l(Math.min(j,Z))}}async function xJ(J){return(await A(J))?.release??null}async function n(J,$,V){let x=`${J}.${process.pid}.${f()}.tmp`;await E(x,JSON.stringify($),{encoding:"utf8",mode:384});try{if(!await V())return Q.trace("sidebar","state lock lost before rename; write aborted",{stateFile:J}),await O(x,{force:!0}).catch(()=>{}),"lock-lost-before-rename";if(await z?.beforeRename?.(J,x),!await V())return Q.trace("sidebar","state lock lost before rename; write aborted",{stateFile:J}),await O(x,{force:!0}).catch(()=>{}),"lock-lost-before-rename";if(await b(x,J),await z?.afterRename?.(J),!await V())return"lock-lost-after-rename";return"written"}catch(G){throw await O(x,{force:!0}).catch(()=>{}),G}}async function M(J=R()){try{let $=await D(J,"utf8");return w(JSON.parse($))}catch{return C}}async function YJ(J,$=R(),V={}){return h=h.then(async()=>{await P(S($),{recursive:!0});for(let x=0;x<2;x++){let G=x===1,X=await A($);if(!X){if(G)Q.warn("sidebar","post-rename repair lock unavailable; write skipped",{stateFile:$});return}let Z=J,j;try{if(V.routingAuthoritative===!1){let Y=await M($),K=await V.resolvePreservedRouting?.(Y);if(K){let B=K.state??J;Z={...B,activeId:K.activeId,route:K.route,lastUpdated:Math.max(B.lastUpdated,Y.lastUpdated)}}await z?.afterMergeRead?.($)}else if(G){let Y=await M($);Z={...Y,activeId:J.activeId,route:J.route,relay:J.relay,fastMode:J.fastMode,cacheKeep:J.cacheKeep,lastUpdated:Math.max(Y.lastUpdated,J.lastUpdated)}}j=await n($,Z,X.ownsLock)}finally{await X.release()}if(j==="lock-lost-after-rename"){if(G){Q.warn("sidebar","post-rename repair lost lock; write skipped",{stateFile:$});return}Q.warn("sidebar","state lock lost after rename; repairing write",{stateFile:$});continue}if(j==="lock-lost-before-rename")return;V.onRoutingResolved?.({activeId:Z.activeId,route:Z.route});return}}).catch(()=>{}),h}async function GJ(){return h}function jJ(J){let $=J.activeId;if($&&$!=="main"){let V=J.fallbacks?.find((x)=>x.enabled&&x.id===$);if(V)return{id:V.id,name:V.label??V.id,quota:V.quota}}return{id:"main",name:"main",quota:J.main?.quota??null}}function i(J){let $=J.replace(/\s+only$/i,"").trim();return/^fable$/i.test($)?"Fa":$}function KJ(J,$){let V=J.fableRecoveries?.find((x)=>x.sessionId===$);if(!V)return;if(V.mode==="fable")return"Fable 5 · restored";return`Opus 4.8 · ${V.remaining} left`}function zJ(J){let $=J?.five_hour?.usedPercent??null,V=J?.seven_day?.usedPercent??null,x=J?.scoped??[],G=x.map((j)=>j.usedPercent);if($==null&&V==null&&x.length===0)return{fiveHourUsedPercent:$,sevenDayUsedPercent:V,scopedUsedPercents:G,text:null};let X=x.map((j)=>`${i(j.title)}: ${Math.round(j.usedPercent)}%`),Z=$==null&&V==null?[]:[`5h: ${$==null?"—":`${Math.round($)}%`}`,`7d: ${V==null?"—":`${Math.round(V)}%`}`];return{fiveHourUsedPercent:$,sevenDayUsedPercent:V,scopedUsedPercents:G,text:[...Z,...X].join(" ")}}var NJ=18000000,QJ=604800000,s=300000,o=0.01,a=1;function BJ(J,$,V){if(!J.resetsAt)return null;let x=new Date(J.resetsAt).getTime();if(!Number.isFinite(x))return null;let G=x-$,X=V-G;if(X<s)return null;if(X<$*o)return null;if(X>=$)return null;let Z=J.usedPercent,j=Math.min(Math.max(X/$*100,0),100),Y=Z-j,K=Math.abs(Y)<a?"on-pace":Y>0?"deficit":"reserve",B=null;if(Z>0){let g=X*100/Z,H=G+g;if(H<x)B=new Date(H).toISOString()}return{pacePercent:j,deltaPercent:Y,state:K,runsOutAt:B}}
|
|
2
|
+
export{R as a,C as b,w as c,$J as d,VJ as e,XJ as f,xJ as g,M as h,YJ as i,GJ as j,jJ as k,i as l,KJ as m,zJ as n,NJ as o,QJ as p,BJ as q};
|