agy-family 0.6.3 → 0.6.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-family",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
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",
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
upsertHostEntry,
|
|
72
72
|
} from '../src/host.mjs';
|
|
73
73
|
|
|
74
|
-
const CLI_VERSION = '0.6.
|
|
74
|
+
const CLI_VERSION = '0.6.4';
|
|
75
75
|
const THIS_CLI_PATH = fileURLToPath(import.meta.url);
|
|
76
76
|
const PACKAGE_ROOT = resolve(dirname(THIS_CLI_PATH), '..', '..', '..');
|
|
77
77
|
|
|
@@ -784,7 +784,7 @@ async function main() {
|
|
|
784
784
|
|
|
785
785
|
console.log('👤 本机当前 Antigravity 账号:');
|
|
786
786
|
if (localAcct) {
|
|
787
|
-
console.log(` ${localAcct.maskedEmail} (来源: ${localAcct.source})`);
|
|
787
|
+
console.log(` ${localAcct.email || localAcct.maskedEmail} (来源: ${localAcct.source})`);
|
|
788
788
|
} else {
|
|
789
789
|
console.log(' (未检测到本地已登录的 Antigravity 账号)');
|
|
790
790
|
}
|
|
@@ -848,7 +848,7 @@ async function main() {
|
|
|
848
848
|
joinedInfo.accountMatch === 'matched'
|
|
849
849
|
? '✓ 与本机当前账号匹配'
|
|
850
850
|
: joinedInfo.accountMatch === 'mismatch'
|
|
851
|
-
? `⚠ 与本机当前账号(${localAcct?.maskedEmail || '未知'})不匹配,已暂停上报`
|
|
851
|
+
? `⚠ 与本机当前账号(${localAcct?.email || localAcct?.maskedEmail || '未知'})不匹配,已暂停上报`
|
|
852
852
|
: '已绑定 SHA-256 邮箱';
|
|
853
853
|
console.log(` 绑定号 : ${joinedInfo.emailHint ? `${joinedInfo.emailHint} · ` : ''}${matchLabel}`);
|
|
854
854
|
}
|
|
@@ -859,8 +859,13 @@ async function main() {
|
|
|
859
859
|
console.log('\n⚙ 本地自动化:');
|
|
860
860
|
console.log(` /family 钩子 : ${hookSt.hookInstalled && hookSt.hookEnabled ? '已启用' : '未启用'}`);
|
|
861
861
|
console.log(` 定时守护进程 : ${daemonSt.installed ? `已安装 (${daemonSt.kind})` : '未安装'}`);
|
|
862
|
+
const masterDisplay = mCfg?.emailAddress || mCfg?.maskedEmail || '已绑定';
|
|
863
|
+
const masterMatchNote =
|
|
864
|
+
mCfg?.emailHash && localAcct?.emailHash && mCfg.emailHash !== localAcct.emailHash
|
|
865
|
+
? ` · 当前本机为 ${localAcct.email || localAcct.maskedEmail}(已隔离保护,不覆盖主号)`
|
|
866
|
+
: '';
|
|
862
867
|
console.log(
|
|
863
|
-
` 主号余量采集 : ${mCfg ? `${
|
|
868
|
+
` 主号余量采集 : ${mCfg ? `${masterDisplay} · ${tapSt.installed ? (tapSt.chained ? '已激活 (与原状态栏链式共存)' : '已激活 (独立)') : '未安装 statusLine 钩子'}${masterMatchNote}` : '未绑定'}`,
|
|
864
869
|
);
|
|
865
870
|
|
|
866
871
|
console.log('\n快捷命令:');
|
|
@@ -1261,20 +1266,43 @@ async function main() {
|
|
|
1261
1266
|
if (action === 'bind') {
|
|
1262
1267
|
const explicitEmail = readFlag(args, '--email').trim().toLowerCase();
|
|
1263
1268
|
let emailHash = '';
|
|
1269
|
+
let emailAddress = '';
|
|
1264
1270
|
let maskedEmail = '';
|
|
1271
|
+
let boundSource = '';
|
|
1272
|
+
let boardMgr = null;
|
|
1273
|
+
|
|
1274
|
+
if (targetUrl && targetKey) {
|
|
1275
|
+
try {
|
|
1276
|
+
const ov = await adminApiRequest({ url: targetUrl, adminKey: targetKey, path: '/api/admin/overview', timeoutMs: 8_000 });
|
|
1277
|
+
boardMgr = (ov.members || []).find((m) => m.role === 'manager' && m.active) || null;
|
|
1278
|
+
} catch {
|
|
1279
|
+
boardMgr = null;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1265
1283
|
if (explicitEmail) {
|
|
1266
1284
|
emailHash = hashEmailSha256(explicitEmail);
|
|
1285
|
+
emailAddress = explicitEmail;
|
|
1267
1286
|
maskedEmail = maskEmailHint(explicitEmail);
|
|
1287
|
+
boundSource = 'explicit';
|
|
1288
|
+
} else if (boardMgr && (boardMgr.expected_email_hash || boardMgr.email_address)) {
|
|
1289
|
+
emailAddress = String(boardMgr.email_address || '').trim().toLowerCase();
|
|
1290
|
+
emailHash = String(boardMgr.expected_email_hash || (emailAddress ? hashEmailSha256(emailAddress) : '')).trim().toLowerCase();
|
|
1291
|
+
maskedEmail = String(boardMgr.email_hint || (emailAddress ? maskEmailHint(emailAddress) : '')).trim();
|
|
1292
|
+
boundSource = 'board-manager';
|
|
1268
1293
|
} else {
|
|
1269
1294
|
const detected = readLocalActiveEmailHint();
|
|
1270
1295
|
if (detected) {
|
|
1271
1296
|
emailHash = detected.emailHash;
|
|
1297
|
+
emailAddress = detected.email || '';
|
|
1272
1298
|
maskedEmail = detected.maskedEmail;
|
|
1299
|
+
boundSource = detected.source || 'local';
|
|
1273
1300
|
}
|
|
1274
1301
|
}
|
|
1275
1302
|
|
|
1276
1303
|
const saved = {
|
|
1277
1304
|
emailHash,
|
|
1305
|
+
...(emailAddress ? { emailAddress } : {}),
|
|
1278
1306
|
maskedEmail,
|
|
1279
1307
|
boundAt: Date.now(),
|
|
1280
1308
|
};
|
|
@@ -1284,12 +1312,30 @@ async function main() {
|
|
|
1284
1312
|
cliPath: THIS_CLI_PATH,
|
|
1285
1313
|
});
|
|
1286
1314
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1315
|
+
const displayAcct = emailAddress || maskedEmail || '(will lock onto active agy account)';
|
|
1316
|
+
const srcNote = boundSource === 'board-manager' ? ` (aligned with board manager "${boardMgr?.name || 'Master'}")` : '';
|
|
1317
|
+
console.log(`✓ Bound Master Subscription Account: ${displayAcct}${srcNote}`);
|
|
1318
|
+
console.log(` Master Config : ${cfgFile} (zero Google tokens stored)`);
|
|
1289
1319
|
console.log(
|
|
1290
1320
|
` Quota Capture : installed built-in statusLine tap (${tap.chained ? 'chained seamlessly with your existing statusLine' : 'standalone'})`,
|
|
1291
1321
|
);
|
|
1292
1322
|
|
|
1323
|
+
if (boardMgr?.expected_email_hash && emailHash && boardMgr.expected_email_hash !== emailHash) {
|
|
1324
|
+
console.warn(
|
|
1325
|
+
`⚠ Warning: Board manager "${boardMgr.name}" is bound to ${boardMgr.email_address || boardMgr.email_hint}, which differs from ${displayAcct}. Server will reject mismatched quota updates until they match.`,
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
const localNow = readLocalActiveEmailHint();
|
|
1330
|
+
if (localNow?.emailHash && emailHash && localNow.emailHash !== emailHash) {
|
|
1331
|
+
console.log(
|
|
1332
|
+
`ℹ Note: Local Antigravity CLI is currently signed into ${localNow.email || localNow.maskedEmail} (not Master ${displayAcct}).`,
|
|
1333
|
+
);
|
|
1334
|
+
console.log(
|
|
1335
|
+
` ${localNow.email || localNow.maskedEmail} will NEVER overwrite Master quota; quota auto-syncs whenever ${displayAcct} is active in agy CLI.`,
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1293
1339
|
if (args.includes('--daemon')) {
|
|
1294
1340
|
const d = installBackgroundDaemon({ executable: process.execPath, cliPath: THIS_CLI_PATH });
|
|
1295
1341
|
if (d.kind === 'launchd' || d.kind === 'cron') {
|
|
@@ -1301,7 +1347,7 @@ async function main() {
|
|
|
1301
1347
|
if (existingQ && targetUrl && targetKey) {
|
|
1302
1348
|
await runMasterQuotaSync({ quiet: false, urlOverride: targetUrl, adminKeyOverride: targetKey });
|
|
1303
1349
|
} else if (targetUrl && targetKey) {
|
|
1304
|
-
console.log('ℹ Quota auto-captures on your next `agy` turn
|
|
1350
|
+
console.log('ℹ Quota auto-captures on your next `agy` turn signed into the Master account, or calibrate immediately with `agy-family master set`.');
|
|
1305
1351
|
} else {
|
|
1306
1352
|
console.log('ℹ No hosted board linked yet — run "agy-family deploy" or "agy-family host link".');
|
|
1307
1353
|
}
|
|
@@ -1311,9 +1357,20 @@ async function main() {
|
|
|
1311
1357
|
// Default: `agy-family master status`
|
|
1312
1358
|
const mCfg = readMasterConfig();
|
|
1313
1359
|
const tapStatus = inspectStatusLineTap();
|
|
1360
|
+
const localNow = readLocalActiveEmailHint();
|
|
1314
1361
|
console.log('Master Subscription Quota Status (100% Standalone · Zero Secrets):');
|
|
1315
1362
|
if (mCfg) {
|
|
1316
|
-
|
|
1363
|
+
const mDisp = mCfg.emailAddress || mCfg.maskedEmail || '(any active agy account)';
|
|
1364
|
+
console.log(` Bound Account : ${mDisp}`);
|
|
1365
|
+
if (localNow) {
|
|
1366
|
+
const matchStr =
|
|
1367
|
+
!mCfg.emailHash
|
|
1368
|
+
? ''
|
|
1369
|
+
: localNow.emailHash === mCfg.emailHash
|
|
1370
|
+
? ' (✓ matches Master)'
|
|
1371
|
+
: ' (≠ Master — protected from overwrite)';
|
|
1372
|
+
console.log(` Local CLI Now : ${localNow.email || localNow.maskedEmail}${matchStr}`);
|
|
1373
|
+
}
|
|
1317
1374
|
console.log(
|
|
1318
1375
|
` Quota Capture : ${tapStatus.installed ? `active (${tapStatus.chained ? 'chained with existing statusLine' : 'standalone'})` : 'not installed (run "agy-family master bind --daemon")'}`,
|
|
1319
1376
|
);
|
|
@@ -890,7 +890,7 @@ export async function runHeadlessSync({ cfg, fullSync = false, home = homedir(),
|
|
|
890
890
|
const { payload, scan, nextSyncedHashes, nextAccountLedger } = await buildSyncPayload({
|
|
891
891
|
deviceId,
|
|
892
892
|
clientKind: 'cli',
|
|
893
|
-
clientVersion: '0.6.
|
|
893
|
+
clientVersion: '0.6.4',
|
|
894
894
|
home,
|
|
895
895
|
fileCache: cache,
|
|
896
896
|
syncedHashes: prevHashes,
|
|
@@ -120,7 +120,7 @@ export function readLocalActiveEmailHint({ home = homedir(), platform = process.
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
if (email) {
|
|
123
|
-
return { emailHash: hashEmailSha256(email), maskedEmail: maskEmailHint(email), source: 'cli-token' };
|
|
123
|
+
return { email, emailHash: hashEmailSha256(email), maskedEmail: maskEmailHint(email), source: 'cli-token' };
|
|
124
124
|
}
|
|
125
125
|
} catch {}
|
|
126
126
|
}
|
|
@@ -143,7 +143,7 @@ export function readLocalActiveEmailHint({ home = homedir(), platform = process.
|
|
|
143
143
|
parsed?.['agy.onboarding.lastLoginUsername'] || parsed?.['agy.auth.email'] || parsed?.email || '',
|
|
144
144
|
);
|
|
145
145
|
if (email) {
|
|
146
|
-
return { emailHash: hashEmailSha256(email), maskedEmail: maskEmailHint(email), source: 'desktop-app-storage' };
|
|
146
|
+
return { email, emailHash: hashEmailSha256(email), maskedEmail: maskEmailHint(email), source: 'desktop-app-storage' };
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
return null;
|
|
@@ -262,8 +262,9 @@ export function ingestStatusLineQuotaPayload(payload, { home = homedir(), now =
|
|
|
262
262
|
const matchedMaster = Boolean(mCfg && (!mHash || (emailHash && emailHash === mHash)));
|
|
263
263
|
|
|
264
264
|
const quotaOut = {
|
|
265
|
+
emailHash: nextSlot.emailHash || '',
|
|
265
266
|
planTier: nextSlot.planTier,
|
|
266
|
-
accountLabel: nextSlot.accountLabel || mCfg?.maskedEmail || '',
|
|
267
|
+
accountLabel: (matchedMaster && mCfg?.emailAddress) || nextSlot.accountLabel || mCfg?.maskedEmail || '',
|
|
267
268
|
source: nextSlot.source,
|
|
268
269
|
isMasterExplicit: matchedMaster,
|
|
269
270
|
observedAt: now,
|
|
@@ -320,8 +321,9 @@ export function extractLocalSubscriptionQuota({
|
|
|
320
321
|
if (!buckets) return null;
|
|
321
322
|
|
|
322
323
|
return {
|
|
324
|
+
emailHash: normalizeSha256Hex(slot.emailHash || mHash || cleanExpected || ''),
|
|
323
325
|
planTier: normalizePlanTier(slot.planTier || slot.tier || mCfg?.planTier || ''),
|
|
324
|
-
accountLabel: String(slot.accountLabel || mCfg?.maskedEmail || ''),
|
|
326
|
+
accountLabel: String((isMasterExplicit && mCfg?.emailAddress) || slot.accountLabel || mCfg?.maskedEmail || ''),
|
|
325
327
|
source: String(slot.source || 'agy-family-statusline'),
|
|
326
328
|
isMasterExplicit,
|
|
327
329
|
observedAt: obs,
|
|
@@ -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.6.
|
|
86
|
+
clientVersion = '0.6.4',
|
|
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.6.
|
|
167
|
+
version: String(clientVersion || '0.6.4').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.6.
|
|
29
|
+
export const SERVER_VERSION = '0.6.4';
|
|
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;
|
|
@@ -1200,6 +1200,12 @@ export function createApp({
|
|
|
1200
1200
|
if (normSubQuota) {
|
|
1201
1201
|
const isMismatch = accountStatus === 'mismatch';
|
|
1202
1202
|
const isExplicitMaster = Boolean(body.subscriptionQuota?.isMasterExplicit);
|
|
1203
|
+
const incomingQuotaHash = String(body.subscriptionQuota?.emailHash || '').trim().toLowerCase();
|
|
1204
|
+
const validIncomingHash = /^[a-f0-9]{64}$/.test(incomingQuotaHash) ? incomingQuotaHash : '';
|
|
1205
|
+
const mgrBoundHash = String(member.expected_email_hash || '').trim().toLowerCase();
|
|
1206
|
+
const quotaHashMatchesManager = mgrBoundHash
|
|
1207
|
+
? (validIncomingHash ? validIncomingHash === mgrBoundHash : !isMismatch)
|
|
1208
|
+
: (!isMismatch || isExplicitMaster);
|
|
1203
1209
|
const safeLabel = normSubQuota.accountLabel || member.email_address || member.email_hint || member.name || '';
|
|
1204
1210
|
const normWithLabel = { ...normSubQuota, accountLabel: safeLabel };
|
|
1205
1211
|
if (!isMismatch) {
|
|
@@ -1208,7 +1214,7 @@ export function createApp({
|
|
|
1208
1214
|
params: buildSubscriptionQuotaParams(`member:${member.id}`, member.id, normWithLabel, now),
|
|
1209
1215
|
});
|
|
1210
1216
|
}
|
|
1211
|
-
if (member.role === 'manager' &&
|
|
1217
|
+
if (member.role === 'manager' && quotaHashMatchesManager) {
|
|
1212
1218
|
writeStmts.push({
|
|
1213
1219
|
sql: UPSERT_SUBSCRIPTION_QUOTA_SQL,
|
|
1214
1220
|
params: buildSubscriptionQuotaParams('master', member.id, normWithLabel, now),
|
|
@@ -1405,11 +1411,11 @@ export function createApp({
|
|
|
1405
1411
|
|
|
1406
1412
|
const members = (membersRows || []).map((m) => {
|
|
1407
1413
|
const q = resolvedQuotas.get(m.id);
|
|
1408
|
-
const { expected_email_hash, ...rest } = m;
|
|
1409
1414
|
return {
|
|
1410
|
-
...
|
|
1411
|
-
|
|
1412
|
-
|
|
1415
|
+
...m,
|
|
1416
|
+
expected_email_hash: m.expected_email_hash || null,
|
|
1417
|
+
account_bound: Boolean(m.expected_email_hash),
|
|
1418
|
+
account_status: m.expected_email_hash ? m.last_account_status || 'unknown' : 'unbound',
|
|
1413
1419
|
effective_quota_pct: q ? q.quotaPct : 0,
|
|
1414
1420
|
is_auto_quota: q ? q.isAutoQuota : m.quota_pct === null || m.quota_pct === undefined,
|
|
1415
1421
|
devices: devicesByMember.get(m.id) || [],
|
|
@@ -1728,7 +1734,22 @@ export function createApp({
|
|
|
1728
1734
|
400,
|
|
1729
1735
|
);
|
|
1730
1736
|
}
|
|
1731
|
-
const mgr = await db.get(
|
|
1737
|
+
const mgr = await db.get(
|
|
1738
|
+
"SELECT id, expected_email_hash, email_address, email_hint, name FROM members WHERE role = 'manager' AND active = 1 LIMIT 1",
|
|
1739
|
+
);
|
|
1740
|
+
const incomingHashRaw = String(body?.emailHash || '').trim().toLowerCase();
|
|
1741
|
+
const incomingHash = /^[a-f0-9]{64}$/.test(incomingHashRaw) ? incomingHashRaw : '';
|
|
1742
|
+
const mgrHash = String(mgr?.expected_email_hash || '').trim().toLowerCase();
|
|
1743
|
+
if (mgrHash && incomingHash && incomingHash !== mgrHash) {
|
|
1744
|
+
return adminJsonRes(
|
|
1745
|
+
{
|
|
1746
|
+
error:
|
|
1747
|
+
'Master subscription quota rejected: active account emailHash does not match the board manager bound email.',
|
|
1748
|
+
code: 'MASTER_ACCOUNT_MISMATCH',
|
|
1749
|
+
},
|
|
1750
|
+
409,
|
|
1751
|
+
);
|
|
1752
|
+
}
|
|
1732
1753
|
const normWithLabel = {
|
|
1733
1754
|
...norm,
|
|
1734
1755
|
accountLabel: norm.accountLabel || mgr?.email_address || mgr?.email_hint || mgr?.name || '',
|
|
@@ -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.6.
|
|
1927
|
+
<span class="mono">agy-family v0.6.4 · MIT</span>
|
|
1928
1928
|
</footer>
|
|
1929
1929
|
</main>
|
|
1930
1930
|
|