@cortexkit/opencode-anthropic-auth 2.16.3 → 2.16.5

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.
@@ -1,2 +1,2 @@
1
1
  var t=["claude-account","claude-cache","claude-cachekeep","claude-prime","claude-start","claude-quota","claude-dump","claude-fast","claude-routing","claude-killswitch","claude-logging"];
2
- export{t as v};
2
+ export{t as w};
@@ -1,2 +1,2 @@
1
1
  import{existsSync as Z,readFileSync as $}from"node:fs";import{dirname as W,join as B,resolve as X}from"node:path";import{fileURLToPath as Y}from"node:url";import{getHostDataHome as F,getHostHome as V}from"@cortexkit/anthropic-auth-core";var b="@cortexkit/opencode-anthropic-auth",x="@cortexkit/pi-anthropic-auth";function G(q=process.env,J=process.platform){let z=q.OPENCODE_CONFIG_DIR?.trim();if(z)return X(z);return B(q.XDG_CONFIG_HOME||B(V(q,J),".config"),"opencode")}function I(q=process.env){return B(F(q),"opencode")}function K(q=process.env){return B(I(q),"auth.json")}function M(q=process.env,J=process.platform){let z=q.PI_CODING_AGENT_DIR?.trim()||q.PI_AGENT_DIR?.trim();if(z)return X(z);return B(V(q,J),".pi","agent")}function R(q=process.env){let J=q.PI_CODING_AGENT_DIR,z=V(q),w=J||B(z,".pi","agent");if(w==="~")w=z;else if(w.startsWith("~/")||process.platform==="win32"&&w.startsWith("~\\"))w=B(z,w.slice(2));if(w.startsWith("file://"))w=Y(w);return B(w,"auth.json")}async function y(){let q=W(Y(import.meta.url));for(let J=0;J<5;J++){let z=B(q,"package.json");if(Z(z))try{let Q=JSON.parse($(z,"utf8"));if(typeof Q.version==="string"&&Q.version.trim())return Q.version.trim()}catch{}let w=W(q);if(w===q)break;q=w}return"1.22.0"}
2
- export{b as F,x as G,G as H,K as I,M as J,R as K,y as L};
2
+ export{b as G,x as H,G as I,K as J,M as K,R as L,y as M};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{u as a}from"./index-9d7k6v9w.js";import"./index-6q2f3m0v.js";import"./index-ct4m3d80.js";import"./index-yrce651f.js";import"./index-bhd1rmy4.js";import"./index-txrrjz4d.js";import"./index-39xzvbey.js";export{a as AnthropicAuthPlugin};
1
+ import{v as a}from"./index-r5psch9p.js";import"./index-sby24dy7.js";import"./index-mrbp5svf.js";import"./index-xvwrzpd4.js";import"./index-1x1mncm7.js";import"./index-aptr1edk.js";import"./index-3fd62zrt.js";export{a as AnthropicAuthPlugin};
@@ -1 +1 @@
1
- import{la as a,ma as b}from"../index-txrrjz4d.js";import"../index-39xzvbey.js";export{a as writePortFile,b as discoverPortFile};
1
+ import{ma as a,na as b}from"../index-aptr1edk.js";import"../index-3fd62zrt.js";export{a as writePortFile,b as discoverPortFile};
@@ -1 +1 @@
1
- import{v as a}from"../index-6q2f3m0v.js";import"../index-39xzvbey.js";export{a as COMMAND_MODAL_NAMES};
1
+ import{w as a}from"../index-sby24dy7.js";import"../index-3fd62zrt.js";export{a as COMMAND_MODAL_NAMES};
@@ -1 +1 @@
1
- import{ma as s}from"../index-txrrjz4d.js";import"../index-39xzvbey.js";async function i(e,o,t,n){let r=await s(e,n);if(!r)return null;let a=new AbortController,l=setTimeout(()=>a.abort(),2000);try{let p=await fetch(`http://127.0.0.1:${r.port}/rpc/${o}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${r.token}`},body:JSON.stringify(t),signal:a.signal});if(!p.ok)return null;return await p.json()}catch{return null}finally{clearTimeout(l)}}function c(e,o){return{async pending(t,n){return(await i(e,"pending-notifications",{lastReceivedId:t,sessionId:n},o))?.messages??[]},async apply(t){return await i(e,"apply",{...t},o)??{text:"apply failed",knobs:{}}},async applyMenu(t){if(t.command!=="claude"||!t.sessionId?.trim())throw TypeError("A claude menu sessionId is required");let n=await i(e,"apply-menu",{...t},o);if(!n)throw Error("Menu apply unavailable; outcome unknown");return n}}}export{c as createRpcClient};
1
+ import{na as s}from"../index-aptr1edk.js";import"../index-3fd62zrt.js";async function i(e,o,t,n){let r=await s(e,n);if(!r)return null;let a=new AbortController,l=setTimeout(()=>a.abort(),2000);try{let p=await fetch(`http://127.0.0.1:${r.port}/rpc/${o}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${r.token}`},body:JSON.stringify(t),signal:a.signal});if(!p.ok)return null;return await p.json()}catch{return null}finally{clearTimeout(l)}}function c(e,o){return{async pending(t,n){return(await i(e,"pending-notifications",{lastReceivedId:t,sessionId:n},o))?.messages??[]},async apply(t){return await i(e,"apply",{...t},o)??{text:"apply failed",knobs:{}}},async applyMenu(t){if(t.command!=="claude"||!t.sessionId?.trim())throw TypeError("A claude menu sessionId is required");let n=await i(e,"apply-menu",{...t},o);if(!n)throw Error("Menu apply unavailable; outcome unknown");return n}}}export{c as createRpcClient};
@@ -1 +1 @@
1
- import{w as a,x as b,y as c}from"../index-ct4m3d80.js";import"../index-39xzvbey.js";export{a as tmpdir,c as getRpcRoot,b as getRpcDir};
1
+ import{x as a,y as b,z as c}from"../index-mrbp5svf.js";import"../index-3fd62zrt.js";export{a as tmpdir,c as getRpcRoot,b as getRpcDir};
@@ -3,6 +3,17 @@ export declare const SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-07-0
3
3
  export declare const SERVER_FALLBACK_MARKER_TEXT = "\u2060";
4
4
  export declare const SERVER_FALLBACK_SIGNATURE_PREFIX = "cortexkit-server-fallback-v1:";
5
5
  export { SERVER_FALLBACK_USAGE_MARKER_TEXT, SERVER_FALLBACK_USAGE_SIGNATURE_PREFIX, };
6
+ type ServerSideFallbackIteration = {
7
+ model: string;
8
+ input_tokens: number;
9
+ output_tokens: number;
10
+ cache_read_input_tokens?: number;
11
+ cache_creation_input_tokens?: number;
12
+ cache_creation?: {
13
+ ephemeral_5m_input_tokens?: number;
14
+ ephemeral_1h_input_tokens?: number;
15
+ };
16
+ };
6
17
  export type ContentFilterFallbackMode = 'server' | 'legacy';
7
18
  export type ServerSideFallbackOutcome = {
8
19
  requestedModel: string;
@@ -11,7 +22,9 @@ export type ServerSideFallbackOutcome = {
11
22
  fallback: boolean;
12
23
  handoff: boolean;
13
24
  stopReason: string;
25
+ iterations: ServerSideFallbackIteration[];
14
26
  };
27
+ export declare function logServedServerFallback(session: string | null, outcome: ServerSideFallbackOutcome): void;
15
28
  export declare function resolveContentFilterFallbackMode(value: string | undefined): ContentFilterFallbackMode;
16
29
  export declare function applyServerSideFallbackToBody(body: Record<string, unknown>, requested: boolean): {
17
30
  enabled: boolean;
@@ -1 +1 @@
1
- import{$ as p,M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h,U as i,V as j,W as k,X as l,Y as m,Z as n,_ as o,aa as q,ba as r,ca as s,da as t,ea as u,fa as v,ga as w,ha as x,ia as y,ja as z,ka as A}from"./index-bhd1rmy4.js";import"./index-39xzvbey.js";export{i as setSidebarState,r as scopedQuotaShortNames,k as resolveActiveAccount,s as quotaLabelColumnWidth,c as normalizeSidebarState,a as getSidebarStateFile,h as getSidebarState,f as getInitialSidebarRoutingTestHooks,p as getFableRecoverySummary,w as getCollapsedQuotaSummary,x as getCollapsedAccounts,q as formatQuotaRowLabel,m as formatPrimeTime,n as formatPrimeCost,o as formatPrimeAccountValue,l as formatFallbackModelLabel,u as fitQuotaRow,v as fitPaceLine,j as drainSidebarWrites,A as computeQuotaPacing,d as __setSidebarStateWriteTestHooks,e as __setInitialSidebarRoutingTestHooks,g as __acquireSidebarStateLockForTest,z as SEVEN_DAY_MS,t as QUOTA_BAR_MIN_CELLS,y as FIVE_HOUR_MS,b as DEFAULT_SIDEBAR_STATE};
1
+ import{$ as o,N as a,O as b,P as c,Q as d,R as e,S as f,T as g,U as h,V as i,W as j,X as k,Y as l,Z as m,_ as n,aa as p,ba as q,ca as r,da as s,ea as t,fa as u,ga as v,ha as w,ia as x,ja as y,ka as z,la as A}from"./index-1x1mncm7.js";import"./index-3fd62zrt.js";export{i as setSidebarState,r as scopedQuotaShortNames,k as resolveActiveAccount,s as quotaLabelColumnWidth,c as normalizeSidebarState,a as getSidebarStateFile,h as getSidebarState,f as getInitialSidebarRoutingTestHooks,p as getFableRecoverySummary,w as getCollapsedQuotaSummary,x as getCollapsedAccounts,q as formatQuotaRowLabel,m as formatPrimeTime,n as formatPrimeCost,o as formatPrimeAccountValue,l as formatFallbackModelLabel,u as fitQuotaRow,v as fitPaceLine,j as drainSidebarWrites,A as computeQuotaPacing,d as __setSidebarStateWriteTestHooks,e as __setInitialSidebarRoutingTestHooks,g as __acquireSidebarStateLockForTest,z as SEVEN_DAY_MS,t as QUOTA_BAR_MIN_CELLS,y as FIVE_HOUR_MS,b as DEFAULT_SIDEBAR_STATE};
@@ -1,4 +1,4 @@
1
- import"./index-39xzvbey.js";import{readFileSync as S,statSync as b,watch as F}from"node:fs";import{mkdir as g,readFile as I,rename as T,writeFile as y}from"node:fs/promises";import{homedir as h}from"node:os";import{basename as v,dirname as _,join as N}from"node:path";import{clearTimeout as D,setTimeout as P}from"node:timers";import{applyEdits as f,modify as m,parse as p}from"jsonc-parser";var c="OPENCODE_TUI_PREFERENCES_FILE",u="tui-preferences.jsonc";function K(){let Q=process.env[c];if(Q)return Q;let q=process.env.OPENCODE_CONFIG_DIR||N(process.env.XDG_CONFIG_HOME||N(h(),".config"),"opencode");return N(q,u)}function H(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}async function Zq(){try{let Q=await I(K(),"utf8"),q=[],J=p(Q,q,{allowTrailingComma:!0});if(q.length>0)return{};return H(J)?J:{}}catch{return{}}}var s="anthropic-auth",d=160,k={forceToTop:!1,order:d,startCollapsed:!1,rememberCollapsed:!0,collapsed:null,pollMs:1500,refreshDebounceMs:200,header:{label:"CLAUDE",showVersion:!0},sections:{quota:!0,fallbackAccounts:!0,routing:!0,cache:!0,health:!0,pacing:!0},appearance:{barWidth:10,barFilledChar:"█",barEmptyChar:"░",warnThreshold:50,errorThreshold:80}};function z(Q,q){return typeof Q==="boolean"?Q:q}function B(Q,q,J,Z){if(typeof Q!=="number"||!Number.isFinite(Q))return q;return Math.min(Math.max(Math.round(Q),J),Z)}function o(Q,q,J){if(typeof Q!=="string"||Q.length===0)return q;return Q.slice(0,J)}function x(Q,q){if(typeof Q!=="string")return q;return[...Q][0]??q}function $q(Q){let q=Q[s];if(!H(q))return structuredClone(k);let J=k,Z=H(q.header)?q.header:{},X=H(q.sections)?q.sections:{},$=H(q.appearance)?q.appearance:{},Y=B($.warnThreshold,J.appearance.warnThreshold,0,99),G=Math.max(B($.errorThreshold,J.appearance.errorThreshold,0,100),Math.min(Y+1,100));return{forceToTop:z(q.forceToTop,J.forceToTop),order:B(q.order,J.order,-1e4,1e4),startCollapsed:z(q.startCollapsed,J.startCollapsed),rememberCollapsed:z(q.rememberCollapsed,J.rememberCollapsed),collapsed:typeof q.collapsed==="boolean"?q.collapsed:null,pollMs:B(q.pollMs,J.pollMs,500,30000),refreshDebounceMs:B(q.refreshDebounceMs,J.refreshDebounceMs,50,5000),header:{label:o(Z.label,J.header.label,20),showVersion:z(Z.showVersion,J.header.showVersion)},sections:{quota:z(X.quota,J.sections.quota),fallbackAccounts:z(X.fallbackAccounts,J.sections.fallbackAccounts),routing:z(X.routing,J.sections.routing),cache:z(X.cache,J.sections.cache),health:z(X.health,J.sections.health),pacing:z(X.pacing,J.sections.pacing)},appearance:{barWidth:B($.barWidth,J.appearance.barWidth,4,40),barFilledChar:x($.barFilledChar,J.appearance.barFilledChar),barEmptyChar:x($.barEmptyChar,J.appearance.barEmptyChar),warnThreshold:Y,errorThreshold:G}}}var n=-1e5;function zq(Q,q,J){let Z=Q[q];if(!H(Z))return J;if(Z.forceToTop===!0)return n+Object.keys(Q).indexOf(q);return B(Z.order,J,-1e4,1e4)}var i=`// Shared preferences for opencode TUI plugins.
1
+ import"./index-3fd62zrt.js";import{readFileSync as S,statSync as b,watch as F}from"node:fs";import{mkdir as g,readFile as I,rename as T,writeFile as y}from"node:fs/promises";import{homedir as h}from"node:os";import{basename as v,dirname as _,join as N}from"node:path";import{clearTimeout as D,setTimeout as P}from"node:timers";import{applyEdits as f,modify as m,parse as p}from"jsonc-parser";var c="OPENCODE_TUI_PREFERENCES_FILE",u="tui-preferences.jsonc";function K(){let Q=process.env[c];if(Q)return Q;let q=process.env.OPENCODE_CONFIG_DIR||N(process.env.XDG_CONFIG_HOME||N(h(),".config"),"opencode");return N(q,u)}function H(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}async function Zq(){try{let Q=await I(K(),"utf8"),q=[],J=p(Q,q,{allowTrailingComma:!0});if(q.length>0)return{};return H(J)?J:{}}catch{return{}}}var s="anthropic-auth",d=160,k={forceToTop:!1,order:d,startCollapsed:!1,rememberCollapsed:!0,collapsed:null,pollMs:1500,refreshDebounceMs:200,header:{label:"CLAUDE",showVersion:!0},sections:{quota:!0,fallbackAccounts:!0,routing:!0,cache:!0,health:!0,pacing:!0},appearance:{barWidth:10,barFilledChar:"█",barEmptyChar:"░",warnThreshold:50,errorThreshold:80}};function z(Q,q){return typeof Q==="boolean"?Q:q}function B(Q,q,J,Z){if(typeof Q!=="number"||!Number.isFinite(Q))return q;return Math.min(Math.max(Math.round(Q),J),Z)}function o(Q,q,J){if(typeof Q!=="string"||Q.length===0)return q;return Q.slice(0,J)}function x(Q,q){if(typeof Q!=="string")return q;return[...Q][0]??q}function $q(Q){let q=Q[s];if(!H(q))return structuredClone(k);let J=k,Z=H(q.header)?q.header:{},X=H(q.sections)?q.sections:{},$=H(q.appearance)?q.appearance:{},Y=B($.warnThreshold,J.appearance.warnThreshold,0,99),G=Math.max(B($.errorThreshold,J.appearance.errorThreshold,0,100),Math.min(Y+1,100));return{forceToTop:z(q.forceToTop,J.forceToTop),order:B(q.order,J.order,-1e4,1e4),startCollapsed:z(q.startCollapsed,J.startCollapsed),rememberCollapsed:z(q.rememberCollapsed,J.rememberCollapsed),collapsed:typeof q.collapsed==="boolean"?q.collapsed:null,pollMs:B(q.pollMs,J.pollMs,500,30000),refreshDebounceMs:B(q.refreshDebounceMs,J.refreshDebounceMs,50,5000),header:{label:o(Z.label,J.header.label,20),showVersion:z(Z.showVersion,J.header.showVersion)},sections:{quota:z(X.quota,J.sections.quota),fallbackAccounts:z(X.fallbackAccounts,J.sections.fallbackAccounts),routing:z(X.routing,J.sections.routing),cache:z(X.cache,J.sections.cache),health:z(X.health,J.sections.health),pacing:z(X.pacing,J.sections.pacing)},appearance:{barWidth:B($.barWidth,J.appearance.barWidth,4,40),barFilledChar:x($.barFilledChar,J.appearance.barFilledChar),barEmptyChar:x($.barEmptyChar,J.appearance.barEmptyChar),warnThreshold:Y,errorThreshold:G}}}var n=-1e5;function zq(Q,q,J){let Z=Q[q];if(!H(Z))return J;if(Z.forceToTop===!0)return n+Object.keys(Q).indexOf(q);return B(Z.order,J,-1e4,1e4)}var i=`// Shared preferences for opencode TUI plugins.
2
2
  // One top-level key per plugin (short name). See each plugin's README for
3
3
  // its supported settings. This file is safe to hand-edit; plugins update
4
4
  // individual keys in place and preserve comments.