antigravity-auth 1.6.0 → 1.7.1

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.
Files changed (258) hide show
  1. package/README.md +79 -41
  2. package/dist/cli.js +17854 -0
  3. package/dist/handler.js +25147 -0
  4. package/dist/index.js +25138 -5
  5. package/package.json +66 -54
  6. package/dist/antigravity/oauth.d.ts +0 -30
  7. package/dist/antigravity/oauth.js +0 -170
  8. package/dist/claude/login.d.ts +0 -7
  9. package/dist/claude/login.js +0 -480
  10. package/dist/claude/menu-helpers.d.ts +0 -22
  11. package/dist/claude/menu-helpers.js +0 -281
  12. package/dist/claude/proxy-manager.d.ts +0 -11
  13. package/dist/claude/proxy-manager.js +0 -129
  14. package/dist/claude/proxy.d.ts +0 -1
  15. package/dist/claude/proxy.js +0 -733
  16. package/dist/constants.d.ts +0 -138
  17. package/dist/constants.js +0 -216
  18. package/dist/hooks/auto-update-checker/cache.d.ts +0 -2
  19. package/dist/hooks/auto-update-checker/cache.js +0 -70
  20. package/dist/hooks/auto-update-checker/checker.d.ts +0 -15
  21. package/dist/hooks/auto-update-checker/checker.js +0 -233
  22. package/dist/hooks/auto-update-checker/constants.d.ts +0 -8
  23. package/dist/hooks/auto-update-checker/constants.js +0 -22
  24. package/dist/hooks/auto-update-checker/index.d.ts +0 -33
  25. package/dist/hooks/auto-update-checker/index.js +0 -121
  26. package/dist/hooks/auto-update-checker/logging.d.ts +0 -2
  27. package/dist/hooks/auto-update-checker/logging.js +0 -8
  28. package/dist/hooks/auto-update-checker/types.d.ts +0 -24
  29. package/dist/hooks/auto-update-checker/types.js +0 -1
  30. package/dist/index.d.ts +0 -6
  31. package/dist/opencode/hooks/auto-update-checker/cache.d.ts +0 -2
  32. package/dist/opencode/hooks/auto-update-checker/cache.js +0 -70
  33. package/dist/opencode/hooks/auto-update-checker/checker.d.ts +0 -15
  34. package/dist/opencode/hooks/auto-update-checker/checker.js +0 -233
  35. package/dist/opencode/hooks/auto-update-checker/constants.d.ts +0 -8
  36. package/dist/opencode/hooks/auto-update-checker/constants.js +0 -22
  37. package/dist/opencode/hooks/auto-update-checker/index.d.ts +0 -33
  38. package/dist/opencode/hooks/auto-update-checker/index.js +0 -121
  39. package/dist/opencode/hooks/auto-update-checker/logging.d.ts +0 -2
  40. package/dist/opencode/hooks/auto-update-checker/logging.js +0 -8
  41. package/dist/opencode/hooks/auto-update-checker/types.d.ts +0 -24
  42. package/dist/opencode/hooks/auto-update-checker/types.js +0 -1
  43. package/dist/opencode/plugin.d.ts +0 -29
  44. package/dist/opencode/plugin.js +0 -2954
  45. package/dist/plugin/accounts.d.ts +0 -173
  46. package/dist/plugin/accounts.js +0 -966
  47. package/dist/plugin/auth.d.ts +0 -20
  48. package/dist/plugin/auth.js +0 -44
  49. package/dist/plugin/cache/index.d.ts +0 -4
  50. package/dist/plugin/cache/index.js +0 -4
  51. package/dist/plugin/cache/signature-cache.d.ts +0 -110
  52. package/dist/plugin/cache/signature-cache.js +0 -347
  53. package/dist/plugin/cache.d.ts +0 -43
  54. package/dist/plugin/cache.js +0 -180
  55. package/dist/plugin/cli.d.ts +0 -26
  56. package/dist/plugin/cli.js +0 -126
  57. package/dist/plugin/config/index.d.ts +0 -15
  58. package/dist/plugin/config/index.js +0 -15
  59. package/dist/plugin/config/loader.d.ts +0 -38
  60. package/dist/plugin/config/loader.js +0 -150
  61. package/dist/plugin/config/models.d.ts +0 -26
  62. package/dist/plugin/config/models.js +0 -95
  63. package/dist/plugin/config/schema.d.ts +0 -144
  64. package/dist/plugin/config/schema.js +0 -458
  65. package/dist/plugin/config/updater.d.ts +0 -76
  66. package/dist/plugin/config/updater.js +0 -205
  67. package/dist/plugin/core/streaming/index.d.ts +0 -2
  68. package/dist/plugin/core/streaming/index.js +0 -2
  69. package/dist/plugin/core/streaming/transformer.d.ts +0 -9
  70. package/dist/plugin/core/streaming/transformer.js +0 -301
  71. package/dist/plugin/core/streaming/types.d.ts +0 -28
  72. package/dist/plugin/core/streaming/types.js +0 -1
  73. package/dist/plugin/debug.d.ts +0 -93
  74. package/dist/plugin/debug.js +0 -375
  75. package/dist/plugin/errors.d.ts +0 -27
  76. package/dist/plugin/errors.js +0 -41
  77. package/dist/plugin/fingerprint.d.ts +0 -69
  78. package/dist/plugin/fingerprint.js +0 -137
  79. package/dist/plugin/image-saver.d.ts +0 -24
  80. package/dist/plugin/image-saver.js +0 -78
  81. package/dist/plugin/logger.d.ts +0 -35
  82. package/dist/plugin/logger.js +0 -67
  83. package/dist/plugin/logging-utils.d.ts +0 -22
  84. package/dist/plugin/logging-utils.js +0 -91
  85. package/dist/plugin/project.d.ts +0 -32
  86. package/dist/plugin/project.js +0 -229
  87. package/dist/plugin/quota.d.ts +0 -34
  88. package/dist/plugin/quota.js +0 -261
  89. package/dist/plugin/recovery/constants.d.ts +0 -21
  90. package/dist/plugin/recovery/constants.js +0 -42
  91. package/dist/plugin/recovery/index.d.ts +0 -11
  92. package/dist/plugin/recovery/index.js +0 -11
  93. package/dist/plugin/recovery/storage.d.ts +0 -23
  94. package/dist/plugin/recovery/storage.js +0 -340
  95. package/dist/plugin/recovery/types.d.ts +0 -115
  96. package/dist/plugin/recovery/types.js +0 -6
  97. package/dist/plugin/recovery.d.ts +0 -60
  98. package/dist/plugin/recovery.js +0 -360
  99. package/dist/plugin/refresh-queue.d.ts +0 -99
  100. package/dist/plugin/refresh-queue.js +0 -235
  101. package/dist/plugin/request-helpers.d.ts +0 -281
  102. package/dist/plugin/request-helpers.js +0 -2200
  103. package/dist/plugin/request.d.ts +0 -110
  104. package/dist/plugin/request.js +0 -1489
  105. package/dist/plugin/rotation.d.ts +0 -182
  106. package/dist/plugin/rotation.js +0 -364
  107. package/dist/plugin/search.d.ts +0 -31
  108. package/dist/plugin/search.js +0 -185
  109. package/dist/plugin/server.d.ts +0 -22
  110. package/dist/plugin/server.js +0 -306
  111. package/dist/plugin/storage.d.ts +0 -136
  112. package/dist/plugin/storage.js +0 -599
  113. package/dist/plugin/stores/signature-store.d.ts +0 -4
  114. package/dist/plugin/stores/signature-store.js +0 -24
  115. package/dist/plugin/thinking-recovery.d.ts +0 -89
  116. package/dist/plugin/thinking-recovery.js +0 -289
  117. package/dist/plugin/token.d.ts +0 -18
  118. package/dist/plugin/token.js +0 -127
  119. package/dist/plugin/transform/claude.d.ts +0 -79
  120. package/dist/plugin/transform/claude.js +0 -256
  121. package/dist/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  122. package/dist/plugin/transform/cross-model-sanitizer.js +0 -224
  123. package/dist/plugin/transform/gemini.d.ts +0 -132
  124. package/dist/plugin/transform/gemini.js +0 -659
  125. package/dist/plugin/transform/index.d.ts +0 -14
  126. package/dist/plugin/transform/index.js +0 -9
  127. package/dist/plugin/transform/model-resolver.d.ts +0 -98
  128. package/dist/plugin/transform/model-resolver.js +0 -320
  129. package/dist/plugin/transform/types.d.ts +0 -110
  130. package/dist/plugin/transform/types.js +0 -1
  131. package/dist/plugin/types.d.ts +0 -95
  132. package/dist/plugin/types.js +0 -1
  133. package/dist/plugin/ui/ansi.d.ts +0 -31
  134. package/dist/plugin/ui/ansi.js +0 -45
  135. package/dist/plugin/ui/auth-menu.d.ts +0 -47
  136. package/dist/plugin/ui/auth-menu.js +0 -199
  137. package/dist/plugin/ui/confirm.d.ts +0 -1
  138. package/dist/plugin/ui/confirm.js +0 -14
  139. package/dist/plugin/ui/select.d.ts +0 -22
  140. package/dist/plugin/ui/select.js +0 -243
  141. package/dist/plugin/version.d.ts +0 -18
  142. package/dist/plugin/version.js +0 -79
  143. package/dist/src/antigravity/oauth.d.ts +0 -30
  144. package/dist/src/antigravity/oauth.js +0 -170
  145. package/dist/src/constants.d.ts +0 -138
  146. package/dist/src/constants.js +0 -216
  147. package/dist/src/hooks/auto-update-checker/cache.d.ts +0 -2
  148. package/dist/src/hooks/auto-update-checker/cache.js +0 -70
  149. package/dist/src/hooks/auto-update-checker/checker.d.ts +0 -15
  150. package/dist/src/hooks/auto-update-checker/checker.js +0 -233
  151. package/dist/src/hooks/auto-update-checker/constants.d.ts +0 -8
  152. package/dist/src/hooks/auto-update-checker/constants.js +0 -22
  153. package/dist/src/hooks/auto-update-checker/index.d.ts +0 -33
  154. package/dist/src/hooks/auto-update-checker/index.js +0 -121
  155. package/dist/src/hooks/auto-update-checker/logging.d.ts +0 -2
  156. package/dist/src/hooks/auto-update-checker/logging.js +0 -8
  157. package/dist/src/hooks/auto-update-checker/types.d.ts +0 -24
  158. package/dist/src/hooks/auto-update-checker/types.js +0 -1
  159. package/dist/src/index.d.ts +0 -6
  160. package/dist/src/index.js +0 -5
  161. package/dist/src/plugin/accounts.d.ts +0 -173
  162. package/dist/src/plugin/accounts.js +0 -966
  163. package/dist/src/plugin/auth.d.ts +0 -20
  164. package/dist/src/plugin/auth.js +0 -44
  165. package/dist/src/plugin/cache/index.d.ts +0 -4
  166. package/dist/src/plugin/cache/index.js +0 -4
  167. package/dist/src/plugin/cache/signature-cache.d.ts +0 -110
  168. package/dist/src/plugin/cache/signature-cache.js +0 -347
  169. package/dist/src/plugin/cache.d.ts +0 -43
  170. package/dist/src/plugin/cache.js +0 -180
  171. package/dist/src/plugin/cli.d.ts +0 -26
  172. package/dist/src/plugin/cli.js +0 -126
  173. package/dist/src/plugin/config/index.d.ts +0 -15
  174. package/dist/src/plugin/config/index.js +0 -15
  175. package/dist/src/plugin/config/loader.d.ts +0 -38
  176. package/dist/src/plugin/config/loader.js +0 -150
  177. package/dist/src/plugin/config/models.d.ts +0 -26
  178. package/dist/src/plugin/config/models.js +0 -95
  179. package/dist/src/plugin/config/schema.d.ts +0 -144
  180. package/dist/src/plugin/config/schema.js +0 -458
  181. package/dist/src/plugin/config/updater.d.ts +0 -76
  182. package/dist/src/plugin/config/updater.js +0 -205
  183. package/dist/src/plugin/core/streaming/index.d.ts +0 -2
  184. package/dist/src/plugin/core/streaming/index.js +0 -2
  185. package/dist/src/plugin/core/streaming/transformer.d.ts +0 -9
  186. package/dist/src/plugin/core/streaming/transformer.js +0 -301
  187. package/dist/src/plugin/core/streaming/types.d.ts +0 -28
  188. package/dist/src/plugin/core/streaming/types.js +0 -1
  189. package/dist/src/plugin/debug.d.ts +0 -93
  190. package/dist/src/plugin/debug.js +0 -375
  191. package/dist/src/plugin/errors.d.ts +0 -27
  192. package/dist/src/plugin/errors.js +0 -41
  193. package/dist/src/plugin/fingerprint.d.ts +0 -69
  194. package/dist/src/plugin/fingerprint.js +0 -137
  195. package/dist/src/plugin/image-saver.d.ts +0 -24
  196. package/dist/src/plugin/image-saver.js +0 -78
  197. package/dist/src/plugin/logger.d.ts +0 -35
  198. package/dist/src/plugin/logger.js +0 -67
  199. package/dist/src/plugin/logging-utils.d.ts +0 -22
  200. package/dist/src/plugin/logging-utils.js +0 -91
  201. package/dist/src/plugin/project.d.ts +0 -32
  202. package/dist/src/plugin/project.js +0 -229
  203. package/dist/src/plugin/quota.d.ts +0 -34
  204. package/dist/src/plugin/quota.js +0 -261
  205. package/dist/src/plugin/recovery/constants.d.ts +0 -21
  206. package/dist/src/plugin/recovery/constants.js +0 -42
  207. package/dist/src/plugin/recovery/index.d.ts +0 -11
  208. package/dist/src/plugin/recovery/index.js +0 -11
  209. package/dist/src/plugin/recovery/storage.d.ts +0 -23
  210. package/dist/src/plugin/recovery/storage.js +0 -340
  211. package/dist/src/plugin/recovery/types.d.ts +0 -115
  212. package/dist/src/plugin/recovery/types.js +0 -6
  213. package/dist/src/plugin/recovery.d.ts +0 -60
  214. package/dist/src/plugin/recovery.js +0 -360
  215. package/dist/src/plugin/refresh-queue.d.ts +0 -99
  216. package/dist/src/plugin/refresh-queue.js +0 -235
  217. package/dist/src/plugin/request-helpers.d.ts +0 -281
  218. package/dist/src/plugin/request-helpers.js +0 -2200
  219. package/dist/src/plugin/request.d.ts +0 -110
  220. package/dist/src/plugin/request.js +0 -1489
  221. package/dist/src/plugin/rotation.d.ts +0 -182
  222. package/dist/src/plugin/rotation.js +0 -364
  223. package/dist/src/plugin/search.d.ts +0 -31
  224. package/dist/src/plugin/search.js +0 -185
  225. package/dist/src/plugin/server.d.ts +0 -22
  226. package/dist/src/plugin/server.js +0 -306
  227. package/dist/src/plugin/storage.d.ts +0 -136
  228. package/dist/src/plugin/storage.js +0 -599
  229. package/dist/src/plugin/stores/signature-store.d.ts +0 -4
  230. package/dist/src/plugin/stores/signature-store.js +0 -24
  231. package/dist/src/plugin/thinking-recovery.d.ts +0 -89
  232. package/dist/src/plugin/thinking-recovery.js +0 -289
  233. package/dist/src/plugin/token.d.ts +0 -18
  234. package/dist/src/plugin/token.js +0 -127
  235. package/dist/src/plugin/transform/claude.d.ts +0 -79
  236. package/dist/src/plugin/transform/claude.js +0 -256
  237. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  238. package/dist/src/plugin/transform/cross-model-sanitizer.js +0 -224
  239. package/dist/src/plugin/transform/gemini.d.ts +0 -132
  240. package/dist/src/plugin/transform/gemini.js +0 -659
  241. package/dist/src/plugin/transform/index.d.ts +0 -14
  242. package/dist/src/plugin/transform/index.js +0 -9
  243. package/dist/src/plugin/transform/model-resolver.d.ts +0 -98
  244. package/dist/src/plugin/transform/model-resolver.js +0 -320
  245. package/dist/src/plugin/transform/types.d.ts +0 -110
  246. package/dist/src/plugin/transform/types.js +0 -1
  247. package/dist/src/plugin/types.d.ts +0 -95
  248. package/dist/src/plugin/types.js +0 -1
  249. package/dist/src/plugin/ui/ansi.d.ts +0 -31
  250. package/dist/src/plugin/ui/ansi.js +0 -45
  251. package/dist/src/plugin/ui/auth-menu.d.ts +0 -47
  252. package/dist/src/plugin/ui/auth-menu.js +0 -199
  253. package/dist/src/plugin/ui/confirm.d.ts +0 -1
  254. package/dist/src/plugin/ui/confirm.js +0 -14
  255. package/dist/src/plugin/ui/select.d.ts +0 -22
  256. package/dist/src/plugin/ui/select.js +0 -243
  257. package/dist/src/plugin/version.d.ts +0 -18
  258. package/dist/src/plugin/version.js +0 -79
@@ -1,98 +0,0 @@
1
- /**
2
- * Model Resolution with Thinking Tier Support
3
- *
4
- * Resolves model names with tier suffixes (e.g., gemini-3-pro-high, claude-opus-4-6-thinking-low)
5
- * to their actual API model names and corresponding thinking configurations.
6
- */
7
- import type { ResolvedModel, GoogleSearchConfig } from "./types";
8
- export interface ModelResolverOptions {
9
- cli_first?: boolean;
10
- }
11
- /**
12
- * Thinking tier budgets by model family.
13
- * Claude and Gemini 2.5 Pro use numeric budgets.
14
- */
15
- export declare const THINKING_TIER_BUDGETS: {
16
- readonly claude: {
17
- readonly low: 8192;
18
- readonly medium: 16384;
19
- readonly high: 32768;
20
- };
21
- readonly "gemini-2.5-pro": {
22
- readonly low: 8192;
23
- readonly medium: 16384;
24
- readonly high: 32768;
25
- };
26
- readonly "gemini-2.5-flash": {
27
- readonly low: 6144;
28
- readonly medium: 12288;
29
- readonly high: 24576;
30
- };
31
- readonly default: {
32
- readonly low: 4096;
33
- readonly medium: 8192;
34
- readonly high: 16384;
35
- };
36
- };
37
- /**
38
- * Gemini 3 uses thinkingLevel strings instead of numeric budgets.
39
- * Flash supports: minimal, low, medium, high
40
- * Pro supports: low, high (no minimal/medium)
41
- */
42
- export declare const GEMINI_3_THINKING_LEVELS: readonly ["minimal", "low", "medium", "high"];
43
- /**
44
- * Model aliases - maps user-friendly names to API model names.
45
- *
46
- * Format:
47
- * - Gemini 3 Pro variants: gemini-3-pro-{low,medium,high}
48
- * - Claude thinking variants: claude-{model}-thinking-{low,medium,high}
49
- * - Claude non-thinking: claude-{model} (no -thinking suffix)
50
- */
51
- export declare const MODEL_ALIASES: Record<string, string>;
52
- /**
53
- * Resolves a model name with optional tier suffix and quota prefix to its actual API model name
54
- * and corresponding thinking configuration.
55
- *
56
- * Quota routing:
57
- * - Default to Antigravity quota unless cli_first is enabled for Gemini models
58
- * - Fallback to Gemini CLI happens at account rotation level when Antigravity is exhausted
59
- * - "antigravity-" prefix marks explicit quota (no fallback allowed)
60
- * - Claude and image models always use Antigravity
61
- *
62
- * Examples:
63
- * - "gemini-2.5-flash" → { quotaPreference: "antigravity" }
64
- * - "gemini-3-pro-preview" → { quotaPreference: "antigravity" }
65
- * - "antigravity-gemini-3-pro-high" → { quotaPreference: "antigravity", explicitQuota: true }
66
- * - "claude-opus-4-6-thinking-medium" → { quotaPreference: "antigravity" }
67
- *
68
- * @param requestedModel - The model name from the request
69
- * @param options - Optional configuration including cli_first preference
70
- * @returns Resolved model with thinking configuration
71
- */
72
- export declare function resolveModelWithTier(requestedModel: string, options?: ModelResolverOptions): ResolvedModel;
73
- /**
74
- * Gets the model family for routing decisions.
75
- */
76
- export declare function getModelFamily(model: string): "claude" | "gemini-flash" | "gemini-pro";
77
- /**
78
- * Variant config from OpenCode's providerOptions.
79
- */
80
- export interface VariantConfig {
81
- thinkingBudget?: number;
82
- googleSearch?: GoogleSearchConfig;
83
- }
84
- /**
85
- * Resolves model name for a specific headerStyle (quota fallback support).
86
- * Transforms model names when switching between gemini-cli and antigravity quotas.
87
- *
88
- * Issue #103: When quota fallback occurs, model names need to be transformed:
89
- * - gemini-3-flash-preview (gemini-cli) → gemini-3-flash (antigravity)
90
- * - gemini-3-pro-preview (gemini-cli) → gemini-3-pro-low (antigravity)
91
- * - gemini-3-flash (antigravity) → gemini-3-flash-preview (gemini-cli)
92
- */
93
- export declare function resolveModelForHeaderStyle(requestedModel: string, headerStyle: "antigravity" | "gemini-cli"): ResolvedModel;
94
- /**
95
- * Resolves model with variant config from providerOptions.
96
- * Variant config takes priority over tier suffix in model name.
97
- */
98
- export declare function resolveModelWithVariant(requestedModel: string, variantConfig?: VariantConfig): ResolvedModel;
@@ -1,320 +0,0 @@
1
- /**
2
- * Model Resolution with Thinking Tier Support
3
- *
4
- * Resolves model names with tier suffixes (e.g., gemini-3-pro-high, claude-opus-4-6-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-pro-low": "gemini-3-pro",
33
- "gemini-3-pro-high": "gemini-3-pro",
34
- "gemini-3.1-pro-low": "gemini-3.1-pro",
35
- "gemini-3.1-pro-high": "gemini-3.1-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
- "gemini-claude-opus-4-6-thinking-low": "claude-opus-4-6-thinking",
40
- "gemini-claude-opus-4-6-thinking-medium": "claude-opus-4-6-thinking",
41
- "gemini-claude-opus-4-6-thinking-high": "claude-opus-4-6-thinking",
42
- "gemini-claude-sonnet-4-6": "claude-sonnet-4-6",
43
- // Reference: Antigravity-Manager/src-tauri/src/proxy/common/model_mapping.rs
44
- };
45
- const TIER_REGEX = /-(minimal|low|medium|high)$/;
46
- const QUOTA_PREFIX_REGEX = /^antigravity-/i;
47
- const GEMINI_3_PRO_REGEX = /^gemini-3(?:\.\d+)?-pro/i;
48
- const GEMINI_3_FLASH_REGEX = /^gemini-3(?:\.\d+)?-flash/i;
49
- // ANTIGRAVITY_ONLY_MODELS removed - all models now default to antigravity
50
- /**
51
- * Image generation models - always route to Antigravity.
52
- * These models don't support thinking and require imageConfig.
53
- */
54
- const IMAGE_GENERATION_MODELS = /image|imagen/i;
55
- // Legacy LEGACY_ANTIGRAVITY_GEMINI3 regex removed - all Gemini models now default to antigravity
56
- /**
57
- * Models that support thinking tier suffixes.
58
- * Only these models should have -low/-medium/-high stripped as thinking tiers.
59
- * GPT models like gpt-oss-120b-medium should NOT have -medium stripped.
60
- */
61
- function supportsThinkingTiers(model) {
62
- const lower = model.toLowerCase();
63
- return (lower.includes("gemini-3") ||
64
- lower.includes("gemini-2.5") ||
65
- (lower.includes("claude") && lower.includes("thinking")));
66
- }
67
- /**
68
- * Extracts thinking tier from model name suffix.
69
- * Only extracts tier for models that support thinking tiers.
70
- */
71
- function extractThinkingTierFromModel(model) {
72
- if (!supportsThinkingTiers(model)) {
73
- return undefined;
74
- }
75
- const tierMatch = model.match(TIER_REGEX);
76
- return tierMatch?.[1];
77
- }
78
- /**
79
- * Determines the budget family for a model.
80
- */
81
- function getBudgetFamily(model) {
82
- if (model.includes("claude")) {
83
- return "claude";
84
- }
85
- if (model.includes("gemini-2.5-pro")) {
86
- return "gemini-2.5-pro";
87
- }
88
- if (model.includes("gemini-2.5-flash")) {
89
- return "gemini-2.5-flash";
90
- }
91
- return "default";
92
- }
93
- /**
94
- * Checks if a model is a thinking-capable model.
95
- */
96
- function isThinkingCapableModel(model) {
97
- const lower = model.toLowerCase();
98
- return (lower.includes("thinking") ||
99
- lower.includes("gemini-3") ||
100
- lower.includes("gemini-2.5"));
101
- }
102
- function isGemini3ProModel(model) {
103
- return GEMINI_3_PRO_REGEX.test(model);
104
- }
105
- function isGemini3FlashModel(model) {
106
- return GEMINI_3_FLASH_REGEX.test(model);
107
- }
108
- /**
109
- * Resolves a model name with optional tier suffix and quota prefix to its actual API model name
110
- * and corresponding thinking configuration.
111
- *
112
- * Quota routing:
113
- * - Default to Antigravity quota unless cli_first is enabled for Gemini models
114
- * - Fallback to Gemini CLI happens at account rotation level when Antigravity is exhausted
115
- * - "antigravity-" prefix marks explicit quota (no fallback allowed)
116
- * - Claude and image models always use Antigravity
117
- *
118
- * Examples:
119
- * - "gemini-2.5-flash" → { quotaPreference: "antigravity" }
120
- * - "gemini-3-pro-preview" → { quotaPreference: "antigravity" }
121
- * - "antigravity-gemini-3-pro-high" → { quotaPreference: "antigravity", explicitQuota: true }
122
- * - "claude-opus-4-6-thinking-medium" → { quotaPreference: "antigravity" }
123
- *
124
- * @param requestedModel - The model name from the request
125
- * @param options - Optional configuration including cli_first preference
126
- * @returns Resolved model with thinking configuration
127
- */
128
- export function resolveModelWithTier(requestedModel, options = {}) {
129
- const isAntigravity = QUOTA_PREFIX_REGEX.test(requestedModel);
130
- const modelWithoutQuota = requestedModel.replace(QUOTA_PREFIX_REGEX, "");
131
- const tier = extractThinkingTierFromModel(modelWithoutQuota);
132
- const baseName = tier ? modelWithoutQuota.replace(TIER_REGEX, "") : modelWithoutQuota;
133
- const isImageModel = IMAGE_GENERATION_MODELS.test(modelWithoutQuota);
134
- const isClaudeModel = modelWithoutQuota.toLowerCase().includes("claude");
135
- // All models default to Antigravity quota unless cli_first is enabled
136
- const preferGeminiCli = options.cli_first === true && !isAntigravity && !isImageModel && !isClaudeModel;
137
- const quotaPreference = preferGeminiCli ? "gemini-cli" : "antigravity";
138
- const explicitQuota = isAntigravity || isImageModel;
139
- const isGemini3 = modelWithoutQuota.toLowerCase().startsWith("gemini-3");
140
- const skipAlias = isAntigravity && isGemini3;
141
- const isGemini3Pro = isGemini3ProModel(modelWithoutQuota);
142
- const isGemini3Flash = isGemini3FlashModel(modelWithoutQuota);
143
- let antigravityModel = modelWithoutQuota;
144
- if (skipAlias) {
145
- if (isGemini3Pro && !tier && !isImageModel) {
146
- antigravityModel = `${modelWithoutQuota}-low`;
147
- }
148
- else if (isGemini3Flash && tier) {
149
- antigravityModel = baseName;
150
- }
151
- }
152
- const actualModel = skipAlias
153
- ? antigravityModel
154
- : MODEL_ALIASES[modelWithoutQuota] || MODEL_ALIASES[baseName] || baseName;
155
- const resolvedModel = actualModel;
156
- const isThinking = isThinkingCapableModel(resolvedModel);
157
- if (isImageModel) {
158
- return {
159
- actualModel: resolvedModel,
160
- isThinkingModel: false,
161
- isImageModel: true,
162
- quotaPreference,
163
- explicitQuota,
164
- };
165
- }
166
- const isEffectiveGemini3 = resolvedModel.toLowerCase().includes("gemini-3");
167
- const isClaudeThinking = resolvedModel.toLowerCase().includes("claude") && resolvedModel.toLowerCase().includes("thinking");
168
- if (!tier) {
169
- if (isEffectiveGemini3) {
170
- return {
171
- actualModel: resolvedModel,
172
- thinkingLevel: "low",
173
- isThinkingModel: true,
174
- quotaPreference,
175
- explicitQuota,
176
- };
177
- }
178
- // Per Anthropic docs, budget_tokens is required when enabling extended thinking
179
- if (isClaudeThinking) {
180
- return {
181
- actualModel: resolvedModel,
182
- thinkingBudget: THINKING_TIER_BUDGETS.claude.high,
183
- isThinkingModel: true,
184
- quotaPreference,
185
- explicitQuota,
186
- };
187
- }
188
- return { actualModel: resolvedModel, isThinkingModel: isThinking, quotaPreference, explicitQuota };
189
- }
190
- if (isEffectiveGemini3) {
191
- return {
192
- actualModel: resolvedModel,
193
- thinkingLevel: tier,
194
- tier,
195
- isThinkingModel: true,
196
- quotaPreference,
197
- explicitQuota,
198
- };
199
- }
200
- const budgetFamily = getBudgetFamily(resolvedModel);
201
- const budgets = THINKING_TIER_BUDGETS[budgetFamily];
202
- const thinkingBudget = budgets[tier];
203
- return {
204
- actualModel: resolvedModel,
205
- thinkingBudget,
206
- tier,
207
- isThinkingModel: isThinking,
208
- quotaPreference,
209
- explicitQuota,
210
- };
211
- }
212
- /**
213
- * Gets the model family for routing decisions.
214
- */
215
- export function getModelFamily(model) {
216
- const lower = model.toLowerCase();
217
- if (lower.includes("claude")) {
218
- return "claude";
219
- }
220
- if (lower.includes("flash")) {
221
- return "gemini-flash";
222
- }
223
- return "gemini-pro";
224
- }
225
- /**
226
- * Maps a thinking budget to Gemini 3 thinking level.
227
- * ≤8192 → low, ≤16384 → medium, >16384 → high
228
- */
229
- function budgetToGemini3Level(budget) {
230
- if (budget <= 8192)
231
- return "low";
232
- if (budget <= 16384)
233
- return "medium";
234
- return "high";
235
- }
236
- /**
237
- * Resolves model name for a specific headerStyle (quota fallback support).
238
- * Transforms model names when switching between gemini-cli and antigravity quotas.
239
- *
240
- * Issue #103: When quota fallback occurs, model names need to be transformed:
241
- * - gemini-3-flash-preview (gemini-cli) → gemini-3-flash (antigravity)
242
- * - gemini-3-pro-preview (gemini-cli) → gemini-3-pro-low (antigravity)
243
- * - gemini-3-flash (antigravity) → gemini-3-flash-preview (gemini-cli)
244
- */
245
- export function resolveModelForHeaderStyle(requestedModel, headerStyle) {
246
- const lower = requestedModel.toLowerCase();
247
- const isGemini3 = lower.includes("gemini-3");
248
- if (!isGemini3) {
249
- return resolveModelWithTier(requestedModel);
250
- }
251
- if (headerStyle === "antigravity") {
252
- let transformedModel = requestedModel
253
- .replace(/-preview-customtools$/i, "")
254
- .replace(/-preview$/i, "")
255
- .replace(/^antigravity-/i, "");
256
- const isGemini3Pro = isGemini3ProModel(transformedModel);
257
- const hasTierSuffix = /-(low|medium|high)$/i.test(transformedModel);
258
- const isImageModel = IMAGE_GENERATION_MODELS.test(transformedModel);
259
- if (isGemini3Pro && !hasTierSuffix && !isImageModel) {
260
- transformedModel = `${transformedModel}-low`;
261
- }
262
- const prefixedModel = `antigravity-${transformedModel}`;
263
- return resolveModelWithTier(prefixedModel);
264
- }
265
- if (headerStyle === "gemini-cli") {
266
- let transformedModel = requestedModel
267
- .replace(/^antigravity-/i, "")
268
- .replace(/-(low|medium|high)$/i, "");
269
- const hasPreviewSuffix = /-preview($|-)/i.test(transformedModel);
270
- if (!hasPreviewSuffix) {
271
- transformedModel = `${transformedModel}-preview`;
272
- }
273
- return {
274
- ...resolveModelWithTier(transformedModel),
275
- quotaPreference: "gemini-cli",
276
- };
277
- }
278
- return resolveModelWithTier(requestedModel);
279
- }
280
- /**
281
- * Resolves model with variant config from providerOptions.
282
- * Variant config takes priority over tier suffix in model name.
283
- */
284
- export function resolveModelWithVariant(requestedModel, variantConfig) {
285
- const base = resolveModelWithTier(requestedModel);
286
- if (!variantConfig) {
287
- return base;
288
- }
289
- if (variantConfig.googleSearch) {
290
- base.googleSearch = variantConfig.googleSearch;
291
- base.configSource = "variant";
292
- }
293
- if (!variantConfig.thinkingBudget) {
294
- return base;
295
- }
296
- const budget = variantConfig.thinkingBudget;
297
- const isGemini3 = base.actualModel.toLowerCase().includes("gemini-3");
298
- if (isGemini3) {
299
- const level = budgetToGemini3Level(budget);
300
- const isAntigravityGemini3Pro = base.quotaPreference === "antigravity" &&
301
- isGemini3ProModel(base.actualModel);
302
- let actualModel = base.actualModel;
303
- if (isAntigravityGemini3Pro) {
304
- const baseModel = base.actualModel.replace(/-(low|medium|high)$/, "");
305
- actualModel = `${baseModel}-${level}`;
306
- }
307
- return {
308
- ...base,
309
- actualModel,
310
- thinkingLevel: level,
311
- thinkingBudget: undefined,
312
- configSource: "variant",
313
- };
314
- }
315
- return {
316
- ...base,
317
- thinkingBudget: budget,
318
- configSource: "variant",
319
- };
320
- }
@@ -1,110 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,95 +0,0 @@
1
- import type { AntigravityTokenExchangeResult } from "../antigravity/oauth";
2
- export interface OAuthAuthDetails {
3
- type: "oauth";
4
- refresh: string;
5
- access?: string;
6
- expires?: number;
7
- }
8
- export interface ApiKeyAuthDetails {
9
- type: "api_key";
10
- key: string;
11
- }
12
- export interface NonOAuthAuthDetails {
13
- type: string;
14
- [key: string]: unknown;
15
- }
16
- export type AuthDetails = OAuthAuthDetails | ApiKeyAuthDetails | NonOAuthAuthDetails;
17
- export type GetAuth = () => Promise<AuthDetails>;
18
- export interface ProviderModel {
19
- cost?: {
20
- input: number;
21
- output: number;
22
- };
23
- [key: string]: unknown;
24
- }
25
- export interface Provider {
26
- models?: Record<string, ProviderModel>;
27
- }
28
- export interface LoaderResult {
29
- apiKey: string;
30
- fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
31
- }
32
- export type PluginClient = any;
33
- export interface PluginContext {
34
- client: PluginClient;
35
- directory: string;
36
- }
37
- export type AuthPrompt = {
38
- type: "text";
39
- key: string;
40
- message: string;
41
- placeholder?: string;
42
- validate?: (value: string) => string | undefined;
43
- condition?: (inputs: Record<string, string>) => boolean;
44
- } | {
45
- type: "select";
46
- key: string;
47
- message: string;
48
- options: Array<{
49
- label: string;
50
- value: string;
51
- hint?: string;
52
- }>;
53
- condition?: (inputs: Record<string, string>) => boolean;
54
- };
55
- export type OAuthAuthorizationResult = {
56
- url: string;
57
- instructions: string;
58
- } & ({
59
- method: "auto";
60
- callback: () => Promise<AntigravityTokenExchangeResult>;
61
- } | {
62
- method: "code";
63
- callback: (code: string) => Promise<AntigravityTokenExchangeResult>;
64
- });
65
- export interface AuthMethod {
66
- provider?: string;
67
- label: string;
68
- type: "oauth" | "api";
69
- prompts?: AuthPrompt[];
70
- authorize?: (inputs?: Record<string, string>) => Promise<OAuthAuthorizationResult>;
71
- }
72
- export interface PluginEventPayload {
73
- event: {
74
- type: string;
75
- properties?: unknown;
76
- };
77
- }
78
- export interface PluginResult {
79
- auth: {
80
- provider: string;
81
- loader: (getAuth: GetAuth, provider: Provider) => Promise<LoaderResult | Record<string, unknown>>;
82
- methods: AuthMethod[];
83
- };
84
- event?: (payload: PluginEventPayload) => void;
85
- tool?: Record<string, unknown>;
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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
1
- /**
2
- * 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;