@cortexkit/anthropic-auth-core 2.4.3 → 2.4.4
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/cachekeep.d.ts +77 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7671 -7464
- package/dist/native-account-refusal.d.ts +11 -0
- package/package.json +1 -1
package/dist/cachekeep.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AccountStorage } from './accounts.ts';
|
|
2
2
|
import type { CacheKeepTrackedSession } from './cachekeep-registry.ts';
|
|
3
|
+
import { type NativeAccountRefusalReason } from './native-account-refusal.ts';
|
|
3
4
|
import { type ProviderErrorSummary } from './provider-error.ts';
|
|
4
5
|
export declare const CLAUDE_CACHE_KEEP_COMMAND_NAME = "claude-cachekeep";
|
|
5
6
|
export declare const CACHE_KEEP_TTL_MS: number;
|
|
@@ -60,7 +61,9 @@ export declare function executeCacheKeepCommand(input: {
|
|
|
60
61
|
nextPrewarmAt?: number;
|
|
61
62
|
hybridActive?: boolean;
|
|
62
63
|
}): string;
|
|
63
|
-
export declare function buildCacheKeepPrewarmBody(bodyText: string
|
|
64
|
+
export declare function buildCacheKeepPrewarmBody(bodyText: string, options?: {
|
|
65
|
+
stripServerFallback?: boolean;
|
|
66
|
+
}): Promise<{
|
|
64
67
|
ok: true;
|
|
65
68
|
bodyText: string;
|
|
66
69
|
} | {
|
|
@@ -81,7 +84,33 @@ export type CacheKeepTarget = {
|
|
|
81
84
|
oauthAccountIdentity?: string;
|
|
82
85
|
accountStoragePath?: string;
|
|
83
86
|
isSubagent: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* A recovery-round warm for the original (source) model, tracked under a
|
|
89
|
+
* key that cannot collide with the session's live target. It follows the
|
|
90
|
+
* same send, auth, retry and logging path; the caller stops it through
|
|
91
|
+
* untrack() when the round ends or its prefix becomes unusable.
|
|
92
|
+
*/
|
|
93
|
+
sourceWarm?: boolean;
|
|
84
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Fingerprint of the cacheable prefix of a request body: tools, system
|
|
97
|
+
* blocks, and messages up to the last cache breakpoint. The billing header
|
|
98
|
+
* block is excluded because its signature is re-signed on every send, and
|
|
99
|
+
* everything past the last breakpoint (output limits, stream flags,
|
|
100
|
+
* thinking config) never affects the stored cache entry. Two bodies with
|
|
101
|
+
* the same fingerprint warm the same cache entry.
|
|
102
|
+
*/
|
|
103
|
+
export declare function cacheWarmCacheablePrefixFingerprint(bodyText: string): string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* How many warms one idle recovery round may send before stopping: each
|
|
106
|
+
* warm pays a cache read, and the idle warms stay worth it while the reads
|
|
107
|
+
* sent since the last user turn cost less than one 1-hour rewrite, so the
|
|
108
|
+
* round stops after floor((1-hour write rate - read rate) / read rate)
|
|
109
|
+
* warms. Rates come from the source model's own catalogue pricing; models
|
|
110
|
+
* without catalogue facts (Opus 5) use the nearest sibling with 1-hour
|
|
111
|
+
* pricing.
|
|
112
|
+
*/
|
|
113
|
+
export declare function cacheKeepSourceWarmIdleCap(modelId: string): number;
|
|
85
114
|
export type CacheKeepPrewarmAttempt = {
|
|
86
115
|
id: number;
|
|
87
116
|
/** One deadline covers credential authorization and the HTTP attempt. */
|
|
@@ -89,6 +118,7 @@ export type CacheKeepPrewarmAttempt = {
|
|
|
89
118
|
};
|
|
90
119
|
export type CacheKeepPrewarmResult = {
|
|
91
120
|
ok: true;
|
|
121
|
+
refused?: false;
|
|
92
122
|
usage?: {
|
|
93
123
|
input_tokens?: number;
|
|
94
124
|
cache_creation_input_tokens?: number;
|
|
@@ -96,10 +126,26 @@ export type CacheKeepPrewarmResult = {
|
|
|
96
126
|
};
|
|
97
127
|
} | {
|
|
98
128
|
ok: false;
|
|
129
|
+
refused?: false;
|
|
99
130
|
reason: string;
|
|
131
|
+
refusal?: NativeAccountRefusalReason;
|
|
100
132
|
status?: number;
|
|
101
133
|
transient?: true;
|
|
102
134
|
provider_error?: ProviderErrorSummary['provider_error'];
|
|
135
|
+
} | {
|
|
136
|
+
/** The warm was refused before any send; the target is removed. */
|
|
137
|
+
ok: false;
|
|
138
|
+
refused: true;
|
|
139
|
+
reason: string;
|
|
140
|
+
status?: undefined;
|
|
141
|
+
transient?: undefined;
|
|
142
|
+
provider_error?: undefined;
|
|
143
|
+
};
|
|
144
|
+
export type CacheKeepPrewarmValidation = {
|
|
145
|
+
ok: true;
|
|
146
|
+
} | {
|
|
147
|
+
ok: false;
|
|
148
|
+
reason: string;
|
|
103
149
|
};
|
|
104
150
|
export declare class CacheKeepManager {
|
|
105
151
|
private readonly options;
|
|
@@ -126,6 +172,15 @@ export declare class CacheKeepManager {
|
|
|
126
172
|
}) => Promise<Headers | undefined> | Headers | undefined;
|
|
127
173
|
onTrackedSessionsChanged?: (sessions: readonly CacheKeepTrackedSession[]) => Promise<void> | void;
|
|
128
174
|
prepareBody?: (bodyText: string, target: CacheKeepTarget) => string | Promise<string>;
|
|
175
|
+
/**
|
|
176
|
+
* Veto a prewarm after its body is built but before anything is
|
|
177
|
+
* sent. A refusal removes the target without sending. Throwing also
|
|
178
|
+
* refuses, so a failing check can never send a mismatched warm.
|
|
179
|
+
*/
|
|
180
|
+
validatePrewarm?: (input: {
|
|
181
|
+
target: CacheKeepTarget;
|
|
182
|
+
warmBodyText: string;
|
|
183
|
+
}) => CacheKeepPrewarmValidation | Promise<CacheKeepPrewarmValidation>;
|
|
129
184
|
onResponse?: (input: {
|
|
130
185
|
target: CacheKeepTarget;
|
|
131
186
|
bodyText: string;
|
|
@@ -149,6 +204,26 @@ export declare class CacheKeepManager {
|
|
|
149
204
|
trackedOAuthRoute(sessionId: string): {
|
|
150
205
|
oauthAccountId?: string;
|
|
151
206
|
} | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* The last request actually sent for a session, as tracked live: the
|
|
209
|
+
* exact signed bytes, destination, and account they went out on. A copy
|
|
210
|
+
* of the headers; the body string itself is shared, never re-serialized.
|
|
211
|
+
*/
|
|
212
|
+
trackedRequest(id: string): {
|
|
213
|
+
bodyText: string;
|
|
214
|
+
url: string;
|
|
215
|
+
headers: Record<string, string>;
|
|
216
|
+
oauthAccountId?: string;
|
|
217
|
+
oauthAccountIdentity?: string;
|
|
218
|
+
isSubagent: boolean;
|
|
219
|
+
cacheExpiresAt: number;
|
|
220
|
+
} | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Stop warming a session without logging: the caller owns the reason
|
|
223
|
+
* (a finished recovery round, a model change, a cleared session) and
|
|
224
|
+
* logs it where the decision is made. Returns whether a target existed.
|
|
225
|
+
*/
|
|
226
|
+
untrack(id: string): boolean;
|
|
152
227
|
trackedCount(): number;
|
|
153
228
|
/**
|
|
154
229
|
* Drop targets whose cache has already expired, without sending or
|
|
@@ -172,6 +247,7 @@ export declare class CacheKeepManager {
|
|
|
172
247
|
oauthAccountIdentity?: string;
|
|
173
248
|
accountStoragePath?: string;
|
|
174
249
|
isSubagent?: boolean;
|
|
250
|
+
sourceWarm?: boolean;
|
|
175
251
|
}): {
|
|
176
252
|
tracked: true;
|
|
177
253
|
} | {
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type { ClaudeCodeBetaLists, ClaudeModelCapabilities, ClaudeModelCatalogue
|
|
|
24
24
|
export { CLAUDE_CODE_DEFAULT_BETAS, CLAUDE_MODEL_CAPABILITIES, getClaudeModelCapabilities, getClaudeModelCatalogue, pinsEffortOnEveryRequest, resolveClaudeModelCapabilities, } from './model-capabilities.ts';
|
|
25
25
|
export * from './model-remap.ts';
|
|
26
26
|
export * from './models.ts';
|
|
27
|
+
export * from './native-account-refusal.ts';
|
|
27
28
|
export type { NativeAccountRuntime, NativeAccountRuntimeOptions, NativeAccountWriteInput, NativeApiSubject, NativeLocalAuthorizeOptions, NativeRelayUpdate, } from './native-account-runtime.ts';
|
|
28
29
|
export { acquireNativeAccountRuntime, createNativeAccountRuntime, nativeAccountPolicy, } from './native-account-runtime.ts';
|
|
29
30
|
export type { NativeAccountMetadataPatch, NativeAccountSnapshot, NativeAccountView, } from './native-account-view.ts';
|