gemix 0.0.2 → 0.1.0
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/{doc/README.md → README.md} +11 -0
- package/dist/auth/oauth.d.ts +13 -0
- package/dist/auth/oauth.d.ts.map +1 -1
- package/dist/auth/oauth.js +63 -0
- package/dist/auth/oauth.js.map +1 -1
- package/dist/commands/dash.d.ts +2 -0
- package/dist/commands/dash.d.ts.map +1 -0
- package/dist/commands/dash.js +125 -0
- package/dist/commands/dash.js.map +1 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/server/public/app.js +181 -0
- package/dist/server/public/index.html +77 -0
- package/dist/server/public/style.css +132 -0
- package/dist/server/quota.d.ts +22 -0
- package/dist/server/quota.d.ts.map +1 -0
- package/dist/server/quota.js +69 -0
- package/dist/server/quota.js.map +1 -0
- package/dist/server/server.d.ts +11 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +170 -0
- package/dist/server/server.js.map +1 -0
- package/package.json +13 -7
- package/src/auth/oauth.ts +0 -194
- package/src/commands/current.ts +0 -18
- package/src/commands/list.ts +0 -20
- package/src/commands/register.ts +0 -53
- package/src/commands/remove.ts +0 -37
- package/src/commands/use.ts +0 -25
- package/src/index.ts +0 -59
- package/src/storage/accounts.ts +0 -285
- package/src/storage/paths.ts +0 -56
- package/src/utils/table.ts +0 -58
- package/src/utils/validation.ts +0 -27
- package/tsconfig.json +0 -20
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* Square corners, roomy spacing. Colors = Gemini app's Material 3 palette, dark + light. */
|
|
2
|
+
:root, :root[data-theme="dark"] {
|
|
3
|
+
color-scheme: dark;
|
|
4
|
+
--background: #131314; --card: #1b1c1d; --panel: #232425;
|
|
5
|
+
--foreground: #e3e3e3; --muted-foreground: #a8abae;
|
|
6
|
+
--border: #2f3133; --border-strong: #444746; --track: #303234;
|
|
7
|
+
--primary: #a8c7fa; --primary-hover: #c2d7fb; --on-primary: #062e6f;
|
|
8
|
+
--destructive: #f2b8b5; --ok: #6dd58c; --warn: #fdd663;
|
|
9
|
+
--gemini: linear-gradient(90deg, #4285f4, #9b72cb, #d96570);
|
|
10
|
+
--mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
|
11
|
+
}
|
|
12
|
+
:root[data-theme="light"] {
|
|
13
|
+
color-scheme: light;
|
|
14
|
+
--background: #f8fafd; --card: #ffffff; --panel: #f0f4f9;
|
|
15
|
+
--foreground: #1f1f1f; --muted-foreground: #5f6368;
|
|
16
|
+
--border: #e1e5ea; --border-strong: #c4c7c5; --track: #e3e8ef;
|
|
17
|
+
--primary: #0b57d0; --primary-hover: #0842a0; --on-primary: #ffffff;
|
|
18
|
+
--destructive: #b3261e; --ok: #146c2e; --warn: #8a5a00;
|
|
19
|
+
}
|
|
20
|
+
@media (prefers-color-scheme: light) {
|
|
21
|
+
:root:not([data-theme]) {
|
|
22
|
+
color-scheme: light;
|
|
23
|
+
--background: #f8fafd; --card: #ffffff; --panel: #f0f4f9;
|
|
24
|
+
--foreground: #1f1f1f; --muted-foreground: #5f6368;
|
|
25
|
+
--border: #e1e5ea; --border-strong: #c4c7c5; --track: #e3e8ef;
|
|
26
|
+
--primary: #0b57d0; --primary-hover: #0842a0; --on-primary: #ffffff;
|
|
27
|
+
--destructive: #b3261e; --ok: #146c2e; --warn: #8a5a00;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
* { box-sizing: border-box; border-radius: 0; }
|
|
31
|
+
body { margin: 0; background: var(--background); color: var(--foreground);
|
|
32
|
+
font: 14px/1.55 Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
|
|
33
|
+
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 32px; }
|
|
34
|
+
.muted { color: var(--muted-foreground); }
|
|
35
|
+
.mono { font-family: var(--mono); font-size: 12px; }
|
|
36
|
+
.hidden { display: none; }
|
|
37
|
+
code { font-family: var(--mono); font-size: 12px; padding: 1px 6px; background: var(--panel); border: 1px solid var(--border); }
|
|
38
|
+
|
|
39
|
+
.topbar { border-bottom: 1px solid var(--border); }
|
|
40
|
+
.topbar .wrap { display: flex; justify-content: space-between; align-items: center; height: 60px; }
|
|
41
|
+
.wordmark { display: flex; align-items: center; gap: 10px; font: 700 15px var(--mono); letter-spacing: .18em; text-transform: uppercase; }
|
|
42
|
+
.wordmark::before { content: ""; width: 14px; height: 14px; background: var(--gemini); }
|
|
43
|
+
|
|
44
|
+
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; padding: 48px 0 28px; }
|
|
45
|
+
.pagehead h1 { margin: 0 0 6px; font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
|
|
46
|
+
.pagehead p { margin: 0; }
|
|
47
|
+
.actions { display: flex; align-items: center; gap: 10px; }
|
|
48
|
+
.actions .mono { margin-right: 8px; }
|
|
49
|
+
|
|
50
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; padding-bottom: 64px; }
|
|
51
|
+
|
|
52
|
+
.card { position: relative; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border);
|
|
53
|
+
transition: border-color .15s, box-shadow .15s; }
|
|
54
|
+
.card:hover { border-color: var(--border-strong); }
|
|
55
|
+
.card.active { border-color: color-mix(in srgb, var(--primary) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent); }
|
|
56
|
+
.card.active::before { content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 3px; background: var(--gemini); }
|
|
57
|
+
.card-head { display: flex; gap: 14px; align-items: center; padding: 24px 24px 0; }
|
|
58
|
+
.avatar { width: 44px; height: 44px; flex: none; object-fit: cover; background: var(--panel); }
|
|
59
|
+
.who { min-width: 0; flex: 1; }
|
|
60
|
+
.who b { display: block; font-size: 16px; font-weight: 600; }
|
|
61
|
+
.who span { display: block; font-size: 13px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
62
|
+
|
|
63
|
+
.badges { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 24px 0; }
|
|
64
|
+
.badge { font: 600 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px;
|
|
65
|
+
border: 1px solid var(--border-strong); color: var(--muted-foreground); }
|
|
66
|
+
.badge.primary { align-self: flex-start; background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
|
|
67
|
+
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
|
|
68
|
+
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
|
|
69
|
+
.badge.bad { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 35%, transparent); background: color-mix(in srgb, var(--destructive) 8%, transparent); }
|
|
70
|
+
|
|
71
|
+
.card-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 20px 24px 24px; }
|
|
72
|
+
.card-body > .muted { grid-column: 1 / -1; padding: 14px; background: var(--panel); border: 1px solid var(--border); }
|
|
73
|
+
.model { display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: 10px;
|
|
74
|
+
padding: 14px; background: var(--panel); border: 1px solid var(--border); }
|
|
75
|
+
.lbl { font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); }
|
|
76
|
+
.pct { font: 700 22px/1 var(--mono); }
|
|
77
|
+
.pct small { font-size: 11px; color: var(--muted-foreground); margin-left: 1px; }
|
|
78
|
+
.seg { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 8px; }
|
|
79
|
+
.seg i { background: var(--track); }
|
|
80
|
+
.reset { grid-column: 1 / -1; font-size: 12px; color: var(--muted-foreground); }
|
|
81
|
+
|
|
82
|
+
.card-foot { display: flex; align-items: center; gap: 6px; padding: 14px 24px; border-top: 1px solid var(--border); }
|
|
83
|
+
.card-foot .grow { flex: 1; }
|
|
84
|
+
.in-use { font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--primary); padding: 0 4px; }
|
|
85
|
+
|
|
86
|
+
.btn { height: 38px; padding: 0 16px; border: 1px solid var(--border-strong); background: transparent; color: var(--foreground);
|
|
87
|
+
font: 500 13px Inter, system-ui, sans-serif; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
|
|
88
|
+
.btn:hover:not(:disabled) { background: var(--panel); border-color: var(--muted-foreground); }
|
|
89
|
+
.btn:disabled { opacity: .4; cursor: not-allowed; }
|
|
90
|
+
.btn.default { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
|
|
91
|
+
.btn.default:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
|
|
92
|
+
.btn.destructive { background: var(--destructive); border-color: var(--destructive); color: var(--on-primary); }
|
|
93
|
+
.btn.ghost { border-color: transparent; color: var(--muted-foreground); }
|
|
94
|
+
.btn.ghost:hover:not(:disabled) { color: var(--foreground); background: var(--panel); border-color: transparent; }
|
|
95
|
+
.btn.ghost.danger:hover:not(:disabled) { color: var(--destructive); }
|
|
96
|
+
.btn.sm { height: 34px; padding: 0 12px; }
|
|
97
|
+
.btn:focus-visible, .input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
|
|
98
|
+
|
|
99
|
+
.skeleton { height: 290px; background: linear-gradient(90deg, var(--card), var(--panel), var(--card)); background-size: 200% 100%;
|
|
100
|
+
border: 1px solid var(--border); animation: sk 1.4s infinite; }
|
|
101
|
+
@keyframes sk { to { background-position: -200% 0; } }
|
|
102
|
+
.empty { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: var(--muted-foreground); border: 1px dashed var(--border-strong); }
|
|
103
|
+
|
|
104
|
+
.dialog { background: var(--card); color: var(--foreground); border: 1px solid var(--border-strong); padding: 28px; width: min(500px, 92vw); }
|
|
105
|
+
.dialog::backdrop { background: rgb(0 0 0 / .6); backdrop-filter: blur(2px); }
|
|
106
|
+
.dialog h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
|
|
107
|
+
.dialog > p { margin: 0; font-size: 13px; }
|
|
108
|
+
.label { display: block; margin: 18px 0 8px; font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); }
|
|
109
|
+
.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--background); color: var(--foreground); font: inherit; }
|
|
110
|
+
.input:focus { border-color: var(--primary); outline: none; }
|
|
111
|
+
.input.mono { font: 12px var(--mono); }
|
|
112
|
+
.row { display: flex; gap: 8px; } .row .input { flex: 1; min-width: 0; }
|
|
113
|
+
.footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 28px; }
|
|
114
|
+
|
|
115
|
+
.toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
|
|
116
|
+
.toast { background: var(--panel); border: 1px solid var(--border-strong); border-left: 3px solid var(--primary);
|
|
117
|
+
padding: 12px 16px; max-width: 360px; font-size: 13px; }
|
|
118
|
+
.toast.err { border-left-color: var(--destructive); }
|
|
119
|
+
|
|
120
|
+
@media (max-width: 640px) {
|
|
121
|
+
.wrap { padding: 0 16px; }
|
|
122
|
+
.grid { grid-template-columns: 1fr; }
|
|
123
|
+
.card-body { grid-template-columns: 1fr; }
|
|
124
|
+
}
|
|
125
|
+
.btn.use { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
|
|
126
|
+
.btn.use:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
|
|
127
|
+
.theme-toggle { display: flex; border: 1px solid var(--border-strong); }
|
|
128
|
+
.theme-toggle button { height: 30px; padding: 0 10px; border: 0; background: transparent; color: var(--muted-foreground);
|
|
129
|
+
font: 600 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
|
|
130
|
+
.theme-toggle button + button { border-left: 1px solid var(--border-strong); }
|
|
131
|
+
.theme-toggle button[aria-pressed="true"] { background: var(--panel); color: var(--foreground); }
|
|
132
|
+
.topbar .right { display: flex; align-items: center; gap: 16px; }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TokenData } from '../storage/accounts.js';
|
|
2
|
+
export interface ModelQuota {
|
|
3
|
+
id: string;
|
|
4
|
+
remaining: number;
|
|
5
|
+
resetTime: string | null;
|
|
6
|
+
}
|
|
7
|
+
export type QuotaResult = {
|
|
8
|
+
status: 'ok';
|
|
9
|
+
tier: string | null;
|
|
10
|
+
tokenExpiry: number;
|
|
11
|
+
models: ModelQuota[];
|
|
12
|
+
} | {
|
|
13
|
+
status: 'relogin';
|
|
14
|
+
} | {
|
|
15
|
+
status: 'error';
|
|
16
|
+
error: string;
|
|
17
|
+
tokenExpiry: number;
|
|
18
|
+
};
|
|
19
|
+
/** Returns a usable access token, refreshing (and persisting) if near expiry. null = dead login. */
|
|
20
|
+
export declare function freshToken(username: string): Promise<TokenData | null>;
|
|
21
|
+
export declare function fetchQuota(username: string): Promise<QuotaResult>;
|
|
22
|
+
//# sourceMappingURL=quota.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../../src/server/quota.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAmBxD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAAE,GAChF;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAgB5D,oGAAoG;AACpG,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAU5E;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8BvE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches per-model weekly quota info from Google's Cloud Code API.
|
|
3
|
+
* Same data source as `agy /usage` — weekly buckets via retrieveUserQuota.
|
|
4
|
+
*/
|
|
5
|
+
import { loadTokens, saveTokens } from '../storage/accounts.js';
|
|
6
|
+
import { refreshTokens } from '../auth/oauth.js';
|
|
7
|
+
const HOST = 'https://daily-cloudcode-pa.googleapis.com/v1internal:';
|
|
8
|
+
async function call(method, token, body) {
|
|
9
|
+
const r = await fetch(HOST + method, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${token}`,
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
'User-Agent': 'antigravity',
|
|
15
|
+
},
|
|
16
|
+
body: JSON.stringify(body),
|
|
17
|
+
});
|
|
18
|
+
if (!r.ok)
|
|
19
|
+
throw new Error(`${method} ${r.status}`);
|
|
20
|
+
return r.json();
|
|
21
|
+
}
|
|
22
|
+
/** Returns a usable access token, refreshing (and persisting) if near expiry. null = dead login. */
|
|
23
|
+
export async function freshToken(username) {
|
|
24
|
+
let t = await loadTokens(username);
|
|
25
|
+
if (!t)
|
|
26
|
+
return null;
|
|
27
|
+
if (!t.expiry_date || t.expiry_date - Date.now() < 5 * 60 * 1000) {
|
|
28
|
+
const n = await refreshTokens(t);
|
|
29
|
+
if (!n)
|
|
30
|
+
return null;
|
|
31
|
+
t = n;
|
|
32
|
+
await saveTokens(username, t);
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
export async function fetchQuota(username) {
|
|
37
|
+
const t = await freshToken(username);
|
|
38
|
+
if (!t)
|
|
39
|
+
return { status: 'relogin' };
|
|
40
|
+
try {
|
|
41
|
+
const a = await call('loadCodeAssist', t.access_token, {
|
|
42
|
+
metadata: { ideType: 'ANTIGRAVITY', platform: 'PLATFORM_UNSPECIFIED', pluginType: 'GEMINI' },
|
|
43
|
+
});
|
|
44
|
+
const q = await call('retrieveUserQuota', t.access_token, {
|
|
45
|
+
project: a.cloudaicompanionProject,
|
|
46
|
+
});
|
|
47
|
+
const models = (q.buckets || [])
|
|
48
|
+
.filter((b) => /^(gemini|claude|gpt)/i.test(b.modelId)) // skip internal chat_*/tab_* buckets
|
|
49
|
+
.map((b) => ({
|
|
50
|
+
id: b.modelId,
|
|
51
|
+
remaining: b.remainingFraction ?? 0,
|
|
52
|
+
resetTime: b.resetTime || null,
|
|
53
|
+
}));
|
|
54
|
+
return {
|
|
55
|
+
status: 'ok',
|
|
56
|
+
tier: a.currentTier?.id || null,
|
|
57
|
+
tokenExpiry: t.expiry_date,
|
|
58
|
+
models,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
return {
|
|
63
|
+
status: 'error',
|
|
64
|
+
error: e instanceof Error ? e.message : String(e),
|
|
65
|
+
tokenExpiry: t.expiry_date,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=quota.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.js","sourceRoot":"","sources":["../../src/server/quota.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,IAA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
|
|
|
1
|
+
/**
|
|
2
|
+
* Local HTTP server for the gemix dashboard.
|
|
3
|
+
* Serves static files from ./public/ and handles /api/* REST endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Ported from gemix-dash/server.mjs — all lib/ imports replaced with
|
|
6
|
+
* gemix's own storage/auth/utils modules.
|
|
7
|
+
*/
|
|
8
|
+
import http from 'node:http';
|
|
9
|
+
export declare const PORT: number;
|
|
10
|
+
export declare const server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
11
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAmB7B,eAAO,MAAM,IAAI,QAAmC,CAAC;AA4IrD,eAAO,MAAM,MAAM,sEAmBjB,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local HTTP server for the gemix dashboard.
|
|
3
|
+
* Serves static files from ./public/ and handles /api/* REST endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Ported from gemix-dash/server.mjs — all lib/ imports replaced with
|
|
6
|
+
* gemix's own storage/auth/utils modules.
|
|
7
|
+
*/
|
|
8
|
+
import http from 'node:http';
|
|
9
|
+
import { promises as fs } from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import crypto from 'node:crypto';
|
|
13
|
+
import { loadAccounts, saveAccounts, addAccount, removeAccount, switchAccount, getActiveUsername, setActiveUsername, } from '../storage/accounts.js';
|
|
14
|
+
import { getAccountDir } from '../storage/paths.js';
|
|
15
|
+
import { buildAuthUrl, exchangeCode } from '../auth/oauth.js';
|
|
16
|
+
import { fetchQuota } from './quota.js';
|
|
17
|
+
import { validateUsername } from '../utils/validation.js';
|
|
18
|
+
export const PORT = Number(process.env.PORT || 4577);
|
|
19
|
+
const PUBLIC = path.join(path.dirname(fileURLToPath(import.meta.url)), 'public');
|
|
20
|
+
const MIME = {
|
|
21
|
+
'.html': 'text/html',
|
|
22
|
+
'.js': 'text/javascript',
|
|
23
|
+
'.css': 'text/css',
|
|
24
|
+
};
|
|
25
|
+
const CACHE_MS = 60_000;
|
|
26
|
+
const quotaCache = new Map();
|
|
27
|
+
const pending = new Map();
|
|
28
|
+
const send = (res, code, body) => {
|
|
29
|
+
res.writeHead(code, { 'Content-Type': 'application/json' });
|
|
30
|
+
res.end(JSON.stringify(body));
|
|
31
|
+
};
|
|
32
|
+
/** Block DNS-rebinding / cross-site calls: only loopback Host, Origin must match if sent. */
|
|
33
|
+
const hostOk = (req) => {
|
|
34
|
+
const h = (req.headers.host || '').replace(/:\d+$/, '');
|
|
35
|
+
if (h !== '127.0.0.1' && h !== 'localhost')
|
|
36
|
+
return false;
|
|
37
|
+
const o = req.headers.origin;
|
|
38
|
+
return !o || o === `http://${req.headers.host}`;
|
|
39
|
+
};
|
|
40
|
+
const readJson = async (req) => {
|
|
41
|
+
let s = '';
|
|
42
|
+
for await (const c of req) {
|
|
43
|
+
s += c;
|
|
44
|
+
if (s.length > 1e5)
|
|
45
|
+
throw new Error('too large');
|
|
46
|
+
}
|
|
47
|
+
return s ? JSON.parse(s) : {};
|
|
48
|
+
};
|
|
49
|
+
async function quotaFor(name, force) {
|
|
50
|
+
const hit = quotaCache.get(name);
|
|
51
|
+
if (!force && hit && Date.now() - hit.at < CACHE_MS)
|
|
52
|
+
return hit.data;
|
|
53
|
+
const data = await fetchQuota(name);
|
|
54
|
+
quotaCache.set(name, { at: Date.now(), data });
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
async function listAccounts(force) {
|
|
58
|
+
const { accounts } = await loadAccounts();
|
|
59
|
+
const active = (await getActiveUsername())?.trim() || null;
|
|
60
|
+
const out = await Promise.all(Object.entries(accounts).map(async ([username, a]) => ({
|
|
61
|
+
username,
|
|
62
|
+
email: a.email,
|
|
63
|
+
name: a.name,
|
|
64
|
+
picture: a.picture,
|
|
65
|
+
created: a.created,
|
|
66
|
+
lastUsed: a.lastUsed,
|
|
67
|
+
active: username === active,
|
|
68
|
+
quota: await quotaFor(username, force),
|
|
69
|
+
})));
|
|
70
|
+
return { active, accounts: out };
|
|
71
|
+
}
|
|
72
|
+
async function rename(oldName, newName) {
|
|
73
|
+
const v = validateUsername(newName);
|
|
74
|
+
if (!v.valid)
|
|
75
|
+
throw Object.assign(new Error(v.error), { code: 400 });
|
|
76
|
+
const data = await loadAccounts();
|
|
77
|
+
if (!data.accounts[oldName])
|
|
78
|
+
throw Object.assign(new Error('not found'), { code: 404 });
|
|
79
|
+
if (data.accounts[newName])
|
|
80
|
+
throw Object.assign(new Error('name taken'), { code: 409 });
|
|
81
|
+
await fs.rename(getAccountDir(oldName), getAccountDir(newName));
|
|
82
|
+
data.accounts[newName] = data.accounts[oldName];
|
|
83
|
+
delete data.accounts[oldName];
|
|
84
|
+
if (data.active === oldName)
|
|
85
|
+
data.active = newName;
|
|
86
|
+
await saveAccounts(data);
|
|
87
|
+
if ((await getActiveUsername())?.trim() === oldName)
|
|
88
|
+
await setActiveUsername(newName);
|
|
89
|
+
quotaCache.delete(oldName);
|
|
90
|
+
}
|
|
91
|
+
async function api(req, res, url) {
|
|
92
|
+
const m = req.method;
|
|
93
|
+
const seg = url.pathname.split('/').filter(Boolean); // ['api','accounts',name?,action?]
|
|
94
|
+
const name = seg[2] && decodeURIComponent(seg[2]);
|
|
95
|
+
if (m === 'GET' && url.pathname === '/api/accounts') {
|
|
96
|
+
return send(res, 200, await listAccounts(url.searchParams.get('refresh') === '1'));
|
|
97
|
+
}
|
|
98
|
+
if (m === 'POST' && url.pathname === '/api/auth-url') {
|
|
99
|
+
const { url: authUrl, codeVerifier } = buildAuthUrl();
|
|
100
|
+
const id = crypto.randomUUID();
|
|
101
|
+
// Expire sessions older than 10 minutes
|
|
102
|
+
for (const [k, v] of pending) {
|
|
103
|
+
if (Date.now() - v.at > 10 * 60_000)
|
|
104
|
+
pending.delete(k);
|
|
105
|
+
}
|
|
106
|
+
pending.set(id, { codeVerifier, at: Date.now() });
|
|
107
|
+
return send(res, 200, { id, url: authUrl });
|
|
108
|
+
}
|
|
109
|
+
if (m === 'POST' && url.pathname === '/api/accounts') {
|
|
110
|
+
const { name: n, code, id } = (await readJson(req));
|
|
111
|
+
if (!n)
|
|
112
|
+
return send(res, 400, { error: 'name required' });
|
|
113
|
+
const v = validateUsername(n);
|
|
114
|
+
if (!v.valid)
|
|
115
|
+
return send(res, 400, { error: v.error });
|
|
116
|
+
if ((await loadAccounts()).accounts[n]) {
|
|
117
|
+
return send(res, 409, { error: `'${n}' already exists` });
|
|
118
|
+
}
|
|
119
|
+
const sess = id ? pending.get(id) : undefined;
|
|
120
|
+
if (!sess || !code?.trim()) {
|
|
121
|
+
return send(res, 400, { error: 'Auth session expired, reopen the link' });
|
|
122
|
+
}
|
|
123
|
+
const r = await exchangeCode(code.trim(), sess.codeVerifier);
|
|
124
|
+
pending.delete(id);
|
|
125
|
+
await addAccount(n, r.email, r.name, r.picture, r.tokens);
|
|
126
|
+
return send(res, 200, { ok: true, email: r.email });
|
|
127
|
+
}
|
|
128
|
+
if (name && m === 'POST' && seg[3] === 'switch') {
|
|
129
|
+
return (await switchAccount(name))
|
|
130
|
+
? send(res, 200, { ok: true })
|
|
131
|
+
: send(res, 404, { error: 'not found or no tokens' });
|
|
132
|
+
}
|
|
133
|
+
if (name && m === 'DELETE' && !seg[3]) {
|
|
134
|
+
quotaCache.delete(name);
|
|
135
|
+
return (await removeAccount(name))
|
|
136
|
+
? send(res, 200, { ok: true })
|
|
137
|
+
: send(res, 404, { error: 'not found' });
|
|
138
|
+
}
|
|
139
|
+
if (name && m === 'PATCH' && !seg[3]) {
|
|
140
|
+
const body = (await readJson(req));
|
|
141
|
+
await rename(name, body.name ?? '');
|
|
142
|
+
return send(res, 200, { ok: true });
|
|
143
|
+
}
|
|
144
|
+
send(res, 404, { error: 'not found' });
|
|
145
|
+
}
|
|
146
|
+
export const server = http.createServer(async (req, res) => {
|
|
147
|
+
try {
|
|
148
|
+
if (!hostOk(req))
|
|
149
|
+
return send(res, 403, { error: 'forbidden' });
|
|
150
|
+
const url = new URL(req.url ?? '/', 'http://x');
|
|
151
|
+
if (url.pathname.startsWith('/api/'))
|
|
152
|
+
return await api(req, res, url);
|
|
153
|
+
// Serve static files from public/
|
|
154
|
+
const file = path.join(PUBLIC, url.pathname === '/' ? 'index.html' : url.pathname);
|
|
155
|
+
if (!file.startsWith(PUBLIC + path.sep))
|
|
156
|
+
return send(res, 403, { error: 'forbidden' });
|
|
157
|
+
const body = await fs.readFile(file).catch(() => null);
|
|
158
|
+
if (!body)
|
|
159
|
+
return send(res, 404, { error: 'not found' });
|
|
160
|
+
res.writeHead(200, { 'Content-Type': MIME[path.extname(file)] || 'application/octet-stream' });
|
|
161
|
+
res.end(body);
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
const err = e;
|
|
165
|
+
send(res, err.code && err.code >= 400 && err.code < 500 ? err.code : 500, {
|
|
166
|
+
error: err.message,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,iBAAiB,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3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Gemini multi-account CLI - manage multiple Google accounts for Gemini API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
|
-
"bin":
|
|
8
|
-
|
|
7
|
+
"bin": "./dist/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18.0.0"
|
|
9
13
|
},
|
|
10
14
|
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
15
|
+
"build": "tsc && node scripts/copy-public.mjs",
|
|
16
|
+
"postbuild": "node scripts/copy-public.mjs",
|
|
12
17
|
"dev": "tsx src/index.ts",
|
|
13
18
|
"start": "node dist/index.js",
|
|
14
|
-
"link": "npm run build && npm link"
|
|
19
|
+
"link": "npm run build && npm link",
|
|
20
|
+
"test": "node test/smoke.mjs"
|
|
15
21
|
},
|
|
16
22
|
"keywords": [
|
|
17
23
|
"gemini",
|
|
@@ -23,9 +29,9 @@
|
|
|
23
29
|
"author": "",
|
|
24
30
|
"license": "MIT",
|
|
25
31
|
"dependencies": {
|
|
32
|
+
"cli-table3": "^0.6.5",
|
|
26
33
|
"commander": "^12.1.0",
|
|
27
|
-
"open": "^10.1.0"
|
|
28
|
-
"cli-table3": "^0.6.5"
|
|
34
|
+
"open": "^10.1.0"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
31
37
|
"@types/node": "^22.10.0",
|