@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.
Files changed (44) hide show
  1. package/dist/accounts.d.ts +30 -16
  2. package/dist/cachekeep.d.ts +8 -5
  3. package/dist/index.d.ts +17 -1
  4. package/dist/index.js +6468 -1969
  5. package/dist/internal-types/claustrum/custody.d.ts +4 -0
  6. package/dist/internal-types/claustrum/index.d.ts +1 -1
  7. package/dist/internal-types/routing-accessor/index.d.ts +34 -9
  8. package/dist/internal-types/settings/define.d.ts +35 -0
  9. package/dist/internal-types/settings/descriptors.d.ts +97 -0
  10. package/dist/internal-types/settings/edit.d.ts +24 -0
  11. package/dist/internal-types/settings/handle.d.ts +30 -0
  12. package/dist/internal-types/settings/index.d.ts +10 -0
  13. package/dist/internal-types/settings/move.d.ts +76 -0
  14. package/dist/internal-types/settings/parse.d.ts +24 -0
  15. package/dist/internal-types/settings/paths.d.ts +12 -0
  16. package/dist/internal-types/settings/refusal.d.ts +7 -0
  17. package/dist/internal-types/settings/resolve.d.ts +15 -0
  18. package/dist/internal-types/settings/schema.d.ts +29 -0
  19. package/dist/internal-types/settings/snapshot.d.ts +24 -0
  20. package/dist/message-threads.d.ts +29 -2
  21. package/dist/native-account-runtime.d.ts +22 -8
  22. package/dist/native-runtime-settings.d.ts +41 -0
  23. package/dist/native-settings-write.d.ts +19 -0
  24. package/dist/path-options.d.ts +16 -0
  25. package/dist/pool-paths.d.ts +2 -1
  26. package/dist/routing-relay.d.ts +6 -1
  27. package/dist/routing-wait.d.ts +14 -0
  28. package/dist/routing.d.ts +2 -2
  29. package/dist/settings-definition.d.ts +621 -0
  30. package/dist/settings-mode.d.ts +22 -0
  31. package/dist/settings-move-fence.d.ts +44 -0
  32. package/dist/settings-move-map.d.ts +7 -0
  33. package/dist/settings-move-run.d.ts +29 -0
  34. package/dist/settings-move-source.d.ts +50 -0
  35. package/dist/settings-move-sources.d.ts +35 -0
  36. package/dist/settings-paths.d.ts +30 -0
  37. package/dist/settings-protection-copy.d.ts +12 -0
  38. package/dist/settings-protection-legacy.d.ts +22 -0
  39. package/dist/settings-record.d.ts +8 -0
  40. package/dist/settings-service.d.ts +99 -0
  41. package/dist/settings-three-way.d.ts +5 -0
  42. package/dist/sticky-routing.d.ts +14 -0
  43. package/package.json +3 -2
  44. package/schema/anthropic-auth.schema.json +1081 -0
@@ -0,0 +1,41 @@
1
+ import type { SettingsEdit } from "./internal-types/settings/index.js";
2
+ import type { AccountStorage } from './accounts.ts';
3
+ import { type SettingsKey } from './settings-definition.ts';
4
+ import { type SettingsMode } from './settings-mode.ts';
5
+ import type { SettingsHost } from './settings-paths.ts';
6
+ import type { SettingsFileStatus, SettingsService, SettingsValues } from './settings-service.ts';
7
+ export interface NativeRuntimeSettingsOptions {
8
+ settingsService?: SettingsService;
9
+ /** Return the cached settings mode; this callback must not read the filesystem. */
10
+ settingsMode?: () => SettingsMode;
11
+ }
12
+ export interface NativeRuntimeSettingsStatus {
13
+ file: SettingsFileStatus;
14
+ values: SettingsValues;
15
+ modelOverrides: Partial<Record<SettingsKey, {
16
+ model: string;
17
+ value: SettingsValues[SettingsKey];
18
+ }[]>>;
19
+ }
20
+ /**
21
+ * Project policy settings from memory, retaining a service reference until close.
22
+ * The host releases its own reference and checks off the request path whether
23
+ * the user file exists or a marker records a completed settings migration, then
24
+ * updates the cached legacy/user-file mode.
25
+ */
26
+ export declare function createNativeRuntimeSettings(options: NativeRuntimeSettingsOptions & {
27
+ host: SettingsHost;
28
+ env?: NodeJS.ProcessEnv;
29
+ }): {
30
+ resolve: {
31
+ (stored: AccountStorage, model?: string): AccountStorage;
32
+ (stored: Record<string, unknown>, model?: string): Record<string, unknown>;
33
+ };
34
+ status: () => NativeRuntimeSettingsStatus | undefined;
35
+ applyEffects: () => void;
36
+ file: () => string | undefined;
37
+ /** Recheck authority on the menu path before choosing a write target. */
38
+ prepareWrite(): Promise<SettingsService | undefined>;
39
+ update(edits: readonly SettingsEdit[], before: Record<string, unknown>): Promise<void>;
40
+ close: () => Promise<void> | undefined;
41
+ };
@@ -0,0 +1,19 @@
1
+ import type { SettingsEdit } from "./internal-types/settings/index.js";
2
+ import type { SettingsHost } from './settings-paths.ts';
3
+ import { type SettingsGeneration } from './settings-service.ts';
4
+ type Settings = Record<string, unknown>;
5
+ interface StoreChange {
6
+ path: string[];
7
+ value: unknown;
8
+ }
9
+ /** Plan the whole menu transaction before either the file or the legacy store changes. */
10
+ export declare function planNativeSettingsWrite(before: Settings, after: Settings, generation: SettingsGeneration, host: SettingsHost): {
11
+ edits: SettingsEdit[];
12
+ storeChanges: StoreChange[];
13
+ refusal: string | undefined;
14
+ };
15
+ /** Apply only store-held deltas to a fresh legacy record, never the resolved settings projection. */
16
+ export declare function applyNativeStoreSettingsChanges(stored: Settings, changes: readonly StoreChange[]): Settings;
17
+ /** Old releases only understand booleans in these legacy fields. */
18
+ export declare function legacyNativeSettings(settings: Settings): Settings;
19
+ export {};
@@ -0,0 +1,16 @@
1
+ import { realpath } from 'node:fs/promises';
2
+ import { posix } from 'node:path';
3
+ /** Pass one process's inputs through every settings path decision. */
4
+ export interface PathResolutionOptions {
5
+ env?: Readonly<Record<string, string | undefined>>;
6
+ home?: string;
7
+ platform?: NodeJS.Platform;
8
+ realpath?: (path: string) => Promise<string>;
9
+ }
10
+ export declare function resolvePathOptions(options?: PathResolutionOptions): {
11
+ env: Readonly<Record<string, string | undefined>>;
12
+ home: string;
13
+ platform: NodeJS.Platform;
14
+ realpath: ((path: string) => Promise<string>) | typeof realpath;
15
+ paths: typeof posix;
16
+ };
@@ -1,3 +1,4 @@
1
+ import { type PathResolutionOptions } from './path-options.ts';
1
2
  import { type StateLayout } from './state-layout-paths.ts';
2
3
  export interface NativePoolPaths {
3
4
  legacyConfig: string;
@@ -22,7 +23,7 @@ export declare function resolveLocalRoutingDestination(host: 'opencode' | 'pi',
22
23
  * This can follow a leaf symlink, so it does not establish configured-leaf safety.
23
24
  * Source capture and recheck must retain the configured path for the lstat guard.
24
25
  */
25
- export declare function canonicalPath(path: string): Promise<string>;
26
+ export declare function canonicalPath(path: string, options?: PathResolutionOptions): Promise<string>;
26
27
  /**
27
28
  * Separate runtime authority from import inputs so a stale legacy writer cannot
28
29
  * rewrite a stamped credential. Both independently configured paths matter.
@@ -16,6 +16,11 @@ type RoutingSubject = {
16
16
  };
17
17
  /** Routing owns quota reserves, including unknown readings and the minimum remaining quota set by the killswitch. Offer only subscription credentials the host may use. */
18
18
  export declare function routingCandidates(accounts: readonly NativeAccountView[]): NativeAccountView[];
19
+ /** Hint only the still-servable vault credential behind the session's own pin. */
20
+ export declare function routingWarmCredential(accounts: readonly NativeAccountView[], assignment: {
21
+ accountId: string;
22
+ accountIdentity?: string;
23
+ } | undefined): string | undefined;
19
24
  export declare function routingChoiceMatches(choice: RoutingChoice, account: RoutingSubject): boolean;
20
25
  /** Fixed text avoids exposing router internals and is not a host auto-retry signal. */
21
26
  export declare class RoutingRefusalError extends Error {
@@ -30,7 +35,7 @@ export declare function createRoutingRelay(quotaFor?: (subject: RoutingSubject)
30
35
  shouldReport(sessionId: string): boolean;
31
36
  admitted(sessionId: string, subject: RoutingSubject): boolean;
32
37
  policy(sessionId: string, account: NativeAccountView, snapshot: NativeAccountSnapshot, modelId?: string): import("./native-account-runtime.ts").NativeAccountPolicy;
33
- accountFor(sessionId: string, modelId: string, candidates: readonly RoutingSubject[]): Promise<RoutingChoice | null>;
38
+ accountFor(sessionId: string, modelId: string, candidates: readonly RoutingSubject[], warmCredentialId?: string): Promise<RoutingChoice | null>;
34
39
  report(sessionId: string, subject: RoutingSubject, headers: Headers, status: number, modelId?: string, served?: boolean): void;
35
40
  };
36
41
  export {};
@@ -0,0 +1,14 @@
1
+ import { type PluginWaitReason } from "./internal-types/routing-accessor/index.js";
2
+ type WaitReason = Extract<PluginWaitReason, 'account_limit' | 'account_free' | 'rate_limited' | 'routing_hold'>;
3
+ type WaitOutcome = 'resumed' | 'cancelled' | 'abandoned';
4
+ /** Report a real delay without calling reportRouting on the request path.
5
+ * Call the returned callback when the wait ends. When the app owns the delay,
6
+ * the plugin cannot observe completion and reports only its start. */
7
+ export declare function startRoutingWait(input: {
8
+ sessionId?: string;
9
+ reason: WaitReason;
10
+ delayMs: number;
11
+ nextMs?: number;
12
+ attempt?: number;
13
+ }): ((outcome: WaitOutcome) => void) | undefined;
14
+ export {};
package/dist/routing.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import type { AccountStorage, RoutingMode } from './accounts.ts';
1
+ import type { AccountSettingsReaderInput, AccountStorage, RoutingMode } from './accounts.ts';
2
2
  export declare const CLAUDE_ROUTING_COMMAND_NAME = "claude-routing";
3
3
  export declare const ROUTING_MODES: readonly ['main-first', 'fallback-first', 'sticky-balanced'];
4
4
  export declare const DEFAULT_ROUTING_MODE: RoutingMode;
5
5
  export declare const MAX_SAME_ACCOUNT_WAITS: readonly ['0', '15', 'max'];
6
6
  export type MaxSameAccountWait = (typeof MAX_SAME_ACCOUNT_WAITS)[number];
7
7
  export declare const DEFAULT_MAX_SAME_ACCOUNT_WAIT: MaxSameAccountWait;
8
- export declare function getMaxSameAccountWait(storage: AccountStorage | null): MaxSameAccountWait;
8
+ export declare function getMaxSameAccountWait(storage: AccountSettingsReaderInput | null): MaxSameAccountWait;
9
9
  type RoutingCommandAction = {
10
10
  type: 'status';
11
11
  } | {