@cortexkit/anthropic-auth-core 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.
@@ -20,6 +20,7 @@ export type OAuthAccount = AccountBase & {
20
20
  lastRefreshError?: AccountOperationError;
21
21
  lastQuotaRefreshError?: AccountOperationError;
22
22
  quota?: OAuthQuotaSnapshot;
23
+ profile?: OAuthAccountProfile;
23
24
  };
24
25
  export type ApiKeyAccount = AccountBase & {
25
26
  type: 'api';
@@ -66,8 +67,31 @@ export type AccountScopedQuotaWindow = AccountQuotaWindow & {
66
67
  modelId?: string;
67
68
  modelName: string;
68
69
  };
70
+ export type QuotaMoney = {
71
+ amountMinor: number;
72
+ currency: string;
73
+ exponent: number;
74
+ };
75
+ export type OAuthExtraUsageSnapshot = {
76
+ used: QuotaMoney;
77
+ limit: QuotaMoney;
78
+ utilizationPercent?: number;
79
+ severity?: string;
80
+ exhausted: boolean;
81
+ };
82
+ export type OAuthAccountProfile = {
83
+ tier: string;
84
+ orgType: string;
85
+ checkedAt: number;
86
+ tokenFingerprint?: string;
87
+ };
69
88
  export type OAuthQuotaSnapshot = Partial<Record<QuotaWindowName, AccountQuotaWindow>> & {
70
89
  scoped?: AccountScopedQuotaWindow[];
90
+ extraUsage?: OAuthExtraUsageSnapshot;
91
+ bindingWindow?: string;
92
+ bindingWindowSource?: 'poll' | 'headers';
93
+ fallbackAdvised?: boolean;
94
+ source?: 'poll' | 'headers';
71
95
  checkedAt?: number;
72
96
  };
73
97
  export type RoutingMode = 'main-first' | 'fallback-first' | 'sticky-balanced';
@@ -84,6 +108,7 @@ export type AccountStorage = {
84
108
  main?: {
85
109
  type: 'opencode';
86
110
  provider: 'anthropic';
111
+ profile?: OAuthAccountProfile;
87
112
  };
88
113
  routing?: {
89
114
  mode?: RoutingMode;
@@ -155,10 +180,12 @@ export type AccountStorage = {
155
180
  * (to display the provider's real model costs).
156
181
  */
157
182
  export declare function isCostZeroingEnabled(storage: Pick<AccountStorage, 'costZeroing'>): boolean;
158
- export type AccountRuntimeEntry = Partial<Pick<OAuthAccount, 'access' | 'refresh' | 'expires' | 'lastUsed' | 'lastRefreshedAt' | 'lastRefreshError' | 'lastQuotaRefreshError' | 'quota'> & Pick<ApiKeyAccount, 'apiKey' | 'lastUsed'>>;
183
+ export type AccountRuntimeEntry = Partial<Pick<OAuthAccount, 'access' | 'refresh' | 'expires' | 'lastUsed' | 'lastRefreshedAt' | 'lastRefreshError' | 'lastQuotaRefreshError' | 'quota' | 'profile'> & Pick<ApiKeyAccount, 'apiKey' | 'lastUsed'>>;
159
184
  export type AccountRuntimeState = {
160
185
  version: 1;
161
186
  main?: {
187
+ profile?: OAuthAccountProfile;
188
+ profileToken?: string;
162
189
  quota?: OAuthQuotaSnapshot;
163
190
  quotaCheckedAt?: number;
164
191
  quotaToken?: string;
@@ -171,6 +198,7 @@ export type AccountRuntimeState = {
171
198
  accounts?: Record<string, AccountRuntimeEntry>;
172
199
  };
173
200
  export type AccountStateSaveScope = {
201
+ mainProfile?: boolean;
174
202
  mainQuota?: boolean;
175
203
  mainRefresh?: boolean;
176
204
  accounts?: true | string[];
@@ -198,6 +226,11 @@ export interface SaveAccountsOptions {
198
226
  }
199
227
  export declare function saveAccounts(storage: AccountStorage, path?: string, options?: SaveAccountsOptions): Promise<void>;
200
228
  export declare function saveAccountState(storage: AccountStorage, path?: string, scope?: AccountStateSaveScope): Promise<void>;
229
+ export declare function saveOAuthProfileState(input: {
230
+ accountId: 'main' | string;
231
+ profile: OAuthAccountProfile | undefined;
232
+ expectedTokenFingerprint: string;
233
+ }, path?: string): Promise<boolean>;
201
234
  export declare function acquireRefreshFileLock(options: {
202
235
  name: string;
203
236
  ttlMs: number;