opencode-ag-auth 1.5.2
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 +749 -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 +171 -0
- package/dist/src/antigravity/oauth.js.map +1 -0
- package/dist/src/constants.d.ts +138 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +220 -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 +173 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -0
- package/dist/src/plugin/accounts.js +1035 -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 +27 -0
- package/dist/src/plugin/cli.d.ts.map +1 -0
- package/dist/src/plugin/cli.js +130 -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 +196 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/models.d.ts +27 -0
- package/dist/src/plugin/config/models.d.ts.map +1 -0
- package/dist/src/plugin/config/models.js +70 -0
- package/dist/src/plugin/config/models.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +133 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +438 -0
- package/dist/src/plugin/config/schema.js.map +1 -0
- package/dist/src/plugin/config/updater.d.ts +55 -0
- package/dist/src/plugin/config/updater.d.ts.map +1 -0
- package/dist/src/plugin/config/updater.js +125 -0
- package/dist/src/plugin/config/updater.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 +271 -0
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
- package/dist/src/plugin/core/streaming/types.d.ts +27 -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 +94 -0
- package/dist/src/plugin/debug.d.ts.map +1 -0
- package/dist/src/plugin/debug.js +418 -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/fingerprint.d.ts +64 -0
- package/dist/src/plugin/fingerprint.d.ts.map +1 -0
- package/dist/src/plugin/fingerprint.js +125 -0
- package/dist/src/plugin/fingerprint.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/proxy.d.ts +2 -0
- package/dist/src/plugin/proxy.d.ts.map +1 -0
- package/dist/src/plugin/proxy.js +20 -0
- package/dist/src/plugin/proxy.js.map +1 -0
- package/dist/src/plugin/quota.d.ts +35 -0
- package/dist/src/plugin/quota.d.ts.map +1 -0
- package/dist/src/plugin/quota.js +273 -0
- package/dist/src/plugin/quota.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 +378 -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 +248 -0
- package/dist/src/plugin/refresh-queue.js.map +1 -0
- package/dist/src/plugin/request-helpers.d.ts +282 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/src/plugin/request-helpers.js +2319 -0
- package/dist/src/plugin/request-helpers.js.map +1 -0
- package/dist/src/plugin/request.d.ts +93 -0
- package/dist/src/plugin/request.d.ts.map +1 -0
- package/dist/src/plugin/request.js +1352 -0
- package/dist/src/plugin/request.js.map +1 -0
- package/dist/src/plugin/rotation.d.ts +169 -0
- package/dist/src/plugin/rotation.d.ts.map +1 -0
- package/dist/src/plugin/rotation.js +328 -0
- package/dist/src/plugin/rotation.js.map +1 -0
- package/dist/src/plugin/search.d.ts +32 -0
- package/dist/src/plugin/search.d.ts.map +1 -0
- package/dist/src/plugin/search.js +195 -0
- package/dist/src/plugin/search.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 +136 -0
- package/dist/src/plugin/storage.d.ts.map +1 -0
- package/dist/src/plugin/storage.js +588 -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 +100 -0
- package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
- package/dist/src/plugin/transform/gemini.js +465 -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 +104 -0
- package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/src/plugin/transform/model-resolver.js +361 -0
- package/dist/src/plugin/transform/model-resolver.js.map +1 -0
- package/dist/src/plugin/transform/types.d.ts +111 -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 +97 -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/ui/ansi.d.ts +32 -0
- package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
- package/dist/src/plugin/ui/ansi.js +52 -0
- package/dist/src/plugin/ui/ansi.js.map +1 -0
- package/dist/src/plugin/ui/auth-menu.d.ts +33 -0
- package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
- package/dist/src/plugin/ui/auth-menu.js +110 -0
- package/dist/src/plugin/ui/auth-menu.js.map +1 -0
- package/dist/src/plugin/ui/confirm.d.ts +2 -0
- package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
- package/dist/src/plugin/ui/confirm.js +15 -0
- package/dist/src/plugin/ui/confirm.js.map +1 -0
- package/dist/src/plugin/ui/select.d.ts +23 -0
- package/dist/src/plugin/ui/select.d.ts.map +1 -0
- package/dist/src/plugin/ui/select.js +254 -0
- package/dist/src/plugin/ui/select.js.map +1 -0
- package/dist/src/plugin/version.d.ts +19 -0
- package/dist/src/plugin/version.d.ts.map +1 -0
- package/dist/src/plugin/version.js +80 -0
- package/dist/src/plugin/version.js.map +1 -0
- package/dist/src/plugin.d.ts +30 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +3050 -0
- package/dist/src/plugin.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,361 @@
|
|
|
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 = [
|
|
23
|
+
"minimal",
|
|
24
|
+
"low",
|
|
25
|
+
"medium",
|
|
26
|
+
"high",
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Model aliases - maps user-friendly names to API model names.
|
|
30
|
+
*
|
|
31
|
+
* Format:
|
|
32
|
+
* - Gemini 3 Pro variants: gemini-3-pro-{low,medium,high}
|
|
33
|
+
* - Claude thinking variants: claude-{model}-thinking-{low,medium,high}
|
|
34
|
+
* - Claude non-thinking: claude-{model} (no -thinking suffix)
|
|
35
|
+
*/
|
|
36
|
+
export const MODEL_ALIASES = {
|
|
37
|
+
// Gemini 3 variants - for Gemini CLI only (tier stripped, thinkingLevel used)
|
|
38
|
+
// For Antigravity, these are bypassed and full model name is kept
|
|
39
|
+
"gemini-3-pro-low": "gemini-3-pro",
|
|
40
|
+
"gemini-3-pro-high": "gemini-3-pro",
|
|
41
|
+
"gemini-3-flash-low": "gemini-3-flash",
|
|
42
|
+
"gemini-3-flash-medium": "gemini-3-flash",
|
|
43
|
+
"gemini-3-flash-high": "gemini-3-flash",
|
|
44
|
+
// Claude proxy names (gemini- prefix for compatibility)
|
|
45
|
+
"gemini-claude-sonnet-4-5": "claude-sonnet-4-5",
|
|
46
|
+
"gemini-claude-sonnet-4-5-thinking-low": "claude-sonnet-4-5-thinking",
|
|
47
|
+
"gemini-claude-sonnet-4-5-thinking-medium": "claude-sonnet-4-5-thinking",
|
|
48
|
+
"gemini-claude-sonnet-4-5-thinking-high": "claude-sonnet-4-5-thinking",
|
|
49
|
+
"gemini-claude-opus-4-6-thinking-low": "claude-opus-4-6-thinking",
|
|
50
|
+
"gemini-claude-opus-4-6-thinking-medium": "claude-opus-4-6-thinking",
|
|
51
|
+
"gemini-claude-opus-4-6-thinking-high": "claude-opus-4-6-thinking",
|
|
52
|
+
// Image generation models - only gemini-3-pro-image is available via Antigravity API
|
|
53
|
+
// Note: gemini-2.5-flash-image (Nano Banana) is NOT supported by Antigravity - only Google AI API
|
|
54
|
+
// Reference: Antigravity-Manager/src-tauri/src/proxy/common/model_mapping.rs
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Model fallbacks when primary model is unavailable.
|
|
58
|
+
* NOTE: Image models should NOT fall back to non-image models!
|
|
59
|
+
*/
|
|
60
|
+
export const MODEL_FALLBACKS = {
|
|
61
|
+
// No fallbacks for image models - they must stay as image models
|
|
62
|
+
};
|
|
63
|
+
const TIER_REGEX = /-(minimal|low|medium|high)$/;
|
|
64
|
+
const QUOTA_PREFIX_REGEX = /^antigravity-/i;
|
|
65
|
+
// ANTIGRAVITY_ONLY_MODELS removed - all models now default to antigravity
|
|
66
|
+
/**
|
|
67
|
+
* Image generation models - always route to Antigravity.
|
|
68
|
+
* These models don't support thinking and require imageConfig.
|
|
69
|
+
*/
|
|
70
|
+
const IMAGE_GENERATION_MODELS = /image|imagen/i;
|
|
71
|
+
// Legacy LEGACY_ANTIGRAVITY_GEMINI3 regex removed - all Gemini models now default to antigravity
|
|
72
|
+
/**
|
|
73
|
+
* Models that support thinking tier suffixes.
|
|
74
|
+
* Only these models should have -low/-medium/-high stripped as thinking tiers.
|
|
75
|
+
* GPT models like gpt-oss-120b-medium should NOT have -medium stripped.
|
|
76
|
+
*/
|
|
77
|
+
function supportsThinkingTiers(model) {
|
|
78
|
+
const lower = model.toLowerCase();
|
|
79
|
+
return (lower.includes("gemini-3") ||
|
|
80
|
+
lower.includes("gemini-2.5") ||
|
|
81
|
+
(lower.includes("claude") && lower.includes("thinking")));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Extracts thinking tier from model name suffix.
|
|
85
|
+
* Only extracts tier for models that support thinking tiers.
|
|
86
|
+
*/
|
|
87
|
+
function extractThinkingTierFromModel(model) {
|
|
88
|
+
// Only extract tier for models that support thinking tiers
|
|
89
|
+
if (!supportsThinkingTiers(model)) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const tierMatch = model.match(TIER_REGEX);
|
|
93
|
+
return tierMatch?.[1];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Determines the budget family for a model.
|
|
97
|
+
*/
|
|
98
|
+
function getBudgetFamily(model) {
|
|
99
|
+
if (model.includes("claude")) {
|
|
100
|
+
return "claude";
|
|
101
|
+
}
|
|
102
|
+
if (model.includes("gemini-2.5-pro")) {
|
|
103
|
+
return "gemini-2.5-pro";
|
|
104
|
+
}
|
|
105
|
+
if (model.includes("gemini-2.5-flash")) {
|
|
106
|
+
return "gemini-2.5-flash";
|
|
107
|
+
}
|
|
108
|
+
return "default";
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Checks if a model is a thinking-capable model.
|
|
112
|
+
*/
|
|
113
|
+
function isThinkingCapableModel(model) {
|
|
114
|
+
const lower = model.toLowerCase();
|
|
115
|
+
return (lower.includes("thinking") ||
|
|
116
|
+
lower.includes("gemini-3") ||
|
|
117
|
+
lower.includes("gemini-2.5"));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Resolves a model name with optional tier suffix and quota prefix to its actual API model name
|
|
121
|
+
* and corresponding thinking configuration.
|
|
122
|
+
*
|
|
123
|
+
* Quota routing:
|
|
124
|
+
* - Default to Antigravity quota unless cli_first is enabled for Gemini models
|
|
125
|
+
* - Fallback to Gemini CLI happens at account rotation level when Antigravity is exhausted
|
|
126
|
+
* - "antigravity-" prefix marks explicit quota (no fallback allowed)
|
|
127
|
+
* - Claude and image models always use Antigravity
|
|
128
|
+
*
|
|
129
|
+
* Examples:
|
|
130
|
+
* - "gemini-2.5-flash" → { quotaPreference: "antigravity" }
|
|
131
|
+
* - "gemini-3-pro-preview" → { quotaPreference: "antigravity" }
|
|
132
|
+
* - "antigravity-gemini-3-pro-high" → { quotaPreference: "antigravity", explicitQuota: true }
|
|
133
|
+
* - "claude-sonnet-4-5-thinking-medium" → { quotaPreference: "antigravity" }
|
|
134
|
+
*
|
|
135
|
+
* @param requestedModel - The model name from the request
|
|
136
|
+
* @param options - Optional configuration including cli_first preference
|
|
137
|
+
* @returns Resolved model with thinking configuration
|
|
138
|
+
*/
|
|
139
|
+
export function resolveModelWithTier(requestedModel, options = {}) {
|
|
140
|
+
const isAntigravity = QUOTA_PREFIX_REGEX.test(requestedModel);
|
|
141
|
+
const modelWithoutQuota = requestedModel.replace(QUOTA_PREFIX_REGEX, "");
|
|
142
|
+
const tier = extractThinkingTierFromModel(modelWithoutQuota);
|
|
143
|
+
const baseName = tier
|
|
144
|
+
? modelWithoutQuota.replace(TIER_REGEX, "")
|
|
145
|
+
: modelWithoutQuota;
|
|
146
|
+
const isImageModel = IMAGE_GENERATION_MODELS.test(modelWithoutQuota);
|
|
147
|
+
const isClaudeModel = modelWithoutQuota.toLowerCase().includes("claude");
|
|
148
|
+
// All models default to Antigravity quota unless cli_first is enabled
|
|
149
|
+
// Fallback to gemini-cli happens at the account rotation level when Antigravity is exhausted
|
|
150
|
+
const preferGeminiCli = options.cli_first === true &&
|
|
151
|
+
!isAntigravity &&
|
|
152
|
+
!isImageModel &&
|
|
153
|
+
!isClaudeModel;
|
|
154
|
+
const quotaPreference = preferGeminiCli
|
|
155
|
+
? "gemini-cli"
|
|
156
|
+
: "antigravity";
|
|
157
|
+
const explicitQuota = isAntigravity || isImageModel;
|
|
158
|
+
const isGemini3 = modelWithoutQuota.toLowerCase().startsWith("gemini-3");
|
|
159
|
+
const skipAlias = isAntigravity && isGemini3;
|
|
160
|
+
// For Antigravity Gemini 3 Pro models without explicit tier, append default tier (-low)
|
|
161
|
+
// Antigravity API: gemini-3-pro requires tier suffix (gemini-3-pro-low/high)
|
|
162
|
+
// gemini-3-flash uses bare name + thinkingLevel param
|
|
163
|
+
const isGemini3Pro = modelWithoutQuota
|
|
164
|
+
.toLowerCase()
|
|
165
|
+
.startsWith("gemini-3-pro");
|
|
166
|
+
const isGemini3Flash = modelWithoutQuota
|
|
167
|
+
.toLowerCase()
|
|
168
|
+
.startsWith("gemini-3-flash");
|
|
169
|
+
let antigravityModel = modelWithoutQuota;
|
|
170
|
+
if (skipAlias) {
|
|
171
|
+
if (isGemini3Pro && !tier && !isImageModel) {
|
|
172
|
+
antigravityModel = `${modelWithoutQuota}-low`;
|
|
173
|
+
}
|
|
174
|
+
else if (isGemini3Flash && tier) {
|
|
175
|
+
antigravityModel = baseName;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const actualModel = skipAlias
|
|
179
|
+
? antigravityModel
|
|
180
|
+
: MODEL_ALIASES[modelWithoutQuota] || MODEL_ALIASES[baseName] || baseName;
|
|
181
|
+
const resolvedModel = MODEL_FALLBACKS[actualModel] || actualModel;
|
|
182
|
+
const isThinking = isThinkingCapableModel(resolvedModel);
|
|
183
|
+
// Image generation models don't support thinking - return early without thinking config
|
|
184
|
+
if (isImageModel) {
|
|
185
|
+
return {
|
|
186
|
+
actualModel: resolvedModel,
|
|
187
|
+
isThinkingModel: false,
|
|
188
|
+
isImageModel: true,
|
|
189
|
+
quotaPreference,
|
|
190
|
+
explicitQuota,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
// Check if this is a Gemini 3 model (works for both aliased and skipAlias paths)
|
|
194
|
+
const isEffectiveGemini3 = resolvedModel.toLowerCase().includes("gemini-3");
|
|
195
|
+
const isClaudeThinking = resolvedModel.toLowerCase().includes("claude") &&
|
|
196
|
+
resolvedModel.toLowerCase().includes("thinking");
|
|
197
|
+
if (!tier) {
|
|
198
|
+
// Gemini 3 models without explicit tier get a default thinkingLevel
|
|
199
|
+
if (isEffectiveGemini3) {
|
|
200
|
+
// Both Pro and Flash default to "low" per Google's API docs
|
|
201
|
+
return {
|
|
202
|
+
actualModel: resolvedModel,
|
|
203
|
+
thinkingLevel: "low",
|
|
204
|
+
isThinkingModel: true,
|
|
205
|
+
quotaPreference,
|
|
206
|
+
explicitQuota,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// Claude thinking models without explicit tier get max budget (32768)
|
|
210
|
+
// Per Anthropic docs, budget_tokens is required when enabling extended thinking
|
|
211
|
+
if (isClaudeThinking) {
|
|
212
|
+
return {
|
|
213
|
+
actualModel: resolvedModel,
|
|
214
|
+
thinkingBudget: THINKING_TIER_BUDGETS.claude.high,
|
|
215
|
+
isThinkingModel: true,
|
|
216
|
+
quotaPreference,
|
|
217
|
+
explicitQuota,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
actualModel: resolvedModel,
|
|
222
|
+
isThinkingModel: isThinking,
|
|
223
|
+
quotaPreference,
|
|
224
|
+
explicitQuota,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// Gemini 3 models with tier always get thinkingLevel set
|
|
228
|
+
if (isEffectiveGemini3) {
|
|
229
|
+
return {
|
|
230
|
+
actualModel: resolvedModel,
|
|
231
|
+
thinkingLevel: tier,
|
|
232
|
+
tier,
|
|
233
|
+
isThinkingModel: true,
|
|
234
|
+
quotaPreference,
|
|
235
|
+
explicitQuota,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const budgetFamily = getBudgetFamily(resolvedModel);
|
|
239
|
+
const budgets = THINKING_TIER_BUDGETS[budgetFamily];
|
|
240
|
+
const thinkingBudget = budgets[tier];
|
|
241
|
+
return {
|
|
242
|
+
actualModel: resolvedModel,
|
|
243
|
+
thinkingBudget,
|
|
244
|
+
tier,
|
|
245
|
+
isThinkingModel: isThinking,
|
|
246
|
+
quotaPreference,
|
|
247
|
+
explicitQuota,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Gets the model family for routing decisions.
|
|
252
|
+
*/
|
|
253
|
+
export function getModelFamily(model) {
|
|
254
|
+
const lower = model.toLowerCase();
|
|
255
|
+
if (lower.includes("claude")) {
|
|
256
|
+
return "claude";
|
|
257
|
+
}
|
|
258
|
+
if (lower.includes("flash")) {
|
|
259
|
+
return "gemini-flash";
|
|
260
|
+
}
|
|
261
|
+
return "gemini-pro";
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Maps a thinking budget to Gemini 3 thinking level.
|
|
265
|
+
* ≤8192 → low, ≤16384 → medium, >16384 → high
|
|
266
|
+
*/
|
|
267
|
+
function budgetToGemini3Level(budget) {
|
|
268
|
+
if (budget <= 8192)
|
|
269
|
+
return "low";
|
|
270
|
+
if (budget <= 16384)
|
|
271
|
+
return "medium";
|
|
272
|
+
return "high";
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Resolves model name for a specific headerStyle (quota fallback support).
|
|
276
|
+
* Transforms model names when switching between gemini-cli and antigravity quotas.
|
|
277
|
+
*
|
|
278
|
+
* Issue #103: When quota fallback occurs, model names need to be transformed:
|
|
279
|
+
* - gemini-3-flash-preview (gemini-cli) → gemini-3-flash (antigravity)
|
|
280
|
+
* - gemini-3-pro-preview (gemini-cli) → gemini-3-pro-low (antigravity)
|
|
281
|
+
* - gemini-3-flash (antigravity) → gemini-3-flash-preview (gemini-cli)
|
|
282
|
+
*/
|
|
283
|
+
export function resolveModelForHeaderStyle(requestedModel, headerStyle) {
|
|
284
|
+
const lower = requestedModel.toLowerCase();
|
|
285
|
+
const isGemini3 = lower.includes("gemini-3");
|
|
286
|
+
if (!isGemini3) {
|
|
287
|
+
return resolveModelWithTier(requestedModel);
|
|
288
|
+
}
|
|
289
|
+
if (headerStyle === "antigravity") {
|
|
290
|
+
let transformedModel = requestedModel
|
|
291
|
+
.replace(/-preview$/i, "")
|
|
292
|
+
.replace(/^antigravity-/i, "");
|
|
293
|
+
const isGemini3Pro = transformedModel
|
|
294
|
+
.toLowerCase()
|
|
295
|
+
.startsWith("gemini-3-pro");
|
|
296
|
+
const hasTierSuffix = /-(low|medium|high)$/i.test(transformedModel);
|
|
297
|
+
const isImageModel = IMAGE_GENERATION_MODELS.test(transformedModel);
|
|
298
|
+
// Don't add tier suffix to image models - they don't support thinking
|
|
299
|
+
if (isGemini3Pro && !hasTierSuffix && !isImageModel) {
|
|
300
|
+
transformedModel = `${transformedModel}-low`;
|
|
301
|
+
}
|
|
302
|
+
const prefixedModel = `antigravity-${transformedModel}`;
|
|
303
|
+
return resolveModelWithTier(prefixedModel);
|
|
304
|
+
}
|
|
305
|
+
if (headerStyle === "gemini-cli") {
|
|
306
|
+
let transformedModel = requestedModel
|
|
307
|
+
.replace(/^antigravity-/i, "")
|
|
308
|
+
.replace(/-(low|medium|high)$/i, "");
|
|
309
|
+
if (!transformedModel.endsWith("-preview")) {
|
|
310
|
+
transformedModel = `${transformedModel}-preview`;
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
...resolveModelWithTier(transformedModel),
|
|
314
|
+
quotaPreference: "gemini-cli",
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
return resolveModelWithTier(requestedModel);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Resolves model with variant config from providerOptions.
|
|
321
|
+
* Variant config takes priority over tier suffix in model name.
|
|
322
|
+
*/
|
|
323
|
+
export function resolveModelWithVariant(requestedModel, variantConfig) {
|
|
324
|
+
const base = resolveModelWithTier(requestedModel);
|
|
325
|
+
if (!variantConfig) {
|
|
326
|
+
return base;
|
|
327
|
+
}
|
|
328
|
+
// Apply Google Search config if present
|
|
329
|
+
if (variantConfig.googleSearch) {
|
|
330
|
+
base.googleSearch = variantConfig.googleSearch;
|
|
331
|
+
base.configSource = "variant";
|
|
332
|
+
}
|
|
333
|
+
if (!variantConfig.thinkingBudget) {
|
|
334
|
+
return base;
|
|
335
|
+
}
|
|
336
|
+
const budget = variantConfig.thinkingBudget;
|
|
337
|
+
const isGemini3 = base.actualModel.toLowerCase().includes("gemini-3");
|
|
338
|
+
if (isGemini3) {
|
|
339
|
+
const level = budgetToGemini3Level(budget);
|
|
340
|
+
const isAntigravityGemini3Pro = base.quotaPreference === "antigravity" &&
|
|
341
|
+
base.actualModel.toLowerCase().startsWith("gemini-3-pro");
|
|
342
|
+
let actualModel = base.actualModel;
|
|
343
|
+
if (isAntigravityGemini3Pro) {
|
|
344
|
+
const baseModel = base.actualModel.replace(/-(low|medium|high)$/, "");
|
|
345
|
+
actualModel = `${baseModel}-${level}`;
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
...base,
|
|
349
|
+
actualModel,
|
|
350
|
+
thinkingLevel: level,
|
|
351
|
+
thinkingBudget: undefined,
|
|
352
|
+
configSource: "variant",
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
...base,
|
|
357
|
+
thinkingBudget: budget,
|
|
358
|
+
configSource: "variant",
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
//# 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;AAQH;;;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;IACtC,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;CACE,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,8EAA8E;IAC9E,kEAAkE;IAClE,kBAAkB,EAAE,cAAc;IAClC,mBAAmB,EAAE,cAAc;IACnC,oBAAoB,EAAE,gBAAgB;IACtC,uBAAuB,EAAE,gBAAgB;IACzC,qBAAqB,EAAE,gBAAgB;IAEvC,wDAAwD;IACxD,0BAA0B,EAAE,mBAAmB;IAC/C,uCAAuC,EAAE,4BAA4B;IACrE,0CAA0C,EAAE,4BAA4B;IACxE,wCAAwC,EAAE,4BAA4B;IAEtE,qCAAqC,EAAE,0BAA0B;IACj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AAC;IAEtE,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,uBAAuB,GAC3B,IAAI,CAAC,eAAe,KAAK,aAAa;YACtC,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,111 @@
|
|
|
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
|
+
* Note: The new googleSearch API for Gemini 2.0+ does not support threshold
|
|
78
|
+
* configuration. The model automatically decides when to search.
|
|
79
|
+
* The threshold field is kept for backward compatibility but is ignored.
|
|
80
|
+
*/
|
|
81
|
+
export interface GoogleSearchConfig {
|
|
82
|
+
mode?: 'auto' | 'off';
|
|
83
|
+
/** @deprecated No longer used - kept for backward compatibility */
|
|
84
|
+
threshold?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Model resolution result with tier information.
|
|
88
|
+
*/
|
|
89
|
+
export interface ResolvedModel {
|
|
90
|
+
/** The actual model name for the API call */
|
|
91
|
+
actualModel: string;
|
|
92
|
+
/** Thinking level for Gemini 3 models */
|
|
93
|
+
thinkingLevel?: string;
|
|
94
|
+
/** Thinking budget for Claude/Gemini 2.5 */
|
|
95
|
+
thinkingBudget?: number;
|
|
96
|
+
/** The tier suffix that was extracted */
|
|
97
|
+
tier?: ThinkingTier;
|
|
98
|
+
/** Whether this is a thinking-capable model */
|
|
99
|
+
isThinkingModel?: boolean;
|
|
100
|
+
/** Whether this is an image generation model */
|
|
101
|
+
isImageModel?: boolean;
|
|
102
|
+
/** Quota preference - all models default to antigravity, with CLI as fallback */
|
|
103
|
+
quotaPreference?: HeaderStyle;
|
|
104
|
+
/** Whether user explicitly specified quota via suffix (vs default selection) */
|
|
105
|
+
explicitQuota?: boolean;
|
|
106
|
+
/** Source of thinking config: "variant" (providerOptions) or "tier" (model suffix) */
|
|
107
|
+
configSource?: "variant" | "tier";
|
|
108
|
+
/** Google Search configuration from variant or global config */
|
|
109
|
+
googleSearch?: GoogleSearchConfig;
|
|
110
|
+
}
|
|
111
|
+
//# 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;IACjC,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,gBAAgB,CAAC,EAAE,OA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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,97 @@
|
|
|
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
|
+
tool?: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
export interface RefreshParts {
|
|
89
|
+
refreshToken: string;
|
|
90
|
+
projectId?: string;
|
|
91
|
+
managedProjectId?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ProjectContextResult {
|
|
94
|
+
auth: OAuthAuthDetails;
|
|
95
|
+
effectiveProjectId: string;
|
|
96
|
+
}
|
|
97
|
+
//# 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,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC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
+
* ANSI escape codes and key parsing for interactive CLI menus.
|
|
3
|
+
* Works cross-platform (Windows/Mac/Linux).
|
|
4
|
+
*/
|
|
5
|
+
export declare const ANSI: {
|
|
6
|
+
readonly hide: "\u001B[?25l";
|
|
7
|
+
readonly show: "\u001B[?25h";
|
|
8
|
+
readonly up: (n?: number) => string;
|
|
9
|
+
readonly down: (n?: number) => string;
|
|
10
|
+
readonly clearLine: "\u001B[2K";
|
|
11
|
+
readonly clearScreen: "\u001B[2J";
|
|
12
|
+
readonly moveTo: (row: number, col: number) => string;
|
|
13
|
+
readonly cyan: "\u001B[36m";
|
|
14
|
+
readonly green: "\u001B[32m";
|
|
15
|
+
readonly red: "\u001B[31m";
|
|
16
|
+
readonly yellow: "\u001B[33m";
|
|
17
|
+
readonly dim: "\u001B[2m";
|
|
18
|
+
readonly bold: "\u001B[1m";
|
|
19
|
+
readonly reset: "\u001B[0m";
|
|
20
|
+
readonly inverse: "\u001B[7m";
|
|
21
|
+
};
|
|
22
|
+
export type KeyAction = 'up' | 'down' | 'enter' | 'escape' | 'escape-start' | null;
|
|
23
|
+
/**
|
|
24
|
+
* Parse raw keyboard input buffer into a key action.
|
|
25
|
+
* Handles Windows/Mac/Linux differences in arrow key sequences.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseKey(data: Buffer): KeyAction;
|
|
28
|
+
/**
|
|
29
|
+
* Check if the terminal supports interactive input.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isTTY(): boolean;
|
|
32
|
+
//# sourceMappingURL=ansi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../../../../src/plugin/ui/ansi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,IAAI;;;;;;;2BAQD,MAAM,OAAO,MAAM;;;;;;;;;CAWzB,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,cAAc,GAAG,IAAI,CAAC;AAEnF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAiBhD;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAE/B"}
|