opencode-antigravity-auth-mf 11.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/LICENSE +21 -0
- package/README.md +630 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/src/antigravity/oauth.d.ts +31 -0
- package/dist/src/antigravity/oauth.d.ts.map +1 -0
- package/dist/src/antigravity/oauth.js +168 -0
- package/dist/src/antigravity/oauth.js.map +1 -0
- package/dist/src/constants.d.ts +99 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +135 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
- package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/cache.js +71 -0
- package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
- package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/checker.js +237 -0
- package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/constants.d.ts +9 -0
- package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/constants.js +23 -0
- package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
- package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/index.js +125 -0
- package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
- package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/types.js +1 -0
- package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +86 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -0
- package/dist/src/plugin/accounts.js +609 -0
- package/dist/src/plugin/accounts.js.map +1 -0
- package/dist/src/plugin/auth.d.ts +21 -0
- package/dist/src/plugin/auth.d.ts.map +1 -0
- package/dist/src/plugin/auth.js +46 -0
- package/dist/src/plugin/auth.js.map +1 -0
- package/dist/src/plugin/cache/index.d.ts +5 -0
- package/dist/src/plugin/cache/index.d.ts.map +1 -0
- package/dist/src/plugin/cache/index.js +5 -0
- package/dist/src/plugin/cache/index.js.map +1 -0
- package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/src/plugin/cache/signature-cache.js +375 -0
- package/dist/src/plugin/cache/signature-cache.js.map +1 -0
- package/dist/src/plugin/cache.d.ts +44 -0
- package/dist/src/plugin/cache.d.ts.map +1 -0
- package/dist/src/plugin/cache.js +200 -0
- package/dist/src/plugin/cache.js.map +1 -0
- package/dist/src/plugin/cli.d.ts +19 -0
- package/dist/src/plugin/cli.d.ts.map +1 -0
- package/dist/src/plugin/cli.js +59 -0
- package/dist/src/plugin/cli.js.map +1 -0
- package/dist/src/plugin/config/index.d.ts +16 -0
- package/dist/src/plugin/config/index.d.ts.map +1 -0
- package/dist/src/plugin/config/index.js +16 -0
- package/dist/src/plugin/config/index.js.map +1 -0
- package/dist/src/plugin/config/loader.d.ts +37 -0
- package/dist/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/src/plugin/config/loader.js +206 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +411 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +339 -0
- package/dist/src/plugin/config/schema.js.map +1 -0
- package/dist/src/plugin/core/streaming/index.d.ts +3 -0
- package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/index.js +3 -0
- package/dist/src/plugin/core/streaming/index.js.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.js +255 -0
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
- package/dist/src/plugin/core/streaming/types.d.ts +35 -0
- package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/types.js +1 -0
- package/dist/src/plugin/core/streaming/types.js.map +1 -0
- package/dist/src/plugin/debug.d.ts +68 -0
- package/dist/src/plugin/debug.d.ts.map +1 -0
- package/dist/src/plugin/debug.js +325 -0
- package/dist/src/plugin/debug.js.map +1 -0
- package/dist/src/plugin/errors.d.ts +28 -0
- package/dist/src/plugin/errors.d.ts.map +1 -0
- package/dist/src/plugin/errors.js +42 -0
- package/dist/src/plugin/errors.js.map +1 -0
- package/dist/src/plugin/image-saver.d.ts +25 -0
- package/dist/src/plugin/image-saver.d.ts.map +1 -0
- package/dist/src/plugin/image-saver.js +86 -0
- package/dist/src/plugin/image-saver.js.map +1 -0
- package/dist/src/plugin/logger.d.ts +54 -0
- package/dist/src/plugin/logger.d.ts.map +1 -0
- package/dist/src/plugin/logger.js +120 -0
- package/dist/src/plugin/logger.js.map +1 -0
- package/dist/src/plugin/project.d.ts +33 -0
- package/dist/src/plugin/project.d.ts.map +1 -0
- package/dist/src/plugin/project.js +234 -0
- package/dist/src/plugin/project.js.map +1 -0
- package/dist/src/plugin/recovery/constants.d.ts +22 -0
- package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/src/plugin/recovery/constants.js +43 -0
- package/dist/src/plugin/recovery/constants.js.map +1 -0
- package/dist/src/plugin/recovery/index.d.ts +12 -0
- package/dist/src/plugin/recovery/index.d.ts.map +1 -0
- package/dist/src/plugin/recovery/index.js +12 -0
- package/dist/src/plugin/recovery/index.js.map +1 -0
- package/dist/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/src/plugin/recovery/storage.js +354 -0
- package/dist/src/plugin/recovery/storage.js.map +1 -0
- package/dist/src/plugin/recovery/types.d.ts +116 -0
- package/dist/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/src/plugin/recovery/types.js +6 -0
- package/dist/src/plugin/recovery/types.js.map +1 -0
- package/dist/src/plugin/recovery.d.ts +61 -0
- package/dist/src/plugin/recovery.d.ts.map +1 -0
- package/dist/src/plugin/recovery.js +376 -0
- package/dist/src/plugin/recovery.js.map +1 -0
- package/dist/src/plugin/refresh-queue.d.ts +101 -0
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/src/plugin/refresh-queue.js +244 -0
- package/dist/src/plugin/refresh-queue.js.map +1 -0
- package/dist/src/plugin/request-helpers.d.ts +278 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/src/plugin/request-helpers.js +2268 -0
- package/dist/src/plugin/request-helpers.js.map +1 -0
- package/dist/src/plugin/request.d.ts +91 -0
- package/dist/src/plugin/request.d.ts.map +1 -0
- package/dist/src/plugin/request.js +1302 -0
- package/dist/src/plugin/request.js.map +1 -0
- package/dist/src/plugin/rotation.d.ts +168 -0
- package/dist/src/plugin/rotation.d.ts.map +1 -0
- package/dist/src/plugin/rotation.js +302 -0
- package/dist/src/plugin/rotation.js.map +1 -0
- package/dist/src/plugin/server.d.ts +23 -0
- package/dist/src/plugin/server.d.ts.map +1 -0
- package/dist/src/plugin/server.js +324 -0
- package/dist/src/plugin/server.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +92 -0
- package/dist/src/plugin/storage.d.ts.map +1 -0
- package/dist/src/plugin/storage.js +417 -0
- package/dist/src/plugin/storage.js.map +1 -0
- package/dist/src/plugin/stores/signature-store.d.ts +5 -0
- package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
- package/dist/src/plugin/stores/signature-store.js +25 -0
- package/dist/src/plugin/stores/signature-store.js.map +1 -0
- package/dist/src/plugin/thinking-recovery.d.ts +90 -0
- package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/src/plugin/thinking-recovery.js +316 -0
- package/dist/src/plugin/thinking-recovery.js.map +1 -0
- package/dist/src/plugin/token.d.ts +19 -0
- package/dist/src/plugin/token.d.ts.map +1 -0
- package/dist/src/plugin/token.js +128 -0
- package/dist/src/plugin/token.js.map +1 -0
- package/dist/src/plugin/transform/claude.d.ts +80 -0
- package/dist/src/plugin/transform/claude.d.ts.map +1 -0
- package/dist/src/plugin/transform/claude.js +265 -0
- package/dist/src/plugin/transform/claude.js.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
- package/dist/src/plugin/transform/gemini.d.ts +112 -0
- package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
- package/dist/src/plugin/transform/gemini.js +409 -0
- package/dist/src/plugin/transform/gemini.js.map +1 -0
- package/dist/src/plugin/transform/index.d.ts +15 -0
- package/dist/src/plugin/transform/index.d.ts.map +1 -0
- package/dist/src/plugin/transform/index.js +14 -0
- package/dist/src/plugin/transform/index.js.map +1 -0
- package/dist/src/plugin/transform/model-resolver.d.ts +101 -0
- package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/src/plugin/transform/model-resolver.js +356 -0
- package/dist/src/plugin/transform/model-resolver.js.map +1 -0
- package/dist/src/plugin/transform/types.d.ts +106 -0
- package/dist/src/plugin/transform/types.d.ts.map +1 -0
- package/dist/src/plugin/transform/types.js +1 -0
- package/dist/src/plugin/transform/types.js.map +1 -0
- package/dist/src/plugin/types.d.ts +96 -0
- package/dist/src/plugin/types.d.ts.map +1 -0
- package/dist/src/plugin/types.js +1 -0
- package/dist/src/plugin/types.js.map +1 -0
- package/dist/src/plugin/usage-reporter.d.ts +23 -0
- package/dist/src/plugin/usage-reporter.d.ts.map +1 -0
- package/dist/src/plugin/usage-reporter.js +43 -0
- package/dist/src/plugin/usage-reporter.js.map +1 -0
- package/dist/src/plugin.d.ts +8 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +1708 -0
- package/dist/src/plugin.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Resolution with Thinking Tier Support
|
|
3
|
+
*
|
|
4
|
+
* Resolves model names with tier suffixes (e.g., gemini-3-pro-high, claude-sonnet-4-5-thinking-low)
|
|
5
|
+
* to their actual API model names and corresponding thinking configurations.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Thinking tier budgets by model family.
|
|
9
|
+
* Claude and Gemini 2.5 Pro use numeric budgets.
|
|
10
|
+
*/
|
|
11
|
+
export const THINKING_TIER_BUDGETS = {
|
|
12
|
+
claude: { low: 8192, medium: 16384, high: 32768 },
|
|
13
|
+
"gemini-2.5-pro": { low: 8192, medium: 16384, high: 32768 },
|
|
14
|
+
"gemini-2.5-flash": { low: 6144, medium: 12288, high: 24576 },
|
|
15
|
+
default: { low: 4096, medium: 8192, high: 16384 },
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Gemini 3 uses thinkingLevel strings instead of numeric budgets.
|
|
19
|
+
* Flash supports: minimal, low, medium, high
|
|
20
|
+
* Pro supports: low, high (no minimal/medium)
|
|
21
|
+
*/
|
|
22
|
+
export const GEMINI_3_THINKING_LEVELS = ["minimal", "low", "medium", "high"];
|
|
23
|
+
/**
|
|
24
|
+
* Model aliases - maps user-friendly names to API model names.
|
|
25
|
+
*
|
|
26
|
+
* Format:
|
|
27
|
+
* - Gemini 3 Pro variants: gemini-3-pro-{low,medium,high}
|
|
28
|
+
* - Claude thinking variants: claude-{model}-thinking-{low,medium,high}
|
|
29
|
+
* - Claude non-thinking: claude-{model} (no -thinking suffix)
|
|
30
|
+
*/
|
|
31
|
+
export const MODEL_ALIASES = {
|
|
32
|
+
// Gemini 3 variants - for Gemini CLI only (tier stripped, thinkingLevel used)
|
|
33
|
+
// For Antigravity, these are bypassed and full model name is kept
|
|
34
|
+
"gemini-3-pro-low": "gemini-3-pro",
|
|
35
|
+
"gemini-3-pro-high": "gemini-3-pro",
|
|
36
|
+
"gemini-3-flash-low": "gemini-3-flash",
|
|
37
|
+
"gemini-3-flash-medium": "gemini-3-flash",
|
|
38
|
+
"gemini-3-flash-high": "gemini-3-flash",
|
|
39
|
+
// Claude proxy names (gemini- prefix for compatibility)
|
|
40
|
+
"gemini-claude-sonnet-4-5": "claude-sonnet-4-5",
|
|
41
|
+
"gemini-claude-sonnet-4-5-thinking-low": "claude-sonnet-4-5-thinking",
|
|
42
|
+
"gemini-claude-sonnet-4-5-thinking-medium": "claude-sonnet-4-5-thinking",
|
|
43
|
+
"gemini-claude-sonnet-4-5-thinking-high": "claude-sonnet-4-5-thinking",
|
|
44
|
+
"gemini-claude-opus-4-5-thinking-low": "claude-opus-4-5-thinking",
|
|
45
|
+
"gemini-claude-opus-4-5-thinking-medium": "claude-opus-4-5-thinking",
|
|
46
|
+
"gemini-claude-opus-4-5-thinking-high": "claude-opus-4-5-thinking",
|
|
47
|
+
// Image generation models - only gemini-3-pro-image is available via Antigravity API
|
|
48
|
+
// Note: gemini-2.5-flash-image (Nano Banana) is NOT supported by Antigravity - only Google AI API
|
|
49
|
+
// Reference: Antigravity-Manager/src-tauri/src/proxy/common/model_mapping.rs
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Model fallbacks when primary model is unavailable.
|
|
53
|
+
* NOTE: Image models should NOT fall back to non-image models!
|
|
54
|
+
*/
|
|
55
|
+
export const MODEL_FALLBACKS = {
|
|
56
|
+
// No fallbacks for image models - they must stay as image models
|
|
57
|
+
};
|
|
58
|
+
const TIER_REGEX = /-(minimal|low|medium|high)$/;
|
|
59
|
+
const QUOTA_PREFIX_REGEX = /^antigravity-/i;
|
|
60
|
+
/**
|
|
61
|
+
* Models that only exist on Antigravity (not on Gemini CLI).
|
|
62
|
+
* These automatically route to Antigravity even without the prefix.
|
|
63
|
+
*/
|
|
64
|
+
const ANTIGRAVITY_ONLY_MODELS = /^(claude|gpt)/i;
|
|
65
|
+
/**
|
|
66
|
+
* Image generation models - always route to Antigravity.
|
|
67
|
+
* These models don't support thinking and require imageConfig.
|
|
68
|
+
*/
|
|
69
|
+
const IMAGE_GENERATION_MODELS = /image|imagen/i;
|
|
70
|
+
/**
|
|
71
|
+
* Legacy Gemini 3 model names that should route to Antigravity quota.
|
|
72
|
+
*
|
|
73
|
+
* Backward compatibility: Since Gemini CLI now uses -preview suffix
|
|
74
|
+
* (gemini-3-pro-preview, gemini-3-flash-preview), old model names
|
|
75
|
+
* without -preview can safely route to Antigravity quota.
|
|
76
|
+
*
|
|
77
|
+
* Matches:
|
|
78
|
+
* - gemini-3-pro-low, gemini-3-pro-high
|
|
79
|
+
* - gemini-3-flash, gemini-3-flash-low, gemini-3-flash-medium, gemini-3-flash-high
|
|
80
|
+
*
|
|
81
|
+
* Does NOT match:
|
|
82
|
+
* - gemini-3-pro-preview (Gemini CLI)
|
|
83
|
+
* - gemini-3-flash-preview (Gemini CLI)
|
|
84
|
+
* - antigravity-gemini-3-* (already handled by prefix)
|
|
85
|
+
*
|
|
86
|
+
* WARNING: This may break if Google/Opencode removes the -preview suffix.
|
|
87
|
+
*/
|
|
88
|
+
const LEGACY_ANTIGRAVITY_GEMINI3 = /^gemini-3-(pro-(low|high)|flash(-low|-medium|-high)?)$/i;
|
|
89
|
+
/**
|
|
90
|
+
* Models that support thinking tier suffixes.
|
|
91
|
+
* Only these models should have -low/-medium/-high stripped as thinking tiers.
|
|
92
|
+
* GPT models like gpt-oss-120b-medium should NOT have -medium stripped.
|
|
93
|
+
*/
|
|
94
|
+
function supportsThinkingTiers(model) {
|
|
95
|
+
const lower = model.toLowerCase();
|
|
96
|
+
return (lower.includes("gemini-3") ||
|
|
97
|
+
lower.includes("gemini-2.5") ||
|
|
98
|
+
(lower.includes("claude") && lower.includes("thinking")));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Extracts thinking tier from model name suffix.
|
|
102
|
+
* Only extracts tier for models that support thinking tiers.
|
|
103
|
+
*/
|
|
104
|
+
function extractThinkingTierFromModel(model) {
|
|
105
|
+
// Only extract tier for models that support thinking tiers
|
|
106
|
+
if (!supportsThinkingTiers(model)) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const tierMatch = model.match(TIER_REGEX);
|
|
110
|
+
return tierMatch?.[1];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Determines the budget family for a model.
|
|
114
|
+
*/
|
|
115
|
+
function getBudgetFamily(model) {
|
|
116
|
+
if (model.includes("claude")) {
|
|
117
|
+
return "claude";
|
|
118
|
+
}
|
|
119
|
+
if (model.includes("gemini-2.5-pro")) {
|
|
120
|
+
return "gemini-2.5-pro";
|
|
121
|
+
}
|
|
122
|
+
if (model.includes("gemini-2.5-flash")) {
|
|
123
|
+
return "gemini-2.5-flash";
|
|
124
|
+
}
|
|
125
|
+
return "default";
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Checks if a model is a thinking-capable model.
|
|
129
|
+
*/
|
|
130
|
+
function isThinkingCapableModel(model) {
|
|
131
|
+
const lower = model.toLowerCase();
|
|
132
|
+
return (lower.includes("thinking") ||
|
|
133
|
+
lower.includes("gemini-3") ||
|
|
134
|
+
lower.includes("gemini-2.5"));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Resolves a model name with optional tier suffix and quota prefix to its actual API model name
|
|
138
|
+
* and corresponding thinking configuration.
|
|
139
|
+
*
|
|
140
|
+
* Quota routing:
|
|
141
|
+
* - "antigravity-" prefix → Antigravity quota
|
|
142
|
+
* - Claude/GPT models → Antigravity quota (auto, these only exist on Antigravity)
|
|
143
|
+
* - Legacy Gemini 3 names (gemini-3-pro-low, gemini-3-flash, etc.) → Antigravity quota (backward compat)
|
|
144
|
+
* - Other models → Gemini CLI quota (default)
|
|
145
|
+
*
|
|
146
|
+
* Examples:
|
|
147
|
+
* - "gemini-2.5-flash" → { quotaPreference: "gemini-cli" }
|
|
148
|
+
* - "gemini-3-pro-preview" → { quotaPreference: "gemini-cli" } (Gemini CLI uses -preview)
|
|
149
|
+
* - "gemini-3-pro-low" → { quotaPreference: "antigravity" } (legacy name, backward compat)
|
|
150
|
+
* - "antigravity-gemini-3-pro-high" → { quotaPreference: "antigravity" } (explicit prefix)
|
|
151
|
+
* - "claude-sonnet-4-5-thinking-medium" → { quotaPreference: "antigravity" } (Claude only on Antigravity)
|
|
152
|
+
*
|
|
153
|
+
* @param requestedModel - The model name from the request
|
|
154
|
+
* @returns Resolved model with thinking configuration
|
|
155
|
+
*/
|
|
156
|
+
export function resolveModelWithTier(requestedModel) {
|
|
157
|
+
const isAntigravity = QUOTA_PREFIX_REGEX.test(requestedModel);
|
|
158
|
+
const modelWithoutQuota = requestedModel.replace(QUOTA_PREFIX_REGEX, "");
|
|
159
|
+
const tier = extractThinkingTierFromModel(modelWithoutQuota);
|
|
160
|
+
const baseName = tier ? modelWithoutQuota.replace(TIER_REGEX, "") : modelWithoutQuota;
|
|
161
|
+
const isAntigravityOnly = ANTIGRAVITY_ONLY_MODELS.test(modelWithoutQuota);
|
|
162
|
+
const isLegacyAntigravity = LEGACY_ANTIGRAVITY_GEMINI3.test(modelWithoutQuota);
|
|
163
|
+
const isImageModel = IMAGE_GENERATION_MODELS.test(modelWithoutQuota);
|
|
164
|
+
// Image models always route to Antigravity
|
|
165
|
+
const quotaPreference = isAntigravity || isAntigravityOnly || isLegacyAntigravity || isImageModel ? "antigravity" : "gemini-cli";
|
|
166
|
+
const explicitQuota = isAntigravity;
|
|
167
|
+
const isGemini3 = modelWithoutQuota.toLowerCase().startsWith("gemini-3");
|
|
168
|
+
const skipAlias = isAntigravity && isGemini3;
|
|
169
|
+
// For Antigravity Gemini 3 Pro models without explicit tier, append default tier (-low)
|
|
170
|
+
// Antigravity API: gemini-3-pro requires tier suffix (gemini-3-pro-low/high)
|
|
171
|
+
// gemini-3-flash uses bare name + thinkingLevel param
|
|
172
|
+
const isGemini3Pro = modelWithoutQuota.toLowerCase().startsWith("gemini-3-pro");
|
|
173
|
+
const isGemini3Flash = modelWithoutQuota.toLowerCase().startsWith("gemini-3-flash");
|
|
174
|
+
let antigravityModel = modelWithoutQuota;
|
|
175
|
+
if (skipAlias) {
|
|
176
|
+
if (isGemini3Pro && !tier && !isImageModel) {
|
|
177
|
+
antigravityModel = `${modelWithoutQuota}-low`;
|
|
178
|
+
}
|
|
179
|
+
else if (isGemini3Flash && tier) {
|
|
180
|
+
antigravityModel = baseName;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const actualModel = skipAlias
|
|
184
|
+
? antigravityModel
|
|
185
|
+
: MODEL_ALIASES[modelWithoutQuota] || MODEL_ALIASES[baseName] || baseName;
|
|
186
|
+
const resolvedModel = MODEL_FALLBACKS[actualModel] || actualModel;
|
|
187
|
+
const isThinking = isThinkingCapableModel(resolvedModel);
|
|
188
|
+
// Image generation models don't support thinking - return early without thinking config
|
|
189
|
+
if (isImageModel) {
|
|
190
|
+
return {
|
|
191
|
+
actualModel: resolvedModel,
|
|
192
|
+
isThinkingModel: false,
|
|
193
|
+
isImageModel: true,
|
|
194
|
+
quotaPreference,
|
|
195
|
+
explicitQuota,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
// Check if this is a Gemini 3 model (works for both aliased and skipAlias paths)
|
|
199
|
+
const isEffectiveGemini3 = resolvedModel.toLowerCase().includes("gemini-3");
|
|
200
|
+
const isClaudeThinking = resolvedModel.toLowerCase().includes("claude") && resolvedModel.toLowerCase().includes("thinking");
|
|
201
|
+
if (!tier) {
|
|
202
|
+
// Gemini 3 models without explicit tier get a default thinkingLevel
|
|
203
|
+
if (isEffectiveGemini3) {
|
|
204
|
+
// Both Pro and Flash default to "low" per Google's API docs
|
|
205
|
+
return {
|
|
206
|
+
actualModel: resolvedModel,
|
|
207
|
+
thinkingLevel: "low",
|
|
208
|
+
isThinkingModel: true,
|
|
209
|
+
quotaPreference,
|
|
210
|
+
explicitQuota,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
// Claude thinking models without explicit tier get max budget (32768)
|
|
214
|
+
// Per Anthropic docs, budget_tokens is required when enabling extended thinking
|
|
215
|
+
if (isClaudeThinking) {
|
|
216
|
+
return {
|
|
217
|
+
actualModel: resolvedModel,
|
|
218
|
+
thinkingBudget: THINKING_TIER_BUDGETS.claude.high,
|
|
219
|
+
isThinkingModel: true,
|
|
220
|
+
quotaPreference,
|
|
221
|
+
explicitQuota,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return { actualModel: resolvedModel, isThinkingModel: isThinking, quotaPreference, explicitQuota };
|
|
225
|
+
}
|
|
226
|
+
// Gemini 3 models with tier always get thinkingLevel set
|
|
227
|
+
if (isEffectiveGemini3) {
|
|
228
|
+
return {
|
|
229
|
+
actualModel: resolvedModel,
|
|
230
|
+
thinkingLevel: tier,
|
|
231
|
+
tier,
|
|
232
|
+
isThinkingModel: true,
|
|
233
|
+
quotaPreference,
|
|
234
|
+
explicitQuota,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const budgetFamily = getBudgetFamily(resolvedModel);
|
|
238
|
+
const budgets = THINKING_TIER_BUDGETS[budgetFamily];
|
|
239
|
+
const thinkingBudget = budgets[tier];
|
|
240
|
+
return {
|
|
241
|
+
actualModel: resolvedModel,
|
|
242
|
+
thinkingBudget,
|
|
243
|
+
tier,
|
|
244
|
+
isThinkingModel: isThinking,
|
|
245
|
+
quotaPreference,
|
|
246
|
+
explicitQuota,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Gets the model family for routing decisions.
|
|
251
|
+
*/
|
|
252
|
+
export function getModelFamily(model) {
|
|
253
|
+
const lower = model.toLowerCase();
|
|
254
|
+
if (lower.includes("claude")) {
|
|
255
|
+
return "claude";
|
|
256
|
+
}
|
|
257
|
+
if (lower.includes("flash")) {
|
|
258
|
+
return "gemini-flash";
|
|
259
|
+
}
|
|
260
|
+
return "gemini-pro";
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Maps a thinking budget to Gemini 3 thinking level.
|
|
264
|
+
* ≤8192 → low, ≤16384 → medium, >16384 → high
|
|
265
|
+
*/
|
|
266
|
+
function budgetToGemini3Level(budget) {
|
|
267
|
+
if (budget <= 8192)
|
|
268
|
+
return "low";
|
|
269
|
+
if (budget <= 16384)
|
|
270
|
+
return "medium";
|
|
271
|
+
return "high";
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Resolves model name for a specific headerStyle (quota fallback support).
|
|
275
|
+
* Transforms model names when switching between gemini-cli and antigravity quotas.
|
|
276
|
+
*
|
|
277
|
+
* Issue #103: When quota fallback occurs, model names need to be transformed:
|
|
278
|
+
* - gemini-3-flash-preview (gemini-cli) → gemini-3-flash (antigravity)
|
|
279
|
+
* - gemini-3-pro-preview (gemini-cli) → gemini-3-pro-low (antigravity)
|
|
280
|
+
* - gemini-3-flash (antigravity) → gemini-3-flash-preview (gemini-cli)
|
|
281
|
+
*/
|
|
282
|
+
export function resolveModelForHeaderStyle(requestedModel, headerStyle) {
|
|
283
|
+
const lower = requestedModel.toLowerCase();
|
|
284
|
+
const isGemini3 = lower.includes("gemini-3");
|
|
285
|
+
if (!isGemini3) {
|
|
286
|
+
return resolveModelWithTier(requestedModel);
|
|
287
|
+
}
|
|
288
|
+
if (headerStyle === "antigravity") {
|
|
289
|
+
let transformedModel = requestedModel
|
|
290
|
+
.replace(/-preview$/i, "")
|
|
291
|
+
.replace(/^antigravity-/i, "");
|
|
292
|
+
const isGemini3Pro = transformedModel.toLowerCase().startsWith("gemini-3-pro");
|
|
293
|
+
const hasTierSuffix = /-(low|medium|high)$/i.test(transformedModel);
|
|
294
|
+
if (isGemini3Pro && !hasTierSuffix) {
|
|
295
|
+
transformedModel = `${transformedModel}-low`;
|
|
296
|
+
}
|
|
297
|
+
const prefixedModel = `antigravity-${transformedModel}`;
|
|
298
|
+
return resolveModelWithTier(prefixedModel);
|
|
299
|
+
}
|
|
300
|
+
if (headerStyle === "gemini-cli") {
|
|
301
|
+
let transformedModel = requestedModel
|
|
302
|
+
.replace(/^antigravity-/i, "")
|
|
303
|
+
.replace(/-(low|medium|high)$/i, "");
|
|
304
|
+
if (!transformedModel.endsWith("-preview")) {
|
|
305
|
+
transformedModel = `${transformedModel}-preview`;
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
...resolveModelWithTier(transformedModel),
|
|
309
|
+
quotaPreference: "gemini-cli",
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return resolveModelWithTier(requestedModel);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Resolves model with variant config from providerOptions.
|
|
316
|
+
* Variant config takes priority over tier suffix in model name.
|
|
317
|
+
*/
|
|
318
|
+
export function resolveModelWithVariant(requestedModel, variantConfig) {
|
|
319
|
+
const base = resolveModelWithTier(requestedModel);
|
|
320
|
+
if (!variantConfig) {
|
|
321
|
+
return base;
|
|
322
|
+
}
|
|
323
|
+
// Apply Google Search config if present
|
|
324
|
+
if (variantConfig.googleSearch) {
|
|
325
|
+
base.googleSearch = variantConfig.googleSearch;
|
|
326
|
+
base.configSource = "variant";
|
|
327
|
+
}
|
|
328
|
+
if (!variantConfig.thinkingBudget) {
|
|
329
|
+
return base;
|
|
330
|
+
}
|
|
331
|
+
const budget = variantConfig.thinkingBudget;
|
|
332
|
+
const isGemini3 = base.actualModel.toLowerCase().includes("gemini-3");
|
|
333
|
+
if (isGemini3) {
|
|
334
|
+
const level = budgetToGemini3Level(budget);
|
|
335
|
+
const isAntigravityGemini3Pro = base.quotaPreference === "antigravity" &&
|
|
336
|
+
base.actualModel.toLowerCase().startsWith("gemini-3-pro");
|
|
337
|
+
let actualModel = base.actualModel;
|
|
338
|
+
if (isAntigravityGemini3Pro) {
|
|
339
|
+
const baseModel = base.actualModel.replace(/-(low|medium|high)$/, "");
|
|
340
|
+
actualModel = `${baseModel}-${level}`;
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
...base,
|
|
344
|
+
actualModel,
|
|
345
|
+
thinkingLevel: level,
|
|
346
|
+
thinkingBudget: undefined,
|
|
347
|
+
configSource: "variant",
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
...base,
|
|
352
|
+
thinkingBudget: budget,
|
|
353
|
+
configSource: "variant",
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=model-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../../../../src/plugin/transform/model-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IACjD,gBAAgB,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC3D,kBAAkB,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7D,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;CACzC,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAEtF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,8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,YAAY,GAAG,SAAS,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEtE,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,uBAAuB,GAAG,IAAI,CAAC,eAAe,KAAK,aAAa;YACpE,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAE5D,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACnC,IAAI,uBAAuB,EAAE,CAAC;YAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;YACtE,WAAW,GAAG,GAAG,SAAS,IAAI,KAAK,EAAE,CAAC;QACxC,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,WAAW;YACX,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,SAAS;YACzB,YAAY,EAAE,SAAS;SACxB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,IAAI;QACP,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,SAAS;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { HeaderStyle } from "../../constants";
|
|
2
|
+
export type ModelFamily = "claude" | "gemini-flash" | "gemini-pro";
|
|
3
|
+
export type ThinkingTier = "low" | "medium" | "high";
|
|
4
|
+
/**
|
|
5
|
+
* Context for request transformation.
|
|
6
|
+
* Contains all information needed to transform a request payload.
|
|
7
|
+
*/
|
|
8
|
+
export interface TransformContext {
|
|
9
|
+
/** The resolved project ID for the API call */
|
|
10
|
+
projectId: string;
|
|
11
|
+
/** The resolved model name (after alias resolution) */
|
|
12
|
+
model: string;
|
|
13
|
+
/** The original model name from the request */
|
|
14
|
+
requestedModel: string;
|
|
15
|
+
/** Model family for routing decisions */
|
|
16
|
+
family: ModelFamily;
|
|
17
|
+
/** Whether this is a streaming request */
|
|
18
|
+
streaming: boolean;
|
|
19
|
+
/** Unique request ID for tracking */
|
|
20
|
+
requestId: string;
|
|
21
|
+
/** Session ID for signature caching */
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
/** Thinking tier if specified via model suffix */
|
|
24
|
+
thinkingTier?: ThinkingTier;
|
|
25
|
+
/** Thinking budget for Claude models (derived from tier) */
|
|
26
|
+
thinkingBudget?: number;
|
|
27
|
+
/** Thinking level for Gemini 3 models (derived from tier) */
|
|
28
|
+
thinkingLevel?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of request transformation.
|
|
32
|
+
*/
|
|
33
|
+
export interface TransformResult {
|
|
34
|
+
/** The transformed request body as JSON string */
|
|
35
|
+
body: string;
|
|
36
|
+
/** Debug information about the transformation */
|
|
37
|
+
debugInfo: TransformDebugInfo;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Debug information from transformation.
|
|
41
|
+
*/
|
|
42
|
+
export interface TransformDebugInfo {
|
|
43
|
+
/** Which transformer was used */
|
|
44
|
+
transformer: "claude" | "gemini";
|
|
45
|
+
/** Number of tools in the request */
|
|
46
|
+
toolCount: number;
|
|
47
|
+
/** Whether tools were transformed */
|
|
48
|
+
toolsTransformed?: boolean;
|
|
49
|
+
/** Thinking tier if resolved */
|
|
50
|
+
thinkingTier?: string;
|
|
51
|
+
/** Thinking budget if set */
|
|
52
|
+
thinkingBudget?: number;
|
|
53
|
+
/** Thinking level if set (Gemini 3) */
|
|
54
|
+
thinkingLevel?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generic request payload type.
|
|
58
|
+
* The actual structure varies between Claude and Gemini.
|
|
59
|
+
*/
|
|
60
|
+
export type RequestPayload = Record<string, unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* Thinking configuration normalized from various input formats.
|
|
63
|
+
*/
|
|
64
|
+
export interface ThinkingConfig {
|
|
65
|
+
/** Numeric thinking budget (for Claude and Gemini 2.5) */
|
|
66
|
+
thinkingBudget?: number;
|
|
67
|
+
/** String thinking level (for Gemini 3: 'low', 'medium', 'high') */
|
|
68
|
+
thinkingLevel?: string;
|
|
69
|
+
/** Whether to include thinking in the response */
|
|
70
|
+
includeThoughts?: boolean;
|
|
71
|
+
/** Snake_case variant for Antigravity backend */
|
|
72
|
+
include_thoughts?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Google Search Grounding configuration.
|
|
76
|
+
*/
|
|
77
|
+
export interface GoogleSearchConfig {
|
|
78
|
+
mode?: 'auto' | 'off';
|
|
79
|
+
threshold?: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Model resolution result with tier information.
|
|
83
|
+
*/
|
|
84
|
+
export interface ResolvedModel {
|
|
85
|
+
/** The actual model name for the API call */
|
|
86
|
+
actualModel: string;
|
|
87
|
+
/** Thinking level for Gemini 3 models */
|
|
88
|
+
thinkingLevel?: string;
|
|
89
|
+
/** Thinking budget for Claude/Gemini 2.5 */
|
|
90
|
+
thinkingBudget?: number;
|
|
91
|
+
/** The tier suffix that was extracted */
|
|
92
|
+
tier?: ThinkingTier;
|
|
93
|
+
/** Whether this is a thinking-capable model */
|
|
94
|
+
isThinkingModel?: boolean;
|
|
95
|
+
/** Whether this is an image generation model */
|
|
96
|
+
isImageModel?: boolean;
|
|
97
|
+
/** Quota preference based on :antigravity or :gemini-cli suffix */
|
|
98
|
+
quotaPreference?: HeaderStyle;
|
|
99
|
+
/** Whether user explicitly specified quota via suffix (vs default selection) */
|
|
100
|
+
explicitQuota?: boolean;
|
|
101
|
+
/** Source of thinking config: "variant" (providerOptions) or "tier" (model suffix) */
|
|
102
|
+
configSource?: "variant" | "tier";
|
|
103
|
+
/** Google Search configuration from variant or global config */
|
|
104
|
+
googleSearch?: GoogleSearchConfig;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugin/transform/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,MAAM,EAAE,WAAW,CAAC;IACpB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,WAAW,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACj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E;IAChE,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/plugin/transform/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import type { AntigravityTokenExchangeResult } from "../antigravity/oauth";
|
|
3
|
+
export interface OAuthAuthDetails {
|
|
4
|
+
type: "oauth";
|
|
5
|
+
refresh: string;
|
|
6
|
+
access?: string;
|
|
7
|
+
expires?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ApiKeyAuthDetails {
|
|
10
|
+
type: "api_key";
|
|
11
|
+
key: string;
|
|
12
|
+
}
|
|
13
|
+
export interface NonOAuthAuthDetails {
|
|
14
|
+
type: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export type AuthDetails = OAuthAuthDetails | ApiKeyAuthDetails | NonOAuthAuthDetails;
|
|
18
|
+
export type GetAuth = () => Promise<AuthDetails>;
|
|
19
|
+
export interface ProviderModel {
|
|
20
|
+
cost?: {
|
|
21
|
+
input: number;
|
|
22
|
+
output: number;
|
|
23
|
+
};
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface Provider {
|
|
27
|
+
models?: Record<string, ProviderModel>;
|
|
28
|
+
}
|
|
29
|
+
export interface LoaderResult {
|
|
30
|
+
apiKey: string;
|
|
31
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
32
|
+
}
|
|
33
|
+
export type PluginClient = PluginInput["client"];
|
|
34
|
+
export interface PluginContext {
|
|
35
|
+
client: PluginClient;
|
|
36
|
+
directory: string;
|
|
37
|
+
}
|
|
38
|
+
export type AuthPrompt = {
|
|
39
|
+
type: "text";
|
|
40
|
+
key: string;
|
|
41
|
+
message: string;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
validate?: (value: string) => string | undefined;
|
|
44
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
45
|
+
} | {
|
|
46
|
+
type: "select";
|
|
47
|
+
key: string;
|
|
48
|
+
message: string;
|
|
49
|
+
options: Array<{
|
|
50
|
+
label: string;
|
|
51
|
+
value: string;
|
|
52
|
+
hint?: string;
|
|
53
|
+
}>;
|
|
54
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
55
|
+
};
|
|
56
|
+
export type OAuthAuthorizationResult = {
|
|
57
|
+
url: string;
|
|
58
|
+
instructions: string;
|
|
59
|
+
} & ({
|
|
60
|
+
method: "auto";
|
|
61
|
+
callback: () => Promise<AntigravityTokenExchangeResult>;
|
|
62
|
+
} | {
|
|
63
|
+
method: "code";
|
|
64
|
+
callback: (code: string) => Promise<AntigravityTokenExchangeResult>;
|
|
65
|
+
});
|
|
66
|
+
export interface AuthMethod {
|
|
67
|
+
provider?: string;
|
|
68
|
+
label: string;
|
|
69
|
+
type: "oauth" | "api";
|
|
70
|
+
prompts?: AuthPrompt[];
|
|
71
|
+
authorize?: (inputs?: Record<string, string>) => Promise<OAuthAuthorizationResult>;
|
|
72
|
+
}
|
|
73
|
+
export interface PluginEventPayload {
|
|
74
|
+
event: {
|
|
75
|
+
type: string;
|
|
76
|
+
properties?: unknown;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface PluginResult {
|
|
80
|
+
auth: {
|
|
81
|
+
provider: string;
|
|
82
|
+
loader: (getAuth: GetAuth, provider: Provider) => Promise<LoaderResult | Record<string, unknown>>;
|
|
83
|
+
methods: AuthMethod[];
|
|
84
|
+
};
|
|
85
|
+
event?: (payload: PluginEventPayload) => void;
|
|
86
|
+
}
|
|
87
|
+
export interface RefreshParts {
|
|
88
|
+
refreshToken: string;
|
|
89
|
+
projectId?: string;
|
|
90
|
+
managedProjectId?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface ProjectContextResult {
|
|
93
|
+
auth: OAuthAuthDetails;
|
|
94
|
+
effectiveProjectId: string;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAE3E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAErF,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,W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AW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACpF;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClG,OAAO,EAAE,UAAU,EAAE,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,gBAAgB,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugin/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface UsageReport {
|
|
2
|
+
accountEmail: string;
|
|
3
|
+
model: string;
|
|
4
|
+
family: string;
|
|
5
|
+
tokens: {
|
|
6
|
+
total: number;
|
|
7
|
+
prompt: number;
|
|
8
|
+
candidates: number;
|
|
9
|
+
};
|
|
10
|
+
success: boolean;
|
|
11
|
+
latencyMs: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the usage reporter with remote service config.
|
|
15
|
+
*/
|
|
16
|
+
export declare function initUsageReporter(endpoint: string, key: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Report usage to remote service asynchronously.
|
|
19
|
+
* This function returns immediately and does not block.
|
|
20
|
+
* Failures are logged but do not throw.
|
|
21
|
+
*/
|
|
22
|
+
export declare function reportUsage(report: UsageReport): void;
|
|
23
|
+
//# sourceMappingURL=usage-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-reporter.d.ts","sourceRoot":"","sources":["../../../src/plugin/usage-reporter.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAIrE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAyBrD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { debugLogToFile } from './debug.js';
|
|
2
|
+
let apiEndpoint;
|
|
3
|
+
let apiKey;
|
|
4
|
+
/**
|
|
5
|
+
* Initialize the usage reporter with remote service config.
|
|
6
|
+
*/
|
|
7
|
+
export function initUsageReporter(endpoint, key) {
|
|
8
|
+
apiEndpoint = endpoint;
|
|
9
|
+
apiKey = key;
|
|
10
|
+
debugLogToFile(`[usage-reporter] Initialized: ${JSON.stringify({ endpoint })}`);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Report usage to remote service asynchronously.
|
|
14
|
+
* This function returns immediately and does not block.
|
|
15
|
+
* Failures are logged but do not throw.
|
|
16
|
+
*/
|
|
17
|
+
export function reportUsage(report) {
|
|
18
|
+
if (!apiEndpoint || !apiKey) {
|
|
19
|
+
return; // Remote mode not configured
|
|
20
|
+
}
|
|
21
|
+
// Fire and forget - do not await
|
|
22
|
+
fetch(`${apiEndpoint}/api/usage`, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
'X-API-Key': apiKey,
|
|
27
|
+
'User-Agent': 'opencode-antigravity-auth',
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify(report),
|
|
30
|
+
})
|
|
31
|
+
.then((res) => {
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
debugLogToFile(`[usage-reporter] Report failed: ${res.status} ${JSON.stringify(report)}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
debugLogToFile(`[usage-reporter] Report sent: ${JSON.stringify(report)}`);
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
.catch((err) => {
|
|
40
|
+
debugLogToFile(`[usage-reporter] Report error: ${err.message} ${JSON.stringify(report)}`);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=usage-reporter.js.map
|