@cortexkit/anthropic-auth-core 2.8.0 → 2.9.1
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/dump.d.ts +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +958 -502
- package/dist/internal-types/claustrum/availability.d.ts +7 -1
- package/dist/internal-types/claustrum/custody.d.ts +11 -2
- package/dist/internal-types/claustrum/enrollment.d.ts +4 -0
- package/dist/internal-types/claustrum/index.d.ts +1 -1
- package/dist/internal-types/routing-accessor/cache-policy.d.ts +3 -0
- package/dist/internal-types/routing-accessor/index.d.ts +48 -5
- package/dist/internal-types/setup/types.d.ts +1 -0
- package/dist/native-custody.d.ts +0 -2
- package/dist/request-gzip.d.ts +3 -2
- package/dist/state-layout-decision.d.ts +8 -1
- package/dist/stream-completion.d.ts +26 -0
- package/package.json +2 -2
|
@@ -85,6 +85,12 @@ export declare const VAULT_FAILURE_CLASSES: Readonly<{
|
|
|
85
85
|
* kind stays `unavailable` for callers handling ClaustrumConsumerError.
|
|
86
86
|
*/
|
|
87
87
|
export declare class ClaustrumUnreachableError extends ClaustrumConsumerError {
|
|
88
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Non-secret host connection diagnostic. A missing accessor can recover
|
|
90
|
+
* once the host bridge installs; a failed accessor could not provide a client.
|
|
91
|
+
* Other unreachable failures leave this unset. Never use adapter error text.
|
|
92
|
+
*/
|
|
93
|
+
readonly reason?: 'host-accessor-missing' | 'host-accessor-failed';
|
|
94
|
+
constructor(reason?: ClaustrumUnreachableError['reason']);
|
|
89
95
|
}
|
|
90
96
|
export declare function classifyVaultFailure(error: unknown): VaultFailureClass;
|
|
@@ -279,6 +279,15 @@ export declare class ClaustrumScopedCustody {
|
|
|
279
279
|
setTimeoutImpl?: typeof setTimeout;
|
|
280
280
|
clearTimeoutImpl?: typeof clearTimeout;
|
|
281
281
|
});
|
|
282
|
+
/**
|
|
283
|
+
* Replace the connection to the same vault without discarding receipts or
|
|
284
|
+
* their enrollment tokens. Open roster watches restart on the new client;
|
|
285
|
+
* their existing handles remain usable. Passing the current client does nothing.
|
|
286
|
+
* Neither client is closed here: the caller closes the old one, and custody's
|
|
287
|
+
* close()/dispose() still closes the client it holds at shutdown.
|
|
288
|
+
* While hosted, next must come from connectVaultHost, as in the constructor.
|
|
289
|
+
*/
|
|
290
|
+
replaceClient(next: ClaustrumScopedClient): void;
|
|
282
291
|
/** A watch losing its transport is the same outage as an unreachable read. */
|
|
283
292
|
transportLost(error?: unknown): void;
|
|
284
293
|
/** Any vault answer ends transport fallback, even when it refuses access. */
|
|
@@ -312,8 +321,8 @@ export declare class ClaustrumScopedCustody {
|
|
|
312
321
|
* Report that a send this consumer actually made was rejected. Only a 401
|
|
313
322
|
* is reported (the vault refuses 429, 402 and 5xx reports), addressed by
|
|
314
323
|
* credential id with the exact record version that send was served, and
|
|
315
|
-
* sent through the client
|
|
316
|
-
* this custody did not issue is refused rather than reported.
|
|
324
|
+
* sent through the current client with the enrollment token that authorized
|
|
325
|
+
* it. A receipt this custody did not issue is refused rather than reported.
|
|
317
326
|
*/
|
|
318
327
|
reportFailure(attempt: ClaustrumScopedAttempt, status: number, reporterSource: ClaustrumReporterSource): Promise<void>;
|
|
319
328
|
/**
|
|
@@ -29,10 +29,13 @@ export declare function classifyEnrollmentError(error: unknown): {
|
|
|
29
29
|
* Each host enrolls separately so the operator can revoke one without the other.
|
|
30
30
|
*/
|
|
31
31
|
export declare function enrollmentName(plugin: string, host: string): string;
|
|
32
|
+
/** Match the vault's plain-text, code-point limit before proposing a display name. */
|
|
33
|
+
export declare function validEnrollmentDisplayName(displayName: string): boolean;
|
|
32
34
|
export interface ClaustrumEnrollmentClient {
|
|
33
35
|
enrollPropose(input: {
|
|
34
36
|
name: string;
|
|
35
37
|
requestSecretHash: string;
|
|
38
|
+
displayName?: string;
|
|
36
39
|
}): Promise<{
|
|
37
40
|
requestId: string;
|
|
38
41
|
}>;
|
|
@@ -142,6 +145,7 @@ export declare class ClaustrumEnrollmentManager {
|
|
|
142
145
|
client: ClaustrumEnrollmentClient;
|
|
143
146
|
paths: ClaustrumEnrollmentPaths;
|
|
144
147
|
proposedName: string;
|
|
148
|
+
displayName?: string;
|
|
145
149
|
now?: () => number;
|
|
146
150
|
mintSecret?: () => string;
|
|
147
151
|
writeTokenFile?: typeof writeEnrollmentTokenFile;
|
|
@@ -4,7 +4,7 @@ export { ClaustrumCredentialError, type ClaustrumReporterSource, type Enrollment
|
|
|
4
4
|
export { ClaustrumUnreachableError, classifyVaultFailure, VAULT_FAILURE_CLASSES, type VaultFailureClass, } from './availability.js';
|
|
5
5
|
export { ClaustrumConsumer, type ClaustrumConsumerOptions, type ClaustrumWatchState, DEFAULT_CONNECT_TIMEOUT_MS, type SendOptions, } from './consumer.js';
|
|
6
6
|
export { type AccountIdentitySource, type ClassifyingClaustrumFamily, type ClaustrumFamily, type ClaustrumFamilyInput, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, type VaultRowFacts, } from './custody.js';
|
|
7
|
-
export { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentConnection, type ClaustrumEnrollmentDisconnectResult, ClaustrumEnrollmentManager, type ClaustrumEnrollmentPaths, type ClaustrumEnrollmentResetResult, type ClaustrumEnrollmentStatus, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, type EnrollmentDisposition, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, vaultAuthority, } from './enrollment.js';
|
|
7
|
+
export { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentConnection, type ClaustrumEnrollmentDisconnectResult, ClaustrumEnrollmentManager, type ClaustrumEnrollmentPaths, type ClaustrumEnrollmentResetResult, type ClaustrumEnrollmentStatus, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, type EnrollmentDisposition, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, validEnrollmentDisplayName, vaultAuthority, } from './enrollment.js';
|
|
8
8
|
export { ClaustrumConsumerError, type ClaustrumConsumerFailureKind, type ClaustrumLogger, } from './errors.js';
|
|
9
9
|
export { connectVaultHost, hasVaultHost, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from './host.js';
|
|
10
10
|
export { assertHostSlotMatchesMode, assertNotCustodyPlaceholder, CUSTODY_PLACEHOLDER_PREFIX, classifyHostSlot, custodyPlaceholder, custodyPlaceholderKey, type HostSlotContent, isCustodyPlaceholder, isCustodyPlaceholderValue, } from './host-slot.js';
|
|
@@ -14,6 +14,9 @@ export interface SessionToolWait {
|
|
|
14
14
|
/** Epoch milliseconds when the oldest running plan tool started. */
|
|
15
15
|
since: number;
|
|
16
16
|
}
|
|
17
|
+
export declare const CACHE_WARM_STOP_REASONS: readonly ['cost-cap', 'count-cap', 'outside-hours', 'session-ended', 'unsupported'];
|
|
18
|
+
/** Billing rejects unknown stop reasons; omit them rather than guessing. */
|
|
19
|
+
export declare function isCacheWarmStopReason(value: unknown): value is (typeof CACHE_WARM_STOP_REASONS)[number];
|
|
17
20
|
/**
|
|
18
21
|
* The stop reasons the llm-runner contract defines today; any other string is
|
|
19
22
|
* accepted too, for reasons that contract adds later.
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* shaping. Account ids are vault account ids, not local pool rows. Nothing is
|
|
4
4
|
* persisted here; plugins on routes the runner does not serve get no turn notes.
|
|
5
5
|
*/
|
|
6
|
+
import { type CacheWarmStopReason } from './cache-policy.js';
|
|
6
7
|
export type { CacheTouchInput, CacheWarmStoppedInput, CacheWarmStopReason, SessionCacheHours, SessionCachePolicy, SessionCacheTtl, SessionKeepWarmMode, SessionToolWait, } from './cache-policy.js';
|
|
7
|
-
export { reportCacheTouch, reportCacheWarmStopped, sessionCachePolicy, sessionToolWait, } from './cache-policy.js';
|
|
8
|
+
export { CACHE_WARM_STOP_REASONS, isCacheWarmStopReason, reportCacheTouch, reportCacheWarmStopped, sessionCachePolicy, sessionToolWait, } from './cache-policy.js';
|
|
8
9
|
/** An eligible vault route, not a local pool row. */
|
|
9
10
|
export interface RoutingCandidate {
|
|
10
11
|
/** Vault account id, not the plugin's route id. */
|
|
@@ -42,6 +43,19 @@ interface RoutingReportIdentity {
|
|
|
42
43
|
accountId: string;
|
|
43
44
|
credentialId?: string;
|
|
44
45
|
}
|
|
46
|
+
export type BillingRequestKind = 'primary' | 'title' | 'compaction' | 'generate' | 'keep_warm' | 'prime';
|
|
47
|
+
export type BillingOutcome = 'completed' | 'cut' | 'failed';
|
|
48
|
+
/** Omit unread counts; zero represents a measured count, not a default. */
|
|
49
|
+
export interface BillingUsage {
|
|
50
|
+
input?: number;
|
|
51
|
+
output?: number;
|
|
52
|
+
cacheRead?: number;
|
|
53
|
+
cacheWrite?: number;
|
|
54
|
+
cacheWrite5m?: number;
|
|
55
|
+
cacheWrite1h?: number;
|
|
56
|
+
reasoning?: number;
|
|
57
|
+
reasoningIncludedInOutput?: boolean;
|
|
58
|
+
}
|
|
45
59
|
export type ReportRoutingInput = (RoutingReportIdentity & ({
|
|
46
60
|
outcome: 'served';
|
|
47
61
|
/**
|
|
@@ -73,6 +87,35 @@ export type ReportRoutingInput = (RoutingReportIdentity & ({
|
|
|
73
87
|
kind: 'turn_note_skipped';
|
|
74
88
|
after_tool_use_id: string;
|
|
75
89
|
reason: 'anchor_missing' | 'before_user_message' | 'unsupported_model' | 'not_oauth';
|
|
90
|
+
} | {
|
|
91
|
+
sessionId: string;
|
|
92
|
+
kind: 'billing';
|
|
93
|
+
attemptId: string;
|
|
94
|
+
requestKind: BillingRequestKind;
|
|
95
|
+
credentialId: string;
|
|
96
|
+
accountId?: string;
|
|
97
|
+
provider: string;
|
|
98
|
+
model: string;
|
|
99
|
+
outcome: BillingOutcome;
|
|
100
|
+
providerRequestId?: string;
|
|
101
|
+
providerResponseId?: string;
|
|
102
|
+
userMessageId?: string;
|
|
103
|
+
status?: number;
|
|
104
|
+
attempt?: number;
|
|
105
|
+
chargeBasis?: 'subscription_included' | 'metered_api';
|
|
106
|
+
usage?: BillingUsage;
|
|
107
|
+
usageByModel?: readonly {
|
|
108
|
+
modelUsed: string;
|
|
109
|
+
usage: BillingUsage;
|
|
110
|
+
}[];
|
|
111
|
+
cache?: {
|
|
112
|
+
ttlMs?: number;
|
|
113
|
+
implicit?: true;
|
|
114
|
+
warming?: {
|
|
115
|
+
on: boolean;
|
|
116
|
+
stopReason?: CacheWarmStopReason;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
76
119
|
};
|
|
77
120
|
/**
|
|
78
121
|
* Read advisory input for request shaping, in landing order, without persisting
|
|
@@ -90,9 +133,9 @@ export declare function turnNotes(sessionId: string): readonly {
|
|
|
90
133
|
*/
|
|
91
134
|
export declare function askRouting<Candidate extends RoutingCandidate>(input: AskRoutingInput<Candidate>): Promise<RoutingSelection<Candidate> | undefined>;
|
|
92
135
|
/**
|
|
93
|
-
* Report a vault request or turn-note event without waiting for
|
|
94
|
-
* contract fields are sent, and all accessor failures are ignored.
|
|
95
|
-
* already be limited to rate-limit headers by the caller; values
|
|
96
|
-
* or redacted here.
|
|
136
|
+
* Report a vault request, billing result or turn-note event without waiting for
|
|
137
|
+
* routing. Only contract fields are sent, and all accessor failures are ignored.
|
|
138
|
+
* Headers must already be limited to rate-limit headers by the caller; values
|
|
139
|
+
* are not filtered or redacted here.
|
|
97
140
|
*/
|
|
98
141
|
export declare function reportRouting(input: ReportRoutingInput): void;
|
package/dist/native-custody.d.ts
CHANGED
|
@@ -223,8 +223,6 @@ export type NativeCustodyRetry = {
|
|
|
223
223
|
code?: NativeCustodyErrorCode;
|
|
224
224
|
};
|
|
225
225
|
export interface NativeCustody {
|
|
226
|
-
/** Whether a 401 needs fresh authorization because a previous relay issued the receipt. */
|
|
227
|
-
isPreviousConnectionReceipt?: (receipt: NativeCustodyReceipt) => boolean;
|
|
228
226
|
/** Authority lifetime only; replacing a relay does not retire issued tokens. */
|
|
229
227
|
readonly generation?: number;
|
|
230
228
|
discover: (signal?: AbortSignal) => Promise<NativeCustodyInventory>;
|
package/dist/request-gzip.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StateLayout } from './state-layout-paths.ts';
|
|
1
2
|
/** Claude Code's own opt-out: `0`/`false` turns gzip off, `1`/`true` forces it. */
|
|
2
3
|
export declare const GZIP_REQUEST_BODIES_ENV = "CLAUDE_CODE_GZIP_REQUEST_BODIES";
|
|
3
4
|
/** How long a persisted latch keeps gzip off. */
|
|
@@ -43,8 +44,8 @@ export declare class RequestGzipLatch {
|
|
|
43
44
|
}
|
|
44
45
|
/** One latch per storage path, shared by every send path in this process. */
|
|
45
46
|
export declare function getRequestGzipLatch(path?: string): RequestGzipLatch;
|
|
46
|
-
/** The latch
|
|
47
|
-
export declare function getRequestGzipLatchPath(accountStoragePath: string): string;
|
|
47
|
+
/** The advisory latch starts empty in state-home; legacy and Pi keep their account-file sibling. */
|
|
48
|
+
export declare function getRequestGzipLatchPath(accountStoragePath: string, layout?: StateLayout): string;
|
|
48
49
|
/** Decide, in Claude Code's order, whether this request body goes out gzipped. */
|
|
49
50
|
export declare function decideRequestGzip(options: {
|
|
50
51
|
url: string | URL;
|
|
@@ -16,7 +16,7 @@ import { type StateLayoutRecord } from './state-layout-record.ts';
|
|
|
16
16
|
* checks, and the mandatory state-home registration. The release that ships
|
|
17
17
|
* the move turns it on.
|
|
18
18
|
*/
|
|
19
|
-
export declare const RELOCATION_MOVE_ENABLED =
|
|
19
|
+
export declare const RELOCATION_MOVE_ENABLED = true;
|
|
20
20
|
/** Turn the move on or off for this process, or back to the default; tests only. */
|
|
21
21
|
export declare function setRelocationMoveEnabledForTests(enabled: boolean | undefined): void;
|
|
22
22
|
/**
|
|
@@ -41,6 +41,8 @@ export interface DecideStateLayoutOptions {
|
|
|
41
41
|
role: HolderRole;
|
|
42
42
|
env?: NodeJS.ProcessEnv;
|
|
43
43
|
home?: string;
|
|
44
|
+
/** Read-only local migration check before registration; offline setup omits it. */
|
|
45
|
+
requireExistingAuthority?: boolean;
|
|
44
46
|
/** Filesystem seam; `node:fs` for this platform otherwise. */
|
|
45
47
|
fs?: StateLayoutFs;
|
|
46
48
|
liveness?: HolderLiveness;
|
|
@@ -91,6 +93,8 @@ export type StateLayoutDecision = {
|
|
|
91
93
|
* neither copy may be served safely; the process must then do no pool I/O
|
|
92
94
|
* for the dataset. `RelocatedError` is never thrown here: a dataset moved by
|
|
93
95
|
* a newer version of the same layout rules is served from its new folder.
|
|
96
|
+
* With `requireExistingAuthority`, an unmigrated local dataset refuses with
|
|
97
|
+
* `NativeAuthorityError` before locks, registration or relocation writes.
|
|
94
98
|
*/
|
|
95
99
|
export declare function decideOpenCodeStateLayout(options: DecideStateLayoutOptions): Promise<StateLayoutDecision>;
|
|
96
100
|
/**
|
|
@@ -112,6 +116,9 @@ export declare function resetStateLayoutDecisionsForTests(): void;
|
|
|
112
116
|
export declare function decidePiStateLayout(options: {
|
|
113
117
|
paths: NativePoolPaths;
|
|
114
118
|
role: HolderRole;
|
|
119
|
+
env?: NodeJS.ProcessEnv;
|
|
120
|
+
/** Read-only local migration check before registration; offline setup omits it. */
|
|
121
|
+
requireExistingAuthority?: boolean;
|
|
115
122
|
onLockEvent?: (event: NativeLockEvent) => void;
|
|
116
123
|
liveness?: HolderLiveness;
|
|
117
124
|
lockTimeoutMs?: number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface IncompleteStreamDiagnostics {
|
|
2
|
+
response_headers: Record<string, string>;
|
|
3
|
+
response_bytes: number;
|
|
4
|
+
sse_events: number;
|
|
5
|
+
send_to_headers_ms?: number;
|
|
6
|
+
/**
|
|
7
|
+
* For credential_scope, send_to_headers_ms starts at credential preparation and
|
|
8
|
+
* includes host scheduling and gzip time: an upper bound, not network latency.
|
|
9
|
+
*/
|
|
10
|
+
timing_source?: 'physical_fetch' | 'credential_scope';
|
|
11
|
+
headers_to_eof_ms: number;
|
|
12
|
+
}
|
|
13
|
+
/** Preserve physical-send timing across wrappers without reading or cloning the body. */
|
|
14
|
+
export declare function copyStreamResponseTiming(source: Response, target: Response, sent?: number, timingSource?: 'physical_fetch' | 'credential_scope'): Response;
|
|
15
|
+
export declare function safeIncompleteStreamDiagnostics(input: IncompleteStreamDiagnostics): IncompleteStreamDiagnostics;
|
|
16
|
+
/** EOF requires a complete message_stop or an explicit protocol error. */
|
|
17
|
+
export declare function createAnthropicStreamCompletion(response: Response): {
|
|
18
|
+
end: () => void;
|
|
19
|
+
push(chunk: Uint8Array): void;
|
|
20
|
+
finish(): (Error & {
|
|
21
|
+
code: string;
|
|
22
|
+
diagnostics: IncompleteStreamDiagnostics;
|
|
23
|
+
}) | undefined;
|
|
24
|
+
};
|
|
25
|
+
/** Validate passthrough API streams without rewriting tool names or response bytes. */
|
|
26
|
+
export declare function guardAnthropicStreamResponse(response: Response, onIncomplete?: (diagnostics: IncompleteStreamDiagnostics) => void | Promise<void>): Response;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"prepublishOnly": "bun run build"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@cortexkit/common-auth": "0.
|
|
33
|
+
"@cortexkit/common-auth": "0.43.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@cortexkit/claustrum-client": "0.17.0",
|