@opengeni/config 1.2.2-canary.5 → 1.3.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/claude-subscription-capacity.d.ts +9 -0
- package/dist/claude-subscription-oauth.d.ts +17 -0
- package/dist/claude-subscription-usage.d.ts +13 -0
- package/dist/credit-promotions.d.ts +25 -0
- package/dist/index.d.ts +781 -12
- package/dist/index.js +2368 -595
- package/dist/index.js.map +1 -1
- package/dist/managed-user-admission.d.ts +2 -0
- package/dist/subscription-account-selection.d.ts +17 -0
- package/package.json +4 -4
- package/src/claude-subscription-capacity.ts +129 -0
- package/src/claude-subscription-oauth.ts +33 -0
- package/src/claude-subscription-usage.ts +328 -0
- package/src/credit-promotions.ts +68 -0
- package/src/index.ts +2248 -278
- package/src/managed-user-admission.ts +11 -0
- package/src/subscription-account-selection.ts +36 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClaudeSubscriptionUsage, ClaudeUsageWindow } from "@opengeni/contracts";
|
|
2
|
+
/** Evaluate provider-reported plan capacity and its explicitly allowed paid fallback. */
|
|
3
|
+
export declare function claudeSubscriptionCapacity(usage: ClaudeSubscriptionUsage, upstreamModelId: string, now: Date, options?: {
|
|
4
|
+
allowOverage?: boolean;
|
|
5
|
+
}): {
|
|
6
|
+
available: boolean;
|
|
7
|
+
nextCheckAt: Date | null;
|
|
8
|
+
blockingWindows: ClaudeUsageWindow["id"][];
|
|
9
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Claude Code 2.1.285's installed OAuth flow; model calls and profile reads only. */
|
|
3
|
+
export declare const CLAUDE_OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
4
|
+
export declare const CLAUDE_OAUTH_AUTHORIZE_URL = "https://claude.com/cai/oauth/authorize";
|
|
5
|
+
export declare const CLAUDE_OAUTH_TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
6
|
+
export declare const CLAUDE_OAUTH_REDIRECT_URL = "https://platform.claude.com/oauth/code/callback";
|
|
7
|
+
export declare const CLAUDE_OAUTH_SCOPES: readonly ["user:inference", "user:profile"];
|
|
8
|
+
export declare const ClaudeOAuthTokenResponse: z.ZodObject<{
|
|
9
|
+
access_token: z.ZodString;
|
|
10
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
11
|
+
expires_in: z.ZodNumber;
|
|
12
|
+
scope: z.ZodString;
|
|
13
|
+
}, z.core.$loose>;
|
|
14
|
+
export declare function claudeAuthorizationUrl(input: {
|
|
15
|
+
challenge: string;
|
|
16
|
+
state: string;
|
|
17
|
+
}): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ClaudeSubscriptionUsage, type ClaudeUsageWindow, type ClaudeUsageRequestStatus } from "@opengeni/contracts";
|
|
2
|
+
export type ClaudeUsageObservation = {
|
|
3
|
+
windows: ClaudeUsageWindow[];
|
|
4
|
+
observedAt: string;
|
|
5
|
+
source: "response_headers" | "provider";
|
|
6
|
+
requestStatus?: ClaudeUsageRequestStatus | null;
|
|
7
|
+
requestRestrictions?: ClaudeUsageRequestStatus[];
|
|
8
|
+
};
|
|
9
|
+
export declare function parseClaudeUsageHeaders(headers: Headers, now?: Date, upstreamModelId?: string): ClaudeUsageObservation | null;
|
|
10
|
+
export declare function parseClaudeUsageResponse(value: unknown, now?: Date): ClaudeUsageObservation | null;
|
|
11
|
+
export declare function emptyClaudeUsage(credentialVersion: number | null): ClaudeSubscriptionUsage;
|
|
12
|
+
/** Preserve omitted windows and reject observations older than their individual window. */
|
|
13
|
+
export declare function mergeClaudeUsage(current: ClaudeSubscriptionUsage, observation: ClaudeUsageObservation): ClaudeSubscriptionUsage;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PromotionalCreditScope } from "@opengeni/contracts";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** Operator configuration only. Keys are Stripe coupon IDs, never customer account IDs. */
|
|
4
|
+
export declare const CreditPromotionPolicy: z.ZodObject<{
|
|
5
|
+
defaultModelIds: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
|
|
6
|
+
signupModelIds: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
|
|
7
|
+
offers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
8
|
+
label: z.ZodString;
|
|
9
|
+
eligibleModelIds: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
|
|
10
|
+
}, z.core.$strict>>>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const EnvCreditPromotionPolicy: z.ZodPreprocess<z.ZodDefault<z.ZodObject<{
|
|
13
|
+
defaultModelIds: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
|
|
14
|
+
signupModelIds: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
|
|
15
|
+
offers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
16
|
+
label: z.ZodString;
|
|
17
|
+
eligibleModelIds: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
|
|
18
|
+
}, z.core.$strict>>>;
|
|
19
|
+
}, z.core.$strict>>>;
|
|
20
|
+
export declare function signupCreditModelIds(settings: {
|
|
21
|
+
creditPromotionPolicy: z.infer<typeof CreditPromotionPolicy>;
|
|
22
|
+
}): string[] | undefined;
|
|
23
|
+
export declare function promotionalCreditScope(settings: {
|
|
24
|
+
creditPromotionPolicy: z.infer<typeof CreditPromotionPolicy>;
|
|
25
|
+
}, couponId: string): PromotionalCreditScope | undefined;
|