@reinamaccredy/oh-my-opencode 3.0.0-beta.14 → 3.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cli/config-manager.d.ts +3 -3
  2. package/dist/cli/index.js +158 -350
  3. package/dist/cli/types.d.ts +0 -1
  4. package/dist/config/index.d.ts +2 -2
  5. package/dist/config/schema.d.ts +215 -181
  6. package/dist/features/background-agent/index.d.ts +1 -1
  7. package/dist/features/background-agent/manager.d.ts +10 -0
  8. package/dist/features/background-agent/types.d.ts +4 -0
  9. package/dist/features/boulder-state/index.d.ts +1 -0
  10. package/dist/features/boulder-state/unified-state.d.ts +86 -0
  11. package/dist/features/maestro/hooks/index.d.ts +16 -0
  12. package/dist/features/maestro/index.d.ts +4 -0
  13. package/dist/features/maestro/skills/index.d.ts +4 -0
  14. package/dist/features/maestro/types.d.ts +42 -0
  15. package/dist/features/maestro/utils/index.d.ts +4 -0
  16. package/dist/features/workflow-engine/contracts/v1/types.d.ts +9 -0
  17. package/dist/hooks/background-notification/index.d.ts +10 -0
  18. package/dist/hooks/index.d.ts +3 -0
  19. package/dist/hooks/maestro-sisyphus-bridge/constants.d.ts +9 -0
  20. package/dist/hooks/maestro-sisyphus-bridge/index.d.ts +53 -0
  21. package/dist/hooks/tdd-enforcement/constants.d.ts +16 -0
  22. package/dist/hooks/tdd-enforcement/index.d.ts +54 -0
  23. package/dist/index.js +1851 -6022
  24. package/dist/shared/migration.d.ts +4 -0
  25. package/dist/tools/skill/tools.d.ts +1 -7
  26. package/dist/tools/slashcommand/tools.d.ts +1 -7
  27. package/package.json +2 -6
  28. package/dist/auth/antigravity/accounts.d.ts +0 -40
  29. package/dist/auth/antigravity/accounts.test.d.ts +0 -1
  30. package/dist/auth/antigravity/browser.d.ts +0 -27
  31. package/dist/auth/antigravity/browser.test.d.ts +0 -1
  32. package/dist/auth/antigravity/cli.d.ts +0 -2
  33. package/dist/auth/antigravity/cli.test.d.ts +0 -1
  34. package/dist/auth/antigravity/constants.d.ts +0 -98
  35. package/dist/auth/antigravity/constants.test.d.ts +0 -1
  36. package/dist/auth/antigravity/fetch.d.ts +0 -69
  37. package/dist/auth/antigravity/index.d.ts +0 -13
  38. package/dist/auth/antigravity/integration.test.d.ts +0 -10
  39. package/dist/auth/antigravity/message-converter.d.ts +0 -54
  40. package/dist/auth/antigravity/oauth.d.ts +0 -51
  41. package/dist/auth/antigravity/oauth.test.d.ts +0 -1
  42. package/dist/auth/antigravity/plugin.d.ts +0 -54
  43. package/dist/auth/antigravity/project.d.ts +0 -10
  44. package/dist/auth/antigravity/request.d.ts +0 -116
  45. package/dist/auth/antigravity/request.test.d.ts +0 -1
  46. package/dist/auth/antigravity/response.d.ts +0 -137
  47. package/dist/auth/antigravity/storage.d.ts +0 -5
  48. package/dist/auth/antigravity/storage.test.d.ts +0 -1
  49. package/dist/auth/antigravity/thinking.d.ts +0 -278
  50. package/dist/auth/antigravity/thinking.test.d.ts +0 -10
  51. package/dist/auth/antigravity/thought-signature-store.d.ts +0 -52
  52. package/dist/auth/antigravity/token.d.ts +0 -38
  53. package/dist/auth/antigravity/token.test.d.ts +0 -1
  54. package/dist/auth/antigravity/tools.d.ts +0 -119
  55. package/dist/auth/antigravity/types.d.ts +0 -229
  56. package/dist/cli/commands/auth.d.ts +0 -2
  57. package/dist/cli/config-manager.test.d.ts +0 -1
  58. package/dist/google-auth.d.ts +0 -3
  59. package/dist/google-auth.js +0 -3871
@@ -1,137 +0,0 @@
1
- /**
2
- * Antigravity Response Handler
3
- * Transforms Antigravity/Gemini API responses to OpenAI-compatible format
4
- *
5
- * Key responsibilities:
6
- * - Non-streaming response transformation
7
- * - SSE streaming response transformation (buffered - see transformStreamingResponse)
8
- * - Error response handling with retry-after extraction
9
- * - Usage metadata extraction from x-antigravity-* headers
10
- */
11
- import type { AntigravityError, AntigravityUsage } from "./types";
12
- /**
13
- * Usage metadata extracted from Antigravity response headers
14
- */
15
- export interface AntigravityUsageMetadata {
16
- cachedContentTokenCount?: number;
17
- totalTokenCount?: number;
18
- promptTokenCount?: number;
19
- candidatesTokenCount?: number;
20
- }
21
- /**
22
- * Transform result with response and metadata
23
- */
24
- export interface TransformResult {
25
- response: Response;
26
- usage?: AntigravityUsageMetadata;
27
- retryAfterMs?: number;
28
- error?: AntigravityError;
29
- }
30
- /**
31
- * Extract usage metadata from Antigravity response headers
32
- *
33
- * Antigravity sets these headers:
34
- * - x-antigravity-cached-content-token-count
35
- * - x-antigravity-total-token-count
36
- * - x-antigravity-prompt-token-count
37
- * - x-antigravity-candidates-token-count
38
- *
39
- * @param headers - Response headers
40
- * @returns Usage metadata if found
41
- */
42
- export declare function extractUsageFromHeaders(headers: Headers): AntigravityUsageMetadata | undefined;
43
- /**
44
- * Extract retry-after value from error response
45
- *
46
- * Antigravity returns retry info in error.details array:
47
- * {
48
- * error: {
49
- * details: [{
50
- * "@type": "type.googleapis.com/google.rpc.RetryInfo",
51
- * "retryDelay": "5.123s"
52
- * }]
53
- * }
54
- * }
55
- *
56
- * Also checks standard Retry-After header.
57
- *
58
- * @param response - Response object (for headers)
59
- * @param errorBody - Parsed error body (optional)
60
- * @returns Retry after value in milliseconds, or undefined
61
- */
62
- export declare function extractRetryAfterMs(response: Response, errorBody?: Record<string, unknown>): number | undefined;
63
- /**
64
- * Parse error response body and extract useful details
65
- *
66
- * @param text - Raw response text
67
- * @returns Parsed error or undefined
68
- */
69
- export declare function parseErrorBody(text: string): AntigravityError | undefined;
70
- /**
71
- * Transform a non-streaming Antigravity response to OpenAI-compatible format
72
- *
73
- * For non-streaming responses:
74
- * - Parses the response body
75
- * - Unwraps the `response` field if present (Antigravity wraps responses)
76
- * - Extracts usage metadata from headers
77
- * - Handles error responses
78
- *
79
- * Note: Does NOT handle thinking block extraction (Task 10)
80
- * Note: Does NOT handle tool normalization (Task 9)
81
- *
82
- * @param response - Fetch Response object
83
- * @returns TransformResult with transformed response and metadata
84
- */
85
- export declare function transformResponse(response: Response): Promise<TransformResult>;
86
- /**
87
- * Transform SSE streaming payload
88
- *
89
- * Processes each line in the SSE stream:
90
- * - Unwraps { response: { ... } } wrapper from data lines
91
- * - Preserves other SSE control lines (event:, id:, retry:, empty lines)
92
- *
93
- * Note: Does NOT extract thinking blocks (Task 10)
94
- *
95
- * @param payload - Raw SSE payload text
96
- * @returns Transformed SSE payload
97
- */
98
- export declare function transformStreamingPayload(payload: string): string;
99
- /**
100
- * Transforms a streaming SSE response from Antigravity to OpenAI format.
101
- *
102
- * Uses TransformStream to process SSE chunks incrementally as they arrive.
103
- * Each line is transformed immediately and yielded to the client.
104
- *
105
- * @param response - The SSE response from Antigravity API
106
- * @returns TransformResult with transformed streaming response
107
- */
108
- export declare function transformStreamingResponse(response: Response): Promise<TransformResult>;
109
- /**
110
- * Check if response is a streaming SSE response
111
- *
112
- * @param response - Fetch Response object
113
- * @returns True if response is SSE stream
114
- */
115
- export declare function isStreamingResponse(response: Response): boolean;
116
- /**
117
- * Extract thought signature from SSE payload text
118
- *
119
- * Looks for thoughtSignature in SSE events:
120
- * data: { "response": { "candidates": [{ "content": { "parts": [{ "thoughtSignature": "..." }] } }] } }
121
- *
122
- * Returns the last found signature (most recent in the stream).
123
- *
124
- * @param payload - SSE payload text
125
- * @returns Last thought signature if found
126
- */
127
- export declare function extractSignatureFromSsePayload(payload: string): string | undefined;
128
- /**
129
- * Extract usage from SSE payload text
130
- *
131
- * Looks for usageMetadata in SSE events:
132
- * data: { "usageMetadata": { ... } }
133
- *
134
- * @param payload - SSE payload text
135
- * @returns Usage if found
136
- */
137
- export declare function extractUsageFromSsePayload(payload: string): AntigravityUsage | undefined;
@@ -1,5 +0,0 @@
1
- import type { AccountStorage } from "./types";
2
- export declare function getDataDir(): string;
3
- export declare function getStoragePath(): string;
4
- export declare function loadAccounts(path?: string): Promise<AccountStorage | null>;
5
- export declare function saveAccounts(storage: AccountStorage, path?: string): Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,278 +0,0 @@
1
- /**
2
- * Antigravity Thinking Block Handler (Gemini only)
3
- *
4
- * Handles extraction and transformation of thinking/reasoning blocks
5
- * from Gemini responses. Thinking blocks contain the model's internal
6
- * reasoning process, available in `-high` model variants.
7
- *
8
- * Key responsibilities:
9
- * - Extract thinking blocks from Gemini response format
10
- * - Detect thinking-capable model variants (`-high` suffix)
11
- * - Format thinking blocks for OpenAI-compatible output
12
- *
13
- * Note: This is Gemini-only. Claude models are NOT handled by Antigravity.
14
- */
15
- import { type AntigravityModelConfig } from "./constants";
16
- /**
17
- * Represents a single thinking/reasoning block extracted from Gemini response
18
- */
19
- export interface ThinkingBlock {
20
- /** The thinking/reasoning text content */
21
- text: string;
22
- /** Optional signature for signed thinking blocks (required for multi-turn) */
23
- signature?: string;
24
- /** Index of the thinking block in sequence */
25
- index?: number;
26
- }
27
- /**
28
- * Raw part structure from Gemini response candidates
29
- */
30
- export interface GeminiPart {
31
- /** Text content of the part */
32
- text?: string;
33
- /** Whether this part is a thinking/reasoning block */
34
- thought?: boolean;
35
- /** Signature for signed thinking blocks */
36
- thoughtSignature?: string;
37
- /** Type field for Anthropic-style format */
38
- type?: string;
39
- /** Signature field for Anthropic-style format */
40
- signature?: string;
41
- }
42
- /**
43
- * Gemini response candidate structure
44
- */
45
- export interface GeminiCandidate {
46
- /** Content containing parts */
47
- content?: {
48
- /** Role of the content (e.g., "model", "assistant") */
49
- role?: string;
50
- /** Array of content parts */
51
- parts?: GeminiPart[];
52
- };
53
- /** Index of the candidate */
54
- index?: number;
55
- }
56
- /**
57
- * Gemini response structure for thinking block extraction
58
- */
59
- export interface GeminiResponse {
60
- /** Response ID */
61
- id?: string;
62
- /** Array of response candidates */
63
- candidates?: GeminiCandidate[];
64
- /** Direct content (some responses use this instead of candidates) */
65
- content?: Array<{
66
- type?: string;
67
- text?: string;
68
- signature?: string;
69
- }>;
70
- /** Model used for response */
71
- model?: string;
72
- }
73
- /**
74
- * Result of thinking block extraction
75
- */
76
- export interface ThinkingExtractionResult {
77
- /** Extracted thinking blocks */
78
- thinkingBlocks: ThinkingBlock[];
79
- /** Combined thinking text for convenience */
80
- combinedThinking: string;
81
- /** Whether any thinking blocks were found */
82
- hasThinking: boolean;
83
- }
84
- /**
85
- * Default thinking budget in tokens for thinking-enabled models
86
- */
87
- export declare const DEFAULT_THINKING_BUDGET = 16000;
88
- /**
89
- * Check if a model variant should include thinking blocks
90
- *
91
- * Returns true for model variants with `-high` suffix, which have
92
- * extended thinking capability enabled.
93
- *
94
- * Examples:
95
- * - `gemini-3-pro-high` → true
96
- * - `gemini-2.5-pro-high` → true
97
- * - `gemini-3-pro-preview` → false
98
- * - `gemini-2.5-pro` → false
99
- *
100
- * @param model - Model identifier string
101
- * @returns True if model should include thinking blocks
102
- */
103
- export declare function shouldIncludeThinking(model: string): boolean;
104
- /**
105
- * Check if a model is thinking-capable (broader check)
106
- *
107
- * This is a broader check than shouldIncludeThinking - it detects models
108
- * that have thinking capability, even if not explicitly requesting thinking output.
109
- *
110
- * @param model - Model identifier string
111
- * @returns True if model supports thinking/reasoning
112
- */
113
- export declare function isThinkingCapableModel(model: string): boolean;
114
- /**
115
- * Extract thinking blocks from a Gemini response
116
- *
117
- * Parses the response structure to identify and extract all thinking/reasoning
118
- * content. Supports both Gemini-style (thought: true) and Anthropic-style
119
- * (type: "thinking") formats.
120
- *
121
- * @param response - Gemini response object
122
- * @returns Extraction result with thinking blocks and metadata
123
- */
124
- export declare function extractThinkingBlocks(response: GeminiResponse): ThinkingExtractionResult;
125
- /**
126
- * Format thinking blocks for OpenAI-compatible output
127
- *
128
- * Converts Gemini thinking block format to OpenAI's expected structure.
129
- * OpenAI expects thinking content as special message blocks or annotations.
130
- *
131
- * Output format:
132
- * ```
133
- * [
134
- * { type: "reasoning", text: "thinking content...", signature?: "..." },
135
- * ...
136
- * ]
137
- * ```
138
- *
139
- * @param thinking - Array of thinking blocks to format
140
- * @returns OpenAI-compatible formatted array
141
- */
142
- export declare function formatThinkingForOpenAI(thinking: ThinkingBlock[]): Array<{
143
- type: "reasoning";
144
- text: string;
145
- signature?: string;
146
- }>;
147
- /**
148
- * Transform thinking parts in a candidate to OpenAI format
149
- *
150
- * Modifies candidate content parts to use OpenAI-style reasoning format
151
- * while preserving the rest of the response structure.
152
- *
153
- * @param candidate - Gemini candidate to transform
154
- * @returns Transformed candidate with reasoning-formatted thinking
155
- */
156
- export declare function transformCandidateThinking(candidate: GeminiCandidate): GeminiCandidate;
157
- /**
158
- * Transform Anthropic-style thinking blocks to reasoning format
159
- *
160
- * Converts `type: "thinking"` blocks to `type: "reasoning"` for consistency.
161
- *
162
- * @param content - Array of content blocks
163
- * @returns Transformed content array
164
- */
165
- export declare function transformAnthropicThinking(content: Array<{
166
- type?: string;
167
- text?: string;
168
- signature?: string;
169
- }>): Array<{
170
- type?: string;
171
- text?: string;
172
- signature?: string;
173
- }>;
174
- /**
175
- * Filter out unsigned thinking blocks
176
- *
177
- * Claude API requires signed thinking blocks for multi-turn conversations.
178
- * This function removes thinking blocks without valid signatures.
179
- *
180
- * @param parts - Array of content parts
181
- * @returns Filtered array without unsigned thinking blocks
182
- */
183
- export declare function filterUnsignedThinkingBlocks(parts: GeminiPart[]): GeminiPart[];
184
- /**
185
- * Transform entire response thinking parts
186
- *
187
- * Main transformation function that handles both Gemini-style and
188
- * Anthropic-style thinking blocks in a response.
189
- *
190
- * @param response - Response object to transform
191
- * @returns Transformed response with standardized reasoning format
192
- */
193
- export declare function transformResponseThinking(response: GeminiResponse): GeminiResponse;
194
- /**
195
- * Thinking configuration for requests
196
- */
197
- export interface ThinkingConfig {
198
- /** Token budget for thinking/reasoning */
199
- thinkingBudget?: number;
200
- /** Whether to include thoughts in response */
201
- includeThoughts?: boolean;
202
- }
203
- /**
204
- * Normalize thinking configuration
205
- *
206
- * Ensures thinkingConfig is valid: includeThoughts only allowed when budget > 0.
207
- *
208
- * @param config - Raw thinking configuration
209
- * @returns Normalized configuration or undefined
210
- */
211
- export declare function normalizeThinkingConfig(config: unknown): ThinkingConfig | undefined;
212
- /**
213
- * Extract thinking configuration from request payload
214
- *
215
- * Supports both Gemini-style thinkingConfig and Anthropic-style thinking options.
216
- * Also supports reasoning_effort parameter which maps to thinking budget/level.
217
- *
218
- * @param requestPayload - Request body
219
- * @param generationConfig - Generation config from request
220
- * @param extraBody - Extra body options
221
- * @returns Extracted thinking configuration or undefined
222
- */
223
- export declare function extractThinkingConfig(requestPayload: Record<string, unknown>, generationConfig?: Record<string, unknown>, extraBody?: Record<string, unknown>): ThinkingConfig | DeleteThinkingConfig | undefined;
224
- /**
225
- * Resolve final thinking configuration based on model and context
226
- *
227
- * Handles special cases like Claude models requiring signed thinking blocks
228
- * for multi-turn conversations.
229
- *
230
- * @param userConfig - User-provided thinking configuration
231
- * @param isThinkingModel - Whether model supports thinking
232
- * @param isClaudeModel - Whether model is Claude (not used in Antigravity, but kept for compatibility)
233
- * @param hasAssistantHistory - Whether conversation has assistant history
234
- * @returns Final thinking configuration
235
- */
236
- export declare function resolveThinkingConfig(userConfig: ThinkingConfig | undefined, isThinkingModel: boolean, isClaudeModel: boolean, hasAssistantHistory: boolean): ThinkingConfig | undefined;
237
- /**
238
- * Get thinking config for a model by normalized ID.
239
- * Uses pattern matching fallback if exact match not found.
240
- *
241
- * @param model - Model identifier string (with or without provider prefix)
242
- * @returns Thinking configuration or undefined if not found
243
- */
244
- export declare function getModelThinkingConfig(model: string): AntigravityModelConfig | undefined;
245
- /**
246
- * Type for the delete thinking config marker.
247
- * Used when reasoning_effort is "none" to signal complete removal.
248
- */
249
- export interface DeleteThinkingConfig {
250
- deleteThinkingConfig: true;
251
- }
252
- /**
253
- * Union type for thinking configuration input.
254
- */
255
- export type ThinkingConfigInput = ThinkingConfig | DeleteThinkingConfig;
256
- /**
257
- * Convert thinking budget to closest level string for Gemini 3 models.
258
- *
259
- * @param budget - Thinking budget in tokens
260
- * @param model - Model identifier
261
- * @returns Level string ("low", "high", etc.) or "medium" fallback
262
- */
263
- export declare function budgetToLevel(budget: number, model: string): string;
264
- /**
265
- * Apply thinking config to request body.
266
- *
267
- * CRITICAL: Sets request.generationConfig.thinkingConfig (NOT outer body!)
268
- *
269
- * Handles:
270
- * - Gemini 3: Sets thinkingLevel (string)
271
- * - Gemini 2.5: Sets thinkingBudget (number)
272
- * - Delete marker: Removes thinkingConfig entirely
273
- *
274
- * @param requestBody - Request body to modify (mutates in place)
275
- * @param model - Model identifier
276
- * @param config - Thinking configuration or delete marker
277
- */
278
- export declare function applyThinkingConfigToRequest(requestBody: Record<string, unknown>, model: string, config: ThinkingConfigInput): void;
@@ -1,10 +0,0 @@
1
- /**
2
- * Tests for reasoning_effort and Gemini 3 thinkingLevel support.
3
- *
4
- * Tests the following functions:
5
- * - getModelThinkingConfig()
6
- * - extractThinkingConfig() with reasoning_effort
7
- * - applyThinkingConfigToRequest()
8
- * - budgetToLevel()
9
- */
10
- export {};
@@ -1,52 +0,0 @@
1
- /**
2
- * Thought Signature Store
3
- *
4
- * Stores and retrieves thought signatures for multi-turn conversations.
5
- * Gemini 3 Pro requires thought_signature on function call content blocks
6
- * in subsequent requests to maintain reasoning continuity.
7
- *
8
- * Key responsibilities:
9
- * - Store the latest thought signature per session
10
- * - Provide signature for injection into function call requests
11
- * - Clear signatures when sessions end
12
- */
13
- /**
14
- * Store a thought signature for a session
15
- *
16
- * @param sessionKey - Unique session identifier (typically fetch instance ID)
17
- * @param signature - The thought signature from model response
18
- */
19
- export declare function setThoughtSignature(sessionKey: string, signature: string): void;
20
- /**
21
- * Retrieve the stored thought signature for a session
22
- *
23
- * @param sessionKey - Unique session identifier
24
- * @returns The stored signature or undefined if not found
25
- */
26
- export declare function getThoughtSignature(sessionKey: string): string | undefined;
27
- /**
28
- * Clear the thought signature for a session
29
- *
30
- * @param sessionKey - Unique session identifier
31
- */
32
- export declare function clearThoughtSignature(sessionKey: string): void;
33
- /**
34
- * Store or retrieve a persistent session ID for a fetch instance
35
- *
36
- * @param fetchInstanceId - Unique identifier for the fetch instance
37
- * @param sessionId - Optional session ID to store (if not provided, returns existing or generates new)
38
- * @returns The session ID for this fetch instance
39
- */
40
- export declare function getOrCreateSessionId(fetchInstanceId: string, sessionId?: string): string;
41
- /**
42
- * Clear the session ID for a fetch instance
43
- *
44
- * @param fetchInstanceId - Unique identifier for the fetch instance
45
- */
46
- export declare function clearSessionId(fetchInstanceId: string): void;
47
- /**
48
- * Clear all stored data for a fetch instance (signature + session ID)
49
- *
50
- * @param fetchInstanceId - Unique identifier for the fetch instance
51
- */
52
- export declare function clearFetchInstanceData(fetchInstanceId: string): void;
@@ -1,38 +0,0 @@
1
- import type { AntigravityRefreshParts, AntigravityTokenExchangeResult, AntigravityTokens } from "./types";
2
- export declare class AntigravityTokenRefreshError extends Error {
3
- code?: string;
4
- description?: string;
5
- status: number;
6
- statusText: string;
7
- responseBody?: string;
8
- constructor(options: {
9
- message: string;
10
- code?: string;
11
- description?: string;
12
- status: number;
13
- statusText: string;
14
- responseBody?: string;
15
- });
16
- get isInvalidGrant(): boolean;
17
- get isNetworkError(): boolean;
18
- }
19
- export declare function isTokenExpired(tokens: AntigravityTokens): boolean;
20
- export declare function refreshAccessToken(refreshToken: string, clientId?: string, clientSecret?: string): Promise<AntigravityTokenExchangeResult>;
21
- /**
22
- * Parse a stored token string into its component parts.
23
- * Storage format: `refreshToken|projectId|managedProjectId`
24
- *
25
- * @param stored - The pipe-separated stored token string
26
- * @returns Parsed refresh parts with refreshToken, projectId, and optional managedProjectId
27
- */
28
- export declare function parseStoredToken(stored: string): AntigravityRefreshParts;
29
- /**
30
- * Format token components for storage.
31
- * Creates a pipe-separated string: `refreshToken|projectId|managedProjectId`
32
- *
33
- * @param refreshToken - The refresh token
34
- * @param projectId - The GCP project ID
35
- * @param managedProjectId - Optional managed project ID for enterprise users
36
- * @returns Formatted string for storage
37
- */
38
- export declare function formatTokenForStorage(refreshToken: string, projectId: string, managedProjectId?: string): string;
@@ -1 +0,0 @@
1
- export {};
@@ -1,119 +0,0 @@
1
- /**
2
- * Antigravity Tool Normalization
3
- * Converts tools between OpenAI and Gemini formats.
4
- *
5
- * OpenAI format:
6
- * { "type": "function", "function": { "name": "x", "description": "...", "parameters": {...} } }
7
- *
8
- * Gemini format:
9
- * { "functionDeclarations": [{ "name": "x", "description": "...", "parameters": {...} }] }
10
- *
11
- * Note: This is for Gemini models ONLY. Claude models are not supported via Antigravity.
12
- */
13
- /**
14
- * OpenAI function tool format
15
- */
16
- export interface OpenAITool {
17
- type: string;
18
- function?: {
19
- name: string;
20
- description?: string;
21
- parameters?: Record<string, unknown>;
22
- };
23
- }
24
- /**
25
- * Gemini function declaration format
26
- */
27
- export interface GeminiFunctionDeclaration {
28
- name: string;
29
- description?: string;
30
- parameters?: Record<string, unknown>;
31
- }
32
- /**
33
- * Gemini tools format (array of functionDeclarations)
34
- */
35
- export interface GeminiTools {
36
- functionDeclarations: GeminiFunctionDeclaration[];
37
- }
38
- /**
39
- * OpenAI tool call in response
40
- */
41
- export interface OpenAIToolCall {
42
- id: string;
43
- type: "function";
44
- function: {
45
- name: string;
46
- arguments: string;
47
- };
48
- }
49
- /**
50
- * Gemini function call in response
51
- */
52
- export interface GeminiFunctionCall {
53
- name: string;
54
- args: Record<string, unknown>;
55
- }
56
- /**
57
- * Gemini function response format
58
- */
59
- export interface GeminiFunctionResponse {
60
- name: string;
61
- response: Record<string, unknown>;
62
- }
63
- /**
64
- * Gemini tool result containing function calls
65
- */
66
- export interface GeminiToolResult {
67
- functionCall?: GeminiFunctionCall;
68
- functionResponse?: GeminiFunctionResponse;
69
- }
70
- /**
71
- * Normalize OpenAI-format tools to Gemini format.
72
- * Converts an array of OpenAI tools to Gemini's functionDeclarations format.
73
- *
74
- * - Handles `function` type tools with name, description, parameters
75
- * - Logs warning for unsupported tool types (does NOT silently drop them)
76
- * - Creates a single object with functionDeclarations array
77
- *
78
- * @param tools - Array of OpenAI-format tools
79
- * @returns Gemini-format tools object with functionDeclarations, or undefined if no valid tools
80
- */
81
- export declare function normalizeToolsForGemini(tools: OpenAITool[]): GeminiTools | undefined;
82
- /**
83
- * Convert Gemini tool results (functionCall) back to OpenAI tool_call format.
84
- * Handles both functionCall (request) and functionResponse (result) formats.
85
- *
86
- * Gemini functionCall format:
87
- * { "name": "tool_name", "args": { ... } }
88
- *
89
- * OpenAI tool_call format:
90
- * { "id": "call_xxx", "type": "function", "function": { "name": "tool_name", "arguments": "..." } }
91
- *
92
- * @param results - Array of Gemini tool results containing functionCall or functionResponse
93
- * @returns Array of OpenAI-format tool calls
94
- */
95
- export declare function normalizeToolResultsFromGemini(results: GeminiToolResult[]): OpenAIToolCall[];
96
- /**
97
- * Convert a single Gemini functionCall to OpenAI tool_call format.
98
- * Useful for streaming responses where each chunk may contain a function call.
99
- *
100
- * @param functionCall - Gemini function call
101
- * @param id - Optional tool call ID (generates one if not provided)
102
- * @returns OpenAI-format tool call
103
- */
104
- export declare function convertFunctionCallToToolCall(functionCall: GeminiFunctionCall, id?: string): OpenAIToolCall;
105
- /**
106
- * Check if a tool array contains any function-type tools.
107
- *
108
- * @param tools - Array of OpenAI-format tools
109
- * @returns true if there are function tools to normalize
110
- */
111
- export declare function hasFunctionTools(tools: OpenAITool[]): boolean;
112
- /**
113
- * Extract function declarations from already-normalized Gemini tools.
114
- * Useful when tools may already be in Gemini format.
115
- *
116
- * @param tools - Tools that may be in Gemini or OpenAI format
117
- * @returns Array of function declarations
118
- */
119
- export declare function extractFunctionDeclarations(tools: unknown): GeminiFunctionDeclaration[];