opencode-antigravity-auth-mf 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +630 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/src/antigravity/oauth.d.ts +31 -0
- package/dist/src/antigravity/oauth.d.ts.map +1 -0
- package/dist/src/antigravity/oauth.js +168 -0
- package/dist/src/antigravity/oauth.js.map +1 -0
- package/dist/src/constants.d.ts +99 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +135 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
- package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/cache.js +71 -0
- package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
- package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/checker.js +237 -0
- package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/constants.d.ts +9 -0
- package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/constants.js +23 -0
- package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
- package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/index.js +125 -0
- package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
- package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/types.js +1 -0
- package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +86 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -0
- package/dist/src/plugin/accounts.js +609 -0
- package/dist/src/plugin/accounts.js.map +1 -0
- package/dist/src/plugin/auth.d.ts +21 -0
- package/dist/src/plugin/auth.d.ts.map +1 -0
- package/dist/src/plugin/auth.js +46 -0
- package/dist/src/plugin/auth.js.map +1 -0
- package/dist/src/plugin/cache/index.d.ts +5 -0
- package/dist/src/plugin/cache/index.d.ts.map +1 -0
- package/dist/src/plugin/cache/index.js +5 -0
- package/dist/src/plugin/cache/index.js.map +1 -0
- package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/src/plugin/cache/signature-cache.js +375 -0
- package/dist/src/plugin/cache/signature-cache.js.map +1 -0
- package/dist/src/plugin/cache.d.ts +44 -0
- package/dist/src/plugin/cache.d.ts.map +1 -0
- package/dist/src/plugin/cache.js +200 -0
- package/dist/src/plugin/cache.js.map +1 -0
- package/dist/src/plugin/cli.d.ts +19 -0
- package/dist/src/plugin/cli.d.ts.map +1 -0
- package/dist/src/plugin/cli.js +59 -0
- package/dist/src/plugin/cli.js.map +1 -0
- package/dist/src/plugin/config/index.d.ts +16 -0
- package/dist/src/plugin/config/index.d.ts.map +1 -0
- package/dist/src/plugin/config/index.js +16 -0
- package/dist/src/plugin/config/index.js.map +1 -0
- package/dist/src/plugin/config/loader.d.ts +37 -0
- package/dist/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/src/plugin/config/loader.js +206 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +411 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +339 -0
- package/dist/src/plugin/config/schema.js.map +1 -0
- package/dist/src/plugin/core/streaming/index.d.ts +3 -0
- package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/index.js +3 -0
- package/dist/src/plugin/core/streaming/index.js.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.js +255 -0
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
- package/dist/src/plugin/core/streaming/types.d.ts +35 -0
- package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/types.js +1 -0
- package/dist/src/plugin/core/streaming/types.js.map +1 -0
- package/dist/src/plugin/debug.d.ts +68 -0
- package/dist/src/plugin/debug.d.ts.map +1 -0
- package/dist/src/plugin/debug.js +325 -0
- package/dist/src/plugin/debug.js.map +1 -0
- package/dist/src/plugin/errors.d.ts +28 -0
- package/dist/src/plugin/errors.d.ts.map +1 -0
- package/dist/src/plugin/errors.js +42 -0
- package/dist/src/plugin/errors.js.map +1 -0
- package/dist/src/plugin/image-saver.d.ts +25 -0
- package/dist/src/plugin/image-saver.d.ts.map +1 -0
- package/dist/src/plugin/image-saver.js +86 -0
- package/dist/src/plugin/image-saver.js.map +1 -0
- package/dist/src/plugin/logger.d.ts +54 -0
- package/dist/src/plugin/logger.d.ts.map +1 -0
- package/dist/src/plugin/logger.js +120 -0
- package/dist/src/plugin/logger.js.map +1 -0
- package/dist/src/plugin/project.d.ts +33 -0
- package/dist/src/plugin/project.d.ts.map +1 -0
- package/dist/src/plugin/project.js +234 -0
- package/dist/src/plugin/project.js.map +1 -0
- package/dist/src/plugin/recovery/constants.d.ts +22 -0
- package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/src/plugin/recovery/constants.js +43 -0
- package/dist/src/plugin/recovery/constants.js.map +1 -0
- package/dist/src/plugin/recovery/index.d.ts +12 -0
- package/dist/src/plugin/recovery/index.d.ts.map +1 -0
- package/dist/src/plugin/recovery/index.js +12 -0
- package/dist/src/plugin/recovery/index.js.map +1 -0
- package/dist/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/src/plugin/recovery/storage.js +354 -0
- package/dist/src/plugin/recovery/storage.js.map +1 -0
- package/dist/src/plugin/recovery/types.d.ts +116 -0
- package/dist/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/src/plugin/recovery/types.js +6 -0
- package/dist/src/plugin/recovery/types.js.map +1 -0
- package/dist/src/plugin/recovery.d.ts +61 -0
- package/dist/src/plugin/recovery.d.ts.map +1 -0
- package/dist/src/plugin/recovery.js +376 -0
- package/dist/src/plugin/recovery.js.map +1 -0
- package/dist/src/plugin/refresh-queue.d.ts +101 -0
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/src/plugin/refresh-queue.js +244 -0
- package/dist/src/plugin/refresh-queue.js.map +1 -0
- package/dist/src/plugin/request-helpers.d.ts +278 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/src/plugin/request-helpers.js +2268 -0
- package/dist/src/plugin/request-helpers.js.map +1 -0
- package/dist/src/plugin/request.d.ts +91 -0
- package/dist/src/plugin/request.d.ts.map +1 -0
- package/dist/src/plugin/request.js +1302 -0
- package/dist/src/plugin/request.js.map +1 -0
- package/dist/src/plugin/rotation.d.ts +168 -0
- package/dist/src/plugin/rotation.d.ts.map +1 -0
- package/dist/src/plugin/rotation.js +302 -0
- package/dist/src/plugin/rotation.js.map +1 -0
- package/dist/src/plugin/server.d.ts +23 -0
- package/dist/src/plugin/server.d.ts.map +1 -0
- package/dist/src/plugin/server.js +324 -0
- package/dist/src/plugin/server.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +92 -0
- package/dist/src/plugin/storage.d.ts.map +1 -0
- package/dist/src/plugin/storage.js +417 -0
- package/dist/src/plugin/storage.js.map +1 -0
- package/dist/src/plugin/stores/signature-store.d.ts +5 -0
- package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
- package/dist/src/plugin/stores/signature-store.js +25 -0
- package/dist/src/plugin/stores/signature-store.js.map +1 -0
- package/dist/src/plugin/thinking-recovery.d.ts +90 -0
- package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/src/plugin/thinking-recovery.js +316 -0
- package/dist/src/plugin/thinking-recovery.js.map +1 -0
- package/dist/src/plugin/token.d.ts +19 -0
- package/dist/src/plugin/token.d.ts.map +1 -0
- package/dist/src/plugin/token.js +128 -0
- package/dist/src/plugin/token.js.map +1 -0
- package/dist/src/plugin/transform/claude.d.ts +80 -0
- package/dist/src/plugin/transform/claude.d.ts.map +1 -0
- package/dist/src/plugin/transform/claude.js +265 -0
- package/dist/src/plugin/transform/claude.js.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
- package/dist/src/plugin/transform/gemini.d.ts +112 -0
- package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
- package/dist/src/plugin/transform/gemini.js +409 -0
- package/dist/src/plugin/transform/gemini.js.map +1 -0
- package/dist/src/plugin/transform/index.d.ts +15 -0
- package/dist/src/plugin/transform/index.d.ts.map +1 -0
- package/dist/src/plugin/transform/index.js +14 -0
- package/dist/src/plugin/transform/index.js.map +1 -0
- package/dist/src/plugin/transform/model-resolver.d.ts +101 -0
- package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/src/plugin/transform/model-resolver.js +356 -0
- package/dist/src/plugin/transform/model-resolver.js.map +1 -0
- package/dist/src/plugin/transform/types.d.ts +106 -0
- package/dist/src/plugin/transform/types.d.ts.map +1 -0
- package/dist/src/plugin/transform/types.js +1 -0
- package/dist/src/plugin/transform/types.js.map +1 -0
- package/dist/src/plugin/types.d.ts +96 -0
- package/dist/src/plugin/types.d.ts.map +1 -0
- package/dist/src/plugin/types.js +1 -0
- package/dist/src/plugin/types.js.map +1 -0
- package/dist/src/plugin/usage-reporter.d.ts +23 -0
- package/dist/src/plugin/usage-reporter.d.ts.map +1 -0
- package/dist/src/plugin/usage-reporter.js +43 -0
- package/dist/src/plugin/usage-reporter.js.map +1 -0
- package/dist/src/plugin.d.ts +8 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +1708 -0
- package/dist/src/plugin.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../../src/plugin/transform/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA0ChG,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAwEvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,OAAO,EACxB,aAAa,EAAE,YAAY,GAC1B,cAAc,CAKhB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,OAAO,EACxB,cAAc,CAAC,EAAE,MAAM,GACtB,cAAc,CAKhB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAOD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,IAAI,WAAW,CAYxD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,cAAc,GACtB;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAAE,CA8G5D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,YAAY,CAAC;IACjC,oDAAoD;IACpD,kBAAkB,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5E,kCAAkC;IAClC,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,qDAAqD;IACrD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yEAAyE;IACzE,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CA2DvB;AAED,MAAM,WAAW,eAAe;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,cAAc,GAAG,eAAe,CAkFxF"}
|
|
@@ -0,0 +1,409 @@
|
|
|
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" && typeof value === "object" && value !== null) {
|
|
72
|
+
// Recursively transform nested property schemas
|
|
73
|
+
const props = {};
|
|
74
|
+
for (const [propName, propSchema] of Object.entries(value)) {
|
|
75
|
+
props[propName] = toGeminiSchema(propSchema);
|
|
76
|
+
}
|
|
77
|
+
result[key] = props;
|
|
78
|
+
}
|
|
79
|
+
else if (key === "items" && typeof value === "object") {
|
|
80
|
+
// Transform array items schema
|
|
81
|
+
result[key] = toGeminiSchema(value);
|
|
82
|
+
}
|
|
83
|
+
else if ((key === "anyOf" || key === "oneOf" || key === "allOf") && Array.isArray(value)) {
|
|
84
|
+
// Transform union type schemas
|
|
85
|
+
result[key] = value.map((item) => toGeminiSchema(item));
|
|
86
|
+
}
|
|
87
|
+
else if (key === "enum" && Array.isArray(value)) {
|
|
88
|
+
// Keep enum values as-is
|
|
89
|
+
result[key] = value;
|
|
90
|
+
}
|
|
91
|
+
else if (key === "default" || key === "examples") {
|
|
92
|
+
// Keep default and examples as-is
|
|
93
|
+
result[key] = value;
|
|
94
|
+
}
|
|
95
|
+
else if (key === "required" && Array.isArray(value)) {
|
|
96
|
+
// Filter required array to only include properties that exist
|
|
97
|
+
// This fixes: "parameters.required[X]: property is not defined"
|
|
98
|
+
if (propertyNames.size > 0) {
|
|
99
|
+
const validRequired = value.filter((prop) => typeof prop === "string" && propertyNames.has(prop));
|
|
100
|
+
if (validRequired.length > 0) {
|
|
101
|
+
result[key] = validRequired;
|
|
102
|
+
}
|
|
103
|
+
// If no valid required properties, omit the required field entirely
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// If there are no properties, keep required as-is (might be a schema without properties)
|
|
107
|
+
result[key] = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
result[key] = value;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Issue #80: Ensure array schemas have an 'items' field
|
|
115
|
+
// Gemini API requires: "parameters.properties[X].items: missing field"
|
|
116
|
+
if (result.type === "ARRAY" && !result.items) {
|
|
117
|
+
result.items = { type: "STRING" };
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if a model is a Gemini model (not Claude).
|
|
123
|
+
*/
|
|
124
|
+
export function isGeminiModel(model) {
|
|
125
|
+
const lower = model.toLowerCase();
|
|
126
|
+
return lower.includes("gemini") && !lower.includes("claude");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Check if a model is Gemini 3 (uses thinkingLevel string).
|
|
130
|
+
*/
|
|
131
|
+
export function isGemini3Model(model) {
|
|
132
|
+
return model.toLowerCase().includes("gemini-3");
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check if a model is Gemini 2.5 (uses numeric thinkingBudget).
|
|
136
|
+
*/
|
|
137
|
+
export function isGemini25Model(model) {
|
|
138
|
+
return model.toLowerCase().includes("gemini-2.5");
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Check if a model is an image generation model.
|
|
142
|
+
* Image models don't support thinking and require imageConfig.
|
|
143
|
+
*/
|
|
144
|
+
export function isImageGenerationModel(model) {
|
|
145
|
+
const lower = model.toLowerCase();
|
|
146
|
+
return (lower.includes("image") ||
|
|
147
|
+
lower.includes("imagen"));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Build Gemini 3 thinking config with thinkingLevel string.
|
|
151
|
+
*/
|
|
152
|
+
export function buildGemini3ThinkingConfig(includeThoughts, thinkingLevel) {
|
|
153
|
+
return {
|
|
154
|
+
includeThoughts,
|
|
155
|
+
thinkingLevel,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Build Gemini 2.5 thinking config with numeric thinkingBudget.
|
|
160
|
+
*/
|
|
161
|
+
export function buildGemini25ThinkingConfig(includeThoughts, thinkingBudget) {
|
|
162
|
+
return {
|
|
163
|
+
includeThoughts,
|
|
164
|
+
...(typeof thinkingBudget === "number" && thinkingBudget > 0 ? { thinkingBudget } : {}),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Valid aspect ratios for image generation.
|
|
169
|
+
*/
|
|
170
|
+
const VALID_ASPECT_RATIOS = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"];
|
|
171
|
+
/**
|
|
172
|
+
* Build image generation config for Gemini image models.
|
|
173
|
+
*
|
|
174
|
+
* Configuration is read from environment variables:
|
|
175
|
+
* - OPENCODE_IMAGE_ASPECT_RATIO: Aspect ratio (e.g., "16:9", "4:3")
|
|
176
|
+
*
|
|
177
|
+
* Defaults to 1:1 aspect ratio if not specified.
|
|
178
|
+
*
|
|
179
|
+
* Note: Resolution setting is not currently supported by the Antigravity API.
|
|
180
|
+
*/
|
|
181
|
+
export function buildImageGenerationConfig() {
|
|
182
|
+
// Read aspect ratio from environment or default to 1:1
|
|
183
|
+
const aspectRatio = process.env.OPENCODE_IMAGE_ASPECT_RATIO || "1:1";
|
|
184
|
+
if (VALID_ASPECT_RATIOS.includes(aspectRatio)) {
|
|
185
|
+
return { aspectRatio };
|
|
186
|
+
}
|
|
187
|
+
console.warn(`[gemini] Invalid aspect ratio "${aspectRatio}". Using default "1:1". Valid values: ${VALID_ASPECT_RATIOS.join(", ")}`);
|
|
188
|
+
// Default to 1:1 square aspect ratio
|
|
189
|
+
return { aspectRatio: "1:1" };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Normalize tools for Gemini models.
|
|
193
|
+
* Ensures tools have proper function-style format.
|
|
194
|
+
*
|
|
195
|
+
* @returns Debug info about tool normalization
|
|
196
|
+
*/
|
|
197
|
+
export function normalizeGeminiTools(payload) {
|
|
198
|
+
let toolDebugMissing = 0;
|
|
199
|
+
const toolDebugSummaries = [];
|
|
200
|
+
if (!Array.isArray(payload.tools)) {
|
|
201
|
+
return { toolDebugMissing, toolDebugSummaries };
|
|
202
|
+
}
|
|
203
|
+
payload.tools = payload.tools.map((tool, toolIndex) => {
|
|
204
|
+
const t = tool;
|
|
205
|
+
// Skip normalization for Google Search Retrieval tool
|
|
206
|
+
if (t.googleSearchRetrieval) {
|
|
207
|
+
return t;
|
|
208
|
+
}
|
|
209
|
+
const newTool = { ...t };
|
|
210
|
+
const schemaCandidates = [
|
|
211
|
+
newTool.function?.input_schema,
|
|
212
|
+
newTool.function?.parameters,
|
|
213
|
+
newTool.function?.inputSchema,
|
|
214
|
+
newTool.custom?.input_schema,
|
|
215
|
+
newTool.custom?.parameters,
|
|
216
|
+
newTool.parameters,
|
|
217
|
+
newTool.input_schema,
|
|
218
|
+
newTool.inputSchema,
|
|
219
|
+
].filter(Boolean);
|
|
220
|
+
const placeholderSchema = {
|
|
221
|
+
type: "OBJECT",
|
|
222
|
+
properties: {
|
|
223
|
+
_placeholder: {
|
|
224
|
+
type: "BOOLEAN",
|
|
225
|
+
description: "Placeholder. Always pass true.",
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
required: ["_placeholder"],
|
|
229
|
+
};
|
|
230
|
+
let schema = schemaCandidates[0];
|
|
231
|
+
const schemaObjectOk = schema && typeof schema === "object" && !Array.isArray(schema);
|
|
232
|
+
if (!schemaObjectOk) {
|
|
233
|
+
schema = placeholderSchema;
|
|
234
|
+
toolDebugMissing += 1;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// Transform existing schema to Gemini-compatible format
|
|
238
|
+
schema = toGeminiSchema(schema);
|
|
239
|
+
}
|
|
240
|
+
const nameCandidate = newTool.name ||
|
|
241
|
+
newTool.function?.name ||
|
|
242
|
+
newTool.custom?.name ||
|
|
243
|
+
`tool-${toolIndex}`;
|
|
244
|
+
// Always update function.input_schema with transformed schema
|
|
245
|
+
if (newTool.function && schema) {
|
|
246
|
+
newTool.function.input_schema = schema;
|
|
247
|
+
}
|
|
248
|
+
// Always update custom.input_schema with transformed schema
|
|
249
|
+
if (newTool.custom && schema) {
|
|
250
|
+
newTool.custom.input_schema = schema;
|
|
251
|
+
}
|
|
252
|
+
// Create custom from function if missing
|
|
253
|
+
if (!newTool.custom && newTool.function) {
|
|
254
|
+
const fn = newTool.function;
|
|
255
|
+
newTool.custom = {
|
|
256
|
+
name: fn.name || nameCandidate,
|
|
257
|
+
description: fn.description,
|
|
258
|
+
input_schema: schema,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
// Create custom if both missing
|
|
262
|
+
if (!newTool.custom && !newTool.function) {
|
|
263
|
+
newTool.custom = {
|
|
264
|
+
name: nameCandidate,
|
|
265
|
+
description: newTool.description,
|
|
266
|
+
input_schema: schema,
|
|
267
|
+
};
|
|
268
|
+
if (!newTool.parameters && !newTool.input_schema && !newTool.inputSchema) {
|
|
269
|
+
newTool.parameters = schema;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (newTool.custom && !newTool.custom.input_schema) {
|
|
273
|
+
newTool.custom.input_schema = {
|
|
274
|
+
type: "OBJECT",
|
|
275
|
+
properties: {},
|
|
276
|
+
};
|
|
277
|
+
toolDebugMissing += 1;
|
|
278
|
+
}
|
|
279
|
+
toolDebugSummaries.push(`idx=${toolIndex}, hasCustom=${!!newTool.custom}, customSchema=${!!newTool.custom?.input_schema}, hasFunction=${!!newTool.function}, functionSchema=${!!newTool.function?.input_schema}`);
|
|
280
|
+
// Strip custom wrappers for Gemini; only function-style is accepted.
|
|
281
|
+
if (newTool.custom) {
|
|
282
|
+
delete newTool.custom;
|
|
283
|
+
}
|
|
284
|
+
return newTool;
|
|
285
|
+
});
|
|
286
|
+
return { toolDebugMissing, toolDebugSummaries };
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Apply all Gemini-specific transformations.
|
|
290
|
+
*/
|
|
291
|
+
export function applyGeminiTransforms(payload, options) {
|
|
292
|
+
const { model, tierThinkingBudget, tierThinkingLevel, normalizedThinking, googleSearch } = options;
|
|
293
|
+
// 1. Apply thinking config if needed
|
|
294
|
+
if (normalizedThinking) {
|
|
295
|
+
let thinkingConfig;
|
|
296
|
+
if (tierThinkingLevel && isGemini3Model(model)) {
|
|
297
|
+
// Gemini 3 uses thinkingLevel string
|
|
298
|
+
thinkingConfig = buildGemini3ThinkingConfig(normalizedThinking.includeThoughts ?? true, tierThinkingLevel);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
// Gemini 2.5 and others use numeric budget
|
|
302
|
+
const thinkingBudget = tierThinkingBudget ?? normalizedThinking.thinkingBudget;
|
|
303
|
+
thinkingConfig = buildGemini25ThinkingConfig(normalizedThinking.includeThoughts ?? true, thinkingBudget);
|
|
304
|
+
}
|
|
305
|
+
const generationConfig = (payload.generationConfig ?? {});
|
|
306
|
+
generationConfig.thinkingConfig = thinkingConfig;
|
|
307
|
+
payload.generationConfig = generationConfig;
|
|
308
|
+
}
|
|
309
|
+
// 2. Apply Google Search (Grounding) if enabled
|
|
310
|
+
if (googleSearch && googleSearch.mode === 'auto') {
|
|
311
|
+
const tools = payload.tools || [];
|
|
312
|
+
if (!payload.tools) {
|
|
313
|
+
payload.tools = tools;
|
|
314
|
+
}
|
|
315
|
+
// Add Google Search tool
|
|
316
|
+
// We cast to any[] to avoid TypeScript issues with the loose RequestPayload type
|
|
317
|
+
payload.tools.push({
|
|
318
|
+
googleSearchRetrieval: {
|
|
319
|
+
dynamicRetrievalConfig: {
|
|
320
|
+
mode: "MODE_DYNAMIC",
|
|
321
|
+
dynamicThreshold: googleSearch.threshold ?? 0.3,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
// 3. Normalize tools
|
|
327
|
+
const result = normalizeGeminiTools(payload);
|
|
328
|
+
// 4. Wrap tools in functionDeclarations format (fixes #203, #206)
|
|
329
|
+
// Antigravity strict protobuf validation rejects wrapper-level 'parameters' field
|
|
330
|
+
// Must be: [{ functionDeclarations: [{ name, description, parameters }] }]
|
|
331
|
+
const wrapResult = wrapToolsAsFunctionDeclarations(payload);
|
|
332
|
+
return {
|
|
333
|
+
...result,
|
|
334
|
+
wrappedFunctionCount: wrapResult.wrappedFunctionCount,
|
|
335
|
+
passthroughToolCount: wrapResult.passthroughToolCount,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Wrap tools array in Gemini's required functionDeclarations format.
|
|
340
|
+
*
|
|
341
|
+
* Gemini/Antigravity API expects:
|
|
342
|
+
* { tools: [{ functionDeclarations: [{ name, description, parameters }] }] }
|
|
343
|
+
*
|
|
344
|
+
* NOT:
|
|
345
|
+
* { tools: [{ function: {...}, parameters: {...} }] }
|
|
346
|
+
*
|
|
347
|
+
* The wrapper-level 'parameters' field causes:
|
|
348
|
+
* "Unknown name 'parameters' at 'request.tools[0]'"
|
|
349
|
+
*/
|
|
350
|
+
export function wrapToolsAsFunctionDeclarations(payload) {
|
|
351
|
+
if (!Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
352
|
+
return { wrappedFunctionCount: 0, passthroughToolCount: 0 };
|
|
353
|
+
}
|
|
354
|
+
const functionDeclarations = [];
|
|
355
|
+
const passthroughTools = [];
|
|
356
|
+
for (const tool of payload.tools) {
|
|
357
|
+
if (tool.googleSearchRetrieval || tool.codeExecution) {
|
|
358
|
+
passthroughTools.push(tool);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (tool.functionDeclarations) {
|
|
362
|
+
if (Array.isArray(tool.functionDeclarations)) {
|
|
363
|
+
for (const decl of tool.functionDeclarations) {
|
|
364
|
+
functionDeclarations.push({
|
|
365
|
+
name: String(decl.name || `tool-${functionDeclarations.length}`),
|
|
366
|
+
description: String(decl.description || ""),
|
|
367
|
+
parameters: decl.parameters || { type: "OBJECT", properties: {} },
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const fn = tool.function;
|
|
374
|
+
const custom = tool.custom;
|
|
375
|
+
const name = String(tool.name ||
|
|
376
|
+
fn?.name ||
|
|
377
|
+
custom?.name ||
|
|
378
|
+
`tool-${functionDeclarations.length}`);
|
|
379
|
+
const description = String(tool.description ||
|
|
380
|
+
fn?.description ||
|
|
381
|
+
custom?.description ||
|
|
382
|
+
"");
|
|
383
|
+
const schema = (fn?.input_schema ||
|
|
384
|
+
fn?.parameters ||
|
|
385
|
+
fn?.inputSchema ||
|
|
386
|
+
custom?.input_schema ||
|
|
387
|
+
custom?.parameters ||
|
|
388
|
+
tool.parameters ||
|
|
389
|
+
tool.input_schema ||
|
|
390
|
+
tool.inputSchema ||
|
|
391
|
+
{ type: "OBJECT", properties: {} });
|
|
392
|
+
functionDeclarations.push({
|
|
393
|
+
name,
|
|
394
|
+
description,
|
|
395
|
+
parameters: schema,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
const finalTools = [];
|
|
399
|
+
if (functionDeclarations.length > 0) {
|
|
400
|
+
finalTools.push({ functionDeclarations });
|
|
401
|
+
}
|
|
402
|
+
finalTools.push(...passthroughTools);
|
|
403
|
+
payload.tools = finalTools;
|
|
404
|
+
return {
|
|
405
|
+
wrappedFunctionCount: functionDeclarations.length,
|
|
406
|
+
passthroughToolCount: passthroughTools.length,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=gemini.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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+
* 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,101 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Thinking tier budgets by model family.
|
|
10
|
+
* Claude and Gemini 2.5 Pro use numeric budgets.
|
|
11
|
+
*/
|
|
12
|
+
export declare const THINKING_TIER_BUDGETS: {
|
|
13
|
+
readonly claude: {
|
|
14
|
+
readonly low: 8192;
|
|
15
|
+
readonly medium: 16384;
|
|
16
|
+
readonly high: 32768;
|
|
17
|
+
};
|
|
18
|
+
readonly "gemini-2.5-pro": {
|
|
19
|
+
readonly low: 8192;
|
|
20
|
+
readonly medium: 16384;
|
|
21
|
+
readonly high: 32768;
|
|
22
|
+
};
|
|
23
|
+
readonly "gemini-2.5-flash": {
|
|
24
|
+
readonly low: 6144;
|
|
25
|
+
readonly medium: 12288;
|
|
26
|
+
readonly high: 24576;
|
|
27
|
+
};
|
|
28
|
+
readonly default: {
|
|
29
|
+
readonly low: 4096;
|
|
30
|
+
readonly medium: 8192;
|
|
31
|
+
readonly high: 16384;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Gemini 3 uses thinkingLevel strings instead of numeric budgets.
|
|
36
|
+
* Flash supports: minimal, low, medium, high
|
|
37
|
+
* Pro supports: low, high (no minimal/medium)
|
|
38
|
+
*/
|
|
39
|
+
export declare const GEMINI_3_THINKING_LEVELS: readonly ["minimal", "low", "medium", "high"];
|
|
40
|
+
/**
|
|
41
|
+
* Model aliases - maps user-friendly names to API model names.
|
|
42
|
+
*
|
|
43
|
+
* Format:
|
|
44
|
+
* - Gemini 3 Pro variants: gemini-3-pro-{low,medium,high}
|
|
45
|
+
* - Claude thinking variants: claude-{model}-thinking-{low,medium,high}
|
|
46
|
+
* - Claude non-thinking: claude-{model} (no -thinking suffix)
|
|
47
|
+
*/
|
|
48
|
+
export declare const MODEL_ALIASES: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* Model fallbacks when primary model is unavailable.
|
|
51
|
+
* NOTE: Image models should NOT fall back to non-image models!
|
|
52
|
+
*/
|
|
53
|
+
export declare const MODEL_FALLBACKS: Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Resolves a model name with optional tier suffix and quota prefix to its actual API model name
|
|
56
|
+
* and corresponding thinking configuration.
|
|
57
|
+
*
|
|
58
|
+
* Quota routing:
|
|
59
|
+
* - "antigravity-" prefix → Antigravity quota
|
|
60
|
+
* - Claude/GPT models → Antigravity quota (auto, these only exist on Antigravity)
|
|
61
|
+
* - Legacy Gemini 3 names (gemini-3-pro-low, gemini-3-flash, etc.) → Antigravity quota (backward compat)
|
|
62
|
+
* - Other models → Gemini CLI quota (default)
|
|
63
|
+
*
|
|
64
|
+
* Examples:
|
|
65
|
+
* - "gemini-2.5-flash" → { quotaPreference: "gemini-cli" }
|
|
66
|
+
* - "gemini-3-pro-preview" → { quotaPreference: "gemini-cli" } (Gemini CLI uses -preview)
|
|
67
|
+
* - "gemini-3-pro-low" → { quotaPreference: "antigravity" } (legacy name, backward compat)
|
|
68
|
+
* - "antigravity-gemini-3-pro-high" → { quotaPreference: "antigravity" } (explicit prefix)
|
|
69
|
+
* - "claude-sonnet-4-5-thinking-medium" → { quotaPreference: "antigravity" } (Claude only on Antigravity)
|
|
70
|
+
*
|
|
71
|
+
* @param requestedModel - The model name from the request
|
|
72
|
+
* @returns Resolved model with thinking configuration
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveModelWithTier(requestedModel: string): ResolvedModel;
|
|
75
|
+
/**
|
|
76
|
+
* Gets the model family for routing decisions.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getModelFamily(model: string): "claude" | "gemini-flash" | "gemini-pro";
|
|
79
|
+
/**
|
|
80
|
+
* Variant config from OpenCode's providerOptions.
|
|
81
|
+
*/
|
|
82
|
+
export interface VariantConfig {
|
|
83
|
+
thinkingBudget?: number;
|
|
84
|
+
googleSearch?: GoogleSearchConfig;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Resolves model name for a specific headerStyle (quota fallback support).
|
|
88
|
+
* Transforms model names when switching between gemini-cli and antigravity quotas.
|
|
89
|
+
*
|
|
90
|
+
* Issue #103: When quota fallback occurs, model names need to be transformed:
|
|
91
|
+
* - gemini-3-flash-preview (gemini-cli) → gemini-3-flash (antigravity)
|
|
92
|
+
* - gemini-3-pro-preview (gemini-cli) → gemini-3-pro-low (antigravity)
|
|
93
|
+
* - gemini-3-flash (antigravity) → gemini-3-flash-preview (gemini-cli)
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveModelForHeaderStyle(requestedModel: string, headerStyle: "antigravity" | "gemini-cli"): ResolvedModel;
|
|
96
|
+
/**
|
|
97
|
+
* Resolves model with variant config from providerOptions.
|
|
98
|
+
* Variant config takes priority over tier suffix in model name.
|
|
99
|
+
*/
|
|
100
|
+
export declare function resolveModelWithVariant(requestedModel: string, variantConfig?: VariantConfig): ResolvedModel;
|
|
101
|
+
//# 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;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAKxB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,+CAAgD,CAAC;AAEtF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAElD,CAAC;AA4FF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,aAAa,CAyG1E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,cAAc,GAAG,YAAY,CAStF;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,CAwCf;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,aAAa,GAC5B,aAAa,CA6Cf"}
|