antigravity-claude-proxy 1.2.10 → 1.2.12

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/README.md CHANGED
@@ -39,10 +39,10 @@ A proxy server that exposes an **Anthropic-compatible API** backed by **Antigrav
39
39
 
40
40
  ```bash
41
41
  # Run directly with npx (no install needed)
42
- npx antigravity-claude-proxy start
42
+ npx antigravity-claude-proxy@latest start
43
43
 
44
44
  # Or install globally
45
- npm install -g antigravity-claude-proxy
45
+ npm install -g antigravity-claude-proxy@latest
46
46
  antigravity-claude-proxy start
47
47
  ```
48
48
 
@@ -78,7 +78,7 @@ Add one or more Google accounts for load balancing.
78
78
  antigravity-claude-proxy accounts add
79
79
 
80
80
  # If using npx
81
- npx antigravity-claude-proxy accounts add
81
+ npx antigravity-claude-proxy@latest accounts add
82
82
 
83
83
  # If cloned locally
84
84
  npm run accounts:add
@@ -93,7 +93,7 @@ This opens your browser for Google OAuth. Sign in and authorize access. Repeat f
93
93
  antigravity-claude-proxy accounts add --no-browser
94
94
 
95
95
  # If using npx
96
- npx antigravity-claude-proxy accounts add -- --no-browser
96
+ npx antigravity-claude-proxy@latest accounts add -- --no-browser
97
97
 
98
98
  # If cloned locally
99
99
  npm run accounts:add -- --no-browser
@@ -121,7 +121,7 @@ antigravity-claude-proxy accounts
121
121
  antigravity-claude-proxy start
122
122
 
123
123
  # If using npx
124
- npx antigravity-claude-proxy start
124
+ npx antigravity-claude-proxy@latest start
125
125
 
126
126
  # If cloned locally
127
127
  npm start
@@ -161,12 +161,15 @@ Add this configuration:
161
161
  "ANTHROPIC_MODEL": "claude-opus-4-5-thinking",
162
162
  "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-5-thinking",
163
163
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-5-thinking",
164
- "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-sonnet-4-5",
165
- "CLAUDE_CODE_SUBAGENT_MODEL": "claude-sonnet-4-5-thinking"
164
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemini-2.5-flash-lite",
165
+ "CLAUDE_CODE_SUBAGENT_MODEL": "claude-sonnet-4-5-thinking",
166
+ "ENABLE_EXPERIMENTAL_MCP_CLI": "true"
166
167
  }
167
168
  }
168
169
  ```
169
170
 
171
+ (Please use **gemini-2.5-flash-lite** as the default haiku model, even if others are claude, as claude code makes several calls via the haiku model for background tasks. If you use claude model for it, you may use you claude usage sooner)
172
+
170
173
  Or to use Gemini models:
171
174
 
172
175
  ```json
@@ -178,7 +181,8 @@ Or to use Gemini models:
178
181
  "ANTHROPIC_DEFAULT_OPUS_MODEL": "gemini-3-pro-high",
179
182
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "gemini-3-flash",
180
183
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemini-2.5-flash-lite",
181
- "CLAUDE_CODE_SUBAGENT_MODEL": "gemini-3-flash"
184
+ "CLAUDE_CODE_SUBAGENT_MODEL": "gemini-3-flash",
185
+ "ENABLE_EXPERIMENTAL_MCP_CLI": "true"
182
186
  }
183
187
  }
184
188
  ```
@@ -191,7 +195,7 @@ Add the proxy settings to your shell profile:
191
195
 
192
196
  ```bash
193
197
  echo 'export ANTHROPIC_BASE_URL="http://localhost:8080"' >> ~/.zshrc
194
- echo 'export ANTHROPIC_API_KEY="test"' >> ~/.zshrc
198
+ echo 'export ANTHROPIC_AUTH_TOKEN="test"' >> ~/.zshrc
195
199
  source ~/.zshrc
196
200
  ```
197
201
 
@@ -201,7 +205,7 @@ source ~/.zshrc
201
205
 
202
206
  ```powershell
203
207
  Add-Content $PROFILE "`n`$env:ANTHROPIC_BASE_URL = 'http://localhost:8080'"
204
- Add-Content $PROFILE "`$env:ANTHROPIC_API_KEY = 'test'"
208
+ Add-Content $PROFILE "`$env:ANTHROPIC_AUTH_TOKEN = 'test'"
205
209
  . $PROFILE
206
210
  ```
207
211
 
@@ -209,7 +213,7 @@ Add-Content $PROFILE "`$env:ANTHROPIC_API_KEY = 'test'"
209
213
 
210
214
  ```cmd
211
215
  setx ANTHROPIC_BASE_URL "http://localhost:8080"
212
- setx ANTHROPIC_API_KEY "test"
216
+ setx ANTHROPIC_AUTH_TOKEN "test"
213
217
  ```
214
218
 
215
219
  Restart your terminal for changes to take effect.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antigravity-claude-proxy",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "description": "Proxy server to use Antigravity's Claude models with Claude Code CLI",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -27,7 +27,8 @@
27
27
  "test:images": "node tests/test-images.cjs",
28
28
  "test:caching": "node tests/test-caching-streaming.cjs",
29
29
  "test:crossmodel": "node tests/test-cross-model-thinking.cjs",
30
- "test:oauth": "node tests/test-oauth-no-browser.cjs"
30
+ "test:oauth": "node tests/test-oauth-no-browser.cjs",
31
+ "test:emptyretry": "node tests/test-empty-response-retry.cjs"
31
32
  },
32
33
  "keywords": [
33
34
  "claude",
@@ -7,6 +7,7 @@
7
7
  import crypto from 'crypto';
8
8
  import {
9
9
  ANTIGRAVITY_HEADERS,
10
+ ANTIGRAVITY_SYSTEM_INSTRUCTION,
10
11
  getModelFamily,
11
12
  isThinkingModel
12
13
  } from '../constants.js';
@@ -27,14 +28,34 @@ export function buildCloudCodeRequest(anthropicRequest, projectId) {
27
28
  // Use stable session ID derived from first user message for cache continuity
28
29
  googleRequest.sessionId = deriveSessionId(anthropicRequest);
29
30
 
31
+ // Build systemInstruction with role: "user" (CLIProxyAPI v6.6.89 compatibility)
32
+ // Prepend Antigravity identity to any existing system instructions
33
+ let systemInstructionText = ANTIGRAVITY_SYSTEM_INSTRUCTION;
34
+ if (googleRequest.systemInstruction && googleRequest.systemInstruction.parts) {
35
+ const existingText = googleRequest.systemInstruction.parts
36
+ .map(p => p.text || '')
37
+ .filter(t => t)
38
+ .join('\n');
39
+ if (existingText) {
40
+ systemInstructionText = ANTIGRAVITY_SYSTEM_INSTRUCTION + '\n\n' + existingText;
41
+ }
42
+ }
43
+
30
44
  const payload = {
31
45
  project: projectId,
32
46
  model: model,
33
47
  request: googleRequest,
34
48
  userAgent: 'antigravity',
49
+ requestType: 'agent', // CLIProxyAPI v6.6.89 compatibility
35
50
  requestId: 'agent-' + crypto.randomUUID()
36
51
  };
37
52
 
53
+ // Inject systemInstruction with role: "user" at the top level (CLIProxyAPI v6.6.89 behavior)
54
+ payload.request.systemInstruction = {
55
+ role: 'user',
56
+ parts: [{ text: systemInstructionText }]
57
+ };
58
+
38
59
  return payload;
39
60
  }
40
61
 
@@ -7,6 +7,7 @@
7
7
 
8
8
  import crypto from 'crypto';
9
9
  import { MIN_SIGNATURE_LENGTH, getModelFamily } from '../constants.js';
10
+ import { EmptyResponseError } from '../errors.js';
10
11
  import { cacheSignature, cacheThinkingSignature } from '../format/signature-cache.js';
11
12
  import { logger } from '../utils/logger.js';
12
13
 
@@ -226,39 +227,10 @@ export async function* streamSSEResponse(response, originalModel) {
226
227
  }
227
228
  }
228
229
 
229
- // Handle no content received
230
+ // Handle no content received - throw error to trigger retry in streaming-handler
230
231
  if (!hasEmittedStart) {
231
- logger.warn('[CloudCode] No content parts received, emitting empty message');
232
- yield {
233
- type: 'message_start',
234
- message: {
235
- id: messageId,
236
- type: 'message',
237
- role: 'assistant',
238
- content: [],
239
- model: originalModel,
240
- stop_reason: null,
241
- stop_sequence: null,
242
- usage: {
243
- input_tokens: inputTokens - cacheReadTokens,
244
- output_tokens: 0,
245
- cache_read_input_tokens: cacheReadTokens,
246
- cache_creation_input_tokens: 0
247
- }
248
- }
249
- };
250
-
251
- yield {
252
- type: 'content_block_start',
253
- index: 0,
254
- content_block: { type: 'text', text: '' }
255
- };
256
- yield {
257
- type: 'content_block_delta',
258
- index: 0,
259
- delta: { type: 'text_delta', text: '[No response received from API]' }
260
- };
261
- yield { type: 'content_block_stop', index: 0 };
232
+ logger.warn('[CloudCode] No content parts received, throwing for retry');
233
+ throw new EmptyResponseError('No content parts received from API');
262
234
  } else {
263
235
  // Close any open block
264
236
  if (currentBlockType !== null) {
@@ -8,16 +8,17 @@
8
8
  import {
9
9
  ANTIGRAVITY_ENDPOINT_FALLBACKS,
10
10
  MAX_RETRIES,
11
+ MAX_EMPTY_RESPONSE_RETRIES,
11
12
  MAX_WAIT_BEFORE_ERROR_MS
12
13
  } from '../constants.js';
13
- import { isRateLimitError, isAuthError } from '../errors.js';
14
+ import { isRateLimitError, isAuthError, isEmptyResponseError } from '../errors.js';
14
15
  import { formatDuration, sleep, isNetworkError } from '../utils/helpers.js';
15
16
  import { logger } from '../utils/logger.js';
16
17
  import { parseResetTime } from './rate-limit-parser.js';
17
18
  import { buildCloudCodeRequest, buildHeaders } from './request-builder.js';
18
19
  import { streamSSEResponse } from './sse-streamer.js';
19
20
  import { getFallbackModel } from '../fallback-config.js';
20
-
21
+ import crypto from 'crypto';
21
22
 
22
23
  /**
23
24
  * Send a streaming request to Cloud Code with multi-account support
@@ -143,16 +144,90 @@ export async function* sendMessageStream(anthropicRequest, accountManager, fallb
143
144
  continue;
144
145
  }
145
146
 
146
- // Stream the response - yield events as they arrive
147
- yield* streamSSEResponse(response, anthropicRequest.model);
147
+ // Stream the response with retry logic for empty responses
148
+ // Uses a for-loop for clearer retry semantics
149
+ let currentResponse = response;
150
+
151
+ for (let emptyRetries = 0; emptyRetries <= MAX_EMPTY_RESPONSE_RETRIES; emptyRetries++) {
152
+ try {
153
+ yield* streamSSEResponse(currentResponse, anthropicRequest.model);
154
+ logger.debug('[CloudCode] Stream completed');
155
+ return;
156
+ } catch (streamError) {
157
+ // Only retry on EmptyResponseError
158
+ if (!isEmptyResponseError(streamError)) {
159
+ throw streamError;
160
+ }
161
+
162
+ // Check if we have retries left
163
+ if (emptyRetries >= MAX_EMPTY_RESPONSE_RETRIES) {
164
+ logger.error(`[CloudCode] Empty response after ${MAX_EMPTY_RESPONSE_RETRIES} retries`);
165
+ yield* emitEmptyResponseFallback(anthropicRequest.model);
166
+ return;
167
+ }
168
+
169
+ // Exponential backoff: 500ms, 1000ms, 2000ms
170
+ const backoffMs = 500 * Math.pow(2, emptyRetries);
171
+ logger.warn(`[CloudCode] Empty response, retry ${emptyRetries + 1}/${MAX_EMPTY_RESPONSE_RETRIES} after ${backoffMs}ms...`);
172
+ await sleep(backoffMs);
173
+
174
+ // Refetch the response
175
+ currentResponse = await fetch(url, {
176
+ method: 'POST',
177
+ headers: buildHeaders(token, model, 'text/event-stream'),
178
+ body: JSON.stringify(payload)
179
+ });
148
180
 
149
- logger.debug('[CloudCode] Stream completed');
150
- return;
181
+ // Handle specific error codes on retry
182
+ if (!currentResponse.ok) {
183
+ const retryErrorText = await currentResponse.text();
184
+
185
+ // Rate limit error - mark account and throw to trigger account switch
186
+ if (currentResponse.status === 429) {
187
+ const resetMs = parseResetTime(currentResponse, retryErrorText);
188
+ accountManager.markRateLimited(account.email, resetMs, model);
189
+ throw new Error(`429 RESOURCE_EXHAUSTED during retry: ${retryErrorText}`);
190
+ }
191
+
192
+ // Auth error - clear caches and throw with recognizable message
193
+ if (currentResponse.status === 401) {
194
+ accountManager.clearTokenCache(account.email);
195
+ accountManager.clearProjectCache(account.email);
196
+ throw new Error(`401 AUTH_INVALID during retry: ${retryErrorText}`);
197
+ }
198
+
199
+ // For 5xx errors, don't pass to streamer - just continue to next retry
200
+ if (currentResponse.status >= 500) {
201
+ logger.warn(`[CloudCode] Retry got ${currentResponse.status}, will retry...`);
202
+ // Don't continue here - let the loop increment and refetch
203
+ // Set currentResponse to null to force refetch at loop start
204
+ emptyRetries--; // Compensate for loop increment since we didn't actually try
205
+ await sleep(1000);
206
+ // Refetch immediately for 5xx
207
+ currentResponse = await fetch(url, {
208
+ method: 'POST',
209
+ headers: buildHeaders(token, model, 'text/event-stream'),
210
+ body: JSON.stringify(payload)
211
+ });
212
+ if (currentResponse.ok) {
213
+ continue; // Try streaming with new response
214
+ }
215
+ // If still failing, let it fall through to throw
216
+ }
217
+
218
+ throw new Error(`Empty response retry failed: ${currentResponse.status} - ${retryErrorText}`);
219
+ }
220
+ // Response is OK, loop will continue to try streamSSEResponse
221
+ }
222
+ }
151
223
 
152
224
  } catch (endpointError) {
153
225
  if (isRateLimitError(endpointError)) {
154
226
  throw endpointError; // Re-throw to trigger account switch
155
227
  }
228
+ if (isEmptyResponseError(endpointError)) {
229
+ throw endpointError; // Re-throw empty response errors to outer handler
230
+ }
156
231
  logger.warn(`[CloudCode] Stream error at ${endpoint}:`, endpointError.message);
157
232
  lastError = endpointError;
158
233
  }
@@ -201,3 +276,49 @@ export async function* sendMessageStream(anthropicRequest, accountManager, fallb
201
276
 
202
277
  throw new Error('Max retries exceeded');
203
278
  }
279
+
280
+ /**
281
+ * Emit a fallback message when all retry attempts fail with empty response
282
+ * @param {string} model - The model name
283
+ * @yields {Object} Anthropic-format SSE events for empty response fallback
284
+ */
285
+ function* emitEmptyResponseFallback(model) {
286
+ // Use proper message ID format consistent with Anthropic API
287
+ const messageId = `msg_${crypto.randomBytes(16).toString('hex')}`;
288
+
289
+ yield {
290
+ type: 'message_start',
291
+ message: {
292
+ id: messageId,
293
+ type: 'message',
294
+ role: 'assistant',
295
+ content: [],
296
+ model: model,
297
+ stop_reason: null,
298
+ stop_sequence: null,
299
+ usage: { input_tokens: 0, output_tokens: 0 }
300
+ }
301
+ };
302
+
303
+ yield {
304
+ type: 'content_block_start',
305
+ index: 0,
306
+ content_block: { type: 'text', text: '' }
307
+ };
308
+
309
+ yield {
310
+ type: 'content_block_delta',
311
+ index: 0,
312
+ delta: { type: 'text_delta', text: '[No response after retries - please try again]' }
313
+ };
314
+
315
+ yield { type: 'content_block_stop', index: 0 };
316
+
317
+ yield {
318
+ type: 'message_delta',
319
+ delta: { stop_reason: 'end_turn', stop_sequence: null },
320
+ usage: { output_tokens: 0 }
321
+ };
322
+
323
+ yield { type: 'message_stop' };
324
+ }
package/src/constants.js CHANGED
@@ -76,6 +76,7 @@ export const ANTIGRAVITY_DB_PATH = getAntigravityDbPath();
76
76
 
77
77
  export const DEFAULT_COOLDOWN_MS = 10 * 1000; // 10 second default cooldown
78
78
  export const MAX_RETRIES = 5; // Max retry attempts across accounts
79
+ export const MAX_EMPTY_RESPONSE_RETRIES = 2; // Max retries for empty API responses
79
80
  export const MAX_ACCOUNTS = 10; // Maximum number of accounts allowed
80
81
 
81
82
  // Rate limit wait thresholds
@@ -144,6 +145,89 @@ export const OAUTH_CONFIG = {
144
145
  };
145
146
  export const OAUTH_REDIRECT_URI = `http://localhost:${OAUTH_CONFIG.callbackPort}/oauth-callback`;
146
147
 
148
+ // Antigravity system instruction (from CLIProxyAPI v6.6.89)
149
+ // Required for compatibility with latest Antigravity API changes
150
+ export const ANTIGRAVITY_SYSTEM_INSTRUCTION = `<identity>
151
+ You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.
152
+ You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.
153
+ The USER will send you requests, which you must always prioritize addressing. Along with each USER request, we will attach additional metadata about their current state, such as what files they have open and where their cursor is.
154
+ This information may or may not be relevant to the coding task, it is up for you to decide.
155
+ </identity>
156
+
157
+ <tool_calling>
158
+ Call tools as you normally would. The following list provides additional guidance to help you avoid errors:
159
+ - **Absolute paths only**. When using tools that accept file path arguments, ALWAYS use the absolute file path.
160
+ </tool_calling>
161
+
162
+ <web_application_development>
163
+ ## Technology Stack,
164
+ Your web applications should be built using the following technologies:,
165
+ 1. **Core**: Use HTML for structure and Javascript for logic.
166
+ 2. **Styling (CSS)**: Use Vanilla CSS for maximum flexibility and control. Avoid using TailwindCSS unless the USER explicitly requests it; in this case, first confirm which TailwindCSS version to use.
167
+ 3. **Web App**: If the USER specifies that they want a more complex web app, use a framework like Next.js or Vite. Only do this if the USER explicitly requests a web app.
168
+ 4. **New Project Creation**: If you need to use a framework for a new app, use \`npx\` with the appropriate script, but there are some rules to follow:,
169
+ - Use \`npx -y\` to automatically install the script and its dependencies
170
+ - You MUST run the command with \`--help\` flag to see all available options first,
171
+ - Initialize the app in the current directory with \`./\` (example: \`npx -y create-vite-app@latest ./\`),
172
+ - You should run in non-interactive mode so that the user doesn't need to input anything,
173
+ 5. **Running Locally**: When running locally, use \`npm run dev\` or equivalent dev server. Only build the production bundle if the USER explicitly requests it or you are validating the code for correctness.
174
+
175
+ # Design Aesthetics,
176
+ 1. **Use Rich Aesthetics**: The USER should be wowed at first glance by the design. Use best practices in modern web design (e.g. vibrant colors, dark modes, glassmorphism, and dynamic animations) to create a stunning first impression. Failure to do this is UNACCEPTABLE.
177
+ 2. **Prioritize Visual Excellence**: Implement designs that will WOW the user and feel extremely premium:
178
+ - Avoid generic colors (plain red, blue, green). Use curated, harmonious color palettes (e.g., HSL tailored colors, sleek dark modes).
179
+ - Using modern typography (e.g., from Google Fonts like Inter, Roboto, or Outfit) instead of browser defaults.
180
+ - Use smooth gradients,
181
+ - Add subtle micro-animations for enhanced user experience,
182
+ 3. **Use a Dynamic Design**: An interface that feels responsive and alive encourages interaction. Achieve this with hover effects and interactive elements. Micro-animations, in particular, are highly effective for improving user engagement.
183
+ 4. **Premium Designs**. Make a design that feels premium and state of the art. Avoid creating simple minimum viable products.
184
+ 4. **Don't use placeholders**. If you need an image, use your generate_image tool to create a working demonstration.,
185
+
186
+ ## Implementation Workflow,
187
+ Follow this systematic approach when building web applications:,
188
+ 1. **Plan and Understand**:,
189
+ - Fully understand the user's requirements,
190
+ - Draw inspiration from modern, beautiful, and dynamic web designs,
191
+ - Outline the features needed for the initial version,
192
+ 2. **Build the Foundation**:,
193
+ - Start by creating/modifying \`index.css\`,
194
+ - Implement the core design system with all tokens and utilities,
195
+ 3. **Create Components**:,
196
+ - Build necessary components using your design system,
197
+ - Ensure all components use predefined styles, not ad-hoc utilities,
198
+ - Keep components focused and reusable,
199
+ 4. **Assemble Pages**:,
200
+ - Update the main application to incorporate your design and components,
201
+ - Ensure proper routing and navigation,
202
+ - Implement responsive layouts,
203
+ 5. **Polish and Optimize**:,
204
+ - Review the overall user experience,
205
+ - Ensure smooth interactions and transitions,
206
+ - Optimize performance where needed,
207
+
208
+ ## SEO Best Practices,
209
+ Automatically implement SEO best practices on every page:,
210
+ - **Title Tags**: Include proper, descriptive title tags for each page,
211
+ - **Meta Descriptions**: Add compelling meta descriptions that accurately summarize page content,
212
+ - **Heading Structure**: Use a single \`<h1>\` per page with proper heading hierarchy,
213
+ - **Semantic HTML**: Use appropriate HTML5 semantic elements,
214
+ - **Unique IDs**: Ensure all interactive elements have unique, descriptive IDs for browser testing,
215
+ - **Performance**: Ensure fast page load times through optimization,
216
+ CRITICAL REMINDER: AESTHETICS ARE VERY IMPORTANT. If your web app looks simple and basic then you have FAILED!
217
+ </web_application_development>
218
+ <ephemeral_message>
219
+ There will be an <EPHEMERAL_MESSAGE> appearing in the conversation at times. This is not coming from the user, but instead injected by the system as important information to pay attention to.
220
+ Do not respond to nor acknowledge those messages, but do follow them strictly.
221
+ </ephemeral_message>
222
+
223
+
224
+ <communication_style>
225
+ - **Formatting**. Format your responses in github-style markdown to make your responses easier for the USER to parse. For example, use headers to organize your responses and bolded or italicized text to highlight important keywords. Use backticks to format file, directory, function, and class names. If providing a URL to the user, format this in markdown as well, for example \`[label](example.com)\`.
226
+ - **Proactiveness**. As an agent, you are allowed to be proactive, but only in the course of completing the user's task. For example, if the user asks you to add a new component, you can edit the code, verify build and test statuses, and take any other obvious follow-up actions, such as performing additional research. However, avoid surprising the user. For example, if the user asks HOW to approach something, you should answer their question and instead of jumping into editing a file.
227
+ - **Helpfulness**. Respond like a helpful software engineer who is explaining your work to a friendly collaborator on the project. Acknowledge mistakes or any backtracking you do as a result of new information.
228
+ - **Ask for clarification**. If you are unsure about the USER's intent, always ask for clarification rather than making assumptions.
229
+ </communication_style>`;
230
+
147
231
  // Model fallback mapping - maps primary model to fallback when quota exhausted
148
232
  export const MODEL_FALLBACK_MAP = {
149
233
  'gemini-3-pro-high': 'claude-opus-4-5-thinking',
@@ -166,6 +250,7 @@ export default {
166
250
  ANTIGRAVITY_DB_PATH,
167
251
  DEFAULT_COOLDOWN_MS,
168
252
  MAX_RETRIES,
253
+ MAX_EMPTY_RESPONSE_RETRIES,
169
254
  MAX_ACCOUNTS,
170
255
  MAX_WAIT_BEFORE_ERROR_MS,
171
256
  MIN_SIGNATURE_LENGTH,
@@ -176,5 +261,6 @@ export default {
176
261
  isThinkingModel,
177
262
  OAUTH_CONFIG,
178
263
  OAUTH_REDIRECT_URI,
179
- MODEL_FALLBACK_MAP
264
+ MODEL_FALLBACK_MAP,
265
+ ANTIGRAVITY_SYSTEM_INSTRUCTION
180
266
  };
package/src/errors.js CHANGED
@@ -135,6 +135,20 @@ export class NativeModuleError extends AntigravityError {
135
135
  }
136
136
  }
137
137
 
138
+ /**
139
+ * Empty response error - thrown when API returns no content
140
+ * Used to trigger retry logic in streaming handler
141
+ */
142
+ export class EmptyResponseError extends AntigravityError {
143
+ /**
144
+ * @param {string} message - Error message
145
+ */
146
+ constructor(message = 'No content received from API') {
147
+ super(message, 'EMPTY_RESPONSE', true, {});
148
+ this.name = 'EmptyResponseError';
149
+ }
150
+ }
151
+
138
152
  /**
139
153
  * Check if an error is a rate limit error
140
154
  * Works with both custom error classes and legacy string-based errors
@@ -164,6 +178,16 @@ export function isAuthError(error) {
164
178
  msg.includes('TOKEN REFRESH FAILED');
165
179
  }
166
180
 
181
+ /**
182
+ * Check if an error is an empty response error
183
+ * @param {Error} error - Error to check
184
+ * @returns {boolean}
185
+ */
186
+ export function isEmptyResponseError(error) {
187
+ return error instanceof EmptyResponseError ||
188
+ error?.name === 'EmptyResponseError';
189
+ }
190
+
167
191
  export default {
168
192
  AntigravityError,
169
193
  RateLimitError,
@@ -172,6 +196,8 @@ export default {
172
196
  MaxRetriesError,
173
197
  ApiError,
174
198
  NativeModuleError,
199
+ EmptyResponseError,
175
200
  isRateLimitError,
176
- isAuthError
201
+ isAuthError,
202
+ isEmptyResponseError
177
203
  };