dsh-agy-link 0.6.34 → 0.6.35
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/CHANGELOG.md +16 -0
- package/README.md +2 -2
- package/dist/cli-image.mjs +1278 -620
- package/dist/client.js +428 -166
- package/dist/index.js +21763 -20663
- package/docs/AUTH.md +19 -14
- package/docs/KNOWN-GAPS.md +1 -3
- package/docs/SECURITY-NOTES.md +14 -53
- package/package.json +2 -3
- package/dist/assets/icon.svg +0 -54
- package/dist/assets/mermaid.min.js +0 -3636
- package/dist/mermaid.min.js +0 -3636
- package/docs/REFACTORING-PLAN.md +0 -51
- package/docs/REFACTORING-RESULTS.md +0 -52
- package/docs/adr-012-account-pool.md +0 -58
- package/docs/spec-account-pool.md +0 -229
- package/icon.svg +0 -54
package/dist/client.js
CHANGED
|
@@ -4,9 +4,7 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
//#region src/client/locales.ts
|
|
8
|
-
/** Native DSH locale dictionaries for the Antigravity UI. */
|
|
9
|
-
const NS = "agy-link";
|
|
7
|
+
//#region src/client/locales/zh.ts
|
|
10
8
|
/** Simplified Chinese is preserved as the original UI language and key source. */
|
|
11
9
|
const zh = {
|
|
12
10
|
"section.label": "Antigravity",
|
|
@@ -38,10 +36,16 @@ window.__ModuleLoader__.load({
|
|
|
38
36
|
"status.needsAuth": "待认证",
|
|
39
37
|
"status.loading": "正在加载 Antigravity 状态...",
|
|
40
38
|
"status.authRequired": "需重新登录",
|
|
39
|
+
"status.cooldown": "冷却中",
|
|
40
|
+
"status.tosBanned": "已封禁 (ToS)",
|
|
41
|
+
"status.validationRequired": "需安全验证",
|
|
41
42
|
"account.setActive": "设为当前使用",
|
|
42
43
|
"account.settingActive": "切换中",
|
|
43
44
|
"account.activeSet": "已切换当前使用账号",
|
|
44
45
|
"account.activeSetFailed": "该账号当前不可用(冷却或需重新登录)",
|
|
46
|
+
"account.reauth": "重新登录",
|
|
47
|
+
"account.reauthing": "重登中",
|
|
48
|
+
"account.reauthTitle": "原位重新登录此账号(保留别名、代理与优先级)",
|
|
45
49
|
"status.proxy": "代理",
|
|
46
50
|
"status.inUse": "当前使用",
|
|
47
51
|
"account.add": "添加 Google 账号",
|
|
@@ -72,6 +76,11 @@ window.__ModuleLoader__.load({
|
|
|
72
76
|
"quota.refreshed": "额度已刷新",
|
|
73
77
|
"quota.refreshStarted": "正在同步额度,稍后自动更新",
|
|
74
78
|
"quota.windowReset": "已重置 · 可用",
|
|
79
|
+
"quota.unactivated": "未激活 · 预热启动计时",
|
|
80
|
+
"quota.paceSurplus": "节奏充裕(富裕 +{pct}%)",
|
|
81
|
+
"quota.paceFast": "消耗较快(超耗 {pct}%)",
|
|
82
|
+
"quota.paceOnTrack": "消耗均衡",
|
|
83
|
+
"quota.timeMarkerTitle": "窗口时间剩余基准线",
|
|
75
84
|
"proxy.button": "代理",
|
|
76
85
|
"proxy.placeholder": "专属代理 URL(如:http://127.0.0.1:7890;留空则使用全局)",
|
|
77
86
|
"proxy.save": "保存",
|
|
@@ -216,6 +225,8 @@ window.__ModuleLoader__.load({
|
|
|
216
225
|
"tsl.collapse": "收起",
|
|
217
226
|
"tsl.expand": "展开"
|
|
218
227
|
};
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/client/locales/en.ts
|
|
219
230
|
const en = {
|
|
220
231
|
"section.label": "Antigravity",
|
|
221
232
|
"console.title": "Antigravity Management Console",
|
|
@@ -246,10 +257,16 @@ window.__ModuleLoader__.load({
|
|
|
246
257
|
"status.needsAuth": "Authentication required",
|
|
247
258
|
"status.loading": "Loading Antigravity status...",
|
|
248
259
|
"status.authRequired": "Sign in again required",
|
|
260
|
+
"status.cooldown": "Cooldown",
|
|
261
|
+
"status.tosBanned": "Suspended (ToS)",
|
|
262
|
+
"status.validationRequired": "Verification required",
|
|
249
263
|
"account.setActive": "Set as in use",
|
|
250
264
|
"account.settingActive": "Switching...",
|
|
251
265
|
"account.activeSet": "Active account switched",
|
|
252
266
|
"account.activeSetFailed": "Account not currently eligible (cooldown or auth required)",
|
|
267
|
+
"account.reauth": "Sign in again",
|
|
268
|
+
"account.reauthing": "Signing in...",
|
|
269
|
+
"account.reauthTitle": "Re-authenticate this account in place (keeps alias, proxy and priority)",
|
|
253
270
|
"status.proxy": "Proxy",
|
|
254
271
|
"status.inUse": "In use",
|
|
255
272
|
"account.add": "Add Google account",
|
|
@@ -280,8 +297,13 @@ window.__ModuleLoader__.load({
|
|
|
280
297
|
"quota.refreshed": "Quota refreshed",
|
|
281
298
|
"quota.refreshStarted": "Syncing quota — figures update shortly",
|
|
282
299
|
"quota.windowReset": "Reset · available",
|
|
300
|
+
"quota.unactivated": "Unactivated · warmup to start",
|
|
301
|
+
"quota.paceSurplus": "Surplus pace (+{pct}%)",
|
|
302
|
+
"quota.paceFast": "Burning fast (-{pct}%)",
|
|
303
|
+
"quota.paceOnTrack": "On pace",
|
|
304
|
+
"quota.timeMarkerTitle": "Remaining time baseline",
|
|
283
305
|
"proxy.button": "Proxy",
|
|
284
|
-
"proxy.placeholder": "Dedicated proxy URL (
|
|
306
|
+
"proxy.placeholder": "Dedicated proxy URL (e.g. http://127.0.0.1:7890; leave blank to use the global proxy)",
|
|
285
307
|
"proxy.save": "Save",
|
|
286
308
|
"proxy.saved": "Proxy saved",
|
|
287
309
|
"cancel": "Cancel",
|
|
@@ -424,6 +446,8 @@ window.__ModuleLoader__.load({
|
|
|
424
446
|
"tsl.collapse": "Collapse",
|
|
425
447
|
"tsl.expand": "Expand"
|
|
426
448
|
};
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/client/locales/ptBR.ts
|
|
427
451
|
const ptBR = {
|
|
428
452
|
"section.label": "Antigravity",
|
|
429
453
|
"console.title": "Console de gerenciamento do Antigravity",
|
|
@@ -454,10 +478,16 @@ window.__ModuleLoader__.load({
|
|
|
454
478
|
"status.needsAuth": "Autenticação necessária",
|
|
455
479
|
"status.loading": "Carregando o status do Antigravity...",
|
|
456
480
|
"status.authRequired": "É necessário entrar novamente",
|
|
481
|
+
"status.cooldown": "Em espera",
|
|
482
|
+
"status.tosBanned": "Suspensa (ToS)",
|
|
483
|
+
"status.validationRequired": "Verificação necessária",
|
|
457
484
|
"account.setActive": "Definir como em uso",
|
|
458
485
|
"account.settingActive": "Alternando...",
|
|
459
486
|
"account.activeSet": "Conta em uso alterada",
|
|
460
487
|
"account.activeSetFailed": "Conta não elegível no momento (cooldown ou login necessário)",
|
|
488
|
+
"account.reauth": "Entrar novamente",
|
|
489
|
+
"account.reauthing": "Entrando...",
|
|
490
|
+
"account.reauthTitle": "Reautenticar esta conta no lugar (mantém apelido, proxy e prioridade)",
|
|
461
491
|
"status.proxy": "Proxy",
|
|
462
492
|
"status.inUse": "Em uso",
|
|
463
493
|
"account.add": "Adicionar conta Google",
|
|
@@ -488,8 +518,13 @@ window.__ModuleLoader__.load({
|
|
|
488
518
|
"quota.refreshed": "Cota atualizada",
|
|
489
519
|
"quota.refreshStarted": "Sincronizando a cota — os números atualizam em breve",
|
|
490
520
|
"quota.windowReset": "Redefinida · disponível",
|
|
521
|
+
"quota.unactivated": "Não ativada · aqueça para iniciar",
|
|
522
|
+
"quota.paceSurplus": "Folga de ritmo (+{pct}%)",
|
|
523
|
+
"quota.paceFast": "Consumo rápido (-{pct}%)",
|
|
524
|
+
"quota.paceOnTrack": "No ritmo",
|
|
525
|
+
"quota.timeMarkerTitle": "Referência de tempo restante",
|
|
491
526
|
"proxy.button": "Proxy",
|
|
492
|
-
"proxy.placeholder": "URL do proxy exclusivo (
|
|
527
|
+
"proxy.placeholder": "URL do proxy exclusivo (ex.: http://127.0.0.1:7890; deixe vazio para usar o proxy global)",
|
|
493
528
|
"proxy.save": "Salvar",
|
|
494
529
|
"proxy.saved": "Proxy salvo",
|
|
495
530
|
"cancel": "Cancelar",
|
|
@@ -632,6 +667,8 @@ window.__ModuleLoader__.load({
|
|
|
632
667
|
"tsl.collapse": "Recolher",
|
|
633
668
|
"tsl.expand": "Expandir"
|
|
634
669
|
};
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/client/locales/es.ts
|
|
635
672
|
const es = {
|
|
636
673
|
"section.label": "Antigravity",
|
|
637
674
|
"console.title": "Consola de administración de Antigravity",
|
|
@@ -662,10 +699,16 @@ window.__ModuleLoader__.load({
|
|
|
662
699
|
"status.needsAuth": "Se requiere autenticación",
|
|
663
700
|
"status.loading": "Cargando el estado de Antigravity...",
|
|
664
701
|
"status.authRequired": "Debe iniciar sesión de nuevo",
|
|
702
|
+
"status.cooldown": "En espera",
|
|
703
|
+
"status.tosBanned": "Suspendida (ToS)",
|
|
704
|
+
"status.validationRequired": "Verificación requerida",
|
|
665
705
|
"account.setActive": "Establecer como en uso",
|
|
666
706
|
"account.settingActive": "Cambiando...",
|
|
667
707
|
"account.activeSet": "Cuenta en uso cambiada",
|
|
668
708
|
"account.activeSetFailed": "Cuenta no elegible ahora (enfriamiento o requiere login)",
|
|
709
|
+
"account.reauth": "Iniciar sesión de nuevo",
|
|
710
|
+
"account.reauthing": "Iniciando...",
|
|
711
|
+
"account.reauthTitle": "Reautenticar esta cuenta en su sitio (conserva alias, proxy y prioridad)",
|
|
669
712
|
"status.proxy": "Proxy",
|
|
670
713
|
"status.inUse": "En uso",
|
|
671
714
|
"account.add": "Añadir cuenta de Google",
|
|
@@ -696,8 +739,13 @@ window.__ModuleLoader__.load({
|
|
|
696
739
|
"quota.refreshed": "Cuota actualizada",
|
|
697
740
|
"quota.refreshStarted": "Sincronizando la cuota — las cifras se actualizarán en breve",
|
|
698
741
|
"quota.windowReset": "Reiniciada · disponible",
|
|
742
|
+
"quota.unactivated": "Sin activar · calentar para iniciar",
|
|
743
|
+
"quota.paceSurplus": "Margen favorable (+{pct}%)",
|
|
744
|
+
"quota.paceFast": "Consumo rápido (-{pct}%)",
|
|
745
|
+
"quota.paceOnTrack": "A buen ritmo",
|
|
746
|
+
"quota.timeMarkerTitle": "Referencia de tiempo restante",
|
|
699
747
|
"proxy.button": "Proxy",
|
|
700
|
-
"proxy.placeholder": "URL de proxy exclusivo (
|
|
748
|
+
"proxy.placeholder": "URL de proxy exclusivo (p. ej.: http://127.0.0.1:7890; déjelo vacío para usar el proxy global)",
|
|
701
749
|
"proxy.save": "Guardar",
|
|
702
750
|
"proxy.saved": "Proxy guardado",
|
|
703
751
|
"cancel": "Cancelar",
|
|
@@ -841,6 +889,10 @@ window.__ModuleLoader__.load({
|
|
|
841
889
|
"tsl.expand": "Expandir"
|
|
842
890
|
};
|
|
843
891
|
//#endregion
|
|
892
|
+
//#region src/client/locales.ts
|
|
893
|
+
/** Native DSH locale dictionaries for the Antigravity UI. */
|
|
894
|
+
const NS = "agy-link";
|
|
895
|
+
//#endregion
|
|
844
896
|
//#region src/client/toolview/styles.ts
|
|
845
897
|
const ROW_CSS = `
|
|
846
898
|
/* Container */
|
|
@@ -1705,6 +1757,57 @@ window.__ModuleLoader__.load({
|
|
|
1705
1757
|
overlaySuspended = false;
|
|
1706
1758
|
}
|
|
1707
1759
|
//#endregion
|
|
1760
|
+
//#region src/common/timeouts.ts
|
|
1761
|
+
/** Status poll: keep the console responsive, never stack polls. */
|
|
1762
|
+
const STATUS_TIMEOUT_MS = 5e3;
|
|
1763
|
+
/** A write (sync / config / auth): the busy flag must always clear. */
|
|
1764
|
+
const WRITE_TIMEOUT_MS = 2e4;
|
|
1765
|
+
//#endregion
|
|
1766
|
+
//#region src/client/api.ts
|
|
1767
|
+
const win$1 = globalThis;
|
|
1768
|
+
const base$1 = win$1.location?.origin ?? "";
|
|
1769
|
+
const PLUGIN_BASE = "/plugins/agy-link";
|
|
1770
|
+
/** One AbortSignal.timeout helper, shared by writes and the status poll. */
|
|
1771
|
+
function timedSignal(ms) {
|
|
1772
|
+
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") return AbortSignal.timeout(ms);
|
|
1773
|
+
}
|
|
1774
|
+
async function postJson(path, body, timeoutMs = WRITE_TIMEOUT_MS) {
|
|
1775
|
+
try {
|
|
1776
|
+
const init = {
|
|
1777
|
+
method: "POST",
|
|
1778
|
+
headers: { "Content-Type": "application/json" },
|
|
1779
|
+
body: JSON.stringify(body)
|
|
1780
|
+
};
|
|
1781
|
+
const signal = timedSignal(timeoutMs);
|
|
1782
|
+
if (signal !== void 0) init.signal = signal;
|
|
1783
|
+
const res = await win$1.fetch?.(base$1 + path, init);
|
|
1784
|
+
if (!res) return null;
|
|
1785
|
+
try {
|
|
1786
|
+
const payload = await res.json();
|
|
1787
|
+
if (!res.ok && payload !== null && typeof payload === "object") return {
|
|
1788
|
+
ok: false,
|
|
1789
|
+
...payload
|
|
1790
|
+
};
|
|
1791
|
+
return payload;
|
|
1792
|
+
} catch {
|
|
1793
|
+
return { ok: res.ok };
|
|
1794
|
+
}
|
|
1795
|
+
} catch {
|
|
1796
|
+
return null;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
/** Small typed endpoint helper for the account-pool actions. */
|
|
1800
|
+
function postPool(action, body = {}, timeoutMs) {
|
|
1801
|
+
return postJson(`${PLUGIN_BASE}/pool/${action}`, body, timeoutMs ?? (action === "warmup" ? 9e4 : 2e4));
|
|
1802
|
+
}
|
|
1803
|
+
/** The shared config-write helper (same /config endpoint the toggles use). */
|
|
1804
|
+
function postConfig(key, value) {
|
|
1805
|
+
return postJson(`${PLUGIN_BASE}/config`, {
|
|
1806
|
+
key,
|
|
1807
|
+
value
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
//#endregion
|
|
1708
1811
|
//#region src/client/images/media.ts
|
|
1709
1812
|
function getOrigin() {
|
|
1710
1813
|
if (typeof window !== "undefined" && window.location?.origin) {
|
|
@@ -1752,7 +1855,11 @@ window.__ModuleLoader__.load({
|
|
|
1752
1855
|
async function openInSystem(rawPath, reveal = false) {
|
|
1753
1856
|
try {
|
|
1754
1857
|
const url = `${getOrigin()}/plugins/agy-link/open?path=${encodeURIComponent(rawPath.trim())}${reveal ? "&reveal=1" : ""}`;
|
|
1755
|
-
const
|
|
1858
|
+
const signal = timedSignal(WRITE_TIMEOUT_MS);
|
|
1859
|
+
const res = await fetch(url, {
|
|
1860
|
+
method: "POST",
|
|
1861
|
+
...signal ? { signal } : {}
|
|
1862
|
+
});
|
|
1756
1863
|
if (!res.ok) return {
|
|
1757
1864
|
ok: false,
|
|
1758
1865
|
error: (await res.json().catch(() => ({})))?.error ?? `HTTP ${res.status}`
|
|
@@ -1891,9 +1998,7 @@ window.__ModuleLoader__.load({
|
|
|
1891
1998
|
position: fixed;
|
|
1892
1999
|
inset: 0;
|
|
1893
2000
|
z-index: 999999;
|
|
1894
|
-
background:
|
|
1895
|
-
backdrop-filter: blur(24px) saturate(160%);
|
|
1896
|
-
-webkit-backdrop-filter: blur(24px) saturate(160%);
|
|
2001
|
+
background: rgba(6, 8, 15, 0.94);
|
|
1897
2002
|
overscroll-behavior: contain;
|
|
1898
2003
|
display: flex;
|
|
1899
2004
|
flex-direction: column;
|
|
@@ -1915,9 +2020,7 @@ window.__ModuleLoader__.load({
|
|
|
1915
2020
|
align-items: center;
|
|
1916
2021
|
gap: 6px;
|
|
1917
2022
|
padding: 6px 14px;
|
|
1918
|
-
background: rgba(20, 24, 38, 0.
|
|
1919
|
-
backdrop-filter: blur(28px) saturate(190%);
|
|
1920
|
-
-webkit-backdrop-filter: blur(28px) saturate(190%);
|
|
2023
|
+
background: rgba(20, 24, 38, 0.95);
|
|
1921
2024
|
border: 1px solid rgba(255, 255, 255, 0.14);
|
|
1922
2025
|
border-radius: 9999px;
|
|
1923
2026
|
box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
|
|
@@ -2024,9 +2127,8 @@ window.__ModuleLoader__.load({
|
|
|
2024
2127
|
left: 50%;
|
|
2025
2128
|
transform: translateX(-50%);
|
|
2026
2129
|
font-size: 11px;
|
|
2027
|
-
color: rgba(255, 255, 255, 0.
|
|
2028
|
-
background: rgba(15, 23, 42, 0.
|
|
2029
|
-
backdrop-filter: blur(12px);
|
|
2130
|
+
color: rgba(255, 255, 255, 0.65);
|
|
2131
|
+
background: rgba(15, 23, 42, 0.9);
|
|
2030
2132
|
padding: 4px 14px;
|
|
2031
2133
|
border-radius: 9999px;
|
|
2032
2134
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
@@ -2051,10 +2153,8 @@ window.__ModuleLoader__.load({
|
|
|
2051
2153
|
bottom: 32px;
|
|
2052
2154
|
left: 50%;
|
|
2053
2155
|
transform: translateX(-50%) translateY(16px);
|
|
2054
|
-
background: rgba(20, 24, 38, 0.
|
|
2156
|
+
background: rgba(20, 24, 38, 0.96);
|
|
2055
2157
|
border: 1px solid rgba(255, 255, 255, 0.16);
|
|
2056
|
-
backdrop-filter: blur(24px);
|
|
2057
|
-
-webkit-backdrop-filter: blur(24px);
|
|
2058
2158
|
color: #f8fafc;
|
|
2059
2159
|
padding: 8px 18px;
|
|
2060
2160
|
border-radius: 9999px;
|
|
@@ -2198,6 +2298,7 @@ window.__ModuleLoader__.load({
|
|
|
2198
2298
|
//#endregion
|
|
2199
2299
|
//#region src/client/images/lightbox.ts
|
|
2200
2300
|
let lightboxOverlay = null;
|
|
2301
|
+
let activeLightboxCleanup = null;
|
|
2201
2302
|
let lightboxScale = 1;
|
|
2202
2303
|
let lightboxTranslateX = 0;
|
|
2203
2304
|
let lightboxTranslateY = 0;
|
|
@@ -2210,7 +2311,10 @@ window.__ModuleLoader__.load({
|
|
|
2210
2311
|
if (existing) existing.remove();
|
|
2211
2312
|
const toast = document.createElement("div");
|
|
2212
2313
|
toast.className = "agy-toast";
|
|
2213
|
-
toast.innerHTML =
|
|
2314
|
+
toast.innerHTML = "<svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#34d399\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20 6 9 17 4 12\"></polyline></svg>";
|
|
2315
|
+
const label = document.createElement("span");
|
|
2316
|
+
label.textContent = message;
|
|
2317
|
+
toast.appendChild(label);
|
|
2214
2318
|
document.body.appendChild(toast);
|
|
2215
2319
|
requestAnimationFrame(() => toast.classList.add("show"));
|
|
2216
2320
|
setTimeout(() => {
|
|
@@ -2346,6 +2450,8 @@ window.__ModuleLoader__.load({
|
|
|
2346
2450
|
if (typeof document === "undefined") return;
|
|
2347
2451
|
injectStyles$5();
|
|
2348
2452
|
if (lightboxOverlay) {
|
|
2453
|
+
activeLightboxCleanup?.();
|
|
2454
|
+
activeLightboxCleanup = null;
|
|
2349
2455
|
lightboxOverlay.remove();
|
|
2350
2456
|
lightboxOverlay = null;
|
|
2351
2457
|
}
|
|
@@ -2372,10 +2478,14 @@ window.__ModuleLoader__.load({
|
|
|
2372
2478
|
const updateTransform = () => {
|
|
2373
2479
|
imgWrap.style.transform = `translate(${lightboxTranslateX}px, ${lightboxTranslateY}px) scale(${lightboxScale})`;
|
|
2374
2480
|
};
|
|
2375
|
-
const
|
|
2481
|
+
const cleanupListeners = () => {
|
|
2376
2482
|
window.removeEventListener("keydown", onKeyDown);
|
|
2377
2483
|
window.removeEventListener("mousemove", onMouseMove);
|
|
2378
2484
|
window.removeEventListener("mouseup", onMouseUp);
|
|
2485
|
+
};
|
|
2486
|
+
const closeLightbox = () => {
|
|
2487
|
+
cleanupListeners();
|
|
2488
|
+
if (activeLightboxCleanup === cleanupListeners) activeLightboxCleanup = null;
|
|
2379
2489
|
overlay.classList.remove("open");
|
|
2380
2490
|
setTimeout(() => {
|
|
2381
2491
|
overlay.remove();
|
|
@@ -2479,6 +2589,7 @@ window.__ModuleLoader__.load({
|
|
|
2479
2589
|
};
|
|
2480
2590
|
window.addEventListener("mousemove", onMouseMove);
|
|
2481
2591
|
window.addEventListener("mouseup", onMouseUp);
|
|
2592
|
+
activeLightboxCleanup = cleanupListeners;
|
|
2482
2593
|
if (!isVideo) body.onwheel = (e) => {
|
|
2483
2594
|
e.preventDefault();
|
|
2484
2595
|
const factor = e.deltaY < 0 ? 1.15 : .87;
|
|
@@ -4803,8 +4914,8 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4803
4914
|
}
|
|
4804
4915
|
}
|
|
4805
4916
|
const { createElement: h$1, useState: useState$1, useEffect: useEffect$1 } = require("react");
|
|
4806
|
-
const win
|
|
4807
|
-
const base
|
|
4917
|
+
const win = globalThis;
|
|
4918
|
+
const base = win.location?.origin ?? "";
|
|
4808
4919
|
const STYLE_ID = "dsh-agy-link-tsl-css-v2";
|
|
4809
4920
|
const TRANSLATION_KIND = "agy-translation";
|
|
4810
4921
|
function service(ctx, name) {
|
|
@@ -5016,7 +5127,7 @@ body.dark .agy-tsl-card,
|
|
|
5016
5127
|
`;
|
|
5017
5128
|
function injectStyles$1() {
|
|
5018
5129
|
if (typeof document === "undefined") return;
|
|
5019
|
-
const doc = win
|
|
5130
|
+
const doc = win.document;
|
|
5020
5131
|
if (doc === null || doc === void 0) return;
|
|
5021
5132
|
const existing = doc.getElementById(STYLE_ID);
|
|
5022
5133
|
if (existing !== null && existing !== void 0) {
|
|
@@ -5149,7 +5260,7 @@ body.dark .agy-tsl-card,
|
|
|
5149
5260
|
if (typeof data.effort === "string" && data.effort !== "") meta.push(data.effort);
|
|
5150
5261
|
if (typeof data.accountId === "string" && data.accountId !== "") meta.push(data.accountId);
|
|
5151
5262
|
const copy = () => {
|
|
5152
|
-
win
|
|
5263
|
+
win.navigator?.clipboard?.writeText(text).then(() => {
|
|
5153
5264
|
setCopied(true);
|
|
5154
5265
|
setTimeout(() => setCopied(false), 1500);
|
|
5155
5266
|
}).catch(() => void 0);
|
|
@@ -5171,57 +5282,6 @@ body.dark .agy-tsl-card,
|
|
|
5171
5282
|
title: meta.join(" · ")
|
|
5172
5283
|
}, meta.join(" · ")), h$1("span", { className: "agy-tsl-actions" }, original === "" ? null : action("original", showOriginal ? t("tsl.hideOriginal", "Hide original") : t("tsl.showOriginal", "Show original"), () => setShowOriginal(!showOriginal), showOriginal), action("copy", copied ? t("tsl.copied", "Copied") : t("tsl.copy", "Copy"), copy), action("collapse", open ? t("tsl.collapse", "Collapse") : t("tsl.expand", "Expand"), () => setOpen(!open)))), open ? h$1("div", { className: "agy-tsl-body" }, renderMarkdown(text)) : null, showOriginal && original !== "" ? h$1("pre", { className: "agy-tsl-original" }, original) : null);
|
|
5173
5284
|
};
|
|
5174
|
-
//#endregion
|
|
5175
|
-
//#region src/common/timeouts.ts
|
|
5176
|
-
/** Status poll: keep the console responsive, never stack polls. */
|
|
5177
|
-
const STATUS_TIMEOUT_MS = 5e3;
|
|
5178
|
-
/** A write (sync / warmup / config / auth): the busy flag must always clear. */
|
|
5179
|
-
const WRITE_TIMEOUT_MS = 2e4;
|
|
5180
|
-
//#endregion
|
|
5181
|
-
//#region src/client/api.ts
|
|
5182
|
-
const win = globalThis;
|
|
5183
|
-
const base = win.location?.origin ?? "";
|
|
5184
|
-
const PLUGIN_BASE = "/plugins/agy-link";
|
|
5185
|
-
/** One AbortSignal.timeout helper, shared by writes and the status poll. */
|
|
5186
|
-
function timedSignal(ms) {
|
|
5187
|
-
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") return AbortSignal.timeout(ms);
|
|
5188
|
-
}
|
|
5189
|
-
async function postJson(path, body) {
|
|
5190
|
-
try {
|
|
5191
|
-
const init = {
|
|
5192
|
-
method: "POST",
|
|
5193
|
-
headers: { "Content-Type": "application/json" },
|
|
5194
|
-
body: JSON.stringify(body)
|
|
5195
|
-
};
|
|
5196
|
-
const signal = timedSignal(WRITE_TIMEOUT_MS);
|
|
5197
|
-
if (signal !== void 0) init.signal = signal;
|
|
5198
|
-
const res = await win.fetch?.(base + path, init);
|
|
5199
|
-
if (!res) return null;
|
|
5200
|
-
try {
|
|
5201
|
-
const payload = await res.json();
|
|
5202
|
-
if (!res.ok && payload !== null && typeof payload === "object") return {
|
|
5203
|
-
ok: false,
|
|
5204
|
-
...payload
|
|
5205
|
-
};
|
|
5206
|
-
return payload;
|
|
5207
|
-
} catch {
|
|
5208
|
-
return { ok: res.ok };
|
|
5209
|
-
}
|
|
5210
|
-
} catch {
|
|
5211
|
-
return null;
|
|
5212
|
-
}
|
|
5213
|
-
}
|
|
5214
|
-
/** Small typed endpoint helper for the account-pool actions. */
|
|
5215
|
-
function postPool(action, body = {}) {
|
|
5216
|
-
return postJson(`${PLUGIN_BASE}/pool/${action}`, body);
|
|
5217
|
-
}
|
|
5218
|
-
/** The shared config-write helper (same /config endpoint the toggles use). */
|
|
5219
|
-
function postConfig(key, value) {
|
|
5220
|
-
return postJson(`${PLUGIN_BASE}/config`, {
|
|
5221
|
-
key,
|
|
5222
|
-
value
|
|
5223
|
-
});
|
|
5224
|
-
}
|
|
5225
5285
|
const { createElement: h, useState, useEffect, useRef } = require("react");
|
|
5226
5286
|
const reactDom = require("react-dom");
|
|
5227
5287
|
//#endregion
|
|
@@ -5229,7 +5289,7 @@ body.dark .agy-tsl-card,
|
|
|
5229
5289
|
const STATUS_CACHE_KEY = "dsh_agy_status_cache";
|
|
5230
5290
|
function loadInitialStatusCache() {
|
|
5231
5291
|
try {
|
|
5232
|
-
const raw = win.localStorage?.getItem(STATUS_CACHE_KEY);
|
|
5292
|
+
const raw = win$1.localStorage?.getItem(STATUS_CACHE_KEY);
|
|
5233
5293
|
if (raw) {
|
|
5234
5294
|
const parsed = JSON.parse(raw);
|
|
5235
5295
|
if (parsed && typeof parsed === "object") return parsed;
|
|
@@ -5238,22 +5298,41 @@ body.dark .agy-tsl-card,
|
|
|
5238
5298
|
return null;
|
|
5239
5299
|
}
|
|
5240
5300
|
let statusCache = loadInitialStatusCache();
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5301
|
+
let lastEtag = null;
|
|
5302
|
+
let inFlightStatus = null;
|
|
5303
|
+
async function fetchStatusRaw(force) {
|
|
5304
|
+
if (!force && inFlightStatus !== null) return inFlightStatus;
|
|
5305
|
+
const job = (async () => {
|
|
5306
|
+
try {
|
|
5307
|
+
const init = {};
|
|
5308
|
+
const signal = timedSignal(STATUS_TIMEOUT_MS);
|
|
5309
|
+
if (signal !== void 0) init.signal = signal;
|
|
5310
|
+
if (!force && lastEtag !== null) init.headers = { "If-None-Match": lastEtag };
|
|
5311
|
+
const res = await win$1.fetch?.(base$1 + "/plugins/agy-link/status", init);
|
|
5312
|
+
if (!res) return { kind: "error" };
|
|
5313
|
+
if (res.status === 304) return { kind: "not-modified" };
|
|
5314
|
+
if (!res.ok) return { kind: "error" };
|
|
5315
|
+
const etag = res.headers?.get?.("etag") ?? res.headers?.get?.("ETag") ?? null;
|
|
5316
|
+
if (typeof etag === "string" && etag !== "") lastEtag = etag;
|
|
5317
|
+
const data = await res.json?.();
|
|
5318
|
+
return data && typeof data === "object" ? {
|
|
5319
|
+
kind: "ok",
|
|
5320
|
+
data
|
|
5321
|
+
} : { kind: "error" };
|
|
5322
|
+
} catch {
|
|
5323
|
+
return { kind: "error" };
|
|
5324
|
+
}
|
|
5325
|
+
})().finally(() => {
|
|
5326
|
+
if (inFlightStatus === job) inFlightStatus = null;
|
|
5327
|
+
});
|
|
5328
|
+
inFlightStatus = job;
|
|
5329
|
+
return job;
|
|
5252
5330
|
}
|
|
5253
5331
|
const statusListeners = /* @__PURE__ */ new Set();
|
|
5254
5332
|
let statusPollTimer = null;
|
|
5255
5333
|
let statusPollInterval = 3e3;
|
|
5256
5334
|
let statusFetchSeq = 0;
|
|
5335
|
+
let visibilityCleanup = null;
|
|
5257
5336
|
function isStatusEqual(a, b) {
|
|
5258
5337
|
if (a === b) return true;
|
|
5259
5338
|
if (a === null || b === null) return false;
|
|
@@ -5276,20 +5355,36 @@ body.dark .agy-tsl-card,
|
|
|
5276
5355
|
function publishStatus(st) {
|
|
5277
5356
|
statusCache = st;
|
|
5278
5357
|
try {
|
|
5279
|
-
win.localStorage?.setItem(STATUS_CACHE_KEY, JSON.stringify(st));
|
|
5358
|
+
win$1.localStorage?.setItem(STATUS_CACHE_KEY, JSON.stringify(st));
|
|
5280
5359
|
} catch {}
|
|
5281
5360
|
for (const fn of [...statusListeners]) try {
|
|
5282
5361
|
fn(st);
|
|
5283
5362
|
} catch {}
|
|
5284
5363
|
}
|
|
5285
|
-
async function statusPollTick() {
|
|
5364
|
+
async function statusPollTick(force = false) {
|
|
5365
|
+
if (!force && win$1.document?.hidden === true) return;
|
|
5286
5366
|
const seq = ++statusFetchSeq;
|
|
5287
|
-
const
|
|
5288
|
-
if (
|
|
5289
|
-
if (!isStatusEqual(statusCache,
|
|
5367
|
+
const res = await fetchStatusRaw(force);
|
|
5368
|
+
if (res.kind === "ok" && seq === statusFetchSeq) {
|
|
5369
|
+
if (!isStatusEqual(statusCache, res.data)) publishStatus(res.data);
|
|
5290
5370
|
}
|
|
5291
5371
|
}
|
|
5372
|
+
function attachVisibilityWake() {
|
|
5373
|
+
if (visibilityCleanup !== null) return;
|
|
5374
|
+
const doc = win$1.document;
|
|
5375
|
+
const w = win$1;
|
|
5376
|
+
const onWake = () => {
|
|
5377
|
+
if (doc?.hidden !== true && statusListeners.size > 0) statusPollTick(false);
|
|
5378
|
+
};
|
|
5379
|
+
doc?.addEventListener?.("visibilitychange", onWake);
|
|
5380
|
+
w.addEventListener?.("focus", onWake);
|
|
5381
|
+
visibilityCleanup = () => {
|
|
5382
|
+
doc?.removeEventListener?.("visibilitychange", onWake);
|
|
5383
|
+
w.removeEventListener?.("focus", onWake);
|
|
5384
|
+
};
|
|
5385
|
+
}
|
|
5292
5386
|
function ensureStatusPolling() {
|
|
5387
|
+
attachVisibilityWake();
|
|
5293
5388
|
if (statusPollTimer !== null) {
|
|
5294
5389
|
if (statusPollInterval !== 3e3) {
|
|
5295
5390
|
clearInterval(statusPollTimer);
|
|
@@ -5297,9 +5392,9 @@ body.dark .agy-tsl-card,
|
|
|
5297
5392
|
} else return;
|
|
5298
5393
|
}
|
|
5299
5394
|
statusPollInterval = 3e3;
|
|
5300
|
-
statusPollTick();
|
|
5395
|
+
statusPollTick(false);
|
|
5301
5396
|
statusPollTimer = setInterval(() => {
|
|
5302
|
-
statusPollTick();
|
|
5397
|
+
statusPollTick(false);
|
|
5303
5398
|
}, 3e3);
|
|
5304
5399
|
}
|
|
5305
5400
|
function stopStatusPollingIfIdle() {
|
|
@@ -5307,7 +5402,7 @@ body.dark .agy-tsl-card,
|
|
|
5307
5402
|
clearInterval(statusPollTimer);
|
|
5308
5403
|
statusPollInterval = 15e3;
|
|
5309
5404
|
statusPollTimer = setInterval(() => {
|
|
5310
|
-
statusPollTick();
|
|
5405
|
+
statusPollTick(false);
|
|
5311
5406
|
}, 15e3);
|
|
5312
5407
|
}
|
|
5313
5408
|
}
|
|
@@ -5317,6 +5412,10 @@ body.dark .agy-tsl-card,
|
|
|
5317
5412
|
clearInterval(statusPollTimer);
|
|
5318
5413
|
statusPollTimer = null;
|
|
5319
5414
|
}
|
|
5415
|
+
visibilityCleanup?.();
|
|
5416
|
+
visibilityCleanup = null;
|
|
5417
|
+
lastEtag = null;
|
|
5418
|
+
inFlightStatus = null;
|
|
5320
5419
|
}
|
|
5321
5420
|
/**
|
|
5322
5421
|
* Subscribe a component to the shared status poll. Returns the latest
|
|
@@ -5334,10 +5433,7 @@ body.dark .agy-tsl-card,
|
|
|
5334
5433
|
stopStatusPollingIfIdle();
|
|
5335
5434
|
};
|
|
5336
5435
|
}, []);
|
|
5337
|
-
const refresh =
|
|
5338
|
-
const st = await getStatus();
|
|
5339
|
-
if (st !== null && !isStatusEqual(statusCache, st)) publishStatus(st);
|
|
5340
|
-
};
|
|
5436
|
+
const refresh = () => statusPollTick(true);
|
|
5341
5437
|
return {
|
|
5342
5438
|
status,
|
|
5343
5439
|
refresh
|
|
@@ -5345,12 +5441,15 @@ body.dark .agy-tsl-card,
|
|
|
5345
5441
|
}
|
|
5346
5442
|
//#endregion
|
|
5347
5443
|
//#region src/client/translate-state.ts
|
|
5444
|
+
const TRANSLATE_REQUEST_TIMEOUT_MS = 18e4;
|
|
5348
5445
|
async function postTranslate(body) {
|
|
5349
5446
|
try {
|
|
5350
|
-
const
|
|
5447
|
+
const signal = timedSignal(TRANSLATE_REQUEST_TIMEOUT_MS);
|
|
5448
|
+
const res = await win.fetch?.(base + "/plugins/agy-link/translate", {
|
|
5351
5449
|
method: "POST",
|
|
5352
5450
|
headers: { "Content-Type": "application/json" },
|
|
5353
|
-
body: JSON.stringify(body)
|
|
5451
|
+
body: JSON.stringify(body),
|
|
5452
|
+
...signal !== void 0 ? { signal } : {}
|
|
5354
5453
|
});
|
|
5355
5454
|
if (!res) return null;
|
|
5356
5455
|
return await res.json();
|
|
@@ -5361,8 +5460,9 @@ body.dark .agy-tsl-card,
|
|
|
5361
5460
|
/** Ask the host whether this reply already owns a durable translation. */
|
|
5362
5461
|
async function getMessageState(sessionId, messageId) {
|
|
5363
5462
|
try {
|
|
5364
|
-
const url = base
|
|
5365
|
-
const
|
|
5463
|
+
const url = base + "/plugins/agy-link/translate/state?session=" + encodeURIComponent(sessionId) + "&message=" + encodeURIComponent(messageId);
|
|
5464
|
+
const signal = timedSignal(STATUS_TIMEOUT_MS);
|
|
5465
|
+
const res = await win.fetch?.(url, signal !== void 0 ? { signal } : void 0);
|
|
5366
5466
|
if (!res) return null;
|
|
5367
5467
|
return await res.json();
|
|
5368
5468
|
} catch {
|
|
@@ -5460,7 +5560,7 @@ body.dark .agy-tsl-card,
|
|
|
5460
5560
|
const TIP_MAX_WIDTH_VW = .5;
|
|
5461
5561
|
/** Viewport size, guarded for a headless/test document. */
|
|
5462
5562
|
function viewport() {
|
|
5463
|
-
const w = win
|
|
5563
|
+
const w = win;
|
|
5464
5564
|
return {
|
|
5465
5565
|
width: typeof w.innerWidth === "number" ? w.innerWidth : 0,
|
|
5466
5566
|
height: typeof w.innerHeight === "number" ? w.innerHeight : 0
|
|
@@ -5469,7 +5569,7 @@ body.dark .agy-tsl-card,
|
|
|
5469
5569
|
/** Hidden by default through INLINE styles — not through the stylesheet. */
|
|
5470
5570
|
function tipNode() {
|
|
5471
5571
|
if (typeof document === "undefined") return null;
|
|
5472
|
-
const doc = win
|
|
5572
|
+
const doc = win.document;
|
|
5473
5573
|
if (doc === null || doc === void 0 || typeof doc.createElement !== "function") return null;
|
|
5474
5574
|
const found = typeof doc.getElementById === "function" ? doc.getElementById(TIP_ID) : null;
|
|
5475
5575
|
if (found !== null && found !== void 0 && found.isConnected !== false) return found;
|
|
@@ -5753,7 +5853,7 @@ body.dark .agy-tsl-card,
|
|
|
5753
5853
|
dispose();
|
|
5754
5854
|
} catch {}
|
|
5755
5855
|
try {
|
|
5756
|
-
const doc = win
|
|
5856
|
+
const doc = win.document;
|
|
5757
5857
|
doc?.getElementById?.(TIP_ID)?.remove?.();
|
|
5758
5858
|
doc?.getElementById?.(STYLE_ID)?.remove?.();
|
|
5759
5859
|
} catch {}
|
|
@@ -6198,12 +6298,13 @@ body.dark .agy-tsl-card,
|
|
|
6198
6298
|
anthropic: "claude",
|
|
6199
6299
|
openai: "openai"
|
|
6200
6300
|
};
|
|
6301
|
+
let agyIconSeq = 0;
|
|
6201
6302
|
/**
|
|
6202
6303
|
* Antigravity logo mark: 3D orbit sphere with specular highlight, luminous front/back rings
|
|
6203
6304
|
* and twin satellite nodes matching the official assets/icon.svg.
|
|
6204
6305
|
*/
|
|
6205
6306
|
function agyIcon(size = 16) {
|
|
6206
|
-
const uid = "agy-logo";
|
|
6307
|
+
const uid = "agy-logo-" + ++agyIconSeq;
|
|
6207
6308
|
return h("svg", {
|
|
6208
6309
|
viewBox: "0 0 36 36",
|
|
6209
6310
|
width: size,
|
|
@@ -7281,7 +7382,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7281
7382
|
//#endregion
|
|
7282
7383
|
//#region src/client/ui/Modal.ts
|
|
7283
7384
|
const portalToBody = (node) => {
|
|
7284
|
-
const body = win.document?.body ?? (typeof document !== "undefined" ? document.body : null);
|
|
7385
|
+
const body = win$1.document?.body ?? (typeof document !== "undefined" ? document.body : null);
|
|
7285
7386
|
if (body && reactDom && typeof reactDom.createPortal === "function") return reactDom.createPortal(node, body);
|
|
7286
7387
|
return node;
|
|
7287
7388
|
};
|
|
@@ -7350,8 +7451,8 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7350
7451
|
onClose();
|
|
7351
7452
|
}
|
|
7352
7453
|
};
|
|
7353
|
-
win.addEventListener?.("keydown", onKey, true);
|
|
7354
|
-
return () => win.removeEventListener?.("keydown", onKey, true);
|
|
7454
|
+
win$1.addEventListener?.("keydown", onKey, true);
|
|
7455
|
+
return () => win$1.removeEventListener?.("keydown", onKey, true);
|
|
7355
7456
|
}, []);
|
|
7356
7457
|
useEffect(() => {
|
|
7357
7458
|
if (typeof document === "undefined") return;
|
|
@@ -7421,7 +7522,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7421
7522
|
minHeight: 0,
|
|
7422
7523
|
background: "var(--agy-bg-panel)"
|
|
7423
7524
|
}
|
|
7424
|
-
}, children)));
|
|
7525
|
+
}, ...Array.isArray(children) ? children : [children])));
|
|
7425
7526
|
}
|
|
7426
7527
|
//#endregion
|
|
7427
7528
|
//#region src/common/model-lineup.ts
|
|
@@ -7731,21 +7832,41 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7731
7832
|
const key = `auth.code.${code ?? ""}`;
|
|
7732
7833
|
return code && key in en ? t(key) : t("api.genericError");
|
|
7733
7834
|
}
|
|
7835
|
+
async function startPoolBeginRequest(payload, actionKey, deps) {
|
|
7836
|
+
const { refresh, showToast, setLoadingAction, t, flowStartedRef } = deps;
|
|
7837
|
+
setLoadingAction(actionKey);
|
|
7838
|
+
const res = await postPool("begin-add", payload);
|
|
7839
|
+
setLoadingAction(null);
|
|
7840
|
+
if (res && res.ok) {
|
|
7841
|
+
flowStartedRef.current = true;
|
|
7842
|
+
await refresh();
|
|
7843
|
+
showToast(res.browserOpened ? t("auth.browserOpened") : t("auth.browserManual"), res.browserOpened ? "info" : "warn");
|
|
7844
|
+
} else showToast(res?.code ? toSafeMessage(t, res.code) : t("auth.startFailed"), "error");
|
|
7845
|
+
}
|
|
7734
7846
|
function useAuthFlow({ status, refresh, showToast, setLoadingAction, t }) {
|
|
7735
7847
|
const [aliasInput, setAliasInput] = useState("");
|
|
7736
7848
|
const [addingAccount, setAddingAccount] = useState(false);
|
|
7737
7849
|
const [importMode, setImportMode] = useState(false);
|
|
7850
|
+
const [reauthAccountId, setReauthAccountId] = useState(null);
|
|
7738
7851
|
const [authCodeInput, setAuthCodeInput] = useState("");
|
|
7739
7852
|
const [addProxyInput, setAddProxyInput] = useState("");
|
|
7740
7853
|
const [tokenInput, setTokenInput] = useState("");
|
|
7741
7854
|
const flowStartedRef = useRef(false);
|
|
7742
7855
|
const safeMessage = (code) => toSafeMessage(t, code);
|
|
7856
|
+
const beginDeps = {
|
|
7857
|
+
refresh,
|
|
7858
|
+
showToast,
|
|
7859
|
+
setLoadingAction,
|
|
7860
|
+
t,
|
|
7861
|
+
flowStartedRef
|
|
7862
|
+
};
|
|
7743
7863
|
const resetForm = () => {
|
|
7744
7864
|
setAuthCodeInput("");
|
|
7745
7865
|
setAliasInput("");
|
|
7746
7866
|
setAddProxyInput("");
|
|
7747
7867
|
setTokenInput("");
|
|
7748
7868
|
setImportMode(false);
|
|
7869
|
+
setReauthAccountId(null);
|
|
7749
7870
|
};
|
|
7750
7871
|
useEffect(() => {
|
|
7751
7872
|
if (!addingAccount || !flowStartedRef.current) return;
|
|
@@ -7766,19 +7887,25 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7766
7887
|
status?.poolAuth?.code
|
|
7767
7888
|
]);
|
|
7768
7889
|
const handleBeginAddAccount = async () => {
|
|
7769
|
-
setLoadingAction("pool:beginAdd");
|
|
7770
7890
|
const alias = aliasInput.trim();
|
|
7771
7891
|
const proxyUrl = addProxyInput.trim();
|
|
7772
|
-
|
|
7892
|
+
await startPoolBeginRequest({
|
|
7893
|
+
...reauthAccountId ? { accountId: reauthAccountId } : {},
|
|
7773
7894
|
...alias ? { alias } : {},
|
|
7774
7895
|
...proxyUrl ? { proxyUrl } : {}
|
|
7775
|
-
});
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7896
|
+
}, "pool:beginAdd", beginDeps);
|
|
7897
|
+
};
|
|
7898
|
+
const handleBeginReauth = async (acc) => {
|
|
7899
|
+
setAddingAccount(true);
|
|
7900
|
+
setImportMode(false);
|
|
7901
|
+
setReauthAccountId(acc.id);
|
|
7902
|
+
setAliasInput(acc.alias);
|
|
7903
|
+
setAddProxyInput(acc.proxyUrl ?? "");
|
|
7904
|
+
setAuthCodeInput("");
|
|
7905
|
+
await startPoolBeginRequest({
|
|
7906
|
+
accountId: acc.id,
|
|
7907
|
+
...acc.proxyUrl ? { proxyUrl: acc.proxyUrl } : {}
|
|
7908
|
+
}, `reauth:${acc.id}`, beginDeps);
|
|
7782
7909
|
};
|
|
7783
7910
|
const handleCompleteAddAccount = async () => {
|
|
7784
7911
|
if (!authCodeInput.trim()) return;
|
|
@@ -7823,6 +7950,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7823
7950
|
setAddingAccount,
|
|
7824
7951
|
importMode,
|
|
7825
7952
|
setImportMode,
|
|
7953
|
+
reauthAccountId,
|
|
7826
7954
|
aliasInput,
|
|
7827
7955
|
setAliasInput,
|
|
7828
7956
|
addProxyInput,
|
|
@@ -7833,6 +7961,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7833
7961
|
setTokenInput,
|
|
7834
7962
|
safeMessage,
|
|
7835
7963
|
handleBeginAddAccount,
|
|
7964
|
+
handleBeginReauth,
|
|
7836
7965
|
handleCompleteAddAccount,
|
|
7837
7966
|
handleCancelAddAccount,
|
|
7838
7967
|
handleImportToken,
|
|
@@ -7973,7 +8102,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7973
8102
|
style: merged
|
|
7974
8103
|
};
|
|
7975
8104
|
if (className !== void 0) attrs.className = className;
|
|
7976
|
-
return h("button", attrs, children);
|
|
8105
|
+
return Array.isArray(children) ? h("button", attrs, ...children) : h("button", attrs, children);
|
|
7977
8106
|
}
|
|
7978
8107
|
//#endregion
|
|
7979
8108
|
//#region src/client/ui/Row.ts
|
|
@@ -7988,7 +8117,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7988
8117
|
//#endregion
|
|
7989
8118
|
//#region src/client/ui/SegGroup.ts
|
|
7990
8119
|
function segGroup(children) {
|
|
7991
|
-
return h("div", { style: S.segGroup }, children);
|
|
8120
|
+
return h("div", { style: S.segGroup }, ...children);
|
|
7992
8121
|
}
|
|
7993
8122
|
//#endregion
|
|
7994
8123
|
//#region src/client/ui/Select.ts
|
|
@@ -8066,6 +8195,64 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8066
8195
|
}, uiIcon("x", 12)));
|
|
8067
8196
|
}
|
|
8068
8197
|
//#endregion
|
|
8198
|
+
//#region src/common/quota-pacing.ts
|
|
8199
|
+
/**
|
|
8200
|
+
* Compare remaining quota fraction against remaining reset window fraction.
|
|
8201
|
+
*
|
|
8202
|
+
* For example, 80% remaining with 1h left in a 5h window (20% time left) has
|
|
8203
|
+
* `surplus = +0.60` ('surplus' — use freely before rollover), whereas 25%
|
|
8204
|
+
* remaining with 6d left in a 7d window (85.7% time left) has `surplus = -0.61`
|
|
8205
|
+
* ('burning_fast' — will exhaust early at current pace).
|
|
8206
|
+
*/
|
|
8207
|
+
function computeQuotaPacing(remainingFraction, resetTimeIso, windowMs, now = Date.now()) {
|
|
8208
|
+
if (typeof remainingFraction !== "number" || !Number.isFinite(remainingFraction) || windowMs <= 0) return {
|
|
8209
|
+
status: "unknown",
|
|
8210
|
+
timeRemainingFraction: 1,
|
|
8211
|
+
elapsedFraction: 0,
|
|
8212
|
+
surplus: 0,
|
|
8213
|
+
burnMultiplier: 1
|
|
8214
|
+
};
|
|
8215
|
+
const clampedQuota = Math.max(0, Math.min(1, remainingFraction));
|
|
8216
|
+
if (!resetTimeIso) return {
|
|
8217
|
+
status: clampedQuota >= .999 ? "unactivated" : "unknown",
|
|
8218
|
+
timeRemainingFraction: 1,
|
|
8219
|
+
elapsedFraction: 0,
|
|
8220
|
+
surplus: 0,
|
|
8221
|
+
burnMultiplier: 1
|
|
8222
|
+
};
|
|
8223
|
+
const resetMs = Date.parse(resetTimeIso);
|
|
8224
|
+
if (Number.isNaN(resetMs)) return {
|
|
8225
|
+
status: "unknown",
|
|
8226
|
+
timeRemainingFraction: 1,
|
|
8227
|
+
elapsedFraction: 0,
|
|
8228
|
+
surplus: 0,
|
|
8229
|
+
burnMultiplier: 1
|
|
8230
|
+
};
|
|
8231
|
+
const diffMs = resetMs - now;
|
|
8232
|
+
if (diffMs <= 0) return {
|
|
8233
|
+
status: "reset",
|
|
8234
|
+
timeRemainingFraction: 0,
|
|
8235
|
+
elapsedFraction: 1,
|
|
8236
|
+
surplus: clampedQuota,
|
|
8237
|
+
burnMultiplier: 0
|
|
8238
|
+
};
|
|
8239
|
+
const timeRemainingFraction = Math.max(0, Math.min(1, diffMs / windowMs));
|
|
8240
|
+
const elapsedFraction = 1 - timeRemainingFraction;
|
|
8241
|
+
const surplus = clampedQuota - timeRemainingFraction;
|
|
8242
|
+
const usedFraction = Math.max(0, 1 - clampedQuota);
|
|
8243
|
+
const burnMultiplier = elapsedFraction >= .02 ? usedFraction / elapsedFraction : 1;
|
|
8244
|
+
let status = "on_track";
|
|
8245
|
+
if (elapsedFraction >= .04 && surplus <= -.15) status = "burning_fast";
|
|
8246
|
+
else if (surplus >= .15) status = "surplus";
|
|
8247
|
+
return {
|
|
8248
|
+
status,
|
|
8249
|
+
timeRemainingFraction,
|
|
8250
|
+
elapsedFraction,
|
|
8251
|
+
surplus,
|
|
8252
|
+
burnMultiplier
|
|
8253
|
+
};
|
|
8254
|
+
}
|
|
8255
|
+
//#endregion
|
|
8069
8256
|
//#region src/client/sections/QuotaPanel.ts
|
|
8070
8257
|
/**
|
|
8071
8258
|
* Format reset timestamp into readable date/time + relative countdown.
|
|
@@ -8127,9 +8314,23 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8127
8314
|
border: "var(--agy-quota-high-border)"
|
|
8128
8315
|
};
|
|
8129
8316
|
}
|
|
8130
|
-
const
|
|
8317
|
+
const FIVE_H_MS = 18e6;
|
|
8318
|
+
const SEVEN_D_MS = 6048e5;
|
|
8319
|
+
function describePacing(t, windowDurationMs, resetStr, rawFraction, rawReset) {
|
|
8320
|
+
const pacing = typeof rawFraction === "number" ? computeQuotaPacing(rawFraction, rawReset, windowDurationMs) : null;
|
|
8321
|
+
const paceLabel = pacing === null ? "" : pacing.status === "surplus" ? t("quota.paceSurplus", { pct: Math.round(Math.abs(pacing.surplus) * 100) }) : pacing.status === "burning_fast" ? t("quota.paceFast", { pct: Math.round(Math.abs(pacing.surplus) * 100) }) : pacing.status === "on_track" ? t("quota.paceOnTrack") : pacing.status === "unactivated" ? t("quota.unactivated") : "";
|
|
8322
|
+
const tooltipText = typeof rawFraction === "number" ? `${(rawFraction * 100).toFixed(1)}%${paceLabel ? ` · ${paceLabel}` : ""}${rawReset ? ` · reset: ${rawReset}` : ""}` : resetStr ? `↻ ${resetStr}` : void 0;
|
|
8323
|
+
const showTimeMarker = pacing !== null && (pacing.status === "surplus" || pacing.status === "on_track" || pacing.status === "burning_fast");
|
|
8324
|
+
return {
|
|
8325
|
+
pacing,
|
|
8326
|
+
tooltipText,
|
|
8327
|
+
showTimeMarker,
|
|
8328
|
+
markerLeftPct: showTimeMarker ? Math.max(2, Math.min(98, Math.round(pacing.timeRemainingFraction * 100))) : 0
|
|
8329
|
+
};
|
|
8330
|
+
}
|
|
8331
|
+
const renderLine = (t, windowName, percent, c, resetStr, windowDurationMs, rawFraction, rawReset, isRefreshing = false) => {
|
|
8131
8332
|
const isShimmer = percent < 0 || isRefreshing;
|
|
8132
|
-
const
|
|
8333
|
+
const { pacing, tooltipText, showTimeMarker, markerLeftPct } = describePacing(t, windowDurationMs, resetStr, rawFraction, rawReset);
|
|
8133
8334
|
return h("div", {
|
|
8134
8335
|
className: "agy-quota-line",
|
|
8135
8336
|
style: {
|
|
@@ -8147,7 +8348,11 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8147
8348
|
whiteSpace: "nowrap"
|
|
8148
8349
|
} }, windowName), h("div", {
|
|
8149
8350
|
className: isShimmer ? "agy-shimmer-track" : "",
|
|
8150
|
-
style:
|
|
8351
|
+
style: {
|
|
8352
|
+
...S.progressBarBg,
|
|
8353
|
+
position: "relative"
|
|
8354
|
+
},
|
|
8355
|
+
title: tooltipText
|
|
8151
8356
|
}, h("div", {
|
|
8152
8357
|
className: "agy-progress-fill",
|
|
8153
8358
|
style: {
|
|
@@ -8156,7 +8361,19 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8156
8361
|
background: c.bar,
|
|
8157
8362
|
borderRadius: "3px"
|
|
8158
8363
|
}
|
|
8159
|
-
})
|
|
8364
|
+
}), showTimeMarker ? h("span", {
|
|
8365
|
+
title: t("quota.timeMarkerTitle"),
|
|
8366
|
+
style: {
|
|
8367
|
+
position: "absolute",
|
|
8368
|
+
left: `${markerLeftPct}%`,
|
|
8369
|
+
top: "-1px",
|
|
8370
|
+
bottom: "-1px",
|
|
8371
|
+
width: "1.5px",
|
|
8372
|
+
background: "var(--agy-text-primary)",
|
|
8373
|
+
opacity: .55,
|
|
8374
|
+
pointerEvents: "none"
|
|
8375
|
+
}
|
|
8376
|
+
}) : null), h("span", {
|
|
8160
8377
|
title: tooltipText,
|
|
8161
8378
|
style: {
|
|
8162
8379
|
padding: "1px 5px",
|
|
@@ -8185,7 +8402,12 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8185
8402
|
fontSize: "10.5px",
|
|
8186
8403
|
fontWeight: 500,
|
|
8187
8404
|
whiteSpace: "nowrap"
|
|
8188
|
-
} }, `↻ ${resetStr}`) :
|
|
8405
|
+
} }, `↻ ${resetStr}`) : pacing?.status === "unactivated" ? h("span", { style: {
|
|
8406
|
+
color: "var(--agy-text-tertiary)",
|
|
8407
|
+
fontSize: "10px",
|
|
8408
|
+
fontWeight: 500,
|
|
8409
|
+
whiteSpace: "nowrap"
|
|
8410
|
+
} }, t("quota.unactivated")) : null));
|
|
8189
8411
|
};
|
|
8190
8412
|
/**
|
|
8191
8413
|
* One family's quota block: brand mark + 5h/weekly bars with reset countdowns
|
|
@@ -8223,7 +8445,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8223
8445
|
fontSize: "12px",
|
|
8224
8446
|
marginBottom: "3px",
|
|
8225
8447
|
color: "var(--agy-text-primary)"
|
|
8226
|
-
} }, brandIcon(FAMILY_BRAND[familyKey], 13), h("span", null, label)), familyKey !== "argon" || has5h ? renderLine(t("quota.fiveHour"), pct5h, c5h, note5h, info?.remainingFraction, info?.resetTime, isRefreshing) : null, renderLine(t("quota.weekly"), pctWeekly, cWeekly, noteWeekly, info?.weeklyFraction, info?.weeklyResetTime, isRefreshing));
|
|
8448
|
+
} }, brandIcon(FAMILY_BRAND[familyKey], 13), h("span", null, label)), familyKey !== "argon" || has5h ? renderLine(t, t("quota.fiveHour"), pct5h, c5h, note5h, FIVE_H_MS, info?.remainingFraction, info?.resetTime, isRefreshing) : null, renderLine(t, t("quota.weekly"), pctWeekly, cWeekly, noteWeekly, SEVEN_D_MS, info?.weeklyFraction, info?.weeklyResetTime, isRefreshing));
|
|
8227
8449
|
}
|
|
8228
8450
|
//#endregion
|
|
8229
8451
|
//#region src/client/sections/AccountsPanel.ts
|
|
@@ -8304,15 +8526,20 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8304
8526
|
margin: "4px 0 2px 0"
|
|
8305
8527
|
},
|
|
8306
8528
|
onClick: () => toggleExpand(acc.id)
|
|
8307
|
-
}, uiIcon(isExpanded ? "chevronUp" : "chevronDown", 10), h("span", null, isExpanded ? t("account.collapseOthers") : t("account.expandOthers"))), isExpanded ?
|
|
8308
|
-
renderQuotaBar("Claude", "anthropic", acc),
|
|
8309
|
-
renderQuotaBar("GPT-OSS", "openai", acc),
|
|
8310
|
-
allChildModels.length > 0 ? renderChildModels(t, allChildModels) : null
|
|
8311
|
-
] : null), hasCooldown ? renderCooldownBanner(t, acc, loadingAction, accountActionBusy, handlers) : null, isEditingProxy ? renderProxyEditor(t, acc, pool, proxyInputs, setProxyInputs, setEditingProxyId, loadingAction, accountActionBusy, handlers) : null);
|
|
8529
|
+
}, uiIcon(isExpanded ? "chevronUp" : "chevronDown", 10), h("span", null, isExpanded ? t("account.collapseOthers") : t("account.expandOthers"))), isExpanded ? h("div", { key: "expanded-details" }, renderQuotaBar("Claude", "anthropic", acc), renderQuotaBar("GPT-OSS", "openai", acc), allChildModels.length > 0 ? renderChildModels(t, allChildModels) : null) : null), hasCooldown ? renderCooldownBanner(t, acc, loadingAction, accountActionBusy, handlers) : null, isEditingProxy ? renderProxyEditor(t, acc, pool, proxyInputs, setProxyInputs, setEditingProxyId, loadingAction, accountActionBusy, handlers) : null);
|
|
8312
8530
|
});
|
|
8313
8531
|
}
|
|
8532
|
+
function extractActionUrl(text) {
|
|
8533
|
+
if (!text) return void 0;
|
|
8534
|
+
const m = text.match(/https:\/\/[^\s)\]>.,;"']+/);
|
|
8535
|
+
return m ? m[0] : void 0;
|
|
8536
|
+
}
|
|
8314
8537
|
function renderStatusBadges(t, acc, ctx) {
|
|
8315
8538
|
const { isAuthRequired, hasCooldown, isInUse, pool } = ctx;
|
|
8539
|
+
const isTos = isAuthRequired && /\bTOS_VIOLATION\b|violation of Terms of Service/i.test(acc.authError ?? "");
|
|
8540
|
+
const isValidation = isAuthRequired && !isTos && /\bVALIDATION_REQUIRED\b/i.test(acc.authError ?? "");
|
|
8541
|
+
const authLabel = isTos ? t("status.tosBanned") : isValidation ? t("status.validationRequired") : t("status.authRequired");
|
|
8542
|
+
const actionUrl = isAuthRequired ? extractActionUrl(acc.authError) : void 0;
|
|
8316
8543
|
return [
|
|
8317
8544
|
acc.email ? h("span", {
|
|
8318
8545
|
style: {
|
|
@@ -8357,18 +8584,27 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8357
8584
|
title: effectiveProxy
|
|
8358
8585
|
}, uiIcon("globe", 10, "var(--agy-badge-proxy-text)"), t("status.proxy")) : null;
|
|
8359
8586
|
})(),
|
|
8360
|
-
isAuthRequired ? h("span", {
|
|
8361
|
-
...
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8587
|
+
isAuthRequired ? h(actionUrl ? "a" : "span", {
|
|
8588
|
+
...actionUrl ? {
|
|
8589
|
+
href: actionUrl,
|
|
8590
|
+
target: "_blank",
|
|
8591
|
+
rel: "noopener noreferrer"
|
|
8592
|
+
} : {},
|
|
8593
|
+
title: acc.authError || authLabel,
|
|
8594
|
+
style: {
|
|
8595
|
+
...S.badgeTag,
|
|
8596
|
+
background: "var(--agy-badge-email-bg)",
|
|
8597
|
+
color: "#ef4444",
|
|
8598
|
+
borderColor: "#fca5a5",
|
|
8599
|
+
gap: "3px",
|
|
8600
|
+
fontSize: "10px",
|
|
8601
|
+
padding: "1px 5px",
|
|
8602
|
+
fontWeight: 700,
|
|
8603
|
+
whiteSpace: "nowrap",
|
|
8604
|
+
flexShrink: 0,
|
|
8605
|
+
textDecoration: actionUrl ? "underline" : "none"
|
|
8606
|
+
}
|
|
8607
|
+
}, uiIcon("alert", 10, "#ef4444"), authLabel) : null,
|
|
8372
8608
|
hasCooldown ? h("span", { style: {
|
|
8373
8609
|
...S.badgeTag,
|
|
8374
8610
|
background: "rgba(245, 158, 11, 0.15)",
|
|
@@ -8380,7 +8616,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8380
8616
|
fontWeight: 700,
|
|
8381
8617
|
whiteSpace: "nowrap",
|
|
8382
8618
|
flexShrink: 0
|
|
8383
|
-
} }, uiIcon("alert", 10, "#f59e0b"), "
|
|
8619
|
+
} }, uiIcon("alert", 10, "#f59e0b"), t("status.cooldown")) : null,
|
|
8384
8620
|
!acc.enabled ? h("span", {
|
|
8385
8621
|
style: {
|
|
8386
8622
|
...S.badgeTag,
|
|
@@ -8484,7 +8720,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8484
8720
|
minWidth: 0,
|
|
8485
8721
|
paddingLeft: "1px"
|
|
8486
8722
|
}
|
|
8487
|
-
}, badges);
|
|
8723
|
+
}, ...badges);
|
|
8488
8724
|
}
|
|
8489
8725
|
function renderCardHeader(t, acc, ctx) {
|
|
8490
8726
|
const { isEditingProxy, isInUse, displayAlias, accounts, loadingAction, accountActionBusy, handlers, setEditingProxyId } = ctx;
|
|
@@ -8540,7 +8776,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8540
8776
|
title: acc.enabled ? t("account.disableTitle") : t("account.enableTitle"),
|
|
8541
8777
|
disabled: accountActionBusy(acc, "enable"),
|
|
8542
8778
|
onClick: () => void handlers.toggleAccountEnabled(acc)
|
|
8543
|
-
}, loadingAction === `enable:${acc.id}` ? [Spinner(), acc.enabled ? t("account.disable") : t("account.enable")] : [uiIcon("power", 10, acc.enabled ? "var(--agy-text-secondary)" : "#ffffff"), ` ${acc.enabled ? t("account.disable") : t("account.enable")}`]), h(Button, {
|
|
8779
|
+
}, ...loadingAction === `enable:${acc.id}` ? [Spinner(), acc.enabled ? t("account.disable") : t("account.enable")] : [uiIcon("power", 10, acc.enabled ? "var(--agy-text-secondary)" : "#ffffff"), ` ${acc.enabled ? t("account.disable") : t("account.enable")}`]), h(Button, {
|
|
8544
8780
|
variant: "default",
|
|
8545
8781
|
size: "sm",
|
|
8546
8782
|
className: "agy-btn",
|
|
@@ -8554,7 +8790,20 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8554
8790
|
title: t("account.syncTitle"),
|
|
8555
8791
|
disabled: accountActionBusy(acc, "refresh"),
|
|
8556
8792
|
onClick: () => void handlers.refreshQuota(acc.id)
|
|
8557
|
-
}, loadingAction === `refresh:${acc.id}` ? [Spinner(), t("account.syncing")] : [uiIcon("refresh", 10), ` ${t("account.sync")}`]), acc.
|
|
8793
|
+
}, ...loadingAction === `refresh:${acc.id}` ? [Spinner(), t("account.syncing")] : [uiIcon("refresh", 10), ` ${t("account.sync")}`]), acc.authRequired && handlers.beginReauth ? h(Button, {
|
|
8794
|
+
variant: "primary",
|
|
8795
|
+
size: "sm",
|
|
8796
|
+
className: "agy-btn",
|
|
8797
|
+
style: {
|
|
8798
|
+
gap: "3px",
|
|
8799
|
+
fontSize: "11px",
|
|
8800
|
+
padding: "1px 6px",
|
|
8801
|
+
height: "22px"
|
|
8802
|
+
},
|
|
8803
|
+
title: t("account.reauthTitle"),
|
|
8804
|
+
disabled: accountActionBusy(acc, "reauth"),
|
|
8805
|
+
onClick: () => void handlers.beginReauth(acc)
|
|
8806
|
+
}, ...loadingAction === `reauth:${acc.id}` ? [Spinner(), t("account.reauthing")] : [uiIcon("externalLink", 10, "#ffffff"), ` ${t("account.reauth")}`]) : null, acc.enabled && !acc.authRequired ? h(Button, {
|
|
8558
8807
|
variant: "default",
|
|
8559
8808
|
size: "sm",
|
|
8560
8809
|
className: "agy-btn",
|
|
@@ -8568,7 +8817,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8568
8817
|
title: t("account.warmupTitle"),
|
|
8569
8818
|
disabled: accountActionBusy(acc, "warmup"),
|
|
8570
8819
|
onClick: () => void handlers.warmupAccount(acc.id)
|
|
8571
|
-
}, loadingAction === `warmup:${acc.id}` ? [Spinner(), t("account.warmingUp")] : [uiIcon("flame", 10, "#f97316"), ` ${t("account.warmup")}`]) : null, acc.enabled && !isInUse ? h(Button, {
|
|
8820
|
+
}, ...loadingAction === `warmup:${acc.id}` ? [Spinner(), t("account.warmingUp")] : [uiIcon("flame", 10, "#f97316"), ` ${t("account.warmup")}`]) : null, acc.enabled && !acc.authRequired && !isInUse ? h(Button, {
|
|
8572
8821
|
variant: "default",
|
|
8573
8822
|
size: "sm",
|
|
8574
8823
|
className: "agy-btn",
|
|
@@ -8581,7 +8830,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8581
8830
|
title: t("account.setActive"),
|
|
8582
8831
|
disabled: accountActionBusy(acc, "active"),
|
|
8583
8832
|
onClick: () => void handlers.setActiveAccount(acc.id)
|
|
8584
|
-
}, loadingAction === `active:${acc.id}` ? [Spinner(), t("account.settingActive")] : [uiIcon("zap", 10), ` ${t("account.setActive")}`]) : null, h(Button, {
|
|
8833
|
+
}, ...loadingAction === `active:${acc.id}` ? [Spinner(), t("account.settingActive")] : [uiIcon("zap", 10), ` ${t("account.setActive")}`]) : null, h(Button, {
|
|
8585
8834
|
variant: isEditingProxy ? "primary" : "default",
|
|
8586
8835
|
size: "sm",
|
|
8587
8836
|
className: "agy-btn",
|
|
@@ -8593,7 +8842,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8593
8842
|
},
|
|
8594
8843
|
disabled: accountActionBusy(acc, "proxy"),
|
|
8595
8844
|
onClick: () => setEditingProxyId(isEditingProxy ? null : acc.id)
|
|
8596
|
-
},
|
|
8845
|
+
}, uiIcon("globe", 10), ` ${t("proxy.button")}`), showRemove ? h(Button, {
|
|
8597
8846
|
variant: "danger",
|
|
8598
8847
|
size: "sm",
|
|
8599
8848
|
className: "agy-btn",
|
|
@@ -8677,7 +8926,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8677
8926
|
},
|
|
8678
8927
|
disabled: accountActionBusy(acc, "clearCooldown"),
|
|
8679
8928
|
onClick: () => void handlers.clearCooldown(acc.id)
|
|
8680
|
-
}, loadingAction === `clearCooldown:${acc.id}` ? [Spinner(), ""] : [uiIcon("zap", 11, "var(--agy-warn-btn-text)"), ` ${t("account.clearCooldown")}`]));
|
|
8929
|
+
}, ...loadingAction === `clearCooldown:${acc.id}` ? [Spinner(), ""] : [uiIcon("zap", 11, "var(--agy-warn-btn-text)"), ` ${t("account.clearCooldown")}`]));
|
|
8681
8930
|
}
|
|
8682
8931
|
function renderProxyEditor(t, acc, pool, proxyInputs, setProxyInputs, setEditingProxyId, loadingAction, accountActionBusy, handlers) {
|
|
8683
8932
|
return h("div", {
|
|
@@ -8706,7 +8955,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8706
8955
|
className: "agy-btn",
|
|
8707
8956
|
disabled: accountActionBusy(acc, "proxy"),
|
|
8708
8957
|
onClick: () => void handlers.saveProxy(acc.id)
|
|
8709
|
-
}, loadingAction === `proxy:${acc.id}` ? [Spinner(), t("proxy.save")] : t("proxy.save")), h(Button, {
|
|
8958
|
+
}, ...loadingAction === `proxy:${acc.id}` ? [Spinner(), t("proxy.save")] : [t("proxy.save")]), h(Button, {
|
|
8710
8959
|
variant: "default",
|
|
8711
8960
|
className: "agy-btn",
|
|
8712
8961
|
onClick: () => setEditingProxyId(null)
|
|
@@ -8897,7 +9146,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8897
9146
|
setOptimisticActiveId
|
|
8898
9147
|
});
|
|
8899
9148
|
const copyImageCommand = () => {
|
|
8900
|
-
const clip = win.navigator?.clipboard;
|
|
9149
|
+
const clip = win$1.navigator?.clipboard;
|
|
8901
9150
|
if (clip?.writeText === void 0) {
|
|
8902
9151
|
showToast(t("config.imageCopyFailed"), "warn");
|
|
8903
9152
|
return;
|
|
@@ -8923,7 +9172,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8923
9172
|
display: "flex",
|
|
8924
9173
|
alignItems: "center",
|
|
8925
9174
|
justifyContent: "center"
|
|
8926
|
-
} }, h("span", { style: S.muted },
|
|
9175
|
+
} }, h("span", { style: S.muted }, Spinner(), t("status.loading")));
|
|
8927
9176
|
return h("div", {
|
|
8928
9177
|
className: "agy-console",
|
|
8929
9178
|
style: S.container
|
|
@@ -8961,7 +9210,10 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8961
9210
|
expandedModels,
|
|
8962
9211
|
toggleExpand,
|
|
8963
9212
|
optimisticActiveId,
|
|
8964
|
-
handlers:
|
|
9213
|
+
handlers: {
|
|
9214
|
+
...accountActions,
|
|
9215
|
+
beginReauth: auth.handleBeginReauth
|
|
9216
|
+
}
|
|
8965
9217
|
}), renderRuntimeConfig(t, status, pool, catalogModels, hiddenModelSet, loadingAction, {
|
|
8966
9218
|
setCfg: config.setCfg,
|
|
8967
9219
|
setMode: config.setMode,
|
|
@@ -8997,7 +9249,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8997
9249
|
fontSize: "11.5px"
|
|
8998
9250
|
},
|
|
8999
9251
|
onClick: actions.onAdd
|
|
9000
|
-
},
|
|
9252
|
+
}, uiIcon("plus", 12, "#ffffff"), ` ${t("account.add")}`) : null, h(Button, {
|
|
9001
9253
|
variant: "default",
|
|
9002
9254
|
size: "sm",
|
|
9003
9255
|
className: "agy-btn",
|
|
@@ -9009,7 +9261,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9009
9261
|
},
|
|
9010
9262
|
disabled: isBusy,
|
|
9011
9263
|
onClick: actions.onWarmupAll
|
|
9012
|
-
}, loadingAction === "warmup:all" ? [Spinner(), t("header.warmingUp")] : [uiIcon("flame", 12, "#f97316"), ` ${t("header.warmup")}`]), h(Button, {
|
|
9264
|
+
}, ...loadingAction === "warmup:all" ? [Spinner(), t("header.warmingUp")] : [uiIcon("flame", 12, "#f97316"), ` ${t("header.warmup")}`]), h(Button, {
|
|
9013
9265
|
variant: "default",
|
|
9014
9266
|
size: "sm",
|
|
9015
9267
|
className: "agy-btn",
|
|
@@ -9021,7 +9273,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9021
9273
|
},
|
|
9022
9274
|
disabled: isBusy,
|
|
9023
9275
|
onClick: actions.onRefreshAll
|
|
9024
|
-
}, loadingAction === "refresh:all" ? [Spinner(), t("header.refreshing")] : [uiIcon("refresh", 12, "var(--agy-text-btn)"), ` ${t("header.refreshQuota")}`])));
|
|
9276
|
+
}, ...loadingAction === "refresh:all" ? [Spinner(), t("header.refreshing")] : [uiIcon("refresh", 12, "var(--agy-text-btn)"), ` ${t("header.refreshQuota")}`])));
|
|
9025
9277
|
}
|
|
9026
9278
|
function renderTokenImportForm(t, auth, pool, isBusy, loadingAction) {
|
|
9027
9279
|
return h("div", null, h("div", { style: {
|
|
@@ -9062,7 +9314,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9062
9314
|
style: { gap: "4px" },
|
|
9063
9315
|
disabled: isBusy || !auth.tokenInput.trim(),
|
|
9064
9316
|
onClick: () => void auth.handleImportToken()
|
|
9065
|
-
}, loadingAction === "pool:importToken" ? [Spinner(), t("auth.importingToken")] : [uiIcon("arrowDown", 12, "#ffffff"), ` ${t("auth.importToken")}`]), h(Button, {
|
|
9317
|
+
}, ...loadingAction === "pool:importToken" ? [Spinner(), t("auth.importingToken")] : [uiIcon("arrowDown", 12, "#ffffff"), ` ${t("auth.importToken")}`]), h(Button, {
|
|
9066
9318
|
variant: "default",
|
|
9067
9319
|
className: "agy-btn",
|
|
9068
9320
|
onClick: () => void auth.handleCancelAddAccount()
|
|
@@ -9096,7 +9348,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9096
9348
|
style: { gap: "4px" },
|
|
9097
9349
|
disabled: isBusy,
|
|
9098
9350
|
onClick: () => void auth.handleBeginAddAccount()
|
|
9099
|
-
}, loadingAction === "pool:beginAdd" ? [Spinner(), t("auth.openingBrowser")] : [uiIcon("externalLink", 12, "#ffffff"), ` ${t("auth.openBrowser")}`]), h(Button, {
|
|
9351
|
+
}, ...loadingAction === "pool:beginAdd" ? [Spinner(), t("auth.openingBrowser")] : [uiIcon("externalLink", 12, "#ffffff"), ` ${t("auth.openBrowser")}`]), h(Button, {
|
|
9100
9352
|
variant: "default",
|
|
9101
9353
|
className: "agy-btn",
|
|
9102
9354
|
onClick: () => void auth.handleCancelAddAccount()
|
|
@@ -9151,7 +9403,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9151
9403
|
style: { gap: "4px" },
|
|
9152
9404
|
disabled: isBusy || !auth.authCodeInput.trim(),
|
|
9153
9405
|
onClick: () => void auth.handleCompleteAddAccount()
|
|
9154
|
-
}, loadingAction === "pool:completeAdd" ? [Spinner(), t("auth.activating")] : [uiIcon("check", 12, "#ffffff"), ` ${t("auth.activate")}`]), h(Button, {
|
|
9406
|
+
}, ...loadingAction === "pool:completeAdd" ? [Spinner(), t("auth.activating")] : [uiIcon("check", 12, "#ffffff"), ` ${t("auth.activate")}`]), h(Button, {
|
|
9155
9407
|
variant: "default",
|
|
9156
9408
|
className: "agy-btn",
|
|
9157
9409
|
onClick: () => void auth.handleCancelAddAccount()
|
|
@@ -9465,10 +9717,13 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9465
9717
|
const color = status === null ? "#64748b" : status.dormantReason ? "#f59e0b" : allInCooldown ? "#f59e0b" : activeAuthRequired ? "#ef4444" : activeHasCooldown ? "#f59e0b" : isAuthed ? "#10b981" : "#f59e0b";
|
|
9466
9718
|
const legacyDefault = activeAcc && activeAcc.defaultAlias === void 0 && activeAcc.systemHome && activeAcc.alias === "主账号 (系统登录)";
|
|
9467
9719
|
const displayAlias = activeAcc ? activeAcc.defaultAlias || legacyDefault ? activeAcc.systemHome ? t("account.defaultAlias") : t("account.aliasDefault", { number: accounts.indexOf(activeAcc) + 1 }) : activeAcc.alias : "";
|
|
9720
|
+
const gFrac = activeAcc?.quotas?.google?.remainingFraction;
|
|
9721
|
+
const activePct = typeof gFrac === "number" && Number.isFinite(gFrac) ? Math.max(0, Math.min(100, Math.round(gFrac * 100))) : null;
|
|
9468
9722
|
const activeEligible = activeAcc !== void 0 && activeAcc.enabled && !activeAcc.authRequired;
|
|
9469
|
-
const activeDetail = activeAcc !== void 0 && activeEligible ? ` · ${t("status.inUse")}: ${displayAlias}${activeAcc.email ? ` (${activeAcc.email})` : ""}` : "";
|
|
9723
|
+
const activeDetail = activeAcc !== void 0 && activeEligible ? ` · ${t("status.inUse")}: ${displayAlias}${activeAcc.email ? ` (${activeAcc.email})` : ""}${activePct !== null ? ` · ${activePct}%` : ""}` : "";
|
|
9470
9724
|
const badgeTitle = status === null ? t("header.badgeLoading") : `${t("header.badgeTitle", { count: accounts.length })}${activeDetail}`;
|
|
9471
9725
|
const buttonLabel = status === null ? "AGY" : displayAlias ? `AGY · ${displayAlias}` : `AGY (${accounts.length})`;
|
|
9726
|
+
const pctColor = activePct === null ? void 0 : activePct <= 20 ? "#ef4444" : activePct <= 50 ? "#f59e0b" : "#10b981";
|
|
9472
9727
|
const badge = h(Button, {
|
|
9473
9728
|
variant: "pill",
|
|
9474
9729
|
title: badgeTitle,
|
|
@@ -9484,7 +9739,14 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9484
9739
|
borderRadius: "50%",
|
|
9485
9740
|
background: color,
|
|
9486
9741
|
flexShrink: 0
|
|
9487
|
-
} }), h("span", { className: "agy-session-status-label" }, buttonLabel)
|
|
9742
|
+
} }), h("span", { className: "agy-session-status-label" }, buttonLabel), activePct !== null && activeEligible ? h("span", {
|
|
9743
|
+
className: "agy-session-status-label",
|
|
9744
|
+
style: {
|
|
9745
|
+
color: pctColor,
|
|
9746
|
+
fontWeight: 700,
|
|
9747
|
+
fontSize: "10.5px"
|
|
9748
|
+
}
|
|
9749
|
+
}, `${activePct}%`) : null);
|
|
9488
9750
|
const modalPortal = isPrimaryHost && isModalOpen ? portalToBody(h(ConsoleDialog, {
|
|
9489
9751
|
t,
|
|
9490
9752
|
SettingsSection
|