antigravity-proxy 0.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.
- package/.dockerignore +10 -0
- package/.env.example +2 -0
- package/Dockerfile +20 -0
- package/README.md +132 -0
- package/bun.lock +51 -0
- package/docker-compose.yml +11 -0
- package/package.json +22 -0
- package/reset-accounts.ts +17 -0
- package/screenshots/screenshot.png +0 -0
- package/src/api/quota.ts +187 -0
- package/src/auth/manager.ts +326 -0
- package/src/auth/oauth.ts +95 -0
- package/src/auth/storage.ts +39 -0
- package/src/auth/types.ts +73 -0
- package/src/config/manager.ts +141 -0
- package/src/config/types.ts +73 -0
- package/src/frontend/components/config-modal.html +109 -0
- package/src/frontend/components/header.html +55 -0
- package/src/frontend/components/main.html +64 -0
- package/src/frontend/css/styles.css +53 -0
- package/src/frontend/index.html +48 -0
- package/src/frontend/js/app.js +883 -0
- package/src/frontend/js/tailwind-config.js +40 -0
- package/src/scripts/check_quota_api.ts +70 -0
- package/src/scripts/check_sandbox_quota.ts +42 -0
- package/src/scripts/debug-accounts.ts +25 -0
- package/src/scripts/debug-quota-raw.ts +47 -0
- package/src/scripts/diagnose_claude_quota.ts +97 -0
- package/src/scripts/reset-accounts.ts +24 -0
- package/src/scripts/test-claude-cli.ts +55 -0
- package/src/scripts/test-request.ts +138 -0
- package/src/scripts/test-routing-logic.ts +40 -0
- package/src/scripts/test_claude_forced.ts +53 -0
- package/src/scripts/test_placeholder_model.ts +85 -0
- package/src/scripts/verify-claude.ts +51 -0
- package/src/server.ts +679 -0
- package/src/utils/cache.ts +18 -0
- package/src/utils/errors.ts +93 -0
- package/src/utils/headers.ts +172 -0
- package/src/utils/schema.ts +100 -0
- package/src/utils/transform.ts +532 -0
- package/tests/functional/gemini-functional.test.ts +122 -0
- package/tests/functional/models.test.ts +100 -0
- package/tests/unit/manager.test.ts +13 -0
- package/tests/unit/transform.test.ts +135 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { getImpersonationHeaders } from "../utils/headers";
|
|
4
|
+
import { transformToGoogleBody } from "../utils/transform";
|
|
5
|
+
|
|
6
|
+
// Usage: bun run src/scripts/test_placeholder_model.ts <email>
|
|
7
|
+
|
|
8
|
+
const email = process.argv[2];
|
|
9
|
+
if (!email) {
|
|
10
|
+
console.error("Usage: bun run src/scripts/test_placeholder_model.ts <email>");
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 1. Load Account
|
|
15
|
+
const dbPath = join(process.cwd(), "antigravity-accounts.json");
|
|
16
|
+
let accounts = [];
|
|
17
|
+
try {
|
|
18
|
+
const data = readFileSync(dbPath, "utf-8");
|
|
19
|
+
const json = JSON.parse(data);
|
|
20
|
+
accounts = Array.isArray(json) ? json : (json.accounts || []);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error("Could not read antigravity-accounts.json");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const account = accounts.find((a: any) => a.email === email);
|
|
27
|
+
if (!account) {
|
|
28
|
+
console.error(`Account ${email} not found.`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log(`\n=== TESTING antigravity-claude-opus-4-5-thinking-high FOR: ${account.email} ===`);
|
|
33
|
+
|
|
34
|
+
const openaiBody = {
|
|
35
|
+
model: "claude-opus-4-5-thinking",
|
|
36
|
+
messages: [
|
|
37
|
+
{ role: "user", content: "Hi" }
|
|
38
|
+
],
|
|
39
|
+
temperature: 0.7,
|
|
40
|
+
max_tokens: 100
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Manually construct the body
|
|
44
|
+
const effectiveProjectId = account.projectId || "rising-fact-p41fc";
|
|
45
|
+
const googleBody = transformToGoogleBody(openaiBody, effectiveProjectId, false, "us-central1"); // requestType=agent
|
|
46
|
+
|
|
47
|
+
// OVERRIDE MODEL NAME with what the plugin uses
|
|
48
|
+
googleBody.model = "antigravity-claude-opus-4-5-thinking-high";
|
|
49
|
+
console.log("Modified Body Model:", googleBody.model);
|
|
50
|
+
|
|
51
|
+
// URL
|
|
52
|
+
const url = "https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal:streamGenerateContent?alt=sse";
|
|
53
|
+
|
|
54
|
+
const headers = getImpersonationHeaders(account.accessToken);
|
|
55
|
+
headers["anthropic-beta"] = "interleaved-thinking-2025-05-14";
|
|
56
|
+
|
|
57
|
+
async function test() {
|
|
58
|
+
try {
|
|
59
|
+
const res = await fetch(url, {
|
|
60
|
+
method: "POST",
|
|
61
|
+
headers: headers,
|
|
62
|
+
body: JSON.stringify(googleBody)
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
console.log(`Status: ${res.status} ${res.statusText}`);
|
|
66
|
+
|
|
67
|
+
if (res.ok) {
|
|
68
|
+
console.log("SUCCESS! MODEL_PLACEHOLDER_M12 works.");
|
|
69
|
+
const reader = res.body?.getReader();
|
|
70
|
+
if (reader) {
|
|
71
|
+
const { value } = await reader.read();
|
|
72
|
+
console.log("First chunk received:", new TextDecoder().decode(value).substring(0, 100) + "...");
|
|
73
|
+
reader.cancel();
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
const text = await res.text();
|
|
77
|
+
console.error("FAILED. Response body:");
|
|
78
|
+
console.error(text.substring(0, 500));
|
|
79
|
+
}
|
|
80
|
+
} catch (e: any) {
|
|
81
|
+
console.error(`EXCEPTION: ${e.message}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
test();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { initManager, getAccounts } from "../auth/manager";
|
|
2
|
+
import { getGeminiCliHeaders } from "../utils/headers";
|
|
3
|
+
|
|
4
|
+
console.log("Initializing...");
|
|
5
|
+
await initManager();
|
|
6
|
+
const accounts = getAccounts();
|
|
7
|
+
const account = accounts.find(a => a.email === "frieserpaldi@gmail.com");
|
|
8
|
+
|
|
9
|
+
if (!account || !account.accessToken) {
|
|
10
|
+
console.error("Account not found");
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const url = "https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse";
|
|
15
|
+
const baseBody = {
|
|
16
|
+
project: account.projectId,
|
|
17
|
+
requestType: "IDE_CHAT",
|
|
18
|
+
request: {
|
|
19
|
+
contents: [{ role: "user", parts: [{ text: "Hi" }] }],
|
|
20
|
+
generationConfig: { candidateCount: 1 }
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const modelsToTest = [
|
|
25
|
+
"gemini-2.5-pro",
|
|
26
|
+
"claude-sonnet-4-5",
|
|
27
|
+
"claude-opus-4-5-thinking"
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
for (const m of modelsToTest) {
|
|
31
|
+
console.log(`\nTesting model: '${m}'`);
|
|
32
|
+
const body = { ...baseBody, model: m };
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const res = await fetch(url, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: getGeminiCliHeaders(account.accessToken),
|
|
38
|
+
body: JSON.stringify(body)
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(`Status: ${res.status}`);
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
console.log("Error:", (await res.text()).substring(0, 200));
|
|
44
|
+
} else {
|
|
45
|
+
console.log("Success!");
|
|
46
|
+
await res.text();
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.error(e);
|
|
50
|
+
}
|
|
51
|
+
}
|