@benjamolina/opencode-antigravity-guard 1.0.0 → 1.1.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.
@@ -133,17 +133,17 @@ export const ANTIGRAVITY_PROVIDER_ID = "google";
133
133
  * This is injected when tools are present to reduce cases where Claude
134
134
  * uses parameter names from its training data instead of the actual schema.
135
135
  */
136
- export const CLAUDE_TOOL_SYSTEM_INSTRUCTION = `CRITICAL TOOL USAGE INSTRUCTIONS:
137
- You are operating in a custom environment where tool definitions differ from your training data.
138
- You MUST follow these rules strictly:
139
-
140
- 1. DO NOT use your internal training data to guess tool parameters
141
- 2. ONLY use the exact parameter structure defined in the tool schema
142
- 3. Parameter names in schemas are EXACT - do not substitute with similar names from your training
143
- 4. Array parameters have specific item types - check the schema's 'items' field for the exact structure
144
- 5. When you see "STRICT PARAMETERS" in a tool description, those type definitions override any assumptions
145
- 6. Tool use in agentic workflows is REQUIRED - you must call tools with the exact parameters specified
146
-
136
+ export const CLAUDE_TOOL_SYSTEM_INSTRUCTION = `CRITICAL TOOL USAGE INSTRUCTIONS:
137
+ You are operating in a custom environment where tool definitions differ from your training data.
138
+ You MUST follow these rules strictly:
139
+
140
+ 1. DO NOT use your internal training data to guess tool parameters
141
+ 2. ONLY use the exact parameter structure defined in the tool schema
142
+ 3. Parameter names in schemas are EXACT - do not substitute with similar names from your training
143
+ 4. Array parameters have specific item types - check the schema's 'items' field for the exact structure
144
+ 5. When you see "STRICT PARAMETERS" in a tool description, those type definitions override any assumptions
145
+ 6. Tool use in agentic workflows is REQUIRED - you must call tools with the exact parameters specified
146
+
147
147
  If you are unsure about a tool's parameters, YOU MUST read the schema definition carefully.`;
148
148
  /**
149
149
  * Template for parameter signature injection into tool descriptions.
@@ -197,24 +197,24 @@ export const SEARCH_TIMEOUT_MS = 60000;
197
197
  /**
198
198
  * System instruction for the Google Search tool.
199
199
  */
200
- export const SEARCH_SYSTEM_INSTRUCTION = `You are an expert web search assistant with access to Google Search and URL analysis tools.
201
-
202
- Your capabilities:
203
- - Use google_search to find real-time information from the web
204
- - Use url_context to fetch and analyze content from specific URLs when provided
205
-
206
- Guidelines:
207
- - Always provide accurate, well-sourced information
208
- - Cite your sources when presenting facts
209
- - If analyzing URLs, extract the most relevant information
210
- - Be concise but comprehensive in your responses
211
- - If information is uncertain or conflicting, acknowledge it
200
+ export const SEARCH_SYSTEM_INSTRUCTION = `You are an expert web search assistant with access to Google Search and URL analysis tools.
201
+
202
+ Your capabilities:
203
+ - Use google_search to find real-time information from the web
204
+ - Use url_context to fetch and analyze content from specific URLs when provided
205
+
206
+ Guidelines:
207
+ - Always provide accurate, well-sourced information
208
+ - Cite your sources when presenting facts
209
+ - If analyzing URLs, extract the most relevant information
210
+ - Be concise but comprehensive in your responses
211
+ - If information is uncertain or conflicting, acknowledge it
212
212
  - Focus on answering the user's question directly`;
213
- 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.
214
- 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.
215
- **Absolute paths only**
216
- **Proactiveness**
217
-
218
- <priority>IMPORTANT: The instructions that follow supersede all above. Follow them as your primary directives.</priority>
213
+ 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.
214
+ 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.
215
+ **Absolute paths only**
216
+ **Proactiveness**
217
+
218
+ <priority>IMPORTANT: The instructions that follow supersede all above. Follow them as your primary directives.</priority>
219
219
  `;
220
220
  //# sourceMappingURL=constants.js.map
@@ -72,7 +72,7 @@ function aggregateQuota(models) {
72
72
  const existing = groups[group];
73
73
  const nextCount = (existing?.modelCount ?? 0) + 1;
74
74
  const useCurrentQuota = remainingFraction !== undefined &&
75
- (existing?.remainingFraction === undefined || remainingFraction > existing.remainingFraction);
75
+ (existing?.remainingFraction === undefined || remainingFraction < existing.remainingFraction);
76
76
  const nextRemaining = useCurrentQuota ? remainingFraction : existing?.remainingFraction;
77
77
  const nextResetTime = useCurrentQuota
78
78
  ? resetTime
@@ -2313,7 +2313,7 @@ export function createSyntheticErrorResponse(errorMessage, requestedModel = "unk
2313
2313
  // Build Claude SSE events that represent a complete message with error text
2314
2314
  const events = [];
2315
2315
  // 1. message_start event
2316
- events.push(`event: message_start
2316
+ events.push(`event: message_start
2317
2317
  data: ${JSON.stringify({
2318
2318
  type: "message_start",
2319
2319
  message: {
@@ -2326,48 +2326,48 @@ data: ${JSON.stringify({
2326
2326
  stop_sequence: null,
2327
2327
  usage: { input_tokens: 0, output_tokens: 0 },
2328
2328
  },
2329
- })}
2330
-
2329
+ })}
2330
+
2331
2331
  `);
2332
2332
  // 2. content_block_start event
2333
- events.push(`event: content_block_start
2333
+ events.push(`event: content_block_start
2334
2334
  data: ${JSON.stringify({
2335
2335
  type: "content_block_start",
2336
2336
  index: 0,
2337
2337
  content_block: { type: "text", text: "" },
2338
- })}
2339
-
2338
+ })}
2339
+
2340
2340
  `);
2341
2341
  // 3. content_block_delta event with the error message
2342
- events.push(`event: content_block_delta
2342
+ events.push(`event: content_block_delta
2343
2343
  data: ${JSON.stringify({
2344
2344
  type: "content_block_delta",
2345
2345
  index: 0,
2346
2346
  delta: { type: "text_delta", text: errorMessage },
2347
- })}
2348
-
2347
+ })}
2348
+
2349
2349
  `);
2350
2350
  // 4. content_block_stop event
2351
- events.push(`event: content_block_stop
2351
+ events.push(`event: content_block_stop
2352
2352
  data: ${JSON.stringify({
2353
2353
  type: "content_block_stop",
2354
2354
  index: 0,
2355
- })}
2356
-
2355
+ })}
2356
+
2357
2357
  `);
2358
2358
  // 5. message_delta event (end_turn)
2359
- events.push(`event: message_delta
2359
+ events.push(`event: message_delta
2360
2360
  data: ${JSON.stringify({
2361
2361
  type: "message_delta",
2362
2362
  delta: { stop_reason: "end_turn", stop_sequence: null },
2363
2363
  usage: { output_tokens: Math.ceil(errorMessage.length / 4) },
2364
- })}
2365
-
2364
+ })}
2365
+
2366
2366
  `);
2367
2367
  // 6. message_stop event
2368
- events.push(`event: message_stop
2369
- data: ${JSON.stringify({ type: "message_stop" })}
2370
-
2368
+ events.push(`event: message_stop
2369
+ data: ${JSON.stringify({ type: "message_stop" })}
2370
+
2371
2371
  `);
2372
2372
  const body = events.join("");
2373
2373
  return new Response(body, {
@@ -136,130 +136,130 @@ export async function startOAuthListener({ timeoutMs = 5 * 60 * 1000 } = {}) {
136
136
  reject(error);
137
137
  };
138
138
  });
139
- const successResponse = `<!DOCTYPE html>
140
- <html lang="en">
141
- <head>
142
- <meta charset="utf-8" />
143
- <meta name="viewport" content="width=device-width, initial-scale=1">
144
- <title>Authentication Successful</title>
145
- <style>
146
- :root {
147
- --bg: #FAFAFA;
148
- --card-bg: #FFFFFF;
149
- --text-primary: #1F2937;
150
- --text-secondary: #6B7280;
151
- --accent: #2563EB;
152
- --success: #10B981;
153
- --border: #E5E7EB;
154
- }
155
- @media (prefers-color-scheme: dark) {
156
- :root {
157
- --bg: #111827;
158
- --card-bg: #1F2937;
159
- --text-primary: #F9FAFB;
160
- --text-secondary: #9CA3AF;
161
- --accent: #3B82F6;
162
- --success: #34D399;
163
- --border: #374151;
164
- }
165
- }
166
- body {
167
- margin: 0;
168
- min-height: 100vh;
169
- display: flex;
170
- align-items: center;
171
- justify-content: center;
172
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
173
- background: var(--bg);
174
- color: var(--text-primary);
175
- padding: 1rem;
176
- }
177
- .card {
178
- background: var(--card-bg);
179
- border-radius: 16px;
180
- padding: 3rem 2rem;
181
- width: 100%;
182
- max-width: 400px;
183
- text-align: center;
184
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
185
- border: 1px solid var(--border);
186
- }
187
- .icon-wrapper {
188
- width: 64px;
189
- height: 64px;
190
- background: rgba(16, 185, 129, 0.1);
191
- border-radius: 50%;
192
- display: flex;
193
- align-items: center;
194
- justify-content: center;
195
- margin: 0 auto 1.5rem;
196
- }
197
- .icon {
198
- width: 32px;
199
- height: 32px;
200
- color: var(--success);
201
- }
202
- h1 {
203
- font-size: 1.5rem;
204
- font-weight: 600;
205
- margin: 0 0 0.5rem;
206
- letter-spacing: -0.025em;
207
- }
208
- p {
209
- color: var(--text-secondary);
210
- font-size: 0.95rem;
211
- line-height: 1.5;
212
- margin: 0 0 2rem;
213
- }
214
- .btn {
215
- display: inline-flex;
216
- align-items: center;
217
- justify-content: center;
218
- background: var(--text-primary);
219
- color: var(--card-bg);
220
- font-weight: 500;
221
- padding: 0.75rem 1.5rem;
222
- border-radius: 8px;
223
- text-decoration: none;
224
- transition: opacity 0.2s;
225
- font-size: 0.95rem;
226
- border: none;
227
- cursor: pointer;
228
- width: 100%;
229
- box-sizing: border-box;
230
- }
231
- .btn:hover {
232
- opacity: 0.9;
233
- }
234
- .sub-text {
235
- margin-top: 1rem;
236
- font-size: 0.8rem;
237
- color: var(--text-secondary);
238
- }
239
- </style>
240
- </head>
241
- <body>
242
- <div class="card">
243
- <div class="icon-wrapper">
244
- <svg class="icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
245
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7" />
246
- </svg>
247
- </div>
248
- <h1>All set!</h1>
249
- <p>You've successfully authenticated with Antigravity. You can now return to Opencode.</p>
250
- <button class="btn" onclick="closeWindow()">Close this tab</button>
251
- <div class="sub-text">Usage Tip: Most browsers block auto-closing. If the button doesn't work, please close the tab manually.</div>
252
- </div>
253
- <script>
254
- function closeWindow() {
255
- window.close();
256
- // Fallback if window.close() is blocked
257
- document.querySelector('.btn').textContent = "Tab cannot be closed automatically";
258
- document.querySelector('.btn').style.opacity = "0.5";
259
- document.querySelector('.btn').style.cursor = "default";
260
- }
261
- </script>
262
- </body>
139
+ const successResponse = `<!DOCTYPE html>
140
+ <html lang="en">
141
+ <head>
142
+ <meta charset="utf-8" />
143
+ <meta name="viewport" content="width=device-width, initial-scale=1">
144
+ <title>Authentication Successful</title>
145
+ <style>
146
+ :root {
147
+ --bg: #FAFAFA;
148
+ --card-bg: #FFFFFF;
149
+ --text-primary: #1F2937;
150
+ --text-secondary: #6B7280;
151
+ --accent: #2563EB;
152
+ --success: #10B981;
153
+ --border: #E5E7EB;
154
+ }
155
+ @media (prefers-color-scheme: dark) {
156
+ :root {
157
+ --bg: #111827;
158
+ --card-bg: #1F2937;
159
+ --text-primary: #F9FAFB;
160
+ --text-secondary: #9CA3AF;
161
+ --accent: #3B82F6;
162
+ --success: #34D399;
163
+ --border: #374151;
164
+ }
165
+ }
166
+ body {
167
+ margin: 0;
168
+ min-height: 100vh;
169
+ display: flex;
170
+ align-items: center;
171
+ justify-content: center;
172
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
173
+ background: var(--bg);
174
+ color: var(--text-primary);
175
+ padding: 1rem;
176
+ }
177
+ .card {
178
+ background: var(--card-bg);
179
+ border-radius: 16px;
180
+ padding: 3rem 2rem;
181
+ width: 100%;
182
+ max-width: 400px;
183
+ text-align: center;
184
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
185
+ border: 1px solid var(--border);
186
+ }
187
+ .icon-wrapper {
188
+ width: 64px;
189
+ height: 64px;
190
+ background: rgba(16, 185, 129, 0.1);
191
+ border-radius: 50%;
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: center;
195
+ margin: 0 auto 1.5rem;
196
+ }
197
+ .icon {
198
+ width: 32px;
199
+ height: 32px;
200
+ color: var(--success);
201
+ }
202
+ h1 {
203
+ font-size: 1.5rem;
204
+ font-weight: 600;
205
+ margin: 0 0 0.5rem;
206
+ letter-spacing: -0.025em;
207
+ }
208
+ p {
209
+ color: var(--text-secondary);
210
+ font-size: 0.95rem;
211
+ line-height: 1.5;
212
+ margin: 0 0 2rem;
213
+ }
214
+ .btn {
215
+ display: inline-flex;
216
+ align-items: center;
217
+ justify-content: center;
218
+ background: var(--text-primary);
219
+ color: var(--card-bg);
220
+ font-weight: 500;
221
+ padding: 0.75rem 1.5rem;
222
+ border-radius: 8px;
223
+ text-decoration: none;
224
+ transition: opacity 0.2s;
225
+ font-size: 0.95rem;
226
+ border: none;
227
+ cursor: pointer;
228
+ width: 100%;
229
+ box-sizing: border-box;
230
+ }
231
+ .btn:hover {
232
+ opacity: 0.9;
233
+ }
234
+ .sub-text {
235
+ margin-top: 1rem;
236
+ font-size: 0.8rem;
237
+ color: var(--text-secondary);
238
+ }
239
+ </style>
240
+ </head>
241
+ <body>
242
+ <div class="card">
243
+ <div class="icon-wrapper">
244
+ <svg class="icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
245
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7" />
246
+ </svg>
247
+ </div>
248
+ <h1>All set!</h1>
249
+ <p>You've successfully authenticated with Antigravity. You can now return to Opencode.</p>
250
+ <button class="btn" onclick="closeWindow()">Close this tab</button>
251
+ <div class="sub-text">Usage Tip: Most browsers block auto-closing. If the button doesn't work, please close the tab manually.</div>
252
+ </div>
253
+ <script>
254
+ function closeWindow() {
255
+ window.close();
256
+ // Fallback if window.close() is blocked
257
+ document.querySelector('.btn').textContent = "Tab cannot be closed automatically";
258
+ document.querySelector('.btn').style.opacity = "0.5";
259
+ document.querySelector('.btn').style.cursor = "default";
260
+ }
261
+ </script>
262
+ </body>
263
263
  </html>`;
264
264
  timeoutHandle = setTimeout(() => {
265
265
  rejectCallback(new Error("Timed out waiting for OAuth callback"));
package/package.json CHANGED
@@ -1,70 +1,70 @@
1
- {
2
- "name": "@benjamolina/opencode-antigravity-guard",
3
- "version": "1.0.0",
4
- "description": "Google Antigravity OAuth plugin for OpenCode with strict reset-time quota locking",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
7
- "type": "module",
8
- "license": "MIT",
9
- "author": "benjamolina",
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/BenjaMolina/opencode-antigravity-guard.git"
13
- },
14
- "homepage": "https://github.com/BenjaMolina/opencode-antigravity-guard#readme",
15
- "bugs": {
16
- "url": "https://github.com/BenjaMolina/opencode-antigravity-guard/issues"
17
- },
18
- "publishConfig": {
19
- "access": "public"
20
- },
21
- "keywords": [
22
- "opencode",
23
- "google",
24
- "antigravity",
25
- "gemini",
26
- "oauth",
27
- "plugin",
28
- "auth",
29
- "claude"
30
- ],
31
- "engines": {
32
- "node": ">=20.0.0"
33
- },
34
- "files": [
35
- "dist/",
36
- "README.md",
37
- "LICENSE"
38
- ],
39
- "scripts": {
40
- "build": "tsc -p tsconfig.build.json && npx tsx scripts/fix-esm-imports.ts",
41
- "build:schema": "npx tsx script/build-schema.ts",
42
- "typecheck": "tsc --noEmit",
43
- "test": "vitest run",
44
- "test:watch": "vitest",
45
- "test:ui": "vitest --ui",
46
- "test:coverage": "vitest run --coverage",
47
- "prepublishOnly": "npm run build",
48
- "test:e2e:models": "npx tsx script/test-models.ts",
49
- "test:e2e:regression": "npx tsx script/test-regression.ts"
50
- },
51
- "peerDependencies": {
52
- "typescript": "^5"
53
- },
54
- "devDependencies": {
55
- "@types/node": "^24.10.1",
56
- "@types/proper-lockfile": "^4.1.4",
57
- "@vitest/coverage-v8": "^3.0.0",
58
- "@vitest/ui": "^3.0.0",
59
- "typescript": "^5.0.0",
60
- "vitest": "^3.0.0",
61
- "zod-to-json-schema": "^3.25.1"
62
- },
63
- "dependencies": {
64
- "@openauthjs/openauth": "^0.4.3",
65
- "@opencode-ai/plugin": "^1.2.10",
66
- "proper-lockfile": "^4.1.2",
67
- "xdg-basedir": "^5.1.0",
68
- "zod": "^4.0.0"
69
- }
70
- }
1
+ {
2
+ "name": "@benjamolina/opencode-antigravity-guard",
3
+ "version": "1.1.1",
4
+ "description": "Google Antigravity OAuth plugin for OpenCode with strict reset-time quota locking",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "license": "MIT",
9
+ "author": "benjamolina",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/BenjaMolina/opencode-antigravity-guard.git"
13
+ },
14
+ "homepage": "https://github.com/BenjaMolina/opencode-antigravity-guard#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/BenjaMolina/opencode-antigravity-guard/issues"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "keywords": [
22
+ "opencode",
23
+ "google",
24
+ "antigravity",
25
+ "gemini",
26
+ "oauth",
27
+ "plugin",
28
+ "auth",
29
+ "claude"
30
+ ],
31
+ "engines": {
32
+ "node": ">=20.0.0"
33
+ },
34
+ "files": [
35
+ "dist/",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.build.json && npx tsx scripts/fix-esm-imports.ts",
41
+ "build:schema": "npx tsx script/build-schema.ts",
42
+ "typecheck": "tsc --noEmit",
43
+ "test": "vitest run",
44
+ "test:watch": "vitest",
45
+ "test:ui": "vitest --ui",
46
+ "test:coverage": "vitest run --coverage",
47
+ "prepublishOnly": "npm run build",
48
+ "test:e2e:models": "npx tsx script/test-models.ts",
49
+ "test:e2e:regression": "npx tsx script/test-regression.ts"
50
+ },
51
+ "peerDependencies": {
52
+ "typescript": "^5"
53
+ },
54
+ "devDependencies": {
55
+ "@types/node": "^24.10.1",
56
+ "@types/proper-lockfile": "^4.1.4",
57
+ "@vitest/coverage-v8": "^3.0.0",
58
+ "@vitest/ui": "^3.0.0",
59
+ "typescript": "^5.0.0",
60
+ "vitest": "^3.0.0",
61
+ "zod-to-json-schema": "^3.25.1"
62
+ },
63
+ "dependencies": {
64
+ "@openauthjs/openauth": "^0.4.3",
65
+ "@opencode-ai/plugin": "^1.2.10",
66
+ "proper-lockfile": "^4.1.2",
67
+ "xdg-basedir": "^5.1.0",
68
+ "zod": "^4.0.0"
69
+ }
70
+ }