antigravity-auth 1.6.0 → 1.7.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/README.md +79 -41
- package/dist/cli.js +17854 -0
- package/dist/handler.js +25147 -0
- package/dist/index.js +25138 -5
- package/package.json +66 -54
- package/dist/antigravity/oauth.d.ts +0 -30
- package/dist/antigravity/oauth.js +0 -170
- package/dist/claude/login.d.ts +0 -7
- package/dist/claude/login.js +0 -480
- package/dist/claude/menu-helpers.d.ts +0 -22
- package/dist/claude/menu-helpers.js +0 -281
- package/dist/claude/proxy-manager.d.ts +0 -11
- package/dist/claude/proxy-manager.js +0 -129
- package/dist/claude/proxy.d.ts +0 -1
- package/dist/claude/proxy.js +0 -733
- package/dist/constants.d.ts +0 -138
- package/dist/constants.js +0 -216
- package/dist/hooks/auto-update-checker/cache.d.ts +0 -2
- package/dist/hooks/auto-update-checker/cache.js +0 -70
- package/dist/hooks/auto-update-checker/checker.d.ts +0 -15
- package/dist/hooks/auto-update-checker/checker.js +0 -233
- package/dist/hooks/auto-update-checker/constants.d.ts +0 -8
- package/dist/hooks/auto-update-checker/constants.js +0 -22
- package/dist/hooks/auto-update-checker/index.d.ts +0 -33
- package/dist/hooks/auto-update-checker/index.js +0 -121
- package/dist/hooks/auto-update-checker/logging.d.ts +0 -2
- package/dist/hooks/auto-update-checker/logging.js +0 -8
- package/dist/hooks/auto-update-checker/types.d.ts +0 -24
- package/dist/hooks/auto-update-checker/types.js +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/opencode/hooks/auto-update-checker/cache.d.ts +0 -2
- package/dist/opencode/hooks/auto-update-checker/cache.js +0 -70
- package/dist/opencode/hooks/auto-update-checker/checker.d.ts +0 -15
- package/dist/opencode/hooks/auto-update-checker/checker.js +0 -233
- package/dist/opencode/hooks/auto-update-checker/constants.d.ts +0 -8
- package/dist/opencode/hooks/auto-update-checker/constants.js +0 -22
- package/dist/opencode/hooks/auto-update-checker/index.d.ts +0 -33
- package/dist/opencode/hooks/auto-update-checker/index.js +0 -121
- package/dist/opencode/hooks/auto-update-checker/logging.d.ts +0 -2
- package/dist/opencode/hooks/auto-update-checker/logging.js +0 -8
- package/dist/opencode/hooks/auto-update-checker/types.d.ts +0 -24
- package/dist/opencode/hooks/auto-update-checker/types.js +0 -1
- package/dist/opencode/plugin.d.ts +0 -29
- package/dist/opencode/plugin.js +0 -2954
- package/dist/plugin/accounts.d.ts +0 -173
- package/dist/plugin/accounts.js +0 -966
- package/dist/plugin/auth.d.ts +0 -20
- package/dist/plugin/auth.js +0 -44
- package/dist/plugin/cache/index.d.ts +0 -4
- package/dist/plugin/cache/index.js +0 -4
- package/dist/plugin/cache/signature-cache.d.ts +0 -110
- package/dist/plugin/cache/signature-cache.js +0 -347
- package/dist/plugin/cache.d.ts +0 -43
- package/dist/plugin/cache.js +0 -180
- package/dist/plugin/cli.d.ts +0 -26
- package/dist/plugin/cli.js +0 -126
- package/dist/plugin/config/index.d.ts +0 -15
- package/dist/plugin/config/index.js +0 -15
- package/dist/plugin/config/loader.d.ts +0 -38
- package/dist/plugin/config/loader.js +0 -150
- package/dist/plugin/config/models.d.ts +0 -26
- package/dist/plugin/config/models.js +0 -95
- package/dist/plugin/config/schema.d.ts +0 -144
- package/dist/plugin/config/schema.js +0 -458
- package/dist/plugin/config/updater.d.ts +0 -76
- package/dist/plugin/config/updater.js +0 -205
- package/dist/plugin/core/streaming/index.d.ts +0 -2
- package/dist/plugin/core/streaming/index.js +0 -2
- package/dist/plugin/core/streaming/transformer.d.ts +0 -9
- package/dist/plugin/core/streaming/transformer.js +0 -301
- package/dist/plugin/core/streaming/types.d.ts +0 -28
- package/dist/plugin/core/streaming/types.js +0 -1
- package/dist/plugin/debug.d.ts +0 -93
- package/dist/plugin/debug.js +0 -375
- package/dist/plugin/errors.d.ts +0 -27
- package/dist/plugin/errors.js +0 -41
- package/dist/plugin/fingerprint.d.ts +0 -69
- package/dist/plugin/fingerprint.js +0 -137
- package/dist/plugin/image-saver.d.ts +0 -24
- package/dist/plugin/image-saver.js +0 -78
- package/dist/plugin/logger.d.ts +0 -35
- package/dist/plugin/logger.js +0 -67
- package/dist/plugin/logging-utils.d.ts +0 -22
- package/dist/plugin/logging-utils.js +0 -91
- package/dist/plugin/project.d.ts +0 -32
- package/dist/plugin/project.js +0 -229
- package/dist/plugin/quota.d.ts +0 -34
- package/dist/plugin/quota.js +0 -261
- package/dist/plugin/recovery/constants.d.ts +0 -21
- package/dist/plugin/recovery/constants.js +0 -42
- package/dist/plugin/recovery/index.d.ts +0 -11
- package/dist/plugin/recovery/index.js +0 -11
- package/dist/plugin/recovery/storage.d.ts +0 -23
- package/dist/plugin/recovery/storage.js +0 -340
- package/dist/plugin/recovery/types.d.ts +0 -115
- package/dist/plugin/recovery/types.js +0 -6
- package/dist/plugin/recovery.d.ts +0 -60
- package/dist/plugin/recovery.js +0 -360
- package/dist/plugin/refresh-queue.d.ts +0 -99
- package/dist/plugin/refresh-queue.js +0 -235
- package/dist/plugin/request-helpers.d.ts +0 -281
- package/dist/plugin/request-helpers.js +0 -2200
- package/dist/plugin/request.d.ts +0 -110
- package/dist/plugin/request.js +0 -1489
- package/dist/plugin/rotation.d.ts +0 -182
- package/dist/plugin/rotation.js +0 -364
- package/dist/plugin/search.d.ts +0 -31
- package/dist/plugin/search.js +0 -185
- package/dist/plugin/server.d.ts +0 -22
- package/dist/plugin/server.js +0 -306
- package/dist/plugin/storage.d.ts +0 -136
- package/dist/plugin/storage.js +0 -599
- package/dist/plugin/stores/signature-store.d.ts +0 -4
- package/dist/plugin/stores/signature-store.js +0 -24
- package/dist/plugin/thinking-recovery.d.ts +0 -89
- package/dist/plugin/thinking-recovery.js +0 -289
- package/dist/plugin/token.d.ts +0 -18
- package/dist/plugin/token.js +0 -127
- package/dist/plugin/transform/claude.d.ts +0 -79
- package/dist/plugin/transform/claude.js +0 -256
- package/dist/plugin/transform/cross-model-sanitizer.d.ts +0 -34
- package/dist/plugin/transform/cross-model-sanitizer.js +0 -224
- package/dist/plugin/transform/gemini.d.ts +0 -132
- package/dist/plugin/transform/gemini.js +0 -659
- package/dist/plugin/transform/index.d.ts +0 -14
- package/dist/plugin/transform/index.js +0 -9
- package/dist/plugin/transform/model-resolver.d.ts +0 -98
- package/dist/plugin/transform/model-resolver.js +0 -320
- package/dist/plugin/transform/types.d.ts +0 -110
- package/dist/plugin/transform/types.js +0 -1
- package/dist/plugin/types.d.ts +0 -95
- package/dist/plugin/types.js +0 -1
- package/dist/plugin/ui/ansi.d.ts +0 -31
- package/dist/plugin/ui/ansi.js +0 -45
- package/dist/plugin/ui/auth-menu.d.ts +0 -47
- package/dist/plugin/ui/auth-menu.js +0 -199
- package/dist/plugin/ui/confirm.d.ts +0 -1
- package/dist/plugin/ui/confirm.js +0 -14
- package/dist/plugin/ui/select.d.ts +0 -22
- package/dist/plugin/ui/select.js +0 -243
- package/dist/plugin/version.d.ts +0 -18
- package/dist/plugin/version.js +0 -79
- package/dist/src/antigravity/oauth.d.ts +0 -30
- package/dist/src/antigravity/oauth.js +0 -170
- package/dist/src/constants.d.ts +0 -138
- package/dist/src/constants.js +0 -216
- package/dist/src/hooks/auto-update-checker/cache.d.ts +0 -2
- package/dist/src/hooks/auto-update-checker/cache.js +0 -70
- package/dist/src/hooks/auto-update-checker/checker.d.ts +0 -15
- package/dist/src/hooks/auto-update-checker/checker.js +0 -233
- package/dist/src/hooks/auto-update-checker/constants.d.ts +0 -8
- package/dist/src/hooks/auto-update-checker/constants.js +0 -22
- package/dist/src/hooks/auto-update-checker/index.d.ts +0 -33
- package/dist/src/hooks/auto-update-checker/index.js +0 -121
- package/dist/src/hooks/auto-update-checker/logging.d.ts +0 -2
- package/dist/src/hooks/auto-update-checker/logging.js +0 -8
- package/dist/src/hooks/auto-update-checker/types.d.ts +0 -24
- package/dist/src/hooks/auto-update-checker/types.js +0 -1
- package/dist/src/index.d.ts +0 -6
- package/dist/src/index.js +0 -5
- package/dist/src/plugin/accounts.d.ts +0 -173
- package/dist/src/plugin/accounts.js +0 -966
- package/dist/src/plugin/auth.d.ts +0 -20
- package/dist/src/plugin/auth.js +0 -44
- package/dist/src/plugin/cache/index.d.ts +0 -4
- package/dist/src/plugin/cache/index.js +0 -4
- package/dist/src/plugin/cache/signature-cache.d.ts +0 -110
- package/dist/src/plugin/cache/signature-cache.js +0 -347
- package/dist/src/plugin/cache.d.ts +0 -43
- package/dist/src/plugin/cache.js +0 -180
- package/dist/src/plugin/cli.d.ts +0 -26
- package/dist/src/plugin/cli.js +0 -126
- package/dist/src/plugin/config/index.d.ts +0 -15
- package/dist/src/plugin/config/index.js +0 -15
- package/dist/src/plugin/config/loader.d.ts +0 -38
- package/dist/src/plugin/config/loader.js +0 -150
- package/dist/src/plugin/config/models.d.ts +0 -26
- package/dist/src/plugin/config/models.js +0 -95
- package/dist/src/plugin/config/schema.d.ts +0 -144
- package/dist/src/plugin/config/schema.js +0 -458
- package/dist/src/plugin/config/updater.d.ts +0 -76
- package/dist/src/plugin/config/updater.js +0 -205
- package/dist/src/plugin/core/streaming/index.d.ts +0 -2
- package/dist/src/plugin/core/streaming/index.js +0 -2
- package/dist/src/plugin/core/streaming/transformer.d.ts +0 -9
- package/dist/src/plugin/core/streaming/transformer.js +0 -301
- package/dist/src/plugin/core/streaming/types.d.ts +0 -28
- package/dist/src/plugin/core/streaming/types.js +0 -1
- package/dist/src/plugin/debug.d.ts +0 -93
- package/dist/src/plugin/debug.js +0 -375
- package/dist/src/plugin/errors.d.ts +0 -27
- package/dist/src/plugin/errors.js +0 -41
- package/dist/src/plugin/fingerprint.d.ts +0 -69
- package/dist/src/plugin/fingerprint.js +0 -137
- package/dist/src/plugin/image-saver.d.ts +0 -24
- package/dist/src/plugin/image-saver.js +0 -78
- package/dist/src/plugin/logger.d.ts +0 -35
- package/dist/src/plugin/logger.js +0 -67
- package/dist/src/plugin/logging-utils.d.ts +0 -22
- package/dist/src/plugin/logging-utils.js +0 -91
- package/dist/src/plugin/project.d.ts +0 -32
- package/dist/src/plugin/project.js +0 -229
- package/dist/src/plugin/quota.d.ts +0 -34
- package/dist/src/plugin/quota.js +0 -261
- package/dist/src/plugin/recovery/constants.d.ts +0 -21
- package/dist/src/plugin/recovery/constants.js +0 -42
- package/dist/src/plugin/recovery/index.d.ts +0 -11
- package/dist/src/plugin/recovery/index.js +0 -11
- package/dist/src/plugin/recovery/storage.d.ts +0 -23
- package/dist/src/plugin/recovery/storage.js +0 -340
- package/dist/src/plugin/recovery/types.d.ts +0 -115
- package/dist/src/plugin/recovery/types.js +0 -6
- package/dist/src/plugin/recovery.d.ts +0 -60
- package/dist/src/plugin/recovery.js +0 -360
- package/dist/src/plugin/refresh-queue.d.ts +0 -99
- package/dist/src/plugin/refresh-queue.js +0 -235
- package/dist/src/plugin/request-helpers.d.ts +0 -281
- package/dist/src/plugin/request-helpers.js +0 -2200
- package/dist/src/plugin/request.d.ts +0 -110
- package/dist/src/plugin/request.js +0 -1489
- package/dist/src/plugin/rotation.d.ts +0 -182
- package/dist/src/plugin/rotation.js +0 -364
- package/dist/src/plugin/search.d.ts +0 -31
- package/dist/src/plugin/search.js +0 -185
- package/dist/src/plugin/server.d.ts +0 -22
- package/dist/src/plugin/server.js +0 -306
- package/dist/src/plugin/storage.d.ts +0 -136
- package/dist/src/plugin/storage.js +0 -599
- package/dist/src/plugin/stores/signature-store.d.ts +0 -4
- package/dist/src/plugin/stores/signature-store.js +0 -24
- package/dist/src/plugin/thinking-recovery.d.ts +0 -89
- package/dist/src/plugin/thinking-recovery.js +0 -289
- package/dist/src/plugin/token.d.ts +0 -18
- package/dist/src/plugin/token.js +0 -127
- package/dist/src/plugin/transform/claude.d.ts +0 -79
- package/dist/src/plugin/transform/claude.js +0 -256
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +0 -34
- package/dist/src/plugin/transform/cross-model-sanitizer.js +0 -224
- package/dist/src/plugin/transform/gemini.d.ts +0 -132
- package/dist/src/plugin/transform/gemini.js +0 -659
- package/dist/src/plugin/transform/index.d.ts +0 -14
- package/dist/src/plugin/transform/index.js +0 -9
- package/dist/src/plugin/transform/model-resolver.d.ts +0 -98
- package/dist/src/plugin/transform/model-resolver.js +0 -320
- package/dist/src/plugin/transform/types.d.ts +0 -110
- package/dist/src/plugin/transform/types.js +0 -1
- package/dist/src/plugin/types.d.ts +0 -95
- package/dist/src/plugin/types.js +0 -1
- package/dist/src/plugin/ui/ansi.d.ts +0 -31
- package/dist/src/plugin/ui/ansi.js +0 -45
- package/dist/src/plugin/ui/auth-menu.d.ts +0 -47
- package/dist/src/plugin/ui/auth-menu.js +0 -199
- package/dist/src/plugin/ui/confirm.d.ts +0 -1
- package/dist/src/plugin/ui/confirm.js +0 -14
- package/dist/src/plugin/ui/select.d.ts +0 -22
- package/dist/src/plugin/ui/select.js +0 -243
- package/dist/src/plugin/version.d.ts +0 -18
- package/dist/src/plugin/version.js +0 -79
package/dist/claude/login.js
DELETED
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standalone CLI login script for Antigravity OAuth.
|
|
3
|
-
* Invoked by `cc auth login` — shows the full interactive account management menu.
|
|
4
|
-
*
|
|
5
|
-
* Usage: bun run scripts/login.ts
|
|
6
|
-
*/
|
|
7
|
-
import { authorizeAntigravity, exchangeAntigravity } from "../src/antigravity/oauth";
|
|
8
|
-
import { startOAuthListener } from "../src/plugin/server";
|
|
9
|
-
import { loadAccounts as _loadAccounts, saveAccounts as _saveAccounts } from "../src/plugin/storage";
|
|
10
|
-
async function loadAccounts() {
|
|
11
|
-
syncBeforeRead();
|
|
12
|
-
return _loadAccounts();
|
|
13
|
-
}
|
|
14
|
-
async function saveAccounts(...args) {
|
|
15
|
-
const result = await _saveAccounts(...args);
|
|
16
|
-
syncAfterWrite();
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
import { promptProjectId, promptAddAnotherAccount, promptLoginMode } from "../src/plugin/cli";
|
|
20
|
-
import { checkAccountsQuota } from "../src/plugin/quota";
|
|
21
|
-
import { verifyAccountAccess, markStoredAccountVerificationRequired, clearStoredAccountVerificationRequired, promptAccountIndexForVerification } from "./menu-helpers";
|
|
22
|
-
import { exec } from "node:child_process";
|
|
23
|
-
import { homedir } from "node:os";
|
|
24
|
-
import { join } from "node:path";
|
|
25
|
-
import { existsSync } from "node:fs";
|
|
26
|
-
let _syncMod = null;
|
|
27
|
-
try {
|
|
28
|
-
const hubSyncPath = join(homedir(), ".claude", "repos", "intisy", "claude-hub", "core", "account-sync.js");
|
|
29
|
-
if (existsSync(hubSyncPath)) {
|
|
30
|
-
_syncMod = await import(hubSyncPath);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch { }
|
|
34
|
-
function syncBeforeRead() { try {
|
|
35
|
-
_syncMod?.syncBeforeRead();
|
|
36
|
-
}
|
|
37
|
-
catch { } }
|
|
38
|
-
function syncAfterWrite() { try {
|
|
39
|
-
_syncMod?.syncAfterWrite("cc");
|
|
40
|
-
}
|
|
41
|
-
catch { } }
|
|
42
|
-
const client = {
|
|
43
|
-
getPluginConfig: () => ({}),
|
|
44
|
-
updatePluginConfig: async () => { },
|
|
45
|
-
log: () => { },
|
|
46
|
-
warn: () => { },
|
|
47
|
-
error: () => { },
|
|
48
|
-
};
|
|
49
|
-
const providerId = "antigravity";
|
|
50
|
-
function openBrowser(url) {
|
|
51
|
-
const cmd = process.platform === "win32"
|
|
52
|
-
? `start "" "${url}"`
|
|
53
|
-
: process.platform === "darwin"
|
|
54
|
-
? `open "${url}"`
|
|
55
|
-
: `xdg-open "${url}"`;
|
|
56
|
-
exec(cmd, (err) => {
|
|
57
|
-
if (err) {
|
|
58
|
-
console.log(`\x1b[33mCould not open browser automatically.\x1b[0m`);
|
|
59
|
-
console.log(`Open this URL manually:\n ${url}\n`);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
async function addOneAccount() {
|
|
64
|
-
const projectId = await promptProjectId();
|
|
65
|
-
const listener = await startOAuthListener({ timeoutMs: 5 * 60 * 1000 });
|
|
66
|
-
const auth = await authorizeAntigravity(projectId);
|
|
67
|
-
console.log("\n\x1b[36mOpening browser for Google sign-in…\x1b[0m");
|
|
68
|
-
console.log(`If the browser doesn't open, visit:\n ${auth.url}\n`);
|
|
69
|
-
openBrowser(auth.url);
|
|
70
|
-
let callbackUrl;
|
|
71
|
-
try {
|
|
72
|
-
callbackUrl = await listener.waitForCallback();
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
console.error("\x1b[31mOAuth callback timed out or failed.\x1b[0m");
|
|
76
|
-
await listener.close();
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
await listener.close();
|
|
80
|
-
const code = callbackUrl.searchParams.get("code");
|
|
81
|
-
const state = callbackUrl.searchParams.get("state");
|
|
82
|
-
if (!code || !state) {
|
|
83
|
-
console.error("\x1b[31mMissing code or state in OAuth callback.\x1b[0m");
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
console.log("\x1b[36mExchanging authorization code…\x1b[0m");
|
|
87
|
-
const result = await exchangeAntigravity(code, state);
|
|
88
|
-
if (result.type === "failed") {
|
|
89
|
-
console.error(`\x1b[31mToken exchange failed: ${result.error}\x1b[0m`);
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
const existing = await loadAccounts();
|
|
93
|
-
const accounts = existing?.accounts ?? [];
|
|
94
|
-
const duplicate = accounts.findIndex((a) => a.email === result.email);
|
|
95
|
-
if (duplicate >= 0) {
|
|
96
|
-
console.log(`\x1b[33mAccount ${result.email} already exists — updating tokens.\x1b[0m`);
|
|
97
|
-
accounts[duplicate] = {
|
|
98
|
-
...accounts[duplicate],
|
|
99
|
-
refreshToken: result.refresh,
|
|
100
|
-
projectId: result.projectId,
|
|
101
|
-
lastUsed: Date.now(),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
accounts.push({
|
|
106
|
-
email: result.email,
|
|
107
|
-
refreshToken: result.refresh,
|
|
108
|
-
projectId: result.projectId,
|
|
109
|
-
addedAt: Date.now(),
|
|
110
|
-
lastUsed: Date.now(),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
await saveAccounts({
|
|
114
|
-
version: 4,
|
|
115
|
-
accounts,
|
|
116
|
-
activeIndex: existing?.activeIndex ?? 0,
|
|
117
|
-
activeIndexByFamily: existing?.activeIndexByFamily,
|
|
118
|
-
});
|
|
119
|
-
console.log(`\x1b[32m✓ Account ${result.email ?? "(unknown)"} saved successfully!\x1b[0m`);
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
function formatWaitTime(ms) {
|
|
123
|
-
const seconds = Math.ceil(ms / 1000);
|
|
124
|
-
if (seconds < 60)
|
|
125
|
-
return `${seconds}s`;
|
|
126
|
-
const minutes = Math.floor(seconds / 60);
|
|
127
|
-
if (minutes < 60)
|
|
128
|
-
return `${minutes}m`;
|
|
129
|
-
return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
|
|
130
|
-
}
|
|
131
|
-
function getColor(remaining) {
|
|
132
|
-
if (typeof remaining !== 'number')
|
|
133
|
-
return '\x1b[0m';
|
|
134
|
-
if (remaining < 0.2)
|
|
135
|
-
return '\x1b[31m';
|
|
136
|
-
if (remaining < 0.6)
|
|
137
|
-
return '\x1b[33m';
|
|
138
|
-
return '\x1b[32m';
|
|
139
|
-
}
|
|
140
|
-
function createProgressBar(remaining, width = 20) {
|
|
141
|
-
if (typeof remaining !== 'number')
|
|
142
|
-
return '░'.repeat(width) + ' ???';
|
|
143
|
-
const filled = Math.round(remaining * width);
|
|
144
|
-
const empty = width - filled;
|
|
145
|
-
const color = getColor(remaining);
|
|
146
|
-
const bar = `${color}${'█'.repeat(filled)}\x1b[0m${'░'.repeat(empty)}`;
|
|
147
|
-
const pct = `${color}${Math.round(remaining * 100)}%\x1b[0m`.padStart(4 + color.length + '\x1b[0m'.length);
|
|
148
|
-
return `${bar} ${pct}`;
|
|
149
|
-
}
|
|
150
|
-
function formatReset(resetTime) {
|
|
151
|
-
if (!resetTime)
|
|
152
|
-
return '';
|
|
153
|
-
const ms = Date.parse(resetTime) - Date.now();
|
|
154
|
-
if (ms <= 0)
|
|
155
|
-
return ' (resetting...)';
|
|
156
|
-
const hours = ms / (1000 * 60 * 60);
|
|
157
|
-
if (hours >= 24) {
|
|
158
|
-
const days = Math.floor(hours / 24);
|
|
159
|
-
const remainingHours = Math.floor(hours % 24);
|
|
160
|
-
if (remainingHours > 0) {
|
|
161
|
-
return ` (resets in ${days}d ${remainingHours}h)`;
|
|
162
|
-
}
|
|
163
|
-
return ` (resets in ${days}d)`;
|
|
164
|
-
}
|
|
165
|
-
return ` (resets in ${formatWaitTime(ms)})`;
|
|
166
|
-
}
|
|
167
|
-
async function main() {
|
|
168
|
-
console.log("\x1b[1m\x1b[36m⚡🚀 Antigravity Account Login 🚀⚡\x1b[0m\n");
|
|
169
|
-
while (true) {
|
|
170
|
-
const existingStorage = await loadAccounts();
|
|
171
|
-
const accountsData = existingStorage?.accounts ?? [];
|
|
172
|
-
const activeIndex = existingStorage?.activeIndex ?? 0;
|
|
173
|
-
const existingAccounts = accountsData.map((acc, idx) => {
|
|
174
|
-
let status = 'active';
|
|
175
|
-
const now = Date.now();
|
|
176
|
-
if (acc.verificationRequired) {
|
|
177
|
-
status = 'verification-required';
|
|
178
|
-
}
|
|
179
|
-
else if (acc.tokenExpired) {
|
|
180
|
-
status = 'expired';
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
const rateLimits = acc.rateLimitResetTimes;
|
|
184
|
-
if (rateLimits) {
|
|
185
|
-
const isRateLimited = Object.values(rateLimits).some((resetTime) => typeof resetTime === 'number' && resetTime > now);
|
|
186
|
-
if (isRateLimited) {
|
|
187
|
-
status = 'rate-limited';
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (acc.coolingDownUntil && acc.coolingDownUntil > now) {
|
|
191
|
-
status = 'rate-limited';
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return {
|
|
195
|
-
email: acc.email,
|
|
196
|
-
index: idx,
|
|
197
|
-
addedAt: acc.addedAt,
|
|
198
|
-
lastUsed: acc.lastUsed,
|
|
199
|
-
status,
|
|
200
|
-
isCurrentAccount: idx === activeIndex,
|
|
201
|
-
enabled: acc.enabled !== false,
|
|
202
|
-
};
|
|
203
|
-
});
|
|
204
|
-
const menuResult = await promptLoginMode(existingAccounts);
|
|
205
|
-
if (menuResult.mode === "cancel") {
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
if (menuResult.mode === "add") {
|
|
209
|
-
if (menuResult.deleteAccountIndex !== undefined) {
|
|
210
|
-
const idx = menuResult.deleteAccountIndex;
|
|
211
|
-
const acc = accountsData[idx];
|
|
212
|
-
if (acc) {
|
|
213
|
-
accountsData.splice(idx, 1);
|
|
214
|
-
let newActiveIndex = activeIndex;
|
|
215
|
-
if (activeIndex === idx)
|
|
216
|
-
newActiveIndex = 0;
|
|
217
|
-
else if (activeIndex > idx)
|
|
218
|
-
newActiveIndex--;
|
|
219
|
-
await saveAccounts({
|
|
220
|
-
...existingStorage,
|
|
221
|
-
accounts: accountsData,
|
|
222
|
-
activeIndex: newActiveIndex,
|
|
223
|
-
});
|
|
224
|
-
console.log(`\nDeleted account ${acc.email || idx + 1}.\n`);
|
|
225
|
-
}
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
if (menuResult.refreshAccountIndex !== undefined) {
|
|
229
|
-
console.log("\n\x1b[36mRe-authenticating account...\x1b[0m");
|
|
230
|
-
}
|
|
231
|
-
const ok = await addOneAccount();
|
|
232
|
-
if (ok) {
|
|
233
|
-
while (await promptAddAnotherAccount(accountsData.length + 1)) {
|
|
234
|
-
await addOneAccount();
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (menuResult.mode === "fresh") {
|
|
240
|
-
if (menuResult.deleteAll) {
|
|
241
|
-
await saveAccounts({ version: 4, accounts: [], activeIndex: 0 });
|
|
242
|
-
console.log("\n\x1b[32m✓ All accounts deleted.\x1b[0m\n");
|
|
243
|
-
}
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
if (menuResult.mode === "check") {
|
|
247
|
-
console.log("\n📊 Checking quotas for all accounts...\n");
|
|
248
|
-
const results = await checkAccountsQuota(accountsData, client, providerId);
|
|
249
|
-
let storageUpdated = false;
|
|
250
|
-
for (const res of results) {
|
|
251
|
-
const label = res.email || `Account ${res.index + 1}`;
|
|
252
|
-
const disabledStr = res.disabled ? " (disabled)" : "";
|
|
253
|
-
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
|
|
254
|
-
console.log(` ${label}${disabledStr}`);
|
|
255
|
-
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
|
|
256
|
-
if (res.status === "error") {
|
|
257
|
-
console.log(` ❌ Error: ${res.error}\n`);
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
const hasGeminiCli = res.geminiCliQuota && res.geminiCliQuota.models.length > 0;
|
|
261
|
-
console.log(`\n ┌─ Gemini CLI Quota`);
|
|
262
|
-
if (!hasGeminiCli) {
|
|
263
|
-
console.log(` │ └─ ${res.geminiCliQuota?.error || "No Gemini CLI quota available"}`);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
const models = res.geminiCliQuota.models;
|
|
267
|
-
models.forEach((model, idx) => {
|
|
268
|
-
const connector = idx === models.length - 1 ? "└─" : "├─";
|
|
269
|
-
const bar = createProgressBar(model.remainingFraction);
|
|
270
|
-
const reset = formatReset(model.resetTime);
|
|
271
|
-
console.log(` │ ${connector} ${model.modelId.padEnd(29)} ${bar}${reset}`);
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
const hasAntigravity = res.quota && Object.keys(res.quota.groups).length > 0;
|
|
275
|
-
console.log(` │`);
|
|
276
|
-
console.log(` └─ Antigravity Quota`);
|
|
277
|
-
if (!hasAntigravity) {
|
|
278
|
-
console.log(` └─ ${res.quota?.error || "No quota information available"}`);
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
const groups = res.quota.groups;
|
|
282
|
-
const groupEntries = [
|
|
283
|
-
{ name: "Claude", data: groups.claude },
|
|
284
|
-
{ name: "Gemini 3 Pro", data: groups["gemini-pro"] },
|
|
285
|
-
{ name: "Gemini 3 Flash", data: groups["gemini-flash"] },
|
|
286
|
-
].filter(g => g.data);
|
|
287
|
-
groupEntries.forEach((g, idx) => {
|
|
288
|
-
const connector = idx === groupEntries.length - 1 ? "└─" : "├─";
|
|
289
|
-
const bar = createProgressBar(g.data.remainingFraction);
|
|
290
|
-
const reset = formatReset(g.data.resetTime);
|
|
291
|
-
console.log(` ${connector} ${g.name.padEnd(29)} ${bar}${reset}`);
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
console.log("");
|
|
295
|
-
if (res.quota?.groups || res.updatedAccount) {
|
|
296
|
-
const acc = accountsData[res.index];
|
|
297
|
-
if (acc) {
|
|
298
|
-
accountsData[res.index] = {
|
|
299
|
-
...acc,
|
|
300
|
-
...(res.updatedAccount || {}),
|
|
301
|
-
cachedQuota: res.quota?.groups,
|
|
302
|
-
cachedQuotaUpdatedAt: Date.now(),
|
|
303
|
-
};
|
|
304
|
-
storageUpdated = true;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
if (storageUpdated && existingStorage) {
|
|
309
|
-
await saveAccounts({ ...existingStorage, accounts: accountsData });
|
|
310
|
-
}
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
if (menuResult.mode === "manage") {
|
|
314
|
-
if (menuResult.toggleAccountIndex !== undefined) {
|
|
315
|
-
const acc = accountsData[menuResult.toggleAccountIndex];
|
|
316
|
-
if (acc && existingStorage) {
|
|
317
|
-
acc.enabled = acc.enabled === false;
|
|
318
|
-
await saveAccounts({ ...existingStorage, accounts: accountsData });
|
|
319
|
-
console.log(`\nAccount ${acc.email || menuResult.toggleAccountIndex + 1} ${acc.enabled ? 'enabled' : 'disabled'}.\n`);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
if (menuResult.mode === "proxies") {
|
|
325
|
-
const { loadProxyConfig, saveProxyConfig } = await import("../src/plugin/proxy-config");
|
|
326
|
-
const { select } = await import("../src/plugin/ui/select");
|
|
327
|
-
const config = loadProxyConfig();
|
|
328
|
-
const strategy = await select([
|
|
329
|
-
{ label: `Automatic${config.strategy === 'automatic' ? ' (current)' : ''}`, value: 'automatic', hint: 'Uses background hot-pool from multiple providers', color: 'cyan' },
|
|
330
|
-
{ label: `Manual${config.strategy === 'manual' ? ' (current)' : ''}`, value: 'manual', hint: 'Uses manually added proxies per account', color: 'cyan' },
|
|
331
|
-
{ label: `Disabled${config.strategy === 'disabled' ? ' (current)' : ''}`, value: 'disabled', hint: 'Direct connection', color: 'cyan' },
|
|
332
|
-
{ label: '', value: 'back', separator: true },
|
|
333
|
-
{ label: 'Back', value: 'back', color: 'yellow' }
|
|
334
|
-
], { message: 'Select Global Proxy Strategy', clearScreen: true });
|
|
335
|
-
if (strategy && strategy !== 'back') {
|
|
336
|
-
config.strategy = strategy;
|
|
337
|
-
saveProxyConfig(config);
|
|
338
|
-
console.log(`\n✓ Proxy strategy updated to: ${strategy}\n`);
|
|
339
|
-
}
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
if (menuResult.mode === "proxy_providers") {
|
|
343
|
-
const { loadProxyConfig, saveProxyConfig } = await import("../src/plugin/proxy-config");
|
|
344
|
-
const { select } = await import("../src/plugin/ui/select");
|
|
345
|
-
while (true) {
|
|
346
|
-
const config = loadProxyConfig();
|
|
347
|
-
const providerItems = Object.entries(config.providers).map(([name, p]) => ({
|
|
348
|
-
label: name + (p.enabled ? " [\x1b[32mON\x1b[0m]" : " [\x1b[31mOFF\x1b[0m]"),
|
|
349
|
-
hint: p.apiKey ? "(Key Set)" : "(No Key)",
|
|
350
|
-
value: name
|
|
351
|
-
}));
|
|
352
|
-
providerItems.push({ label: "", value: "back", separator: true });
|
|
353
|
-
providerItems.push({ label: "Back", value: "back", color: "yellow" });
|
|
354
|
-
const chosenProvider = await select(providerItems, { message: "Select a Provider to configure", clearScreen: true });
|
|
355
|
-
if (!chosenProvider || chosenProvider === "back")
|
|
356
|
-
break;
|
|
357
|
-
const prov = config.providers[chosenProvider];
|
|
358
|
-
if (prov) {
|
|
359
|
-
const action = await select([
|
|
360
|
-
{ label: prov.enabled ? "Disable Provider" : "Enable Provider", value: "toggle" },
|
|
361
|
-
{ label: "Set API Key / Proxy List URL", value: "setkey" },
|
|
362
|
-
{ label: "Back", value: "back", color: "yellow" }
|
|
363
|
-
], { message: `Configure ${chosenProvider}`, clearScreen: true });
|
|
364
|
-
if (action === "toggle") {
|
|
365
|
-
prov.enabled = !prov.enabled;
|
|
366
|
-
saveProxyConfig(config);
|
|
367
|
-
}
|
|
368
|
-
else if (action === "setkey") {
|
|
369
|
-
const readline = await import("readline");
|
|
370
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
371
|
-
const newKey = await new Promise(resolve => rl.question('Enter API Key or URL for ' + chosenProvider + ' (leave empty to cancel): ', resolve));
|
|
372
|
-
rl.close();
|
|
373
|
-
if (newKey && newKey.trim()) {
|
|
374
|
-
prov.apiKey = newKey.trim();
|
|
375
|
-
saveProxyConfig(config);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
if (menuResult.mode === "verify" || menuResult.mode === "verify-all") {
|
|
383
|
-
const verifyAll = menuResult.mode === "verify-all" || menuResult.verifyAll === true;
|
|
384
|
-
if (verifyAll) {
|
|
385
|
-
if (accountsData.length === 0) {
|
|
386
|
-
console.log("\nNo accounts available to verify.\n");
|
|
387
|
-
continue;
|
|
388
|
-
}
|
|
389
|
-
console.log(`\nChecking verification status for ${accountsData.length} account(s)...\n`);
|
|
390
|
-
let okCount = 0, blockedCount = 0, errorCount = 0;
|
|
391
|
-
let storageUpdated = false;
|
|
392
|
-
const blockedResults = [];
|
|
393
|
-
for (let i = 0; i < accountsData.length; i++) {
|
|
394
|
-
const account = accountsData[i];
|
|
395
|
-
if (!account)
|
|
396
|
-
continue;
|
|
397
|
-
const label = account.email || `Account ${i + 1}`;
|
|
398
|
-
process.stdout.write(`- [${i + 1}/${accountsData.length}] ${label} ... `);
|
|
399
|
-
const verification = await verifyAccountAccess(account, client, providerId);
|
|
400
|
-
if (verification.status === "ok") {
|
|
401
|
-
const { changed } = clearStoredAccountVerificationRequired(account, true);
|
|
402
|
-
if (changed)
|
|
403
|
-
storageUpdated = true;
|
|
404
|
-
okCount += 1;
|
|
405
|
-
console.log("ok");
|
|
406
|
-
continue;
|
|
407
|
-
}
|
|
408
|
-
if (verification.status === "blocked") {
|
|
409
|
-
const changed = markStoredAccountVerificationRequired(account, verification.message, verification.verifyUrl);
|
|
410
|
-
if (changed)
|
|
411
|
-
storageUpdated = true;
|
|
412
|
-
blockedCount += 1;
|
|
413
|
-
console.log("needs verification");
|
|
414
|
-
blockedResults.push({
|
|
415
|
-
label,
|
|
416
|
-
message: verification.message,
|
|
417
|
-
verifyUrl: verification.verifyUrl ?? account.verificationUrl,
|
|
418
|
-
});
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
errorCount += 1;
|
|
422
|
-
console.log(`error (${verification.message})`);
|
|
423
|
-
}
|
|
424
|
-
if (storageUpdated && existingStorage) {
|
|
425
|
-
await saveAccounts({ ...existingStorage, accounts: accountsData });
|
|
426
|
-
}
|
|
427
|
-
console.log(`\nVerification summary: ${okCount} ready, ${blockedCount} need verification, ${errorCount} errors.`);
|
|
428
|
-
if (blockedResults.length > 0) {
|
|
429
|
-
console.log("\nAccounts needing verification:");
|
|
430
|
-
for (const result of blockedResults) {
|
|
431
|
-
console.log(`\n- ${result.label}\n ${result.message}\n URL: ${result.verifyUrl || "not provided by API response"}`);
|
|
432
|
-
}
|
|
433
|
-
console.log("");
|
|
434
|
-
}
|
|
435
|
-
else
|
|
436
|
-
console.log("");
|
|
437
|
-
continue;
|
|
438
|
-
}
|
|
439
|
-
let verifyAccountIndex = menuResult.verifyAccountIndex;
|
|
440
|
-
if (verifyAccountIndex === undefined) {
|
|
441
|
-
verifyAccountIndex = await promptAccountIndexForVerification(existingAccounts);
|
|
442
|
-
}
|
|
443
|
-
if (verifyAccountIndex === undefined) {
|
|
444
|
-
console.log("\nVerification cancelled.\n");
|
|
445
|
-
continue;
|
|
446
|
-
}
|
|
447
|
-
const account = accountsData[verifyAccountIndex];
|
|
448
|
-
if (!account) {
|
|
449
|
-
console.log(`\nAccount ${verifyAccountIndex + 1} not found.\n`);
|
|
450
|
-
continue;
|
|
451
|
-
}
|
|
452
|
-
const label = account.email || `Account ${verifyAccountIndex + 1}`;
|
|
453
|
-
console.log(`\nChecking verification status for ${label}...\n`);
|
|
454
|
-
const verification = await verifyAccountAccess(account, client, providerId);
|
|
455
|
-
if (verification.status === "ok") {
|
|
456
|
-
const { changed, wasVerificationRequired } = clearStoredAccountVerificationRequired(account, true);
|
|
457
|
-
if (changed && existingStorage) {
|
|
458
|
-
await saveAccounts({ ...existingStorage, accounts: accountsData });
|
|
459
|
-
}
|
|
460
|
-
console.log(`✓ ${label} is ready for requests${wasVerificationRequired ? ' and has been re-enabled' : ''}.\n`);
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
if (verification.status === "blocked") {
|
|
464
|
-
const changed = markStoredAccountVerificationRequired(account, verification.message, verification.verifyUrl);
|
|
465
|
-
if (changed && existingStorage) {
|
|
466
|
-
await saveAccounts({ ...existingStorage, accounts: accountsData });
|
|
467
|
-
}
|
|
468
|
-
console.log(`\n⚠️ Verification Required for ${label}`);
|
|
469
|
-
console.log(`\n${verification.message}`);
|
|
470
|
-
console.log(`\nPlease visit this URL to verify your account:\n ${verification.verifyUrl ?? account.verificationUrl}\n`);
|
|
471
|
-
continue;
|
|
472
|
-
}
|
|
473
|
-
console.log(`\n❌ Error verifying account: ${verification.message}\n`);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
main().catch((err) => {
|
|
478
|
-
console.error("\x1b[31mFatal error:\x1b[0m", err);
|
|
479
|
-
process.exit(1);
|
|
480
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PluginClient } from "../src/plugin/types";
|
|
2
|
-
export interface VerificationProbeResult {
|
|
3
|
-
status: "ok" | "blocked" | "error";
|
|
4
|
-
message: string;
|
|
5
|
-
verifyUrl?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function verifyAccountAccess(account: {
|
|
8
|
-
refreshToken: string;
|
|
9
|
-
email?: string;
|
|
10
|
-
projectId?: string;
|
|
11
|
-
managedProjectId?: string;
|
|
12
|
-
verificationUrl?: string;
|
|
13
|
-
}, client: PluginClient, providerId: string): Promise<VerificationProbeResult>;
|
|
14
|
-
export declare function promptAccountIndexForVerification(accounts: Array<{
|
|
15
|
-
email?: string;
|
|
16
|
-
index: number;
|
|
17
|
-
}>): Promise<number | undefined>;
|
|
18
|
-
export declare function markStoredAccountVerificationRequired(account: any, message: string, verifyUrl?: string): boolean;
|
|
19
|
-
export declare function clearStoredAccountVerificationRequired(account: any, reEnable?: boolean): {
|
|
20
|
-
changed: boolean;
|
|
21
|
-
wasVerificationRequired: boolean;
|
|
22
|
-
};
|