@cortexkit/opencode-anthropic-auth 1.10.2 → 1.11.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.d.ts +41 -0
- package/dist/cli.js +6 -6
- package/dist/index-7f07xr7k.js +2 -0
- package/dist/{index-p8j7mmfc.js → index-7hq52c3b.js} +1 -1
- package/dist/index-c1phnbjn.js +417 -0
- package/dist/index-srn1rawx.js +2 -0
- package/dist/index-vhcx8tx6.js +1 -0
- package/dist/index-zfddfgk2.js +4 -0
- package/dist/index.js +11 -10
- package/dist/logger-q4dnhr8x.js +1 -0
- package/dist/rpc/port-file.d.ts +1 -1
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +2 -1
- package/dist/rpc/rpc-client.d.ts +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state.d.ts +4 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/tui/command-dialogs.d.ts +1 -0
- package/dist/tui-preferences.js +2 -2
- package/package.json +4 -4
- package/src/rpc/port-file.ts +7 -1
- package/src/rpc/protocol.ts +3 -0
- package/src/rpc/rpc-client.ts +10 -3
- package/src/rpc/rpc-dir.ts +2 -2
- package/src/rpc/rpc-server.ts +5 -3
- package/src/sidebar-state.ts +99 -11
- package/src/tui/command-dialogs.tsx +478 -1
- package/src/tui-preferences.ts +57 -18
- package/src/tui.tsx +25 -14
- package/dist/index-3ynbghx3.js +0 -1
- package/dist/index-9yjbmhf1.js +0 -2
- package/dist/index-fvzta6xw.js +0 -410
- package/dist/index-jb14nj5c.js +0 -2
package/src/tui.tsx
CHANGED
|
@@ -304,10 +304,13 @@ function AccountBlock(props: {
|
|
|
304
304
|
quota: AccountQuota | null
|
|
305
305
|
active: boolean
|
|
306
306
|
pacingEnabled: boolean
|
|
307
|
+
needsReauth?: boolean
|
|
307
308
|
marginTop?: number
|
|
308
309
|
}) {
|
|
309
|
-
const statusWord = () =>
|
|
310
|
-
|
|
310
|
+
const statusWord = () =>
|
|
311
|
+
props.needsReauth ? 're-login' : props.active ? 'active' : 'idle'
|
|
312
|
+
const statusTone = (): Tone =>
|
|
313
|
+
props.needsReauth ? 'err' : props.active ? 'ok' : 'muted'
|
|
311
314
|
const pacingFor = (
|
|
312
315
|
window:
|
|
313
316
|
| { usedPercent: number; remainingPercent: number; resetsAt?: string }
|
|
@@ -374,7 +377,8 @@ function QuotaDialogContent(props: {
|
|
|
374
377
|
})
|
|
375
378
|
setTimeout(refresh, 0)
|
|
376
379
|
const theme = () => props.api.theme.current
|
|
377
|
-
const enabledFallbacks = () =>
|
|
380
|
+
const enabledFallbacks = () =>
|
|
381
|
+
(state().fallbacks ?? []).filter((f) => f.enabled)
|
|
378
382
|
return (
|
|
379
383
|
<box flexDirection='column' padding={2} width='100%' alignItems='center'>
|
|
380
384
|
<box flexDirection='column' width={58}>
|
|
@@ -387,7 +391,7 @@ function QuotaDialogContent(props: {
|
|
|
387
391
|
theme={theme()}
|
|
388
392
|
appearance={prefs().appearance}
|
|
389
393
|
name='main'
|
|
390
|
-
quota={state().main
|
|
394
|
+
quota={state().main?.quota}
|
|
391
395
|
active={state().activeId === 'main'}
|
|
392
396
|
pacingEnabled={prefs().sections.pacing}
|
|
393
397
|
/>
|
|
@@ -401,6 +405,7 @@ function QuotaDialogContent(props: {
|
|
|
401
405
|
quota={fb.quota}
|
|
402
406
|
active={state().activeId === fb.id}
|
|
403
407
|
pacingEnabled={prefs().sections.pacing}
|
|
408
|
+
needsReauth={fb.needsReauth}
|
|
404
409
|
marginTop={1}
|
|
405
410
|
/>
|
|
406
411
|
)}
|
|
@@ -526,9 +531,10 @@ function QuotaSidebar(props: {
|
|
|
526
531
|
})
|
|
527
532
|
|
|
528
533
|
const theme = () => props.api.theme.current
|
|
529
|
-
const enabledFallbacks = () =>
|
|
534
|
+
const enabledFallbacks = () =>
|
|
535
|
+
(state().fallbacks ?? []).filter((f) => f.enabled)
|
|
530
536
|
const hasData = () =>
|
|
531
|
-
state().main
|
|
537
|
+
state().main?.quota != null || enabledFallbacks().length > 0
|
|
532
538
|
|
|
533
539
|
const headerLabel = () => {
|
|
534
540
|
const name = prefs().header.label
|
|
@@ -568,9 +574,10 @@ function QuotaSidebar(props: {
|
|
|
568
574
|
return base === 'ok' || base === 'muted' ? 'warn' : base
|
|
569
575
|
}
|
|
570
576
|
|
|
571
|
-
const quotaBackedOff = () => state().main
|
|
572
|
-
const refreshBackedOff = () => state().main
|
|
573
|
-
const
|
|
577
|
+
const quotaBackedOff = () => state().main?.quotaBackedOff === true
|
|
578
|
+
const refreshBackedOff = () => state().main?.refreshBackedOff === true
|
|
579
|
+
const needsReauth = () => enabledFallbacks().some((f) => f.needsReauth)
|
|
580
|
+
const degraded = () => quotaBackedOff() || refreshBackedOff() || needsReauth()
|
|
574
581
|
|
|
575
582
|
const cacheKeep = () => state().cacheKeep
|
|
576
583
|
const showCache = () =>
|
|
@@ -667,7 +674,7 @@ function QuotaSidebar(props: {
|
|
|
667
674
|
theme={theme()}
|
|
668
675
|
appearance={prefs().appearance}
|
|
669
676
|
name='main'
|
|
670
|
-
quota={state().main
|
|
677
|
+
quota={state().main?.quota}
|
|
671
678
|
active={state().activeId === 'main'}
|
|
672
679
|
pacingEnabled={prefs().sections.pacing}
|
|
673
680
|
/>
|
|
@@ -681,6 +688,7 @@ function QuotaSidebar(props: {
|
|
|
681
688
|
quota={fb.quota}
|
|
682
689
|
active={state().activeId === fb.id}
|
|
683
690
|
pacingEnabled={prefs().sections.pacing}
|
|
691
|
+
needsReauth={fb.needsReauth}
|
|
684
692
|
marginTop={1}
|
|
685
693
|
/>
|
|
686
694
|
)}
|
|
@@ -738,7 +746,7 @@ function QuotaSidebar(props: {
|
|
|
738
746
|
<StatRow
|
|
739
747
|
theme={theme()}
|
|
740
748
|
label='Quota API'
|
|
741
|
-
value={`backoff ${formatUntil(state().main
|
|
749
|
+
value={`backoff ${formatUntil(state().main?.quotaBackoffUntil)}`}
|
|
742
750
|
tone='warn'
|
|
743
751
|
/>
|
|
744
752
|
</Show>
|
|
@@ -746,7 +754,7 @@ function QuotaSidebar(props: {
|
|
|
746
754
|
<StatRow
|
|
747
755
|
theme={theme()}
|
|
748
756
|
label='Token refresh'
|
|
749
|
-
value={`backoff ${formatUntil(state().main
|
|
757
|
+
value={`backoff ${formatUntil(state().main?.refreshBackoffUntil)}`}
|
|
750
758
|
tone='warn'
|
|
751
759
|
/>
|
|
752
760
|
</Show>
|
|
@@ -770,7 +778,10 @@ const tui: TuiPlugin = async (api) => {
|
|
|
770
778
|
|
|
771
779
|
if (!rpcPollStarted) {
|
|
772
780
|
rpcPollStarted = true
|
|
773
|
-
const rpcClient = createRpcClient(
|
|
781
|
+
const rpcClient = createRpcClient(
|
|
782
|
+
getRpcDir(api.state.path.directory ?? ''),
|
|
783
|
+
process.pid,
|
|
784
|
+
)
|
|
774
785
|
let lastNotificationId = 0
|
|
775
786
|
let rpcInFlight = false
|
|
776
787
|
setInterval(() => {
|
|
@@ -795,7 +806,7 @@ const tui: TuiPlugin = async (api) => {
|
|
|
795
806
|
continue
|
|
796
807
|
}
|
|
797
808
|
openCommandDialog(api, message.payload, (command, args) =>
|
|
798
|
-
rpcClient.apply({ command, arguments: args }),
|
|
809
|
+
rpcClient.apply({ command, arguments: args, sessionId }),
|
|
799
810
|
)
|
|
800
811
|
}
|
|
801
812
|
})
|
package/dist/index-3ynbghx3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createHash as z}from"node:crypto";import{homedir as F,tmpdir as L}from"node:os";import{join as k}from"node:path";var G="OPENCODE_ANTHROPIC_AUTH_RPC_DIR";function Q(q){let g=process.env[G]?.trim();if(g)return g;let w=z("sha256").update(q).digest("hex").slice(0,16),x=process.env.XDG_STATE_HOME||k(F(),".local","state");return k(x,"cortexkit","anthropic-auth","rpc",w)}export{L as fb,Q as gb};
|
package/dist/index-9yjbmhf1.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{mkdir as R,readFile as g,writeFile as q}from"node:fs/promises";import{tmpdir as C}from"node:os";import{dirname as y,join as V}from"node:path";var H="OPENCODE_ANTHROPIC_AUTH_SIDEBAR_STATE_FILE",k=V(C(),"opencode-anthropic-auth"),O=V(k,"sidebar-state.json");function h(){return process.env[H]||O}var b={main:{quota:null},fallbacks:[],activeId:void 0,route:"main",relay:null,fastMode:!1,lastUpdated:0};async function I(){try{let z=await g(h(),"utf8");return JSON.parse(z)}catch{return b}}async function S(z){try{let x=h();await R(y(x),{recursive:!0}),await q(x,JSON.stringify(z),"utf8")}catch{}}function D(z){let x=z.activeId;if(x&&x!=="main"){let J=z.fallbacks.find((K)=>K.enabled&&K.id===x);if(J)return{id:J.id,name:J.label??J.id,quota:J.quota}}return{id:"main",name:"main",quota:z.main.quota}}function F(z){let x=z?.five_hour?.usedPercent??null,J=z?.seven_day?.usedPercent??null;if(x==null&&J==null)return{fiveHourUsedPercent:x,sevenDayUsedPercent:J,text:null};return{fiveHourUsedPercent:x,sevenDayUsedPercent:J,text:`5h: ${x==null?"—":`${Math.round(x)}%`} 7d: ${J==null?"—":`${Math.round(J)}%`}`}}var U=18000000,v=604800000,N=300000,L=0.01,m=1;function T(z,x,J){if(!z.resetsAt)return null;let K=new Date(z.resetsAt).getTime();if(!Number.isFinite(K))return null;let Y=K-x,Q=J-Y;if(Q<N)return null;if(Q<x*L)return null;if(Q>=x)return null;let W=z.usedPercent,Z=Math.min(Math.max(Q/x*100,0),100),X=W-Z,j=Math.abs(X)<m?"on-pace":X>0?"deficit":"reserve",$=null;if(W>0){let G=Q*100/W,B=Y+G;if(B<K)$=new Date(B).toISOString()}return{pacePercent:Z,deltaPercent:X,state:j,runsOutAt:$}}
|
|
2
|
-
export{h as Wa,b as Xa,I as Ya,S as Za,D as _a,F as $a,U as ab,v as bb,T as cb};
|