tuxevil-rotator 3.4.0 → 3.6.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/CHANGELOG.md +20 -0
- package/README.md +4 -1
- package/package.json +1 -1
- package/src/account-identity.ts +96 -0
- package/src/compat/model-specs.ts +93 -27
- package/src/compat.ts +147 -20
- package/src/config-defaults.ts +2 -1
- package/src/providers/google-antigravity/catalog.ts +15 -4
- package/src/providers/google-antigravity/dynamic-catalog.ts +602 -0
- package/src/providers/google-antigravity/quota.ts +81 -6
- package/src/providers/google-antigravity/translators.ts +84 -27
- package/src/proxy.ts +26 -4
- package/src/rotator.ts +189 -97
- package/src/spend-logger.ts +3 -21
- package/src/static/dashboard.js +10 -7
- package/src/types.ts +86 -15
- package/src/validators.ts +6 -0
package/src/types.ts
CHANGED
|
@@ -142,8 +142,8 @@ export interface Config {
|
|
|
142
142
|
streamRecoveryMaxRetries?: number;
|
|
143
143
|
// Prompt compression mode ("off" | "lite" | "rtk" | "rtk+lite").
|
|
144
144
|
compressionMode?: "off" | "lite" | "rtk" | "rtk+lite";
|
|
145
|
-
//
|
|
146
|
-
// matched case-insensitively
|
|
145
|
+
// Partially override per-model specs used by the compat layer. Keys are model id
|
|
146
|
+
// substrings matched case-insensitively; omitted fields inherit effective defaults.
|
|
147
147
|
modelSpecs?: Record<string, ModelSpecConfig>;
|
|
148
148
|
// Override model-id aliases used to translate the operator-facing name
|
|
149
149
|
// (e.g. "gemini-3.1-pro-high") to the upstream Antigravity name
|
|
@@ -207,16 +207,28 @@ export interface GoogleQuotaResponse {
|
|
|
207
207
|
remainingFraction?: number;
|
|
208
208
|
resetTime?: string;
|
|
209
209
|
};
|
|
210
|
+
displayName?: string;
|
|
211
|
+
maxTokens?: number;
|
|
212
|
+
maxOutputTokens?: number;
|
|
213
|
+
thinkingBudget?: number;
|
|
214
|
+
minThinkingBudget?: number;
|
|
215
|
+
supportsThinking?: boolean;
|
|
216
|
+
supportsImages?: boolean;
|
|
217
|
+
supportsVideo?: boolean;
|
|
210
218
|
}
|
|
211
219
|
>;
|
|
220
|
+
defaultAgentModelId?: string;
|
|
221
|
+
tieredModelIds?: Record<string, string[]>;
|
|
212
222
|
}
|
|
213
223
|
|
|
214
224
|
// Per-model thinking/output spec used by the compat layer.
|
|
215
225
|
// Operators can override defaults via the `modelSpecs` field in accounts.json.
|
|
216
226
|
export interface ModelSpecConfig {
|
|
217
|
-
maxOutputTokens
|
|
218
|
-
thinkingBudget
|
|
219
|
-
|
|
227
|
+
maxOutputTokens?: number;
|
|
228
|
+
thinkingBudget?: number; // -1 = adaptive (model decides), >=0 = fixed
|
|
229
|
+
minThinkingBudget?: number;
|
|
230
|
+
isThinking?: boolean;
|
|
231
|
+
contextWindow?: number;
|
|
220
232
|
}
|
|
221
233
|
|
|
222
234
|
// Per-model quota info for an account
|
|
@@ -279,6 +291,14 @@ export const QUOTA_MODEL_KEYS: Record<
|
|
|
279
291
|
},
|
|
280
292
|
};
|
|
281
293
|
|
|
294
|
+
const STATIC_ANTIGRAVITY_MODEL_IDS = new Set(
|
|
295
|
+
Object.values(QUOTA_MODEL_KEYS).flatMap(({ altKeys }) => altKeys),
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
export function isStaticAntigravityModel(model: string): boolean {
|
|
299
|
+
return STATIC_ANTIGRAVITY_MODEL_IDS.has(model.toLowerCase());
|
|
300
|
+
}
|
|
301
|
+
|
|
282
302
|
// Map request model names to quota model keys (family buckets).
|
|
283
303
|
export function resolveQuotaModelKey(requestModel: string): string | null {
|
|
284
304
|
const lower = requestModel.toLowerCase();
|
|
@@ -436,7 +456,22 @@ export interface PersistedSafetyState {
|
|
|
436
456
|
}>;
|
|
437
457
|
}
|
|
438
458
|
|
|
459
|
+
export interface PersistedDynamicModelOwnership {
|
|
460
|
+
scopedModels: string[];
|
|
461
|
+
accounts: Record<
|
|
462
|
+
string,
|
|
463
|
+
{
|
|
464
|
+
credentialGenerationFingerprint: string;
|
|
465
|
+
models: string[];
|
|
466
|
+
}
|
|
467
|
+
>;
|
|
468
|
+
}
|
|
469
|
+
|
|
439
470
|
export interface PersistedState {
|
|
471
|
+
// Historical dynamic model IDs mapped to their shared quota pools.
|
|
472
|
+
dynamicModelQuotaPools?: Record<string, string>;
|
|
473
|
+
// Exact account ownership for dynamically discovered model IDs.
|
|
474
|
+
dynamicModelOwnership?: PersistedDynamicModelOwnership;
|
|
440
475
|
// Per-model active account index
|
|
441
476
|
modelAccounts: Record<string, number>;
|
|
442
477
|
// Per-model request count on the active account
|
|
@@ -691,16 +726,15 @@ export interface TokenUsageData {
|
|
|
691
726
|
};
|
|
692
727
|
}
|
|
693
728
|
|
|
729
|
+
export interface ModelPricing {
|
|
730
|
+
inputPer1M: number;
|
|
731
|
+
outputPer1M: number;
|
|
732
|
+
cachingPer1M?: number;
|
|
733
|
+
cachingStoragePer1MPerHour?: number;
|
|
734
|
+
}
|
|
735
|
+
|
|
694
736
|
// Pricing per 1M tokens (USD) — what these would cost on paid APIs
|
|
695
|
-
export const MODEL_PRICING: Record<
|
|
696
|
-
string,
|
|
697
|
-
{
|
|
698
|
-
inputPer1M: number;
|
|
699
|
-
outputPer1M: number;
|
|
700
|
-
cachingPer1M?: number;
|
|
701
|
-
cachingStoragePer1MPerHour?: number;
|
|
702
|
-
}
|
|
703
|
-
> = {
|
|
737
|
+
export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
704
738
|
"claude-opus-4-6-thinking": { inputPer1M: 5.0, outputPer1M: 25.0 },
|
|
705
739
|
"claude-sonnet-4-6": { inputPer1M: 3.0, outputPer1M: 15.0 },
|
|
706
740
|
"gemini-3.1-pro": { inputPer1M: 2.0, outputPer1M: 12.0 },
|
|
@@ -823,6 +857,41 @@ export const MODEL_PRICING: Record<
|
|
|
823
857
|
|
|
824
858
|
};
|
|
825
859
|
|
|
860
|
+
/**
|
|
861
|
+
* Resolves pricing for a model, using exact lookup first and dynamic family fallbacks
|
|
862
|
+
* for newly released models without manual pricing entries.
|
|
863
|
+
*/
|
|
864
|
+
export function getModelPricing(model: string): ModelPricing | undefined {
|
|
865
|
+
if (!model) return undefined;
|
|
866
|
+
if (MODEL_PRICING[model]) return MODEL_PRICING[model];
|
|
867
|
+
const lower = model.toLowerCase();
|
|
868
|
+
if (MODEL_PRICING[lower]) return MODEL_PRICING[lower];
|
|
869
|
+
// Dynamic family fallbacks for unseen future models. Keep provider and
|
|
870
|
+
// version checks explicit so an unrelated model containing "flash" cannot
|
|
871
|
+
// inherit Gemini pricing.
|
|
872
|
+
if (lower.includes("claude") && lower.includes("opus")) {
|
|
873
|
+
return MODEL_PRICING["claude-opus-4-6-thinking"];
|
|
874
|
+
}
|
|
875
|
+
if (lower.includes("claude") && lower.includes("sonnet")) {
|
|
876
|
+
return MODEL_PRICING["claude-sonnet-4-6"];
|
|
877
|
+
}
|
|
878
|
+
if (lower.includes("gemini")) {
|
|
879
|
+
if (lower.includes("3.8") && lower.includes("flash")) {
|
|
880
|
+
return MODEL_PRICING["gemini-3.8-flash-high"];
|
|
881
|
+
}
|
|
882
|
+
if (lower.includes("3.7") && lower.includes("flash")) {
|
|
883
|
+
return MODEL_PRICING["gemini-3.7-flash-tiered"];
|
|
884
|
+
}
|
|
885
|
+
if (lower.includes("3.6") && lower.includes("flash")) {
|
|
886
|
+
return MODEL_PRICING["gemini-3.6-flash-high"];
|
|
887
|
+
}
|
|
888
|
+
if (lower.includes("flash")) return MODEL_PRICING["gemini-3-flash"];
|
|
889
|
+
if (lower.includes("pro")) return MODEL_PRICING["gemini-3.1-pro"];
|
|
890
|
+
}
|
|
891
|
+
if (lower.includes("gpt-oss")) return MODEL_PRICING["gpt-oss-120b-medium"];
|
|
892
|
+
return undefined;
|
|
893
|
+
}
|
|
894
|
+
|
|
826
895
|
// Which Ollama Cloud models respond on which subscription tiers, verified
|
|
827
896
|
// 2026-08-30 via scripts/verify_ollama_models.ts (/api/tags discovery +
|
|
828
897
|
// /api/chat probes: HTTP 200 = free, HTTP 402 = subscription-only).
|
|
@@ -906,9 +975,11 @@ export const ANTIGRAVITY_VERSION =
|
|
|
906
975
|
rotatorEnv("ANTIGRAVITY_VERSION") ||
|
|
907
976
|
process.env.PI_AI_ANTIGRAVITY_VERSION ||
|
|
908
977
|
"2.11.0";
|
|
978
|
+
export const DEFAULT_ANTIGRAVITY_USER_AGENT =
|
|
979
|
+
`antigravity/ide/${ANTIGRAVITY_VERSION} (aidev_client; os_type=darwin; arch=arm64)`;
|
|
909
980
|
export const QUOTA_USER_AGENT =
|
|
910
981
|
rotatorEnv("QUOTA_USER_AGENT") ||
|
|
911
|
-
|
|
982
|
+
DEFAULT_ANTIGRAVITY_USER_AGENT;
|
|
912
983
|
export const REQUEST_USER_AGENT =
|
|
913
984
|
rotatorEnv("REQUEST_USER_AGENT") || QUOTA_USER_AGENT;
|
|
914
985
|
export const REQUEST_GOOG_API_CLIENT =
|
package/src/validators.ts
CHANGED
|
@@ -173,9 +173,15 @@ export function validateConfig(value: unknown): ValidationResult<Config> {
|
|
|
173
173
|
if (spec.thinkingBudget !== undefined && (typeof spec.thinkingBudget !== "number" || !Number.isFinite(spec.thinkingBudget))) {
|
|
174
174
|
errors.push(`config.modelSpecs.${key}.thinkingBudget must be a number`);
|
|
175
175
|
}
|
|
176
|
+
if (spec.minThinkingBudget !== undefined && !isNonNegativeNumber(spec.minThinkingBudget)) {
|
|
177
|
+
errors.push(`config.modelSpecs.${key}.minThinkingBudget must be a non-negative number`);
|
|
178
|
+
}
|
|
176
179
|
if (spec.isThinking !== undefined && typeof spec.isThinking !== "boolean") {
|
|
177
180
|
errors.push(`config.modelSpecs.${key}.isThinking must be a boolean`);
|
|
178
181
|
}
|
|
182
|
+
if (spec.contextWindow !== undefined && !isPositiveNumber(spec.contextWindow)) {
|
|
183
|
+
errors.push(`config.modelSpecs.${key}.contextWindow must be a positive number`);
|
|
184
|
+
}
|
|
179
185
|
}
|
|
180
186
|
}
|
|
181
187
|
}
|