@cortexkit/anthropic-auth-core 2.14.0 → 2.15.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/accounts.d.ts +11 -0
- package/dist/cch.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +455 -154
- package/dist/internal-types/setup/enroll.d.ts +2 -1
- package/dist/internal-types/setup/process-fence.d.ts +9 -0
- package/dist/internal-types/setup/process-guard.d.ts +12 -0
- package/dist/internal-types/setup/register.d.ts +2 -1
- package/dist/layout-fence.d.ts +3 -2
- package/dist/native-account-runtime.d.ts +4 -0
- package/dist/native-migration.d.ts +4 -0
- package/dist/native-runtime-settings.d.ts +4 -0
- package/dist/pool-authority.d.ts +3 -1
- package/dist/settings-mode-status.d.ts +25 -0
- package/dist/settings-move-run.d.ts +6 -0
- package/dist/settings-start.d.ts +2 -0
- package/dist/sticky-routing.d.ts +34 -0
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type MenuTerminal } from '../auth-menu/terminal.js';
|
|
2
|
+
import { SetupProcessGuard } from './process-guard.js';
|
|
2
3
|
import type { SetupEnrollmentAccess, SetupHost, SetupIO, SetupPlugin } from './types.js';
|
|
3
4
|
/** Fixed text: no version, host or account detail, so it is safe to print anywhere. */
|
|
4
5
|
export declare const UNSUPPORTED_VAULT_MESSAGE = "This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read \"Upgrading from v0.1.3\" in its release notes first), or run setup without --claustrum to use local accounts.";
|
|
@@ -31,4 +32,4 @@ export declare class HostNotEnrolledError extends Error {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
/** Enroll an independently revocable host; plugin callbacks choose its credential store and account permissions. */
|
|
34
|
-
export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: () => Promise<void>): Promise<SetupEnrollmentAccess | undefined>;
|
|
35
|
+
export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: (() => Promise<void>) | SetupProcessGuard): Promise<SetupEnrollmentAccess | undefined>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CommandRunner, ProcessFence, SetupEnvironment } from './types.js';
|
|
2
2
|
export interface ProcessInspectionStep {
|
|
3
3
|
step: 'tasklist' | 'CIM' | 'ps';
|
|
4
|
+
/** The selected CIM interpreter; absent for tasklist and ps. */
|
|
5
|
+
program?: 'pwsh' | 'powershell';
|
|
4
6
|
exitCode: number | null;
|
|
5
7
|
signal: NodeJS.Signals | null;
|
|
6
8
|
timedOut: boolean;
|
|
@@ -9,6 +11,7 @@ export interface ProcessInspectionStep {
|
|
|
9
11
|
export declare class ProcessInspectionError extends Error implements ProcessInspectionStep {
|
|
10
12
|
readonly code = "process-inspection-failed";
|
|
11
13
|
readonly step: ProcessInspectionStep['step'];
|
|
14
|
+
readonly program?: ProcessInspectionStep['program'];
|
|
12
15
|
readonly exitCode: number | null;
|
|
13
16
|
readonly signal: NodeJS.Signals | null;
|
|
14
17
|
readonly timedOut: boolean;
|
|
@@ -30,6 +33,10 @@ export declare class ProcessFenceViolationError extends Error {
|
|
|
30
33
|
export declare function listSetupProcesses(runner?: CommandRunner, options?: {
|
|
31
34
|
platform?: string;
|
|
32
35
|
env?: SetupEnvironment;
|
|
36
|
+
/** Tests can replace the regular-file check for the fixed pwsh location. */
|
|
37
|
+
isFile?: (file: string) => boolean;
|
|
38
|
+
/** Reports before each slow Windows ARM PowerShell 5.1 check. */
|
|
39
|
+
onProgress?: (line: string) => void;
|
|
33
40
|
onStep?: (details: ProcessInspectionStep) => void;
|
|
34
41
|
/** False skips the Windows PowerShell query for Node and Bun command lines. */
|
|
35
42
|
inspectRuntimes?: boolean;
|
|
@@ -53,5 +60,7 @@ export declare function listSetupProcesses(runner?: CommandRunner, options?: {
|
|
|
53
60
|
export declare function createProcessFence(runner?: CommandRunner, options?: {
|
|
54
61
|
platform?: string;
|
|
55
62
|
selfPid?: number;
|
|
63
|
+
isFile?: (file: string) => boolean;
|
|
64
|
+
onProgress?: (line: string) => void;
|
|
56
65
|
}): ProcessFence;
|
|
57
66
|
export declare function assertHostsStopped(fence: ProcessFence, env?: SetupEnvironment): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Reuse an inspection only while setup has done nothing a running host could observe. */
|
|
2
|
+
export declare class SetupProcessGuard {
|
|
3
|
+
#private;
|
|
4
|
+
private readonly inspect;
|
|
5
|
+
private readonly now;
|
|
6
|
+
constructor(inspect: () => Promise<void>, now?: () => number);
|
|
7
|
+
check(options?: {
|
|
8
|
+
reuse?: boolean;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
/** Callbacks, writes and waits can all make an earlier inspection stale. */
|
|
11
|
+
step<T>(run: () => T | Promise<T>): Promise<T>;
|
|
12
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SetupProcessGuard } from './process-guard.js';
|
|
1
2
|
import type { OpenCodeGeneration, SetupIO, SetupPlugin } from './types.js';
|
|
2
3
|
export interface PlannedWrite {
|
|
3
4
|
path: string;
|
|
@@ -9,5 +10,5 @@ export interface PlannedWrite {
|
|
|
9
10
|
/** Edit only array entries so unrelated JSONC text, including comments, survives. */
|
|
10
11
|
export declare function updatePluginConfig(text: string, key: 'plugin' | 'plugins', pkg: string, version: string): string;
|
|
11
12
|
export declare function planOpenCodeRegistration(plugin: SetupPlugin, generation: OpenCodeGeneration, io?: SetupIO): PlannedWrite[];
|
|
12
|
-
export declare function registerOpenCode(writes: readonly PlannedWrite[], beforeWrite?: () => Promise<void>): Promise<void>;
|
|
13
|
+
export declare function registerOpenCode(writes: readonly PlannedWrite[], beforeWrite?: (() => Promise<void>) | SetupProcessGuard): Promise<void>;
|
|
13
14
|
export declare function registerPi(plugin: SetupPlugin, executable: string, io?: SetupIO): Promise<void>;
|
package/dist/layout-fence.d.ts
CHANGED
|
@@ -57,8 +57,9 @@ export declare function defaultPreNArtifactLocations(env?: NodeJS.ProcessEnv, ho
|
|
|
57
57
|
/**
|
|
58
58
|
* The fence's check for older versions: an RPC port file or CacheKeep record without the
|
|
59
59
|
* `writer` stamp, whose pid is alive, belongs to a version that registers
|
|
60
|
-
* nothing and blocks.
|
|
61
|
-
*
|
|
60
|
+
* nothing and blocks. Unreadable or malformed publisher-owned files need a
|
|
61
|
+
* proven dead filename pid, or a readable regular file's pre-boot mtime.
|
|
62
|
+
* Other scan failures block. A record from before this boot is stale even
|
|
62
63
|
* if its pid has been reused; missing or untrustworthy times keep blocking.
|
|
63
64
|
*/
|
|
64
65
|
export declare function preNArtifactBlockers(locations: PreNArtifactLocations, pidAlive?: (pid: number) => boolean, clock?: Pick<HolderLiveness, 'now' | 'uptime'>,
|
|
@@ -16,6 +16,7 @@ import { type NativePoolPaths } from './pool-paths.ts';
|
|
|
16
16
|
import type { QuotaRequestDispatch } from './quota-manager.ts';
|
|
17
17
|
import { type RelayConfig } from './relay.ts';
|
|
18
18
|
import { type RelocationGuard } from './relocation-guard.ts';
|
|
19
|
+
import type { SettingsMoveDiagnostic } from './settings-mode-status.ts';
|
|
19
20
|
export type { NativeAccountMetadataPatch, NativeAccountSnapshot, NativeAccountView, } from './native-account-view.ts';
|
|
20
21
|
export interface NativeAccountRuntimeOptions extends NativeRuntimeSettingsOptions {
|
|
21
22
|
paths: NativePoolPaths;
|
|
@@ -94,6 +95,9 @@ export interface NativeAccountRuntime {
|
|
|
94
95
|
resolveSettings?(stored: AccountStorage, model?: string): AccountStorage;
|
|
95
96
|
/** No-model settings and every explicit model override, for /claude status. */
|
|
96
97
|
getSettingsStatus?(): NativeRuntimeSettingsStatus | undefined;
|
|
98
|
+
getSettingsModeStatus?(): string;
|
|
99
|
+
/** Update the memory-only startup diagnostic when another host instance joins. */
|
|
100
|
+
setSettingsDiagnostic?(diagnostic: SettingsMoveDiagnostic): void;
|
|
97
101
|
/**
|
|
98
102
|
* The user's gateway for Claude OAuth model requests, from memory. Hosts
|
|
99
103
|
* use it only for model requests, never for sign-in, refresh or usage.
|
|
@@ -39,6 +39,8 @@ export interface NativeMigrationOptions {
|
|
|
39
39
|
routingDestinationPath: string;
|
|
40
40
|
env: NodeJS.ProcessEnv;
|
|
41
41
|
processFence: () => Promise<void>;
|
|
42
|
+
/** Read-only safety checks; defaults to processFence for existing callers. */
|
|
43
|
+
validate?: () => Promise<void>;
|
|
42
44
|
removePiAnthropicAuth: boolean;
|
|
43
45
|
custody?: NativeMigrationCustody;
|
|
44
46
|
preflight?: NativeMigrationPreflight;
|
|
@@ -80,6 +82,8 @@ export interface NativeEmptyInitOptions {
|
|
|
80
82
|
paths: NativePoolPaths;
|
|
81
83
|
routingDestinationPath: string;
|
|
82
84
|
processFence: () => Promise<void>;
|
|
85
|
+
/** Read-only safety checks; defaults to processFence for existing callers. */
|
|
86
|
+
validate?: () => Promise<void>;
|
|
83
87
|
env: NodeJS.ProcessEnv;
|
|
84
88
|
}
|
|
85
89
|
export interface NativeEmptyInitHooks extends Pick<NativeMigrationHooks, 'onStep'> {
|
|
@@ -2,6 +2,7 @@ import type { AccountStorage } from './accounts.ts';
|
|
|
2
2
|
import { type ClaudeGateway, type ClaudeGatewayStatus } from './gateway.ts';
|
|
3
3
|
import { type SettingsKey } from './settings-definition.ts';
|
|
4
4
|
import { type SettingsMode, type SettingsModeOptions } from './settings-mode.ts';
|
|
5
|
+
import { type SettingsMoveDiagnostic } from './settings-mode-status.ts';
|
|
5
6
|
import type { SettingsHost } from './settings-paths.ts';
|
|
6
7
|
import { type SettingsFileStatus, type SettingsService, type SettingsUpdate, type SettingsValues } from './settings-service.ts';
|
|
7
8
|
import type { SettingsProtectionFallback, SettingsReopen } from './settings-start.ts';
|
|
@@ -9,6 +10,7 @@ export interface NativeRuntimeSettingsOptions {
|
|
|
9
10
|
settingsService?: SettingsService;
|
|
10
11
|
/** Return the cached settings mode; this callback must not read the filesystem. */
|
|
11
12
|
settingsMode?: () => SettingsMode;
|
|
13
|
+
settingsDiagnostic?: SettingsMoveDiagnostic;
|
|
12
14
|
settingsAuthority?: {
|
|
13
15
|
options?: SettingsModeOptions;
|
|
14
16
|
/** Schedule a background authority check and return its cancellation function. */
|
|
@@ -56,6 +58,8 @@ export declare function createNativeRuntimeSettings(options: NativeRuntimeSettin
|
|
|
56
58
|
(stored: Record<string, unknown>, model?: string): Record<string, unknown>;
|
|
57
59
|
};
|
|
58
60
|
status: () => NativeRuntimeSettingsStatus | undefined;
|
|
61
|
+
modeStatus(file: string): string;
|
|
62
|
+
setDiagnostic(next: SettingsMoveDiagnostic): void;
|
|
59
63
|
gateway: () => ClaudeGateway | undefined;
|
|
60
64
|
applyEffects: () => void;
|
|
61
65
|
file: () => string | undefined;
|
package/dist/pool-authority.d.ts
CHANGED
|
@@ -189,5 +189,7 @@ export declare function recordNativeCustodyActivation(paths: NativePoolPaths, pl
|
|
|
189
189
|
/** Advance a recorded activation one phase; never backwards or across a phase. */
|
|
190
190
|
export declare function advanceNativeCustodyActivation(paths: NativePoolPaths, expected: NativeCustodyActivationPhase, next: NativeCustodyActivationPhase, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
191
191
|
/** Publish local authority without inventing migration inputs or creating a pool. */
|
|
192
|
-
export declare function beginNativeEmptyInit(paths: NativePoolPaths, hooks?: JournalHooks
|
|
192
|
+
export declare function beginNativeEmptyInit(paths: NativePoolPaths, hooks?: JournalHooks & {
|
|
193
|
+
validate?: () => Promise<void>;
|
|
194
|
+
}): Promise<NativeEmptyInitJournal>;
|
|
193
195
|
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SettingsMode } from './settings-mode.ts';
|
|
2
|
+
import type { SettingsMoveFenceBlocker } from './settings-move-fence.ts';
|
|
3
|
+
import type { SettingsMoveStartupResult } from './settings-move-run.ts';
|
|
4
|
+
import type { SettingsMoveSourcesResult } from './settings-move-sources.ts';
|
|
5
|
+
/** Only blocker identities are exposed; reasons can contain filesystem errors. */
|
|
6
|
+
export interface SettingsMoveBlockerIdentity {
|
|
7
|
+
kind: SettingsMoveFenceBlocker['kind'];
|
|
8
|
+
path?: string;
|
|
9
|
+
pid?: number | null;
|
|
10
|
+
release?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface SettingsMoveDiagnostic {
|
|
13
|
+
outcome: SettingsMoveStartupResult['outcome'] | 'authority-refused' | 'startup-failed';
|
|
14
|
+
blockers?: readonly SettingsMoveBlockerIdentity[];
|
|
15
|
+
sourceReason?: Extract<SettingsMoveSourcesResult, {
|
|
16
|
+
status: 'unavailable';
|
|
17
|
+
}>['reason'];
|
|
18
|
+
}
|
|
19
|
+
export declare function settingsMoveBlockerIdentity(blocker: SettingsMoveFenceBlocker): SettingsMoveBlockerIdentity;
|
|
20
|
+
/** Shared by every host, using only the runtime's cached settings mode and move result. */
|
|
21
|
+
export declare function formatSettingsModeStatus(options: {
|
|
22
|
+
mode: SettingsMode;
|
|
23
|
+
file: string;
|
|
24
|
+
diagnostic?: SettingsMoveDiagnostic;
|
|
25
|
+
}): string;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type MoveOutcome, type MoveResult, moveSettingsOnce } from "./internal-types/settings/index.js";
|
|
2
2
|
import { type SettingsMode, type SettingsModeOptions } from './settings-mode.ts';
|
|
3
|
+
import { type SettingsMoveBlockerIdentity, type SettingsMoveDiagnostic } from './settings-mode-status.ts';
|
|
3
4
|
import { type SettingsMoveFenceOptions } from './settings-move-fence.ts';
|
|
4
5
|
import { prepareSettingsMoveSources, type SettingsMoveSourcesOptions } from './settings-move-sources.ts';
|
|
5
6
|
import { type SettingsPaths } from './settings-paths.ts';
|
|
6
7
|
import { type SettingsService } from './settings-service.ts';
|
|
7
8
|
export interface SettingsMoveStartupOptions extends SettingsMoveSourcesOptions {
|
|
9
|
+
log?: SettingsMoveSourcesOptions['log'] & {
|
|
10
|
+
info?: (message: string) => void;
|
|
11
|
+
};
|
|
8
12
|
fence: Pick<SettingsMoveFenceOptions, 'registration' | 'floor' | 'self' | 'liveness' | 'artifacts' | 'readHolders'>;
|
|
9
13
|
authority?: Pick<SettingsModeOptions, 'fs' | 'ownership' | 'now'>;
|
|
10
14
|
dependencies?: {
|
|
@@ -33,6 +37,8 @@ export interface SettingsMoveStartupResult {
|
|
|
33
37
|
*/
|
|
34
38
|
| 'import-pending';
|
|
35
39
|
move?: MoveResult;
|
|
40
|
+
blockers?: SettingsMoveBlockerIdentity[];
|
|
41
|
+
sourceReason?: SettingsMoveDiagnostic['sourceReason'];
|
|
36
42
|
/**
|
|
37
43
|
* In user-file mode: the file is missing and this host's legacy store was
|
|
38
44
|
* never imported. The host uses the file (its protection comes from this
|
package/dist/settings-start.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type SettingsMode } from './settings-mode.ts';
|
|
2
|
+
import type { SettingsMoveDiagnostic } from './settings-mode-status.ts';
|
|
2
3
|
import { runSettingsMoveAtStartup, type SettingsMoveStartupOptions } from './settings-move-run.ts';
|
|
3
4
|
import { type SettingsProtectionRecovery, type SettingsProtectionValues, type SettingsService, type SettingsServiceOptions } from './settings-service.ts';
|
|
4
5
|
export interface StartSettingsOptions extends SettingsMoveStartupOptions {
|
|
@@ -47,6 +48,7 @@ export interface SettingsProtectionFallback {
|
|
|
47
48
|
}
|
|
48
49
|
export interface StartedSettings {
|
|
49
50
|
mode: SettingsMode;
|
|
51
|
+
diagnostic?: SettingsMoveDiagnostic;
|
|
50
52
|
/**
|
|
51
53
|
* The settings file; empty only when no path could be resolved, which the
|
|
52
54
|
* shared-runtime key treats as "no settings file".
|
package/dist/sticky-routing.d.ts
CHANGED
|
@@ -118,6 +118,40 @@ export declare function decideStickyQuotaFailure(input: {
|
|
|
118
118
|
accountId: string;
|
|
119
119
|
};
|
|
120
120
|
}): StickyQuotaFailureDecision;
|
|
121
|
+
export type StickyQuotaExhaustion = {
|
|
122
|
+
/** When the last exhausted window blocking the request resets. */
|
|
123
|
+
readonly resetAt: number;
|
|
124
|
+
readonly reason: 'five-hour' | 'seven-day' | 'model-scoped';
|
|
125
|
+
/** The window's name as quota refusals show it, such as "weekly". */
|
|
126
|
+
readonly limitName: string;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Confirmed exhaustion that still blocks a request for `modelId`: an exhausted
|
|
130
|
+
* 5-hour, weekly or model-scoped window whose reset is known and still ahead.
|
|
131
|
+
* It reads the same evidence as `decideStickyQuotaFailure`, except that stored
|
|
132
|
+
* header readings never count, because their percentages are display-rounded:
|
|
133
|
+
* only raw refused-request headers or a polled reading confirm exhaustion.
|
|
134
|
+
* Returns the latest such reset, since the account can serve the request again
|
|
135
|
+
* only after every one of those windows resets. Windows whose reset is unknown
|
|
136
|
+
* or already past are not counted.
|
|
137
|
+
*/
|
|
138
|
+
export declare function stickyQuotaExhaustionInForce(input: {
|
|
139
|
+
quota: OAuthQuotaSnapshot | QuotaState | undefined;
|
|
140
|
+
responseHeaders?: Headers;
|
|
141
|
+
modelId?: string;
|
|
142
|
+
now?: number;
|
|
143
|
+
}): StickyQuotaExhaustion | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* The quota refusal for a request that no account can take because every
|
|
146
|
+
* account that could is confirmed exhausted (see `stickyQuotaExhaustionInForce`).
|
|
147
|
+
* It names the window that resets first across those accounts.
|
|
148
|
+
*/
|
|
149
|
+
export declare function createExhaustedNoRouteResponse(input: {
|
|
150
|
+
exhausted: readonly StickyQuotaExhaustion[];
|
|
151
|
+
storage?: AccountStorage | null;
|
|
152
|
+
sessionId?: string | null;
|
|
153
|
+
now?: number;
|
|
154
|
+
}): Response;
|
|
121
155
|
/** Bound an unconfirmed 429's host retry while preserving any shorter upstream wait. */
|
|
122
156
|
export declare function stickyRetainRetryHeaders(upstream: Headers, now?: number): Headers;
|
|
123
157
|
export declare function getStickyRoutingStatePath(accountStoragePath: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"prepublishOnly": "bun run build"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cortexkit/common-auth": "0.
|
|
34
|
+
"@cortexkit/common-auth": "0.52.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cortexkit/claustrum-client": "0.18.0",
|