dsh-agy-link 0.6.1 → 0.6.2
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 +18 -0
- package/dist/index.js +94 -41
- package/docs/spec-account-pool.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2 (2026-11-06)
|
|
4
|
+
|
|
5
|
+
### English
|
|
6
|
+
|
|
7
|
+
- **Fix(quota): Argon is weekly-only when the backend folds it into the Gemini bucket, and `/agy clear-cooldown` can now lift a quota bench (issue #77).** (thanks @hjwsm1989, #78)
|
|
8
|
+
- The model-level fallback filed Argon's **weekly** `quotaInfo` under `remainingFraction` (the 5-hour slot), so the 10% 5h floor benched accounts whose weekly quota was still above the 5% weekly floor — the `5% < weekly ≤ 10%` dead band. Argon without a backend 5-hour window is now written to `weeklyFraction/weeklyResetTime` only (an existing mis-filled row is healed on the next poll).
|
|
9
|
+
- The "no account can serve" error now reports the real reason via `pool.explainIneligibility()` (`disabled` / `auth` / `cooldown` / `quota`) and suggests a remedy that works; `/agy clear-cooldown` also lifts the proactive low-quota bench for the cached snapshot (`quotaGateClearedAt`), re-arming as soon as a poll writes fresher data.
|
|
10
|
+
- Retired Argon groups release their cooldown again: the dedicated-group decision uses the summary alone, not the synthesized model row that made the `else` branch unreachable.
|
|
11
|
+
|
|
12
|
+
### 中文
|
|
13
|
+
|
|
14
|
+
- **修复(quota):后端把 Argon 折进 Gemini 桶时按「仅周额度」处理,且 `/agy clear-cooldown` 现在能解除配额停摆(issue #77)。**(感谢 @hjwsm1989,#78)
|
|
15
|
+
- 模型级回退把 Argon 的**周** `quotaInfo` 写进 `remainingFraction`(5 小时槽),于是 10% 的 5h 下限会误伤周额度仍高于 5% 下限的账号(`5% < weekly ≤ 10%` 死区)。现在没有后端 5 小时窗口的 Argon 只写 `weeklyFraction/weeklyResetTime`,并在下次轮询时修复已被误填的行。
|
|
16
|
+
- 「无可用账号」错误改用 `pool.explainIneligibility()` 报告真实原因(`disabled`/`auth`/`cooldown`/`quota`)并给出有效建议;`/agy clear-cooldown` 会同时解除针对当前缓存快照的主动低配额停摆(`quotaGateClearedAt`),一旦轮询写入更新数据即自动重新生效。
|
|
17
|
+
- 退役的 Argon 组重新能释放冷却:专用组判定只看 summary,不再被模型回退合成出来的行挡住。
|
|
18
|
+
|
|
19
|
+
**Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.6.1...v0.6.2
|
|
20
|
+
|
|
3
21
|
## 0.6.1 (2026-11-06)
|
|
4
22
|
|
|
5
23
|
### English
|
package/dist/index.js
CHANGED
|
@@ -4359,6 +4359,7 @@ var AccountPoolManager = class {
|
|
|
4359
4359
|
if (acc.cooldowns === void 0 || acc.cooldowns === null) acc.cooldowns = {};
|
|
4360
4360
|
if (acc.quotas === void 0 || acc.quotas === null) acc.quotas = {};
|
|
4361
4361
|
if (acc.enabled === void 0) acc.enabled = true;
|
|
4362
|
+
if (acc.quotaGateClearedAt !== void 0 && (typeof acc.quotaGateClearedAt !== "object" || acc.quotaGateClearedAt === null)) acc.quotaGateClearedAt = void 0;
|
|
4362
4363
|
for (const [fam, cd] of Object.entries(acc.cooldowns)) if (cd && cd.reason === "agy run aborted by caller") delete acc.cooldowns[fam];
|
|
4363
4364
|
}
|
|
4364
4365
|
return {
|
|
@@ -4786,26 +4787,51 @@ var AccountPoolManager = class {
|
|
|
4786
4787
|
this.persist();
|
|
4787
4788
|
}
|
|
4788
4789
|
/**
|
|
4789
|
-
*
|
|
4790
|
+
* True when a family's cached quota snapshot benches the account.
|
|
4791
|
+
*
|
|
4792
|
+
* A user-visible `clearCooldown(..., includeQuotaBench = true)` records the
|
|
4793
|
+
* `updatedAt` of the snapshot it overrode; the gate stays off only while the
|
|
4794
|
+
* cached row is no newer than that stamp, so a fresh poll always re-arms it.
|
|
4790
4795
|
*/
|
|
4791
|
-
|
|
4792
|
-
if (!acc.enabled || acc.authRequired) return false;
|
|
4793
|
-
const cd = acc.cooldowns?.[family];
|
|
4794
|
-
if (cd && cd.cooldownUntil > now) return false;
|
|
4796
|
+
isQuotaBenched(acc, family, now) {
|
|
4795
4797
|
const quota = acc.quotas?.[family];
|
|
4796
|
-
if (quota
|
|
4798
|
+
if (!quota) return false;
|
|
4799
|
+
const clearedAt = acc.quotaGateClearedAt?.[family];
|
|
4800
|
+
if (clearedAt !== void 0 && (quota.updatedAt ?? 0) <= clearedAt) return false;
|
|
4801
|
+
if (typeof quota.remainingFraction === "number" && quota.remainingFraction <= .1) {
|
|
4797
4802
|
if (quota.resetTime) {
|
|
4798
4803
|
const resetMs = Date.parse(quota.resetTime);
|
|
4799
|
-
if (Number.isNaN(resetMs) || resetMs > now) return
|
|
4800
|
-
} else return
|
|
4804
|
+
if (Number.isNaN(resetMs) || resetMs > now) return true;
|
|
4805
|
+
} else return true;
|
|
4801
4806
|
}
|
|
4802
|
-
if (
|
|
4807
|
+
if (typeof quota.weeklyFraction === "number" && quota.weeklyFraction <= .05) {
|
|
4803
4808
|
if (quota.weeklyResetTime) {
|
|
4804
4809
|
const resetMs = Date.parse(quota.weeklyResetTime);
|
|
4805
|
-
if (Number.isNaN(resetMs) || resetMs > now) return
|
|
4806
|
-
} else return
|
|
4810
|
+
if (Number.isNaN(resetMs) || resetMs > now) return true;
|
|
4811
|
+
} else return true;
|
|
4807
4812
|
}
|
|
4808
|
-
return
|
|
4813
|
+
return false;
|
|
4814
|
+
}
|
|
4815
|
+
/**
|
|
4816
|
+
* Why this account cannot serve `family` right now, or null when it can.
|
|
4817
|
+
*
|
|
4818
|
+
* Exists so callers can report the ACTUAL blocker: quota rotation used to be
|
|
4819
|
+
* folded into "in cooldown", which pointed users at `/agy clear-cooldown` for
|
|
4820
|
+
* a state that command did not touch.
|
|
4821
|
+
*/
|
|
4822
|
+
explainIneligibility(acc, family, now = Date.now()) {
|
|
4823
|
+
if (!acc.enabled) return "disabled";
|
|
4824
|
+
if (acc.authRequired) return "auth";
|
|
4825
|
+
const cd = acc.cooldowns?.[family];
|
|
4826
|
+
if (cd && cd.cooldownUntil > now) return "cooldown";
|
|
4827
|
+
if (this.isQuotaBenched(acc, family, now)) return "quota";
|
|
4828
|
+
return null;
|
|
4829
|
+
}
|
|
4830
|
+
/**
|
|
4831
|
+
* Check whether an account is eligible to serve requests for the given family.
|
|
4832
|
+
*/
|
|
4833
|
+
isAccountEligible(acc, family, now = Date.now()) {
|
|
4834
|
+
return this.explainIneligibility(acc, family, now) === null;
|
|
4809
4835
|
}
|
|
4810
4836
|
/**
|
|
4811
4837
|
* Returns the currently active and healthy account ID.
|
|
@@ -4908,7 +4934,8 @@ var AccountPoolManager = class {
|
|
|
4908
4934
|
const isExhausted5h = typeof info.remainingFraction === "number" && info.remainingFraction <= .1 && (!info.resetTime || Number.isNaN(Date.parse(info.resetTime)) || Date.parse(info.resetTime) > now);
|
|
4909
4935
|
const isExhaustedWeekly = typeof info.weeklyFraction === "number" && info.weeklyFraction <= .05 && (!info.weeklyResetTime || Number.isNaN(Date.parse(info.weeklyResetTime)) || Date.parse(info.weeklyResetTime) > now);
|
|
4910
4936
|
if (isExhausted5h || isExhaustedWeekly) {
|
|
4911
|
-
|
|
4937
|
+
const clearedAt = acc.quotaGateClearedAt?.[famKey];
|
|
4938
|
+
if (!(clearedAt !== void 0 && (info.updatedAt ?? 0) <= clearedAt) && (this.data.activeAccountIds?.[famKey] === id || this.data.lastActiveAccountId === id)) this.advanceAccount(id, famKey);
|
|
4912
4939
|
}
|
|
4913
4940
|
}
|
|
4914
4941
|
this.persist();
|
|
@@ -4988,18 +5015,36 @@ var AccountPoolManager = class {
|
|
|
4988
5015
|
acc.dedicatedGroups = acc.dedicatedGroups.filter((f) => f !== family);
|
|
4989
5016
|
this.persist();
|
|
4990
5017
|
}
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
5018
|
+
/**
|
|
5019
|
+
* Reset cooldown timers.
|
|
5020
|
+
*
|
|
5021
|
+
* `includeQuotaBench` (set by the user-facing `/agy clear-cooldown` command
|
|
5022
|
+
* and its HTTP twin) ALSO lifts the proactive low-quota rotation for the
|
|
5023
|
+
* cached snapshot. The override records that snapshot's `updatedAt`, so the
|
|
5024
|
+
* safety gate re-arms as soon as a poll produces fresher data. Internal
|
|
5025
|
+
* callers (orphan release, CLI quota cleanup) leave it off: they only mean to
|
|
5026
|
+
* drop a 429 timer.
|
|
5027
|
+
*/
|
|
5028
|
+
clearCooldown(id, family, includeQuotaBench = false) {
|
|
5029
|
+
const now = Date.now();
|
|
5030
|
+
const clearOne = (acc) => {
|
|
4999
5031
|
acc.cooldowns ??= {};
|
|
5000
5032
|
if (family) delete acc.cooldowns[family];
|
|
5001
5033
|
else acc.cooldowns = {};
|
|
5002
|
-
|
|
5034
|
+
if (!includeQuotaBench) return;
|
|
5035
|
+
const families = family ? [family] : Object.keys(acc.quotas ?? {});
|
|
5036
|
+
if (families.length === 0) return;
|
|
5037
|
+
acc.quotaGateClearedAt ??= {};
|
|
5038
|
+
for (const fam of families) {
|
|
5039
|
+
const updatedAt = acc.quotas?.[fam]?.updatedAt;
|
|
5040
|
+
acc.quotaGateClearedAt[fam] = Math.max(now, updatedAt ?? 0);
|
|
5041
|
+
}
|
|
5042
|
+
};
|
|
5043
|
+
if (id) {
|
|
5044
|
+
const acc = this.getAccount(id);
|
|
5045
|
+
if (!acc) return;
|
|
5046
|
+
clearOne(acc);
|
|
5047
|
+
} else for (const acc of this.data.accounts) clearOne(acc);
|
|
5003
5048
|
this.persist();
|
|
5004
5049
|
}
|
|
5005
5050
|
/**
|
|
@@ -5077,6 +5122,8 @@ var AccountPoolManager = class {
|
|
|
5077
5122
|
if (cd && cd.cooldownUntil > now) bump(cd.cooldownUntil);
|
|
5078
5123
|
const quota = acc.quotas?.[family];
|
|
5079
5124
|
if (quota === void 0) continue;
|
|
5125
|
+
const clearedAt = acc.quotaGateClearedAt?.[family];
|
|
5126
|
+
if (clearedAt !== void 0 && (quota.updatedAt ?? 0) <= clearedAt) continue;
|
|
5080
5127
|
const drained5h = typeof quota.remainingFraction === "number" && quota.remainingFraction <= .1 && typeof quota.resetTime === "string" && Date.parse(quota.resetTime) > now;
|
|
5081
5128
|
const drainedWeekly = typeof quota.weeklyFraction === "number" && quota.weeklyFraction <= .05 && typeof quota.weeklyResetTime === "string" && Date.parse(quota.weeklyResetTime) > now;
|
|
5082
5129
|
if (drained5h || drainedWeekly) bump(this.nextQuotaResetAt(acc, family));
|
|
@@ -31406,7 +31453,9 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31406
31453
|
const allAccounts = pool.getAccounts();
|
|
31407
31454
|
const accounts = allAccounts.filter((a) => a.enabled);
|
|
31408
31455
|
const disabled = allAccounts.length - accounts.length;
|
|
31409
|
-
const
|
|
31456
|
+
const reasons = accounts.map((a) => typeof pool.explainIneligibility === "function" ? pool.explainIneligibility(a, family) : pool.isAccountEligible(a, family) ? null : "cooldown");
|
|
31457
|
+
const cooling = reasons.filter((r) => r === "cooldown").length;
|
|
31458
|
+
const quotaBlocked = reasons.filter((r) => r === "quota").length;
|
|
31410
31459
|
const signedOut = accounts.filter((a) => a.authRequired === true).length;
|
|
31411
31460
|
const countdown = pool.getEarliestAvailableCountdown?.(family) ?? pool.getEarliestResetCountdown(family);
|
|
31412
31461
|
if (countdown !== null && countdown > 0 && countdown <= 2e4) {
|
|
@@ -31420,13 +31469,14 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31420
31469
|
else {
|
|
31421
31470
|
const details = [];
|
|
31422
31471
|
if (cooling > 0) details.push(`${cooling} in cooldown`);
|
|
31472
|
+
if (quotaBlocked > 0) details.push(`${quotaBlocked} quota-exhausted`);
|
|
31423
31473
|
if (signedOut > 0) details.push(`${signedOut} signed out`);
|
|
31424
31474
|
if (disabled > 0) details.push(`${disabled} disabled`);
|
|
31425
31475
|
const detailStr = details.length > 0 ? ` (${details.join(", ")})` : "";
|
|
31426
31476
|
why = `no account can serve ${family} right now${detailStr}`;
|
|
31427
31477
|
}
|
|
31428
31478
|
const waitStr = countdown !== null && countdown > 0 ? ` (earliest reset in ${Math.ceil(countdown / 1e3)}s)` : "";
|
|
31429
|
-
throw new LlmError(`All Antigravity accounts are unavailable: ${why}${waitStr}. Add an account, wait for reset, or run /agy clear-cooldown
|
|
31479
|
+
throw new LlmError(`All Antigravity accounts are unavailable: ${why}${waitStr}. ${quotaBlocked > 0 && cooling === 0 ? "Add an account, wait for the quota reset, or run /agy clear-cooldown to override the current quota snapshot." : "Add an account, wait for reset, or run /agy clear-cooldown."}`, Err.AGY_ERROR);
|
|
31430
31480
|
}
|
|
31431
31481
|
}
|
|
31432
31482
|
}
|
|
@@ -33001,7 +33051,7 @@ const HELP$1 = [
|
|
|
33001
33051
|
"- `/agy enable-account <id>` — enable an account slot",
|
|
33002
33052
|
"- `/agy disable-account <id>` — disable an account slot (skips in rotation)",
|
|
33003
33053
|
"- `/agy refresh-quota` — query Google backend for fresh quota %",
|
|
33004
|
-
"- `/agy clear-cooldown` — reset cooldown timers
|
|
33054
|
+
"- `/agy clear-cooldown` — reset cooldown timers (and any active low-quota bench)",
|
|
33005
33055
|
"- `/agy remove-account <id>` — delete an account slot",
|
|
33006
33056
|
"- `/agy auth` — Google login for the primary account (opens the browser)",
|
|
33007
33057
|
"- `/agy auth-code <code>` — finish login by pasting the code (fallback)",
|
|
@@ -33088,8 +33138,8 @@ async function handle$1(deps, raw, invocation) {
|
|
|
33088
33138
|
if (sub === "clear-cooldown") {
|
|
33089
33139
|
const pool = deps.pool?.();
|
|
33090
33140
|
if (!pool) return err$1("Account pool not available");
|
|
33091
|
-
pool.clearCooldown(arg || void 0);
|
|
33092
|
-
return ok$1("Cleared cooldown timers.");
|
|
33141
|
+
pool.clearCooldown(arg || void 0, void 0, true);
|
|
33142
|
+
return ok$1("Cleared cooldown timers and any active low-quota bench (until the next quota refresh).");
|
|
33093
33143
|
}
|
|
33094
33144
|
if (sub === "remove-account") {
|
|
33095
33145
|
if (!arg) return err$1("usage: /agy remove-account <id>");
|
|
@@ -35588,18 +35638,22 @@ var QuotaService = class {
|
|
|
35588
35638
|
});
|
|
35589
35639
|
const isStale = stale5hFamilies.has(fam);
|
|
35590
35640
|
if (!familyQuotas[fam]) {
|
|
35591
|
-
|
|
35641
|
+
if (fam === "argon") familyQuotas.argon = {
|
|
35642
|
+
...account.quotas.argon ?? {},
|
|
35643
|
+
remainingFraction: void 0,
|
|
35644
|
+
resetTime: void 0,
|
|
35645
|
+
weeklyFraction: remaining,
|
|
35646
|
+
weeklyResetTime: resetTime,
|
|
35647
|
+
updatedAt: now
|
|
35648
|
+
};
|
|
35649
|
+
else familyQuotas[fam] = pickFamilyQuota(account.quotas[fam], {
|
|
35592
35650
|
remainingFraction: remaining,
|
|
35593
35651
|
resetTime,
|
|
35594
35652
|
updatedAt: now
|
|
35595
35653
|
}, summaryGroups.length > 0);
|
|
35596
|
-
if (fam === "argon" && familyQuotas[fam].weeklyFraction === void 0) {
|
|
35597
|
-
familyQuotas[fam].weeklyFraction = remaining;
|
|
35598
|
-
familyQuotas[fam].weeklyResetTime = resetTime;
|
|
35599
|
-
}
|
|
35600
35654
|
} else {
|
|
35601
35655
|
const familyQuota = familyQuotas[fam];
|
|
35602
|
-
if (sameQuotaWindow(resetTime, familyQuota.weeklyResetTime) && !sameQuotaWindow(resetTime, familyQuota.resetTime)) {
|
|
35656
|
+
if (fam === "argon" && familyQuota.resetTime === void 0 || sameQuotaWindow(resetTime, familyQuota.weeklyResetTime) && !sameQuotaWindow(resetTime, familyQuota.resetTime)) {
|
|
35603
35657
|
if (remaining < (familyQuota.weeklyFraction ?? 1)) {
|
|
35604
35658
|
familyQuota.weeklyFraction = remaining;
|
|
35605
35659
|
familyQuota.weeklyResetTime = resetTime;
|
|
@@ -35622,18 +35676,17 @@ var QuotaService = class {
|
|
|
35622
35676
|
if (familyQuotas[fam]) familyQuotas[fam].models = list;
|
|
35623
35677
|
}
|
|
35624
35678
|
if (summaryGroups.length > 0) {
|
|
35625
|
-
if (summaryHasArgonGroup(summaryGroups)
|
|
35679
|
+
if (summaryHasArgonGroup(summaryGroups)) this.pool.noteDedicatedGroup(account.id, "argon");
|
|
35626
35680
|
else {
|
|
35627
|
-
this.pool.
|
|
35681
|
+
const groupSeenBefore = this.pool.hasDedicatedGroup(account.id, "argon");
|
|
35682
|
+
if (familyQuotas.argon === void 0) this.pool.clearQuotaFamily(account.id, "argon");
|
|
35628
35683
|
if (shouldReleaseOrphanedCooldown({
|
|
35629
35684
|
summaryAuthoritative: true,
|
|
35630
35685
|
groupPresent: false,
|
|
35631
|
-
groupSeenBefore
|
|
35686
|
+
groupSeenBefore,
|
|
35632
35687
|
hasCooldown: account.cooldowns?.argon !== void 0
|
|
35633
|
-
}))
|
|
35634
|
-
|
|
35635
|
-
this.pool.clearCooldown(account.id, "argon");
|
|
35636
|
-
}
|
|
35688
|
+
})) this.pool.clearCooldown(account.id, "argon");
|
|
35689
|
+
this.pool.forgetDedicatedGroup(account.id, "argon");
|
|
35637
35690
|
}
|
|
35638
35691
|
}
|
|
35639
35692
|
this.pool.updateAccountQuotas(account.id, familyQuotas, email);
|
|
@@ -37708,7 +37761,7 @@ function apply(ctx, entryConfig = {}) {
|
|
|
37708
37761
|
const body = await readBody(req);
|
|
37709
37762
|
const id = typeof body.id === "string" ? body.id : void 0;
|
|
37710
37763
|
const family = typeof body.family === "string" ? body.family : void 0;
|
|
37711
|
-
pool.clearCooldown(id, family);
|
|
37764
|
+
pool.clearCooldown(id, family, true);
|
|
37712
37765
|
sendJson(res, 200, {
|
|
37713
37766
|
ok: true,
|
|
37714
37767
|
pool: pool.getPoolData()
|
|
@@ -226,4 +226,4 @@ All host routes are namespaced under `/plugins/agy-link/`:
|
|
|
226
226
|
- `/agy add-account [alias]`: Start terminal-guided OAuth login for a new account slot.
|
|
227
227
|
- `/agy refresh-quota [id]`: Fetch fresh quota percentages from Google backend.
|
|
228
228
|
- `/agy remove-account <id>`: Delete an account slot.
|
|
229
|
-
- `/agy clear-cooldown [id]`: Manually reset cooldown timers for accounts.
|
|
229
|
+
- `/agy clear-cooldown [id]`: Manually reset cooldown timers for accounts. It also lifts the proactive low-quota bench for the cached quota snapshot; the bench re-arms as soon as a quota refresh writes newer data.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agy-link",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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",
|