opencode-agy-auth 2.0.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 +745 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/src/antigravity/oauth.d.ts +31 -0
- package/dist/src/antigravity/oauth.d.ts.map +1 -0
- package/dist/src/antigravity/oauth.js +171 -0
- package/dist/src/antigravity/oauth.js.map +1 -0
- package/dist/src/constants.d.ts +155 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +251 -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 +174 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -0
- package/dist/src/plugin/accounts.js +1243 -0
- package/dist/src/plugin/accounts.js.map +1 -0
- package/dist/src/plugin/auth.d.ts +21 -0
- package/dist/src/plugin/auth.d.ts.map +1 -0
- package/dist/src/plugin/auth.js +46 -0
- package/dist/src/plugin/auth.js.map +1 -0
- package/dist/src/plugin/cache/index.d.ts +5 -0
- package/dist/src/plugin/cache/index.d.ts.map +1 -0
- package/dist/src/plugin/cache/index.js +5 -0
- package/dist/src/plugin/cache/index.js.map +1 -0
- package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/src/plugin/cache/signature-cache.js +375 -0
- package/dist/src/plugin/cache/signature-cache.js.map +1 -0
- package/dist/src/plugin/cache.d.ts +44 -0
- package/dist/src/plugin/cache.d.ts.map +1 -0
- package/dist/src/plugin/cache.js +200 -0
- package/dist/src/plugin/cache.js.map +1 -0
- package/dist/src/plugin/cli.d.ts +27 -0
- package/dist/src/plugin/cli.d.ts.map +1 -0
- package/dist/src/plugin/cli.js +130 -0
- package/dist/src/plugin/cli.js.map +1 -0
- package/dist/src/plugin/config/index.d.ts +16 -0
- package/dist/src/plugin/config/index.d.ts.map +1 -0
- package/dist/src/plugin/config/index.js +16 -0
- package/dist/src/plugin/config/index.js.map +1 -0
- package/dist/src/plugin/config/loader.d.ts +38 -0
- package/dist/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/src/plugin/config/loader.js +204 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/models.d.ts +27 -0
- package/dist/src/plugin/config/models.d.ts.map +1 -0
- package/dist/src/plugin/config/models.js +79 -0
- package/dist/src/plugin/config/models.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +134 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +445 -0
- package/dist/src/plugin/config/schema.js.map +1 -0
- package/dist/src/plugin/config/updater.d.ts +55 -0
- package/dist/src/plugin/config/updater.d.ts.map +1 -0
- package/dist/src/plugin/config/updater.js +133 -0
- package/dist/src/plugin/config/updater.js.map +1 -0
- package/dist/src/plugin/core/streaming/index.d.ts +3 -0
- package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/index.js +3 -0
- package/dist/src/plugin/core/streaming/index.js.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.js +271 -0
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
- package/dist/src/plugin/core/streaming/types.d.ts +27 -0
- package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/types.js +1 -0
- package/dist/src/plugin/core/streaming/types.js.map +1 -0
- package/dist/src/plugin/debug.d.ts +94 -0
- package/dist/src/plugin/debug.d.ts.map +1 -0
- package/dist/src/plugin/debug.js +418 -0
- package/dist/src/plugin/debug.js.map +1 -0
- package/dist/src/plugin/errors.d.ts +28 -0
- package/dist/src/plugin/errors.d.ts.map +1 -0
- package/dist/src/plugin/errors.js +42 -0
- package/dist/src/plugin/errors.js.map +1 -0
- package/dist/src/plugin/fingerprint.d.ts +71 -0
- package/dist/src/plugin/fingerprint.d.ts.map +1 -0
- package/dist/src/plugin/fingerprint.js +140 -0
- package/dist/src/plugin/fingerprint.js.map +1 -0
- package/dist/src/plugin/image-saver.d.ts +25 -0
- package/dist/src/plugin/image-saver.d.ts.map +1 -0
- package/dist/src/plugin/image-saver.js +86 -0
- package/dist/src/plugin/image-saver.js.map +1 -0
- package/dist/src/plugin/logger.d.ts +54 -0
- package/dist/src/plugin/logger.d.ts.map +1 -0
- package/dist/src/plugin/logger.js +120 -0
- package/dist/src/plugin/logger.js.map +1 -0
- package/dist/src/plugin/project.d.ts +33 -0
- package/dist/src/plugin/project.d.ts.map +1 -0
- package/dist/src/plugin/project.js +234 -0
- package/dist/src/plugin/project.js.map +1 -0
- package/dist/src/plugin/proxy.d.ts +2 -0
- package/dist/src/plugin/proxy.d.ts.map +1 -0
- package/dist/src/plugin/proxy.js +20 -0
- package/dist/src/plugin/proxy.js.map +1 -0
- package/dist/src/plugin/quota.d.ts +58 -0
- package/dist/src/plugin/quota.d.ts.map +1 -0
- package/dist/src/plugin/quota.js +430 -0
- package/dist/src/plugin/quota.js.map +1 -0
- package/dist/src/plugin/recovery/constants.d.ts +22 -0
- package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/src/plugin/recovery/constants.js +43 -0
- package/dist/src/plugin/recovery/constants.js.map +1 -0
- package/dist/src/plugin/recovery/index.d.ts +12 -0
- package/dist/src/plugin/recovery/index.d.ts.map +1 -0
- package/dist/src/plugin/recovery/index.js +12 -0
- package/dist/src/plugin/recovery/index.js.map +1 -0
- package/dist/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/src/plugin/recovery/storage.js +354 -0
- package/dist/src/plugin/recovery/storage.js.map +1 -0
- package/dist/src/plugin/recovery/types.d.ts +116 -0
- package/dist/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/src/plugin/recovery/types.js +6 -0
- package/dist/src/plugin/recovery/types.js.map +1 -0
- package/dist/src/plugin/recovery.d.ts +61 -0
- package/dist/src/plugin/recovery.d.ts.map +1 -0
- package/dist/src/plugin/recovery.js +378 -0
- package/dist/src/plugin/recovery.js.map +1 -0
- package/dist/src/plugin/refresh-queue.d.ts +101 -0
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/src/plugin/refresh-queue.js +248 -0
- package/dist/src/plugin/refresh-queue.js.map +1 -0
- package/dist/src/plugin/request-helpers.d.ts +306 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/src/plugin/request-helpers.js +2476 -0
- package/dist/src/plugin/request-helpers.js.map +1 -0
- package/dist/src/plugin/request.d.ts +98 -0
- package/dist/src/plugin/request.d.ts.map +1 -0
- package/dist/src/plugin/request.js +1513 -0
- package/dist/src/plugin/request.js.map +1 -0
- package/dist/src/plugin/rotation.d.ts +169 -0
- package/dist/src/plugin/rotation.d.ts.map +1 -0
- package/dist/src/plugin/rotation.js +328 -0
- package/dist/src/plugin/rotation.js.map +1 -0
- package/dist/src/plugin/search.d.ts +32 -0
- package/dist/src/plugin/search.d.ts.map +1 -0
- package/dist/src/plugin/search.js +195 -0
- package/dist/src/plugin/search.js.map +1 -0
- package/dist/src/plugin/server.d.ts +23 -0
- package/dist/src/plugin/server.d.ts.map +1 -0
- package/dist/src/plugin/server.js +324 -0
- package/dist/src/plugin/server.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +137 -0
- package/dist/src/plugin/storage.d.ts.map +1 -0
- package/dist/src/plugin/storage.js +588 -0
- package/dist/src/plugin/storage.js.map +1 -0
- package/dist/src/plugin/stores/signature-store.d.ts +5 -0
- package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
- package/dist/src/plugin/stores/signature-store.js +25 -0
- package/dist/src/plugin/stores/signature-store.js.map +1 -0
- package/dist/src/plugin/thinking-recovery.d.ts +90 -0
- package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/src/plugin/thinking-recovery.js +316 -0
- package/dist/src/plugin/thinking-recovery.js.map +1 -0
- package/dist/src/plugin/token.d.ts +19 -0
- package/dist/src/plugin/token.d.ts.map +1 -0
- package/dist/src/plugin/token.js +128 -0
- package/dist/src/plugin/token.js.map +1 -0
- package/dist/src/plugin/transform/claude.d.ts +82 -0
- package/dist/src/plugin/transform/claude.d.ts.map +1 -0
- package/dist/src/plugin/transform/claude.js +278 -0
- package/dist/src/plugin/transform/claude.js.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
- package/dist/src/plugin/transform/gemini.d.ts +100 -0
- package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
- package/dist/src/plugin/transform/gemini.js +504 -0
- package/dist/src/plugin/transform/gemini.js.map +1 -0
- package/dist/src/plugin/transform/index.d.ts +15 -0
- package/dist/src/plugin/transform/index.d.ts.map +1 -0
- package/dist/src/plugin/transform/index.js +14 -0
- package/dist/src/plugin/transform/index.js.map +1 -0
- package/dist/src/plugin/transform/model-resolver.d.ts +104 -0
- package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/src/plugin/transform/model-resolver.js +409 -0
- package/dist/src/plugin/transform/model-resolver.js.map +1 -0
- package/dist/src/plugin/transform/types.d.ts +111 -0
- package/dist/src/plugin/transform/types.d.ts.map +1 -0
- package/dist/src/plugin/transform/types.js +1 -0
- package/dist/src/plugin/transform/types.js.map +1 -0
- package/dist/src/plugin/types.d.ts +97 -0
- package/dist/src/plugin/types.d.ts.map +1 -0
- package/dist/src/plugin/types.js +1 -0
- package/dist/src/plugin/types.js.map +1 -0
- package/dist/src/plugin/ui/ansi.d.ts +32 -0
- package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
- package/dist/src/plugin/ui/ansi.js +52 -0
- package/dist/src/plugin/ui/ansi.js.map +1 -0
- package/dist/src/plugin/ui/auth-menu.d.ts +37 -0
- package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
- package/dist/src/plugin/ui/auth-menu.js +182 -0
- package/dist/src/plugin/ui/auth-menu.js.map +1 -0
- package/dist/src/plugin/ui/confirm.d.ts +2 -0
- package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
- package/dist/src/plugin/ui/confirm.js +15 -0
- package/dist/src/plugin/ui/confirm.js.map +1 -0
- package/dist/src/plugin/ui/select.d.ts +23 -0
- package/dist/src/plugin/ui/select.d.ts.map +1 -0
- package/dist/src/plugin/ui/select.js +254 -0
- package/dist/src/plugin/ui/select.js.map +1 -0
- package/dist/src/plugin/version.d.ts +19 -0
- package/dist/src/plugin/version.d.ts.map +1 -0
- package/dist/src/plugin/version.js +74 -0
- package/dist/src/plugin/version.js.map +1 -0
- package/dist/src/plugin.d.ts +40 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +3407 -0
- package/dist/src/plugin.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
import type { RequestPayload, ThinkingConfig, ThinkingTier, GoogleSearchConfig } from "./types";
|
|
10
|
+
export declare function toGeminiSchema(schema: unknown): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a model is a Gemini model (not Claude).
|
|
13
|
+
*/
|
|
14
|
+
export declare function isGeminiModel(model: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a model is Gemini 3 (uses thinkingLevel string).
|
|
17
|
+
*/
|
|
18
|
+
export declare function isGemini3Model(model: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a model is Gemini 2.5 (uses numeric thinkingBudget).
|
|
21
|
+
*/
|
|
22
|
+
export declare function isGemini25Model(model: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a model is an image generation model.
|
|
25
|
+
* Image models don't support thinking and require imageConfig.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isImageGenerationModel(model: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Build Gemini 3 thinking config with thinkingLevel string.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildGemini3ThinkingConfig(includeThoughts: boolean, thinkingLevel: ThinkingTier): ThinkingConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Build Gemini 2.5 thinking config with numeric thinkingBudget.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildGemini25ThinkingConfig(includeThoughts: boolean, thinkingBudget?: number): ThinkingConfig;
|
|
36
|
+
/**
|
|
37
|
+
* Image generation config for Gemini image models.
|
|
38
|
+
*
|
|
39
|
+
* Supported aspect ratios: "1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"
|
|
40
|
+
*/
|
|
41
|
+
export interface ImageConfig {
|
|
42
|
+
aspectRatio?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build image generation config for Gemini image models.
|
|
46
|
+
*
|
|
47
|
+
* Configuration is read from environment variables:
|
|
48
|
+
* - OPENCODE_IMAGE_ASPECT_RATIO: Aspect ratio (e.g., "16:9", "4:3")
|
|
49
|
+
*
|
|
50
|
+
* Defaults to 1:1 aspect ratio if not specified.
|
|
51
|
+
*
|
|
52
|
+
* Note: Resolution setting is not currently supported by the Antigravity API.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildImageGenerationConfig(): ImageConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Normalize tools for Gemini models.
|
|
57
|
+
* Ensures tools have proper function-style format.
|
|
58
|
+
*
|
|
59
|
+
* @returns Debug info about tool normalization
|
|
60
|
+
*/
|
|
61
|
+
export declare function normalizeGeminiTools(payload: RequestPayload): {
|
|
62
|
+
toolDebugMissing: number;
|
|
63
|
+
toolDebugSummaries: string[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Apply all Gemini-specific transformations to a request payload.
|
|
67
|
+
*/
|
|
68
|
+
export interface GeminiTransformOptions {
|
|
69
|
+
/** The effective model name (resolved) */
|
|
70
|
+
model: string;
|
|
71
|
+
/** Tier-based thinking budget (from model suffix, for Gemini 2.5) */
|
|
72
|
+
tierThinkingBudget?: number;
|
|
73
|
+
/** Tier-based thinking level (from model suffix, for Gemini 3) */
|
|
74
|
+
tierThinkingLevel?: ThinkingTier;
|
|
75
|
+
/** Normalized thinking config from user settings */
|
|
76
|
+
normalizedThinking?: {
|
|
77
|
+
includeThoughts?: boolean;
|
|
78
|
+
thinkingBudget?: number;
|
|
79
|
+
};
|
|
80
|
+
/** Google Search configuration */
|
|
81
|
+
googleSearch?: GoogleSearchConfig;
|
|
82
|
+
}
|
|
83
|
+
export interface GeminiTransformResult {
|
|
84
|
+
toolDebugMissing: number;
|
|
85
|
+
toolDebugSummaries: string[];
|
|
86
|
+
/** Number of function declarations after wrapping */
|
|
87
|
+
wrappedFunctionCount: number;
|
|
88
|
+
/** Number of passthrough tools (googleSearch, googleSearchRetrieval, codeExecution) */
|
|
89
|
+
passthroughToolCount: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Apply all Gemini-specific transformations.
|
|
93
|
+
*/
|
|
94
|
+
export declare function applyGeminiTransforms(payload: RequestPayload, options: GeminiTransformOptions): GeminiTransformResult;
|
|
95
|
+
export interface WrapToolsResult {
|
|
96
|
+
wrappedFunctionCount: number;
|
|
97
|
+
passthroughToolCount: number;
|
|
98
|
+
}
|
|
99
|
+
export declare function wrapToolsAsFunctionDeclarations(payload: RequestPayload): WrapToolsResult;
|
|
100
|
+
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -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,EA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oB,EAAE,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;AAgDD,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,cAAc,GACtB,eAAe,CAkIjB"}
|
|
@@ -0,0 +1,504 @@
|
|
|
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
|
+
if (Array.isArray(t.functionDeclarations)) {
|
|
225
|
+
toolDebugSummaries.push(`idx=${toolIndex}, hasFunctionDeclarations=true, passthrough=true`);
|
|
226
|
+
return t;
|
|
227
|
+
}
|
|
228
|
+
const newTool = { ...t };
|
|
229
|
+
const schemaCandidates = [
|
|
230
|
+
newTool.function?.input_schema,
|
|
231
|
+
newTool.function?.parameters,
|
|
232
|
+
newTool.function?.inputSchema,
|
|
233
|
+
newTool.custom?.input_schema,
|
|
234
|
+
newTool.custom?.parameters,
|
|
235
|
+
newTool.parameters,
|
|
236
|
+
newTool.input_schema,
|
|
237
|
+
newTool.inputSchema,
|
|
238
|
+
].filter(Boolean);
|
|
239
|
+
const placeholderSchema = {
|
|
240
|
+
type: "OBJECT",
|
|
241
|
+
properties: {
|
|
242
|
+
_placeholder: {
|
|
243
|
+
type: "BOOLEAN",
|
|
244
|
+
description: "Placeholder. Always pass true.",
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
required: ["_placeholder"],
|
|
248
|
+
};
|
|
249
|
+
let schema = schemaCandidates[0];
|
|
250
|
+
const schemaObjectOk = schema &&
|
|
251
|
+
typeof schema === "object" &&
|
|
252
|
+
!Array.isArray(schema) &&
|
|
253
|
+
Object.keys(schema).length > 0;
|
|
254
|
+
if (!schemaObjectOk) {
|
|
255
|
+
schema = placeholderSchema;
|
|
256
|
+
toolDebugMissing += 1;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// Transform existing schema to Gemini-compatible format
|
|
260
|
+
schema = toGeminiSchema(schema);
|
|
261
|
+
}
|
|
262
|
+
const nameCandidate = newTool.name ||
|
|
263
|
+
newTool.function?.name ||
|
|
264
|
+
newTool.custom?.name ||
|
|
265
|
+
`tool-${toolIndex}`;
|
|
266
|
+
// Always update function.input_schema with transformed schema
|
|
267
|
+
if (newTool.function && schema) {
|
|
268
|
+
newTool.function.input_schema = schema;
|
|
269
|
+
}
|
|
270
|
+
// Always update custom.input_schema with transformed schema
|
|
271
|
+
if (newTool.custom && schema) {
|
|
272
|
+
newTool.custom.input_schema = schema;
|
|
273
|
+
}
|
|
274
|
+
// Create custom from function if missing
|
|
275
|
+
if (!newTool.custom && newTool.function) {
|
|
276
|
+
const fn = newTool.function;
|
|
277
|
+
newTool.custom = {
|
|
278
|
+
name: fn.name || nameCandidate,
|
|
279
|
+
description: fn.description,
|
|
280
|
+
input_schema: schema,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if (!newTool.function && newTool.custom) {
|
|
284
|
+
const customTool = newTool.custom;
|
|
285
|
+
newTool.function = {
|
|
286
|
+
name: customTool.name || nameCandidate,
|
|
287
|
+
description: customTool.description || newTool.description,
|
|
288
|
+
input_schema: schema,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
// Create custom if both missing
|
|
292
|
+
if (!newTool.custom && !newTool.function) {
|
|
293
|
+
newTool.custom = {
|
|
294
|
+
name: nameCandidate,
|
|
295
|
+
description: newTool.description,
|
|
296
|
+
input_schema: schema,
|
|
297
|
+
};
|
|
298
|
+
if (!newTool.parameters &&
|
|
299
|
+
!newTool.input_schema &&
|
|
300
|
+
!newTool.inputSchema) {
|
|
301
|
+
newTool.parameters = schema;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (newTool.custom &&
|
|
305
|
+
!newTool.custom.input_schema) {
|
|
306
|
+
newTool.custom.input_schema =
|
|
307
|
+
placeholderSchema;
|
|
308
|
+
toolDebugMissing += 1;
|
|
309
|
+
}
|
|
310
|
+
toolDebugSummaries.push(`idx=${toolIndex}, hasCustom=${!!newTool.custom}, customSchema=${!!newTool.custom?.input_schema}, hasFunction=${!!newTool.function}, functionSchema=${!!newTool.function?.input_schema}`);
|
|
311
|
+
// Strip custom wrappers for Gemini; only function-style is accepted.
|
|
312
|
+
if (newTool.custom) {
|
|
313
|
+
delete newTool.custom;
|
|
314
|
+
}
|
|
315
|
+
return newTool;
|
|
316
|
+
});
|
|
317
|
+
return { toolDebugMissing, toolDebugSummaries };
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Apply all Gemini-specific transformations.
|
|
321
|
+
*/
|
|
322
|
+
export function applyGeminiTransforms(payload, options) {
|
|
323
|
+
const { model, tierThinkingBudget, tierThinkingLevel, normalizedThinking, googleSearch, } = options;
|
|
324
|
+
// 1. Apply thinking config if needed
|
|
325
|
+
if (normalizedThinking) {
|
|
326
|
+
let thinkingConfig;
|
|
327
|
+
if (tierThinkingLevel && isGemini3Model(model)) {
|
|
328
|
+
// Gemini 3 uses thinkingLevel string
|
|
329
|
+
thinkingConfig = buildGemini3ThinkingConfig(normalizedThinking.includeThoughts ?? true, tierThinkingLevel);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
// Gemini 2.5 and others use numeric budget
|
|
333
|
+
const thinkingBudget = tierThinkingBudget ?? normalizedThinking.thinkingBudget;
|
|
334
|
+
thinkingConfig = buildGemini25ThinkingConfig(normalizedThinking.includeThoughts ?? true, thinkingBudget);
|
|
335
|
+
}
|
|
336
|
+
const generationConfig = (payload.generationConfig ?? {});
|
|
337
|
+
generationConfig.thinkingConfig = thinkingConfig;
|
|
338
|
+
payload.generationConfig = generationConfig;
|
|
339
|
+
}
|
|
340
|
+
// 2. Apply Google Search (Grounding) if enabled
|
|
341
|
+
// Uses the new googleSearch API for Gemini 2.0+ / Gemini 3 models
|
|
342
|
+
// Note: The old googleSearchRetrieval with dynamicRetrievalConfig is deprecated
|
|
343
|
+
// The new API doesn't support threshold - the model decides when to search automatically
|
|
344
|
+
if (googleSearch && googleSearch.mode === "auto") {
|
|
345
|
+
const tools = payload.tools || [];
|
|
346
|
+
if (!payload.tools) {
|
|
347
|
+
payload.tools = tools;
|
|
348
|
+
}
|
|
349
|
+
// Add Google Search tool using new API format for Gemini 2.0+
|
|
350
|
+
// See: https://ai.google.dev/gemini-api/docs/grounding
|
|
351
|
+
payload.tools.push({
|
|
352
|
+
googleSearch: {},
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
// 3. Normalize tools
|
|
356
|
+
const result = normalizeGeminiTools(payload);
|
|
357
|
+
// 4. Wrap tools in functionDeclarations format (fixes #203, #206)
|
|
358
|
+
// Antigravity strict protobuf validation rejects wrapper-level 'parameters' field
|
|
359
|
+
// Must be: [{ functionDeclarations: [{ name, description, parameters }] }]
|
|
360
|
+
const wrapResult = wrapToolsAsFunctionDeclarations(payload);
|
|
361
|
+
return {
|
|
362
|
+
...result,
|
|
363
|
+
wrappedFunctionCount: wrapResult.wrappedFunctionCount,
|
|
364
|
+
passthroughToolCount: wrapResult.passthroughToolCount,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Wrap tools array in Gemini's required functionDeclarations format.
|
|
369
|
+
*
|
|
370
|
+
* Gemini/Antigravity API expects:
|
|
371
|
+
* { tools: [{ functionDeclarations: [{ name, description, parameters }] }] }
|
|
372
|
+
*
|
|
373
|
+
* NOT:
|
|
374
|
+
* { tools: [{ function: {...}, parameters: {...} }] }
|
|
375
|
+
*
|
|
376
|
+
* The wrapper-level 'parameters' field causes:
|
|
377
|
+
* "Unknown name 'parameters' at 'request.tools[0]'"
|
|
378
|
+
*/
|
|
379
|
+
/**
|
|
380
|
+
* Detect if a tool is a web search tool in any of the supported formats:
|
|
381
|
+
* - Claude/Anthropic: { type: "web_search_20250305" } or { name: "web_search" }
|
|
382
|
+
* - Gemini native: { googleSearch: {} } or { googleSearchRetrieval: {} }
|
|
383
|
+
*/
|
|
384
|
+
function isWebSearchTool(tool) {
|
|
385
|
+
// 1. Gemini native format
|
|
386
|
+
if (tool.googleSearch || tool.googleSearchRetrieval) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
// 2. Claude/Anthropic format: { type: "web_search_20250305" }
|
|
390
|
+
if (tool.type === "web_search_20250305") {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
// 3. Simple name-based format: { name: "web_search" | "google_search" }
|
|
394
|
+
const name = tool.name;
|
|
395
|
+
if (name === "web_search" || name === "google_search") {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
function sanitizeFunctionName(name, fallbackIndex) {
|
|
401
|
+
const normalized = name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
402
|
+
const ensuredPrefix = /^[a-zA-Z_]/.test(normalized)
|
|
403
|
+
? normalized
|
|
404
|
+
: `tool_${normalized}`;
|
|
405
|
+
const safe = ensuredPrefix || `tool_${fallbackIndex}`;
|
|
406
|
+
return safe.slice(0, 64);
|
|
407
|
+
}
|
|
408
|
+
export function wrapToolsAsFunctionDeclarations(payload) {
|
|
409
|
+
if (!Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
410
|
+
return { wrappedFunctionCount: 0, passthroughToolCount: 0 };
|
|
411
|
+
}
|
|
412
|
+
const functionDeclarations = [];
|
|
413
|
+
const passthroughTools = [];
|
|
414
|
+
let hasWebSearchTool = false;
|
|
415
|
+
const usedFunctionNames = new Map();
|
|
416
|
+
const reserveFunctionName = (rawName, fallbackIndex) => {
|
|
417
|
+
const baseName = sanitizeFunctionName(rawName, fallbackIndex);
|
|
418
|
+
const seen = usedFunctionNames.get(baseName) ?? 0;
|
|
419
|
+
usedFunctionNames.set(baseName, seen + 1);
|
|
420
|
+
if (seen === 0) {
|
|
421
|
+
return baseName;
|
|
422
|
+
}
|
|
423
|
+
const suffix = `_${seen}`;
|
|
424
|
+
const maxBaseLength = 64 - suffix.length;
|
|
425
|
+
const truncatedBase = baseName.slice(0, Math.max(1, maxBaseLength));
|
|
426
|
+
return `${truncatedBase}${suffix}`;
|
|
427
|
+
};
|
|
428
|
+
for (const tool of payload.tools) {
|
|
429
|
+
// Handle passthrough tools (Google Search and Code Execution)
|
|
430
|
+
if (tool.googleSearch || tool.googleSearchRetrieval || tool.codeExecution) {
|
|
431
|
+
passthroughTools.push(tool);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
// Detect and convert web search tools to Gemini format
|
|
435
|
+
if (isWebSearchTool(tool)) {
|
|
436
|
+
hasWebSearchTool = true;
|
|
437
|
+
continue; // Will be added as { googleSearch: {} } at the end
|
|
438
|
+
}
|
|
439
|
+
if (tool.functionDeclarations) {
|
|
440
|
+
if (Array.isArray(tool.functionDeclarations)) {
|
|
441
|
+
for (const decl of tool.functionDeclarations) {
|
|
442
|
+
const rawSchema = (decl.parameters ||
|
|
443
|
+
decl.parametersJsonSchema ||
|
|
444
|
+
decl.input_schema ||
|
|
445
|
+
decl.inputSchema || {
|
|
446
|
+
type: "OBJECT",
|
|
447
|
+
properties: {},
|
|
448
|
+
});
|
|
449
|
+
const schema = toGeminiSchema(rawSchema);
|
|
450
|
+
const rawName = String(decl.name || `tool-${functionDeclarations.length}`);
|
|
451
|
+
functionDeclarations.push({
|
|
452
|
+
name: reserveFunctionName(rawName, functionDeclarations.length),
|
|
453
|
+
description: String(decl.description || ""),
|
|
454
|
+
parameters: schema,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
const fn = tool.function;
|
|
461
|
+
const custom = tool.custom;
|
|
462
|
+
const name = String(tool.name ||
|
|
463
|
+
fn?.name ||
|
|
464
|
+
custom?.name ||
|
|
465
|
+
`tool-${functionDeclarations.length}`);
|
|
466
|
+
const description = String(tool.description || fn?.description || custom?.description || "");
|
|
467
|
+
const schema = (fn?.input_schema ||
|
|
468
|
+
fn?.parameters ||
|
|
469
|
+
fn?.inputSchema ||
|
|
470
|
+
custom?.input_schema ||
|
|
471
|
+
custom?.parameters ||
|
|
472
|
+
tool.parameters ||
|
|
473
|
+
tool.input_schema ||
|
|
474
|
+
tool.inputSchema || { type: "OBJECT", properties: {} });
|
|
475
|
+
functionDeclarations.push({
|
|
476
|
+
name: reserveFunctionName(name, functionDeclarations.length),
|
|
477
|
+
description,
|
|
478
|
+
parameters: schema,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
const finalTools = [];
|
|
482
|
+
if (functionDeclarations.length > 0) {
|
|
483
|
+
finalTools.push({ functionDeclarations });
|
|
484
|
+
}
|
|
485
|
+
finalTools.push(...passthroughTools);
|
|
486
|
+
// Add googleSearch tool if a web search tool was detected
|
|
487
|
+
// Note: googleSearch cannot be combined with functionDeclarations in the same request
|
|
488
|
+
// If there are function declarations, we skip adding googleSearch (Gemini API limitation)
|
|
489
|
+
if (hasWebSearchTool && functionDeclarations.length === 0) {
|
|
490
|
+
finalTools.push({ googleSearch: {} });
|
|
491
|
+
}
|
|
492
|
+
else if (hasWebSearchTool && functionDeclarations.length > 0) {
|
|
493
|
+
// Log warning: web search requested but can't be used with functions
|
|
494
|
+
console.warn("[gemini] web_search tool detected but cannot be combined with function declarations. " +
|
|
495
|
+
"Use the explicit google_search() tool call instead.");
|
|
496
|
+
}
|
|
497
|
+
payload.tools = finalTools;
|
|
498
|
+
return {
|
|
499
|
+
wrappedFunctionCount: functionDeclarations.length,
|
|
500
|
+
passthroughToolCount: passthroughTools.length +
|
|
501
|
+
(hasWebSearchTool && functionDeclarations.length === 0 ? 1 : 0),
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
//# sourceMappingURL=gemini.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../../src/plugin/transform/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH;;;;;;;;;;;;;;GAcG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,sBAAsB;IACtB,SAAS;IACT,KAAK;IACL,UAAU;IACV,MAAM;IACN,OAAO;IACP,aAAa;IACb,OAAO;IACP,kBAAkB;IAClB,iBAAiB;IACjB,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK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AE,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
|