agy-family 0.2.4 → 0.2.5
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.2.
|
|
3
|
+
"version": "0.2.5",
|
|
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",
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Zero-dependency unified CLI client, Antigravity /family Hook host, and self-host launcher for agy-family.
|
|
3
3
|
|
|
4
|
+
const _origEmitWarning = process.emitWarning;
|
|
5
|
+
process.emitWarning = function (warning, ...args) {
|
|
6
|
+
const msg = typeof warning === 'string' ? warning : warning?.message || '';
|
|
7
|
+
const type = typeof args[0] === 'string' ? args[0] : warning?.name || '';
|
|
8
|
+
if (type === 'ExperimentalWarning' && /sqlite/i.test(msg)) return;
|
|
9
|
+
return _origEmitWarning.call(this, warning, ...args);
|
|
10
|
+
};
|
|
11
|
+
|
|
4
12
|
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
13
|
import { homedir } from 'node:os';
|
|
6
14
|
import { dirname, join } from 'node:path';
|
|
@@ -27,7 +35,7 @@ import {
|
|
|
27
35
|
uninstallBackgroundDaemon,
|
|
28
36
|
} from '../src/hook.mjs';
|
|
29
37
|
|
|
30
|
-
const CLI_VERSION = '0.2.
|
|
38
|
+
const CLI_VERSION = '0.2.5';
|
|
31
39
|
const THIS_CLI_PATH = fileURLToPath(import.meta.url);
|
|
32
40
|
|
|
33
41
|
function configBaseDir(home = homedir()) {
|
|
@@ -716,7 +716,7 @@ export async function runHeadlessSync({ cfg, fullSync = false, home = homedir(),
|
|
|
716
716
|
const { payload, scan, nextSyncedHashes, nextAccountLedger } = await buildSyncPayload({
|
|
717
717
|
deviceId,
|
|
718
718
|
clientKind: 'cli',
|
|
719
|
-
clientVersion: '0.2.
|
|
719
|
+
clientVersion: '0.2.5',
|
|
720
720
|
home,
|
|
721
721
|
fileCache: cache,
|
|
722
722
|
syncedHashes: prevHashes,
|
|
@@ -143,7 +143,11 @@ export function defaultDesktopAppStoragePaths({
|
|
|
143
143
|
}
|
|
144
144
|
if (platform === 'win32') {
|
|
145
145
|
const appData = env.APPDATA || join(home, 'AppData', 'Roaming');
|
|
146
|
-
|
|
146
|
+
const localAppData = env.LOCALAPPDATA || join(home, 'AppData', 'Local');
|
|
147
|
+
return [
|
|
148
|
+
join(appData, 'Antigravity', 'app_storage.json'),
|
|
149
|
+
join(localAppData, 'Antigravity', 'app_storage.json'),
|
|
150
|
+
];
|
|
147
151
|
}
|
|
148
152
|
const xdg = env.XDG_CONFIG_HOME || join(home, '.config');
|
|
149
153
|
return [join(xdg, 'Antigravity', 'app_storage.json')];
|
|
@@ -254,6 +258,7 @@ async function readEmailFromIdeStateDb(dbPath, sqlJsModule = null) {
|
|
|
254
258
|
export async function detectLocalActiveAccountHash({
|
|
255
259
|
home = homedir(),
|
|
256
260
|
clientKind = 'cli',
|
|
261
|
+
expectedEmailHash = '',
|
|
257
262
|
hintEmail = '',
|
|
258
263
|
hintEmailHash = '',
|
|
259
264
|
ideStateDbPath = '',
|
|
@@ -262,6 +267,7 @@ export async function detectLocalActiveAccountHash({
|
|
|
262
267
|
env = process.env,
|
|
263
268
|
now = Date.now(),
|
|
264
269
|
} = {}) {
|
|
270
|
+
const cleanExpected = normalizeSha256Hex(expectedEmailHash);
|
|
265
271
|
const explicitHint = normalizeSha256Hex(hintEmailHash) || hashEmailSha256(hintEmail) || '';
|
|
266
272
|
|
|
267
273
|
let ideHash = '';
|
|
@@ -327,8 +333,16 @@ export async function detectLocalActiveAccountHash({
|
|
|
327
333
|
primarySource = 'hook-cache';
|
|
328
334
|
}
|
|
329
335
|
} else if (cliHash && ideHash) {
|
|
330
|
-
// Unified CLI covers BOTH Desktop IDE and agy CLI:
|
|
331
|
-
|
|
336
|
+
// Unified CLI covers BOTH Desktop IDE and agy CLI:
|
|
337
|
+
// If either surface is logged into the bound family email, report verified as primary
|
|
338
|
+
// (while bySource still excludes the non-family surface's buckets independently!).
|
|
339
|
+
if (cleanExpected && ideHash === cleanExpected && cliHash !== cleanExpected) {
|
|
340
|
+
primaryHash = ideHash;
|
|
341
|
+
primarySource = ideSource;
|
|
342
|
+
} else if (cleanExpected && cliHash === cleanExpected && ideHash !== cleanExpected) {
|
|
343
|
+
primaryHash = cliHash;
|
|
344
|
+
primarySource = 'cli-token';
|
|
345
|
+
} else if (ideMtimeMs > cliMtimeMs) {
|
|
332
346
|
primaryHash = ideHash;
|
|
333
347
|
primarySource = ideSource;
|
|
334
348
|
} else {
|
|
@@ -82,7 +82,7 @@ export function diffSyncBuckets(buckets, syncedHashes = null, { fullSync = false
|
|
|
82
82
|
export async function buildSyncPayload({
|
|
83
83
|
deviceId,
|
|
84
84
|
clientKind = 'cli',
|
|
85
|
-
clientVersion = '0.2.
|
|
85
|
+
clientVersion = '0.2.5',
|
|
86
86
|
home,
|
|
87
87
|
roots = null,
|
|
88
88
|
sourceFilter = 'all',
|
|
@@ -116,6 +116,7 @@ export async function buildSyncPayload({
|
|
|
116
116
|
: await detectLocalActiveAccountHash({
|
|
117
117
|
home,
|
|
118
118
|
clientKind,
|
|
119
|
+
expectedEmailHash,
|
|
119
120
|
hintEmail,
|
|
120
121
|
ideStateDbPath,
|
|
121
122
|
sqlJsModule,
|
|
@@ -154,7 +155,7 @@ export async function buildSyncPayload({
|
|
|
154
155
|
deviceId: String(deviceId || deriveAnonymousDeviceId()).slice(0, 32),
|
|
155
156
|
client: {
|
|
156
157
|
kind: clientKind === 'extension' ? 'extension' : 'cli',
|
|
157
|
-
version: String(clientVersion || '0.2.
|
|
158
|
+
version: String(clientVersion || '0.2.5').slice(0, 24),
|
|
158
159
|
},
|
|
159
160
|
account: {
|
|
160
161
|
emailHash: effectiveReportedHash,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import { renderDashboardHtml } from './ui.mjs';
|
|
22
22
|
import { dispatchWebhook, sendDedupedAlert, validateWebhookUrl } from './webhooks.mjs';
|
|
23
23
|
|
|
24
|
-
export const SERVER_VERSION = '0.2.
|
|
24
|
+
export const SERVER_VERSION = '0.2.5';
|
|
25
25
|
const MAX_BUCKETS_PER_SYNC = 1000;
|
|
26
26
|
const MAX_DEVICES_PER_MEMBER = 8;
|
|
27
27
|
const MAX_TOKENS_PER_BUCKET = 500_000_000;
|
|
@@ -1028,6 +1028,39 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity Family Board' }
|
|
|
1028
1028
|
border: 1px solid var(--hairline);
|
|
1029
1029
|
}
|
|
1030
1030
|
.msg-line { font-size: 12px; margin-top: 7px; min-height: 16px; }
|
|
1031
|
+
.toast {
|
|
1032
|
+
position: fixed;
|
|
1033
|
+
top: 18px;
|
|
1034
|
+
left: 50%;
|
|
1035
|
+
transform: translate(-50%, -10px);
|
|
1036
|
+
z-index: 220;
|
|
1037
|
+
display: inline-flex;
|
|
1038
|
+
align-items: center;
|
|
1039
|
+
gap: 7px;
|
|
1040
|
+
padding: 8px 14px;
|
|
1041
|
+
border-radius: var(--r-pill);
|
|
1042
|
+
background: var(--ink);
|
|
1043
|
+
color: var(--canvas);
|
|
1044
|
+
border: 1px solid var(--hairline-strong);
|
|
1045
|
+
font-size: 12.5px;
|
|
1046
|
+
font-weight: 500;
|
|
1047
|
+
pointer-events: none;
|
|
1048
|
+
opacity: 0;
|
|
1049
|
+
transition: opacity 0.16s ease, transform 0.16s ease;
|
|
1050
|
+
white-space: nowrap;
|
|
1051
|
+
}
|
|
1052
|
+
.toast.show {
|
|
1053
|
+
opacity: 1;
|
|
1054
|
+
transform: translate(-50%, 0);
|
|
1055
|
+
}
|
|
1056
|
+
.toast-dot {
|
|
1057
|
+
width: 7px;
|
|
1058
|
+
height: 7px;
|
|
1059
|
+
border-radius: 50%;
|
|
1060
|
+
background: #34b385;
|
|
1061
|
+
flex-shrink: 0;
|
|
1062
|
+
}
|
|
1063
|
+
.toast.err .toast-dot { background: #f05277; }
|
|
1031
1064
|
|
|
1032
1065
|
@media (max-width: 1039px) {
|
|
1033
1066
|
body { overflow: auto; }
|
|
@@ -1205,7 +1238,7 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity Family Board' }
|
|
|
1205
1238
|
|
|
1206
1239
|
<footer class="foot">
|
|
1207
1240
|
<span data-i18n="privacyNote">隐私承诺:客户端仅只读扫描本地 SQLite 数值元数据,绝不上传 Prompt、代码、文件路径或 Google 凭据。</span>
|
|
1208
|
-
<span class="mono">agy-family v0.2.
|
|
1241
|
+
<span class="mono">agy-family v0.2.5 · MIT</span>
|
|
1209
1242
|
</footer>
|
|
1210
1243
|
</main>
|
|
1211
1244
|
|
|
@@ -1419,6 +1452,8 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity Family Board' }
|
|
|
1419
1452
|
</div>
|
|
1420
1453
|
</div>
|
|
1421
1454
|
|
|
1455
|
+
<div class="toast" id="toast" role="status" aria-live="polite"><span class="toast-dot"></span><span id="toastText"></span></div>
|
|
1456
|
+
|
|
1422
1457
|
<script>
|
|
1423
1458
|
const I18N = {
|
|
1424
1459
|
zh: {
|
|
@@ -1575,19 +1610,45 @@ const fmtAgo = (ts) => {
|
|
|
1575
1610
|
return lang === 'zh' ? d + ' 天前' : d + 'd ago';
|
|
1576
1611
|
};
|
|
1577
1612
|
|
|
1613
|
+
let toastTimer = null;
|
|
1614
|
+
function showToast(message, kind = 'ok') {
|
|
1615
|
+
const box = document.getElementById('toast');
|
|
1616
|
+
const txt = document.getElementById('toastText');
|
|
1617
|
+
if (!box || !txt) return;
|
|
1618
|
+
txt.textContent = message;
|
|
1619
|
+
box.className = 'toast show' + (kind === 'err' ? ' err' : '');
|
|
1620
|
+
if (toastTimer) clearTimeout(toastTimer);
|
|
1621
|
+
toastTimer = setTimeout(() => {
|
|
1622
|
+
box.classList.remove('show');
|
|
1623
|
+
}, 2400);
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1578
1626
|
async function copyText(str) {
|
|
1579
1627
|
if (navigator.clipboard && window.isSecureContext) {
|
|
1580
|
-
|
|
1581
|
-
|
|
1628
|
+
try {
|
|
1629
|
+
await navigator.clipboard.writeText(str);
|
|
1630
|
+
return true;
|
|
1631
|
+
} catch {
|
|
1632
|
+
// Fall through to legacy textarea selection copy.
|
|
1633
|
+
}
|
|
1582
1634
|
}
|
|
1583
1635
|
const ta = document.createElement('textarea');
|
|
1584
1636
|
ta.value = str;
|
|
1637
|
+
ta.setAttribute('readonly', '');
|
|
1585
1638
|
ta.style.position = 'fixed';
|
|
1639
|
+
ta.style.top = '-9999px';
|
|
1586
1640
|
ta.style.opacity = '0';
|
|
1587
1641
|
document.body.appendChild(ta);
|
|
1642
|
+
ta.focus();
|
|
1588
1643
|
ta.select();
|
|
1589
|
-
|
|
1590
|
-
|
|
1644
|
+
let ok = false;
|
|
1645
|
+
try {
|
|
1646
|
+
ok = document.execCommand('copy');
|
|
1647
|
+
} finally {
|
|
1648
|
+
document.body.removeChild(ta);
|
|
1649
|
+
}
|
|
1650
|
+
if (!ok) throw new Error('Clipboard unavailable');
|
|
1651
|
+
return true;
|
|
1591
1652
|
}
|
|
1592
1653
|
|
|
1593
1654
|
function updateAdminHeaderTitle() {
|
|
@@ -2229,14 +2290,41 @@ function showInvite(uri, name) {
|
|
|
2229
2290
|
'<button class="btn btn-sm btn-primary" id="copyCliCmdBtn">' + esc(lang === 'zh' ? '复制一行接入命令 (IDE + CLI)' : 'Copy 1-line setup (IDE + CLI)') + '</button>' +
|
|
2230
2291
|
'<button class="btn btn-sm" id="copyInviteBtn">' + esc(t('copyInvite')) + '</button>' +
|
|
2231
2292
|
'</div>';
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2293
|
+
const bindCopyBtn = (btnId, textToCopy, toastMsg) => {
|
|
2294
|
+
const btn = document.getElementById(btnId);
|
|
2295
|
+
if (!btn) return;
|
|
2296
|
+
const origLabel = btn.textContent;
|
|
2297
|
+
btn.addEventListener('click', async () => {
|
|
2298
|
+
try {
|
|
2299
|
+
await copyText(textToCopy);
|
|
2300
|
+
btn.textContent = '✓ ' + t('copied');
|
|
2301
|
+
showToast(toastMsg, 'ok');
|
|
2302
|
+
setTimeout(() => {
|
|
2303
|
+
if (btn.isConnected) btn.textContent = origLabel;
|
|
2304
|
+
}, 2200);
|
|
2305
|
+
} catch {
|
|
2306
|
+
const uriEl = document.getElementById('inviteUriText');
|
|
2307
|
+
if (uriEl && window.getSelection) {
|
|
2308
|
+
const range = document.createRange();
|
|
2309
|
+
range.selectNodeContents(uriEl);
|
|
2310
|
+
const sel = window.getSelection();
|
|
2311
|
+
sel.removeAllRanges();
|
|
2312
|
+
sel.addRange(range);
|
|
2313
|
+
}
|
|
2314
|
+
showToast(lang === 'zh' ? '已自动全选,请按 Cmd+C / Ctrl+C 复制' : 'Selected — press Cmd+C / Ctrl+C to copy', 'err');
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
};
|
|
2318
|
+
bindCopyBtn(
|
|
2319
|
+
'copyCliCmdBtn',
|
|
2320
|
+
cliOneLiner,
|
|
2321
|
+
lang === 'zh' ? '已复制一行接入命令到剪贴板' : 'Copied 1-line setup command',
|
|
2322
|
+
);
|
|
2323
|
+
bindCopyBtn(
|
|
2324
|
+
'copyInviteBtn',
|
|
2325
|
+
latestInviteUri,
|
|
2326
|
+
lang === 'zh' ? '已复制专属邀请码到剪贴板' : 'Copied invite URI',
|
|
2327
|
+
);
|
|
2240
2328
|
}
|
|
2241
2329
|
|
|
2242
2330
|
async function loadAdmin() {
|
|
@@ -2498,6 +2586,7 @@ document.getElementById('adminMemberList').addEventListener('click', async (e) =
|
|
|
2498
2586
|
method: 'PATCH',
|
|
2499
2587
|
body: JSON.stringify(patchBody),
|
|
2500
2588
|
});
|
|
2589
|
+
showToast(lang === 'zh' ? '已保存成员设置' : 'Member updated');
|
|
2501
2590
|
await loadAdmin();
|
|
2502
2591
|
await fetchBoard();
|
|
2503
2592
|
} catch (err) {
|
|
@@ -2511,6 +2600,7 @@ document.getElementById('adminMemberList').addEventListener('click', async (e) =
|
|
|
2511
2600
|
method: 'PATCH',
|
|
2512
2601
|
body: JSON.stringify({ active: !isActive }),
|
|
2513
2602
|
});
|
|
2603
|
+
showToast(lang === 'zh' ? (isActive ? '已停用成员' : '已恢复成员') : (isActive ? 'Member paused' : 'Member resumed'));
|
|
2514
2604
|
await loadAdmin();
|
|
2515
2605
|
await fetchBoard();
|
|
2516
2606
|
return;
|
|
@@ -2518,6 +2608,8 @@ document.getElementById('adminMemberList').addEventListener('click', async (e) =
|
|
|
2518
2608
|
if (act === 'rotate') {
|
|
2519
2609
|
const res = await adminReq('/api/admin/members/' + encodeURIComponent(id) + '/rotate', { method: 'POST' });
|
|
2520
2610
|
showInvite(res.inviteUri, res.member.name);
|
|
2611
|
+
document.getElementById('newInviteOut')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
2612
|
+
showToast(lang === 'zh' ? '已重置专属接入命令,请复制发给成员' : 'Invite rotated');
|
|
2521
2613
|
return;
|
|
2522
2614
|
}
|
|
2523
2615
|
if (act === 'delete') {
|
|
@@ -2723,6 +2815,7 @@ document.getElementById('createMemberBtn').addEventListener('click', async () =>
|
|
|
2723
2815
|
document.getElementById('newQuotaPct').value = '';
|
|
2724
2816
|
if (document.getElementById('newMemberEmail')) document.getElementById('newMemberEmail').value = '';
|
|
2725
2817
|
showInvite(res.inviteUri, res.member.name);
|
|
2818
|
+
showToast(lang === 'zh' ? '成员已创建,点击按钮即可复制接入命令' : 'Member created');
|
|
2726
2819
|
await loadAdmin();
|
|
2727
2820
|
await fetchBoard();
|
|
2728
2821
|
} catch (e) {
|
|
@@ -2770,6 +2863,7 @@ document.getElementById('saveSettingsBtn').addEventListener('click', async () =>
|
|
|
2770
2863
|
}
|
|
2771
2864
|
msg.style.color = 'var(--good)';
|
|
2772
2865
|
msg.textContent = lang === 'zh' ? '已保存' : 'Saved';
|
|
2866
|
+
showToast(lang === 'zh' ? '配置已保存' : 'Settings saved');
|
|
2773
2867
|
await fetchBoard();
|
|
2774
2868
|
} catch (e) {
|
|
2775
2869
|
msg.style.color = 'var(--danger)';
|