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
package/src/storage/paths.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import * as os from 'node:os';
|
|
3
|
-
import { promises as fs } from 'node:fs';
|
|
4
|
-
|
|
5
|
-
const GEMX_DIR = '.gemix';
|
|
6
|
-
const GEMINI_DIR = '.gemini';
|
|
7
|
-
const ACCOUNTS_FILE = 'accounts.json';
|
|
8
|
-
const ACTIVE_FILE = 'active';
|
|
9
|
-
const ACCOUNTS_DIR = 'accounts';
|
|
10
|
-
const OAUTH_CREDS_FILE = 'oauth_creds.json';
|
|
11
|
-
const GOOGLE_ACCOUNTS_FILE = 'google_accounts.json';
|
|
12
|
-
|
|
13
|
-
export function getGemxDir(): string {
|
|
14
|
-
return path.join(os.homedir(), GEMX_DIR);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function getAccountsFilePath(): string {
|
|
18
|
-
return path.join(getGemxDir(), ACCOUNTS_FILE);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getActiveFilePath(): string {
|
|
22
|
-
return path.join(getGemxDir(), ACTIVE_FILE);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function getAccountsDir(): string {
|
|
26
|
-
return path.join(getGemxDir(), ACCOUNTS_DIR);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function getAccountDir(username: string): string {
|
|
30
|
-
return path.join(getAccountsDir(), username);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function getAccountTokensPath(username: string): string {
|
|
34
|
-
return path.join(getAccountDir(username), 'tokens.json');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function getGeminiOAuthCredsPath(): string {
|
|
38
|
-
return path.join(os.homedir(), GEMINI_DIR, OAUTH_CREDS_FILE);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getGeminiGoogleAccountsPath(): string {
|
|
42
|
-
return path.join(os.homedir(), GEMINI_DIR, GOOGLE_ACCOUNTS_FILE);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function getAntigravityOAuthTokenPath(): string {
|
|
46
|
-
return path.join(os.homedir(), GEMINI_DIR, 'antigravity-cli', 'antigravity-oauth-token');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export async function ensureGemxDir(): Promise<void> {
|
|
50
|
-
await fs.mkdir(getGemxDir(), { recursive: true });
|
|
51
|
-
await fs.mkdir(getAccountsDir(), { recursive: true });
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function ensureAccountDir(username: string): Promise<void> {
|
|
55
|
-
await fs.mkdir(getAccountDir(username), { recursive: true });
|
|
56
|
-
}
|
package/src/utils/table.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import Table from 'cli-table3';
|
|
2
|
-
import type { AccountInfo } from '../storage/accounts.js';
|
|
3
|
-
|
|
4
|
-
interface AccountRow {
|
|
5
|
-
username: string;
|
|
6
|
-
email: string;
|
|
7
|
-
limits: string;
|
|
8
|
-
status: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function formatAccountTable(
|
|
12
|
-
accounts: Record<string, AccountInfo>,
|
|
13
|
-
activeUsername: string | null
|
|
14
|
-
): string {
|
|
15
|
-
const table = new Table({
|
|
16
|
-
head: ['USERNAME', 'EMAIL', 'LIMITS', 'STATUS'],
|
|
17
|
-
style: { head: ['cyan'] },
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const sortedUsernames = Object.keys(accounts).sort();
|
|
21
|
-
|
|
22
|
-
for (const username of sortedUsernames) {
|
|
23
|
-
const account = accounts[username];
|
|
24
|
-
const isActive = username === activeUsername;
|
|
25
|
-
const limits = `${account.limits.requestsPerDay} req/day`;
|
|
26
|
-
const status = isActive ? '● active' : '○ inactive';
|
|
27
|
-
|
|
28
|
-
table.push([username, account.email, limits, status]);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return table.toString();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function formatAccountTableJson(
|
|
35
|
-
accounts: Record<string, AccountInfo>,
|
|
36
|
-
activeUsername: string | null
|
|
37
|
-
): object {
|
|
38
|
-
const sortedUsernames = Object.keys(accounts).sort();
|
|
39
|
-
const result = sortedUsernames.map((username) => ({
|
|
40
|
-
username,
|
|
41
|
-
email: accounts[username].email,
|
|
42
|
-
name: accounts[username].name,
|
|
43
|
-
limits: accounts[username].limits,
|
|
44
|
-
active: username === activeUsername,
|
|
45
|
-
created: accounts[username].created,
|
|
46
|
-
lastUsed: accounts[username].lastUsed,
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
return { accounts: result };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function formatLimits(limits: { requestsPerDay: number; tokensPerDay: number }): string {
|
|
53
|
-
const reqStr = `${limits.requestsPerDay} requests/day`;
|
|
54
|
-
const tokenStr = limits.tokensPerDay >= 1000000
|
|
55
|
-
? `${(limits.tokensPerDay / 1000000).toFixed(0)}M tokens/day`
|
|
56
|
-
: `${limits.tokensPerDay.toLocaleString()} tokens/day`;
|
|
57
|
-
return `${reqStr}, ${tokenStr}`;
|
|
58
|
-
}
|
package/src/utils/validation.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function validateUsername(username: string): { valid: boolean; error?: string } {
|
|
2
|
-
if (!username || username.length < 3) {
|
|
3
|
-
return { valid: false, error: 'Username must be at least 3 characters' };
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
if (username.length > 30) {
|
|
7
|
-
return { valid: false, error: 'Username must be at most 30 characters' };
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (!/^[a-zA-Z0-9]/.test(username)) {
|
|
11
|
-
return { valid: false, error: 'Username must start with a letter or number' };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (!/[a-zA-Z0-9]$/.test(username)) {
|
|
15
|
-
return { valid: false, error: 'Username must end with a letter or number' };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!/^[a-zA-Z0-9-]+$/.test(username)) {
|
|
19
|
-
return { valid: false, error: 'Username can only contain letters, numbers, and hyphens' };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (username.includes('--')) {
|
|
23
|
-
return { valid: false, error: 'Username cannot contain consecutive hyphens' };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return { valid: true };
|
|
27
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "Node16",
|
|
5
|
-
"moduleResolution": "Node16",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"declarationMap": true,
|
|
16
|
-
"sourceMap": true
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|