agy-family 0.5.0 → 0.6.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/README.md +17 -7
- package/README.zh-CN.md +18 -8
- package/package.json +1 -1
- package/packages/cli/bin/agy-family.mjs +124 -111
- package/packages/cli/src/hook.mjs +1 -1
- package/packages/cli/src/host.mjs +16 -0
- package/packages/core/src/pricing-node.mjs +4 -24
- package/packages/core/src/pricing.mjs +2 -2
- package/packages/core/src/quota.mjs +337 -161
- package/packages/core/src/sync.mjs +2 -2
- package/packages/server-core/src/index.mjs +1 -1
- package/packages/server-core/src/ui.mjs +3 -3
package/README.md
CHANGED
|
@@ -40,28 +40,38 @@ packages/
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
## 1. One CLI for
|
|
43
|
+
## 1. One Standalone CLI for Hosting, Master Quota & Joining (Zero External Dependencies)
|
|
44
44
|
|
|
45
|
-
Install `agy-family` once — the same CLI handles **
|
|
45
|
+
Install `agy-family` once — the same self-contained CLI handles **hosting**, **live master subscription quota sync**, **passwordless browser access**, and **joining a family board** (zero `git clone`, zero external tools required):
|
|
46
46
|
|
|
47
47
|
```sh
|
|
48
48
|
npm i -g agy-family
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
- **
|
|
51
|
+
- **Host your own board on Cloudflare Workers + D1 (free tier, 1 command)** — auto-provisions D1, applies migrations, enables `cli-only` private mode by default, generates `AGY_FAMILY_ADMIN_KEY`, syncs live `models.dev` 3-tier pricing, and with `--self` joins you automatically:
|
|
52
52
|
```sh
|
|
53
|
-
agy-family
|
|
53
|
+
agy-family deploy --self --member "Owner" --email "master@gmail.com" --daemon
|
|
54
|
+
```
|
|
55
|
+
- **Bind the Master Account for live 5h / weekly subscription quota sync** (built-in official `statusLine` passive tap — zero external tools, zero OAuth secrets, transparently chains any existing status line):
|
|
56
|
+
```sh
|
|
57
|
+
agy-family master bind --daemon
|
|
54
58
|
```
|
|
55
|
-
- **
|
|
59
|
+
- **Open the web board passwordlessly** (60s one-time ticket -> 7-day `HttpOnly` cookie; manager machines auto-unlock Admin Console):
|
|
56
60
|
```sh
|
|
57
|
-
agy-family
|
|
61
|
+
agy-family open # Open directly in your default browser
|
|
62
|
+
agy-family open --link # Print a 5-minute single-use link for mobile
|
|
58
63
|
```
|
|
59
|
-
- **Invite members, inspect
|
|
64
|
+
- **Invite members, inspect host, or upgrade anytime**:
|
|
60
65
|
```sh
|
|
61
66
|
agy-family invite "Alice" --email "alice@gmail.com" --quota 20 # Prints ready-to-paste join command
|
|
62
67
|
agy-family host # Show board URL, Admin Key & member list
|
|
63
68
|
npm i -g agy-family@latest && agy-family deploy # Idempotent zero-downtime upgrade
|
|
64
69
|
```
|
|
70
|
+
- **Join someone's family board & view dashboard** (works for both Antigravity Desktop IDE & `agy` CLI):
|
|
71
|
+
```sh
|
|
72
|
+
agy-family join "agyfam://join?d=..." --daemon
|
|
73
|
+
agy-family open
|
|
74
|
+
```
|
|
65
75
|
- **Self-host locally or on any VPS (built-in Node SQLite)**:
|
|
66
76
|
```sh
|
|
67
77
|
agy-family serve --port 8787
|
package/README.zh-CN.md
CHANGED
|
@@ -40,28 +40,38 @@ packages/
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
## 一、一个 CLI
|
|
43
|
+
## 一、一个 CLI:既能「上车」也能「自己开车」(零外部依赖、零密码)
|
|
44
44
|
|
|
45
|
-
只需全局安装一次 `agy-family
|
|
45
|
+
只需全局安装一次 `agy-family`,**成员上车**、**主号订阅余量同步**、**免密打开网页看板**和**车主部署/发邀请/自托管**全部由这一个包独立完成(免 `git clone`、不依赖任何其他工具):
|
|
46
46
|
|
|
47
47
|
```sh
|
|
48
48
|
npm i -g agy-family
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
-
|
|
51
|
+
- **🚗 车主免费云端开车**(Cloudflare Workers + D1 永久免费层,自动创建 D1、跑迁移、默认开启 `cli-only` 隐私保护、生成 Admin Key、同步 `models.dev` 三级定价,加 `--self` 顺便把自己也接上车):
|
|
52
52
|
```sh
|
|
53
|
-
agy-family
|
|
53
|
+
agy-family deploy --self --member "你的名字" --email "主号@gmail.com" --daemon
|
|
54
54
|
```
|
|
55
|
-
-
|
|
55
|
+
- **⚡ 绑定主号实时订阅额度**(内置 `statusLine` 官方被动采集钩子,零外部工具依赖、零 Google 凭据、自动透明串联保留你原有的终端状态栏):
|
|
56
56
|
```sh
|
|
57
|
-
agy-family
|
|
57
|
+
agy-family master bind --daemon # 绑定主号并自动捕获同步 5h / 周订阅余量
|
|
58
58
|
```
|
|
59
|
-
-
|
|
59
|
+
- **🔐 零密码打开网页看板**(一次性 60s 票据换取 7 天 `HttpOnly` 会话,主号电脑自动免密解锁「家庭组管理」后台):
|
|
60
|
+
```sh
|
|
61
|
+
agy-family open # 自动打开浏览器
|
|
62
|
+
agy-family open --link # 生成 5 分钟单次有效链接(方便手机临时看)
|
|
63
|
+
```
|
|
64
|
+
- **🎟️ 车主发车票 / 查状态 / 后续升级**:
|
|
60
65
|
```sh
|
|
61
66
|
agy-family invite "成员名" --email "member@gmail.com" --quota 20 # 生成一行上车命令
|
|
62
|
-
agy-family host #
|
|
67
|
+
agy-family host # 查看看板地址与 Admin Key
|
|
63
68
|
npm i -g agy-family@latest && agy-family deploy # 一键平滑升级云端看板(保留数据与密钥)
|
|
64
69
|
```
|
|
70
|
+
- **🚌 成员上车 & 查看面板**(桌面 IDE 和 `agy` CLI 通用):
|
|
71
|
+
```sh
|
|
72
|
+
agy-family join "agyfam://join?d=..." --daemon # 加入家庭组并开启后台同步
|
|
73
|
+
agy-family open # 零密码打开网页看板
|
|
74
|
+
```
|
|
65
75
|
- **🏠 本地 / VPS 自托管开车**(零依赖内置 SQLite):
|
|
66
76
|
```sh
|
|
67
77
|
agy-family serve --port 8787
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-family",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Zero-privacy-leak transparent usage dashboard, /family slash command, and fair-use budget guardrail for Google One / Antigravity family groups.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@ process.emitWarning = function (warning, ...args) {
|
|
|
9
9
|
return _origEmitWarning.call(this, warning, ...args);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
import { spawn } from 'node:child_process';
|
|
12
|
+
import { execSync, spawn } from 'node:child_process';
|
|
13
13
|
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
14
14
|
import { homedir, userInfo } from 'node:os';
|
|
15
15
|
import { dirname, join, resolve } from 'node:path';
|
|
@@ -20,22 +20,27 @@ import {
|
|
|
20
20
|
extractEmailFromHookPayload,
|
|
21
21
|
extractLocalSubscriptionQuota,
|
|
22
22
|
fetchBoardSummary,
|
|
23
|
+
formatCompactStatusLineOutput,
|
|
23
24
|
formatResetCountdown,
|
|
24
25
|
getOrCreateSharedDeviceId,
|
|
25
26
|
hashEmailSha256,
|
|
27
|
+
ingestStatusLineQuotaPayload,
|
|
28
|
+
inspectStatusLineTap,
|
|
29
|
+
installStatusLineTap,
|
|
30
|
+
isManagedStatusLineCommand,
|
|
31
|
+
maskEmailHint,
|
|
26
32
|
masterConfigPath,
|
|
27
33
|
normalizePlanTier,
|
|
28
34
|
pushMasterQuotaToServer,
|
|
29
35
|
pushSyncPayload,
|
|
30
|
-
|
|
31
|
-
readAgyBarQuotaCache,
|
|
36
|
+
readLocalActiveEmailHint,
|
|
32
37
|
readLocalPricingSources,
|
|
33
38
|
readMasterConfig,
|
|
34
|
-
refreshAgyBarAliasQuota,
|
|
35
39
|
removeMasterConfig,
|
|
36
40
|
requestWebLoginTicket,
|
|
37
|
-
|
|
41
|
+
statusLineChainPath,
|
|
38
42
|
syncLocalPricingCache,
|
|
43
|
+
uninstallStatusLineTap,
|
|
39
44
|
writeActiveAccountCache,
|
|
40
45
|
writeMasterConfig,
|
|
41
46
|
} from '../../core/src/index.mjs';
|
|
@@ -61,7 +66,7 @@ import {
|
|
|
61
66
|
writeHostConfig,
|
|
62
67
|
} from '../src/host.mjs';
|
|
63
68
|
|
|
64
|
-
const CLI_VERSION = '0.
|
|
69
|
+
const CLI_VERSION = '0.6.0';
|
|
65
70
|
const THIS_CLI_PATH = fileURLToPath(import.meta.url);
|
|
66
71
|
const PACKAGE_ROOT = resolve(dirname(THIS_CLI_PATH), '..', '..', '..');
|
|
67
72
|
|
|
@@ -158,8 +163,8 @@ Join a Family Group (Member):
|
|
|
158
163
|
Host Your Own Board (Family Manager):
|
|
159
164
|
agy-family deploy [--name agy-family] [--title "..."] [--admin-key <key>] [--self] [--member <name>] [--email <gmail>] [--daemon]
|
|
160
165
|
One-command deploy/upgrade on Cloudflare Workers + D1 (free tier, no git clone)
|
|
161
|
-
agy-family master [bind
|
|
162
|
-
Bind &
|
|
166
|
+
agy-family master [bind|sync|set|status|unlink] [--email <gmail>] [--daemon]
|
|
167
|
+
Bind master account & auto-capture live 5h / weekly subscription quota (100% standalone, zero secrets)
|
|
163
168
|
agy-family invite <name> [--email <gmail>] [--quota <pct>] [--role member|manager]
|
|
164
169
|
Create a member and print their ready-to-paste one-line join command
|
|
165
170
|
agy-family host [show|link|unlink] View or link your hosted board URL, Admin Key, and D1 metadata
|
|
@@ -202,7 +207,6 @@ function formatMasterQuotaLine(mq) {
|
|
|
202
207
|
|
|
203
208
|
async function runMasterQuotaSync({
|
|
204
209
|
home = homedir(),
|
|
205
|
-
forceRefresh = false,
|
|
206
210
|
quiet = false,
|
|
207
211
|
urlOverride = '',
|
|
208
212
|
adminKeyOverride = '',
|
|
@@ -213,20 +217,11 @@ async function runMasterQuotaSync({
|
|
|
213
217
|
const targetKey = adminKeyOverride || host?.adminKey || '';
|
|
214
218
|
if (!mCfg || !targetUrl || !targetKey) return null;
|
|
215
219
|
|
|
216
|
-
|
|
217
|
-
if (mCfg.alias && (forceRefresh || shouldAutoRefreshMasterQuota(mCfg, quota))) {
|
|
218
|
-
const ref = refreshAgyBarAliasQuota(mCfg.alias);
|
|
219
|
-
if (ref.ok) {
|
|
220
|
-
quota = extractLocalSubscriptionQuota({ home, masterConfig: mCfg });
|
|
221
|
-
if (quota) quota = { ...quota, source: 'agy-bar-refresh' };
|
|
222
|
-
} else if (!quiet && forceRefresh) {
|
|
223
|
-
console.warn(`! Live agy-bar refresh failed (${ref.error}); falling back to cached quota.`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
220
|
+
const quota = extractLocalSubscriptionQuota({ home, masterConfig: mCfg });
|
|
226
221
|
if (!quota) {
|
|
227
222
|
if (!quiet) {
|
|
228
223
|
console.warn(
|
|
229
|
-
|
|
224
|
+
'! No captured master subscription quota yet. Send any turn in `agy` CLI while signed into the master account, or calibrate manually with "agy-family master set".',
|
|
230
225
|
);
|
|
231
226
|
}
|
|
232
227
|
return null;
|
|
@@ -342,13 +337,66 @@ async function runHookCommand(eventArg) {
|
|
|
342
337
|
raw += chunk;
|
|
343
338
|
}
|
|
344
339
|
const trimmed = raw.trim();
|
|
345
|
-
|
|
340
|
+
let payload = {};
|
|
341
|
+
if (trimmed) {
|
|
342
|
+
try {
|
|
343
|
+
payload = JSON.parse(trimmed);
|
|
344
|
+
} catch {
|
|
345
|
+
payload = {};
|
|
346
|
+
}
|
|
347
|
+
}
|
|
346
348
|
|
|
347
349
|
if (eventArg === 'pre-invocation') {
|
|
348
350
|
const response = await handlePreInvocation(payload, { home: homedir() });
|
|
349
351
|
process.stdout.write(JSON.stringify(response || {}));
|
|
350
352
|
return;
|
|
351
353
|
}
|
|
354
|
+
if (eventArg === 'statusline') {
|
|
355
|
+
const home = homedir();
|
|
356
|
+
let capturedRes = { captured: false, matchedMaster: false, quota: null };
|
|
357
|
+
try {
|
|
358
|
+
capturedRes = ingestStatusLineQuotaPayload(payload, { home });
|
|
359
|
+
} catch {}
|
|
360
|
+
|
|
361
|
+
if (capturedRes.matchedMaster) {
|
|
362
|
+
try {
|
|
363
|
+
const throttlePath = join(configBaseDir(home), 'last-master-push.json');
|
|
364
|
+
const prev = readJsonSafe(throttlePath);
|
|
365
|
+
const now = Date.now();
|
|
366
|
+
if (!prev?.ts || now - Number(prev.ts) >= 60_000) {
|
|
367
|
+
writePrivateJson(throttlePath, { ts: now });
|
|
368
|
+
const child = spawn(process.execPath, [THIS_CLI_PATH, 'master', 'sync', '--quiet'], {
|
|
369
|
+
detached: true,
|
|
370
|
+
stdio: 'ignore',
|
|
371
|
+
windowsHide: true,
|
|
372
|
+
});
|
|
373
|
+
child.unref();
|
|
374
|
+
}
|
|
375
|
+
} catch {}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const chain = readJsonSafe(statusLineChainPath(home));
|
|
379
|
+
if (chain?.command && !isManagedStatusLineCommand(chain.command)) {
|
|
380
|
+
try {
|
|
381
|
+
const out = execSync(chain.command, {
|
|
382
|
+
input: raw,
|
|
383
|
+
encoding: 'utf8',
|
|
384
|
+
timeout: 8_000,
|
|
385
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
386
|
+
});
|
|
387
|
+
if (out) process.stdout.write(out);
|
|
388
|
+
return;
|
|
389
|
+
} catch {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (capturedRes.quota) {
|
|
395
|
+
const compact = formatCompactStatusLineOutput(capturedRes.quota);
|
|
396
|
+
if (compact) process.stdout.write(compact);
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
352
400
|
if (eventArg === 'stop') {
|
|
353
401
|
const hookEmail = extractEmailFromHookPayload(payload);
|
|
354
402
|
if (hookEmail) {
|
|
@@ -366,7 +414,7 @@ async function runHookCommand(eventArg) {
|
|
|
366
414
|
process.stdout.write('{}');
|
|
367
415
|
} catch {
|
|
368
416
|
// Always fail open so hook glitches never block Antigravity IDE or CLI turns.
|
|
369
|
-
process.stdout.write('{}');
|
|
417
|
+
if (eventArg !== 'statusline') process.stdout.write('{}');
|
|
370
418
|
}
|
|
371
419
|
}
|
|
372
420
|
|
|
@@ -449,7 +497,6 @@ async function main() {
|
|
|
449
497
|
const watch = args.includes('--watch');
|
|
450
498
|
const fullSync = args.includes('--full');
|
|
451
499
|
const quiet = args.includes('--quiet');
|
|
452
|
-
const forceRefresh = args.includes('--refresh-quota') || args.includes('--refresh');
|
|
453
500
|
const daysIdx = args.indexOf('--days');
|
|
454
501
|
const lookbackDays = daysIdx >= 0 ? Number(args[daysIdx + 1]) || 31 : 31;
|
|
455
502
|
const intervalIdx = args.indexOf('--interval');
|
|
@@ -462,7 +509,7 @@ async function main() {
|
|
|
462
509
|
const runTick = async (isFirst) => {
|
|
463
510
|
if (!dryRun && hasMasterHost) {
|
|
464
511
|
try {
|
|
465
|
-
await runMasterQuotaSync({
|
|
512
|
+
await runMasterQuotaSync({ quiet });
|
|
466
513
|
} catch (err) {
|
|
467
514
|
if (!quiet) console.error(`Master quota sync error: ${err.message}`);
|
|
468
515
|
}
|
|
@@ -678,7 +725,9 @@ async function main() {
|
|
|
678
725
|
|
|
679
726
|
if (cmd === 'uninstall') {
|
|
680
727
|
uninstallAntigravityIntegration();
|
|
728
|
+
uninstallStatusLineTap();
|
|
681
729
|
uninstallBackgroundDaemon();
|
|
730
|
+
removeMasterConfig();
|
|
682
731
|
rmSync(clientConfigPath(), { force: true });
|
|
683
732
|
rmSync(syncedHashesPath(), { force: true });
|
|
684
733
|
rmSync(accountLedgerPath(), { force: true });
|
|
@@ -771,7 +820,8 @@ async function main() {
|
|
|
771
820
|
}
|
|
772
821
|
|
|
773
822
|
console.log('\nNext steps:');
|
|
774
|
-
console.log(
|
|
823
|
+
console.log(' Open board : agy-family open');
|
|
824
|
+
console.log(' Master quota : agy-family master bind --daemon');
|
|
775
825
|
console.log(' Invite member : agy-family invite "Alice" --email "alice@gmail.com"');
|
|
776
826
|
if (!joinSelf) {
|
|
777
827
|
console.log(' Join yourself : agy-family deploy --self --member "YourName" --daemon');
|
|
@@ -830,6 +880,7 @@ async function main() {
|
|
|
830
880
|
if (m.quotaPct != null) console.log(` Quota Share : ${m.quotaPct}%`);
|
|
831
881
|
console.log('\nSend this one-line join command (works for both Antigravity Desktop IDE & agy CLI):');
|
|
832
882
|
console.log(` ${res.joinCommand}`);
|
|
883
|
+
console.log('Then open the web board anytime with: agy-family open');
|
|
833
884
|
console.log('\nRaw invite code:');
|
|
834
885
|
console.log(` ${res.inviteUri}`);
|
|
835
886
|
return;
|
|
@@ -844,8 +895,12 @@ async function main() {
|
|
|
844
895
|
const targetKey = adminKeyOverride || host?.adminKey || '';
|
|
845
896
|
|
|
846
897
|
if (action === 'unlink' || action === 'remove' || action === 'clear') {
|
|
898
|
+
const sl = uninstallStatusLineTap();
|
|
847
899
|
const removed = removeMasterConfig();
|
|
848
900
|
console.log(`✓ Local master subscription binding: ${removed ? 'removed' : 'not configured'}.`);
|
|
901
|
+
if (sl.restored) {
|
|
902
|
+
console.log(`✓ Antigravity statusLine: ${sl.hadChained ? 'restored previous statusLine command' : 'removed capture hook'}.`);
|
|
903
|
+
}
|
|
849
904
|
return;
|
|
850
905
|
}
|
|
851
906
|
|
|
@@ -882,11 +937,10 @@ async function main() {
|
|
|
882
937
|
}
|
|
883
938
|
const mCfg = readMasterConfig();
|
|
884
939
|
if (!mCfg) {
|
|
885
|
-
console.error('No master account bound yet. Run "agy-family master bind"
|
|
940
|
+
console.error('No master account bound yet. Run "agy-family master bind --daemon".');
|
|
886
941
|
process.exit(1);
|
|
887
942
|
}
|
|
888
943
|
const res = await runMasterQuotaSync({
|
|
889
|
-
forceRefresh: args.includes('--refresh'),
|
|
890
944
|
quiet: args.includes('--quiet'),
|
|
891
945
|
urlOverride: targetUrl,
|
|
892
946
|
adminKeyOverride: targetKey,
|
|
@@ -896,81 +950,36 @@ async function main() {
|
|
|
896
950
|
}
|
|
897
951
|
|
|
898
952
|
if (action === 'bind') {
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
continue;
|
|
906
|
-
}
|
|
907
|
-
if (a.startsWith('--')) continue;
|
|
908
|
-
positional.push(a);
|
|
909
|
-
}
|
|
910
|
-
const query = positional[0] || '';
|
|
911
|
-
const barAccounts = readAgyBarAccounts();
|
|
912
|
-
const barCache = readAgyBarQuotaCache();
|
|
913
|
-
const sortedAccounts = [...barAccounts].sort((a, b) => {
|
|
914
|
-
const rank = (t) => (t.includes('Ultra') ? 3 : t.includes('Pro') ? 2 : 1);
|
|
915
|
-
return rank(b.tier) - rank(a.tier);
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
if (!query) {
|
|
919
|
-
if (sortedAccounts.length === 0) {
|
|
920
|
-
console.log('No agy-bar accounts found on this machine.');
|
|
921
|
-
console.log('You can either:');
|
|
922
|
-
console.log(' 1. Save your master account in agy-bar ("agy-bar account save"), then run "agy-family master bind <alias> --refresh --daemon"');
|
|
923
|
-
console.log(' 2. Or push manually: agy-family master set --tier "Google AI Ultra" --gemini-5h 80 --gemini-weekly 40 --3p-5h 100 --3p-weekly 100');
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
926
|
-
console.log('Detected local agy-bar accounts (choose your Google Family Master account):');
|
|
927
|
-
sortedAccounts.forEach((a, idx) => {
|
|
928
|
-
const entry = barCache?.accounts?.[a.quotaKey];
|
|
929
|
-
const g5 = entry?.buckets?.['gemini-5h']?.remaining_fraction;
|
|
930
|
-
const gw = entry?.buckets?.['gemini-weekly']?.remaining_fraction;
|
|
931
|
-
const qSummary =
|
|
932
|
-
g5 !== undefined || gw !== undefined
|
|
933
|
-
? `Gemini 5h ${g5 !== undefined ? `${Math.round(g5 * 100)}%` : '—'} · wk ${gw !== undefined ? `${Math.round(gw * 100)}%` : '—'}`
|
|
934
|
-
: 'no cached quota yet';
|
|
935
|
-
console.log(
|
|
936
|
-
` #${idx + 1} ${a.alias.padEnd(16)} ${(a.tier || 'Unknown').padEnd(16)} ${(a.maskedEmail || '').padEnd(22)} ${qSummary}`,
|
|
937
|
-
);
|
|
938
|
-
});
|
|
939
|
-
const suggested = sortedAccounts[0].alias;
|
|
940
|
-
console.log(`\nBind master & enable background quota sync:\n agy-family master bind ${suggested} --refresh --daemon`);
|
|
941
|
-
return;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
let matched = null;
|
|
945
|
-
const numMatch = /^#?([1-9]\d*)$/.exec(query);
|
|
946
|
-
if (numMatch) {
|
|
947
|
-
matched = sortedAccounts[Number(numMatch[1]) - 1] || null;
|
|
953
|
+
const explicitEmail = readFlag(args, '--email').trim().toLowerCase();
|
|
954
|
+
let emailHash = '';
|
|
955
|
+
let maskedEmail = '';
|
|
956
|
+
if (explicitEmail) {
|
|
957
|
+
emailHash = hashEmailSha256(explicitEmail);
|
|
958
|
+
maskedEmail = maskEmailHint(explicitEmail);
|
|
948
959
|
} else {
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
null;
|
|
955
|
-
}
|
|
956
|
-
if (!matched) {
|
|
957
|
-
console.error(`Account "${query}" not found in agy-bar. Run "agy-family master bind" with no arguments to list available accounts.`);
|
|
958
|
-
process.exit(1);
|
|
960
|
+
const detected = readLocalActiveEmailHint();
|
|
961
|
+
if (detected) {
|
|
962
|
+
emailHash = detected.emailHash;
|
|
963
|
+
maskedEmail = detected.maskedEmail;
|
|
964
|
+
}
|
|
959
965
|
}
|
|
960
966
|
|
|
961
|
-
const autoRefresh = !args.includes('--no-auto-refresh');
|
|
962
967
|
const saved = {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
maskedEmail: matched.maskedEmail,
|
|
966
|
-
planTier: matched.tier || '',
|
|
967
|
-
autoRefresh,
|
|
968
|
+
emailHash,
|
|
969
|
+
maskedEmail,
|
|
968
970
|
boundAt: Date.now(),
|
|
969
971
|
};
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
972
|
+
const cfgFile = writeMasterConfig(saved);
|
|
973
|
+
const tap = installStatusLineTap({
|
|
974
|
+
executable: process.execPath,
|
|
975
|
+
cliPath: THIS_CLI_PATH,
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
console.log(`✓ Bound Master Subscription Account${maskedEmail ? `: ${maskedEmail}` : ' (will lock onto active agy account)'}`);
|
|
979
|
+
console.log(` Master Config : ${cfgFile} (SHA-256 fingerprint only; zero Google tokens stored)`);
|
|
980
|
+
console.log(
|
|
981
|
+
` Quota Capture : installed built-in statusLine tap (${tap.chained ? 'chained seamlessly with your existing statusLine' : 'standalone'})`,
|
|
982
|
+
);
|
|
974
983
|
|
|
975
984
|
if (args.includes('--daemon')) {
|
|
976
985
|
const d = installBackgroundDaemon({ executable: process.execPath, cliPath: THIS_CLI_PATH });
|
|
@@ -979,25 +988,26 @@ async function main() {
|
|
|
979
988
|
}
|
|
980
989
|
}
|
|
981
990
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
adminKeyOverride: targetKey,
|
|
988
|
-
});
|
|
991
|
+
const existingQ = extractLocalSubscriptionQuota({ masterConfig: saved });
|
|
992
|
+
if (existingQ && targetUrl && targetKey) {
|
|
993
|
+
await runMasterQuotaSync({ quiet: false, urlOverride: targetUrl, adminKeyOverride: targetKey });
|
|
994
|
+
} else if (targetUrl && targetKey) {
|
|
995
|
+
console.log('ℹ Quota auto-captures on your next `agy` turn (0 secrets, 100% standalone), or calibrate immediately with `agy-family master set`.');
|
|
989
996
|
} else {
|
|
990
|
-
console.log('ℹ No hosted board linked yet — run "agy-family
|
|
997
|
+
console.log('ℹ No hosted board linked yet — run "agy-family deploy" or "agy-family host link".');
|
|
991
998
|
}
|
|
992
999
|
return;
|
|
993
1000
|
}
|
|
994
1001
|
|
|
995
1002
|
// Default: `agy-family master status`
|
|
996
1003
|
const mCfg = readMasterConfig();
|
|
997
|
-
|
|
1004
|
+
const tapStatus = inspectStatusLineTap();
|
|
1005
|
+
console.log('Master Subscription Quota Status (100% Standalone · Zero Secrets):');
|
|
998
1006
|
if (mCfg) {
|
|
999
|
-
console.log(` Bound Account : ${mCfg.
|
|
1000
|
-
console.log(
|
|
1007
|
+
console.log(` Bound Account : ${mCfg.maskedEmail || '(any active agy account)'}`);
|
|
1008
|
+
console.log(
|
|
1009
|
+
` Quota Capture : ${tapStatus.installed ? `active (${tapStatus.chained ? 'chained with existing statusLine' : 'standalone'})` : 'not installed (run "agy-family master bind --daemon")'}`,
|
|
1010
|
+
);
|
|
1001
1011
|
console.log(` Config File : ${masterConfigPath()}`);
|
|
1002
1012
|
const localQ = extractLocalSubscriptionQuota({ masterConfig: mCfg });
|
|
1003
1013
|
if (localQ) {
|
|
@@ -1006,17 +1016,20 @@ async function main() {
|
|
|
1006
1016
|
const c5 = localQ.buckets['3p-5h']?.remainingFraction;
|
|
1007
1017
|
const cw = localQ.buckets['3p-weekly']?.remainingFraction;
|
|
1008
1018
|
console.log(
|
|
1009
|
-
` Local Cache : Gemini 5h ${g5 !== undefined ? `${Math.round(g5 * 100)}%` : '—'} · wk ${gw !== undefined ? `${Math.round(gw * 100)}%` : '—'} | 3P 5h ${c5 !== undefined ? `${Math.round(c5 * 100)}%` : '—'} · wk ${cw !== undefined ? `${Math.round(cw * 100)}%` : '—'}`,
|
|
1019
|
+
` Local Cache : ${localQ.planTier ? `${localQ.planTier} · ` : ''}Gemini 5h ${g5 !== undefined ? `${Math.round(g5 * 100)}%` : '—'} · wk ${gw !== undefined ? `${Math.round(gw * 100)}%` : '—'} | 3P 5h ${c5 !== undefined ? `${Math.round(c5 * 100)}%` : '—'} · wk ${cw !== undefined ? `${Math.round(cw * 100)}%` : '—'}`,
|
|
1010
1020
|
);
|
|
1021
|
+
} else {
|
|
1022
|
+
console.log(' Local Cache : waiting for next `agy` turn (or run `agy-family master set ...`)');
|
|
1011
1023
|
}
|
|
1012
1024
|
} else {
|
|
1013
|
-
console.log(' Bound Account : none
|
|
1025
|
+
console.log(' Bound Account : none');
|
|
1026
|
+
console.log(' Quick setup : agy-family master bind --daemon [--email master@gmail.com]');
|
|
1014
1027
|
}
|
|
1015
1028
|
if (targetUrl && targetKey) {
|
|
1016
1029
|
try {
|
|
1017
1030
|
const ov = await adminApiRequest({ url: targetUrl, adminKey: targetKey, path: '/api/admin/overview', timeoutMs: 8_000 });
|
|
1018
1031
|
const line = formatMasterQuotaLine(ov.masterSubscriptionQuota);
|
|
1019
|
-
console.log(` Live Board : ${line || 'not synced yet
|
|
1032
|
+
console.log(` Live Board : ${line || 'not synced yet'}`);
|
|
1020
1033
|
} catch (err) {
|
|
1021
1034
|
console.log(` Live Board : unreachable (${err.message})`);
|
|
1022
1035
|
}
|
|
@@ -1121,7 +1134,7 @@ async function main() {
|
|
|
1121
1134
|
|
|
1122
1135
|
main().catch((err) => {
|
|
1123
1136
|
if (process.argv[2] === 'hook-run') {
|
|
1124
|
-
process.stdout.write('{}');
|
|
1137
|
+
if (process.argv[3] !== 'statusline') process.stdout.write('{}');
|
|
1125
1138
|
return;
|
|
1126
1139
|
}
|
|
1127
1140
|
console.error(`Error: ${err?.message || err}`);
|
|
@@ -794,7 +794,7 @@ export async function runHeadlessSync({ cfg, fullSync = false, home = homedir(),
|
|
|
794
794
|
const { payload, scan, nextSyncedHashes, nextAccountLedger } = await buildSyncPayload({
|
|
795
795
|
deviceId,
|
|
796
796
|
clientKind: 'cli',
|
|
797
|
-
clientVersion: '0.
|
|
797
|
+
clientVersion: '0.6.0',
|
|
798
798
|
home,
|
|
799
799
|
fileCache: cache,
|
|
800
800
|
syncedHashes: prevHashes,
|
|
@@ -401,6 +401,22 @@ export async function deployToCloudflare({
|
|
|
401
401
|
log('5/5 Preserving existing AGY_FAMILY_ADMIN_KEY & syncing live models.dev pricing...');
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
+
if (needSecretPut && !existing.url) {
|
|
405
|
+
try {
|
|
406
|
+
await adminApiRequest({
|
|
407
|
+
url: deployedUrl,
|
|
408
|
+
adminKey: finalAdminKey,
|
|
409
|
+
path: '/api/admin/settings',
|
|
410
|
+
method: 'PATCH',
|
|
411
|
+
body: { boardAccessMode: 'cli-only' },
|
|
412
|
+
fetchFn,
|
|
413
|
+
timeoutMs: 10_000,
|
|
414
|
+
});
|
|
415
|
+
} catch {
|
|
416
|
+
// Non-fatal: manager can switch access mode anytime in Admin Console.
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
404
420
|
let pricingSync = null;
|
|
405
421
|
try {
|
|
406
422
|
pricingSync = await adminApiRequest({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Local Node.js disk adapter for the 3-Tier Dynamic Pricing Engine.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// Standalone: maintains `~/.config/agy-family/pricing-cache.json` (24h TTL from models.dev / litellm)
|
|
3
|
+
// and optional custom overrides in `~/.config/agy-family/config.json` (`customPricing`).
|
|
4
4
|
|
|
5
5
|
import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
6
6
|
import { homedir } from 'node:os';
|
|
@@ -34,39 +34,19 @@ function readJsonIfFreshMtime(filePath, slot) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const slotFamCache = { path: '', mtimeMs: -1, data: null };
|
|
37
|
-
const slotBarCache = { path: '', mtimeMs: -1, data: null };
|
|
38
37
|
const slotFamCfg = { path: '', mtimeMs: -1, data: null };
|
|
39
|
-
const slotBarCfg = { path: '', mtimeMs: -1, data: null };
|
|
40
38
|
|
|
41
39
|
export function agyFamilyPricingCachePath(home = homedir()) {
|
|
42
40
|
return join(home, '.config', 'agy-family', 'pricing-cache.json');
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
export function agyBarPricingCachePath(home = homedir()) {
|
|
46
|
-
return join(home, '.gemini', 'config', 'agy-bar', 'pricing-cache.json');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
export function readLocalPricingSources({ home = homedir() } = {}) {
|
|
50
44
|
const famCfg = readJsonIfFreshMtime(join(home, '.config', 'agy-family', 'config.json'), slotFamCfg);
|
|
51
|
-
const barCfg = readJsonIfFreshMtime(join(home, '.gemini', 'config', 'agy-bar', 'config.json'), slotBarCfg);
|
|
52
|
-
|
|
53
45
|
const customPricing =
|
|
54
|
-
|
|
55
|
-
(barCfg?.customPricing && typeof barCfg.customPricing === 'object' ? barCfg.customPricing : null) ||
|
|
56
|
-
null;
|
|
46
|
+
famCfg?.customPricing && typeof famCfg.customPricing === 'object' ? famCfg.customPricing : null;
|
|
57
47
|
|
|
58
48
|
const famCache = readJsonIfFreshMtime(agyFamilyPricingCachePath(home), slotFamCache);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const famValid = famCache && typeof famCache.rates === 'object' ? famCache : null;
|
|
62
|
-
const barValid = barCache && typeof barCache.rates === 'object' ? barCache : null;
|
|
63
|
-
|
|
64
|
-
let pricingCache = null;
|
|
65
|
-
if (famValid && barValid) {
|
|
66
|
-
pricingCache = Number(barValid.fetchedAt || 0) > Number(famValid.fetchedAt || 0) ? barValid : famValid;
|
|
67
|
-
} else {
|
|
68
|
-
pricingCache = famValid || barValid || null;
|
|
69
|
-
}
|
|
49
|
+
const pricingCache = famCache && typeof famCache.rates === 'object' ? famCache : null;
|
|
70
50
|
|
|
71
51
|
return { customPricing, pricingCache };
|
|
72
52
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// 3-Tier Dynamic Model Pricing Engine
|
|
1
|
+
// 3-Tier Dynamic Model Pricing Engine:
|
|
2
2
|
// Tier 1: User / Admin custom overrides (`customPricing` map)
|
|
3
3
|
// Tier 2: Auto-synced live pricing cache (`models.dev` -> fallback `litellm`, 24h TTL)
|
|
4
4
|
// Tier 3: Calibrated built-in table seeded from models.dev (offline fallback)
|
|
@@ -13,7 +13,7 @@ export const PRICING_SOURCES = Object.freeze({
|
|
|
13
13
|
litellm: 'https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
// Tier 3 exact normalized-key map (calibrated
|
|
16
|
+
// Tier 3 exact normalized-key map (calibrated from models.dev, USD per 1M tokens)
|
|
17
17
|
export const BUILTIN_RATES_MAP = Object.freeze({
|
|
18
18
|
'claude-opus-5-5': Object.freeze({ label: 'Claude Opus 5.5', input: 4.0, output: 20.0, cacheRead: 0.2, cacheWrite: 5.0 }),
|
|
19
19
|
'claude-opus-5': Object.freeze({ label: 'Claude Opus 5', input: 5.0, output: 25.0, cacheRead: 0.5, cacheWrite: 6.25 }),
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Standalone, zero-secret, zero-external-tool subscription quota capture & master sync for agy-family.
|
|
2
|
+
// Captures official Antigravity CLI `statusLine` JSON payloads (plan_tier + 5h/weekly remaining_fraction & reset_time)
|
|
3
|
+
// into `~/.config/agy-family/quota-cache.json`, chaining cleanly with any existing user statusLine command.
|
|
4
|
+
// NEVER reads, stores, or transmits Google OAuth tokens or client secrets.
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
-
import { createHash } from 'node:crypto';
|
|
7
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
6
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
7
|
import { homedir } from 'node:os';
|
|
9
8
|
import { dirname, join } from 'node:path';
|
|
9
|
+
import { pathToFileURL } from 'node:url';
|
|
10
10
|
import { hashEmailSha256, maskEmailHint, normalizeEmail, normalizeSha256Hex } from './account.mjs';
|
|
11
11
|
|
|
12
12
|
const EPOCH_SENTINEL_MS = 86_400_000;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
export function hashQuotaKeySha1(email) {
|
|
16
|
-
const clean = normalizeEmail(email);
|
|
17
|
-
if (!clean) return '';
|
|
18
|
-
return createHash('sha1').update(clean).digest('hex').slice(0, 12);
|
|
19
|
-
}
|
|
13
|
+
const RESET_TOLERANCE_MS = 5_000;
|
|
14
|
+
const MAX_CACHE_AGE_MS = 6 * 60 * 60 * 1000;
|
|
20
15
|
|
|
21
16
|
export function normalizePlanTier(raw) {
|
|
22
17
|
const s = String(raw || '').trim();
|
|
@@ -28,10 +23,6 @@ export function normalizePlanTier(raw) {
|
|
|
28
23
|
return s.slice(0, 40);
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
export function agyBarDir(home = homedir()) {
|
|
32
|
-
return join(home, '.gemini', 'config', 'agy-bar');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
26
|
export function masterConfigPath(home = homedir()) {
|
|
36
27
|
return join(home, '.config', 'agy-family', 'master.json');
|
|
37
28
|
}
|
|
@@ -40,20 +31,37 @@ export function localQuotaCachePath(home = homedir()) {
|
|
|
40
31
|
return join(home, '.config', 'agy-family', 'quota-cache.json');
|
|
41
32
|
}
|
|
42
33
|
|
|
34
|
+
export function statusLineChainPath(home = homedir()) {
|
|
35
|
+
return join(home, '.config', 'agy-family', 'statusline-chain.json');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function agyCliSettingsPath(home = homedir()) {
|
|
39
|
+
return join(home, '.gemini', 'antigravity-cli', 'settings.json');
|
|
40
|
+
}
|
|
41
|
+
|
|
43
42
|
function readJsonSafe(filePath) {
|
|
44
43
|
if (!filePath || !existsSync(filePath)) return null;
|
|
45
44
|
try {
|
|
46
|
-
return JSON.parse(readFileSync(filePath, 'utf8'));
|
|
45
|
+
return JSON.parse(readFileSync(filePath, 'utf8').replace(/^\uFEFF/, ''));
|
|
47
46
|
} catch {
|
|
48
47
|
return null;
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
function
|
|
51
|
+
function writeJsonAtomic(filePath, data, mode = 0o600) {
|
|
53
52
|
mkdirSync(dirname(filePath), { recursive: true });
|
|
54
|
-
|
|
53
|
+
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
54
|
+
writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`, { encoding: 'utf8', mode });
|
|
55
|
+
try {
|
|
56
|
+
renameSync(tmp, filePath);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
try {
|
|
59
|
+
rmSync(tmp, { force: true });
|
|
60
|
+
} catch {}
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
55
63
|
try {
|
|
56
|
-
chmodSync(filePath,
|
|
64
|
+
chmodSync(filePath, mode);
|
|
57
65
|
} catch {
|
|
58
66
|
// Ignore on non-POSIX filesystems.
|
|
59
67
|
}
|
|
@@ -66,95 +74,205 @@ export function readMasterConfig({ home = homedir() } = {}) {
|
|
|
66
74
|
|
|
67
75
|
export function writeMasterConfig(data, { home = homedir() } = {}) {
|
|
68
76
|
const fp = masterConfigPath(home);
|
|
69
|
-
|
|
77
|
+
writeJsonAtomic(fp, data, 0o600);
|
|
70
78
|
return fp;
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
export function removeMasterConfig({ home = homedir() } = {}) {
|
|
74
82
|
const fp = masterConfigPath(home);
|
|
75
|
-
|
|
76
|
-
rmSync(fp, { force: true });
|
|
77
|
-
|
|
83
|
+
const hadCfg = existsSync(fp);
|
|
84
|
+
if (hadCfg) rmSync(fp, { force: true });
|
|
85
|
+
const qFp = localQuotaCachePath(home);
|
|
86
|
+
if (existsSync(qFp)) rmSync(qFp, { force: true });
|
|
87
|
+
return hadCfg;
|
|
78
88
|
}
|
|
79
89
|
|
|
80
|
-
export function
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
return idx.accounts
|
|
84
|
-
.filter((a) => a && typeof a === 'object')
|
|
85
|
-
.map((a) => ({
|
|
86
|
-
id: String(a.id || ''),
|
|
87
|
-
alias: String(a.alias || ''),
|
|
88
|
-
maskedEmail: String(a.maskedEmail || ''),
|
|
89
|
-
quotaKey: String(a.quotaKey || a.emailHash || ''),
|
|
90
|
-
tier: normalizePlanTier(a.tier || ''),
|
|
91
|
-
rawTier: String(a.tier || ''),
|
|
92
|
-
authStatus: String(a.authStatus || 'ok'),
|
|
93
|
-
lastRefreshedAt: Number(a.lastRefreshedAt) || null,
|
|
94
|
-
}));
|
|
90
|
+
export function readLocalQuotaCache({ home = homedir() } = {}) {
|
|
91
|
+
const raw = readJsonSafe(localQuotaCachePath(home));
|
|
92
|
+
return raw && typeof raw === 'object' ? raw : null;
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
export function
|
|
98
|
-
const
|
|
99
|
-
|
|
95
|
+
export function writeLocalQuotaCache(cacheObj, { home = homedir() } = {}) {
|
|
96
|
+
const fp = localQuotaCachePath(home);
|
|
97
|
+
writeJsonAtomic(fp, cacheObj, 0o600);
|
|
98
|
+
return fp;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
function
|
|
101
|
+
export function readLocalActiveEmailHint({ home = homedir(), platform = process.platform, env = process.env } = {}) {
|
|
103
102
|
const tokPath = join(home, '.gemini', 'jetski-standalone-oauth-token');
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
const parsed = JSON.parse(raw);
|
|
112
|
-
if (!parsed || typeof parsed !== 'object') return '';
|
|
113
|
-
const direct = normalizeEmail(parsed.id_token_email || parsed.email || parsed.token?.email || '');
|
|
114
|
-
if (direct) return direct;
|
|
115
|
-
const jwt = parsed.id_token || parsed.token?.id_token || '';
|
|
116
|
-
if (typeof jwt === 'string' && jwt.includes('.')) {
|
|
117
|
-
const parts = jwt.trim().split('.');
|
|
118
|
-
if (parts[1]) {
|
|
119
|
-
const claims = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8'));
|
|
120
|
-
return normalizeEmail(claims?.email || '');
|
|
103
|
+
if (existsSync(tokPath)) {
|
|
104
|
+
try {
|
|
105
|
+
let raw = readFileSync(tokPath, 'utf8').trim();
|
|
106
|
+
const prefix = 'go-keyring-base64:';
|
|
107
|
+
if (raw.startsWith(prefix)) {
|
|
108
|
+
raw = Buffer.from(raw.slice(prefix.length), 'base64').toString('utf8').trim();
|
|
121
109
|
}
|
|
110
|
+
const parsed = JSON.parse(raw);
|
|
111
|
+
let email = normalizeEmail(parsed?.id_token_email || parsed?.email || parsed?.token?.email || '');
|
|
112
|
+
if (!email) {
|
|
113
|
+
const jwt = parsed?.id_token || parsed?.token?.id_token || '';
|
|
114
|
+
if (typeof jwt === 'string' && jwt.includes('.')) {
|
|
115
|
+
const p1 = jwt.trim().split('.')[1];
|
|
116
|
+
if (p1) {
|
|
117
|
+
const claims = JSON.parse(Buffer.from(p1, 'base64url').toString('utf8'));
|
|
118
|
+
email = normalizeEmail(claims?.email || '');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (email) {
|
|
123
|
+
return { emailHash: hashEmailSha256(email), maskedEmail: maskEmailHint(email), source: 'cli-token' };
|
|
124
|
+
}
|
|
125
|
+
} catch {}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Fallback: Antigravity 2.0 Desktop app_storage.json
|
|
129
|
+
const useEnvDirs = home === homedir() || env !== process.env;
|
|
130
|
+
const appStorageCandidates =
|
|
131
|
+
platform === 'darwin'
|
|
132
|
+
? [join(home, 'Library', 'Application Support', 'Antigravity', 'app_storage.json')]
|
|
133
|
+
: platform === 'win32'
|
|
134
|
+
? [
|
|
135
|
+
join((useEnvDirs && env.APPDATA) || join(home, 'AppData', 'Roaming'), 'Antigravity', 'app_storage.json'),
|
|
136
|
+
join((useEnvDirs && env.LOCALAPPDATA) || join(home, 'AppData', 'Local'), 'Antigravity', 'app_storage.json'),
|
|
137
|
+
]
|
|
138
|
+
: [join((useEnvDirs && env.XDG_CONFIG_HOME) || join(home, '.config'), 'Antigravity', 'app_storage.json')];
|
|
139
|
+
|
|
140
|
+
for (const fp of appStorageCandidates) {
|
|
141
|
+
const parsed = readJsonSafe(fp);
|
|
142
|
+
const email = normalizeEmail(
|
|
143
|
+
parsed?.['agy.onboarding.lastLoginUsername'] || parsed?.['agy.auth.email'] || parsed?.email || '',
|
|
144
|
+
);
|
|
145
|
+
if (email) {
|
|
146
|
+
return { emailHash: hashEmailSha256(email), maskedEmail: maskEmailHint(email), source: 'desktop-app-storage' };
|
|
122
147
|
}
|
|
123
|
-
} catch {
|
|
124
|
-
return '';
|
|
125
148
|
}
|
|
126
|
-
return
|
|
149
|
+
return null;
|
|
127
150
|
}
|
|
128
151
|
|
|
129
|
-
function normalizeBucketEntry(raw) {
|
|
152
|
+
function normalizeBucketEntry(raw, observedAt) {
|
|
130
153
|
if (!raw || typeof raw !== 'object' || raw.disabled === true) return null;
|
|
131
154
|
const f = Number(raw.remaining_fraction ?? raw.remainingFraction ?? raw.remaining);
|
|
132
155
|
if (!Number.isFinite(f) || f < 0) return null;
|
|
133
|
-
const clamped = Math.max(0, Math.min(1, f > 1 && f <= 100 ? f / 100 : f));
|
|
156
|
+
const clamped = Math.round(Math.max(0, Math.min(1, f > 1 && f <= 100 ? f / 100 : f)) * 10_000) / 10_000;
|
|
134
157
|
const rawReset = raw.reset_ts ?? raw.resetAt ?? raw.reset_time ?? raw.resetTime ?? null;
|
|
135
158
|
let resetTime = null;
|
|
159
|
+
let resetTs = null;
|
|
136
160
|
if (rawReset !== null && rawReset !== undefined && rawReset !== '') {
|
|
137
161
|
const ms = typeof rawReset === 'number' ? rawReset : Date.parse(String(rawReset));
|
|
138
162
|
if (Number.isFinite(ms) && ms > EPOCH_SENTINEL_MS) {
|
|
139
|
-
|
|
163
|
+
resetTs = Math.round(ms);
|
|
164
|
+
resetTime = new Date(resetTs).toISOString();
|
|
140
165
|
}
|
|
141
166
|
}
|
|
142
167
|
return {
|
|
143
|
-
remainingFraction:
|
|
168
|
+
remainingFraction: clamped,
|
|
144
169
|
...(resetTime ? { resetTime } : {}),
|
|
170
|
+
...(resetTs ? { resetTs } : {}),
|
|
171
|
+
observedAt: Number(raw.observedAt) || observedAt,
|
|
145
172
|
};
|
|
146
173
|
}
|
|
147
174
|
|
|
148
|
-
function
|
|
175
|
+
function pickFresherQuotaBucket(incoming, cached, now) {
|
|
176
|
+
if (!incoming) return cached || null;
|
|
177
|
+
if (!cached) return incoming;
|
|
178
|
+
if (now - (Number(cached.observedAt) || 0) > MAX_CACHE_AGE_MS) return incoming;
|
|
179
|
+
const inTs = incoming.resetTs || null;
|
|
180
|
+
const caTs = cached.resetTs || null;
|
|
181
|
+
if (inTs && caTs) {
|
|
182
|
+
if (caTs > inTs + RESET_TOLERANCE_MS) return cached;
|
|
183
|
+
if (inTs > caTs + RESET_TOLERANCE_MS) return incoming;
|
|
184
|
+
return cached.remainingFraction < incoming.remainingFraction - 1e-6 ? cached : incoming;
|
|
185
|
+
}
|
|
186
|
+
if (!inTs && caTs && caTs > now && incoming.remainingFraction >= 0.999 && cached.remainingFraction < 0.999) {
|
|
187
|
+
return cached;
|
|
188
|
+
}
|
|
189
|
+
return incoming;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function normalizeBucketsForOutput(rawBuckets, observedAt) {
|
|
149
193
|
if (!rawBuckets || typeof rawBuckets !== 'object') return null;
|
|
150
194
|
const out = {};
|
|
151
195
|
for (const key of ['gemini-5h', 'gemini-weekly', '3p-5h', '3p-weekly']) {
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
196
|
+
const b = normalizeBucketEntry(rawBuckets[key], observedAt);
|
|
197
|
+
if (b) {
|
|
198
|
+
out[key] = {
|
|
199
|
+
remainingFraction: b.remainingFraction,
|
|
200
|
+
...(b.resetTime ? { resetTime: b.resetTime } : {}),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
154
203
|
}
|
|
155
204
|
return Object.keys(out).length > 0 ? out : null;
|
|
156
205
|
}
|
|
157
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Passively ingest Antigravity CLI's official `statusLine` JSON payload into `~/.config/agy-family/quota-cache.json`.
|
|
209
|
+
* Never stores plaintext email — stores only SHA-256 hash + masked hint + numeric quota fractions & reset timestamps.
|
|
210
|
+
*/
|
|
211
|
+
export function ingestStatusLineQuotaPayload(payload, { home = homedir(), now = Date.now() } = {}) {
|
|
212
|
+
if (!payload || typeof payload !== 'object' || !payload.quota || typeof payload.quota !== 'object') {
|
|
213
|
+
return { captured: false, matchedMaster: false, quota: null };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const rawEmail = normalizeEmail(payload.email || payload.account?.email || payload.user_email || '');
|
|
217
|
+
const emailHash = rawEmail ? hashEmailSha256(rawEmail) : '';
|
|
218
|
+
const maskedEmail = rawEmail ? maskEmailHint(rawEmail) : '';
|
|
219
|
+
const accountKey = emailHash || 'default';
|
|
220
|
+
const planTier = normalizePlanTier(payload.plan_tier || payload.planTier || payload.tier || '');
|
|
221
|
+
|
|
222
|
+
const existing = readLocalQuotaCache({ home }) || { version: 1, accounts: {} };
|
|
223
|
+
const accounts = existing.accounts && typeof existing.accounts === 'object' ? { ...existing.accounts } : {};
|
|
224
|
+
const prevSlot = accounts[accountKey] && typeof accounts[accountKey] === 'object' ? accounts[accountKey] : {};
|
|
225
|
+
const prevBuckets = prevSlot.buckets && typeof prevSlot.buckets === 'object' ? prevSlot.buckets : {};
|
|
226
|
+
|
|
227
|
+
const mergedBuckets = {};
|
|
228
|
+
for (const key of ['gemini-5h', 'gemini-weekly', '3p-5h', '3p-weekly']) {
|
|
229
|
+
const inc = normalizeBucketEntry(payload.quota[key], now);
|
|
230
|
+
const prev = normalizeBucketEntry(prevBuckets[key], prevSlot.updatedAt || now);
|
|
231
|
+
const winner = pickFresherQuotaBucket(inc, prev, now);
|
|
232
|
+
if (winner) mergedBuckets[key] = winner;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (Object.keys(mergedBuckets).length === 0) {
|
|
236
|
+
return { captured: false, matchedMaster: false, quota: null };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const nextSlot = {
|
|
240
|
+
emailHash,
|
|
241
|
+
accountLabel: maskedEmail || prevSlot.accountLabel || '',
|
|
242
|
+
planTier: planTier || prevSlot.planTier || '',
|
|
243
|
+
source: 'agy-family-statusline',
|
|
244
|
+
observedAt: now,
|
|
245
|
+
updatedAt: now,
|
|
246
|
+
buckets: mergedBuckets,
|
|
247
|
+
};
|
|
248
|
+
accounts[accountKey] = nextSlot;
|
|
249
|
+
|
|
250
|
+
writeLocalQuotaCache(
|
|
251
|
+
{
|
|
252
|
+
version: 1,
|
|
253
|
+
lastAccountKey: accountKey,
|
|
254
|
+
updatedAt: now,
|
|
255
|
+
accounts,
|
|
256
|
+
},
|
|
257
|
+
{ home },
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const mCfg = readMasterConfig({ home });
|
|
261
|
+
const mHash = normalizeSha256Hex(mCfg?.emailHash || '');
|
|
262
|
+
const matchedMaster = Boolean(mCfg && (!mHash || (emailHash && emailHash === mHash)));
|
|
263
|
+
|
|
264
|
+
const quotaOut = {
|
|
265
|
+
planTier: nextSlot.planTier,
|
|
266
|
+
accountLabel: nextSlot.accountLabel || mCfg?.maskedEmail || '',
|
|
267
|
+
source: nextSlot.source,
|
|
268
|
+
isMasterExplicit: matchedMaster,
|
|
269
|
+
observedAt: now,
|
|
270
|
+
buckets: normalizeBucketsForOutput(mergedBuckets, now),
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
return { captured: true, matchedMaster, emailHash, quota: quotaOut };
|
|
274
|
+
}
|
|
275
|
+
|
|
158
276
|
export function extractLocalSubscriptionQuota({
|
|
159
277
|
home = homedir(),
|
|
160
278
|
masterConfig = undefined,
|
|
@@ -162,110 +280,168 @@ export function extractLocalSubscriptionQuota({
|
|
|
162
280
|
now = Date.now(),
|
|
163
281
|
} = {}) {
|
|
164
282
|
const mCfg = masterConfig !== undefined ? masterConfig : readMasterConfig({ home });
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Number(cacheEntry?.updatedAt) || 0,
|
|
183
|
-
...Object.values(cacheEntry?.buckets || {}).map((b) => Number(b?.observedAt) || 0),
|
|
184
|
-
);
|
|
185
|
-
return {
|
|
186
|
-
planTier: matchedAcct?.tier || normalizePlanTier(mCfg.planTier || ''),
|
|
187
|
-
accountLabel: matchedAcct?.maskedEmail || mCfg.maskedEmail || mCfg.alias || '',
|
|
188
|
-
source: 'agy-bar',
|
|
189
|
-
isMasterExplicit: true,
|
|
190
|
-
observedAt: obsMs > EPOCH_SENTINEL_MS ? obsMs : now,
|
|
191
|
-
buckets,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
283
|
+
const cache = readLocalQuotaCache({ home });
|
|
284
|
+
if (!cache || typeof cache !== 'object') return null;
|
|
285
|
+
|
|
286
|
+
const pickSlot = (key) => {
|
|
287
|
+
if (!key || !cache.accounts || typeof cache.accounts !== 'object') return null;
|
|
288
|
+
const slot = cache.accounts[key];
|
|
289
|
+
return slot && typeof slot === 'object' ? slot : null;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
let slot = null;
|
|
293
|
+
let isMasterExplicit = false;
|
|
294
|
+
|
|
295
|
+
// Priority 1: Explicitly bound Master Account by SHA-256 emailHash
|
|
296
|
+
const mHash = normalizeSha256Hex(mCfg?.emailHash || '');
|
|
297
|
+
if (mCfg) {
|
|
298
|
+
slot = (mHash && pickSlot(mHash)) || (!mHash && pickSlot(cache.lastAccountKey)) || (!mHash && pickSlot('default')) || null;
|
|
299
|
+
if (slot) isMasterExplicit = true;
|
|
194
300
|
}
|
|
195
301
|
|
|
196
|
-
// Priority 2:
|
|
197
|
-
const activeEmail = readLocalActiveEmailInMemory(home);
|
|
302
|
+
// Priority 2: Expected family member emailHash
|
|
198
303
|
const cleanExpected = normalizeSha256Hex(expectedEmailHash);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (activeEmail && emailAllowed && barCache) {
|
|
203
|
-
const qKey = hashQuotaKeySha1(activeEmail);
|
|
204
|
-
const cacheEntry =
|
|
205
|
-
(qKey && barCache.accounts?.[qKey]) ||
|
|
206
|
-
(qKey && barCache.accountKey === qKey ? { updatedAt: barCache.updatedAt, buckets: barCache.buckets } : null) ||
|
|
207
|
-
null;
|
|
208
|
-
const buckets = normalizeQuotaBucketsMap(cacheEntry?.buckets);
|
|
209
|
-
if (buckets) {
|
|
210
|
-
const matchedAcct = barAccounts.find((a) => a.quotaKey === qKey) || null;
|
|
211
|
-
const obsMs = Math.max(
|
|
212
|
-
Number(cacheEntry?.updatedAt) || 0,
|
|
213
|
-
...Object.values(cacheEntry?.buckets || {}).map((b) => Number(b?.observedAt) || 0),
|
|
214
|
-
);
|
|
215
|
-
return {
|
|
216
|
-
planTier: matchedAcct?.tier || '',
|
|
217
|
-
accountLabel: matchedAcct?.maskedEmail || maskEmailHint(activeEmail) || '',
|
|
218
|
-
source: 'agy-bar',
|
|
219
|
-
isMasterExplicit: false,
|
|
220
|
-
observedAt: obsMs > EPOCH_SENTINEL_MS ? obsMs : now,
|
|
221
|
-
buckets,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
304
|
+
if (!slot && cleanExpected) {
|
|
305
|
+
slot = pickSlot(cleanExpected);
|
|
224
306
|
}
|
|
225
307
|
|
|
226
|
-
// Priority 3:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
planTier: normalizePlanTier(localCache.planTier || localCache.tier || ''),
|
|
233
|
-
accountLabel: String(localCache.accountLabel || mCfg?.maskedEmail || mCfg?.alias || ''),
|
|
234
|
-
source: String(localCache.source || 'local-cache'),
|
|
235
|
-
isMasterExplicit: Boolean(localCache.isMasterExplicit || mCfg),
|
|
236
|
-
observedAt: Number(localCache.observedAt || localCache.updatedAt) || now,
|
|
237
|
-
buckets,
|
|
238
|
-
};
|
|
308
|
+
// Priority 3: Unbound single-account fallback (legacy flat cache or lastAccountKey when no email hash bound)
|
|
309
|
+
if (!slot && !cleanExpected && !mHash) {
|
|
310
|
+
if (cache.buckets && typeof cache.buckets === 'object') {
|
|
311
|
+
slot = cache;
|
|
312
|
+
} else {
|
|
313
|
+
slot = pickSlot(cache.lastAccountKey) || pickSlot('default');
|
|
239
314
|
}
|
|
240
315
|
}
|
|
241
316
|
|
|
242
|
-
return null;
|
|
317
|
+
if (!slot) return null;
|
|
318
|
+
const obs = Number(slot.observedAt || slot.updatedAt) || now;
|
|
319
|
+
const buckets = normalizeBucketsForOutput(slot.buckets, obs);
|
|
320
|
+
if (!buckets) return null;
|
|
321
|
+
|
|
322
|
+
return {
|
|
323
|
+
planTier: normalizePlanTier(slot.planTier || slot.tier || mCfg?.planTier || ''),
|
|
324
|
+
accountLabel: String(slot.accountLabel || mCfg?.maskedEmail || ''),
|
|
325
|
+
source: String(slot.source || 'agy-family-statusline'),
|
|
326
|
+
isMasterExplicit,
|
|
327
|
+
observedAt: obs,
|
|
328
|
+
buckets,
|
|
329
|
+
};
|
|
243
330
|
}
|
|
244
331
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
332
|
+
function shQuote(val) {
|
|
333
|
+
return `'${String(val).replaceAll("'", "'\\''")}'`;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function buildStatusLineTapCommand(executable, cliPath, platform = process.platform) {
|
|
337
|
+
if (platform === 'win32') {
|
|
338
|
+
const encoded = Buffer.from(pathToFileURL(cliPath).href).toString('base64');
|
|
339
|
+
return `node -e "process.argv.push('hook-run','statusline');import(Buffer.from('${encoded}','base64').toString())"`;
|
|
252
340
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
341
|
+
return `${shQuote(executable)} ${shQuote(cliPath)} hook-run statusline`;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function isManagedStatusLineCommand(cmd) {
|
|
345
|
+
const s = String(cmd || '');
|
|
346
|
+
return s.includes('agy-family') && s.includes('statusline');
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function installStatusLineTap({
|
|
350
|
+
executable = process.execPath,
|
|
351
|
+
cliPath,
|
|
352
|
+
home = homedir(),
|
|
353
|
+
platform = process.platform,
|
|
354
|
+
} = {}) {
|
|
355
|
+
const settingsFile = agyCliSettingsPath(home);
|
|
356
|
+
const chainFile = statusLineChainPath(home);
|
|
357
|
+
const existingSettings = readJsonSafe(settingsFile) || {};
|
|
358
|
+
const existingSl = existingSettings.statusLine && typeof existingSettings.statusLine === 'object' ? existingSettings.statusLine : null;
|
|
359
|
+
|
|
360
|
+
let chainedCommand = '';
|
|
361
|
+
if (existingSl && typeof existingSl.command === 'string' && existingSl.command.trim() && !isManagedStatusLineCommand(existingSl.command)) {
|
|
362
|
+
chainedCommand = existingSl.command.trim();
|
|
363
|
+
writeJsonAtomic(
|
|
364
|
+
chainFile,
|
|
365
|
+
{
|
|
366
|
+
command: chainedCommand,
|
|
367
|
+
enabled: existingSl.enabled !== false,
|
|
368
|
+
type: existingSl.type || 'command',
|
|
369
|
+
savedAt: Date.now(),
|
|
370
|
+
},
|
|
371
|
+
0o600,
|
|
372
|
+
);
|
|
373
|
+
} else {
|
|
374
|
+
const savedChain = readJsonSafe(chainFile);
|
|
375
|
+
if (savedChain?.command) chainedCommand = String(savedChain.command);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const tapCommand = buildStatusLineTapCommand(executable, cliPath, platform);
|
|
379
|
+
const nextSettings = {
|
|
380
|
+
...existingSettings,
|
|
381
|
+
statusLine: {
|
|
382
|
+
type: 'command',
|
|
383
|
+
command: tapCommand,
|
|
384
|
+
enabled: true,
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
writeJsonAtomic(settingsFile, nextSettings, 0o600);
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
settingsFile,
|
|
391
|
+
tapCommand,
|
|
392
|
+
chained: Boolean(chainedCommand),
|
|
393
|
+
chainedCommand,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export function uninstallStatusLineTap({ home = homedir() } = {}) {
|
|
398
|
+
const settingsFile = agyCliSettingsPath(home);
|
|
399
|
+
const chainFile = statusLineChainPath(home);
|
|
400
|
+
const settings = readJsonSafe(settingsFile);
|
|
401
|
+
const chain = readJsonSafe(chainFile);
|
|
402
|
+
let restored = false;
|
|
403
|
+
|
|
404
|
+
if (settings && typeof settings === 'object') {
|
|
405
|
+
const curCmd = settings.statusLine?.command || '';
|
|
406
|
+
if (isManagedStatusLineCommand(curCmd)) {
|
|
407
|
+
const next = { ...settings };
|
|
408
|
+
if (chain?.command) {
|
|
409
|
+
next.statusLine = {
|
|
410
|
+
type: chain.type || 'command',
|
|
411
|
+
command: chain.command,
|
|
412
|
+
enabled: chain.enabled !== false,
|
|
413
|
+
};
|
|
414
|
+
} else {
|
|
415
|
+
delete next.statusLine;
|
|
416
|
+
}
|
|
417
|
+
writeJsonAtomic(settingsFile, next, 0o600);
|
|
418
|
+
restored = true;
|
|
419
|
+
}
|
|
262
420
|
}
|
|
421
|
+
if (existsSync(chainFile)) rmSync(chainFile, { force: true });
|
|
422
|
+
return { restored, hadChained: Boolean(chain?.command) };
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export function inspectStatusLineTap({ home = homedir() } = {}) {
|
|
426
|
+
const settings = readJsonSafe(agyCliSettingsPath(home));
|
|
427
|
+
const chain = readJsonSafe(statusLineChainPath(home));
|
|
428
|
+
const cmd = settings?.statusLine?.command || '';
|
|
429
|
+
return {
|
|
430
|
+
installed: isManagedStatusLineCommand(cmd),
|
|
431
|
+
enabled: Boolean(settings?.statusLine?.enabled !== false && isManagedStatusLineCommand(cmd)),
|
|
432
|
+
chained: Boolean(chain?.command),
|
|
433
|
+
};
|
|
263
434
|
}
|
|
264
435
|
|
|
265
|
-
export function
|
|
266
|
-
if (!
|
|
267
|
-
|
|
268
|
-
|
|
436
|
+
export function formatCompactStatusLineOutput(quota) {
|
|
437
|
+
if (!quota || !quota.buckets) return '';
|
|
438
|
+
const tier = (quota.planTier || '').replace(/^Google AI\s+/i, '').trim() || 'AGY';
|
|
439
|
+
const g5 = quota.buckets['gemini-5h']?.remainingFraction;
|
|
440
|
+
const gw = quota.buckets['gemini-weekly']?.remainingFraction;
|
|
441
|
+
const parts = [tier];
|
|
442
|
+
if (g5 !== undefined) parts.push(`G5h ${Math.round(g5 * 100)}%`);
|
|
443
|
+
if (gw !== undefined) parts.push(`Wk ${Math.round(gw * 100)}%`);
|
|
444
|
+
return parts.join(' · ');
|
|
269
445
|
}
|
|
270
446
|
|
|
271
447
|
export async function pushMasterQuotaToServer({
|
|
@@ -83,7 +83,7 @@ export function diffSyncBuckets(buckets, syncedHashes = null, { fullSync = false
|
|
|
83
83
|
export async function buildSyncPayload({
|
|
84
84
|
deviceId,
|
|
85
85
|
clientKind = 'cli',
|
|
86
|
-
clientVersion = '0.
|
|
86
|
+
clientVersion = '0.6.0',
|
|
87
87
|
home,
|
|
88
88
|
roots = null,
|
|
89
89
|
sourceFilter = 'all',
|
|
@@ -164,7 +164,7 @@ export async function buildSyncPayload({
|
|
|
164
164
|
deviceId: String(deviceId || deriveAnonymousDeviceId()).slice(0, 32),
|
|
165
165
|
client: {
|
|
166
166
|
kind: clientKind === 'extension' ? 'extension' : 'cli',
|
|
167
|
-
version: String(clientVersion || '0.
|
|
167
|
+
version: String(clientVersion || '0.6.0').slice(0, 24),
|
|
168
168
|
...(platformLabel ? { platform: platformLabel } : {}),
|
|
169
169
|
},
|
|
170
170
|
account: {
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { FAVICON_SVG, renderDashboardHtml } from './ui.mjs';
|
|
27
27
|
import { dispatchWebhook, sendDedupedAlert, validateWebhookUrl } from './webhooks.mjs';
|
|
28
28
|
|
|
29
|
-
export const SERVER_VERSION = '0.
|
|
29
|
+
export const SERVER_VERSION = '0.6.0';
|
|
30
30
|
const MAX_BUCKETS_PER_SYNC = 1000;
|
|
31
31
|
const MAX_DEVICES_PER_MEMBER = 8;
|
|
32
32
|
const MAX_TOKENS_PER_BUCKET = 500_000_000;
|
|
@@ -1924,7 +1924,7 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
|
|
|
1924
1924
|
|
|
1925
1925
|
<footer class="foot">
|
|
1926
1926
|
<span data-i18n="privacyNote">隐私承诺:客户端仅只读扫描本地 SQLite 数值元数据,绝不上传 Prompt、代码、文件路径或 Google 凭据。</span>
|
|
1927
|
-
<span class="mono">agy-family v0.
|
|
1927
|
+
<span class="mono">agy-family v0.6.0 · MIT</span>
|
|
1928
1928
|
</footer>
|
|
1929
1929
|
</main>
|
|
1930
1930
|
|
|
@@ -2044,10 +2044,10 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
|
|
|
2044
2044
|
<div class="sec-h" data-i18n="masterAutoSyncHead">命令行自动同步主号订阅额度(推荐)</div>
|
|
2045
2045
|
<div class="guide-card" style="margin-bottom:12px">
|
|
2046
2046
|
<div style="font-size:12px;color:var(--body);line-height:1.55" id="masterCliGuideDesc">
|
|
2047
|
-
|
|
2047
|
+
在主号电脑运行下方命令,内置被动采集钩子自动从 Antigravity 官方 <code>statusLine</code> 捕获 5h / 周订阅余量并同步到看板(<strong>完全独立于单一 <code>agy-family</code> 包、不依赖任何其他工具、不读取 Google 凭据</strong>;若原本已装其他状态栏会自动透明串联保留):
|
|
2048
2048
|
</div>
|
|
2049
2049
|
<div style="display:flex;align-items:center;gap:8px;margin-top:8px">
|
|
2050
|
-
<div class="code-block mono" style="flex:1;margin:0" id="masterCliCmd">agy-family master bind</div>
|
|
2050
|
+
<div class="code-block mono" style="flex:1;margin:0" id="masterCliCmd">agy-family master bind --daemon</div>
|
|
2051
2051
|
<button type="button" class="btn btn-sm" id="copyMasterCmdBtn">复制</button>
|
|
2052
2052
|
</div>
|
|
2053
2053
|
</div>
|