@cortexkit/anthropic-auth-core 2.9.1 → 2.10.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/billing.d.ts +30 -0
- package/dist/cachekeep-registry.d.ts +1 -1
- package/dist/cachekeep.d.ts +24 -1
- package/dist/constants.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2497 -1852
- package/dist/internal-types/claustrum/enrollment.d.ts +25 -4
- package/dist/internal-types/claustrum/index.d.ts +1 -1
- package/dist/internal-types/setup/command-error.d.ts +1 -1
- package/dist/internal-types/setup/enroll.d.ts +2 -2
- package/dist/internal-types/setup/index.d.ts +1 -1
- package/dist/internal-types/setup/types.d.ts +12 -1
- package/dist/message-threads.d.ts +2 -0
- package/dist/models.d.ts +4 -1
- package/dist/native-account-runtime.d.ts +2 -0
- package/dist/relay.d.ts +2 -0
- package/dist/routing-peek.d.ts +15 -0
- package/dist/routing-reports.d.ts +7 -0
- package/dist/sticky-routing.d.ts +12 -0
- package/dist/stream-completion.d.ts +3 -1
- package/package.json +3 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type BillingUsage, type ReportRoutingInput } from "./internal-types/routing-accessor/index.js";
|
|
2
|
+
type BillingReport = Extract<ReportRoutingInput, {
|
|
3
|
+
kind: 'billing';
|
|
4
|
+
}>;
|
|
5
|
+
export type AnthropicBillingWarming = NonNullable<NonNullable<BillingReport['cache']>['warming']>;
|
|
6
|
+
export type AnthropicBillingRequest = Omit<BillingReport, 'kind' | 'attemptId' | 'provider' | 'outcome' | 'status' | 'providerRequestId' | 'providerResponseId' | 'usage' | 'usageByModel'> & {
|
|
7
|
+
attemptId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Read once a completed response finishes, after the host has let CacheKeep
|
|
10
|
+
* track or refuse it, so the report carries the keep-warm state that request
|
|
11
|
+
* produced. Must not wait or do I/O; `undefined` leaves `cache.warming` out.
|
|
12
|
+
*/
|
|
13
|
+
cacheWarming?: () => AnthropicBillingWarming | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** Iteration usage is the billed sum; top-level usage can describe only the last model. */
|
|
16
|
+
export declare function anthropicBillingUsage(raw: Record<string, unknown>): {
|
|
17
|
+
usage: BillingUsage;
|
|
18
|
+
usageByModel?: BillingReport['usageByModel'];
|
|
19
|
+
};
|
|
20
|
+
export declare function reportAnthropicBillingFailure(input: AnthropicBillingRequest): void;
|
|
21
|
+
/** One collector per physical upstream response, including relay responses. */
|
|
22
|
+
export declare function createAnthropicBillingObserver(input: AnthropicBillingRequest, status: number, headers: Headers, sse?: boolean): {
|
|
23
|
+
push: (chunk: Uint8Array) => void;
|
|
24
|
+
finish(): void;
|
|
25
|
+
};
|
|
26
|
+
/** Observe only consumed response bytes: no tee, background drain or prompt logging. */
|
|
27
|
+
export declare function observeAnthropicBillingResponse(input: AnthropicBillingRequest, response: Response): Response;
|
|
28
|
+
/** Call only at the physical send boundary, after authorization and local admission. */
|
|
29
|
+
export declare function withAnthropicBilling(input: AnthropicBillingRequest, send: () => Promise<Response>): Promise<Response>;
|
|
30
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import * as nodePath from 'node:path';
|
|
|
2
2
|
import { type HolderLiveness } from './holder-registry.ts';
|
|
3
3
|
import { type OwnerOnlyOptions } from './owner-only.ts';
|
|
4
4
|
export declare const CACHE_KEEP_REGISTRY_LEASE_MS: number;
|
|
5
|
-
export declare const CACHE_KEEP_STOP_REASONS: readonly ['cost-cap', 'schedule', 'evicted', 'policy-refused', 'retries-exhausted', 'session-forgotten', 'disabled'];
|
|
5
|
+
export declare const CACHE_KEEP_STOP_REASONS: readonly ['cost-cap', 'schedule', 'evicted', 'policy-refused', 'routing-moved', 'retries-exhausted', 'session-forgotten', 'disabled'];
|
|
6
6
|
export type CacheKeepStopReason = (typeof CACHE_KEEP_STOP_REASONS)[number];
|
|
7
7
|
export type CacheKeepTrackedSession = {
|
|
8
8
|
id: string;
|
package/dist/cachekeep.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CacheWarmStopReason } from "./internal-types/routing-accessor/index.js";
|
|
2
2
|
import type { AccountStorage } from './accounts.ts';
|
|
3
|
+
import { type AnthropicBillingRequest, type AnthropicBillingWarming } from './billing.ts';
|
|
3
4
|
import { type CacheKeepFailure } from './cachekeep-failure.ts';
|
|
4
5
|
import type { CacheKeepStopReason, CacheKeepTrackedSession } from './cachekeep-registry.ts';
|
|
5
6
|
import { type NativeAccountRefusalReason } from './native-account-refusal.ts';
|
|
@@ -186,6 +187,7 @@ export declare class CacheKeepManager {
|
|
|
186
187
|
private readonly targets;
|
|
187
188
|
private readonly immediateTargets;
|
|
188
189
|
private readonly stoppedSessions;
|
|
190
|
+
private readonly warmingRecords;
|
|
189
191
|
private timer;
|
|
190
192
|
private dueTimer;
|
|
191
193
|
private tickPromise;
|
|
@@ -195,6 +197,7 @@ export declare class CacheKeepManager {
|
|
|
195
197
|
constructor(options: {
|
|
196
198
|
loadStorage: () => Promise<AccountStorage | null>;
|
|
197
199
|
fetchImpl?: typeof fetch;
|
|
200
|
+
billingRequest?: (target: CacheKeepTarget, attempt: CacheKeepPrewarmAttempt) => AnthropicBillingRequest | undefined;
|
|
198
201
|
now?: () => number;
|
|
199
202
|
prewarmTimeoutMs?: number;
|
|
200
203
|
setIntervalImpl?: typeof globalThis.setInterval;
|
|
@@ -202,6 +205,11 @@ export declare class CacheKeepManager {
|
|
|
202
205
|
setTimeoutImpl?: typeof globalThis.setTimeout;
|
|
203
206
|
clearTimeoutImpl?: typeof globalThis.clearTimeout;
|
|
204
207
|
prepareHeaders?: (headers: Headers, target: CacheKeepTarget, attempt: CacheKeepPrewarmAttempt) => Promise<Headers | undefined> | Headers | undefined;
|
|
208
|
+
/** Pure in-memory route lookup; an unknown answer keeps the target. */
|
|
209
|
+
peekRoutingAccount?: (target: Readonly<CacheKeepTarget>, route: {
|
|
210
|
+
sessionId: string;
|
|
211
|
+
modelId?: string;
|
|
212
|
+
}) => string | undefined;
|
|
205
213
|
/** Optionally reauthorize a replayable prewarm after a genuine 401.
|
|
206
214
|
* Return headers only for a verified newer version of the same account;
|
|
207
215
|
* onResponse observes only the final physical attempt. */
|
|
@@ -285,6 +293,21 @@ export declare class CacheKeepManager {
|
|
|
285
293
|
*/
|
|
286
294
|
trackedPolicyState(id: string): Readonly<CacheKeepPolicyState> | undefined;
|
|
287
295
|
hasPlannedTarget(id: string): boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Whether keep-warm tracks a session, read from memory only (no lock, no
|
|
298
|
+
* storage). `on: true` means a live target holds the session's cache. A stop
|
|
299
|
+
* carries its reason only when billing reports accept that reason
|
|
300
|
+
* (`isCacheWarmStopReason`); other stops report `on: false` alone.
|
|
301
|
+
* `undefined` means this manager has seen nothing that decides it.
|
|
302
|
+
*/
|
|
303
|
+
warming(id: string): AnthropicBillingWarming | undefined;
|
|
304
|
+
/**
|
|
305
|
+
* Record that a session's policy or settings keep warming off, for a host
|
|
306
|
+
* that refuses to track before reaching this manager (an API-key route,
|
|
307
|
+
* local keep-warm disabled, or a subagent without subagent warming).
|
|
308
|
+
*/
|
|
309
|
+
recordWarmingOff(id: string): void;
|
|
310
|
+
private setWarmingRecord;
|
|
288
311
|
updateSubagent(id: string, isSubagent: boolean): void;
|
|
289
312
|
/** An old response cannot price or reset a newer captured request. */
|
|
290
313
|
recordAcceptedUsage(id: string, bodyText: string, usage: AcceptedCacheUsage): void;
|
package/dist/constants.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare const CCH_SALT = "59cf53e54c78";
|
|
|
26
26
|
export declare const CCH_POSITIONS: number[];
|
|
27
27
|
export declare const CLAUDE_CODE_VERSION = "2.1.302";
|
|
28
28
|
export declare const CLAUDE_CODE_ENTRYPOINT = "cli";
|
|
29
|
+
export declare const CLAUDE_CODE_ACCEPT_ENCODING = "gzip, deflate, br, zstd";
|
|
29
30
|
export declare const CLAUDE_CODE_STAINLESS_PACKAGE_VERSION = "0.128.0";
|
|
30
31
|
export declare const CLAUDE_CODE_STAINLESS_RUNTIME_VERSION = "v26.3.0";
|
|
31
32
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { CommandResult, CommandRunner, HostDetection, OpenCodeGeneration, P
|
|
|
4
4
|
export { assertHostsStopped, createProcessFence, runSetup, setupEnrollment, setupUsage, } from "./internal-types/setup/index.js";
|
|
5
5
|
export * from './accounts.ts';
|
|
6
6
|
export * from './auth.ts';
|
|
7
|
+
export * from './billing.ts';
|
|
7
8
|
export * from './cache1h.ts';
|
|
8
9
|
export * from './cachekeep.ts';
|
|
9
10
|
export * from './cachekeep-failure.ts';
|
|
@@ -99,6 +100,8 @@ export * from './request-abort.ts';
|
|
|
99
100
|
export * from './request-gzip.ts';
|
|
100
101
|
export * from './request-history.ts';
|
|
101
102
|
export * from './routing.ts';
|
|
103
|
+
export * from './routing-peek.ts';
|
|
104
|
+
export * from './routing-reports.ts';
|
|
102
105
|
export * from './server-fallback-usage.ts';
|
|
103
106
|
export * from './session-cache-activity.ts';
|
|
104
107
|
export * from './session-cache-policy.ts';
|