agy-family 0.2.3 → 0.2.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.2.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -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.4',
|
|
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,22 @@ 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
|
+
return [join(appData, 'Antigravity', 'app_storage.json')];
|
|
147
|
+
}
|
|
148
|
+
const xdg = env.XDG_CONFIG_HOME || join(home, '.config');
|
|
149
|
+
return [join(xdg, 'Antigravity', 'app_storage.json')];
|
|
150
|
+
}
|
|
151
|
+
|
|
136
152
|
export function defaultIdeStateDbPaths({ home = homedir(), platform = process.platform, env = process.env } = {}) {
|
|
137
153
|
if (platform === 'darwin') {
|
|
138
154
|
return [join(home, 'Library', 'Application Support', 'Antigravity', 'User', 'globalStorage', 'state.vscdb')];
|
|
@@ -145,9 +161,36 @@ export function defaultIdeStateDbPaths({ home = homedir(), platform = process.pl
|
|
|
145
161
|
return [join(xdg, 'Antigravity', 'User', 'globalStorage', 'state.vscdb')];
|
|
146
162
|
}
|
|
147
163
|
|
|
164
|
+
function safeMtimeMs(filePath) {
|
|
165
|
+
try {
|
|
166
|
+
return statSync(filePath).mtimeMs || 0;
|
|
167
|
+
} catch {
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function readEmailFromDesktopAppStorage(filePath) {
|
|
173
|
+
if (!filePath || !existsSync(filePath)) return { email: '', mtimeMs: 0 };
|
|
174
|
+
try {
|
|
175
|
+
const parsed = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
176
|
+
if (!parsed || typeof parsed !== 'object') return { email: '', mtimeMs: 0 };
|
|
177
|
+
const email = normalizeEmail(
|
|
178
|
+
parsed['agy.onboarding.lastLoginUsername'] ||
|
|
179
|
+
parsed['agy.auth.email'] ||
|
|
180
|
+
parsed.email ||
|
|
181
|
+
parsed.userEmail ||
|
|
182
|
+
parsed.account?.email ||
|
|
183
|
+
'',
|
|
184
|
+
);
|
|
185
|
+
return { email, mtimeMs: email ? safeMtimeMs(filePath) : 0 };
|
|
186
|
+
} catch {
|
|
187
|
+
return { email: '', mtimeMs: 0 };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
148
191
|
function readEmailFromCliTokenFile(home) {
|
|
149
192
|
const tokPath = join(home, '.gemini', 'jetski-standalone-oauth-token');
|
|
150
|
-
if (!existsSync(tokPath)) return '';
|
|
193
|
+
if (!existsSync(tokPath)) return { email: '', mtimeMs: 0 };
|
|
151
194
|
try {
|
|
152
195
|
let raw = readFileSync(tokPath, 'utf8').trim();
|
|
153
196
|
const prefix = 'go-keyring-base64:';
|
|
@@ -155,13 +198,13 @@ function readEmailFromCliTokenFile(home) {
|
|
|
155
198
|
raw = Buffer.from(raw.slice(prefix.length), 'base64').toString('utf8').trim();
|
|
156
199
|
}
|
|
157
200
|
const parsed = JSON.parse(raw);
|
|
158
|
-
if (!parsed || typeof parsed !== 'object') return '';
|
|
159
|
-
|
|
201
|
+
if (!parsed || typeof parsed !== 'object') return { email: '', mtimeMs: 0 };
|
|
202
|
+
const email =
|
|
160
203
|
normalizeEmail(parsed.id_token_email || parsed.email || parsed.token?.email || '') ||
|
|
161
|
-
decodeJwtEmailUnsafe(parsed.id_token || parsed.token?.id_token || '')
|
|
162
|
-
);
|
|
204
|
+
decodeJwtEmailUnsafe(parsed.id_token || parsed.token?.id_token || '');
|
|
205
|
+
return { email, mtimeMs: email ? safeMtimeMs(tokPath) : 0 };
|
|
163
206
|
} catch {
|
|
164
|
-
return '';
|
|
207
|
+
return { email: '', mtimeMs: 0 };
|
|
165
208
|
}
|
|
166
209
|
}
|
|
167
210
|
|
|
@@ -223,21 +266,42 @@ export async function detectLocalActiveAccountHash({
|
|
|
223
266
|
|
|
224
267
|
let ideHash = '';
|
|
225
268
|
let ideSource = '';
|
|
226
|
-
|
|
269
|
+
let ideMtimeMs = 0;
|
|
270
|
+
|
|
271
|
+
// 1. Antigravity 2.0 Desktop App (`app_storage.json` -> `agy.onboarding.lastLoginUsername`) — directly readable by unified CLI!
|
|
272
|
+
for (const appStoragePath of defaultDesktopAppStoragePaths({ home, platform, env })) {
|
|
273
|
+
const res = readEmailFromDesktopAppStorage(appStoragePath);
|
|
274
|
+
const h = hashEmailSha256(res.email) || '';
|
|
275
|
+
if (h) {
|
|
276
|
+
ideHash = h;
|
|
277
|
+
ideSource = 'desktop-app-storage';
|
|
278
|
+
ideMtimeMs = res.mtimeMs;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// 2. Fallback for Antigravity 1.x VS Code fork (`state.vscdb`)
|
|
284
|
+
if (!ideHash && ideStateDbPath) {
|
|
227
285
|
ideHash = hashEmailSha256(await readEmailFromIdeStateDb(ideStateDbPath, sqlJsModule)) || '';
|
|
228
|
-
if (ideHash)
|
|
286
|
+
if (ideHash) {
|
|
287
|
+
ideSource = 'ide-state';
|
|
288
|
+
ideMtimeMs = safeMtimeMs(ideStateDbPath);
|
|
289
|
+
}
|
|
229
290
|
}
|
|
230
291
|
if (!ideHash) {
|
|
231
292
|
for (const candidate of defaultIdeStateDbPaths({ home, platform, env })) {
|
|
232
293
|
ideHash = hashEmailSha256(await readEmailFromIdeStateDb(candidate, sqlJsModule)) || '';
|
|
233
294
|
if (ideHash) {
|
|
234
295
|
ideSource = 'ide-state';
|
|
296
|
+
ideMtimeMs = safeMtimeMs(candidate);
|
|
235
297
|
break;
|
|
236
298
|
}
|
|
237
299
|
}
|
|
238
300
|
}
|
|
239
301
|
|
|
240
|
-
const
|
|
302
|
+
const cliInfo = readEmailFromCliTokenFile(home);
|
|
303
|
+
const cliHash = hashEmailSha256(cliInfo.email) || '';
|
|
304
|
+
const cliMtimeMs = cliInfo.mtimeMs;
|
|
241
305
|
const cached = readActiveAccountCache(home, now);
|
|
242
306
|
|
|
243
307
|
const resolvedDesktop = ideHash || cached.desktop || explicitHint || cliHash || cached.any || null;
|
|
@@ -262,6 +326,15 @@ export async function detectLocalActiveAccountHash({
|
|
|
262
326
|
primaryHash = cached.any;
|
|
263
327
|
primarySource = 'hook-cache';
|
|
264
328
|
}
|
|
329
|
+
} else if (cliHash && ideHash) {
|
|
330
|
+
// Unified CLI covers BOTH Desktop IDE and agy CLI: prefer whichever auth file was updated most recently
|
|
331
|
+
if (ideMtimeMs > cliMtimeMs) {
|
|
332
|
+
primaryHash = ideHash;
|
|
333
|
+
primarySource = ideSource;
|
|
334
|
+
} else {
|
|
335
|
+
primaryHash = cliHash;
|
|
336
|
+
primarySource = 'cli-token';
|
|
337
|
+
}
|
|
265
338
|
} else if (cliHash) {
|
|
266
339
|
primaryHash = cliHash;
|
|
267
340
|
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.4',
|
|
86
86
|
home,
|
|
87
87
|
roots = null,
|
|
88
88
|
sourceFilter = 'all',
|
|
@@ -154,7 +154,7 @@ export async function buildSyncPayload({
|
|
|
154
154
|
deviceId: String(deviceId || deriveAnonymousDeviceId()).slice(0, 32),
|
|
155
155
|
client: {
|
|
156
156
|
kind: clientKind === 'extension' ? 'extension' : 'cli',
|
|
157
|
-
version: String(clientVersion || '0.2.
|
|
157
|
+
version: String(clientVersion || '0.2.4').slice(0, 24),
|
|
158
158
|
},
|
|
159
159
|
account: {
|
|
160
160
|
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.4';
|
|
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;
|
|
@@ -1205,7 +1205,7 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity Family Board' }
|
|
|
1205
1205
|
|
|
1206
1206
|
<footer class="foot">
|
|
1207
1207
|
<span data-i18n="privacyNote">隐私承诺:客户端仅只读扫描本地 SQLite 数值元数据,绝不上传 Prompt、代码、文件路径或 Google 凭据。</span>
|
|
1208
|
-
<span class="mono">agy-family v0.2.
|
|
1208
|
+
<span class="mono">agy-family v0.2.4 · MIT</span>
|
|
1209
1209
|
</footer>
|
|
1210
1210
|
</main>
|
|
1211
1211
|
|
|
@@ -1611,27 +1611,20 @@ function renderGuideBody() {
|
|
|
1611
1611
|
if (!el) return;
|
|
1612
1612
|
if (lang === 'zh') {
|
|
1613
1613
|
el.innerHTML =
|
|
1614
|
-
'<div class="guide-card"><strong
|
|
1615
|
-
'<div style="color:var(--body);margin-top:6px;line-height:1.6"
|
|
1614
|
+
'<div class="guide-card"><strong>统一 CLI 一行接入(Windows / macOS / Linux · 桌面 IDE 与 agy CLI 通用)</strong>' +
|
|
1615
|
+
'<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
1616
|
'<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>';
|
|
1617
|
+
'<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>' +
|
|
1618
|
+
'<div class="guide-card"><strong>隐私承诺与非家庭组号自动免计</strong>' +
|
|
1619
|
+
'<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
1620
|
} else {
|
|
1625
1621
|
el.innerHTML =
|
|
1626
|
-
'<div class="guide-card"><strong>One-Line Setup (
|
|
1627
|
-
'<div style="color:var(--body);margin-top:6px;line-height:1.6">
|
|
1622
|
+
'<div class="guide-card"><strong>Unified One-Line CLI Setup (Windows / macOS / Linux · Desktop IDE & agy CLI)</strong>' +
|
|
1623
|
+
'<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
1624
|
'<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>';
|
|
1625
|
+
'<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>' +
|
|
1626
|
+
'<div class="guide-card"><strong>Privacy & Non-Family Account Auto-Skip</strong>' +
|
|
1627
|
+
'<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
1628
|
}
|
|
1636
1629
|
}
|
|
1637
1630
|
|
|
@@ -2225,20 +2218,16 @@ async function adminReq(path, opts = {}) {
|
|
|
2225
2218
|
|
|
2226
2219
|
function showInvite(uri, name) {
|
|
2227
2220
|
latestInviteUri = uri;
|
|
2228
|
-
const ideLaunchUri = uri.startsWith('agyfam://join')
|
|
2229
|
-
? 'vscode://agy-family.agy-family/join' + uri.slice('agyfam://join'.length)
|
|
2230
|
-
: uri;
|
|
2231
2221
|
const cliOneLiner = 'npm i -g agy-family && agy-family join "' + uri + '" --daemon';
|
|
2232
2222
|
const box = document.getElementById('newInviteOut');
|
|
2233
2223
|
box.style.display = 'block';
|
|
2234
2224
|
box.innerHTML =
|
|
2235
2225
|
'<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(
|
|
2226
|
+
(lang === 'zh' ? '专属接入命令(仅显示一次 · 桌面 IDE 与 CLI 通用)' : 'Personal 1-line setup (shown once · IDE & CLI)') + '</div>' +
|
|
2227
|
+
'<div id="inviteUriText" style="color:var(--body)">' + esc(cliOneLiner) + '</div>' +
|
|
2238
2228
|
'<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>' +
|
|
2229
|
+
'<button class="btn btn-sm btn-primary" id="copyCliCmdBtn">' + esc(lang === 'zh' ? '复制一行接入命令 (IDE + CLI)' : 'Copy 1-line setup (IDE + CLI)') + '</button>' +
|
|
2240
2230
|
'<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
2231
|
'</div>';
|
|
2243
2232
|
document.getElementById('copyCliCmdBtn').addEventListener('click', async (ev) => {
|
|
2244
2233
|
try { await copyText(cliOneLiner); ev.currentTarget.textContent = t('copied'); }
|
|
@@ -2248,10 +2237,6 @@ function showInvite(uri, name) {
|
|
|
2248
2237
|
try { await copyText(latestInviteUri); ev.currentTarget.textContent = t('copied'); }
|
|
2249
2238
|
catch { ev.currentTarget.textContent = 'Select & Copy'; }
|
|
2250
2239
|
});
|
|
2251
|
-
document.getElementById('copyIdeLinkBtn').addEventListener('click', async (ev) => {
|
|
2252
|
-
try { await copyText(ideLaunchUri); ev.currentTarget.textContent = t('copied'); }
|
|
2253
|
-
catch { ev.currentTarget.textContent = 'Select & Copy'; }
|
|
2254
|
-
});
|
|
2255
2240
|
}
|
|
2256
2241
|
|
|
2257
2242
|
async function loadAdmin() {
|