@cortexkit/opencode-antigravity-auth 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +147 -32
- package/dist/index.js.map +3 -3
- package/dist/src/plugin/accounts.d.ts +7 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +16 -5
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +3 -2
- package/dist/src/plugin/debug.js.map +1 -1
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +8 -4
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/request.d.ts +9 -4
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +25 -14
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +13 -3
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +27 -1
- package/dist/src/plugin.js.map +1 -1
- package/package.json +2 -2
- package/dist/src/plugin/transform/claude.d.ts +0 -92
- package/dist/src/plugin/transform/claude.d.ts.map +0 -1
- package/dist/src/plugin/transform/claude.js +0 -280
- package/dist/src/plugin/transform/claude.js.map +0 -1
- package/dist/src/plugin/transform/gemini.d.ts +0 -100
- package/dist/src/plugin/transform/gemini.d.ts.map +0 -1
- package/dist/src/plugin/transform/gemini.js +0 -446
- package/dist/src/plugin/transform/gemini.js.map +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude-specific Request Transformations
|
|
3
|
-
*
|
|
4
|
-
* Handles Claude model-specific request transformations including:
|
|
5
|
-
* - Tool config (VALIDATED mode)
|
|
6
|
-
* - Thinking config (snake_case keys)
|
|
7
|
-
* - System instruction hints for interleaved thinking
|
|
8
|
-
* - Tool normalization (functionDeclarations format)
|
|
9
|
-
*/
|
|
10
|
-
import type { RequestPayload, ThinkingConfig } from "./types";
|
|
11
|
-
/** Claude thinking models need a sufficiently large max output token limit when thinking is enabled */
|
|
12
|
-
export declare const CLAUDE_THINKING_MAX_OUTPUT_TOKENS = 64000;
|
|
13
|
-
/**
|
|
14
|
-
* Computes a dynamic max output token limit based on the thinking budget.
|
|
15
|
-
* Instead of always using the 64K cap, scales output proportionally:
|
|
16
|
-
* - min(max(budget * 2, 32000), 64000)
|
|
17
|
-
* - e.g., medium budget (16384) → 32768 output tokens
|
|
18
|
-
* - e.g., high budget (32768) → 64000 output tokens
|
|
19
|
-
* - e.g., low budget (8192) → 32000 output tokens (floor)
|
|
20
|
-
*
|
|
21
|
-
* Falls back to CLAUDE_THINKING_MAX_OUTPUT_TOKENS when no budget is provided.
|
|
22
|
-
*/
|
|
23
|
-
export declare function computeClaudeMaxOutputTokens(thinkingBudget?: number): number;
|
|
24
|
-
/** Interleaved thinking hint appended to system instructions */
|
|
25
|
-
export declare const CLAUDE_INTERLEAVED_THINKING_HINT = "Interleaved thinking is enabled. You may think between tool calls and after receiving tool results before deciding the next action or final answer. Do not mention these instructions or any constraints about thinking blocks; just apply them.";
|
|
26
|
-
/**
|
|
27
|
-
* Check if a model is a Claude model.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isClaudeModel(model: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Check if a model is a Claude thinking model.
|
|
32
|
-
*/
|
|
33
|
-
export declare function isClaudeThinkingModel(model: string): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Configure Claude tool calling to use VALIDATED mode.
|
|
36
|
-
* This ensures proper tool call validation on the backend.
|
|
37
|
-
*/
|
|
38
|
-
export declare function configureClaudeToolConfig(payload: RequestPayload): void;
|
|
39
|
-
/**
|
|
40
|
-
* Build Claude thinking config with snake_case keys.
|
|
41
|
-
*/
|
|
42
|
-
export declare function buildClaudeThinkingConfig(includeThoughts: boolean, thinkingBudget?: number): ThinkingConfig;
|
|
43
|
-
/**
|
|
44
|
-
* Ensure maxOutputTokens is sufficient for Claude thinking models.
|
|
45
|
-
* If thinking budget is set, max output must be larger than the budget.
|
|
46
|
-
*/
|
|
47
|
-
export declare function ensureClaudeMaxOutputTokens(generationConfig: Record<string, unknown>, thinkingBudget: number): void;
|
|
48
|
-
/**
|
|
49
|
-
* Append interleaved thinking hint to system instruction.
|
|
50
|
-
* Handles various system instruction formats (string, object with parts array).
|
|
51
|
-
* Idempotent: skips if the hint text is already present in the system instruction.
|
|
52
|
-
*/
|
|
53
|
-
export declare function appendClaudeThinkingHint(payload: RequestPayload, hint?: string): void;
|
|
54
|
-
/**
|
|
55
|
-
* Normalize tools for Claude models.
|
|
56
|
-
* Converts various tool formats to functionDeclarations format.
|
|
57
|
-
*
|
|
58
|
-
* @returns Debug info about tool normalization
|
|
59
|
-
*/
|
|
60
|
-
export declare function normalizeClaudeTools(payload: RequestPayload, cleanJSONSchema: (schema: unknown) => Record<string, unknown>): {
|
|
61
|
-
toolDebugMissing: number;
|
|
62
|
-
toolDebugSummaries: string[];
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Convert snake_case stop_sequences to camelCase stopSequences.
|
|
66
|
-
*/
|
|
67
|
-
export declare function convertStopSequences(generationConfig: Record<string, unknown>): void;
|
|
68
|
-
/**
|
|
69
|
-
* Apply all Claude-specific transformations to a request payload.
|
|
70
|
-
*/
|
|
71
|
-
export interface ClaudeTransformOptions {
|
|
72
|
-
/** The effective model name (resolved) */
|
|
73
|
-
model: string;
|
|
74
|
-
/** Tier-based thinking budget (from model suffix) */
|
|
75
|
-
tierThinkingBudget?: number;
|
|
76
|
-
/** Normalized thinking config from user settings */
|
|
77
|
-
normalizedThinking?: {
|
|
78
|
-
includeThoughts?: boolean;
|
|
79
|
-
thinkingBudget?: number;
|
|
80
|
-
};
|
|
81
|
-
/** Function to clean JSON schema for Antigravity */
|
|
82
|
-
cleanJSONSchema: (schema: unknown) => Record<string, unknown>;
|
|
83
|
-
}
|
|
84
|
-
export interface ClaudeTransformResult {
|
|
85
|
-
toolDebugMissing: number;
|
|
86
|
-
toolDebugSummaries: string[];
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Apply all Claude-specific transformations.
|
|
90
|
-
*/
|
|
91
|
-
export declare function applyClaudeTransforms(payload: RequestPayload, options: ClaudeTransformOptions): ClaudeTransformResult;
|
|
92
|
-
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../../src/plugin/transform/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAM9D,uGAAuG;AACvG,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAK5E;AACD,gEAAgE;AAChE,eAAO,MAAM,gCAAgC,qPACuM,CAAC;AAErP;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG5D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAcvE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,OAAO,EACxB,cAAc,CAAC,EAAE,MAAM,GACtB,cAAc,CAOhB;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,cAAc,EAAE,MAAM,GACrB,IAAI,CASN;AACD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,cAAc,EACvB,IAAI,GAAE,MAAyC,GAC9C,IAAI,CAqCN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5D;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAAE,CA2I5D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,IAAI,CAKN;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,kBAAkB,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5E,oDAAoD;IACpD,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAuCvB"}
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude-specific Request Transformations
|
|
3
|
-
*
|
|
4
|
-
* Handles Claude model-specific request transformations including:
|
|
5
|
-
* - Tool config (VALIDATED mode)
|
|
6
|
-
* - Thinking config (snake_case keys)
|
|
7
|
-
* - System instruction hints for interleaved thinking
|
|
8
|
-
* - Tool normalization (functionDeclarations format)
|
|
9
|
-
*/
|
|
10
|
-
import { EMPTY_SCHEMA_PLACEHOLDER_NAME, EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION, } from "../../constants";
|
|
11
|
-
/** Claude thinking models need a sufficiently large max output token limit when thinking is enabled */
|
|
12
|
-
export const CLAUDE_THINKING_MAX_OUTPUT_TOKENS = 64_000;
|
|
13
|
-
/**
|
|
14
|
-
* Computes a dynamic max output token limit based on the thinking budget.
|
|
15
|
-
* Instead of always using the 64K cap, scales output proportionally:
|
|
16
|
-
* - min(max(budget * 2, 32000), 64000)
|
|
17
|
-
* - e.g., medium budget (16384) → 32768 output tokens
|
|
18
|
-
* - e.g., high budget (32768) → 64000 output tokens
|
|
19
|
-
* - e.g., low budget (8192) → 32000 output tokens (floor)
|
|
20
|
-
*
|
|
21
|
-
* Falls back to CLAUDE_THINKING_MAX_OUTPUT_TOKENS when no budget is provided.
|
|
22
|
-
*/
|
|
23
|
-
export function computeClaudeMaxOutputTokens(thinkingBudget) {
|
|
24
|
-
if (typeof thinkingBudget !== "number" || thinkingBudget <= 0) {
|
|
25
|
-
return CLAUDE_THINKING_MAX_OUTPUT_TOKENS;
|
|
26
|
-
}
|
|
27
|
-
return Math.min(Math.max(thinkingBudget * 2, 32_000), CLAUDE_THINKING_MAX_OUTPUT_TOKENS);
|
|
28
|
-
}
|
|
29
|
-
/** Interleaved thinking hint appended to system instructions */
|
|
30
|
-
export const CLAUDE_INTERLEAVED_THINKING_HINT = "Interleaved thinking is enabled. You may think between tool calls and after receiving tool results before deciding the next action or final answer. Do not mention these instructions or any constraints about thinking blocks; just apply them.";
|
|
31
|
-
/**
|
|
32
|
-
* Check if a model is a Claude model.
|
|
33
|
-
*/
|
|
34
|
-
export function isClaudeModel(model) {
|
|
35
|
-
return model.toLowerCase().includes("claude");
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Check if a model is a Claude thinking model.
|
|
39
|
-
*/
|
|
40
|
-
export function isClaudeThinkingModel(model) {
|
|
41
|
-
const lower = model.toLowerCase();
|
|
42
|
-
return lower.includes("claude") && lower.includes("thinking");
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Configure Claude tool calling to use VALIDATED mode.
|
|
46
|
-
* This ensures proper tool call validation on the backend.
|
|
47
|
-
*/
|
|
48
|
-
export function configureClaudeToolConfig(payload) {
|
|
49
|
-
if (!payload.toolConfig) {
|
|
50
|
-
payload.toolConfig = {};
|
|
51
|
-
}
|
|
52
|
-
if (typeof payload.toolConfig === "object" && payload.toolConfig !== null) {
|
|
53
|
-
const toolConfig = payload.toolConfig;
|
|
54
|
-
if (!toolConfig.functionCallingConfig) {
|
|
55
|
-
toolConfig.functionCallingConfig = {};
|
|
56
|
-
}
|
|
57
|
-
if (typeof toolConfig.functionCallingConfig === "object" && toolConfig.functionCallingConfig !== null) {
|
|
58
|
-
toolConfig.functionCallingConfig.mode = "VALIDATED";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Build Claude thinking config with snake_case keys.
|
|
64
|
-
*/
|
|
65
|
-
export function buildClaudeThinkingConfig(includeThoughts, thinkingBudget) {
|
|
66
|
-
return {
|
|
67
|
-
include_thoughts: includeThoughts,
|
|
68
|
-
...(typeof thinkingBudget === "number" && thinkingBudget > 0
|
|
69
|
-
? { thinking_budget: thinkingBudget }
|
|
70
|
-
: {}),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Ensure maxOutputTokens is sufficient for Claude thinking models.
|
|
75
|
-
* If thinking budget is set, max output must be larger than the budget.
|
|
76
|
-
*/
|
|
77
|
-
export function ensureClaudeMaxOutputTokens(generationConfig, thinkingBudget) {
|
|
78
|
-
const currentMax = (generationConfig.maxOutputTokens ?? generationConfig.max_output_tokens);
|
|
79
|
-
if (!currentMax || currentMax <= thinkingBudget) {
|
|
80
|
-
generationConfig.maxOutputTokens = computeClaudeMaxOutputTokens(thinkingBudget);
|
|
81
|
-
if (generationConfig.max_output_tokens !== undefined) {
|
|
82
|
-
delete generationConfig.max_output_tokens;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Append interleaved thinking hint to system instruction.
|
|
88
|
-
* Handles various system instruction formats (string, object with parts array).
|
|
89
|
-
* Idempotent: skips if the hint text is already present in the system instruction.
|
|
90
|
-
*/
|
|
91
|
-
export function appendClaudeThinkingHint(payload, hint = CLAUDE_INTERLEAVED_THINKING_HINT) {
|
|
92
|
-
const existing = payload.systemInstruction;
|
|
93
|
-
// Idempotency guard: check if the hint is already present
|
|
94
|
-
if (typeof existing === "string" && existing.includes(hint)) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (existing && typeof existing === "object") {
|
|
98
|
-
const sys = existing;
|
|
99
|
-
if (Array.isArray(sys.parts)) {
|
|
100
|
-
const alreadyHasHint = sys.parts.some((p) => p && typeof p === "object" && p.text === hint);
|
|
101
|
-
if (alreadyHasHint)
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (typeof existing === "string") {
|
|
106
|
-
payload.systemInstruction = existing.trim().length > 0
|
|
107
|
-
? { role: "user", parts: [{ text: existing }, { text: hint }] }
|
|
108
|
-
: hint;
|
|
109
|
-
}
|
|
110
|
-
else if (existing && typeof existing === "object") {
|
|
111
|
-
const sys = existing;
|
|
112
|
-
const partsValue = sys.parts;
|
|
113
|
-
if (Array.isArray(partsValue)) {
|
|
114
|
-
// Spread to avoid mutating shared array reference (OpenCode may reuse between requests)
|
|
115
|
-
sys.parts = [...partsValue, { text: hint }];
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
sys.parts = [{ text: hint }];
|
|
119
|
-
}
|
|
120
|
-
payload.systemInstruction = sys;
|
|
121
|
-
}
|
|
122
|
-
else if (Array.isArray(payload.contents)) {
|
|
123
|
-
// No existing system instruction, create one
|
|
124
|
-
payload.systemInstruction = { parts: [{ text: hint }] };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Normalize tools for Claude models.
|
|
129
|
-
* Converts various tool formats to functionDeclarations format.
|
|
130
|
-
*
|
|
131
|
-
* @returns Debug info about tool normalization
|
|
132
|
-
*/
|
|
133
|
-
export function normalizeClaudeTools(payload, cleanJSONSchema) {
|
|
134
|
-
let toolDebugMissing = 0;
|
|
135
|
-
const toolDebugSummaries = [];
|
|
136
|
-
if (!Array.isArray(payload.tools)) {
|
|
137
|
-
return { toolDebugMissing, toolDebugSummaries };
|
|
138
|
-
}
|
|
139
|
-
const functionDeclarations = [];
|
|
140
|
-
const passthroughTools = [];
|
|
141
|
-
const normalizeSchema = (schema) => {
|
|
142
|
-
const createPlaceholderSchema = (base = {}) => ({
|
|
143
|
-
...base,
|
|
144
|
-
type: "object",
|
|
145
|
-
properties: {
|
|
146
|
-
[EMPTY_SCHEMA_PLACEHOLDER_NAME]: {
|
|
147
|
-
type: "boolean",
|
|
148
|
-
description: EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
required: [EMPTY_SCHEMA_PLACEHOLDER_NAME],
|
|
152
|
-
});
|
|
153
|
-
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
|
154
|
-
toolDebugMissing += 1;
|
|
155
|
-
return createPlaceholderSchema();
|
|
156
|
-
}
|
|
157
|
-
const cleaned = cleanJSONSchema(schema);
|
|
158
|
-
if (!cleaned || typeof cleaned !== "object" || Array.isArray(cleaned)) {
|
|
159
|
-
toolDebugMissing += 1;
|
|
160
|
-
return createPlaceholderSchema();
|
|
161
|
-
}
|
|
162
|
-
// Claude VALIDATED mode requires tool parameters to be an object schema
|
|
163
|
-
// with at least one property.
|
|
164
|
-
const hasProperties = cleaned.properties &&
|
|
165
|
-
typeof cleaned.properties === "object" &&
|
|
166
|
-
Object.keys(cleaned.properties).length > 0;
|
|
167
|
-
cleaned.type = "object";
|
|
168
|
-
if (!hasProperties) {
|
|
169
|
-
cleaned.properties = {
|
|
170
|
-
_placeholder: {
|
|
171
|
-
type: "boolean",
|
|
172
|
-
description: "Placeholder. Always pass true.",
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
cleaned.required = Array.isArray(cleaned.required)
|
|
176
|
-
? Array.from(new Set([...cleaned.required, "_placeholder"]))
|
|
177
|
-
: ["_placeholder"];
|
|
178
|
-
}
|
|
179
|
-
return cleaned;
|
|
180
|
-
};
|
|
181
|
-
payload.tools.forEach((tool) => {
|
|
182
|
-
const t = tool;
|
|
183
|
-
const pushDeclaration = (decl, source) => {
|
|
184
|
-
const schema = decl?.parameters ||
|
|
185
|
-
decl?.parametersJsonSchema ||
|
|
186
|
-
decl?.input_schema ||
|
|
187
|
-
decl?.inputSchema ||
|
|
188
|
-
t.parameters ||
|
|
189
|
-
t.parametersJsonSchema ||
|
|
190
|
-
t.input_schema ||
|
|
191
|
-
t.inputSchema ||
|
|
192
|
-
t.function?.parameters ||
|
|
193
|
-
t.function?.parametersJsonSchema ||
|
|
194
|
-
t.function?.input_schema ||
|
|
195
|
-
t.function?.inputSchema ||
|
|
196
|
-
t.custom?.parameters ||
|
|
197
|
-
t.custom?.parametersJsonSchema ||
|
|
198
|
-
t.custom?.input_schema;
|
|
199
|
-
let name = decl?.name ||
|
|
200
|
-
t.name ||
|
|
201
|
-
t.function?.name ||
|
|
202
|
-
t.custom?.name ||
|
|
203
|
-
`tool-${functionDeclarations.length}`;
|
|
204
|
-
// Sanitize tool name: must be alphanumeric with underscores, no special chars
|
|
205
|
-
name = String(name).replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
206
|
-
const description = decl?.description ||
|
|
207
|
-
t.description ||
|
|
208
|
-
t.function?.description ||
|
|
209
|
-
t.custom?.description ||
|
|
210
|
-
"";
|
|
211
|
-
functionDeclarations.push({
|
|
212
|
-
name,
|
|
213
|
-
description: String(description || ""),
|
|
214
|
-
parameters: normalizeSchema(schema),
|
|
215
|
-
});
|
|
216
|
-
toolDebugSummaries.push(`decl=${name},src=${source},hasSchema=${schema ? "y" : "n"}`);
|
|
217
|
-
};
|
|
218
|
-
// Check for functionDeclarations array first
|
|
219
|
-
if (Array.isArray(t.functionDeclarations) && t.functionDeclarations.length > 0) {
|
|
220
|
-
t.functionDeclarations.forEach((decl) => pushDeclaration(decl, "functionDeclarations"));
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
// Fall back to function/custom style definitions
|
|
224
|
-
if (t.function || t.custom || t.parameters || t.input_schema || t.inputSchema) {
|
|
225
|
-
pushDeclaration(t.function ??
|
|
226
|
-
t.custom ??
|
|
227
|
-
t, "function/custom");
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
// Preserve any non-function tool entries (e.g., codeExecution) untouched
|
|
231
|
-
passthroughTools.push(tool);
|
|
232
|
-
});
|
|
233
|
-
const finalTools = [];
|
|
234
|
-
if (functionDeclarations.length > 0) {
|
|
235
|
-
finalTools.push({ functionDeclarations });
|
|
236
|
-
}
|
|
237
|
-
payload.tools = finalTools.concat(passthroughTools);
|
|
238
|
-
return { toolDebugMissing, toolDebugSummaries };
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Convert snake_case stop_sequences to camelCase stopSequences.
|
|
242
|
-
*/
|
|
243
|
-
export function convertStopSequences(generationConfig) {
|
|
244
|
-
if (Array.isArray(generationConfig.stop_sequences)) {
|
|
245
|
-
generationConfig.stopSequences = generationConfig.stop_sequences;
|
|
246
|
-
delete generationConfig.stop_sequences;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Apply all Claude-specific transformations.
|
|
251
|
-
*/
|
|
252
|
-
export function applyClaudeTransforms(payload, options) {
|
|
253
|
-
const { model, tierThinkingBudget, normalizedThinking, cleanJSONSchema } = options;
|
|
254
|
-
const isThinking = isClaudeThinkingModel(model);
|
|
255
|
-
// 1. Configure tool calling mode
|
|
256
|
-
configureClaudeToolConfig(payload);
|
|
257
|
-
if (payload.generationConfig) {
|
|
258
|
-
convertStopSequences(payload.generationConfig);
|
|
259
|
-
}
|
|
260
|
-
// 2. Apply thinking config if needed
|
|
261
|
-
if (normalizedThinking) {
|
|
262
|
-
const thinkingBudget = tierThinkingBudget ?? normalizedThinking.thinkingBudget;
|
|
263
|
-
if (isThinking) {
|
|
264
|
-
const thinkingConfig = buildClaudeThinkingConfig(normalizedThinking.includeThoughts ?? true, thinkingBudget);
|
|
265
|
-
const generationConfig = (payload.generationConfig ?? {});
|
|
266
|
-
generationConfig.thinkingConfig = thinkingConfig;
|
|
267
|
-
if (typeof thinkingBudget === "number" && thinkingBudget > 0) {
|
|
268
|
-
ensureClaudeMaxOutputTokens(generationConfig, thinkingBudget);
|
|
269
|
-
}
|
|
270
|
-
payload.generationConfig = generationConfig;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// 3. Append interleaved thinking hint for thinking models with tools
|
|
274
|
-
if (isThinking && Array.isArray(payload.tools) && payload.tools.length > 0) {
|
|
275
|
-
appendClaudeThinkingHint(payload);
|
|
276
|
-
}
|
|
277
|
-
// 4. Normalize tools
|
|
278
|
-
return normalizeClaudeTools(payload, cleanJSONSchema);
|
|
279
|
-
}
|
|
280
|
-
//# sourceMappingURL=claude.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../../../src/plugin/transform/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,GACrC,MAAM,iBAAiB,CAAC;AAEzB,uGAAuG;AACvG,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B,CAAC,cAAuB;IAClE,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,IAAI,CAAC,EA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;QAE/E,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,cAAc,GAAG,yBAAyB,CAC9C,kBAAkB,CAAC,eAAe,IAAI,IAAI,EAC1C,cAAc,CACf,CAAC;YAEF,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAA4B,CAAC;YACrF,gBAAgB,CAAC,cAAc,GAAG,cAAc,CAAC;YAEjD,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;gBAC7D,2BAA2B,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;YAChE,CAAC;YAED,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,IAAI,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAK,OAAO,CAAC,KAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1F,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,qBAAqB;IACrB,OAAO,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,100 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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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