agy-family 0.6.5 → 0.6.6

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.5",
3
+ "version": "0.6.6",
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.5';
74
+ const CLI_VERSION = '0.6.6';
75
75
  const THIS_CLI_PATH = fileURLToPath(import.meta.url);
76
76
  const PACKAGE_ROOT = resolve(dirname(THIS_CLI_PATH), '..', '..', '..');
77
77
 
@@ -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.5',
893
+ clientVersion: '0.6.6',
894
894
  home,
895
895
  fileCache: cache,
896
896
  syncedHashes: prevHashes,
@@ -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.5',
86
+ clientVersion = '0.6.6',
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.5').slice(0, 24),
167
+ version: String(clientVersion || '0.6.6').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.5';
29
+ export const SERVER_VERSION = '0.6.6';
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;
@@ -180,6 +180,37 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
180
180
  border-radius: 50%;
181
181
  background: var(--good);
182
182
  flex-shrink: 0;
183
+ transition: background 0.15s ease;
184
+ }
185
+ .sync-dot.paused {
186
+ background: var(--muted);
187
+ opacity: 0.6;
188
+ }
189
+ .sync-sep {
190
+ opacity: 0.45;
191
+ user-select: none;
192
+ }
193
+ .refresh-select {
194
+ appearance: none;
195
+ -webkit-appearance: none;
196
+ border: none;
197
+ background: transparent;
198
+ color: var(--body);
199
+ font-family: var(--font-mono);
200
+ font-size: 11px;
201
+ line-height: 1.2;
202
+ padding: 1px 4px;
203
+ border-radius: 4px;
204
+ cursor: pointer;
205
+ outline: none;
206
+ }
207
+ .refresh-select:hover, .refresh-select:focus-visible {
208
+ background: var(--hover);
209
+ color: var(--ink);
210
+ }
211
+ .refresh-select option {
212
+ background: var(--surface-card);
213
+ color: var(--ink);
183
214
  }
184
215
  .icon-refresh {
185
216
  display: inline-grid;
@@ -1740,8 +1771,17 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
1740
1771
  <div class="brand-mark" aria-hidden="true">${FAVICON_SVG}</div>
1741
1772
  <h1 class="brand-title" id="boardTitle">${safeTitle}</h1>
1742
1773
  <span class="sync-pill">
1743
- <span class="sync-dot"></span>
1774
+ <span class="sync-dot" id="syncDot"></span>
1744
1775
  <span id="updatedLine">--:--</span>
1776
+ <span class="sync-sep" aria-hidden="true">·</span>
1777
+ <select class="refresh-select" id="autoRefreshSelect" aria-label="自动刷新间隔" title="自动刷新间隔">
1778
+ <option value="10">10s</option>
1779
+ <option value="15">15s</option>
1780
+ <option value="30" selected>30s</option>
1781
+ <option value="60">1m</option>
1782
+ <option value="300">5m</option>
1783
+ <option value="0">关闭</option>
1784
+ </select>
1745
1785
  <button class="icon-refresh" id="refreshBtn" title="Refresh" aria-label="Refresh">
1746
1786
  <svg width="11" height="11" viewBox="0 0 16 16" fill="none" aria-hidden="true">
1747
1787
  <path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2.5V5.2H10.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
@@ -1924,7 +1964,7 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
1924
1964
 
1925
1965
  <footer class="foot">
1926
1966
  <span data-i18n="privacyNote">隐私承诺:客户端仅只读扫描本地 SQLite 数值元数据,绝不上传 Prompt、代码、文件路径或 Google 凭据。</span>
1927
- <span class="mono">agy-family v0.6.5 · MIT</span>
1967
+ <span class="mono">agy-family v0.6.6 · MIT</span>
1928
1968
  </footer>
1929
1969
  </main>
1930
1970
 
@@ -2481,6 +2521,15 @@ function applyI18n() {
2481
2521
  if (tpBtn) tpBtn.textContent = lang === 'zh' ? '查看 / 自定义单价' : 'View / Edit rates';
2482
2522
  const advSum = document.getElementById('advancedRulesSummary');
2483
2523
  if (advSum) advSum.textContent = lang === 'zh' ? '高级设置与群通知(时区 / 预警 / 查看密码 / Webhook)' : 'Advanced & Notifications (Timezone / Warn / View Key / Webhook)';
2524
+ const arSel = document.getElementById('autoRefreshSelect');
2525
+ if (arSel) {
2526
+ arSel.title = lang === 'zh' ? '页面自动刷新间隔' : 'Auto-refresh interval';
2527
+ arSel.setAttribute('aria-label', arSel.title);
2528
+ const offOpt = arSel.querySelector('option[value="0"]');
2529
+ if (offOpt) offOpt.textContent = lang === 'zh' ? '关闭' : 'Off';
2530
+ }
2531
+ const rfBtn = document.getElementById('refreshBtn');
2532
+ if (rfBtn) rfBtn.title = lang === 'zh' ? '立即刷新' : 'Refresh now';
2484
2533
  updateRangeTriggerLabel(lastBoardData?.window || null);
2485
2534
  updateAdminHeaderTitle();
2486
2535
  renderGuideBody();
@@ -2724,6 +2773,7 @@ async function fetchBoard(opts) {
2724
2773
  }
2725
2774
  const isTabOrManual = !silent && hasLoadedBoard;
2726
2775
  hasLoadedBoard = true;
2776
+ lastBoardFetchedAt = Date.now();
2727
2777
  lastBoardData = data;
2728
2778
  renderBoard(data);
2729
2779
  if (isTabOrManual) {
@@ -4255,7 +4305,61 @@ document.getElementById('checkOfflineBtn').addEventListener('click', async () =>
4255
4305
  });
4256
4306
  });
4257
4307
 
4258
- document.getElementById('refreshBtn')?.addEventListener('click', () => fetchBoard());
4308
+ const ALLOWED_REFRESH_SECS = [0, 10, 15, 30, 60, 300];
4309
+ let autoRefreshSec = (() => {
4310
+ const raw = localStorage.getItem('agf_refresh_sec');
4311
+ if (raw === null || raw === '') return 30;
4312
+ const n = Number(raw);
4313
+ return ALLOWED_REFRESH_SECS.includes(n) ? n : 30;
4314
+ })();
4315
+ let autoRefreshTimer = null;
4316
+ let lastBoardFetchedAt = 0;
4317
+
4318
+ function formatRefreshLabel(sec) {
4319
+ if (!sec) return lang === 'zh' ? '关闭' : 'Off';
4320
+ if (sec < 60) return sec + 's';
4321
+ return Math.round(sec / 60) + 'm';
4322
+ }
4323
+
4324
+ function scheduleAutoRefresh() {
4325
+ if (autoRefreshTimer) {
4326
+ clearInterval(autoRefreshTimer);
4327
+ autoRefreshTimer = null;
4328
+ }
4329
+ const sel = document.getElementById('autoRefreshSelect');
4330
+ if (sel && String(sel.value) !== String(autoRefreshSec)) sel.value = String(autoRefreshSec);
4331
+ const dot = document.getElementById('syncDot');
4332
+ if (dot) dot.classList.toggle('paused', autoRefreshSec <= 0);
4333
+ if (autoRefreshSec > 0) {
4334
+ autoRefreshTimer = setInterval(() => {
4335
+ if (document.hidden) return;
4336
+ fetchBoard({ silent: true });
4337
+ }, autoRefreshSec * 1000);
4338
+ }
4339
+ }
4340
+
4341
+ document.getElementById('autoRefreshSelect')?.addEventListener('change', (ev) => {
4342
+ const n = Number(ev.target.value);
4343
+ autoRefreshSec = ALLOWED_REFRESH_SECS.includes(n) ? n : 30;
4344
+ localStorage.setItem('agf_refresh_sec', String(autoRefreshSec));
4345
+ scheduleAutoRefresh();
4346
+ showToast(
4347
+ autoRefreshSec > 0
4348
+ ? (lang === 'zh' ? '已设为每 ' + formatRefreshLabel(autoRefreshSec) + ' 自动刷新' : 'Auto-refresh set to every ' + formatRefreshLabel(autoRefreshSec))
4349
+ : (lang === 'zh' ? '已关闭自动刷新' : 'Auto-refresh turned off'),
4350
+ );
4351
+ });
4352
+
4353
+ document.addEventListener('visibilitychange', () => {
4354
+ if (!document.hidden && autoRefreshSec > 0 && Date.now() - lastBoardFetchedAt >= autoRefreshSec * 1000) {
4355
+ fetchBoard({ silent: true });
4356
+ }
4357
+ });
4358
+
4359
+ document.getElementById('refreshBtn')?.addEventListener('click', () => {
4360
+ fetchBoard();
4361
+ scheduleAutoRefresh();
4362
+ });
4259
4363
 
4260
4364
  function fmtShortDate(isoKey) {
4261
4365
  const parts = String(isoKey || '').split('-');
@@ -4807,8 +4911,8 @@ document.getElementById('testWebhookBtn').addEventListener('click', async () =>
4807
4911
  });
4808
4912
 
4809
4913
  applyI18n();
4914
+ scheduleAutoRefresh();
4810
4915
  fetchBoard();
4811
- setInterval(() => fetchBoard({ silent: true }), 60000);
4812
4916
  </script>
4813
4917
  </body>
4814
4918
  </html>`;