@cortexkit/anthropic-auth-core 2.11.1 → 2.11.3
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/accounts.d.ts +30 -16
- package/dist/cachekeep.d.ts +8 -5
- package/dist/index.d.ts +17 -1
- package/dist/index.js +6468 -1969
- package/dist/internal-types/claustrum/custody.d.ts +4 -0
- package/dist/internal-types/claustrum/index.d.ts +1 -1
- package/dist/internal-types/routing-accessor/index.d.ts +34 -9
- package/dist/internal-types/settings/define.d.ts +35 -0
- package/dist/internal-types/settings/descriptors.d.ts +97 -0
- package/dist/internal-types/settings/edit.d.ts +24 -0
- package/dist/internal-types/settings/handle.d.ts +30 -0
- package/dist/internal-types/settings/index.d.ts +10 -0
- package/dist/internal-types/settings/move.d.ts +76 -0
- package/dist/internal-types/settings/parse.d.ts +24 -0
- package/dist/internal-types/settings/paths.d.ts +12 -0
- package/dist/internal-types/settings/refusal.d.ts +7 -0
- package/dist/internal-types/settings/resolve.d.ts +15 -0
- package/dist/internal-types/settings/schema.d.ts +29 -0
- package/dist/internal-types/settings/snapshot.d.ts +24 -0
- package/dist/message-threads.d.ts +29 -2
- package/dist/native-account-runtime.d.ts +22 -8
- package/dist/native-runtime-settings.d.ts +41 -0
- package/dist/native-settings-write.d.ts +19 -0
- package/dist/path-options.d.ts +16 -0
- package/dist/pool-paths.d.ts +2 -1
- package/dist/routing-relay.d.ts +6 -1
- package/dist/routing-wait.d.ts +14 -0
- package/dist/routing.d.ts +2 -2
- package/dist/settings-definition.d.ts +621 -0
- package/dist/settings-mode.d.ts +22 -0
- package/dist/settings-move-fence.d.ts +44 -0
- package/dist/settings-move-map.d.ts +7 -0
- package/dist/settings-move-run.d.ts +29 -0
- package/dist/settings-move-source.d.ts +50 -0
- package/dist/settings-move-sources.d.ts +35 -0
- package/dist/settings-paths.d.ts +30 -0
- package/dist/settings-protection-copy.d.ts +12 -0
- package/dist/settings-protection-legacy.d.ts +22 -0
- package/dist/settings-record.d.ts +8 -0
- package/dist/settings-service.d.ts +99 -0
- package/dist/settings-three-way.d.ts +5 -0
- package/dist/sticky-routing.d.ts +14 -0
- package/package.json +3 -2
- package/schema/anthropic-auth.schema.json +1081 -0
package/dist/accounts.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ProviderAccountUuid } from './claude-code.ts';
|
|
2
2
|
import { type Cache1hMode } from './constants.ts';
|
|
3
3
|
import type { LogLevel } from './logger.ts';
|
|
4
|
+
import { type PathResolutionOptions } from './path-options.ts';
|
|
5
|
+
import { type ThreeWayBoolean } from './settings-three-way.ts';
|
|
4
6
|
export type { ProviderAccountUuid } from './claude-code.ts';
|
|
5
7
|
export declare const ACCOUNT_FILE_NAME = "anthropic-auth.json";
|
|
6
8
|
export declare const ACCOUNT_STATE_FILE_NAME = "anthropic-auth-state.json";
|
|
@@ -194,11 +196,11 @@ export type AccountStorage = {
|
|
|
194
196
|
mainRefreshLeaseTokenHash?: string;
|
|
195
197
|
};
|
|
196
198
|
quota?: {
|
|
197
|
-
enabled?:
|
|
199
|
+
enabled?: ThreeWayBoolean;
|
|
198
200
|
checkIntervalMinutes?: number;
|
|
199
201
|
refreshEveryNRequests?: number;
|
|
200
|
-
minimumRemaining?: Partial<Record<QuotaWindowName | '5h' | '1w', number>>;
|
|
201
|
-
failClosedOnUnknownQuota?:
|
|
202
|
+
minimumRemaining?: Partial<Record<QuotaWindowName | 'scoped' | '5h' | '1w', number>>;
|
|
203
|
+
failClosedOnUnknownQuota?: ThreeWayBoolean;
|
|
202
204
|
/** Opt-in OpenCode TUI toast after quota refresh. Default: false. */
|
|
203
205
|
showToasts?: boolean;
|
|
204
206
|
mainQuota?: OAuthQuotaSnapshot;
|
|
@@ -212,7 +214,7 @@ export type AccountStorage = {
|
|
|
212
214
|
enabled?: boolean;
|
|
213
215
|
};
|
|
214
216
|
claudeCache?: {
|
|
215
|
-
enabled?:
|
|
217
|
+
enabled?: ThreeWayBoolean;
|
|
216
218
|
mode?: Cache1hMode;
|
|
217
219
|
};
|
|
218
220
|
dump?: {
|
|
@@ -274,6 +276,16 @@ export type AccountStorage = {
|
|
|
274
276
|
killswitch?: KillswitchConfig;
|
|
275
277
|
accounts: FallbackAccount[];
|
|
276
278
|
};
|
|
279
|
+
/** Shared input for readers of legacy booleans and user-file default/on/off values. */
|
|
280
|
+
export type AccountSettingsReaderInput = Omit<AccountStorage, 'quota' | 'claudeCache'> & {
|
|
281
|
+
quota?: Omit<NonNullable<AccountStorage['quota']>, 'enabled' | 'failClosedOnUnknownQuota'> & {
|
|
282
|
+
enabled?: ThreeWayBoolean;
|
|
283
|
+
failClosedOnUnknownQuota?: ThreeWayBoolean;
|
|
284
|
+
};
|
|
285
|
+
claudeCache?: Omit<NonNullable<AccountStorage['claudeCache']>, 'enabled'> & {
|
|
286
|
+
enabled?: ThreeWayBoolean;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
277
289
|
/**
|
|
278
290
|
* Whether Anthropic OAuth model costs should be zeroed in the provider hook.
|
|
279
291
|
* Defaults to enabled; only an explicit `costZeroing.enabled === false` opts out
|
|
@@ -313,9 +325,9 @@ export type AccountStateSaveScope = {
|
|
|
313
325
|
};
|
|
314
326
|
export declare const FALLBACK_BACKGROUND_TICK_MS = 60000;
|
|
315
327
|
/** OpenCode's config folder, as OpenCode itself resolves it. */
|
|
316
|
-
export declare function getOpenCodeConfigDir(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
317
|
-
export declare function getAccountStoragePath(): string;
|
|
318
|
-
export declare function getAccountStatePath(configPath?: string): string;
|
|
328
|
+
export declare function getOpenCodeConfigDir(env?: NodeJS.ProcessEnv, home?: string, options?: Pick<PathResolutionOptions, 'platform' | 'realpath'>): string;
|
|
329
|
+
export declare function getAccountStoragePath(options?: PathResolutionOptions): string;
|
|
330
|
+
export declare function getAccountStatePath(configPath?: string | undefined, options?: PathResolutionOptions): string;
|
|
319
331
|
export declare function createEmptyStorage(): AccountStorage;
|
|
320
332
|
export declare function mergeMainQuotaErrorClearedAt(existing: number | undefined, incoming: number | undefined): number | undefined;
|
|
321
333
|
export declare function mergeMainRefreshErrorClearedAt(existing: number | undefined, incoming: number | undefined): number | undefined;
|
|
@@ -335,17 +347,18 @@ export declare function acquireRefreshFileLock(options: {
|
|
|
335
347
|
release: () => Promise<void>;
|
|
336
348
|
assertOwned: () => Promise<void>;
|
|
337
349
|
} | null>;
|
|
338
|
-
export declare function isCache1hPersistentlyEnabled(storage:
|
|
350
|
+
export declare function isCache1hPersistentlyEnabled(storage: AccountSettingsReaderInput | null): boolean;
|
|
339
351
|
export declare function getCache1hPersistentMode(storage: AccountStorage | null): Cache1hMode;
|
|
340
352
|
export declare function isDumpPersistentlyEnabled(storage: AccountStorage | null): boolean;
|
|
341
353
|
export declare function isFastModePersistentlyEnabled(storage: AccountStorage | null): boolean;
|
|
342
354
|
export declare function isCacheKeepSubagentsEnabled(storage: AccountStorage | null): boolean;
|
|
343
355
|
export declare function isPrimePersistentlyEnabled(storage: AccountStorage | null): boolean;
|
|
344
356
|
export declare function shouldFallbackStatus(status: number, storage: AccountStorage | null): boolean;
|
|
345
|
-
export declare function getQuotaMinimumRemainingThresholds(storage:
|
|
357
|
+
export declare function getQuotaMinimumRemainingThresholds(storage: AccountSettingsReaderInput | null): {
|
|
346
358
|
five_hour: number;
|
|
347
359
|
seven_day: number;
|
|
348
360
|
};
|
|
361
|
+
export declare function quotaEnabled(storage: AccountSettingsReaderInput | null): boolean;
|
|
349
362
|
export declare function getRefreshBeforeExpiryMs(storage: AccountStorage | null): number;
|
|
350
363
|
export declare function getRefreshIntervalMs(storage: AccountStorage | null): number;
|
|
351
364
|
export declare function hashRefreshToken(refreshToken: string): string;
|
|
@@ -384,7 +397,7 @@ export declare function buildQuotaOperationError(input: {
|
|
|
384
397
|
}): AccountOperationError;
|
|
385
398
|
export declare function quotaBackoffActive(error: AccountOperationError | undefined, now: number): boolean;
|
|
386
399
|
export declare function formatQuotaBackoffMessage(error: AccountOperationError, now: number): string;
|
|
387
|
-
export declare function getQuotaCheckIntervalMs(storage:
|
|
400
|
+
export declare function getQuotaCheckIntervalMs(storage: AccountSettingsReaderInput | null): number;
|
|
388
401
|
export declare function getPersistedLogLevel(storage: AccountStorage | null): LogLevel | undefined;
|
|
389
402
|
export declare function getPersistedMainQuota(storage: AccountStorage | null): {
|
|
390
403
|
quota: OAuthQuotaSnapshot;
|
|
@@ -397,10 +410,11 @@ export declare function getPersistedMainQuota(storage: AccountStorage | null): {
|
|
|
397
410
|
* Returns 0 when disabled (default).
|
|
398
411
|
*/
|
|
399
412
|
export declare function getQuotaRefreshEveryNRequests(storage: AccountStorage | null): number;
|
|
413
|
+
export declare function failClosedOnUnknownQuota(storage: AccountSettingsReaderInput | null): boolean;
|
|
400
414
|
export declare function getScopedQuotaWindowForModel(quota: OAuthQuotaSnapshot | undefined, model: unknown): AccountScopedQuotaWindow | undefined;
|
|
401
415
|
export declare function quotaSnapshotModelScopeIsExhausted(quota: OAuthQuotaSnapshot | undefined, model: unknown): boolean;
|
|
402
416
|
export declare function quotaSnapshotPassesModelScope(quota: OAuthQuotaSnapshot | undefined, model: unknown): boolean;
|
|
403
|
-
export declare function quotaSnapshotPassesPolicy(quota: OAuthQuotaSnapshot | undefined, storage:
|
|
417
|
+
export declare function quotaSnapshotPassesPolicy(quota: OAuthQuotaSnapshot | undefined, storage: AccountSettingsReaderInput | null): boolean;
|
|
404
418
|
/** A poll's omitted session window is evidence, unlike a partial header harvest. */
|
|
405
419
|
export declare function quotaSnapshotOmitsFiveHour(quota: OAuthQuotaSnapshot | undefined): quota is OAuthQuotaSnapshot & {
|
|
406
420
|
checkedAt: number;
|
|
@@ -410,8 +424,8 @@ export declare function quotaSnapshotOmitsFiveHour(quota: OAuthQuotaSnapshot | u
|
|
|
410
424
|
export declare function quotaSnapshotHasStandardWindows(quota: OAuthQuotaSnapshot | undefined): quota is OAuthQuotaSnapshot;
|
|
411
425
|
export declare const DEFAULT_KILLSWITCH_THRESHOLDS: Record<QuotaWindowName | 'scoped', number>;
|
|
412
426
|
export declare function normalizeKillswitchThresholds(thresholds: KillswitchThresholds | undefined): Record<QuotaWindowName | 'scoped', number>;
|
|
413
|
-
export declare function isKillswitchEnabled(storage:
|
|
414
|
-
export declare function getKillswitchThresholdsForAccount(storage:
|
|
427
|
+
export declare function isKillswitchEnabled(storage: AccountSettingsReaderInput | null): boolean;
|
|
428
|
+
export declare function getKillswitchThresholdsForAccount(storage: AccountSettingsReaderInput | null, accountId?: string): Record<QuotaWindowName | 'scoped', number>;
|
|
415
429
|
/**
|
|
416
430
|
* Returns true if the account's quota is above its killswitch threshold.
|
|
417
431
|
* When killswitch is disabled, always returns true.
|
|
@@ -420,7 +434,7 @@ export declare function getKillswitchThresholdsForAccount(storage: AccountStorag
|
|
|
420
434
|
* evaluated against the quota window matching that model — additive to the
|
|
421
435
|
* 5h/7d check. A model with no matching scoped window is unaffected.
|
|
422
436
|
*/
|
|
423
|
-
export declare function killswitchPassesPolicy(quota: OAuthQuotaSnapshot | undefined, storage:
|
|
437
|
+
export declare function killswitchPassesPolicy(quota: OAuthQuotaSnapshot | undefined, storage: AccountSettingsReaderInput | null, accountId?: string, modelId?: string): boolean;
|
|
424
438
|
export type QuotaResetEvidence = {
|
|
425
439
|
quota?: OAuthQuotaSnapshot;
|
|
426
440
|
accountIdentity?: string;
|
|
@@ -429,7 +443,7 @@ export type QuotaResetEvidence = {
|
|
|
429
443
|
/** Only current, identity-bound readings can justify waiting for a stored reset. */
|
|
430
444
|
export declare function quotaRefusalTiming(input: {
|
|
431
445
|
readings: readonly QuotaResetEvidence[];
|
|
432
|
-
storage?:
|
|
446
|
+
storage?: AccountSettingsReaderInput | null;
|
|
433
447
|
scopedModelId?: string;
|
|
434
448
|
modelId?: string;
|
|
435
449
|
sessionTtlMs?: number;
|
|
@@ -446,7 +460,7 @@ export declare function killswitchRetryAfterSeconds(mainQuota: OAuthQuotaSnapsho
|
|
|
446
460
|
sessionTtlMs?: number;
|
|
447
461
|
}): number;
|
|
448
462
|
export declare function getKillswitchConfig(storage: AccountStorage | null): KillswitchConfig;
|
|
449
|
-
export declare function getQuotaNextRefreshAt(quota: OAuthQuotaSnapshot | undefined, storage:
|
|
463
|
+
export declare function getQuotaNextRefreshAt(quota: OAuthQuotaSnapshot | undefined, storage: AccountSettingsReaderInput | null, now: number): number;
|
|
450
464
|
export declare function fetchOAuthQuotaSnapshot(input: {
|
|
451
465
|
accessToken: string;
|
|
452
466
|
fetchImpl?: typeof fetch;
|
package/dist/cachekeep.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CacheWarmStopReason } from "./internal-types/routing-accessor/index.js";
|
|
2
|
-
import type { AccountStorage } from './accounts.ts';
|
|
2
|
+
import type { AccountSettingsReaderInput, AccountStorage } from './accounts.ts';
|
|
3
3
|
import { type AnthropicBillingRequest, type AnthropicBillingWarming } from './billing.ts';
|
|
4
4
|
import { type CacheKeepFailure } from './cachekeep-failure.ts';
|
|
5
5
|
import type { CacheKeepStopReason, CacheKeepTrackedSession } from './cachekeep-registry.ts';
|
|
@@ -49,10 +49,10 @@ export type CacheKeepStatus = {
|
|
|
49
49
|
hybridActive?: boolean;
|
|
50
50
|
};
|
|
51
51
|
export declare function parseCacheKeepCommandAction(input: string): CacheKeepCommandAction;
|
|
52
|
-
export declare function getCacheKeepWindow(storage:
|
|
53
|
-
export declare function isCacheKeepAlways(storage:
|
|
54
|
-
export declare function isCacheKeepPersistentlyEnabled(storage:
|
|
55
|
-
export declare function isCacheKeepHybridActive(storage:
|
|
52
|
+
export declare function getCacheKeepWindow(storage: AccountSettingsReaderInput | null): CacheKeepWindow | undefined;
|
|
53
|
+
export declare function isCacheKeepAlways(storage: AccountSettingsReaderInput | null): boolean;
|
|
54
|
+
export declare function isCacheKeepPersistentlyEnabled(storage: AccountSettingsReaderInput | null): boolean;
|
|
55
|
+
export declare function isCacheKeepHybridActive(storage: AccountSettingsReaderInput | null): boolean;
|
|
56
56
|
export declare function isWithinCacheKeepWindow(window: CacheKeepWindow | undefined, now?: Date): boolean;
|
|
57
57
|
export declare function isCacheKeepActiveNow(storage: AccountStorage | null, now?: Date): boolean;
|
|
58
58
|
export declare function localDayKey(now?: Date): string;
|
|
@@ -196,6 +196,8 @@ export declare class CacheKeepManager {
|
|
|
196
196
|
private readonly admittedWarmCosts;
|
|
197
197
|
constructor(options: {
|
|
198
198
|
loadStorage: () => Promise<AccountStorage | null>;
|
|
199
|
+
/** Memory-only settings projection; omitted by hosts that still use legacy settings. */
|
|
200
|
+
resolveSettings?: (storage: AccountStorage, model?: string) => AccountStorage;
|
|
199
201
|
fetchImpl?: typeof fetch;
|
|
200
202
|
billingRequest?: (target: CacheKeepTarget, attempt: CacheKeepPrewarmAttempt) => AnthropicBillingRequest | undefined;
|
|
201
203
|
now?: () => number;
|
|
@@ -367,6 +369,7 @@ export declare class CacheKeepManager {
|
|
|
367
369
|
}): Promise<CacheKeepPrewarmResult>;
|
|
368
370
|
tick(): Promise<void>;
|
|
369
371
|
private runTick;
|
|
372
|
+
private targetSettings;
|
|
370
373
|
private lastPrewarmStart;
|
|
371
374
|
private scheduleRetry;
|
|
372
375
|
private sendPrewarm;
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export { CLAUDE_CODE_DEFAULT_BETAS, CLAUDE_MODEL_CAPABILITIES, getClaudeModelCap
|
|
|
33
33
|
export * from './model-remap.ts';
|
|
34
34
|
export * from './models.ts';
|
|
35
35
|
export * from './native-account-refusal.ts';
|
|
36
|
-
export type { NativeAccountPolicy, NativeAccountRuntime, NativeAccountRuntimeOptions, NativeAccountWriteInput, NativeApiSubject, NativeLocalAuthorizeOptions, NativeQuotaPolicyLimit, NativeRelayUpdate, } from './native-account-runtime.ts';
|
|
36
|
+
export type { NativeAccountPolicy, NativeAccountRuntime, NativeAccountRuntimeOptions, NativeAccountWriteInput, NativeApiSubject, NativeLocalAuthorizeOptions, NativeQuotaPolicyLimit, NativeRelayUpdate, NativeSettingsWriteResult, } from './native-account-runtime.ts';
|
|
37
37
|
export { acquireNativeAccountRuntime, createNativeAccountRuntime, nativeAccountPolicy, } from './native-account-runtime.ts';
|
|
38
38
|
export type { NativeAccountMetadataPatch, NativeAccountSnapshot, NativeAccountView, } from './native-account-view.ts';
|
|
39
39
|
export { formatNativeAccountState, nativeAccountCanServe, } from './native-account-view.ts';
|
|
@@ -63,6 +63,7 @@ export type { NativeCommittedMaterial, NativeIdentityBootstrap, NativeRefreshCon
|
|
|
63
63
|
export type { NativeLocalFailureAttribution, NativeLocalFailurePolicy, NativeLocalFailureSkipReason, } from './native-runtime.ts';
|
|
64
64
|
export { NativeRuntimeError } from './native-runtime.ts';
|
|
65
65
|
export { nativeRuntimeOptionIdentity } from './native-runtime-registry.ts';
|
|
66
|
+
export * from './native-runtime-settings.ts';
|
|
66
67
|
export * from './native-settings.ts';
|
|
67
68
|
export { isNativeTransientAccountError, NativeTransientAccountError, } from './native-transient-account.ts';
|
|
68
69
|
export type { CommandApplyRequest, CommandApplyResult, CommandDialogPayload, CommandInvocation, CommandMenu, CommandMenuModel, KnobValue, KnobValues, MenuAction, MenuItem, MenuKnob, MenuSection, NativeCommandApplyResult, NativeUiOptions, NotifyKind, SectionSlot, } from './native-ui.ts';
|
|
@@ -78,6 +79,7 @@ export { acquireNativeVaultRuntime, createNativeVaultRuntime, discoverNativeVaul
|
|
|
78
79
|
export * from './oauth-origin.ts';
|
|
79
80
|
export * from './oauth-profile.ts';
|
|
80
81
|
export { createWindowsOwnerOnly, ensureWindowsOwnerOnlyDirectory, isOwnerOnly, type OwnerOnlyOptions, readWindowsOwnerOnly, } from './owner-only.ts';
|
|
82
|
+
export * from './path-options.ts';
|
|
81
83
|
export * from './pkce.ts';
|
|
82
84
|
export type { NativeEmptyInitJournal, NativeLegacyMigrationJournal, NativeMigrationJournal, } from './pool-authority.ts';
|
|
83
85
|
export { nativeJournalMayAdoptLaterHostLogin, nativeMigrationAuthorityPhase, readNativeMigrationJournal, } from './pool-authority.ts';
|
|
@@ -104,9 +106,23 @@ export * from './routing.ts';
|
|
|
104
106
|
export * from './routing-peek.ts';
|
|
105
107
|
export * from './routing-relay.ts';
|
|
106
108
|
export * from './routing-reports.ts';
|
|
109
|
+
export { startRoutingWait } from './routing-wait.ts';
|
|
107
110
|
export * from './server-fallback-usage.ts';
|
|
108
111
|
export * from './session-cache-activity.ts';
|
|
109
112
|
export * from './session-cache-policy.ts';
|
|
113
|
+
export * from './settings-definition.ts';
|
|
114
|
+
export * from './settings-mode.ts';
|
|
115
|
+
export * from './settings-move-fence.ts';
|
|
116
|
+
export * from './settings-move-map.ts';
|
|
117
|
+
export * from './settings-move-run.ts';
|
|
118
|
+
export * from './settings-move-source.ts';
|
|
119
|
+
export * from './settings-move-sources.ts';
|
|
120
|
+
export * from './settings-paths.ts';
|
|
121
|
+
export * from './settings-protection-copy.ts';
|
|
122
|
+
export * from './settings-protection-legacy.ts';
|
|
123
|
+
export * from './settings-record.ts';
|
|
124
|
+
export * from './settings-service.ts';
|
|
125
|
+
export * from './settings-three-way.ts';
|
|
110
126
|
export type { SseEvent, SseFramer, SseFramerOptions } from './sse.ts';
|
|
111
127
|
export { createSseFramer, DEFAULT_SSE_MAX_FRAME_BYTES, decodeSseFrame, isSseCandidateFrame, isTerminatedSseFrame, parseSseFrame, SseFrameTooLargeError, } from './sse.ts';
|
|
112
128
|
export * from './start.ts';
|