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.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +749 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/antigravity/oauth.d.ts +31 -0
  8. package/dist/src/antigravity/oauth.d.ts.map +1 -0
  9. package/dist/src/antigravity/oauth.js +171 -0
  10. package/dist/src/antigravity/oauth.js.map +1 -0
  11. package/dist/src/constants.d.ts +138 -0
  12. package/dist/src/constants.d.ts.map +1 -0
  13. package/dist/src/constants.js +220 -0
  14. package/dist/src/constants.js.map +1 -0
  15. package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
  16. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  17. package/dist/src/hooks/auto-update-checker/cache.js +71 -0
  18. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
  19. package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
  20. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  21. package/dist/src/hooks/auto-update-checker/checker.js +237 -0
  22. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
  23. package/dist/src/hooks/auto-update-checker/constants.d.ts +9 -0
  24. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  25. package/dist/src/hooks/auto-update-checker/constants.js +23 -0
  26. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
  27. package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
  28. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  29. package/dist/src/hooks/auto-update-checker/index.js +125 -0
  30. package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
  31. package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
  32. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  33. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  34. package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
  35. package/dist/src/plugin/accounts.d.ts +173 -0
  36. package/dist/src/plugin/accounts.d.ts.map +1 -0
  37. package/dist/src/plugin/accounts.js +1035 -0
  38. package/dist/src/plugin/accounts.js.map +1 -0
  39. package/dist/src/plugin/auth.d.ts +21 -0
  40. package/dist/src/plugin/auth.d.ts.map +1 -0
  41. package/dist/src/plugin/auth.js +46 -0
  42. package/dist/src/plugin/auth.js.map +1 -0
  43. package/dist/src/plugin/cache/index.d.ts +5 -0
  44. package/dist/src/plugin/cache/index.d.ts.map +1 -0
  45. package/dist/src/plugin/cache/index.js +5 -0
  46. package/dist/src/plugin/cache/index.js.map +1 -0
  47. package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
  48. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
  49. package/dist/src/plugin/cache/signature-cache.js +375 -0
  50. package/dist/src/plugin/cache/signature-cache.js.map +1 -0
  51. package/dist/src/plugin/cache.d.ts +44 -0
  52. package/dist/src/plugin/cache.d.ts.map +1 -0
  53. package/dist/src/plugin/cache.js +200 -0
  54. package/dist/src/plugin/cache.js.map +1 -0
  55. package/dist/src/plugin/cli.d.ts +27 -0
  56. package/dist/src/plugin/cli.d.ts.map +1 -0
  57. package/dist/src/plugin/cli.js +130 -0
  58. package/dist/src/plugin/cli.js.map +1 -0
  59. package/dist/src/plugin/config/index.d.ts +16 -0
  60. package/dist/src/plugin/config/index.d.ts.map +1 -0
  61. package/dist/src/plugin/config/index.js +16 -0
  62. package/dist/src/plugin/config/index.js.map +1 -0
  63. package/dist/src/plugin/config/loader.d.ts +37 -0
  64. package/dist/src/plugin/config/loader.d.ts.map +1 -0
  65. package/dist/src/plugin/config/loader.js +196 -0
  66. package/dist/src/plugin/config/loader.js.map +1 -0
  67. package/dist/src/plugin/config/models.d.ts +27 -0
  68. package/dist/src/plugin/config/models.d.ts.map +1 -0
  69. package/dist/src/plugin/config/models.js +70 -0
  70. package/dist/src/plugin/config/models.js.map +1 -0
  71. package/dist/src/plugin/config/schema.d.ts +133 -0
  72. package/dist/src/plugin/config/schema.d.ts.map +1 -0
  73. package/dist/src/plugin/config/schema.js +438 -0
  74. package/dist/src/plugin/config/schema.js.map +1 -0
  75. package/dist/src/plugin/config/updater.d.ts +55 -0
  76. package/dist/src/plugin/config/updater.d.ts.map +1 -0
  77. package/dist/src/plugin/config/updater.js +125 -0
  78. package/dist/src/plugin/config/updater.js.map +1 -0
  79. package/dist/src/plugin/core/streaming/index.d.ts +3 -0
  80. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
  81. package/dist/src/plugin/core/streaming/index.js +3 -0
  82. package/dist/src/plugin/core/streaming/index.js.map +1 -0
  83. package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
  84. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  85. package/dist/src/plugin/core/streaming/transformer.js +271 -0
  86. package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
  87. package/dist/src/plugin/core/streaming/types.d.ts +27 -0
  88. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
  89. package/dist/src/plugin/core/streaming/types.js +1 -0
  90. package/dist/src/plugin/core/streaming/types.js.map +1 -0
  91. package/dist/src/plugin/debug.d.ts +94 -0
  92. package/dist/src/plugin/debug.d.ts.map +1 -0
  93. package/dist/src/plugin/debug.js +418 -0
  94. package/dist/src/plugin/debug.js.map +1 -0
  95. package/dist/src/plugin/errors.d.ts +28 -0
  96. package/dist/src/plugin/errors.d.ts.map +1 -0
  97. package/dist/src/plugin/errors.js +42 -0
  98. package/dist/src/plugin/errors.js.map +1 -0
  99. package/dist/src/plugin/fingerprint.d.ts +64 -0
  100. package/dist/src/plugin/fingerprint.d.ts.map +1 -0
  101. package/dist/src/plugin/fingerprint.js +125 -0
  102. package/dist/src/plugin/fingerprint.js.map +1 -0
  103. package/dist/src/plugin/image-saver.d.ts +25 -0
  104. package/dist/src/plugin/image-saver.d.ts.map +1 -0
  105. package/dist/src/plugin/image-saver.js +86 -0
  106. package/dist/src/plugin/image-saver.js.map +1 -0
  107. package/dist/src/plugin/logger.d.ts +54 -0
  108. package/dist/src/plugin/logger.d.ts.map +1 -0
  109. package/dist/src/plugin/logger.js +120 -0
  110. package/dist/src/plugin/logger.js.map +1 -0
  111. package/dist/src/plugin/project.d.ts +33 -0
  112. package/dist/src/plugin/project.d.ts.map +1 -0
  113. package/dist/src/plugin/project.js +234 -0
  114. package/dist/src/plugin/project.js.map +1 -0
  115. package/dist/src/plugin/proxy.d.ts +2 -0
  116. package/dist/src/plugin/proxy.d.ts.map +1 -0
  117. package/dist/src/plugin/proxy.js +20 -0
  118. package/dist/src/plugin/proxy.js.map +1 -0
  119. package/dist/src/plugin/quota.d.ts +35 -0
  120. package/dist/src/plugin/quota.d.ts.map +1 -0
  121. package/dist/src/plugin/quota.js +273 -0
  122. package/dist/src/plugin/quota.js.map +1 -0
  123. package/dist/src/plugin/recovery/constants.d.ts +22 -0
  124. package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
  125. package/dist/src/plugin/recovery/constants.js +43 -0
  126. package/dist/src/plugin/recovery/constants.js.map +1 -0
  127. package/dist/src/plugin/recovery/index.d.ts +12 -0
  128. package/dist/src/plugin/recovery/index.d.ts.map +1 -0
  129. package/dist/src/plugin/recovery/index.js +12 -0
  130. package/dist/src/plugin/recovery/index.js.map +1 -0
  131. package/dist/src/plugin/recovery/storage.d.ts +24 -0
  132. package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
  133. package/dist/src/plugin/recovery/storage.js +354 -0
  134. package/dist/src/plugin/recovery/storage.js.map +1 -0
  135. package/dist/src/plugin/recovery/types.d.ts +116 -0
  136. package/dist/src/plugin/recovery/types.d.ts.map +1 -0
  137. package/dist/src/plugin/recovery/types.js +6 -0
  138. package/dist/src/plugin/recovery/types.js.map +1 -0
  139. package/dist/src/plugin/recovery.d.ts +61 -0
  140. package/dist/src/plugin/recovery.d.ts.map +1 -0
  141. package/dist/src/plugin/recovery.js +378 -0
  142. package/dist/src/plugin/recovery.js.map +1 -0
  143. package/dist/src/plugin/refresh-queue.d.ts +101 -0
  144. package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
  145. package/dist/src/plugin/refresh-queue.js +248 -0
  146. package/dist/src/plugin/refresh-queue.js.map +1 -0
  147. package/dist/src/plugin/request-helpers.d.ts +282 -0
  148. package/dist/src/plugin/request-helpers.d.ts.map +1 -0
  149. package/dist/src/plugin/request-helpers.js +2319 -0
  150. package/dist/src/plugin/request-helpers.js.map +1 -0
  151. package/dist/src/plugin/request.d.ts +93 -0
  152. package/dist/src/plugin/request.d.ts.map +1 -0
  153. package/dist/src/plugin/request.js +1352 -0
  154. package/dist/src/plugin/request.js.map +1 -0
  155. package/dist/src/plugin/rotation.d.ts +169 -0
  156. package/dist/src/plugin/rotation.d.ts.map +1 -0
  157. package/dist/src/plugin/rotation.js +328 -0
  158. package/dist/src/plugin/rotation.js.map +1 -0
  159. package/dist/src/plugin/search.d.ts +32 -0
  160. package/dist/src/plugin/search.d.ts.map +1 -0
  161. package/dist/src/plugin/search.js +195 -0
  162. package/dist/src/plugin/search.js.map +1 -0
  163. package/dist/src/plugin/server.d.ts +23 -0
  164. package/dist/src/plugin/server.d.ts.map +1 -0
  165. package/dist/src/plugin/server.js +324 -0
  166. package/dist/src/plugin/server.js.map +1 -0
  167. package/dist/src/plugin/storage.d.ts +136 -0
  168. package/dist/src/plugin/storage.d.ts.map +1 -0
  169. package/dist/src/plugin/storage.js +588 -0
  170. package/dist/src/plugin/storage.js.map +1 -0
  171. package/dist/src/plugin/stores/signature-store.d.ts +5 -0
  172. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
  173. package/dist/src/plugin/stores/signature-store.js +25 -0
  174. package/dist/src/plugin/stores/signature-store.js.map +1 -0
  175. package/dist/src/plugin/thinking-recovery.d.ts +90 -0
  176. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
  177. package/dist/src/plugin/thinking-recovery.js +316 -0
  178. package/dist/src/plugin/thinking-recovery.js.map +1 -0
  179. package/dist/src/plugin/token.d.ts +19 -0
  180. package/dist/src/plugin/token.d.ts.map +1 -0
  181. package/dist/src/plugin/token.js +128 -0
  182. package/dist/src/plugin/token.js.map +1 -0
  183. package/dist/src/plugin/transform/claude.d.ts +80 -0
  184. package/dist/src/plugin/transform/claude.d.ts.map +1 -0
  185. package/dist/src/plugin/transform/claude.js +265 -0
  186. package/dist/src/plugin/transform/claude.js.map +1 -0
  187. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
  188. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  189. package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
  190. package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
  191. package/dist/src/plugin/transform/gemini.d.ts +100 -0
  192. package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
  193. package/dist/src/plugin/transform/gemini.js +465 -0
  194. package/dist/src/plugin/transform/gemini.js.map +1 -0
  195. package/dist/src/plugin/transform/index.d.ts +15 -0
  196. package/dist/src/plugin/transform/index.d.ts.map +1 -0
  197. package/dist/src/plugin/transform/index.js +14 -0
  198. package/dist/src/plugin/transform/index.js.map +1 -0
  199. package/dist/src/plugin/transform/model-resolver.d.ts +104 -0
  200. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
  201. package/dist/src/plugin/transform/model-resolver.js +361 -0
  202. package/dist/src/plugin/transform/model-resolver.js.map +1 -0
  203. package/dist/src/plugin/transform/types.d.ts +111 -0
  204. package/dist/src/plugin/transform/types.d.ts.map +1 -0
  205. package/dist/src/plugin/transform/types.js +1 -0
  206. package/dist/src/plugin/transform/types.js.map +1 -0
  207. package/dist/src/plugin/types.d.ts +97 -0
  208. package/dist/src/plugin/types.d.ts.map +1 -0
  209. package/dist/src/plugin/types.js +1 -0
  210. package/dist/src/plugin/types.js.map +1 -0
  211. package/dist/src/plugin/ui/ansi.d.ts +32 -0
  212. package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
  213. package/dist/src/plugin/ui/ansi.js +52 -0
  214. package/dist/src/plugin/ui/ansi.js.map +1 -0
  215. package/dist/src/plugin/ui/auth-menu.d.ts +33 -0
  216. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
  217. package/dist/src/plugin/ui/auth-menu.js +110 -0
  218. package/dist/src/plugin/ui/auth-menu.js.map +1 -0
  219. package/dist/src/plugin/ui/confirm.d.ts +2 -0
  220. package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
  221. package/dist/src/plugin/ui/confirm.js +15 -0
  222. package/dist/src/plugin/ui/confirm.js.map +1 -0
  223. package/dist/src/plugin/ui/select.d.ts +23 -0
  224. package/dist/src/plugin/ui/select.d.ts.map +1 -0
  225. package/dist/src/plugin/ui/select.js +254 -0
  226. package/dist/src/plugin/ui/select.js.map +1 -0
  227. package/dist/src/plugin/version.d.ts +19 -0
  228. package/dist/src/plugin/version.d.ts.map +1 -0
  229. package/dist/src/plugin/version.js +80 -0
  230. package/dist/src/plugin/version.js.map +1 -0
  231. package/dist/src/plugin.d.ts +30 -0
  232. package/dist/src/plugin.d.ts.map +1 -0
  233. package/dist/src/plugin.js +3050 -0
  234. package/dist/src/plugin.js.map +1 -0
  235. package/package.json +68 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../../src/plugin/transform/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EACnB,MAAM,SAAS,CAAC;AA0CjB,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAmFvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,M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AAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAmEvB;AAED,MAAM,WAAW,eAAe;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAuCD,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,cAAc,GACtB,eAAe,CA2GjB"}
@@ -0,0 +1,465 @@
1
+ /**
2
+ * Gemini-specific Request Transformations
3
+ *
4
+ * Handles Gemini model-specific request transformations including:
5
+ * - Thinking config (camelCase keys, thinkingLevel for Gemini 3)
6
+ * - Tool normalization (function/custom format)
7
+ * - Schema transformation (JSON Schema -> Gemini Schema format)
8
+ */
9
+ /**
10
+ * Transform a JSON Schema to Gemini-compatible format.
11
+ * Based on @google/genai SDK's processJsonSchema() function.
12
+ *
13
+ * Key transformations:
14
+ * - Converts type values to uppercase (object -> OBJECT)
15
+ * - Removes unsupported fields like additionalProperties, $schema
16
+ * - Recursively processes nested schemas (properties, items, anyOf, etc.)
17
+ *
18
+ * @param schema - A JSON Schema object or primitive value
19
+ * @returns Gemini-compatible schema
20
+ *
21
+ * Fields that Gemini API rejects and must be removed from schemas.
22
+ * Antigravity uses strict protobuf-backed JSON validation.
23
+ */
24
+ const UNSUPPORTED_SCHEMA_FIELDS = new Set([
25
+ "additionalProperties",
26
+ "$schema",
27
+ "$id",
28
+ "$comment",
29
+ "$ref",
30
+ "$defs",
31
+ "definitions",
32
+ "const",
33
+ "contentMediaType",
34
+ "contentEncoding",
35
+ "if",
36
+ "then",
37
+ "else",
38
+ "not",
39
+ "patternProperties",
40
+ "unevaluatedProperties",
41
+ "unevaluatedItems",
42
+ "dependentRequired",
43
+ "dependentSchemas",
44
+ "propertyNames",
45
+ "minContains",
46
+ "maxContains",
47
+ ]);
48
+ export function toGeminiSchema(schema) {
49
+ // Return primitives and arrays as-is
50
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
51
+ return schema;
52
+ }
53
+ const inputSchema = schema;
54
+ const result = {};
55
+ // First pass: collect all property names for required validation
56
+ const propertyNames = new Set();
57
+ if (inputSchema.properties && typeof inputSchema.properties === "object") {
58
+ for (const propName of Object.keys(inputSchema.properties)) {
59
+ propertyNames.add(propName);
60
+ }
61
+ }
62
+ for (const [key, value] of Object.entries(inputSchema)) {
63
+ // Skip unsupported fields that Gemini API rejects
64
+ if (UNSUPPORTED_SCHEMA_FIELDS.has(key)) {
65
+ continue;
66
+ }
67
+ if (key === "type" && typeof value === "string") {
68
+ // Convert type to uppercase for Gemini API
69
+ result[key] = value.toUpperCase();
70
+ }
71
+ else if (key === "properties" &&
72
+ typeof value === "object" &&
73
+ value !== null) {
74
+ // Recursively transform nested property schemas
75
+ const props = {};
76
+ for (const [propName, propSchema] of Object.entries(value)) {
77
+ props[propName] = toGeminiSchema(propSchema);
78
+ }
79
+ result[key] = props;
80
+ }
81
+ else if (key === "items" && typeof value === "object") {
82
+ // Transform array items schema
83
+ result[key] = toGeminiSchema(value);
84
+ }
85
+ else if ((key === "anyOf" || key === "oneOf" || key === "allOf") &&
86
+ Array.isArray(value)) {
87
+ // Transform union type schemas
88
+ result[key] = value.map((item) => toGeminiSchema(item));
89
+ }
90
+ else if (key === "enum" && Array.isArray(value)) {
91
+ // Keep enum values as-is
92
+ result[key] = value;
93
+ }
94
+ else if (key === "default" || key === "examples") {
95
+ // Keep default and examples as-is
96
+ result[key] = value;
97
+ }
98
+ else if (key === "required" && Array.isArray(value)) {
99
+ // Filter required array to only include properties that exist
100
+ // This fixes: "parameters.required[X]: property is not defined"
101
+ if (propertyNames.size > 0) {
102
+ const validRequired = value.filter((prop) => typeof prop === "string" && propertyNames.has(prop));
103
+ if (validRequired.length > 0) {
104
+ result[key] = validRequired;
105
+ }
106
+ // If no valid required properties, omit the required field entirely
107
+ }
108
+ else {
109
+ // If there are no properties, keep required as-is (might be a schema without properties)
110
+ result[key] = value;
111
+ }
112
+ }
113
+ else {
114
+ result[key] = value;
115
+ }
116
+ }
117
+ // Issue #80: Ensure array schemas have an 'items' field
118
+ // Gemini API requires: "parameters.properties[X].items: missing field"
119
+ if (result.type === "ARRAY" && !result.items) {
120
+ result.items = { type: "STRING" };
121
+ }
122
+ return result;
123
+ }
124
+ /**
125
+ * Check if a model is a Gemini model (not Claude).
126
+ */
127
+ export function isGeminiModel(model) {
128
+ const lower = model.toLowerCase();
129
+ return lower.includes("gemini") && !lower.includes("claude");
130
+ }
131
+ /**
132
+ * Check if a model is Gemini 3 (uses thinkingLevel string).
133
+ */
134
+ export function isGemini3Model(model) {
135
+ return model.toLowerCase().includes("gemini-3");
136
+ }
137
+ /**
138
+ * Check if a model is Gemini 2.5 (uses numeric thinkingBudget).
139
+ */
140
+ export function isGemini25Model(model) {
141
+ return model.toLowerCase().includes("gemini-2.5");
142
+ }
143
+ /**
144
+ * Check if a model is an image generation model.
145
+ * Image models don't support thinking and require imageConfig.
146
+ */
147
+ export function isImageGenerationModel(model) {
148
+ const lower = model.toLowerCase();
149
+ return lower.includes("image") || lower.includes("imagen");
150
+ }
151
+ /**
152
+ * Build Gemini 3 thinking config with thinkingLevel string.
153
+ */
154
+ export function buildGemini3ThinkingConfig(includeThoughts, thinkingLevel) {
155
+ return {
156
+ includeThoughts,
157
+ thinkingLevel,
158
+ };
159
+ }
160
+ /**
161
+ * Build Gemini 2.5 thinking config with numeric thinkingBudget.
162
+ */
163
+ export function buildGemini25ThinkingConfig(includeThoughts, thinkingBudget) {
164
+ return {
165
+ includeThoughts,
166
+ ...(typeof thinkingBudget === "number" && thinkingBudget > 0
167
+ ? { thinkingBudget }
168
+ : {}),
169
+ };
170
+ }
171
+ /**
172
+ * Valid aspect ratios for image generation.
173
+ */
174
+ const VALID_ASPECT_RATIOS = [
175
+ "1:1",
176
+ "2:3",
177
+ "3:2",
178
+ "3:4",
179
+ "4:3",
180
+ "4:5",
181
+ "5:4",
182
+ "9:16",
183
+ "16:9",
184
+ "21:9",
185
+ ];
186
+ /**
187
+ * Build image generation config for Gemini image models.
188
+ *
189
+ * Configuration is read from environment variables:
190
+ * - OPENCODE_IMAGE_ASPECT_RATIO: Aspect ratio (e.g., "16:9", "4:3")
191
+ *
192
+ * Defaults to 1:1 aspect ratio if not specified.
193
+ *
194
+ * Note: Resolution setting is not currently supported by the Antigravity API.
195
+ */
196
+ export function buildImageGenerationConfig() {
197
+ // Read aspect ratio from environment or default to 1:1
198
+ const aspectRatio = process.env.OPENCODE_IMAGE_ASPECT_RATIO || "1:1";
199
+ if (VALID_ASPECT_RATIOS.includes(aspectRatio)) {
200
+ return { aspectRatio };
201
+ }
202
+ console.warn(`[gemini] Invalid aspect ratio "${aspectRatio}". Using default "1:1". Valid values: ${VALID_ASPECT_RATIOS.join(", ")}`);
203
+ // Default to 1:1 square aspect ratio
204
+ return { aspectRatio: "1:1" };
205
+ }
206
+ /**
207
+ * Normalize tools for Gemini models.
208
+ * Ensures tools have proper function-style format.
209
+ *
210
+ * @returns Debug info about tool normalization
211
+ */
212
+ export function normalizeGeminiTools(payload) {
213
+ let toolDebugMissing = 0;
214
+ const toolDebugSummaries = [];
215
+ if (!Array.isArray(payload.tools)) {
216
+ return { toolDebugMissing, toolDebugSummaries };
217
+ }
218
+ payload.tools = payload.tools.map((tool, toolIndex) => {
219
+ const t = tool;
220
+ // Skip normalization for Google Search tools (both old and new API)
221
+ if (t.googleSearch || t.googleSearchRetrieval) {
222
+ return t;
223
+ }
224
+ const newTool = { ...t };
225
+ const schemaCandidates = [
226
+ newTool.function?.input_schema,
227
+ newTool.function?.parameters,
228
+ newTool.function?.inputSchema,
229
+ newTool.custom?.input_schema,
230
+ newTool.custom?.parameters,
231
+ newTool.parameters,
232
+ newTool.input_schema,
233
+ newTool.inputSchema,
234
+ ].filter(Boolean);
235
+ const placeholderSchema = {
236
+ type: "OBJECT",
237
+ properties: {
238
+ _placeholder: {
239
+ type: "BOOLEAN",
240
+ description: "Placeholder. Always pass true.",
241
+ },
242
+ },
243
+ required: ["_placeholder"],
244
+ };
245
+ let schema = schemaCandidates[0];
246
+ const schemaObjectOk = schema &&
247
+ typeof schema === "object" &&
248
+ !Array.isArray(schema) &&
249
+ Object.keys(schema).length > 0;
250
+ if (!schemaObjectOk) {
251
+ schema = placeholderSchema;
252
+ toolDebugMissing += 1;
253
+ }
254
+ else {
255
+ // Transform existing schema to Gemini-compatible format
256
+ schema = toGeminiSchema(schema);
257
+ }
258
+ const nameCandidate = newTool.name ||
259
+ newTool.function?.name ||
260
+ newTool.custom?.name ||
261
+ `tool-${toolIndex}`;
262
+ // Always update function.input_schema with transformed schema
263
+ if (newTool.function && schema) {
264
+ newTool.function.input_schema = schema;
265
+ }
266
+ // Always update custom.input_schema with transformed schema
267
+ if (newTool.custom && schema) {
268
+ newTool.custom.input_schema = schema;
269
+ }
270
+ // Create custom from function if missing
271
+ if (!newTool.custom && newTool.function) {
272
+ const fn = newTool.function;
273
+ newTool.custom = {
274
+ name: fn.name || nameCandidate,
275
+ description: fn.description,
276
+ input_schema: schema,
277
+ };
278
+ }
279
+ // Create custom if both missing
280
+ if (!newTool.custom && !newTool.function) {
281
+ newTool.custom = {
282
+ name: nameCandidate,
283
+ description: newTool.description,
284
+ input_schema: schema,
285
+ };
286
+ if (!newTool.parameters &&
287
+ !newTool.input_schema &&
288
+ !newTool.inputSchema) {
289
+ newTool.parameters = schema;
290
+ }
291
+ }
292
+ if (newTool.custom &&
293
+ !newTool.custom.input_schema) {
294
+ newTool.custom.input_schema =
295
+ placeholderSchema;
296
+ toolDebugMissing += 1;
297
+ }
298
+ toolDebugSummaries.push(`idx=${toolIndex}, hasCustom=${!!newTool.custom}, customSchema=${!!newTool.custom?.input_schema}, hasFunction=${!!newTool.function}, functionSchema=${!!newTool.function?.input_schema}`);
299
+ // Strip custom wrappers for Gemini; only function-style is accepted.
300
+ if (newTool.custom) {
301
+ delete newTool.custom;
302
+ }
303
+ return newTool;
304
+ });
305
+ return { toolDebugMissing, toolDebugSummaries };
306
+ }
307
+ /**
308
+ * Apply all Gemini-specific transformations.
309
+ */
310
+ export function applyGeminiTransforms(payload, options) {
311
+ const { model, tierThinkingBudget, tierThinkingLevel, normalizedThinking, googleSearch, } = options;
312
+ // 1. Apply thinking config if needed
313
+ if (normalizedThinking) {
314
+ let thinkingConfig;
315
+ if (tierThinkingLevel && isGemini3Model(model)) {
316
+ // Gemini 3 uses thinkingLevel string
317
+ thinkingConfig = buildGemini3ThinkingConfig(normalizedThinking.includeThoughts ?? true, tierThinkingLevel);
318
+ }
319
+ else {
320
+ // Gemini 2.5 and others use numeric budget
321
+ const thinkingBudget = tierThinkingBudget ?? normalizedThinking.thinkingBudget;
322
+ thinkingConfig = buildGemini25ThinkingConfig(normalizedThinking.includeThoughts ?? true, thinkingBudget);
323
+ }
324
+ const generationConfig = (payload.generationConfig ?? {});
325
+ generationConfig.thinkingConfig = thinkingConfig;
326
+ payload.generationConfig = generationConfig;
327
+ }
328
+ // 2. Apply Google Search (Grounding) if enabled
329
+ // Uses the new googleSearch API for Gemini 2.0+ / Gemini 3 models
330
+ // Note: The old googleSearchRetrieval with dynamicRetrievalConfig is deprecated
331
+ // The new API doesn't support threshold - the model decides when to search automatically
332
+ if (googleSearch && googleSearch.mode === "auto") {
333
+ const tools = payload.tools || [];
334
+ if (!payload.tools) {
335
+ payload.tools = tools;
336
+ }
337
+ // Add Google Search tool using new API format for Gemini 2.0+
338
+ // See: https://ai.google.dev/gemini-api/docs/grounding
339
+ payload.tools.push({
340
+ googleSearch: {},
341
+ });
342
+ }
343
+ // 3. Normalize tools
344
+ const result = normalizeGeminiTools(payload);
345
+ // 4. Wrap tools in functionDeclarations format (fixes #203, #206)
346
+ // Antigravity strict protobuf validation rejects wrapper-level 'parameters' field
347
+ // Must be: [{ functionDeclarations: [{ name, description, parameters }] }]
348
+ const wrapResult = wrapToolsAsFunctionDeclarations(payload);
349
+ return {
350
+ ...result,
351
+ wrappedFunctionCount: wrapResult.wrappedFunctionCount,
352
+ passthroughToolCount: wrapResult.passthroughToolCount,
353
+ };
354
+ }
355
+ /**
356
+ * Wrap tools array in Gemini's required functionDeclarations format.
357
+ *
358
+ * Gemini/Antigravity API expects:
359
+ * { tools: [{ functionDeclarations: [{ name, description, parameters }] }] }
360
+ *
361
+ * NOT:
362
+ * { tools: [{ function: {...}, parameters: {...} }] }
363
+ *
364
+ * The wrapper-level 'parameters' field causes:
365
+ * "Unknown name 'parameters' at 'request.tools[0]'"
366
+ */
367
+ /**
368
+ * Detect if a tool is a web search tool in any of the supported formats:
369
+ * - Claude/Anthropic: { type: "web_search_20250305" } or { name: "web_search" }
370
+ * - Gemini native: { googleSearch: {} } or { googleSearchRetrieval: {} }
371
+ */
372
+ function isWebSearchTool(tool) {
373
+ // 1. Gemini native format
374
+ if (tool.googleSearch || tool.googleSearchRetrieval) {
375
+ return true;
376
+ }
377
+ // 2. Claude/Anthropic format: { type: "web_search_20250305" }
378
+ if (tool.type === "web_search_20250305") {
379
+ return true;
380
+ }
381
+ // 3. Simple name-based format: { name: "web_search" | "google_search" }
382
+ const name = tool.name;
383
+ if (name === "web_search" || name === "google_search") {
384
+ return true;
385
+ }
386
+ return false;
387
+ }
388
+ export function wrapToolsAsFunctionDeclarations(payload) {
389
+ if (!Array.isArray(payload.tools) || payload.tools.length === 0) {
390
+ return { wrappedFunctionCount: 0, passthroughToolCount: 0 };
391
+ }
392
+ const functionDeclarations = [];
393
+ const passthroughTools = [];
394
+ let hasWebSearchTool = false;
395
+ for (const tool of payload.tools) {
396
+ // Handle passthrough tools (Google Search and Code Execution)
397
+ if (tool.googleSearch || tool.googleSearchRetrieval || tool.codeExecution) {
398
+ passthroughTools.push(tool);
399
+ continue;
400
+ }
401
+ // Detect and convert web search tools to Gemini format
402
+ if (isWebSearchTool(tool)) {
403
+ hasWebSearchTool = true;
404
+ continue; // Will be added as { googleSearch: {} } at the end
405
+ }
406
+ if (tool.functionDeclarations) {
407
+ if (Array.isArray(tool.functionDeclarations)) {
408
+ for (const decl of tool.functionDeclarations) {
409
+ functionDeclarations.push({
410
+ name: String(decl.name || `tool-${functionDeclarations.length}`),
411
+ description: String(decl.description || ""),
412
+ parameters: decl.parameters || {
413
+ type: "OBJECT",
414
+ properties: {},
415
+ },
416
+ });
417
+ }
418
+ }
419
+ continue;
420
+ }
421
+ const fn = tool.function;
422
+ const custom = tool.custom;
423
+ const name = String(tool.name ||
424
+ fn?.name ||
425
+ custom?.name ||
426
+ `tool-${functionDeclarations.length}`);
427
+ const description = String(tool.description || fn?.description || custom?.description || "");
428
+ const schema = (fn?.input_schema ||
429
+ fn?.parameters ||
430
+ fn?.inputSchema ||
431
+ custom?.input_schema ||
432
+ custom?.parameters ||
433
+ tool.parameters ||
434
+ tool.input_schema ||
435
+ tool.inputSchema || { type: "OBJECT", properties: {} });
436
+ functionDeclarations.push({
437
+ name,
438
+ description,
439
+ parameters: schema,
440
+ });
441
+ }
442
+ const finalTools = [];
443
+ if (functionDeclarations.length > 0) {
444
+ finalTools.push({ functionDeclarations });
445
+ }
446
+ finalTools.push(...passthroughTools);
447
+ // Add googleSearch tool if a web search tool was detected
448
+ // Note: googleSearch cannot be combined with functionDeclarations in the same request
449
+ // If there are function declarations, we skip adding googleSearch (Gemini API limitation)
450
+ if (hasWebSearchTool && functionDeclarations.length === 0) {
451
+ finalTools.push({ googleSearch: {} });
452
+ }
453
+ else if (hasWebSearchTool && functionDeclarations.length > 0) {
454
+ // Log warning: web search requested but can't be used with functions
455
+ console.warn("[gemini] web_search tool detected but cannot be combined with function declarations. " +
456
+ "Use the explicit google_search() tool call instead.");
457
+ }
458
+ payload.tools = finalTools;
459
+ return {
460
+ wrappedFunctionCount: functionDeclarations.length,
461
+ passthroughToolCount: passthroughTools.length +
462
+ (hasWebSearchTool && functionDeclarations.length === 0 ? 1 : 0),
463
+ };
464
+ }
465
+ //# sourceMappingURL=gemini.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../../src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,EAAE,UAAU,EAAE,EAAE,EAAE,CAGvD,CAAC;QAEF,oBAAoB,CAAC,IAAI,CAAC;YACxB,IAAI;YACJ,WAAW;YACX,UAAU,EAAE,MAAM;SACnB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,UAAU,GAAc,EAAE,CAAC;IAEjC,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,UAAU,CAAC,IAAI,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,UAAU,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;IAErC,0DAA0D;IAC1D,sFAAsF;IACtF,0FAA0F;IAC1F,IAAI,gBAAgB,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1D,UAAU,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;SAAM,IAAI,gBAAgB,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,qEAAqE;QACrE,OAAO,CAAC,IAAI,CACV,uFAAuF;YACrF,qDAAqD,CACxD,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC;IAE3B,OAAO;QACL,oBAAoB,EAAE,oBAAoB,CAAC,MAAM;QACjD,oBAAoB,EAClB,gBAAgB,CAAC,MAAM;YACvB,CAAC,gBAAgB,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAClE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Transform Module Index
3
+ *
4
+ * Re-exports transform functions and types for request transformation.
5
+ */
6
+ export type { ModelFamily, ThinkingTier, TransformContext, TransformResult, TransformDebugInfo, RequestPayload, ThinkingConfig, ResolvedModel, GoogleSearchConfig, } from "./types";
7
+ export { resolveModelWithTier, resolveModelWithVariant, resolveModelForHeaderStyle, getModelFamily, MODEL_ALIASES, MODEL_FALLBACKS, THINKING_TIER_BUDGETS, GEMINI_3_THINKING_LEVELS, } from "./model-resolver";
8
+ export type { VariantConfig } from "./model-resolver";
9
+ export { isClaudeModel, isClaudeThinkingModel, configureClaudeToolConfig, buildClaudeThinkingConfig, ensureClaudeMaxOutputTokens, appendClaudeThinkingHint, normalizeClaudeTools, applyClaudeTransforms, CLAUDE_THINKING_MAX_OUTPUT_TOKENS, CLAUDE_INTERLEAVED_THINKING_HINT, } from "./claude";
10
+ export type { ClaudeTransformOptions, ClaudeTransformResult } from "./claude";
11
+ export { isGeminiModel, isGemini3Model, isGemini25Model, isImageGenerationModel, buildGemini3ThinkingConfig, buildGemini25ThinkingConfig, buildImageGenerationConfig, normalizeGeminiTools, applyGeminiTransforms, } from "./gemini";
12
+ export type { GeminiTransformOptions, GeminiTransformResult, ImageConfig } from "./gemini";
13
+ export { sanitizeCrossModelPayload, sanitizeCrossModelPayloadInPlace, getModelFamily as getCrossModelFamily, stripGeminiThinkingMetadata, stripClaudeThinkingFields, } from "./cross-model-sanitizer";
14
+ export type { SanitizerOptions } from "./cross-model-sanitizer";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugin/transform/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAG9E,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG3F,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,cAAc,IAAI,mBAAmB,EACrC,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Transform Module Index
3
+ *
4
+ * Re-exports transform functions and types for request transformation.
5
+ */
6
+ // Model resolution
7
+ export { resolveModelWithTier, resolveModelWithVariant, resolveModelForHeaderStyle, getModelFamily, MODEL_ALIASES, MODEL_FALLBACKS, THINKING_TIER_BUDGETS, GEMINI_3_THINKING_LEVELS, } from "./model-resolver";
8
+ // Claude transforms
9
+ export { isClaudeModel, isClaudeThinkingModel, configureClaudeToolConfig, buildClaudeThinkingConfig, ensureClaudeMaxOutputTokens, appendClaudeThinkingHint, normalizeClaudeTools, applyClaudeTransforms, CLAUDE_THINKING_MAX_OUTPUT_TOKENS, CLAUDE_INTERLEAVED_THINKING_HINT, } from "./claude";
10
+ // Gemini transforms
11
+ export { isGeminiModel, isGemini3Model, isGemini25Model, isImageGenerationModel, buildGemini3ThinkingConfig, buildGemini25ThinkingConfig, buildImageGenerationConfig, normalizeGeminiTools, applyGeminiTransforms, } from "./gemini";
12
+ // Cross-model sanitization
13
+ export { sanitizeCrossModelPayload, sanitizeCrossModelPayloadInPlace, getModelFamily as getCrossModelFamily, stripGeminiThinkingMetadata, stripClaudeThinkingFields, } from "./cross-model-sanitizer";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugin/transform/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,mBAAmB;AACnB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,oBAAoB;AACpB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,UAAU,CAAC;AAGlB,oBAAoB;AACpB,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAGlB,2BAA2B;AAC3B,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,cAAc,IAAI,mBAAmB,EACrC,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,104 @@
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
+ 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
+ * Model fallbacks when primary model is unavailable.
54
+ * NOTE: Image models should NOT fall back to non-image models!
55
+ */
56
+ export declare const MODEL_FALLBACKS: Record<string, string>;
57
+ /**
58
+ * Resolves a model name with optional tier suffix and quota prefix to its actual API model name
59
+ * and corresponding thinking configuration.
60
+ *
61
+ * Quota routing:
62
+ * - Default to Antigravity quota unless cli_first is enabled for Gemini models
63
+ * - Fallback to Gemini CLI happens at account rotation level when Antigravity is exhausted
64
+ * - "antigravity-" prefix marks explicit quota (no fallback allowed)
65
+ * - Claude and image models always use Antigravity
66
+ *
67
+ * Examples:
68
+ * - "gemini-2.5-flash" → { quotaPreference: "antigravity" }
69
+ * - "gemini-3-pro-preview" → { quotaPreference: "antigravity" }
70
+ * - "antigravity-gemini-3-pro-high" → { quotaPreference: "antigravity", explicitQuota: true }
71
+ * - "claude-sonnet-4-5-thinking-medium" → { quotaPreference: "antigravity" }
72
+ *
73
+ * @param requestedModel - The model name from the request
74
+ * @param options - Optional configuration including cli_first preference
75
+ * @returns Resolved model with thinking configuration
76
+ */
77
+ export declare function resolveModelWithTier(requestedModel: string, options?: ModelResolverOptions): ResolvedModel;
78
+ /**
79
+ * Gets the model family for routing decisions.
80
+ */
81
+ export declare function getModelFamily(model: string): "claude" | "gemini-flash" | "gemini-pro";
82
+ /**
83
+ * Variant config from OpenCode's providerOptions.
84
+ */
85
+ export interface VariantConfig {
86
+ thinkingBudget?: number;
87
+ googleSearch?: GoogleSearchConfig;
88
+ }
89
+ /**
90
+ * Resolves model name for a specific headerStyle (quota fallback support).
91
+ * Transforms model names when switching between gemini-cli and antigravity quotas.
92
+ *
93
+ * Issue #103: When quota fallback occurs, model names need to be transformed:
94
+ * - gemini-3-flash-preview (gemini-cli) → gemini-3-flash (antigravity)
95
+ * - gemini-3-pro-preview (gemini-cli) → gemini-3-pro-low (antigravity)
96
+ * - gemini-3-flash (antigravity) → gemini-3-flash-preview (gemini-cli)
97
+ */
98
+ export declare function resolveModelForHeaderStyle(requestedModel: string, headerStyle: "antigravity" | "gemini-cli"): ResolvedModel;
99
+ /**
100
+ * Resolves model with variant config from providerOptions.
101
+ * Variant config takes priority over tier suffix in model name.
102
+ */
103
+ export declare function resolveModelWithVariant(requestedModel: string, variantConfig?: VariantConfig): ResolvedModel;
104
+ //# sourceMappingURL=model-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-resolver.d.ts","sourceRoot":"","sources":["../../../../src/plugin/transform/model-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/E,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAKxB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,+CAK3B,CAAC;AAEX;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsBhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAElD,CAAC;AAsEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,oBAAyB,GACjC,aAAa,CA6Hf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GACZ,QAAQ,GAAG,cAAc,GAAG,YAAY,CAS1C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAYD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,aAAa,GAAG,YAAY,GACxC,aAAa,CA4Cf;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,aAAa,GAC5B,aAAa,CA8Cf"}