agy-family 0.2.3 → 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,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// so even switching accounts mid-hour never pollutes family group usage or share percentages.
|
|
10
10
|
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
13
13
|
import { homedir } from 'node:os';
|
|
14
14
|
import { dirname, join } from 'node:path';
|
|
15
15
|
import { estimateUsageUsd } from './pricing.mjs';
|
|
@@ -133,6 +133,26 @@ function readActiveAccountCache(home, now) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
export function defaultDesktopAppStoragePaths({
|
|
137
|
+
home = homedir(),
|
|
138
|
+
platform = process.platform,
|
|
139
|
+
env = process.env,
|
|
140
|
+
} = {}) {
|
|
141
|
+
if (platform === 'darwin') {
|
|
142
|
+
return [join(home, 'Library', 'Application Support', 'Antigravity', 'app_storage.json')];
|
|
143
|
+
}
|
|
144
|
+
if (platform === 'win32') {
|
|
145
|
+
const appData = env.APPDATA || join(home, 'AppData', 'Roaming');
|
|
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
|
+
];
|
|
151
|
+
}
|
|
152
|
+
const xdg = env.XDG_CONFIG_HOME || join(home, '.config');
|
|
153
|
+
return [join(xdg, 'Antigravity', 'app_storage.json')];
|
|
154
|
+
}
|
|
155
|
+
|
|
136
156
|
export function defaultIdeStateDbPaths({ home = homedir(), platform = process.platform, env = process.env } = {}) {
|
|
137
157
|
if (platform === 'darwin') {
|
|
138
158
|
return [join(home, 'Library', 'Application Support', 'Antigravity', 'User', 'globalStorage', 'state.vscdb')];
|
|
@@ -145,9 +165,36 @@ export function defaultIdeStateDbPaths({ home = homedir(), platform = process.pl
|
|
|
145
165
|
return [join(xdg, 'Antigravity', 'User', 'globalStorage', 'state.vscdb')];
|
|
146
166
|
}
|
|
147
167
|
|
|
168
|
+
function safeMtimeMs(filePath) {
|
|
169
|
+
try {
|
|
170
|
+
return statSync(filePath).mtimeMs || 0;
|
|
171
|
+
} catch {
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function readEmailFromDesktopAppStorage(filePath) {
|
|
177
|
+
if (!filePath || !existsSync(filePath)) return { email: '', mtimeMs: 0 };
|
|
178
|
+
try {
|
|
179
|
+
const parsed = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
180
|
+
if (!parsed || typeof parsed !== 'object') return { email: '', mtimeMs: 0 };
|
|
181
|
+
const email = normalizeEmail(
|
|
182
|
+
parsed['agy.onboarding.lastLoginUsername'] ||
|
|
183
|
+
parsed['agy.auth.email'] ||
|
|
184
|
+
parsed.email ||
|
|
185
|
+
parsed.userEmail ||
|
|
186
|
+
parsed.account?.email ||
|
|
187
|
+
'',
|
|
188
|
+
);
|
|
189
|
+
return { email, mtimeMs: email ? safeMtimeMs(filePath) : 0 };
|
|
190
|
+
} catch {
|
|
191
|
+
return { email: '', mtimeMs: 0 };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
148
195
|
function readEmailFromCliTokenFile(home) {
|
|
149
196
|
const tokPath = join(home, '.gemini', 'jetski-standalone-oauth-token');
|
|
150
|
-
if (!existsSync(tokPath)) return '';
|
|
197
|
+
if (!existsSync(tokPath)) return { email: '', mtimeMs: 0 };
|
|
151
198
|
try {
|
|
152
199
|
let raw = readFileSync(tokPath, 'utf8').trim();
|
|
153
200
|
const prefix = 'go-keyring-base64:';
|
|
@@ -155,13 +202,13 @@ function readEmailFromCliTokenFile(home) {
|
|
|
155
202
|
raw = Buffer.from(raw.slice(prefix.length), 'base64').toString('utf8').trim();
|
|
156
203
|
}
|
|
157
204
|
const parsed = JSON.parse(raw);
|
|
158
|
-
if (!parsed || typeof parsed !== 'object') return '';
|
|
159
|
-
|
|
205
|
+
if (!parsed || typeof parsed !== 'object') return { email: '', mtimeMs: 0 };
|
|
206
|
+
const email =
|
|
160
207
|
normalizeEmail(parsed.id_token_email || parsed.email || parsed.token?.email || '') ||
|
|
161
|
-
decodeJwtEmailUnsafe(parsed.id_token || parsed.token?.id_token || '')
|
|
162
|
-
);
|
|
208
|
+
decodeJwtEmailUnsafe(parsed.id_token || parsed.token?.id_token || '');
|
|
209
|
+
return { email, mtimeMs: email ? safeMtimeMs(tokPath) : 0 };
|
|
163
210
|
} catch {
|
|
164
|
-
return '';
|
|
211
|
+
return { email: '', mtimeMs: 0 };
|
|
165
212
|
}
|
|
166
213
|
}
|
|
167
214
|
|
|
@@ -211,6 +258,7 @@ async function readEmailFromIdeStateDb(dbPath, sqlJsModule = null) {
|
|
|
211
258
|
export async function detectLocalActiveAccountHash({
|
|
212
259
|
home = homedir(),
|
|
213
260
|
clientKind = 'cli',
|
|
261
|
+
expectedEmailHash = '',
|
|
214
262
|
hintEmail = '',
|
|
215
263
|
hintEmailHash = '',
|
|
216
264
|
ideStateDbPath = '',
|
|
@@ -219,25 +267,47 @@ export async function detectLocalActiveAccountHash({
|
|
|
219
267
|
env = process.env,
|
|
220
268
|
now = Date.now(),
|
|
221
269
|
} = {}) {
|
|
270
|
+
const cleanExpected = normalizeSha256Hex(expectedEmailHash);
|
|
222
271
|
const explicitHint = normalizeSha256Hex(hintEmailHash) || hashEmailSha256(hintEmail) || '';
|
|
223
272
|
|
|
224
273
|
let ideHash = '';
|
|
225
274
|
let ideSource = '';
|
|
226
|
-
|
|
275
|
+
let ideMtimeMs = 0;
|
|
276
|
+
|
|
277
|
+
// 1. Antigravity 2.0 Desktop App (`app_storage.json` -> `agy.onboarding.lastLoginUsername`) — directly readable by unified CLI!
|
|
278
|
+
for (const appStoragePath of defaultDesktopAppStoragePaths({ home, platform, env })) {
|
|
279
|
+
const res = readEmailFromDesktopAppStorage(appStoragePath);
|
|
280
|
+
const h = hashEmailSha256(res.email) || '';
|
|
281
|
+
if (h) {
|
|
282
|
+
ideHash = h;
|
|
283
|
+
ideSource = 'desktop-app-storage';
|
|
284
|
+
ideMtimeMs = res.mtimeMs;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// 2. Fallback for Antigravity 1.x VS Code fork (`state.vscdb`)
|
|
290
|
+
if (!ideHash && ideStateDbPath) {
|
|
227
291
|
ideHash = hashEmailSha256(await readEmailFromIdeStateDb(ideStateDbPath, sqlJsModule)) || '';
|
|
228
|
-
if (ideHash)
|
|
292
|
+
if (ideHash) {
|
|
293
|
+
ideSource = 'ide-state';
|
|
294
|
+
ideMtimeMs = safeMtimeMs(ideStateDbPath);
|
|
295
|
+
}
|
|
229
296
|
}
|
|
230
297
|
if (!ideHash) {
|
|
231
298
|
for (const candidate of defaultIdeStateDbPaths({ home, platform, env })) {
|
|
232
299
|
ideHash = hashEmailSha256(await readEmailFromIdeStateDb(candidate, sqlJsModule)) || '';
|
|
233
300
|
if (ideHash) {
|
|
234
301
|
ideSource = 'ide-state';
|
|
302
|
+
ideMtimeMs = safeMtimeMs(candidate);
|
|
235
303
|
break;
|
|
236
304
|
}
|
|
237
305
|
}
|
|
238
306
|
}
|
|
239
307
|
|
|
240
|
-
const
|
|
308
|
+
const cliInfo = readEmailFromCliTokenFile(home);
|
|
309
|
+
const cliHash = hashEmailSha256(cliInfo.email) || '';
|
|
310
|
+
const cliMtimeMs = cliInfo.mtimeMs;
|
|
241
311
|
const cached = readActiveAccountCache(home, now);
|
|
242
312
|
|
|
243
313
|
const resolvedDesktop = ideHash || cached.desktop || explicitHint || cliHash || cached.any || null;
|
|
@@ -262,6 +332,23 @@ export async function detectLocalActiveAccountHash({
|
|
|
262
332
|
primaryHash = cached.any;
|
|
263
333
|
primarySource = 'hook-cache';
|
|
264
334
|
}
|
|
335
|
+
} else if (cliHash && ideHash) {
|
|
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) {
|
|
346
|
+
primaryHash = ideHash;
|
|
347
|
+
primarySource = ideSource;
|
|
348
|
+
} else {
|
|
349
|
+
primaryHash = cliHash;
|
|
350
|
+
primarySource = 'cli-token';
|
|
351
|
+
}
|
|
265
352
|
} else if (cliHash) {
|
|
266
353
|
primaryHash = cliHash;
|
|
267
354
|
primarySource = 'cli-token';
|
|
@@ -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() {
|
|
@@ -1611,27 +1672,20 @@ function renderGuideBody() {
|
|
|
1611
1672
|
if (!el) return;
|
|
1612
1673
|
if (lang === 'zh') {
|
|
1613
1674
|
el.innerHTML =
|
|
1614
|
-
'<div class="guide-card"><strong
|
|
1615
|
-
'<div style="color:var(--body);margin-top:6px;line-height:1.6"
|
|
1675
|
+
'<div class="guide-card"><strong>统一 CLI 一行接入(Windows / macOS / Linux · 桌面 IDE 与 agy CLI 通用)</strong>' +
|
|
1676
|
+
'<div style="color:var(--body);margin-top:6px;line-height:1.6">复制家庭组管理员发来的 1 行命令在终端执行(需 Node.js ≥ 22.13),即可同时托管本机 <strong>Antigravity 桌面版 IDE + agy CLI</strong>,自动开启后台增量心跳并全局注册 <code>/family</code> 零 Token 指令:</div>' +
|
|
1616
1677
|
'<div class="code-block mono">npm i -g agy-family && agy-family join "agyfam://join?d=..." --daemon</div>' +
|
|
1617
|
-
'<div style="color:var(--muted);font-size:11.5px;margin-top:6px"
|
|
1618
|
-
'<div class="guide-card"><strong
|
|
1619
|
-
'<
|
|
1620
|
-
'<li>从 <a href="https://github.com/xy-tuoren/agy-family/releases/latest" target="_blank" rel="noreferrer">GitHub Releases</a> 下载 <code>agy-family-*.vsix</code> 并拖入扩展面板;</li>' +
|
|
1621
|
-
'<li>点击管理员发来的「IDE 扩展链接」,或点右下角状态栏粘贴 <code>agyfam://join?d=...</code> 邀请码。</li>' +
|
|
1622
|
-
'</ol></div>' +
|
|
1623
|
-
'<div style="font-size:11.5px;color:var(--muted)">隐私边界:仅只读扫描本机 SQLite 数值统计(小时桶/模型/Token),绝不上传 Prompt、代码、路径或凭据;随时可执行 <code>/family audit</code> 核验。</div>';
|
|
1678
|
+
'<div style="color:var(--muted);font-size:11.5px;margin-top:6px">在桌面 IDE 或 CLI 对话框随时输入 <code>/family</code>、<code>/family 7d</code>、<code>/family sync</code>、<code>/family audit</code>(0 Token 消耗)。</div></div>' +
|
|
1679
|
+
'<div class="guide-card"><strong>隐私承诺与非家庭组号自动免计</strong>' +
|
|
1680
|
+
'<div style="color:var(--body);margin-top:6px;line-height:1.6">仅只读扫描本机对话 SQLite 数值元数据(小时桶 / 模型 / Token 计数),<strong>绝不上传 Prompt、代码、路径或 Google 凭据</strong>;若管理员绑定了家庭组邮箱 <code>SHA-256</code> 指纹,切到个人/工作号期间产生的用量会自动排除免计。</div></div>';
|
|
1624
1681
|
} else {
|
|
1625
1682
|
el.innerHTML =
|
|
1626
|
-
'<div class="guide-card"><strong>One-Line Setup (
|
|
1627
|
-
'<div style="color:var(--body);margin-top:6px;line-height:1.6">
|
|
1683
|
+
'<div class="guide-card"><strong>Unified One-Line CLI Setup (Windows / macOS / Linux · Desktop IDE & agy CLI)</strong>' +
|
|
1684
|
+
'<div style="color:var(--body);margin-top:6px;line-height:1.6">Run the 1-line command from your family manager (requires Node.js ≥ 22.13) to cover both <strong>Antigravity Desktop IDE and agy CLI</strong>, enable background delta sync, and register <code>/family</code> everywhere:</div>' +
|
|
1628
1685
|
'<div class="code-block mono">npm i -g agy-family && agy-family join "agyfam://join?d=..." --daemon</div>' +
|
|
1629
|
-
'<div style="color:var(--muted);font-size:11.5px;margin-top:6px">Type <code>/family</code>, <code>/family 7d</code>, <code>/family sync</code>, or <code>/family audit</code> anytime with 0 tokens.</div></div>' +
|
|
1630
|
-
'<div class="guide-card"><strong>
|
|
1631
|
-
'<
|
|
1632
|
-
'<li>Download <code>agy-family-*.vsix</code> from <a href="https://github.com/xy-tuoren/agy-family/releases/latest" target="_blank" rel="noreferrer">GitHub Releases</a> and drag it into Extensions;</li>' +
|
|
1633
|
-
'<li>Click your manager's 1-click IDE link, or paste your <code>agyfam://join?d=...</code> invite code from the status bar.</li>' +
|
|
1634
|
-
'</ol></div>';
|
|
1686
|
+
'<div style="color:var(--muted);font-size:11.5px;margin-top:6px">Type <code>/family</code>, <code>/family 7d</code>, <code>/family sync</code>, or <code>/family audit</code> anytime in IDE or CLI with 0 tokens.</div></div>' +
|
|
1687
|
+
'<div class="guide-card"><strong>Privacy & Non-Family Account Auto-Skip</strong>' +
|
|
1688
|
+
'<div style="color:var(--body);margin-top:6px;line-height:1.6">Scans only local read-only SQLite numeric stats — never prompts, code, paths, or credentials. When a family email SHA-256 is bound, switching to any other Google account automatically skips non-family usage.</div></div>';
|
|
1635
1689
|
}
|
|
1636
1690
|
}
|
|
1637
1691
|
|
|
@@ -2225,33 +2279,52 @@ async function adminReq(path, opts = {}) {
|
|
|
2225
2279
|
|
|
2226
2280
|
function showInvite(uri, name) {
|
|
2227
2281
|
latestInviteUri = uri;
|
|
2228
|
-
const ideLaunchUri = uri.startsWith('agyfam://join')
|
|
2229
|
-
? 'vscode://agy-family.agy-family/join' + uri.slice('agyfam://join'.length)
|
|
2230
|
-
: uri;
|
|
2231
2282
|
const cliOneLiner = 'npm i -g agy-family && agy-family join "' + uri + '" --daemon';
|
|
2232
2283
|
const box = document.getElementById('newInviteOut');
|
|
2233
2284
|
box.style.display = 'block';
|
|
2234
2285
|
box.innerHTML =
|
|
2235
2286
|
'<div style="margin-bottom:6px;color:var(--ink);font-family:var(--font-sans);font-weight:600">' + esc(name) + ' — ' +
|
|
2236
|
-
(lang === 'zh' ? '
|
|
2237
|
-
'<div id="inviteUriText" style="color:var(--body)">' + esc(
|
|
2287
|
+
(lang === 'zh' ? '专属接入命令(仅显示一次 · 桌面 IDE 与 CLI 通用)' : 'Personal 1-line setup (shown once · IDE & CLI)') + '</div>' +
|
|
2288
|
+
'<div id="inviteUriText" style="color:var(--body)">' + esc(cliOneLiner) + '</div>' +
|
|
2238
2289
|
'<div style="display:flex;gap:6px;flex-wrap:wrap;margin-top:10px">' +
|
|
2239
|
-
'<button class="btn btn-sm btn-primary" id="copyCliCmdBtn">' + esc(lang === 'zh' ? '复制一行接入命令 (IDE+CLI)' : 'Copy 1-line setup (IDE+CLI)') + '</button>' +
|
|
2290
|
+
'<button class="btn btn-sm btn-primary" id="copyCliCmdBtn">' + esc(lang === 'zh' ? '复制一行接入命令 (IDE + CLI)' : 'Copy 1-line setup (IDE + CLI)') + '</button>' +
|
|
2240
2291
|
'<button class="btn btn-sm" id="copyInviteBtn">' + esc(t('copyInvite')) + '</button>' +
|
|
2241
|
-
'<button class="btn btn-sm" id="copyIdeLinkBtn">' + esc(lang === 'zh' ? '复制 IDE 扩展链接' : 'Copy IDE link') + '</button>' +
|
|
2242
2292
|
'</div>';
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
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
|
+
);
|
|
2255
2328
|
}
|
|
2256
2329
|
|
|
2257
2330
|
async function loadAdmin() {
|
|
@@ -2513,6 +2586,7 @@ document.getElementById('adminMemberList').addEventListener('click', async (e) =
|
|
|
2513
2586
|
method: 'PATCH',
|
|
2514
2587
|
body: JSON.stringify(patchBody),
|
|
2515
2588
|
});
|
|
2589
|
+
showToast(lang === 'zh' ? '已保存成员设置' : 'Member updated');
|
|
2516
2590
|
await loadAdmin();
|
|
2517
2591
|
await fetchBoard();
|
|
2518
2592
|
} catch (err) {
|
|
@@ -2526,6 +2600,7 @@ document.getElementById('adminMemberList').addEventListener('click', async (e) =
|
|
|
2526
2600
|
method: 'PATCH',
|
|
2527
2601
|
body: JSON.stringify({ active: !isActive }),
|
|
2528
2602
|
});
|
|
2603
|
+
showToast(lang === 'zh' ? (isActive ? '已停用成员' : '已恢复成员') : (isActive ? 'Member paused' : 'Member resumed'));
|
|
2529
2604
|
await loadAdmin();
|
|
2530
2605
|
await fetchBoard();
|
|
2531
2606
|
return;
|
|
@@ -2533,6 +2608,8 @@ document.getElementById('adminMemberList').addEventListener('click', async (e) =
|
|
|
2533
2608
|
if (act === 'rotate') {
|
|
2534
2609
|
const res = await adminReq('/api/admin/members/' + encodeURIComponent(id) + '/rotate', { method: 'POST' });
|
|
2535
2610
|
showInvite(res.inviteUri, res.member.name);
|
|
2611
|
+
document.getElementById('newInviteOut')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
2612
|
+
showToast(lang === 'zh' ? '已重置专属接入命令,请复制发给成员' : 'Invite rotated');
|
|
2536
2613
|
return;
|
|
2537
2614
|
}
|
|
2538
2615
|
if (act === 'delete') {
|
|
@@ -2738,6 +2815,7 @@ document.getElementById('createMemberBtn').addEventListener('click', async () =>
|
|
|
2738
2815
|
document.getElementById('newQuotaPct').value = '';
|
|
2739
2816
|
if (document.getElementById('newMemberEmail')) document.getElementById('newMemberEmail').value = '';
|
|
2740
2817
|
showInvite(res.inviteUri, res.member.name);
|
|
2818
|
+
showToast(lang === 'zh' ? '成员已创建,点击按钮即可复制接入命令' : 'Member created');
|
|
2741
2819
|
await loadAdmin();
|
|
2742
2820
|
await fetchBoard();
|
|
2743
2821
|
} catch (e) {
|
|
@@ -2785,6 +2863,7 @@ document.getElementById('saveSettingsBtn').addEventListener('click', async () =>
|
|
|
2785
2863
|
}
|
|
2786
2864
|
msg.style.color = 'var(--good)';
|
|
2787
2865
|
msg.textContent = lang === 'zh' ? '已保存' : 'Saved';
|
|
2866
|
+
showToast(lang === 'zh' ? '配置已保存' : 'Settings saved');
|
|
2788
2867
|
await fetchBoard();
|
|
2789
2868
|
} catch (e) {
|
|
2790
2869
|
msg.style.color = 'var(--danger)';
|