@cortexkit/anthropic-auth-core 2.9.0 → 2.10.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/billing.d.ts +23 -0
- package/dist/cachekeep-registry.d.ts +1 -1
- package/dist/cachekeep.d.ts +7 -0
- package/dist/dump.d.ts +3 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2534 -1603
- 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 +29 -4
- 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/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 +13 -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/native-custody.d.ts +0 -2
- package/dist/relay.d.ts +2 -0
- package/dist/routing-peek.d.ts +15 -0
- package/dist/sticky-routing.d.ts +12 -0
- package/dist/stream-completion.d.ts +26 -0
- package/package.json +3 -3
|
@@ -0,0 +1,23 @@
|
|
|
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 AnthropicBillingRequest = Omit<BillingReport, 'kind' | 'attemptId' | 'provider' | 'outcome' | 'status' | 'providerRequestId' | 'providerResponseId' | 'usage' | 'usageByModel'> & {
|
|
6
|
+
attemptId?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Iteration usage is the billed sum; top-level usage can describe only the last model. */
|
|
9
|
+
export declare function anthropicBillingUsage(raw: Record<string, unknown>): {
|
|
10
|
+
usage: BillingUsage;
|
|
11
|
+
usageByModel?: BillingReport['usageByModel'];
|
|
12
|
+
};
|
|
13
|
+
export declare function reportAnthropicBillingFailure(input: AnthropicBillingRequest): void;
|
|
14
|
+
/** One collector per physical upstream response, including relay responses. */
|
|
15
|
+
export declare function createAnthropicBillingObserver(input: AnthropicBillingRequest, status: number, headers: Headers, sse?: boolean): {
|
|
16
|
+
push: (chunk: Uint8Array) => void;
|
|
17
|
+
finish(): void;
|
|
18
|
+
};
|
|
19
|
+
/** Observe only consumed response bytes: no tee, background drain or prompt logging. */
|
|
20
|
+
export declare function observeAnthropicBillingResponse(input: AnthropicBillingRequest, response: Response): Response;
|
|
21
|
+
/** Call only at the physical send boundary, after authorization and local admission. */
|
|
22
|
+
export declare function withAnthropicBilling(input: AnthropicBillingRequest, send: () => Promise<Response>): Promise<Response>;
|
|
23
|
+
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
1
|
import type { CacheWarmStopReason } from "./internal-types/routing-accessor/index.js";
|
|
2
2
|
import type { AccountStorage } from './accounts.ts';
|
|
3
|
+
import { type AnthropicBillingRequest } 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';
|
|
@@ -195,6 +196,7 @@ export declare class CacheKeepManager {
|
|
|
195
196
|
constructor(options: {
|
|
196
197
|
loadStorage: () => Promise<AccountStorage | null>;
|
|
197
198
|
fetchImpl?: typeof fetch;
|
|
199
|
+
billingRequest?: (target: CacheKeepTarget, attempt: CacheKeepPrewarmAttempt) => AnthropicBillingRequest | undefined;
|
|
198
200
|
now?: () => number;
|
|
199
201
|
prewarmTimeoutMs?: number;
|
|
200
202
|
setIntervalImpl?: typeof globalThis.setInterval;
|
|
@@ -202,6 +204,11 @@ export declare class CacheKeepManager {
|
|
|
202
204
|
setTimeoutImpl?: typeof globalThis.setTimeout;
|
|
203
205
|
clearTimeoutImpl?: typeof globalThis.clearTimeout;
|
|
204
206
|
prepareHeaders?: (headers: Headers, target: CacheKeepTarget, attempt: CacheKeepPrewarmAttempt) => Promise<Headers | undefined> | Headers | undefined;
|
|
207
|
+
/** Pure in-memory route lookup; an unknown answer keeps the target. */
|
|
208
|
+
peekRoutingAccount?: (target: Readonly<CacheKeepTarget>, route: {
|
|
209
|
+
sessionId: string;
|
|
210
|
+
modelId?: string;
|
|
211
|
+
}) => string | undefined;
|
|
205
212
|
/** Optionally reauthorize a replayable prewarm after a genuine 401.
|
|
206
213
|
* Return headers only for a verified newer version of the same account;
|
|
207
214
|
* onResponse observes only the final physical attempt. */
|
package/dist/dump.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderErrorSummary } from './provider-error.ts';
|
|
2
|
+
import { type IncompleteStreamDiagnostics } from './stream-completion.ts';
|
|
2
3
|
type DumpHeaders = ConstructorParameters<typeof Headers>[0];
|
|
3
4
|
export declare const CLAUDE_DUMP_COMMAND_NAME = "claude-dump";
|
|
4
5
|
export type DumpCommandAction = {
|
|
@@ -81,7 +82,7 @@ export type ReplyTextEdge = {
|
|
|
81
82
|
export declare function createDumpResponseObserver(handle: DumpHandle | null, status: number): {
|
|
82
83
|
observe(event: Record<string, unknown>): void;
|
|
83
84
|
replyTextEdges: () => ReplyTextEdge[] | undefined;
|
|
84
|
-
fail(): void;
|
|
85
|
+
fail(diagnostics?: IncompleteStreamDiagnostics): void;
|
|
85
86
|
finish(): Promise<void>;
|
|
86
87
|
};
|
|
87
88
|
export declare function dumpResponseArtifact(handle: DumpHandle | null, input: {
|
|
@@ -90,5 +91,6 @@ export declare function dumpResponseArtifact(handle: DumpHandle | null, input: {
|
|
|
90
91
|
complete?: boolean;
|
|
91
92
|
provider_error?: ProviderErrorSummary['provider_error'];
|
|
92
93
|
reply_text_edges?: readonly ReplyTextEdge[];
|
|
94
|
+
incomplete_stream?: IncompleteStreamDiagnostics;
|
|
93
95
|
}): Promise<void>;
|
|
94
96
|
export {};
|
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,7 @@ 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';
|
|
102
104
|
export * from './server-fallback-usage.ts';
|
|
103
105
|
export * from './session-cache-activity.ts';
|
|
104
106
|
export * from './session-cache-policy.ts';
|
|
@@ -110,5 +112,7 @@ export * from './state-layout-errors.ts';
|
|
|
110
112
|
export * from './state-layout-paths.ts';
|
|
111
113
|
export * from './state-layout-restore.ts';
|
|
112
114
|
export * from './sticky-routing.ts';
|
|
115
|
+
export type { IncompleteStreamDiagnostics } from './stream-completion.ts';
|
|
116
|
+
export { copyStreamResponseTiming, createAnthropicStreamCompletion, guardAnthropicStreamResponse, } from './stream-completion.ts';
|
|
113
117
|
export * from './thinking-binding.ts';
|
|
114
118
|
export * from './turn-end-note.ts';
|