antigravity-claude-proxy 1.2.14 → 1.2.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.
package/README.md CHANGED
@@ -230,6 +230,31 @@ claude
230
230
 
231
231
  > **Note:** If Claude Code asks you to select a login method, add `"hasCompletedOnboarding": true` to `~/.claude.json` (macOS/Linux) or `%USERPROFILE%\.claude.json` (Windows), then restart your terminal and try again.
232
232
 
233
+ ### Multiple Claude Code Instances (Optional)
234
+
235
+ To run both the official Claude Code and Antigravity version simultaneously, add this alias:
236
+
237
+ **macOS / Linux:**
238
+
239
+ ```bash
240
+ # Add to ~/.zshrc or ~/.bashrc
241
+ alias claude-antigravity='CLAUDE_CONFIG_DIR=~/.claude-account-antigravity ANTHROPIC_BASE_URL="http://localhost:8080" ANTHROPIC_AUTH_TOKEN="test" command claude'
242
+ ```
243
+
244
+ **Windows (PowerShell):**
245
+
246
+ ```powershell
247
+ # Add to $PROFILE
248
+ function claude-antigravity {
249
+ $env:CLAUDE_CONFIG_DIR = "$env:USERPROFILE\.claude-account-antigravity"
250
+ $env:ANTHROPIC_BASE_URL = "http://localhost:8080"
251
+ $env:ANTHROPIC_AUTH_TOKEN = "test"
252
+ claude
253
+ }
254
+ ```
255
+
256
+ Then run `claude` for official API or `claude-antigravity` for this proxy.
257
+
233
258
  ---
234
259
 
235
260
  ## Available Models
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antigravity-claude-proxy",
3
- "version": "1.2.14",
3
+ "version": "1.2.16",
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",
@@ -28,7 +28,8 @@
28
28
  "test:caching": "node tests/test-caching-streaming.cjs",
29
29
  "test:crossmodel": "node tests/test-cross-model-thinking.cjs",
30
30
  "test:oauth": "node tests/test-oauth-no-browser.cjs",
31
- "test:emptyretry": "node tests/test-empty-response-retry.cjs"
31
+ "test:emptyretry": "node tests/test-empty-response-retry.cjs",
32
+ "test:sanitizer": "node tests/test-schema-sanitizer.cjs"
32
33
  },
33
34
  "keywords": [
34
35
  "claude",
@@ -28,16 +28,20 @@ export function buildCloudCodeRequest(anthropicRequest, projectId) {
28
28
  // Use stable session ID derived from first user message for cache continuity
29
29
  googleRequest.sessionId = deriveSessionId(anthropicRequest);
30
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;
31
+ // Build system instruction parts array with [ignore] tags to prevent model from
32
+ // identifying as "Antigravity" (fixes GitHub issue #76)
33
+ // Reference: CLIProxyAPI, gcli2api, AIClient-2-API all use this approach
34
+ const systemParts = [
35
+ { text: ANTIGRAVITY_SYSTEM_INSTRUCTION },
36
+ { text: `Please ignore the following [ignore]${ANTIGRAVITY_SYSTEM_INSTRUCTION}[/ignore]` }
37
+ ];
38
+
39
+ // Append any existing system instructions from the request
34
40
  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
+ for (const part of googleRequest.systemInstruction.parts) {
42
+ if (part.text) {
43
+ systemParts.push({ text: part.text });
44
+ }
41
45
  }
42
46
  }
43
47
 
@@ -53,7 +57,7 @@ export function buildCloudCodeRequest(anthropicRequest, projectId) {
53
57
  // Inject systemInstruction with role: "user" at the top level (CLIProxyAPI v6.6.89 behavior)
54
58
  payload.request.systemInstruction = {
55
59
  role: 'user',
56
- parts: [{ text: systemInstructionText }]
60
+ parts: systemParts
57
61
  };
58
62
 
59
63
  return payload;
package/src/constants.js CHANGED
@@ -145,88 +145,10 @@ export const OAUTH_CONFIG = {
145
145
  };
146
146
  export const OAUTH_REDIRECT_URI = `http://localhost:${OAUTH_CONFIG.callbackPort}/oauth-callback`;
147
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>`;
148
+ // Minimal Antigravity system instruction (from CLIProxyAPI)
149
+ // Only includes the essential identity portion to reduce token usage and improve response quality
150
+ // Reference: GitHub issue #76, CLIProxyAPI, gcli2api
151
+ export const ANTIGRAVITY_SYSTEM_INSTRUCTION = `You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.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.**Absolute paths only****Proactiveness**`;
230
152
 
231
153
  // Model fallback mapping - maps primary model to fallback when quota exhausted
232
154
  export const MODEL_FALLBACK_MAP = {
@@ -9,7 +9,7 @@ import {
9
9
  isThinkingModel
10
10
  } from '../constants.js';
11
11
  import { convertContentToParts, convertRole } from './content-converter.js';
12
- import { sanitizeSchema, cleanSchemaForGemini } from './schema-sanitizer.js';
12
+ import { sanitizeSchema, cleanSchema } from './schema-sanitizer.js';
13
13
  import {
14
14
  restoreThinkingSignatures,
15
15
  removeTrailingThinkingBlocks,
@@ -210,10 +210,11 @@ export function convertAnthropicToGoogle(anthropicRequest) {
210
210
  // Sanitize schema for general compatibility
211
211
  let parameters = sanitizeSchema(schema);
212
212
 
213
- // For Gemini models, apply additional cleaning for VALIDATED mode
214
- if (isGeminiModel) {
215
- parameters = cleanSchemaForGemini(parameters);
216
- }
213
+ // Apply Google-format cleaning for ALL models since they all go through
214
+ // Cloud Code API which validates schemas using Google's protobuf format.
215
+ // This fixes issue #82: /compact command fails with schema transformation error
216
+ // "Proto field is not repeating, cannot start list" for Claude models.
217
+ parameters = cleanSchema(parameters);
217
218
 
218
219
  return {
219
220
  name: String(name).replace(/[^a-zA-Z0-9_-]/g, '_').slice(0, 64),
@@ -564,6 +564,27 @@ export function sanitizeSchema(schema) {
564
564
  return sanitized;
565
565
  }
566
566
 
567
+ /**
568
+ * Convert JSON Schema type names to Google's Protobuf-style uppercase type names.
569
+ * Google's Generative AI API expects uppercase types: STRING, OBJECT, ARRAY, etc.
570
+ *
571
+ * @param {string} type - JSON Schema type name (lowercase)
572
+ * @returns {string} Google-format type name (uppercase)
573
+ */
574
+ function toGoogleType(type) {
575
+ if (!type || typeof type !== 'string') return type;
576
+ const typeMap = {
577
+ 'string': 'STRING',
578
+ 'number': 'NUMBER',
579
+ 'integer': 'INTEGER',
580
+ 'boolean': 'BOOLEAN',
581
+ 'array': 'ARRAY',
582
+ 'object': 'OBJECT',
583
+ 'null': 'STRING' // Fallback for null type
584
+ };
585
+ return typeMap[type.toLowerCase()] || type.toUpperCase();
586
+ }
587
+
567
588
  /**
568
589
  * Cleans JSON schema for Gemini API compatibility.
569
590
  * Uses a multi-phase pipeline matching opencode-antigravity-auth approach.
@@ -571,9 +592,9 @@ export function sanitizeSchema(schema) {
571
592
  * @param {Object} schema - The JSON schema to clean
572
593
  * @returns {Object} Cleaned schema safe for Gemini API
573
594
  */
574
- export function cleanSchemaForGemini(schema) {
595
+ export function cleanSchema(schema) {
575
596
  if (!schema || typeof schema !== 'object') return schema;
576
- if (Array.isArray(schema)) return schema.map(cleanSchemaForGemini);
597
+ if (Array.isArray(schema)) return schema.map(cleanSchema);
577
598
 
578
599
  // Phase 1: Convert $refs to hints
579
600
  let result = convertRefsToHints(schema);
@@ -620,16 +641,16 @@ export function cleanSchemaForGemini(schema) {
620
641
  if (result.properties && typeof result.properties === 'object') {
621
642
  const newProps = {};
622
643
  for (const [key, value] of Object.entries(result.properties)) {
623
- newProps[key] = cleanSchemaForGemini(value);
644
+ newProps[key] = cleanSchema(value);
624
645
  }
625
646
  result.properties = newProps;
626
647
  }
627
648
 
628
649
  if (result.items) {
629
650
  if (Array.isArray(result.items)) {
630
- result.items = result.items.map(cleanSchemaForGemini);
651
+ result.items = result.items.map(cleanSchema);
631
652
  } else if (typeof result.items === 'object') {
632
- result.items = cleanSchemaForGemini(result.items);
653
+ result.items = cleanSchema(result.items);
633
654
  }
634
655
  }
635
656
 
@@ -642,5 +663,11 @@ export function cleanSchemaForGemini(schema) {
642
663
  }
643
664
  }
644
665
 
666
+ // Phase 5: Convert type to Google's uppercase format (STRING, OBJECT, ARRAY, etc.)
667
+ // Only convert at current level - nested types already converted by recursive cleanSchema calls
668
+ if (result.type && typeof result.type === 'string') {
669
+ result.type = toGoogleType(result.type);
670
+ }
671
+
645
672
  return result;
646
673
  }