agy-family 0.2.10 → 0.3.0
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 +1 -1
- package/packages/cli/bin/agy-family.mjs +1 -1
- package/packages/cli/src/hook.mjs +1 -1
- package/packages/cli/src/host.mjs +3 -3
- package/packages/core/src/sync.mjs +2 -2
- package/packages/server-core/src/index.mjs +31 -6
- package/packages/server-core/src/schema.mjs +1 -1
- package/packages/server-core/src/stats.mjs +258 -42
- package/packages/server-core/src/ui.mjs +563 -120
- package/wrangler.jsonc +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-family",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
writeHostConfig,
|
|
48
48
|
} from '../src/host.mjs';
|
|
49
49
|
|
|
50
|
-
const CLI_VERSION = '0.
|
|
50
|
+
const CLI_VERSION = '0.3.0';
|
|
51
51
|
const THIS_CLI_PATH = fileURLToPath(import.meta.url);
|
|
52
52
|
const PACKAGE_ROOT = resolve(dirname(THIS_CLI_PATH), '..', '..', '..');
|
|
53
53
|
|
|
@@ -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.
|
|
719
|
+
clientVersion: '0.3.0',
|
|
720
720
|
home,
|
|
721
721
|
fileCache: cache,
|
|
722
722
|
syncedHashes: prevHashes,
|
|
@@ -107,7 +107,7 @@ export function buildWranglerConfig({
|
|
|
107
107
|
workerName = 'agy-family',
|
|
108
108
|
databaseName = 'agy-family-db',
|
|
109
109
|
databaseId = '',
|
|
110
|
-
boardTitle = 'Antigravity
|
|
110
|
+
boardTitle = 'Antigravity 家庭组',
|
|
111
111
|
defaultDailyCapUsd = 10,
|
|
112
112
|
defaultWeeklyCapUsd = 50,
|
|
113
113
|
defaultCycleCapUsd = 150,
|
|
@@ -127,7 +127,7 @@ export function buildWranglerConfig({
|
|
|
127
127
|
},
|
|
128
128
|
],
|
|
129
129
|
vars: {
|
|
130
|
-
BOARD_TITLE: String(boardTitle || 'Antigravity
|
|
130
|
+
BOARD_TITLE: String(boardTitle || 'Antigravity 家庭组').trim(),
|
|
131
131
|
DEFAULT_DAILY_CAP_USD: String(defaultDailyCapUsd),
|
|
132
132
|
DEFAULT_WEEKLY_CAP_USD: String(defaultWeeklyCapUsd),
|
|
133
133
|
DEFAULT_CYCLE_CAP_USD: String(defaultCycleCapUsd),
|
|
@@ -291,7 +291,7 @@ export async function deployToCloudflare({
|
|
|
291
291
|
const finalDbName = String(
|
|
292
292
|
databaseName || (existing.workerName === finalWorkerName ? existing.databaseName : '') || `${finalWorkerName}-db`,
|
|
293
293
|
).trim();
|
|
294
|
-
const finalTitle = String(boardTitle || existing.boardTitle || 'Antigravity
|
|
294
|
+
const finalTitle = String(boardTitle || existing.boardTitle || 'Antigravity 家庭组').trim();
|
|
295
295
|
|
|
296
296
|
const explicitAdminKey = String(adminKey || '').trim();
|
|
297
297
|
const reusedKey = !rotateKey && !explicitAdminKey && existing.adminKey && (!existing.workerName || existing.workerName === finalWorkerName);
|
|
@@ -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.
|
|
85
|
+
clientVersion = '0.3.0',
|
|
86
86
|
home,
|
|
87
87
|
roots = null,
|
|
88
88
|
sourceFilter = 'all',
|
|
@@ -155,7 +155,7 @@ export async function buildSyncPayload({
|
|
|
155
155
|
deviceId: String(deviceId || deriveAnonymousDeviceId()).slice(0, 32),
|
|
156
156
|
client: {
|
|
157
157
|
kind: clientKind === 'extension' ? 'extension' : 'cli',
|
|
158
|
-
version: String(clientVersion || '0.
|
|
158
|
+
version: String(clientVersion || '0.3.0').slice(0, 24),
|
|
159
159
|
},
|
|
160
160
|
account: {
|
|
161
161
|
emailHash: effectiveReportedHash,
|
|
@@ -9,6 +9,7 @@ import { ensureSchema, MAX_FAMILY_MEMBERS } from './schema.mjs';
|
|
|
9
9
|
import {
|
|
10
10
|
buildBoardCsv,
|
|
11
11
|
buildBoardPayload,
|
|
12
|
+
buildEffectivePricingTable,
|
|
12
13
|
buildMemberDetailPayload,
|
|
13
14
|
checkOfflineMembersAndAlert,
|
|
14
15
|
computeCreditsReconciliation,
|
|
@@ -20,10 +21,10 @@ import {
|
|
|
20
21
|
roundUsd,
|
|
21
22
|
syncServerPricingCache,
|
|
22
23
|
} from './stats.mjs';
|
|
23
|
-
import { renderDashboardHtml } from './ui.mjs';
|
|
24
|
+
import { FAVICON_SVG, renderDashboardHtml } from './ui.mjs';
|
|
24
25
|
import { dispatchWebhook, sendDedupedAlert, validateWebhookUrl } from './webhooks.mjs';
|
|
25
26
|
|
|
26
|
-
export const SERVER_VERSION = '0.
|
|
27
|
+
export const SERVER_VERSION = '0.3.0';
|
|
27
28
|
const MAX_BUCKETS_PER_SYNC = 1000;
|
|
28
29
|
const MAX_DEVICES_PER_MEMBER = 8;
|
|
29
30
|
const MAX_TOKENS_PER_BUCKET = 500_000_000;
|
|
@@ -325,6 +326,18 @@ export function createApp({
|
|
|
325
326
|
return jsonRes({ ok: true, version: SERVER_VERSION, runtime, time: now });
|
|
326
327
|
}
|
|
327
328
|
|
|
329
|
+
// Favicon (SVG icon served at both /favicon.svg and /favicon.ico)
|
|
330
|
+
if (request.method === 'GET' && (path === '/favicon.svg' || path === '/favicon.ico')) {
|
|
331
|
+
return new Response(FAVICON_SVG, {
|
|
332
|
+
status: 200,
|
|
333
|
+
headers: {
|
|
334
|
+
'Content-Type': 'image/svg+xml; charset=utf-8',
|
|
335
|
+
'Cache-Control': 'public, max-age=86400',
|
|
336
|
+
'X-Content-Type-Options': 'nosniff',
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
328
341
|
// Public Transparent Dashboard UI
|
|
329
342
|
if (request.method === 'GET' && path === '/') {
|
|
330
343
|
const settings = await loadSettings(db, envDefaults);
|
|
@@ -825,12 +838,21 @@ export function createApp({
|
|
|
825
838
|
} catch {
|
|
826
839
|
integrityEvents = [];
|
|
827
840
|
}
|
|
828
|
-
return adminJsonRes({
|
|
841
|
+
return adminJsonRes({
|
|
842
|
+
settings,
|
|
843
|
+
serverVersion: SERVER_VERSION,
|
|
844
|
+
pricingTable: buildEffectivePricingTable(settings),
|
|
845
|
+
members,
|
|
846
|
+
maxMembers: MAX_FAMILY_MEMBERS,
|
|
847
|
+
snapshots,
|
|
848
|
+
alerts,
|
|
849
|
+
integrityEvents,
|
|
850
|
+
});
|
|
829
851
|
}
|
|
830
852
|
|
|
831
853
|
if (request.method === 'POST' && path === '/api/admin/members') {
|
|
832
|
-
const
|
|
833
|
-
if ((
|
|
854
|
+
const existingRows = await db.all('SELECT color FROM members');
|
|
855
|
+
if ((existingRows || []).length >= MAX_FAMILY_MEMBERS) {
|
|
834
856
|
return adminJsonRes(
|
|
835
857
|
{
|
|
836
858
|
error: `Google 家庭组最多支持 ${MAX_FAMILY_MEMBERS} 位成员(1 位家庭组管理员 + 5 位家庭成员)。`,
|
|
@@ -844,7 +866,10 @@ export function createApp({
|
|
|
844
866
|
const name = String(body.name || '').trim().slice(0, 40);
|
|
845
867
|
if (!name) return adminJsonRes({ error: 'Member name is required.' }, 400);
|
|
846
868
|
const role = body.role === 'manager' ? 'manager' : 'member';
|
|
847
|
-
const
|
|
869
|
+
const defaultPalette = ['#f54e00', '#1f8a65', '#3b7dd8', '#8b5cf6', '#c08532', '#cf2d56'];
|
|
870
|
+
const usedColors = new Set((existingRows || []).map((r) => String(r.color || '').toLowerCase()));
|
|
871
|
+
const nextAutoColor = defaultPalette.find((c) => !usedColors.has(c)) || defaultPalette[(existingRows || []).length % defaultPalette.length];
|
|
872
|
+
const color = /^#[0-9a-fA-F]{6}$/.test(String(body.color || '')) ? body.color : nextAutoColor;
|
|
848
873
|
const quotaPct = parseQuotaPctInput(body.quotaPct);
|
|
849
874
|
const emailParsed = await parseMemberEmailInput(body.email);
|
|
850
875
|
const expectedEmailHash = emailParsed.action === 'set' ? emailParsed.hash : null;
|
|
@@ -88,7 +88,7 @@ export const SCHEMA_STATEMENTS = Object.freeze([
|
|
|
88
88
|
]);
|
|
89
89
|
|
|
90
90
|
export const DEFAULT_SETTINGS = Object.freeze({
|
|
91
|
-
boardTitle: 'Antigravity
|
|
91
|
+
boardTitle: 'Antigravity 家庭组',
|
|
92
92
|
defaultDailyCapUsd: 10,
|
|
93
93
|
defaultWeeklyCapUsd: 50,
|
|
94
94
|
defaultCycleCapUsd: 150,
|