dsh-agy-link 0.6.38 → 0.6.40
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 +28 -0
- package/dist/cli-image.mjs +140 -85
- package/dist/client.js +79 -3
- package/dist/index.js +349 -35
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.40 (2026-11-19)
|
|
4
|
+
|
|
5
|
+
### English
|
|
6
|
+
|
|
7
|
+
- **Improve(diagnostics): `AGY_NOT_INSTALLED` now says where agy was searched and how to point at it (merges PR #133).** The error used to read only "install it via …", which says "not installed" — but the more common case is the CLI being installed while a GUI-launched host inherits a different `PATH`. `resolveAgyBin()`'s probe list was computed and then discarded; it is now preserved. `agyBinCandidates()` splits the collection out, `agyBinDiagnostics()` adds the configured `agyBin` and the per-platform install hint, and `agyNotInstalledMessage()` reports the probed locations, both documented overrides (`agyBin` config / `DSH_AGY_BIN`) and a `/agy doctor` pointer. The header badge uses the same text, and `/agy doctor` lists every probed path under `agy lookup`. `resolveAgyBin()` keeps its signature and behaviour; 9 new tests. Thanks to @angel12538.
|
|
8
|
+
- **Test:** the PATH-probe case now injects its own `PATH` instead of assuming the host has a `nodejs` directory, so it passes on any machine.
|
|
9
|
+
|
|
10
|
+
### 中文
|
|
11
|
+
|
|
12
|
+
- **改进(诊断):`AGY_NOT_INSTALLED` 现在会说明搜索过哪些位置、以及如何指向二进制(合并 PR #133)。** 此前错误文案只有「install it via …」,读起来就是「没装」——但更常见的情况是 CLI 已安装,只是 GUI 启动的宿主继承了不同的 `PATH`。`resolveAgyBin()` 原本算完探测列表就丢弃,现在保留下来:`agyBinCandidates()` 拆出候选收集,`agyBinDiagnostics()` 补充已配置的 `agyBin` 与各平台安装提示,`agyNotInstalledMessage()` 输出探测位置、两种已文档化的覆盖方式(`agyBin` 配置 / `DSH_AGY_BIN`)以及 `/agy doctor` 指路。头部徽标复用同一文案,`/agy doctor` 在 `agy lookup` 段列出每个探测路径。`resolveAgyBin()` 签名与行为不变;新增 9 条测试。感谢 @angel12538。
|
|
13
|
+
- **测试**:PATH 探测用例改为注入自定义 `PATH`,不再假设宿主存在 `nodejs` 目录,因此任何机器都能通过。
|
|
14
|
+
|
|
15
|
+
## 0.6.39 (2026-11-19)
|
|
16
|
+
|
|
17
|
+
### English
|
|
18
|
+
|
|
19
|
+
- **Fix(quota): a manual pool refresh no longer freezes one account for days or takes a minute (reported live: "the first one refreshed, the second is just stuck, and every refresh is far too slow").** Two independent causes, both fixed:
|
|
20
|
+
- **Stuck row.** An account whose `retrieveUserQuotaSummary` was refused (`403 You do not have a valid license of this product`, with `ECONNRESET` on the daily endpoint) produced no authoritative snapshot — and `buildFamilyQuotas` deliberately keeps the previous complete value, so the card kept rendering yesterday's percentages with **no error anywhere** (three `catch` layers swallowed it and the route had already answered `ok`). The pipeline now records `quotaUnavailable = { reason, since, retryAfter, detail }` on the account (`no_license` / `auth` / `unreachable` / `partial`), the console renders "Quota refresh failed · <reason> · figures last updated <time>", and an authoritative snapshot clears the marker. A `no_license` account also leaves the hourly background sweep for `QUOTA_LICENSE_RETRY_MS` (6h) and skips the doomed summary call entirely, while an explicit click still probes (so a renewed licence recovers immediately).
|
|
21
|
+
- **Slow.** `daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary` resets the connection for every account on this machine (measured 5.3-8.4s) while the sandbox endpoint answers, and every quota call walked the fixed endpoint list from that dead end first — on every account, every refresh, including the background sweep. A per-operation endpoint health memory (`QUOTA_ENDPOINT_DOWN_MS` 10min) now tries recently-failed endpoints last (never skipping them; a total outage still probes), and a user-initiated sweep may run 2 same-egress accounts in parallel with the existing 400-850ms start jitter (`sweep.ts`); the unattended sweep stays strictly serial. One five-account pool that measured ~55s now finishes its per-account work in roughly the time of two cascades.
|
|
22
|
+
- **Fix(ui): refresh progress is real, and a duplicate click says so.** `/status` now exposes `quotaRefreshing` (the host's in-flight account ids) and account cards render "syncing" from it instead of from the click that cleared the moment the route answered; `/pool/refresh-quota` returns `alreadyRunning: true` when the same key is still in flight, so the console says "a refresh is already running" instead of a false "started".
|
|
23
|
+
|
|
24
|
+
### 中文
|
|
25
|
+
|
|
26
|
+
- **修复(额度):手动刷新账号池不再让某个号「永远卡住」,也不再慢到一分钟(现场反馈:第一个刷出来了、第二个一直卡着、每个都慢得离谱)。** 两个独立根因,都已修复:
|
|
27
|
+
- **卡住**。某账号的 `retrieveUserQuotaSummary` 被拒(`403 You do not have a valid license of this product`,daily 端点还 `ECONNRESET`),拿不到权威快照;而 `buildFamilyQuotas` 的设计是**保留上一份完整数据**(防止部分回退数据覆盖好数据),于是卡片一直渲染前一天的百分比,**任何地方都没有报错**(三层 `catch` 全吞、路由还提前回了 `ok`)。现在管线把 `quotaUnavailable = { reason, since, retryAfter, detail }` 写到账号上(`no_license` / `auth` / `unreachable` / `partial`),控制台渲染「配额刷新失败 · 原因 · 数据停留在 <时间>」,拿到权威快照即清除标记。`no_license` 账号同时退出每小时后台轮询 `QUOTA_LICENSE_RETRY_MS`(6 小时)并跳过注定失败的摘要请求;**用户手动点击仍然必探**(续费后可立即恢复)。
|
|
28
|
+
- **慢**。`daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary` 对本机每个账号都重置连接(实测 5.3~8.4 秒),而 sandbox 端点正常,但每次配额调用都从这条死端点起步——每个账号、每次刷新、包括后台轮询。新增按「操作|端点」的失败记忆(`QUOTA_ENDPOINT_DOWN_MS` 10 分钟),把刚失败的端点排到最后(**绝不跳过**,全部失败时仍按原序探测);用户手动全池刷新允许**同一出口内 2 个账号并发**并保留原有 `400~850ms` 起点抖动(`sweep.ts`),后台轮询仍严格串行。实测 5 号同出口的池子从约 55 秒降到约两个级联的时间。
|
|
29
|
+
- **修复(UI):刷新进度是真的,重复点击也有话讲。** `/status` 新增 `quotaRefreshing`(宿主在途的账号 id),账号卡据此渲染「同步中」,不再依赖「点击后立刻清空」的客户端状态;`/pool/refresh-quota` 在同 key 仍在途时返回 `alreadyRunning: true`,控制台提示「正在刷新中」而不是谎报「已开始刷新」。
|
|
30
|
+
|
|
3
31
|
## 0.6.38 (2026-11-19)
|
|
4
32
|
|
|
5
33
|
### English
|
package/dist/cli-image.mjs
CHANGED
|
@@ -1541,6 +1541,107 @@ function defaultPoolData() {
|
|
|
1541
1541
|
};
|
|
1542
1542
|
}
|
|
1543
1543
|
//#endregion
|
|
1544
|
+
//#region src/runtime/agy/bin.ts
|
|
1545
|
+
const IS_WIN$3 = process.platform === "win32";
|
|
1546
|
+
/** Executable candidates for one PATH entry, per-platform. Exported for tests. */
|
|
1547
|
+
function binCandidates(dir, platform = process.platform) {
|
|
1548
|
+
return (platform === "win32" ? [
|
|
1549
|
+
".exe",
|
|
1550
|
+
".cmd",
|
|
1551
|
+
".bat"
|
|
1552
|
+
] : [""]).map((e) => join(dir, "agy" + e));
|
|
1553
|
+
}
|
|
1554
|
+
/** True when the resolved bin is a Windows cmd shim (needs shell wrapping). */
|
|
1555
|
+
function isCmdShim(bin) {
|
|
1556
|
+
return /\.(cmd|bat)$/i.test(bin);
|
|
1557
|
+
}
|
|
1558
|
+
/** cmd.exe argument quoting (cross-spawn rules). Exported for tests. */
|
|
1559
|
+
function windowsQuote(arg) {
|
|
1560
|
+
if (/[ \t\n\v"]/.test(arg) === false) return arg;
|
|
1561
|
+
let escaped = arg.replace(/(\\+)\"/g, "$1$1\\\"").replace(/(\\+)$/, "$1$1");
|
|
1562
|
+
escaped = "\"" + escaped.replace(/"/g, "\\\"") + "\"";
|
|
1563
|
+
return escaped;
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Every location the plugin probes for the agy executable.
|
|
1567
|
+
*
|
|
1568
|
+
* Kept separate from `resolveAgyBin` so a failed lookup can report WHERE it
|
|
1569
|
+
* looked: a missing binary is otherwise indistinguishable from a broken PATH,
|
|
1570
|
+
* and the user is left guessing which install layout they should match.
|
|
1571
|
+
*/
|
|
1572
|
+
function agyBinCandidates(cfg) {
|
|
1573
|
+
const candidates = [];
|
|
1574
|
+
if (cfg.agyBin !== "") candidates.push(cfg.agyBin);
|
|
1575
|
+
const pathEnv = process.env.PATH ?? "";
|
|
1576
|
+
for (const dir of pathEnv.split(delimiter)) if (dir !== "") candidates.push(...binCandidates(dir));
|
|
1577
|
+
const home = homedir();
|
|
1578
|
+
if (IS_WIN$3) {
|
|
1579
|
+
const local = process.env.LOCALAPPDATA ?? "";
|
|
1580
|
+
const appData = process.env.APPDATA ?? "";
|
|
1581
|
+
if (local !== "") {
|
|
1582
|
+
candidates.push(join(local, "agy", "bin", "agy.exe"));
|
|
1583
|
+
candidates.push(join(local, "agy", "bin", "agy.cmd"));
|
|
1584
|
+
candidates.push(join(local, "agy", "bin", "agy.bat"));
|
|
1585
|
+
candidates.push(join(local, "agy", "agy.exe"));
|
|
1586
|
+
candidates.push(join(local, "Programs", "agy", "agy.exe"));
|
|
1587
|
+
candidates.push(join(local, "Programs", "agy", "bin", "agy.exe"));
|
|
1588
|
+
candidates.push(join(local, "Microsoft", "WinGet", "Links", "agy.exe"));
|
|
1589
|
+
candidates.push(join(local, "pnpm", "agy.cmd"));
|
|
1590
|
+
candidates.push(join(local, "pnpm", "agy.exe"));
|
|
1591
|
+
}
|
|
1592
|
+
if (appData !== "") {
|
|
1593
|
+
candidates.push(join(appData, "npm", "agy.cmd"));
|
|
1594
|
+
candidates.push(join(appData, "Roaming", "npm", "agy.cmd"));
|
|
1595
|
+
}
|
|
1596
|
+
candidates.push(join(home, ".local", "bin", "agy.exe"));
|
|
1597
|
+
candidates.push(join(home, ".local", "bin", "agy.cmd"));
|
|
1598
|
+
candidates.push(join(home, ".bun", "bin", "agy.exe"));
|
|
1599
|
+
candidates.push(join(home, ".cargo", "bin", "agy.exe"));
|
|
1600
|
+
candidates.push(join(home, "scoop", "shims", "agy.exe"));
|
|
1601
|
+
} else {
|
|
1602
|
+
candidates.push(join(home, ".local", "bin", "agy"));
|
|
1603
|
+
candidates.push("/usr/local/bin/agy");
|
|
1604
|
+
candidates.push("/opt/homebrew/bin/agy");
|
|
1605
|
+
candidates.push("/opt/homebrew/sbin/agy");
|
|
1606
|
+
candidates.push("/home/linuxbrew/.linuxbrew/bin/agy");
|
|
1607
|
+
candidates.push(join(home, ".bun", "bin", "agy"));
|
|
1608
|
+
candidates.push(join(home, ".cargo", "bin", "agy"));
|
|
1609
|
+
candidates.push(join(home, ".local", "share", "pnpm", "agy"));
|
|
1610
|
+
candidates.push(join(home, "Library", "pnpm", "agy"));
|
|
1611
|
+
candidates.push(join(home, ".yarn", "bin", "agy"));
|
|
1612
|
+
candidates.push(join(home, ".npm-global", "bin", "agy"));
|
|
1613
|
+
candidates.push(join(home, ".volta", "bin", "agy"));
|
|
1614
|
+
candidates.push(join(home, ".asdf", "shims", "agy"));
|
|
1615
|
+
candidates.push(join(home, ".nix-profile", "bin", "agy"));
|
|
1616
|
+
candidates.push("/run/current-system/sw/bin/agy");
|
|
1617
|
+
try {
|
|
1618
|
+
const nvmNodeDir = join(home, ".nvm", "versions", "node");
|
|
1619
|
+
if (existsSync(nvmNodeDir)) for (const v of readdirSync(nvmNodeDir)) candidates.push(join(nvmNodeDir, v, "bin", "agy"));
|
|
1620
|
+
} catch {}
|
|
1621
|
+
candidates.push(join(home, ".local", "share", "fnm", "current", "bin", "agy"));
|
|
1622
|
+
candidates.push(join(home, ".fnm", "current", "bin", "agy"));
|
|
1623
|
+
candidates.push(join(home, "Library", "Application Support", "fnm", "current", "bin", "agy"));
|
|
1624
|
+
}
|
|
1625
|
+
return candidates;
|
|
1626
|
+
}
|
|
1627
|
+
function agyBinDiagnostics(cfg) {
|
|
1628
|
+
return {
|
|
1629
|
+
probed: agyBinCandidates(cfg),
|
|
1630
|
+
configured: cfg.agyBin,
|
|
1631
|
+
installHint: IS_WIN$3 ? "the official installer defaults to " + join(process.env.LOCALAPPDATA ?? "%LOCALAPPDATA%", "agy", "bin", "agy.exe") : "the official installer defaults to " + join(homedir(), ".local", "bin", "agy")
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
function resolveAgyBin(cfg) {
|
|
1635
|
+
const hits = [];
|
|
1636
|
+
for (const c of agyBinCandidates(cfg)) try {
|
|
1637
|
+
accessSync(c, constants.F_OK);
|
|
1638
|
+
hits.push(c);
|
|
1639
|
+
} catch {
|
|
1640
|
+
continue;
|
|
1641
|
+
}
|
|
1642
|
+
return hits.find((h) => !isCmdShim(h)) ?? hits[0] ?? null;
|
|
1643
|
+
}
|
|
1644
|
+
//#endregion
|
|
1544
1645
|
//#region src/provider/call-context.ts
|
|
1545
1646
|
/**
|
|
1546
1647
|
* Effective agy permission mode for one turn.
|
|
@@ -1556,9 +1657,27 @@ function defaultPoolData() {
|
|
|
1556
1657
|
function effectivePermissionMode(configured, dshPlanMode, isAux) {
|
|
1557
1658
|
return dshPlanMode && !isAux ? "plan" : configured;
|
|
1558
1659
|
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Message for a missing agy executable.
|
|
1662
|
+
*
|
|
1663
|
+
* A bare "not found on PATH" is unactionable: the user cannot tell whether the
|
|
1664
|
+
* CLI is missing, installed outside the probed locations, or simply not on the
|
|
1665
|
+
* PATH the GUI host inherited. The message therefore names the locations that
|
|
1666
|
+
* were probed and both documented ways to point the plugin at a binary the
|
|
1667
|
+
* probes do not cover.
|
|
1668
|
+
*/
|
|
1669
|
+
function agyNotInstalledMessage(cfg) {
|
|
1670
|
+
const diag = agyBinDiagnostics(cfg);
|
|
1671
|
+
const lines = ["agy binary not found — install it via https://antigravity.google/docs/cli/install", "probed " + diag.probed.length + " location(s): " + diag.probed.join(", ")];
|
|
1672
|
+
if (diag.configured !== "") lines.push("configured agyBin (" + diag.configured + ") does not exist either");
|
|
1673
|
+
lines.push(diag.installHint);
|
|
1674
|
+
lines.push("if agy is installed elsewhere, set the plugin config agyBin to its absolute path, or the DSH_AGY_BIN environment variable");
|
|
1675
|
+
lines.push("run /agy doctor for a full report");
|
|
1676
|
+
return lines.join("\n");
|
|
1677
|
+
}
|
|
1559
1678
|
function resolveCallContext(input) {
|
|
1560
1679
|
const { options, cfg, bin } = input;
|
|
1561
|
-
if (!bin) throw new LlmError(
|
|
1680
|
+
if (!bin) throw new LlmError(agyNotInstalledMessage(cfg), Err.AGY_NOT_INSTALLED);
|
|
1562
1681
|
const isReview = typeof options.system === "string" && options.system.includes("REVIEW_POLICY");
|
|
1563
1682
|
const purpose = options.purpose ?? "chat";
|
|
1564
1683
|
const isTitle = purpose === "session-title";
|
|
@@ -5003,90 +5122,6 @@ function makeLineDecoder(encoding) {
|
|
|
5003
5122
|
};
|
|
5004
5123
|
}
|
|
5005
5124
|
//#endregion
|
|
5006
|
-
//#region src/runtime/agy/bin.ts
|
|
5007
|
-
const IS_WIN$3 = process.platform === "win32";
|
|
5008
|
-
/** Executable candidates for one PATH entry, per-platform. Exported for tests. */
|
|
5009
|
-
function binCandidates(dir, platform = process.platform) {
|
|
5010
|
-
return (platform === "win32" ? [
|
|
5011
|
-
".exe",
|
|
5012
|
-
".cmd",
|
|
5013
|
-
".bat"
|
|
5014
|
-
] : [""]).map((e) => join(dir, "agy" + e));
|
|
5015
|
-
}
|
|
5016
|
-
/** True when the resolved bin is a Windows cmd shim (needs shell wrapping). */
|
|
5017
|
-
function isCmdShim(bin) {
|
|
5018
|
-
return /\.(cmd|bat)$/i.test(bin);
|
|
5019
|
-
}
|
|
5020
|
-
/** cmd.exe argument quoting (cross-spawn rules). Exported for tests. */
|
|
5021
|
-
function windowsQuote(arg) {
|
|
5022
|
-
if (/[ \t\n\v"]/.test(arg) === false) return arg;
|
|
5023
|
-
let escaped = arg.replace(/(\\+)\"/g, "$1$1\\\"").replace(/(\\+)$/, "$1$1");
|
|
5024
|
-
escaped = "\"" + escaped.replace(/"/g, "\\\"") + "\"";
|
|
5025
|
-
return escaped;
|
|
5026
|
-
}
|
|
5027
|
-
function resolveAgyBin(cfg) {
|
|
5028
|
-
const candidates = [];
|
|
5029
|
-
if (cfg.agyBin !== "") candidates.push(cfg.agyBin);
|
|
5030
|
-
const pathEnv = process.env.PATH ?? "";
|
|
5031
|
-
for (const dir of pathEnv.split(delimiter)) if (dir !== "") candidates.push(...binCandidates(dir));
|
|
5032
|
-
const home = homedir();
|
|
5033
|
-
if (IS_WIN$3) {
|
|
5034
|
-
const local = process.env.LOCALAPPDATA ?? "";
|
|
5035
|
-
const appData = process.env.APPDATA ?? "";
|
|
5036
|
-
if (local !== "") {
|
|
5037
|
-
candidates.push(join(local, "agy", "bin", "agy.exe"));
|
|
5038
|
-
candidates.push(join(local, "agy", "bin", "agy.cmd"));
|
|
5039
|
-
candidates.push(join(local, "agy", "bin", "agy.bat"));
|
|
5040
|
-
candidates.push(join(local, "agy", "agy.exe"));
|
|
5041
|
-
candidates.push(join(local, "Programs", "agy", "agy.exe"));
|
|
5042
|
-
candidates.push(join(local, "Programs", "agy", "bin", "agy.exe"));
|
|
5043
|
-
candidates.push(join(local, "Microsoft", "WinGet", "Links", "agy.exe"));
|
|
5044
|
-
candidates.push(join(local, "pnpm", "agy.cmd"));
|
|
5045
|
-
candidates.push(join(local, "pnpm", "agy.exe"));
|
|
5046
|
-
}
|
|
5047
|
-
if (appData !== "") {
|
|
5048
|
-
candidates.push(join(appData, "npm", "agy.cmd"));
|
|
5049
|
-
candidates.push(join(appData, "Roaming", "npm", "agy.cmd"));
|
|
5050
|
-
}
|
|
5051
|
-
candidates.push(join(home, ".local", "bin", "agy.exe"));
|
|
5052
|
-
candidates.push(join(home, ".local", "bin", "agy.cmd"));
|
|
5053
|
-
candidates.push(join(home, ".bun", "bin", "agy.exe"));
|
|
5054
|
-
candidates.push(join(home, ".cargo", "bin", "agy.exe"));
|
|
5055
|
-
candidates.push(join(home, "scoop", "shims", "agy.exe"));
|
|
5056
|
-
} else {
|
|
5057
|
-
candidates.push(join(home, ".local", "bin", "agy"));
|
|
5058
|
-
candidates.push("/usr/local/bin/agy");
|
|
5059
|
-
candidates.push("/opt/homebrew/bin/agy");
|
|
5060
|
-
candidates.push("/opt/homebrew/sbin/agy");
|
|
5061
|
-
candidates.push("/home/linuxbrew/.linuxbrew/bin/agy");
|
|
5062
|
-
candidates.push(join(home, ".bun", "bin", "agy"));
|
|
5063
|
-
candidates.push(join(home, ".cargo", "bin", "agy"));
|
|
5064
|
-
candidates.push(join(home, ".local", "share", "pnpm", "agy"));
|
|
5065
|
-
candidates.push(join(home, "Library", "pnpm", "agy"));
|
|
5066
|
-
candidates.push(join(home, ".yarn", "bin", "agy"));
|
|
5067
|
-
candidates.push(join(home, ".npm-global", "bin", "agy"));
|
|
5068
|
-
candidates.push(join(home, ".volta", "bin", "agy"));
|
|
5069
|
-
candidates.push(join(home, ".asdf", "shims", "agy"));
|
|
5070
|
-
candidates.push(join(home, ".nix-profile", "bin", "agy"));
|
|
5071
|
-
candidates.push("/run/current-system/sw/bin/agy");
|
|
5072
|
-
try {
|
|
5073
|
-
const nvmNodeDir = join(home, ".nvm", "versions", "node");
|
|
5074
|
-
if (existsSync(nvmNodeDir)) for (const v of readdirSync(nvmNodeDir)) candidates.push(join(nvmNodeDir, v, "bin", "agy"));
|
|
5075
|
-
} catch {}
|
|
5076
|
-
candidates.push(join(home, ".local", "share", "fnm", "current", "bin", "agy"));
|
|
5077
|
-
candidates.push(join(home, ".fnm", "current", "bin", "agy"));
|
|
5078
|
-
candidates.push(join(home, "Library", "Application Support", "fnm", "current", "bin", "agy"));
|
|
5079
|
-
}
|
|
5080
|
-
const hits = [];
|
|
5081
|
-
for (const c of candidates) try {
|
|
5082
|
-
accessSync(c, constants.F_OK);
|
|
5083
|
-
hits.push(c);
|
|
5084
|
-
} catch {
|
|
5085
|
-
continue;
|
|
5086
|
-
}
|
|
5087
|
-
return hits.find((h) => !isCmdShim(h)) ?? hits[0] ?? null;
|
|
5088
|
-
}
|
|
5089
|
-
//#endregion
|
|
5090
5125
|
//#region src/runtime/agy/env.ts
|
|
5091
5126
|
const IS_WIN$2 = process.platform === "win32";
|
|
5092
5127
|
/**
|
|
@@ -8896,6 +8931,26 @@ var AccountPoolManager = class {
|
|
|
8896
8931
|
this.persist();
|
|
8897
8932
|
}
|
|
8898
8933
|
/**
|
|
8934
|
+
* Record that the last refresh produced no authoritative snapshot.
|
|
8935
|
+
*
|
|
8936
|
+
* Kept on the account (not just in a log line) because the console has to be
|
|
8937
|
+
* able to say WHY a row is frozen: a failed summary keeps the previous
|
|
8938
|
+
* complete value by design, so the numbers alone can never show staleness.
|
|
8939
|
+
*/
|
|
8940
|
+
noteQuotaUnavailable(id, state) {
|
|
8941
|
+
const acc = this.getAccount(id);
|
|
8942
|
+
if (!acc) return;
|
|
8943
|
+
acc.quotaUnavailable = state;
|
|
8944
|
+
this.persist();
|
|
8945
|
+
}
|
|
8946
|
+
/** Clear the marker once an authoritative snapshot arrives. */
|
|
8947
|
+
clearQuotaUnavailable(id) {
|
|
8948
|
+
const acc = this.getAccount(id);
|
|
8949
|
+
if (!acc?.quotaUnavailable) return;
|
|
8950
|
+
delete acc.quotaUnavailable;
|
|
8951
|
+
this.persist();
|
|
8952
|
+
}
|
|
8953
|
+
/**
|
|
8899
8954
|
* Drop one family's quota row.
|
|
8900
8955
|
*
|
|
8901
8956
|
* Used when stored numbers provably cannot be attributed to this account —
|
package/dist/client.js
CHANGED
|
@@ -77,6 +77,13 @@ window.__ModuleLoader__.load({
|
|
|
77
77
|
"quota.refreshStarted": "正在同步额度,稍后自动更新",
|
|
78
78
|
"quota.windowReset": "已重置 · 可用",
|
|
79
79
|
"quota.unactivated": "未激活 · 预热启动计时",
|
|
80
|
+
"quota.refreshInProgress": "该账号正在刷新中,请稍候",
|
|
81
|
+
"quota.unavailableTitle": "配额刷新失败",
|
|
82
|
+
"quota.unavailable.no_license": "此账号无有效许可(接口 403)",
|
|
83
|
+
"quota.unavailable.auth": "登录凭据已失效(401)",
|
|
84
|
+
"quota.unavailable.unreachable": "配额接口不可达",
|
|
85
|
+
"quota.unavailable.partial": "只取到模型级数据,5 小时/周额度未更新",
|
|
86
|
+
"quota.unavailableSince": " · 数据停留在 {time}",
|
|
80
87
|
"quota.paceSurplus": "节奏充裕(富裕 +{pct}%)",
|
|
81
88
|
"quota.paceFast": "消耗较快(超耗 {pct}%)",
|
|
82
89
|
"quota.paceOnTrack": "消耗均衡",
|
|
@@ -298,6 +305,13 @@ window.__ModuleLoader__.load({
|
|
|
298
305
|
"quota.refreshStarted": "Syncing quota — figures update shortly",
|
|
299
306
|
"quota.windowReset": "Reset · available",
|
|
300
307
|
"quota.unactivated": "Unactivated · warmup to start",
|
|
308
|
+
"quota.refreshInProgress": "A refresh is already running for this account",
|
|
309
|
+
"quota.unavailableTitle": "Quota refresh failed",
|
|
310
|
+
"quota.unavailable.no_license": "this account has no valid license (HTTP 403)",
|
|
311
|
+
"quota.unavailable.auth": "the login credential is no longer valid (401)",
|
|
312
|
+
"quota.unavailable.unreachable": "the quota endpoints are unreachable",
|
|
313
|
+
"quota.unavailable.partial": "only per-model data arrived; 5-hour/weekly figures are stale",
|
|
314
|
+
"quota.unavailableSince": " · figures last updated {time}",
|
|
301
315
|
"quota.paceSurplus": "Surplus pace (+{pct}%)",
|
|
302
316
|
"quota.paceFast": "Burning fast (-{pct}%)",
|
|
303
317
|
"quota.paceOnTrack": "On pace",
|
|
@@ -519,6 +533,13 @@ window.__ModuleLoader__.load({
|
|
|
519
533
|
"quota.refreshStarted": "Sincronizando a cota — os números atualizam em breve",
|
|
520
534
|
"quota.windowReset": "Redefinida · disponível",
|
|
521
535
|
"quota.unactivated": "Não ativada · aqueça para iniciar",
|
|
536
|
+
"quota.refreshInProgress": "Já existe uma atualização em andamento para esta conta",
|
|
537
|
+
"quota.unavailableTitle": "Falha ao atualizar a cota",
|
|
538
|
+
"quota.unavailable.no_license": "esta conta não tem uma licença válida (HTTP 403)",
|
|
539
|
+
"quota.unavailable.auth": "a credencial de acesso não é mais válida (401)",
|
|
540
|
+
"quota.unavailable.unreachable": "não é possível alcançar os serviços de cota",
|
|
541
|
+
"quota.unavailable.partial": "só chegaram dados por modelo; os números de 5 h/semana estão desatualizados",
|
|
542
|
+
"quota.unavailableSince": " · dados de {time}",
|
|
522
543
|
"quota.paceSurplus": "Folga de ritmo (+{pct}%)",
|
|
523
544
|
"quota.paceFast": "Consumo rápido (-{pct}%)",
|
|
524
545
|
"quota.paceOnTrack": "No ritmo",
|
|
@@ -740,6 +761,13 @@ window.__ModuleLoader__.load({
|
|
|
740
761
|
"quota.refreshStarted": "Sincronizando la cuota — las cifras se actualizarán en breve",
|
|
741
762
|
"quota.windowReset": "Reiniciada · disponible",
|
|
742
763
|
"quota.unactivated": "Sin activar · calentar para iniciar",
|
|
764
|
+
"quota.refreshInProgress": "Ya hay una actualización en curso para esta cuenta",
|
|
765
|
+
"quota.unavailableTitle": "No se pudo actualizar la cuota",
|
|
766
|
+
"quota.unavailable.no_license": "esta cuenta no tiene una licencia válida (HTTP 403)",
|
|
767
|
+
"quota.unavailable.auth": "la credencial de acceso ya no es válida (401)",
|
|
768
|
+
"quota.unavailable.unreachable": "no se puede alcanzar los servicios de cuota",
|
|
769
|
+
"quota.unavailable.partial": "solo llegaron datos por modelo; las cifras de 5 h/semana están desactualizadas",
|
|
770
|
+
"quota.unavailableSince": " · datos del {time}",
|
|
743
771
|
"quota.paceSurplus": "Margen favorable (+{pct}%)",
|
|
744
772
|
"quota.paceFast": "Consumo rápido (-{pct}%)",
|
|
745
773
|
"quota.paceOnTrack": "A buen ritmo",
|
|
@@ -7761,6 +7789,10 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7761
7789
|
return;
|
|
7762
7790
|
}
|
|
7763
7791
|
await refresh();
|
|
7792
|
+
if (res?.alreadyRunning === true) {
|
|
7793
|
+
showToast(t("quota.refreshInProgress"), "info");
|
|
7794
|
+
return;
|
|
7795
|
+
}
|
|
7764
7796
|
showToast(res?.pending === true ? t("quota.refreshStarted") : t("quota.refreshed"), res?.pending === true ? "info" : "success");
|
|
7765
7797
|
} finally {
|
|
7766
7798
|
setLoadingAction(null);
|
|
@@ -8447,12 +8479,55 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8447
8479
|
color: "var(--agy-text-primary)"
|
|
8448
8480
|
} }, 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));
|
|
8449
8481
|
}
|
|
8482
|
+
/** Short absolute stamp for "this data is from …" notes (past tense). */
|
|
8483
|
+
function formatSnapshotStamp(ms) {
|
|
8484
|
+
const d = new Date(ms);
|
|
8485
|
+
const hh = d.getHours().toString().padStart(2, "0");
|
|
8486
|
+
const mm = d.getMinutes().toString().padStart(2, "0");
|
|
8487
|
+
return `${d.getMonth() + 1}/${d.getDate()} ${hh}:${mm}`;
|
|
8488
|
+
}
|
|
8489
|
+
/**
|
|
8490
|
+
* One-line "quota unavailable" note for an account whose last refresh produced
|
|
8491
|
+
* no authoritative snapshot.
|
|
8492
|
+
*
|
|
8493
|
+
* WHY (live 2026-11-19): `buildFamilyQuotas` deliberately keeps the previous
|
|
8494
|
+
* complete value when the summary failed — a partial fallback must never
|
|
8495
|
+
* overwrite good data — so a refused account renders yesterday's percentages
|
|
8496
|
+
* with nothing to say they are old. The user reported exactly that as "the
|
|
8497
|
+
* second account is stuck". The numbers stay honest; the freshness does not
|
|
8498
|
+
* get to hide.
|
|
8499
|
+
*/
|
|
8500
|
+
function renderQuotaUnavailableNote(t, acc) {
|
|
8501
|
+
const state = acc.quotaUnavailable;
|
|
8502
|
+
if (!state) return null;
|
|
8503
|
+
const newest = Math.max(0, ...Object.values(acc.quotas).map((q) => q?.updatedAt ?? 0));
|
|
8504
|
+
const reason = t(`quota.unavailable.${state.reason}`);
|
|
8505
|
+
return h("div", {
|
|
8506
|
+
key: "agy-quota-unavailable",
|
|
8507
|
+
style: {
|
|
8508
|
+
display: "flex",
|
|
8509
|
+
alignItems: "center",
|
|
8510
|
+
gap: "5px",
|
|
8511
|
+
margin: "2px 0 5px 0",
|
|
8512
|
+
padding: "3px 7px",
|
|
8513
|
+
borderRadius: "6px",
|
|
8514
|
+
fontSize: "11px",
|
|
8515
|
+
fontWeight: 600,
|
|
8516
|
+
color: "var(--agy-quota-med-text)",
|
|
8517
|
+
background: "var(--agy-quota-med-bg)",
|
|
8518
|
+
border: "1px solid var(--agy-quota-med-border)"
|
|
8519
|
+
}
|
|
8520
|
+
}, uiIcon("alert", 10, "var(--agy-quota-med-text)"), h("span", null, `${t("quota.unavailableTitle")} · ${reason}`), newest > 0 ? h("span", { style: {
|
|
8521
|
+
fontWeight: 500,
|
|
8522
|
+
opacity: .85
|
|
8523
|
+
} }, t("quota.unavailableSince", { time: formatSnapshotStamp(newest) })) : null);
|
|
8524
|
+
}
|
|
8450
8525
|
//#endregion
|
|
8451
8526
|
//#region src/client/sections/AccountsPanel.ts
|
|
8452
8527
|
function AccountsPanel(props) {
|
|
8453
|
-
const { t, pool, accounts, loadingAction, proxyInputs, setProxyInputs, editingProxyId, setEditingProxyId, expandedModels, toggleExpand, optimisticActiveId, handlers } = props;
|
|
8528
|
+
const { t, pool, accounts, loadingAction, quotaRefreshing = [], proxyInputs, setProxyInputs, editingProxyId, setEditingProxyId, expandedModels, toggleExpand, optimisticActiveId, handlers } = props;
|
|
8454
8529
|
const accountActionBusy = (acc, action) => loadingAction === `${action}:${acc.id}`;
|
|
8455
|
-
const renderQuotaBar = (label, familyKey, acc) => renderFamilyQuotaBar(t, label, familyKey, acc, loadingAction === "refresh:all" || loadingAction === `refresh:${acc.id}`);
|
|
8530
|
+
const renderQuotaBar = (label, familyKey, acc) => renderFamilyQuotaBar(t, label, familyKey, acc, loadingAction === "refresh:all" || loadingAction === `refresh:${acc.id}` || quotaRefreshing.includes(acc.id));
|
|
8456
8531
|
const authoritativeActiveId = pool?.activeAccountId ?? pool?.lastActiveAccountId ?? pool?.activeAccountIds?.google ?? pool?.primaryAccountId;
|
|
8457
8532
|
const activeAccountId = optimisticActiveId ?? authoritativeActiveId;
|
|
8458
8533
|
return accounts.map((acc) => {
|
|
@@ -8517,7 +8592,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8517
8592
|
}), h("div", {
|
|
8518
8593
|
key: "agy-body",
|
|
8519
8594
|
style: S.quotaBox
|
|
8520
|
-
}, renderQuotaBar("Gemini", "google", acc), acc.quotas.argon ? renderQuotaBar("Argon", "argon", acc) : null, h(Button, {
|
|
8595
|
+
}, renderQuotaUnavailableNote(t, acc), renderQuotaBar("Gemini", "google", acc), acc.quotas.argon ? renderQuotaBar("Argon", "argon", acc) : null, h(Button, {
|
|
8521
8596
|
variant: "dashed",
|
|
8522
8597
|
style: {
|
|
8523
8598
|
color: isExpanded ? "var(--dsw-alias-state-business-primary, #3b82f6)" : "var(--agy-text-secondary)",
|
|
@@ -9203,6 +9278,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9203
9278
|
pool,
|
|
9204
9279
|
accounts,
|
|
9205
9280
|
loadingAction,
|
|
9281
|
+
quotaRefreshing: status.quotaRefreshing ?? [],
|
|
9206
9282
|
proxyInputs,
|
|
9207
9283
|
setProxyInputs,
|
|
9208
9284
|
editingProxyId,
|
package/dist/index.js
CHANGED
|
@@ -566,6 +566,20 @@ function modelFamilyOf(modelId) {
|
|
|
566
566
|
return "unknown";
|
|
567
567
|
}
|
|
568
568
|
/**
|
|
569
|
+
* True when the unattended quota probe must skip this account's summary call.
|
|
570
|
+
*
|
|
571
|
+
* Only a licence refusal suppresses: it is the one verdict the network cannot
|
|
572
|
+
* fix on its own, and re-probing it every hour is pure risk-control exposure.
|
|
573
|
+
* `auth` stays on the existing authRequired lifecycle, and network faults must
|
|
574
|
+
* be retried normally.
|
|
575
|
+
*/
|
|
576
|
+
function quotaSummarySuppressed(account, now = Date.now()) {
|
|
577
|
+
const state = account.quotaUnavailable;
|
|
578
|
+
if (state === void 0) return false;
|
|
579
|
+
if (state.reason !== "no_license") return false;
|
|
580
|
+
return state.retryAfter > now;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
569
583
|
* Determine whether a managed account has confirmed access to the Gemini 4 Argon family.
|
|
570
584
|
*
|
|
571
585
|
* An account qualifies for Argon when:
|
|
@@ -641,6 +655,7 @@ function shouldPollAccount(account) {
|
|
|
641
655
|
if (!account.enabled) return false;
|
|
642
656
|
if (account.authRequired) return false;
|
|
643
657
|
const now = Date.now();
|
|
658
|
+
if (quotaSummarySuppressed(account, now)) return false;
|
|
644
659
|
for (const cd of Object.values(account.cooldowns ?? {})) if (cd && cd.cooldownUntil > now) return false;
|
|
645
660
|
return true;
|
|
646
661
|
}
|
|
@@ -2876,7 +2891,14 @@ function windowsQuote(arg) {
|
|
|
2876
2891
|
escaped = "\"" + escaped.replace(/"/g, "\\\"") + "\"";
|
|
2877
2892
|
return escaped;
|
|
2878
2893
|
}
|
|
2879
|
-
|
|
2894
|
+
/**
|
|
2895
|
+
* Every location the plugin probes for the agy executable.
|
|
2896
|
+
*
|
|
2897
|
+
* Kept separate from `resolveAgyBin` so a failed lookup can report WHERE it
|
|
2898
|
+
* looked: a missing binary is otherwise indistinguishable from a broken PATH,
|
|
2899
|
+
* and the user is left guessing which install layout they should match.
|
|
2900
|
+
*/
|
|
2901
|
+
function agyBinCandidates(cfg) {
|
|
2880
2902
|
const candidates = [];
|
|
2881
2903
|
if (cfg.agyBin !== "") candidates.push(cfg.agyBin);
|
|
2882
2904
|
const pathEnv = process.env.PATH ?? "";
|
|
@@ -2929,8 +2951,18 @@ function resolveAgyBin(cfg) {
|
|
|
2929
2951
|
candidates.push(join(home, ".fnm", "current", "bin", "agy"));
|
|
2930
2952
|
candidates.push(join(home, "Library", "Application Support", "fnm", "current", "bin", "agy"));
|
|
2931
2953
|
}
|
|
2954
|
+
return candidates;
|
|
2955
|
+
}
|
|
2956
|
+
function agyBinDiagnostics(cfg) {
|
|
2957
|
+
return {
|
|
2958
|
+
probed: agyBinCandidates(cfg),
|
|
2959
|
+
configured: cfg.agyBin,
|
|
2960
|
+
installHint: IS_WIN$3 ? "the official installer defaults to " + join(process.env.LOCALAPPDATA ?? "%LOCALAPPDATA%", "agy", "bin", "agy.exe") : "the official installer defaults to " + join(homedir(), ".local", "bin", "agy")
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
function resolveAgyBin(cfg) {
|
|
2932
2964
|
const hits = [];
|
|
2933
|
-
for (const c of
|
|
2965
|
+
for (const c of agyBinCandidates(cfg)) try {
|
|
2934
2966
|
accessSync(c, constants.F_OK);
|
|
2935
2967
|
hits.push(c);
|
|
2936
2968
|
} catch {
|
|
@@ -3062,6 +3094,23 @@ function longRouteTimeout(jobTimeoutMs) {
|
|
|
3062
3094
|
/** How long a manual quota refresh keeps its dedupe entry when work never settles. */
|
|
3063
3095
|
const QUOTA_REFRESH_DEDUP_MS = 9e4;
|
|
3064
3096
|
/**
|
|
3097
|
+
* How long an endpoint that just failed keeps its "try me LAST" memory.
|
|
3098
|
+
*
|
|
3099
|
+
* Measured 2026-11-19: retrieveUserQuotaSummary on
|
|
3100
|
+
* daily-cloudcode-pa.googleapis.com resets the connection after 5-8s for every
|
|
3101
|
+
* account, while the sandbox endpoint answers. The endpoint list is walked from
|
|
3102
|
+
* the same end on every refresh, so without this memory each account pays that
|
|
3103
|
+
* timeout first — including the hourly background sweep. Short enough that a
|
|
3104
|
+
* recovered endpoint returns on its own.
|
|
3105
|
+
*/
|
|
3106
|
+
const QUOTA_ENDPOINT_DOWN_MS = 6e5;
|
|
3107
|
+
/**
|
|
3108
|
+
* How long a "no valid licence" verdict (403 from the quota summary) keeps the
|
|
3109
|
+
* UNATTENDED probe away from that account. An explicit user refresh ignores it,
|
|
3110
|
+
* so a restored licence is picked up the moment the user asks for it.
|
|
3111
|
+
*/
|
|
3112
|
+
const QUOTA_LICENSE_RETRY_MS = 216e5;
|
|
3113
|
+
/**
|
|
3065
3114
|
* Grace the idle watchdog grants before killing a quiet child. libuv runs the
|
|
3066
3115
|
* timers phase BEFORE the poll phase: when the DSH host's event loop is blocked
|
|
3067
3116
|
* (a large parse, many parallel workers), an expired watchdog can fire before
|
|
@@ -3877,6 +3926,26 @@ var AccountPoolManager = class {
|
|
|
3877
3926
|
this.persist();
|
|
3878
3927
|
}
|
|
3879
3928
|
/**
|
|
3929
|
+
* Record that the last refresh produced no authoritative snapshot.
|
|
3930
|
+
*
|
|
3931
|
+
* Kept on the account (not just in a log line) because the console has to be
|
|
3932
|
+
* able to say WHY a row is frozen: a failed summary keeps the previous
|
|
3933
|
+
* complete value by design, so the numbers alone can never show staleness.
|
|
3934
|
+
*/
|
|
3935
|
+
noteQuotaUnavailable(id, state) {
|
|
3936
|
+
const acc = this.getAccount(id);
|
|
3937
|
+
if (!acc) return;
|
|
3938
|
+
acc.quotaUnavailable = state;
|
|
3939
|
+
this.persist();
|
|
3940
|
+
}
|
|
3941
|
+
/** Clear the marker once an authoritative snapshot arrives. */
|
|
3942
|
+
clearQuotaUnavailable(id) {
|
|
3943
|
+
const acc = this.getAccount(id);
|
|
3944
|
+
if (!acc?.quotaUnavailable) return;
|
|
3945
|
+
delete acc.quotaUnavailable;
|
|
3946
|
+
this.persist();
|
|
3947
|
+
}
|
|
3948
|
+
/**
|
|
3880
3949
|
* Drop one family's quota row.
|
|
3881
3950
|
*
|
|
3882
3951
|
* Used when stored numbers provably cannot be attributed to this account —
|
|
@@ -29520,9 +29589,27 @@ async function runAgyOnce(deps, req) {
|
|
|
29520
29589
|
function effectivePermissionMode(configured, dshPlanMode, isAux) {
|
|
29521
29590
|
return dshPlanMode && !isAux ? "plan" : configured;
|
|
29522
29591
|
}
|
|
29592
|
+
/**
|
|
29593
|
+
* Message for a missing agy executable.
|
|
29594
|
+
*
|
|
29595
|
+
* A bare "not found on PATH" is unactionable: the user cannot tell whether the
|
|
29596
|
+
* CLI is missing, installed outside the probed locations, or simply not on the
|
|
29597
|
+
* PATH the GUI host inherited. The message therefore names the locations that
|
|
29598
|
+
* were probed and both documented ways to point the plugin at a binary the
|
|
29599
|
+
* probes do not cover.
|
|
29600
|
+
*/
|
|
29601
|
+
function agyNotInstalledMessage(cfg) {
|
|
29602
|
+
const diag = agyBinDiagnostics(cfg);
|
|
29603
|
+
const lines = ["agy binary not found — install it via https://antigravity.google/docs/cli/install", "probed " + diag.probed.length + " location(s): " + diag.probed.join(", ")];
|
|
29604
|
+
if (diag.configured !== "") lines.push("configured agyBin (" + diag.configured + ") does not exist either");
|
|
29605
|
+
lines.push(diag.installHint);
|
|
29606
|
+
lines.push("if agy is installed elsewhere, set the plugin config agyBin to its absolute path, or the DSH_AGY_BIN environment variable");
|
|
29607
|
+
lines.push("run /agy doctor for a full report");
|
|
29608
|
+
return lines.join("\n");
|
|
29609
|
+
}
|
|
29523
29610
|
function resolveCallContext(input) {
|
|
29524
29611
|
const { options, cfg, bin } = input;
|
|
29525
|
-
if (!bin) throw new LlmError(
|
|
29612
|
+
if (!bin) throw new LlmError(agyNotInstalledMessage(cfg), Err.AGY_NOT_INSTALLED);
|
|
29526
29613
|
const isReview = typeof options.system === "string" && options.system.includes("REVIEW_POLICY");
|
|
29527
29614
|
const purpose = options.purpose ?? "chat";
|
|
29528
29615
|
const isTitle = purpose === "session-title";
|
|
@@ -36219,6 +36306,13 @@ function writeDoctorReport(deps) {
|
|
|
36219
36306
|
lines.push("- generated: " + (/* @__PURE__ */ new Date()).toISOString());
|
|
36220
36307
|
lines.push("- agy binary: " + (deps.bin() ?? "NOT FOUND"));
|
|
36221
36308
|
lines.push("- agy version: " + (deps.version() ?? "unknown"));
|
|
36309
|
+
if (deps.bin() === null) {
|
|
36310
|
+
const diag = agyBinDiagnostics(cfg);
|
|
36311
|
+
lines.push("- agy lookup: NOT FOUND — probed " + diag.probed.length + " location(s)");
|
|
36312
|
+
for (const p of diag.probed) lines.push(" - " + p);
|
|
36313
|
+
lines.push("- agy lookup: install hint — " + diag.installHint);
|
|
36314
|
+
lines.push("- agy lookup: override — set plugin config agyBin, or the DSH_AGY_BIN environment variable");
|
|
36315
|
+
}
|
|
36222
36316
|
lines.push("- agy auto-updater: " + (cfg.suppressAgyAutoUpdate ? describeAgyAutoUpdate() : "not suppressed (suppressAgyAutoUpdate=false)"));
|
|
36223
36317
|
const cfgDump = {
|
|
36224
36318
|
...cfg,
|
|
@@ -39448,6 +39542,14 @@ function buildFamilyQuotas(params) {
|
|
|
39448
39542
|
}
|
|
39449
39543
|
//#endregion
|
|
39450
39544
|
//#region src/features/quota/refresh.ts
|
|
39545
|
+
/** Map the HTTP verdict onto the account-level marker. */
|
|
39546
|
+
function unavailableReason(failure, hasModelData) {
|
|
39547
|
+
if (failure === null) return hasModelData ? "partial" : "unreachable";
|
|
39548
|
+
if (failure.kind === "no_license") return "no_license";
|
|
39549
|
+
if (failure.kind === "auth") return "auth";
|
|
39550
|
+
if (failure.kind === "network") return "unreachable";
|
|
39551
|
+
return hasModelData ? "partial" : "unreachable";
|
|
39552
|
+
}
|
|
39451
39553
|
/**
|
|
39452
39554
|
* Fetch and aggregate live quota statistics (both 5-hour limit and weekly limit)
|
|
39453
39555
|
* for a single account across model families.
|
|
@@ -39517,13 +39619,35 @@ async function refreshAccountQuotaPipeline(deps, account, force = false) {
|
|
|
39517
39619
|
}
|
|
39518
39620
|
deps.pool.resetAccountIdentity(account.id, email);
|
|
39519
39621
|
}
|
|
39520
|
-
const
|
|
39622
|
+
const suppressSummary = !force && quotaSummarySuppressed(account, now);
|
|
39623
|
+
let summary = null;
|
|
39624
|
+
let discovered = null;
|
|
39625
|
+
if (suppressSummary) discovered = await deps.fetchAvailableModels(accessToken, deps.proxyFor(account));
|
|
39626
|
+
else {
|
|
39627
|
+
const [fetchedSummary, fetchedModels] = await Promise.all([deps.fetchQuotaSummary(accessToken, deps.proxyFor(account)), deps.fetchAvailableModels(accessToken, deps.proxyFor(account))]);
|
|
39628
|
+
summary = fetchedSummary;
|
|
39629
|
+
discovered = fetchedModels;
|
|
39630
|
+
}
|
|
39521
39631
|
const userQuota = !Boolean(discovered?.models && Object.values(discovered.models).some((m) => m?.quotaInfo !== void 0)) ? await deps.fetchUserQuota(accessToken, deps.proxyFor(account)).catch(() => null) : null;
|
|
39522
39632
|
if (!email) {
|
|
39523
39633
|
const info = await deps.fetchUserInfo(accessToken, deps.proxyFor(account));
|
|
39524
39634
|
if (info?.email) email = info.email;
|
|
39525
39635
|
}
|
|
39526
39636
|
const modelsCatalog = buildModelsCatalog(discovered, userQuota);
|
|
39637
|
+
if (!suppressSummary) {
|
|
39638
|
+
if ((summary?.groups?.length ?? 0) > 0 || (summary?.buckets?.length ?? 0) > 0) deps.pool.clearQuotaUnavailable(account.id);
|
|
39639
|
+
else {
|
|
39640
|
+
const failure = deps.summaryFailure?.() ?? null;
|
|
39641
|
+
const reason = unavailableReason(failure, Object.keys(modelsCatalog).length > 0);
|
|
39642
|
+
const previous = account.quotaUnavailable;
|
|
39643
|
+
deps.pool.noteQuotaUnavailable(account.id, {
|
|
39644
|
+
reason,
|
|
39645
|
+
since: previous?.reason === reason ? previous.since : now,
|
|
39646
|
+
retryAfter: now + QUOTA_LICENSE_RETRY_MS,
|
|
39647
|
+
...failure?.detail === void 0 ? {} : { detail: failure.detail }
|
|
39648
|
+
});
|
|
39649
|
+
}
|
|
39650
|
+
}
|
|
39527
39651
|
if (!summary && Object.keys(modelsCatalog).length === 0) return null;
|
|
39528
39652
|
if (account.authRequired) deps.pool.clearAuthRequired(account.id);
|
|
39529
39653
|
const { familyQuotas, summaryGroups } = buildFamilyQuotas({
|
|
@@ -39550,6 +39674,96 @@ async function refreshAccountQuotaPipeline(deps, account, force = false) {
|
|
|
39550
39674
|
return familyQuotas;
|
|
39551
39675
|
}
|
|
39552
39676
|
//#endregion
|
|
39677
|
+
//#region src/features/quota/endpoint-health.ts
|
|
39678
|
+
function endpointHealthKey(op, endpoint) {
|
|
39679
|
+
return `${op}|${endpoint}`;
|
|
39680
|
+
}
|
|
39681
|
+
/** TTL-bounded failure memory; a recovered endpoint re-enters on its own. */
|
|
39682
|
+
var EndpointHealth = class {
|
|
39683
|
+
downMs;
|
|
39684
|
+
now;
|
|
39685
|
+
downUntil = /* @__PURE__ */ new Map();
|
|
39686
|
+
constructor(downMs = QUOTA_ENDPOINT_DOWN_MS, now = () => Date.now()) {
|
|
39687
|
+
this.downMs = downMs;
|
|
39688
|
+
this.now = now;
|
|
39689
|
+
}
|
|
39690
|
+
isDown(key) {
|
|
39691
|
+
const until = this.downUntil.get(key);
|
|
39692
|
+
if (until === void 0) return false;
|
|
39693
|
+
if (until <= this.now()) {
|
|
39694
|
+
this.downUntil.delete(key);
|
|
39695
|
+
return false;
|
|
39696
|
+
}
|
|
39697
|
+
return true;
|
|
39698
|
+
}
|
|
39699
|
+
noteFailure(key) {
|
|
39700
|
+
this.downUntil.set(key, this.now() + this.downMs);
|
|
39701
|
+
}
|
|
39702
|
+
noteSuccess(key) {
|
|
39703
|
+
this.downUntil.delete(key);
|
|
39704
|
+
}
|
|
39705
|
+
};
|
|
39706
|
+
/**
|
|
39707
|
+
* Re-order an endpoint list so recently-failed endpoints are tried LAST.
|
|
39708
|
+
*
|
|
39709
|
+
* Never returns an empty list and never drops an endpoint: when everything is
|
|
39710
|
+
* marked down the original order is used, because a total outage must still be
|
|
39711
|
+
* probed (skipping all of them would lock the pool out of a recovered network).
|
|
39712
|
+
*/
|
|
39713
|
+
function orderEndpointsByHealth(endpoints, op, health) {
|
|
39714
|
+
if (health === void 0 || endpoints.length < 2) return [...endpoints];
|
|
39715
|
+
const healthy = [];
|
|
39716
|
+
const unhealthy = [];
|
|
39717
|
+
for (const endpoint of endpoints) if (health.isDown(endpointHealthKey(op, endpoint))) unhealthy.push(endpoint);
|
|
39718
|
+
else healthy.push(endpoint);
|
|
39719
|
+
return unhealthy.length === 0 || healthy.length === 0 ? [...endpoints] : [...healthy, ...unhealthy];
|
|
39720
|
+
}
|
|
39721
|
+
//#endregion
|
|
39722
|
+
//#region src/features/quota/sweep.ts
|
|
39723
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
39724
|
+
/** Run `items` with at most `limit` in flight, never starting two within `staggerMs`. */
|
|
39725
|
+
async function runStaggered(items, limit, run, staggerMs) {
|
|
39726
|
+
const queue = [...items];
|
|
39727
|
+
if (queue.length === 0) return;
|
|
39728
|
+
const width = Math.max(1, Math.min(Math.floor(limit), queue.length));
|
|
39729
|
+
let starting = 0;
|
|
39730
|
+
let lastStart = 0;
|
|
39731
|
+
const worker = async () => {
|
|
39732
|
+
for (;;) {
|
|
39733
|
+
const item = queue.shift();
|
|
39734
|
+
if (item === void 0) return;
|
|
39735
|
+
if (starting > 0) {
|
|
39736
|
+
const gap = staggerMs();
|
|
39737
|
+
if (gap > 0) {
|
|
39738
|
+
const wait = lastStart + gap - Date.now();
|
|
39739
|
+
if (wait > 0) await sleep(wait);
|
|
39740
|
+
}
|
|
39741
|
+
}
|
|
39742
|
+
starting++;
|
|
39743
|
+
lastStart = Date.now();
|
|
39744
|
+
await run(item);
|
|
39745
|
+
}
|
|
39746
|
+
};
|
|
39747
|
+
await Promise.all(Array.from({ length: width }, () => worker()));
|
|
39748
|
+
}
|
|
39749
|
+
/**
|
|
39750
|
+
* Sweep accounts grouped by egress.
|
|
39751
|
+
*
|
|
39752
|
+
* Errors never abort the sweep (one broken account must not silence the pool),
|
|
39753
|
+
* matching the previous `.catch(() => null)` semantics at the call site.
|
|
39754
|
+
*/
|
|
39755
|
+
async function sweepAccountsByEgress(accounts, options) {
|
|
39756
|
+
const groups = /* @__PURE__ */ new Map();
|
|
39757
|
+
for (const account of accounts) {
|
|
39758
|
+
const egress = options.egressOf(account);
|
|
39759
|
+
const group = groups.get(egress);
|
|
39760
|
+
if (group === void 0) groups.set(egress, [account]);
|
|
39761
|
+
else group.push(account);
|
|
39762
|
+
}
|
|
39763
|
+
const concurrency = Math.max(1, Math.floor(options.concurrency ?? 1));
|
|
39764
|
+
await Promise.allSettled([...groups.values()].map((group) => runStaggered(group, concurrency, options.run, options.staggerMs)));
|
|
39765
|
+
}
|
|
39766
|
+
//#endregion
|
|
39553
39767
|
//#region src/features/quota/http.ts
|
|
39554
39768
|
/** Re-order endpoints so the preferred/working endpoint is tried first. */
|
|
39555
39769
|
function orderedEndpoints(preferredIndex) {
|
|
@@ -39558,6 +39772,41 @@ function orderedEndpoints(preferredIndex) {
|
|
|
39558
39772
|
for (let i = 0; i < total; i++) ordered.push(AGY_ENDPOINTS[(preferredIndex + i) % total]);
|
|
39559
39773
|
return ordered;
|
|
39560
39774
|
}
|
|
39775
|
+
/** The API's own status enum, which is safe to surface (no message body). */
|
|
39776
|
+
function apiErrorStatus(bodyText) {
|
|
39777
|
+
try {
|
|
39778
|
+
const parsed = JSON.parse(bodyText);
|
|
39779
|
+
return typeof parsed.error?.status === "string" ? parsed.error.status : void 0;
|
|
39780
|
+
} catch {
|
|
39781
|
+
return;
|
|
39782
|
+
}
|
|
39783
|
+
}
|
|
39784
|
+
function networkFailureCode(error) {
|
|
39785
|
+
const cause = error?.cause;
|
|
39786
|
+
return typeof cause?.code === "string" ? cause.code : void 0;
|
|
39787
|
+
}
|
|
39788
|
+
/**
|
|
39789
|
+
* Classify a refusal. A 403 that talks about a licence is the one case the
|
|
39790
|
+
* account can never retry its way out of, so it gets its own kind.
|
|
39791
|
+
*/
|
|
39792
|
+
function classifySummaryRefusal(status, bodyText = "") {
|
|
39793
|
+
const detail = apiErrorStatus(bodyText);
|
|
39794
|
+
if (status === 401) return {
|
|
39795
|
+
kind: "auth",
|
|
39796
|
+
status,
|
|
39797
|
+
...detail === void 0 ? {} : { detail }
|
|
39798
|
+
};
|
|
39799
|
+
if (status === 403 && /licen[cs]e/i.test(bodyText)) return {
|
|
39800
|
+
kind: "no_license",
|
|
39801
|
+
status,
|
|
39802
|
+
...detail === void 0 ? {} : { detail }
|
|
39803
|
+
};
|
|
39804
|
+
return {
|
|
39805
|
+
kind: "http",
|
|
39806
|
+
status,
|
|
39807
|
+
...detail === void 0 ? {} : { detail }
|
|
39808
|
+
};
|
|
39809
|
+
}
|
|
39561
39810
|
/**
|
|
39562
39811
|
* Query live user info (email) from Google OAuth userinfo endpoint.
|
|
39563
39812
|
*/
|
|
@@ -39581,13 +39830,16 @@ function requestQuotaSummaryEndpoint(endpoint, accessToken, proxyUrl, agyVersion
|
|
|
39581
39830
|
* via v1internal:retrieveUserQuotaSummary.
|
|
39582
39831
|
*/
|
|
39583
39832
|
async function fetchQuotaSummary(deps, accessToken, proxyUrl) {
|
|
39584
|
-
const endpoints = orderedEndpoints(deps.getPreferredEndpointIndex());
|
|
39833
|
+
const endpoints = orderEndpointsByHealth(orderedEndpoints(deps.getPreferredEndpointIndex()), "summary", deps.endpointHealth);
|
|
39585
39834
|
let partialSummary = null;
|
|
39835
|
+
let refusal = null;
|
|
39586
39836
|
for (let i = 0; i < endpoints.length; i++) {
|
|
39587
39837
|
const endpoint = endpoints[i];
|
|
39838
|
+
const healthKey = endpointHealthKey("summary", endpoint);
|
|
39588
39839
|
try {
|
|
39589
39840
|
const res = await deps.fetchSummaryEndpoint(endpoint, accessToken, proxyUrl, deps.accountScope);
|
|
39590
39841
|
if (res.ok) {
|
|
39842
|
+
deps.endpointHealth?.noteSuccess(healthKey);
|
|
39591
39843
|
const summary = await res.json();
|
|
39592
39844
|
if (summary?.groups?.some((g) => {
|
|
39593
39845
|
const name = (g.displayName || "").toLowerCase();
|
|
@@ -39603,16 +39855,33 @@ async function fetchQuotaSummary(deps, accessToken, proxyUrl) {
|
|
|
39603
39855
|
existingNames.add(name);
|
|
39604
39856
|
}
|
|
39605
39857
|
}
|
|
39858
|
+
deps.onSummaryFailure?.(null);
|
|
39606
39859
|
return partialSummary;
|
|
39607
39860
|
}
|
|
39608
39861
|
if (i > 0 && !partialSummary) deps.setPreferredEndpointIndex(AGY_ENDPOINTS.indexOf(endpoint));
|
|
39862
|
+
deps.onSummaryFailure?.(null);
|
|
39609
39863
|
return summary;
|
|
39610
39864
|
}
|
|
39611
39865
|
if (!partialSummary && summary && Array.isArray(summary.groups) && summary.groups.length > 0) partialSummary = summary;
|
|
39612
39866
|
}
|
|
39613
|
-
if (res.status === 401 || res.status === 403)
|
|
39614
|
-
|
|
39867
|
+
if (res.status === 401 || res.status === 403) {
|
|
39868
|
+
deps.endpointHealth?.noteSuccess(healthKey);
|
|
39869
|
+
refusal = classifySummaryRefusal(res.status, await res.text().catch(() => ""));
|
|
39870
|
+
break;
|
|
39871
|
+
}
|
|
39872
|
+
if (res.status >= 500) deps.endpointHealth?.noteFailure(healthKey);
|
|
39873
|
+
else deps.endpointHealth?.noteSuccess(healthKey);
|
|
39874
|
+
refusal = classifySummaryRefusal(res.status);
|
|
39875
|
+
} catch (error) {
|
|
39876
|
+
deps.endpointHealth?.noteFailure(healthKey);
|
|
39877
|
+
const code = networkFailureCode(error);
|
|
39878
|
+
refusal = {
|
|
39879
|
+
kind: "network",
|
|
39880
|
+
...code === void 0 ? {} : { detail: code }
|
|
39881
|
+
};
|
|
39882
|
+
}
|
|
39615
39883
|
}
|
|
39884
|
+
deps.onSummaryFailure?.(partialSummary === null ? refusal : null);
|
|
39616
39885
|
return partialSummary;
|
|
39617
39886
|
}
|
|
39618
39887
|
/** POST /v1internal:retrieveUserQuota for one endpoint. */
|
|
@@ -39631,14 +39900,25 @@ function requestUserQuotaEndpoint(endpoint, accessToken, proxyUrl, agyVersion, a
|
|
|
39631
39900
|
* Fetch per-model live user quota via v1internal:retrieveUserQuota.
|
|
39632
39901
|
*/
|
|
39633
39902
|
async function fetchUserQuota(deps, accessToken, proxyUrl) {
|
|
39634
|
-
const endpoints = orderedEndpoints(deps.getPreferredEndpointIndex());
|
|
39903
|
+
const endpoints = orderEndpointsByHealth(orderedEndpoints(deps.getPreferredEndpointIndex()), "userQuota", deps.endpointHealth);
|
|
39635
39904
|
for (let i = 0; i < endpoints.length; i++) {
|
|
39636
39905
|
const endpoint = endpoints[i];
|
|
39906
|
+
const healthKey = endpointHealthKey("userQuota", endpoint);
|
|
39637
39907
|
try {
|
|
39638
39908
|
const res = await deps.fetchUserQuotaEndpoint(endpoint, accessToken, proxyUrl, deps.accountScope);
|
|
39639
|
-
if (res.ok)
|
|
39640
|
-
|
|
39641
|
-
|
|
39909
|
+
if (res.ok) {
|
|
39910
|
+
deps.endpointHealth?.noteSuccess(healthKey);
|
|
39911
|
+
return await res.json();
|
|
39912
|
+
}
|
|
39913
|
+
if (res.status === 401 || res.status === 403) {
|
|
39914
|
+
deps.endpointHealth?.noteSuccess(healthKey);
|
|
39915
|
+
break;
|
|
39916
|
+
}
|
|
39917
|
+
if (res.status >= 500) deps.endpointHealth?.noteFailure(healthKey);
|
|
39918
|
+
else deps.endpointHealth?.noteSuccess(healthKey);
|
|
39919
|
+
} catch {
|
|
39920
|
+
deps.endpointHealth?.noteFailure(healthKey);
|
|
39921
|
+
}
|
|
39642
39922
|
}
|
|
39643
39923
|
return null;
|
|
39644
39924
|
}
|
|
@@ -39646,9 +39926,10 @@ async function fetchUserQuota(deps, accessToken, proxyUrl) {
|
|
|
39646
39926
|
* Fetch available models and model-level quotas via v1internal:fetchAvailableModels.
|
|
39647
39927
|
*/
|
|
39648
39928
|
async function fetchAvailableModels(deps, accessToken, proxyUrl) {
|
|
39649
|
-
const endpoints = orderedEndpoints(deps.getPreferredEndpointIndex());
|
|
39929
|
+
const endpoints = orderEndpointsByHealth(orderedEndpoints(deps.getPreferredEndpointIndex()), "models", deps.endpointHealth);
|
|
39650
39930
|
for (let i = 0; i < endpoints.length; i++) {
|
|
39651
39931
|
const endpoint = endpoints[i];
|
|
39932
|
+
const healthKey = endpointHealthKey("models", endpoint);
|
|
39652
39933
|
try {
|
|
39653
39934
|
const res = await agyFetch(`${endpoint}/v1internal:fetchAvailableModels`, {
|
|
39654
39935
|
method: "POST",
|
|
@@ -39660,11 +39941,19 @@ async function fetchAvailableModels(deps, accessToken, proxyUrl) {
|
|
|
39660
39941
|
body: JSON.stringify({})
|
|
39661
39942
|
}, proxyUrl, deps.accountScope);
|
|
39662
39943
|
if (res.ok) {
|
|
39944
|
+
deps.endpointHealth?.noteSuccess(healthKey);
|
|
39663
39945
|
if (AGY_ENDPOINTS.indexOf(endpoint) === 0) deps.setPreferredEndpointIndex(0);
|
|
39664
39946
|
return await res.json();
|
|
39665
39947
|
}
|
|
39666
|
-
if (res.status === 401 || res.status === 403)
|
|
39667
|
-
|
|
39948
|
+
if (res.status === 401 || res.status === 403) {
|
|
39949
|
+
deps.endpointHealth?.noteSuccess(healthKey);
|
|
39950
|
+
break;
|
|
39951
|
+
}
|
|
39952
|
+
if (res.status >= 500) deps.endpointHealth?.noteFailure(healthKey);
|
|
39953
|
+
else deps.endpointHealth?.noteSuccess(healthKey);
|
|
39954
|
+
} catch {
|
|
39955
|
+
deps.endpointHealth?.noteFailure(healthKey);
|
|
39956
|
+
}
|
|
39668
39957
|
}
|
|
39669
39958
|
return null;
|
|
39670
39959
|
}
|
|
@@ -40007,6 +40296,15 @@ var QuotaService = class {
|
|
|
40007
40296
|
/** accountId -> in-flight getValidAccessToken attempt (dedup). */
|
|
40008
40297
|
tokenRefreshInFlight = /* @__PURE__ */ new Map();
|
|
40009
40298
|
/**
|
|
40299
|
+
* Recent per-endpoint failures: a quota call that just reset is tried LAST
|
|
40300
|
+
* instead of first (see features/quota/endpoint-health.ts for the incident).
|
|
40301
|
+
*/
|
|
40302
|
+
endpointHealth = new EndpointHealth();
|
|
40303
|
+
/** accountId -> refusal behind the last empty summary (drives quotaUnavailable). */
|
|
40304
|
+
summaryFailures = /* @__PURE__ */ new Map();
|
|
40305
|
+
/** accountIds with a refresh in flight, so the console can show real progress. */
|
|
40306
|
+
refreshingIds = /* @__PURE__ */ new Set();
|
|
40307
|
+
/**
|
|
40010
40308
|
* @param globalProxy resolves the plugin-wide proxy URL; used when the
|
|
40011
40309
|
* account has no dedicated proxyUrl. Injected so tests stay network-free.
|
|
40012
40310
|
*/
|
|
@@ -40020,7 +40318,13 @@ var QuotaService = class {
|
|
|
40020
40318
|
httpDeps(accountScope) {
|
|
40021
40319
|
return {
|
|
40022
40320
|
agyVersion: () => this.agyVersion(),
|
|
40023
|
-
|
|
40321
|
+
endpointHealth: this.endpointHealth,
|
|
40322
|
+
...accountScope ? {
|
|
40323
|
+
accountScope,
|
|
40324
|
+
onSummaryFailure: (failure) => {
|
|
40325
|
+
this.summaryFailures.set(accountScope, failure);
|
|
40326
|
+
}
|
|
40327
|
+
} : {},
|
|
40024
40328
|
getPreferredEndpointIndex: () => this.preferredEndpointIndex,
|
|
40025
40329
|
setPreferredEndpointIndex: (index) => {
|
|
40026
40330
|
this.preferredEndpointIndex = index;
|
|
@@ -40203,6 +40507,19 @@ var QuotaService = class {
|
|
|
40203
40507
|
* public signature and every override point stay unchanged.
|
|
40204
40508
|
*/
|
|
40205
40509
|
async refreshAccountQuota(account, force = false) {
|
|
40510
|
+
this.refreshingIds.add(account.id);
|
|
40511
|
+
this.summaryFailures.delete(account.id);
|
|
40512
|
+
try {
|
|
40513
|
+
return await this.runQuotaPipeline(account, force);
|
|
40514
|
+
} finally {
|
|
40515
|
+
this.refreshingIds.delete(account.id);
|
|
40516
|
+
}
|
|
40517
|
+
}
|
|
40518
|
+
/** Account ids with a quota refresh in flight (the console renders "同步中" from this). */
|
|
40519
|
+
refreshingAccounts() {
|
|
40520
|
+
return [...this.refreshingIds];
|
|
40521
|
+
}
|
|
40522
|
+
async runQuotaPipeline(account, force) {
|
|
40206
40523
|
return refreshAccountQuotaPipeline({
|
|
40207
40524
|
pool: this.pool,
|
|
40208
40525
|
shouldUseCli: () => this.cliDeps.viaCli?.() !== false,
|
|
@@ -40217,7 +40534,8 @@ var QuotaService = class {
|
|
|
40217
40534
|
detectEmailFromLogs: (home) => detectEmailFromAgyLogs(home),
|
|
40218
40535
|
readPrimaryCredential: (baseDir) => readPrimaryCredential(baseDir),
|
|
40219
40536
|
writePrimaryCredential: (cred, baseDir) => writePrimaryCredential(cred, baseDir),
|
|
40220
|
-
credentialFingerprint: (raw) => credentialFingerprint(raw)
|
|
40537
|
+
credentialFingerprint: (raw) => credentialFingerprint(raw),
|
|
40538
|
+
summaryFailure: () => this.summaryFailures.get(account.id) ?? null
|
|
40221
40539
|
}, account, force);
|
|
40222
40540
|
}
|
|
40223
40541
|
/**
|
|
@@ -40273,22 +40591,15 @@ var QuotaService = class {
|
|
|
40273
40591
|
}
|
|
40274
40592
|
return;
|
|
40275
40593
|
}
|
|
40276
|
-
const
|
|
40277
|
-
|
|
40278
|
-
|
|
40279
|
-
|
|
40280
|
-
|
|
40281
|
-
|
|
40282
|
-
|
|
40283
|
-
|
|
40284
|
-
|
|
40285
|
-
await this.refreshAccountQuota(group[i], force).catch(() => null);
|
|
40286
|
-
if (i < group.length - 1) {
|
|
40287
|
-
const gap = nextForceGapMs();
|
|
40288
|
-
if (gap > 0) await new Promise((resolve) => setTimeout(resolve, gap));
|
|
40289
|
-
}
|
|
40290
|
-
}
|
|
40291
|
-
}));
|
|
40594
|
+
const concurrency = Math.max(1, Math.floor(this.cliDeps.forceConcurrency?.() ?? 2));
|
|
40595
|
+
await sweepAccountsByEgress(accounts, {
|
|
40596
|
+
egressOf: (acc) => this.proxyFor(acc) || "__direct__",
|
|
40597
|
+
run: async (acc) => {
|
|
40598
|
+
await this.refreshAccountQuota(acc, force).catch(() => null);
|
|
40599
|
+
},
|
|
40600
|
+
staggerMs: nextForceGapMs,
|
|
40601
|
+
concurrency
|
|
40602
|
+
});
|
|
40292
40603
|
}
|
|
40293
40604
|
};
|
|
40294
40605
|
//#endregion
|
|
@@ -41348,7 +41659,7 @@ const queryParam = (req, key) => {
|
|
|
41348
41659
|
//#endregion
|
|
41349
41660
|
//#region src/transport/http/routes/status.ts
|
|
41350
41661
|
function handleStatus(services, req, res) {
|
|
41351
|
-
const { getConfig, bin, store, pool, catalog, auth, poolAuth, adapter, translation, lastRun } = services;
|
|
41662
|
+
const { getConfig, bin, store, pool, quota, catalog, auth, poolAuth, adapter, translation, lastRun } = services;
|
|
41352
41663
|
const { version: versionCache, dormantReason } = services.status;
|
|
41353
41664
|
runRoute(res, async () => {
|
|
41354
41665
|
const cfg = getConfig();
|
|
@@ -41373,6 +41684,7 @@ function handleStatus(services, req, res) {
|
|
|
41373
41684
|
auth: auth.status(),
|
|
41374
41685
|
poolAuth: poolAuth.status(),
|
|
41375
41686
|
pool: poolData,
|
|
41687
|
+
quotaRefreshing: typeof quota?.refreshingAccounts === "function" ? quota.refreshingAccounts() : [],
|
|
41376
41688
|
catalog: {
|
|
41377
41689
|
source: cat.source,
|
|
41378
41690
|
count: cat.models.length,
|
|
@@ -41642,7 +41954,8 @@ function handlePoolRefreshQuota(services, req, res) {
|
|
|
41642
41954
|
const body = await readBody(req);
|
|
41643
41955
|
const id = typeof body.id === "string" ? body.id : "";
|
|
41644
41956
|
const key = id || "__all__";
|
|
41645
|
-
|
|
41957
|
+
const alreadyRunning = quotaRefreshInFlight.has(key);
|
|
41958
|
+
if (!alreadyRunning) {
|
|
41646
41959
|
const work = (async () => {
|
|
41647
41960
|
if (id) {
|
|
41648
41961
|
const acc = pool.getAccount(id);
|
|
@@ -41664,6 +41977,7 @@ function handlePoolRefreshQuota(services, req, res) {
|
|
|
41664
41977
|
sendJson(res, 200, {
|
|
41665
41978
|
ok: true,
|
|
41666
41979
|
pending: true,
|
|
41980
|
+
alreadyRunning,
|
|
41667
41981
|
pool: pool.getPoolData()
|
|
41668
41982
|
});
|
|
41669
41983
|
});
|
|
@@ -42854,7 +43168,7 @@ function apply(ctx, entryConfig = {}) {
|
|
|
42854
43168
|
}
|
|
42855
43169
|
const currentBin = bin();
|
|
42856
43170
|
if (!currentBin) {
|
|
42857
|
-
services.status.dormantReason =
|
|
43171
|
+
services.status.dormantReason = agyNotInstalledMessage(getConfig());
|
|
42858
43172
|
log("dormant: agy binary not found");
|
|
42859
43173
|
return;
|
|
42860
43174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agy-link",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.40",
|
|
4
4
|
"description": "Google Antigravity (agy CLI) models for DeepSeek Harness — stream Gemini/Claude/GPT-OSS subscriptions into DSH with thinking, tool activity, token usage and in-GUI Google OAuth login.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|