dsh-agy-link 0.6.16 → 0.6.18
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 +34 -0
- package/README.md +3 -1
- package/dist/cli-image.mjs +95 -26
- package/dist/client.js +8 -0
- package/dist/index.js +191 -34
- package/docs/README.en.md +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.18 (2026-11-11)
|
|
4
|
+
|
|
5
|
+
### English
|
|
6
|
+
|
|
7
|
+
- **Fix(catalog): the model picker shows the pool-wide model set, and dispatch routes Argon to an account that actually has it.** (thanks @Ronnoc, #95)
|
|
8
|
+
- The picker now exposes the **union** of models across enabled accounts (fallback + discovered + quota-reported), so Argon is visible whenever *some* account in the pool can serve it — not only when the currently active account can. Listing stays synchronous and side-effect-free (no probing).
|
|
9
|
+
- **Model resolution is pure again**: an earlier revision switched the active account inside `resolveModel()`; that now happens only at turn dispatch, so rendering the picker or inspecting a model can never rewrite `lastActiveAccountId`.
|
|
10
|
+
- Eligibility gained an explicit `unsupported` reason (distinct from `quota`/`cooldown`): when no enabled account has access to the family, the error says so and the hint no longer suggests a quota fix. Argon requests route via family eligibility (accounts without Argon are `unsupported` for that family).
|
|
11
|
+
|
|
12
|
+
### 中文
|
|
13
|
+
|
|
14
|
+
- **修复(目录):模型选单展示号池全集,Argon 请求路由到真正具备权限的账号。**(感谢 @Ronnoc,#95)
|
|
15
|
+
- 选单合并所有启用账号的模型(回退 + 发现 + 配额上报),只要池中有账号支持 Argon 就可见;列举仍为同步、无副作用(不探测)。
|
|
16
|
+
- **模型解析恢复纯读**:早期修订在 `resolveModel()` 里切换活动账号,现只在**请求派发**时切换,渲染选单/查看模型不会再改 `lastActiveAccountId`。
|
|
17
|
+
- 资格判定新增 `unsupported` 原因(区别于 `quota`/`cooldown`):全池都无该族权限时错误会明确说明,提示也不再误导为配额问题;Argon 请求按族资格路由。
|
|
18
|
+
|
|
19
|
+
## 0.6.17 (2026-11-11)
|
|
20
|
+
|
|
21
|
+
### English
|
|
22
|
+
|
|
23
|
+
- **Feat(auth): reauthenticate an existing pool account in place — `/agy auth <id|alias|email>`, final result via `/agy auth-status`.** (thanks @Ronnoc, #96)
|
|
24
|
+
- When a secondary account's stored credential is missing or invalid, you no longer have to remove and recreate it (losing its configuration and local state): the browser flow writes into a staging slot, verifies the Google identity, and only then **atomically** moves the new token into that account's isolated `.gemini/antigravity-cli` dir (mode 0600).
|
|
25
|
+
- Identity checks before the swap: the account must be isolated (not the system-HOME primary), the verified email must match the account's recorded email when one exists, and no **other** pool account may already own that email. Missing email, missing refresh token or a mismatched/duplicate identity aborts with `identity_unverified` / `identity_mismatch` and leaves the old credential untouched.
|
|
26
|
+
- The flow is stale-safe (a superseded flow never writes), clears `authRequired`, records the address, and refreshes that account's quota. No credential value is ever printed.
|
|
27
|
+
|
|
28
|
+
### 中文
|
|
29
|
+
|
|
30
|
+
- **新增(auth):原地重登已有账号——`/agy auth <ID|别名|邮箱>`,最终结果用 `/agy auth-status` 查看。**(感谢 @Ronnoc,#96)
|
|
31
|
+
- 副账号凭据缺失/失效时,不必再「删除后重建」(会丢配置与本地状态):浏览器流程先写入 staging 槽位并校验 Google 身份,再把新 token **原子地** rename 到该账号独立的 `.gemini/antigravity-cli`(0600 权限)。
|
|
32
|
+
- 替换前的身份校验:必须是隔离账号(不是 system-HOME 主账号);已记录邮箱的账号要求邮箱一致;同一邮箱不得属于池中**其他**账号。缺邮箱/缺 refresh token/身份不符或重复 → `identity_unverified` / `identity_mismatch`,旧凭据保持不动。
|
|
33
|
+
- 流程具备「旧流程不写盘」的过期保护,成功后清除 `authRequired`、记录邮箱并刷新该账号配额;任何输出都不打印凭据值。
|
|
34
|
+
|
|
35
|
+
**Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.6.16...v0.6.17
|
|
36
|
+
|
|
3
37
|
## 0.6.16 (2026-11-10)
|
|
4
38
|
|
|
5
39
|
### English
|
package/README.md
CHANGED
|
@@ -138,7 +138,9 @@ dsh plugin --profile web add dsh-agy-link
|
|
|
138
138
|
|
|
139
139
|
# 3. 登录与添加账号:
|
|
140
140
|
# 方式 A:点击顶部导航栏的 "AGY (n)" 徽标,点击 "➕ 添加账号",浏览器一键登录;
|
|
141
|
-
# 方式 B:输入框执行 /agy auth
|
|
141
|
+
# 方式 B:输入框执行 /agy auth 为主账号发起登录;执行 /agy pool 查看账号 ID,
|
|
142
|
+
# 再用 /agy auth <账号 ID> 重新登录已有的备用账号(也支持完整别名或邮箱)。
|
|
143
|
+
# 授权后 30 秒内执行 /agy auth-status 查看最终登录结果。
|
|
142
144
|
|
|
143
145
|
# 4. 在 /model 选择器中挑选 Antigravity 模型,立即开启对话!
|
|
144
146
|
```
|
package/dist/cli-image.mjs
CHANGED
|
@@ -1295,6 +1295,11 @@ function formatBytes(n) {
|
|
|
1295
1295
|
}
|
|
1296
1296
|
//#endregion
|
|
1297
1297
|
//#region src/common/pool-types.ts
|
|
1298
|
+
/** Check if a model identifier belongs to the Gemini 4 Argon family. */
|
|
1299
|
+
function isArgonModel(modelId) {
|
|
1300
|
+
if (!modelId) return false;
|
|
1301
|
+
return modelId.trim().toLowerCase().includes("argon");
|
|
1302
|
+
}
|
|
1298
1303
|
/**
|
|
1299
1304
|
* Map a model slug to its backend quota counter family.
|
|
1300
1305
|
*
|
|
@@ -1312,6 +1317,24 @@ function modelFamilyOf(modelId) {
|
|
|
1312
1317
|
if (id.startsWith("gpt-") || id.startsWith("openai/") || id.includes("gpt-oss")) return "openai";
|
|
1313
1318
|
return "unknown";
|
|
1314
1319
|
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Determine whether a managed account has confirmed access to the Gemini 4 Argon family.
|
|
1322
|
+
*
|
|
1323
|
+
* An account qualifies for Argon when:
|
|
1324
|
+
* 1. It carries an authoritative Argon quota bucket.
|
|
1325
|
+
* 2. It has a dedicated Argon group recorded by the pool.
|
|
1326
|
+
* 3. Its Google per-model quota breakdown includes an Argon model.
|
|
1327
|
+
* 4. Or its discovered catalog includes Argon (when no negative quota breakdown is present).
|
|
1328
|
+
*/
|
|
1329
|
+
function accountHasArgon(acc, pool, catalog) {
|
|
1330
|
+
if (!acc) return false;
|
|
1331
|
+
if (acc.quotas?.argon !== void 0) return true;
|
|
1332
|
+
if (pool && typeof pool.hasDedicatedGroup === "function" && pool.hasDedicatedGroup(acc.id, "argon")) return true;
|
|
1333
|
+
if (acc.quotas?.google?.models?.some((m) => isArgonModel(m.modelId))) return true;
|
|
1334
|
+
if (Array.isArray(acc.quotas?.google?.models)) return false;
|
|
1335
|
+
if (catalog && catalog.source === "discovered") return catalog.models?.some((m) => isArgonModel(m.id)) ?? false;
|
|
1336
|
+
return false;
|
|
1337
|
+
}
|
|
1315
1338
|
function defaultPoolData() {
|
|
1316
1339
|
return {
|
|
1317
1340
|
version: 1,
|
|
@@ -2628,23 +2651,10 @@ var EventMapper = class {
|
|
|
2628
2651
|
};
|
|
2629
2652
|
//#endregion
|
|
2630
2653
|
//#region src/host/models.ts
|
|
2631
|
-
/** Check
|
|
2632
|
-
function
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
/**
|
|
2636
|
-
* Determine whether a managed account has confirmed access to the Gemini 4 Argon family.
|
|
2637
|
-
* Argon is exclusive to paid Pro/Ultra plans and returns a separate quota bucket
|
|
2638
|
-
* and/or dedicated model list from agy cli. Free/standard accounts do not have Argon.
|
|
2639
|
-
*/
|
|
2640
|
-
function accountHasArgon(acc, pool, catalog) {
|
|
2641
|
-
if (!acc) return false;
|
|
2642
|
-
if (acc.quotas?.argon !== void 0) return true;
|
|
2643
|
-
if (pool && typeof pool.hasDedicatedGroup === "function" && pool.hasDedicatedGroup(acc.id, "argon")) return true;
|
|
2644
|
-
if (acc.quotas?.google?.models?.some((m) => isArgonModel(m.modelId))) return true;
|
|
2645
|
-
if (Array.isArray(acc.quotas?.google?.models)) return false;
|
|
2646
|
-
if (catalog && catalog.source === "discovered") return catalog.models.some((m) => isArgonModel(m.id));
|
|
2647
|
-
return false;
|
|
2654
|
+
/** Check whether any enabled account in the pool has confirmed access to Argon. */
|
|
2655
|
+
function poolHasArgon(pool, catalog) {
|
|
2656
|
+
if (!pool) return false;
|
|
2657
|
+
return pool.getAccounts().filter((a) => a.enabled).some((acc) => accountHasArgon(acc, pool, catalog?.get(acc.id)));
|
|
2648
2658
|
}
|
|
2649
2659
|
/** Parse `agy models` stdout: JSON shapes first, then two-column text. */
|
|
2650
2660
|
function parseModelsOutput(stdout) {
|
|
@@ -2831,6 +2841,7 @@ function sanitizeCatalogEntries(models) {
|
|
|
2831
2841
|
}
|
|
2832
2842
|
var ModelCatalog = class ModelCatalog {
|
|
2833
2843
|
discover;
|
|
2844
|
+
fallbackDefs;
|
|
2834
2845
|
ttlMs;
|
|
2835
2846
|
onUpdate;
|
|
2836
2847
|
current;
|
|
@@ -2846,6 +2857,7 @@ var ModelCatalog = class ModelCatalog {
|
|
|
2846
2857
|
lastAttemptAt = 0;
|
|
2847
2858
|
constructor(discover, fallbackDefs, ttlMs, onUpdate) {
|
|
2848
2859
|
this.discover = discover;
|
|
2860
|
+
this.fallbackDefs = fallbackDefs;
|
|
2849
2861
|
this.ttlMs = ttlMs;
|
|
2850
2862
|
this.onUpdate = onUpdate;
|
|
2851
2863
|
this.current = {
|
|
@@ -2854,6 +2866,51 @@ var ModelCatalog = class ModelCatalog {
|
|
|
2854
2866
|
discoveredAt: 0
|
|
2855
2867
|
};
|
|
2856
2868
|
}
|
|
2869
|
+
/**
|
|
2870
|
+
* Return the complete full set of all known models across fallbacks, base
|
|
2871
|
+
* discovered catalog, per-account discovered catalogs, and quota-reported models.
|
|
2872
|
+
* Nothing is excluded, providing the true superset ("全集") for settings and manual picking.
|
|
2873
|
+
*/
|
|
2874
|
+
getAllKnownModels(accounts = []) {
|
|
2875
|
+
const list = [];
|
|
2876
|
+
const fallbacks = buildFallbackCatalog(this.fallbackDefs);
|
|
2877
|
+
for (const m of fallbacks) list.push(m);
|
|
2878
|
+
for (const m of this.current.models) list.push(m);
|
|
2879
|
+
for (const acc of accounts) {
|
|
2880
|
+
if (!acc.enabled) continue;
|
|
2881
|
+
const cat = this.accountCatalogs.get(acc.id);
|
|
2882
|
+
if (cat) for (const m of cat.models) list.push(m);
|
|
2883
|
+
if (acc.quotas) for (const fam of [
|
|
2884
|
+
"argon",
|
|
2885
|
+
"anthropic",
|
|
2886
|
+
"google"
|
|
2887
|
+
]) {
|
|
2888
|
+
const models = acc.quotas[fam]?.models;
|
|
2889
|
+
if (models?.length) {
|
|
2890
|
+
const raw = models.map((m) => ({
|
|
2891
|
+
slug: m.modelId,
|
|
2892
|
+
label: m.displayName || m.modelId
|
|
2893
|
+
}));
|
|
2894
|
+
for (const m of foldEfforts(raw)) list.push(m);
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
return list;
|
|
2899
|
+
}
|
|
2900
|
+
/**
|
|
2901
|
+
* Return the union of all models available across all pool accounts,
|
|
2902
|
+
* merged with discovered catalogs, per-account quota models, and fallback models.
|
|
2903
|
+
* If any enabled account in the pool has Argon access, Argon is included in the union.
|
|
2904
|
+
*/
|
|
2905
|
+
getUnion(accounts = [], pool) {
|
|
2906
|
+
if (accounts.length === 0 && !pool) return this.current.models;
|
|
2907
|
+
const all = this.getAllKnownModels(accounts);
|
|
2908
|
+
const hasAnyArgon = pool ? poolHasArgon(pool, this) : accounts.some((a) => accountHasArgon(a, pool, this.get(a.id)));
|
|
2909
|
+
return all.filter((entry) => {
|
|
2910
|
+
if (isArgonModel(entry.id) && !hasAnyArgon) return false;
|
|
2911
|
+
return true;
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2857
2914
|
get(accountId) {
|
|
2858
2915
|
if (accountId && this.accountCatalogs.has(accountId)) return this.accountCatalogs.get(accountId);
|
|
2859
2916
|
return this.current;
|
|
@@ -4909,6 +4966,10 @@ var AccountPoolManager = class {
|
|
|
4909
4966
|
}
|
|
4910
4967
|
return false;
|
|
4911
4968
|
}
|
|
4969
|
+
/** Determine whether a managed account has confirmed access to Gemini 4 Argon. */
|
|
4970
|
+
accountHasArgon(acc) {
|
|
4971
|
+
return accountHasArgon(acc, this);
|
|
4972
|
+
}
|
|
4912
4973
|
/**
|
|
4913
4974
|
* Why this account cannot serve `family` right now, or null when it can.
|
|
4914
4975
|
*
|
|
@@ -4919,6 +4980,7 @@ var AccountPoolManager = class {
|
|
|
4919
4980
|
explainIneligibility(acc, family, now = Date.now()) {
|
|
4920
4981
|
if (!acc.enabled) return "disabled";
|
|
4921
4982
|
if (acc.authRequired) return "auth";
|
|
4983
|
+
if (family === "argon" && !this.accountHasArgon(acc)) return "unsupported";
|
|
4922
4984
|
const cd = acc.cooldowns?.[family];
|
|
4923
4985
|
if (cd && cd.cooldownUntil > now) return "cooldown";
|
|
4924
4986
|
if (this.isQuotaBenched(acc, family, now)) return "quota";
|
|
@@ -29544,7 +29606,7 @@ async function acquireCredentialSlot(account, pool, options = {}) {
|
|
|
29544
29606
|
const afterRaw = io.readSlot();
|
|
29545
29607
|
const afterFingerprint = credentialFingerprint(afterRaw);
|
|
29546
29608
|
if (sameCredentialGrant(afterRaw, accountRaw)) {
|
|
29547
|
-
if (afterRaw && afterRaw !== accountRaw) writeFileAtomic(accountFile, afterRaw);
|
|
29609
|
+
if (afterRaw && afterRaw !== accountRaw && readTokenFileRaw(accountFile) === accountRaw) writeFileAtomic(accountFile, afterRaw);
|
|
29548
29610
|
} else if (afterFingerprint !== null) log(`[agy-link] credential slot was replaced during ${account.alias || account.id}'s run — refusing to write a foreign credential into the account file`);
|
|
29549
29611
|
} finally {
|
|
29550
29612
|
try {
|
|
@@ -30980,12 +31042,10 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
30980
31042
|
return activeId ? pool.getAccount(activeId) : void 0;
|
|
30981
31043
|
}
|
|
30982
31044
|
async listModels(_provider) {
|
|
30983
|
-
const
|
|
31045
|
+
const pool = this.deps.pool;
|
|
31046
|
+
const accounts = pool ? pool.getAccounts().filter((a) => a.enabled) : [];
|
|
30984
31047
|
const cfg = this.deps.getConfig();
|
|
30985
|
-
const
|
|
30986
|
-
let models = cat.models;
|
|
30987
|
-
if (!activeAcc || !accountHasArgon(activeAcc, this.deps.pool, cat)) models = models.filter((m) => !isArgonModel(m.id));
|
|
30988
|
-
const { entries, dropped } = sanitizeCatalogEntries(models);
|
|
31048
|
+
const { entries, dropped } = sanitizeCatalogEntries(this.deps.catalog.getUnion(accounts, pool));
|
|
30989
31049
|
if (dropped.length > 0) this.warnOnce("catalog-dupes", "model catalog contained duplicate ids [" + dropped.join(", ") + "] — kept first occurrence so DSH does not drop the whole provider group (INVALID_CATALOG)");
|
|
30990
31050
|
const hidden = new Set(cfg.hiddenModels.map((s) => s.trim()));
|
|
30991
31051
|
return entries.filter((m) => !hidden.has(m.id)).map((m) => ({
|
|
@@ -30996,12 +31056,15 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
30996
31056
|
}));
|
|
30997
31057
|
}
|
|
30998
31058
|
async resolveModel(_provider, model, _signal) {
|
|
31059
|
+
const pool = this.deps.pool;
|
|
30999
31060
|
const activeAcc = this.getActiveAccount();
|
|
31000
31061
|
const cfg = this.deps.getConfig();
|
|
31001
|
-
const
|
|
31062
|
+
const accounts = pool ? pool.getAccounts().filter((a) => a.enabled) : [];
|
|
31002
31063
|
const rawModel = typeof model === "string" ? model.trim() : "";
|
|
31003
31064
|
const cleanId = rawModel !== "" ? rawModel : cfg.defaultModel;
|
|
31004
|
-
const
|
|
31065
|
+
const unionModels = this.deps.catalog.getUnion(accounts, pool);
|
|
31066
|
+
const allModels = this.deps.catalog.getAllKnownModels(accounts);
|
|
31067
|
+
const entry = unionModels.find((m) => m.id === cleanId) ?? allModels.find((m) => m.id === cleanId) ?? findEntry(this.deps.catalog.get(activeAcc?.id), cleanId) ?? findEntry(this.deps.catalog.get(), cleanId);
|
|
31005
31068
|
const rawName = entry ? entry.name : cleanId;
|
|
31006
31069
|
const name = typeof rawName === "string" && rawName.trim() !== "" ? rawName.trim() : cleanId;
|
|
31007
31070
|
const contextWindow = typeof cfg.contextWindowDefault === "number" && cfg.contextWindowDefault > 0 ? cfg.contextWindowDefault : 2e5;
|
|
@@ -31273,6 +31336,9 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31273
31336
|
}
|
|
31274
31337
|
}
|
|
31275
31338
|
if (!account && this.deps.pool) account = this.deps.pool.selectAccount(family) ?? void 0;
|
|
31339
|
+
if (account && this.deps.pool) {
|
|
31340
|
+
if (this.deps.pool.getPoolData().lastActiveAccountId !== account.id) this.deps.pool.setActiveAccount(account.id, family);
|
|
31341
|
+
}
|
|
31276
31342
|
if (this.deps.pool && this.deps.pool.getAccounts().length > 0 && !account) {
|
|
31277
31343
|
if (cfg.autoFallbackModel) {
|
|
31278
31344
|
const familyModel = {
|
|
@@ -31304,6 +31370,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31304
31370
|
const reasons = accounts.map((a) => typeof pool.explainIneligibility === "function" ? pool.explainIneligibility(a, family) : pool.isAccountEligible(a, family) ? null : "cooldown");
|
|
31305
31371
|
const cooling = reasons.filter((r) => r === "cooldown").length;
|
|
31306
31372
|
const quotaBlocked = reasons.filter((r) => r === "quota").length;
|
|
31373
|
+
const unsupported = reasons.filter((r) => r === "unsupported").length;
|
|
31307
31374
|
const signedOut = accounts.filter((a) => a.authRequired === true).length;
|
|
31308
31375
|
const countdown = pool.getEarliestAvailableCountdown?.(family) ?? pool.getEarliestResetCountdown(family);
|
|
31309
31376
|
if (countdown !== null && countdown > 0 && countdown <= 2e4) {
|
|
@@ -31318,13 +31385,15 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31318
31385
|
const details = [];
|
|
31319
31386
|
if (cooling > 0) details.push(`${cooling} in cooldown`);
|
|
31320
31387
|
if (quotaBlocked > 0) details.push(`${quotaBlocked} quota-exhausted`);
|
|
31388
|
+
if (unsupported > 0) details.push(`${unsupported} lack ${family} access`);
|
|
31321
31389
|
if (signedOut > 0) details.push(`${signedOut} signed out`);
|
|
31322
31390
|
if (disabled > 0) details.push(`${disabled} disabled`);
|
|
31323
31391
|
const detailStr = details.length > 0 ? ` (${details.join(", ")})` : "";
|
|
31324
31392
|
why = `no account can serve ${family} right now${detailStr}`;
|
|
31325
31393
|
}
|
|
31326
31394
|
const waitStr = countdown !== null && countdown > 0 ? ` (earliest reset in ${Math.ceil(countdown / 1e3)}s)` : "";
|
|
31327
|
-
|
|
31395
|
+
const hint = unsupported > 0 && quotaBlocked === 0 && cooling === 0 ? `No enabled account has access to ${family} (requires a plan with ${family} enabled).` : 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.";
|
|
31396
|
+
throw new LlmError(`All Antigravity accounts are unavailable: ${why}${waitStr}. ${hint}`, Err.AGY_ERROR);
|
|
31328
31397
|
}
|
|
31329
31398
|
}
|
|
31330
31399
|
}
|
package/dist/client.js
CHANGED
|
@@ -202,6 +202,8 @@ window.__ModuleLoader__.load({
|
|
|
202
202
|
"auth.code.primary_activated": "主账号已登录。",
|
|
203
203
|
"auth.code.account_activated": "账号已添加并激活。",
|
|
204
204
|
"auth.code.missing_code": "请输入授权码。",
|
|
205
|
+
"auth.code.identity_mismatch": "登录的 Google 账号与目标账号不一致,或已属于其他账号。",
|
|
206
|
+
"auth.code.identity_unverified": "无法验证账号身份或获取长期凭据,请重试。",
|
|
205
207
|
"auth.code.request_failed": "请求未完成。请重试。",
|
|
206
208
|
"api.genericError": "操作未完成。请重试。",
|
|
207
209
|
"duration.day": "天",
|
|
@@ -392,6 +394,8 @@ window.__ModuleLoader__.load({
|
|
|
392
394
|
"auth.code.primary_activated": "Primary account signed in.",
|
|
393
395
|
"auth.code.account_activated": "Account added and activated.",
|
|
394
396
|
"auth.code.missing_code": "Enter an authorization code.",
|
|
397
|
+
"auth.code.identity_mismatch": "The Google account does not match the target or belongs to another account.",
|
|
398
|
+
"auth.code.identity_unverified": "Could not verify the identity or obtain a refresh token. Try again.",
|
|
395
399
|
"auth.code.request_failed": "The request did not complete. Try again.",
|
|
396
400
|
"api.genericError": "The operation did not complete. Try again.",
|
|
397
401
|
"duration.day": "d",
|
|
@@ -582,6 +586,8 @@ window.__ModuleLoader__.load({
|
|
|
582
586
|
"auth.code.primary_activated": "Conta principal conectada.",
|
|
583
587
|
"auth.code.account_activated": "Conta adicionada e ativada.",
|
|
584
588
|
"auth.code.missing_code": "Informe um código de autorização.",
|
|
589
|
+
"auth.code.identity_mismatch": "A conta Google não corresponde à conta selecionada ou pertence a outra conta.",
|
|
590
|
+
"auth.code.identity_unverified": "Não foi possível verificar a identidade ou obter uma credencial duradoura. Tente novamente.",
|
|
585
591
|
"auth.code.request_failed": "A solicitação não foi concluída. Tente novamente.",
|
|
586
592
|
"api.genericError": "A operação não foi concluída. Tente novamente.",
|
|
587
593
|
"duration.day": "d",
|
|
@@ -772,6 +778,8 @@ window.__ModuleLoader__.load({
|
|
|
772
778
|
"auth.code.primary_activated": "Cuenta principal conectada.",
|
|
773
779
|
"auth.code.account_activated": "Cuenta añadida y activada.",
|
|
774
780
|
"auth.code.missing_code": "Introduzca un código de autorización.",
|
|
781
|
+
"auth.code.identity_mismatch": "La cuenta de Google no coincide con la cuenta seleccionada o pertenece a otra cuenta.",
|
|
782
|
+
"auth.code.identity_unverified": "No se pudo verificar la identidad u obtener una credencial duradera. Inténtelo de nuevo.",
|
|
775
783
|
"auth.code.request_failed": "La solicitud no se completó. Inténtelo de nuevo.",
|
|
776
784
|
"api.genericError": "La operación no se completó. Inténtelo de nuevo.",
|
|
777
785
|
"duration.day": "d",
|
package/dist/index.js
CHANGED
|
@@ -706,6 +706,11 @@ function resolveConfig(entry, env = process.env, overrides = readOverrides()) {
|
|
|
706
706
|
}
|
|
707
707
|
//#endregion
|
|
708
708
|
//#region src/common/pool-types.ts
|
|
709
|
+
/** Check if a model identifier belongs to the Gemini 4 Argon family. */
|
|
710
|
+
function isArgonModel(modelId) {
|
|
711
|
+
if (!modelId) return false;
|
|
712
|
+
return modelId.trim().toLowerCase().includes("argon");
|
|
713
|
+
}
|
|
709
714
|
/**
|
|
710
715
|
* Map a model slug to its backend quota counter family.
|
|
711
716
|
*
|
|
@@ -724,6 +729,24 @@ function modelFamilyOf(modelId) {
|
|
|
724
729
|
return "unknown";
|
|
725
730
|
}
|
|
726
731
|
/**
|
|
732
|
+
* Determine whether a managed account has confirmed access to the Gemini 4 Argon family.
|
|
733
|
+
*
|
|
734
|
+
* An account qualifies for Argon when:
|
|
735
|
+
* 1. It carries an authoritative Argon quota bucket.
|
|
736
|
+
* 2. It has a dedicated Argon group recorded by the pool.
|
|
737
|
+
* 3. Its Google per-model quota breakdown includes an Argon model.
|
|
738
|
+
* 4. Or its discovered catalog includes Argon (when no negative quota breakdown is present).
|
|
739
|
+
*/
|
|
740
|
+
function accountHasArgon(acc, pool, catalog) {
|
|
741
|
+
if (!acc) return false;
|
|
742
|
+
if (acc.quotas?.argon !== void 0) return true;
|
|
743
|
+
if (pool && typeof pool.hasDedicatedGroup === "function" && pool.hasDedicatedGroup(acc.id, "argon")) return true;
|
|
744
|
+
if (acc.quotas?.google?.models?.some((m) => isArgonModel(m.modelId))) return true;
|
|
745
|
+
if (Array.isArray(acc.quotas?.google?.models)) return false;
|
|
746
|
+
if (catalog && catalog.source === "discovered") return catalog.models?.some((m) => isArgonModel(m.id)) ?? false;
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
727
750
|
* Whether the background quota poller should touch this account at all.
|
|
728
751
|
* Disabled, auth-quarantined and cooldown accounts are skipped so automatic
|
|
729
752
|
* polling never hammers Google endpoints for accounts already known to be
|
|
@@ -2455,23 +2478,10 @@ var EventMapper = class {
|
|
|
2455
2478
|
};
|
|
2456
2479
|
//#endregion
|
|
2457
2480
|
//#region src/host/models.ts
|
|
2458
|
-
/** Check
|
|
2459
|
-
function
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
/**
|
|
2463
|
-
* Determine whether a managed account has confirmed access to the Gemini 4 Argon family.
|
|
2464
|
-
* Argon is exclusive to paid Pro/Ultra plans and returns a separate quota bucket
|
|
2465
|
-
* and/or dedicated model list from agy cli. Free/standard accounts do not have Argon.
|
|
2466
|
-
*/
|
|
2467
|
-
function accountHasArgon(acc, pool, catalog) {
|
|
2468
|
-
if (!acc) return false;
|
|
2469
|
-
if (acc.quotas?.argon !== void 0) return true;
|
|
2470
|
-
if (pool && typeof pool.hasDedicatedGroup === "function" && pool.hasDedicatedGroup(acc.id, "argon")) return true;
|
|
2471
|
-
if (acc.quotas?.google?.models?.some((m) => isArgonModel(m.modelId))) return true;
|
|
2472
|
-
if (Array.isArray(acc.quotas?.google?.models)) return false;
|
|
2473
|
-
if (catalog && catalog.source === "discovered") return catalog.models.some((m) => isArgonModel(m.id));
|
|
2474
|
-
return false;
|
|
2481
|
+
/** Check whether any enabled account in the pool has confirmed access to Argon. */
|
|
2482
|
+
function poolHasArgon(pool, catalog) {
|
|
2483
|
+
if (!pool) return false;
|
|
2484
|
+
return pool.getAccounts().filter((a) => a.enabled).some((acc) => accountHasArgon(acc, pool, catalog?.get(acc.id)));
|
|
2475
2485
|
}
|
|
2476
2486
|
/** Parse `agy models` stdout: JSON shapes first, then two-column text. */
|
|
2477
2487
|
function parseModelsOutput(stdout) {
|
|
@@ -2658,6 +2668,7 @@ function sanitizeCatalogEntries(models) {
|
|
|
2658
2668
|
}
|
|
2659
2669
|
var ModelCatalog = class ModelCatalog {
|
|
2660
2670
|
discover;
|
|
2671
|
+
fallbackDefs;
|
|
2661
2672
|
ttlMs;
|
|
2662
2673
|
onUpdate;
|
|
2663
2674
|
current;
|
|
@@ -2673,6 +2684,7 @@ var ModelCatalog = class ModelCatalog {
|
|
|
2673
2684
|
lastAttemptAt = 0;
|
|
2674
2685
|
constructor(discover, fallbackDefs, ttlMs, onUpdate) {
|
|
2675
2686
|
this.discover = discover;
|
|
2687
|
+
this.fallbackDefs = fallbackDefs;
|
|
2676
2688
|
this.ttlMs = ttlMs;
|
|
2677
2689
|
this.onUpdate = onUpdate;
|
|
2678
2690
|
this.current = {
|
|
@@ -2681,6 +2693,51 @@ var ModelCatalog = class ModelCatalog {
|
|
|
2681
2693
|
discoveredAt: 0
|
|
2682
2694
|
};
|
|
2683
2695
|
}
|
|
2696
|
+
/**
|
|
2697
|
+
* Return the complete full set of all known models across fallbacks, base
|
|
2698
|
+
* discovered catalog, per-account discovered catalogs, and quota-reported models.
|
|
2699
|
+
* Nothing is excluded, providing the true superset ("全集") for settings and manual picking.
|
|
2700
|
+
*/
|
|
2701
|
+
getAllKnownModels(accounts = []) {
|
|
2702
|
+
const list = [];
|
|
2703
|
+
const fallbacks = buildFallbackCatalog(this.fallbackDefs);
|
|
2704
|
+
for (const m of fallbacks) list.push(m);
|
|
2705
|
+
for (const m of this.current.models) list.push(m);
|
|
2706
|
+
for (const acc of accounts) {
|
|
2707
|
+
if (!acc.enabled) continue;
|
|
2708
|
+
const cat = this.accountCatalogs.get(acc.id);
|
|
2709
|
+
if (cat) for (const m of cat.models) list.push(m);
|
|
2710
|
+
if (acc.quotas) for (const fam of [
|
|
2711
|
+
"argon",
|
|
2712
|
+
"anthropic",
|
|
2713
|
+
"google"
|
|
2714
|
+
]) {
|
|
2715
|
+
const models = acc.quotas[fam]?.models;
|
|
2716
|
+
if (models?.length) {
|
|
2717
|
+
const raw = models.map((m) => ({
|
|
2718
|
+
slug: m.modelId,
|
|
2719
|
+
label: m.displayName || m.modelId
|
|
2720
|
+
}));
|
|
2721
|
+
for (const m of foldEfforts(raw)) list.push(m);
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
return list;
|
|
2726
|
+
}
|
|
2727
|
+
/**
|
|
2728
|
+
* Return the union of all models available across all pool accounts,
|
|
2729
|
+
* merged with discovered catalogs, per-account quota models, and fallback models.
|
|
2730
|
+
* If any enabled account in the pool has Argon access, Argon is included in the union.
|
|
2731
|
+
*/
|
|
2732
|
+
getUnion(accounts = [], pool) {
|
|
2733
|
+
if (accounts.length === 0 && !pool) return this.current.models;
|
|
2734
|
+
const all = this.getAllKnownModels(accounts);
|
|
2735
|
+
const hasAnyArgon = pool ? poolHasArgon(pool, this) : accounts.some((a) => accountHasArgon(a, pool, this.get(a.id)));
|
|
2736
|
+
return all.filter((entry) => {
|
|
2737
|
+
if (isArgonModel(entry.id) && !hasAnyArgon) return false;
|
|
2738
|
+
return true;
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2684
2741
|
get(accountId) {
|
|
2685
2742
|
if (accountId && this.accountCatalogs.has(accountId)) return this.accountCatalogs.get(accountId);
|
|
2686
2743
|
return this.current;
|
|
@@ -4976,6 +5033,10 @@ var AccountPoolManager = class {
|
|
|
4976
5033
|
}
|
|
4977
5034
|
return false;
|
|
4978
5035
|
}
|
|
5036
|
+
/** Determine whether a managed account has confirmed access to Gemini 4 Argon. */
|
|
5037
|
+
accountHasArgon(acc) {
|
|
5038
|
+
return accountHasArgon(acc, this);
|
|
5039
|
+
}
|
|
4979
5040
|
/**
|
|
4980
5041
|
* Why this account cannot serve `family` right now, or null when it can.
|
|
4981
5042
|
*
|
|
@@ -4986,6 +5047,7 @@ var AccountPoolManager = class {
|
|
|
4986
5047
|
explainIneligibility(acc, family, now = Date.now()) {
|
|
4987
5048
|
if (!acc.enabled) return "disabled";
|
|
4988
5049
|
if (acc.authRequired) return "auth";
|
|
5050
|
+
if (family === "argon" && !this.accountHasArgon(acc)) return "unsupported";
|
|
4989
5051
|
const cd = acc.cooldowns?.[family];
|
|
4990
5052
|
if (cd && cd.cooldownUntil > now) return "cooldown";
|
|
4991
5053
|
if (this.isQuotaBenched(acc, family, now)) return "quota";
|
|
@@ -29840,7 +29902,7 @@ async function acquireCredentialSlot(account, pool, options = {}) {
|
|
|
29840
29902
|
const afterRaw = io.readSlot();
|
|
29841
29903
|
const afterFingerprint = credentialFingerprint(afterRaw);
|
|
29842
29904
|
if (sameCredentialGrant$1(afterRaw, accountRaw)) {
|
|
29843
|
-
if (afterRaw && afterRaw !== accountRaw) writeFileAtomic(accountFile, afterRaw);
|
|
29905
|
+
if (afterRaw && afterRaw !== accountRaw && readTokenFileRaw(accountFile) === accountRaw) writeFileAtomic(accountFile, afterRaw);
|
|
29844
29906
|
} else if (afterFingerprint !== null) log(`[agy-link] credential slot was replaced during ${account.alias || account.id}'s run — refusing to write a foreign credential into the account file`);
|
|
29845
29907
|
} finally {
|
|
29846
29908
|
try {
|
|
@@ -31296,12 +31358,10 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31296
31358
|
return activeId ? pool.getAccount(activeId) : void 0;
|
|
31297
31359
|
}
|
|
31298
31360
|
async listModels(_provider) {
|
|
31299
|
-
const
|
|
31361
|
+
const pool = this.deps.pool;
|
|
31362
|
+
const accounts = pool ? pool.getAccounts().filter((a) => a.enabled) : [];
|
|
31300
31363
|
const cfg = this.deps.getConfig();
|
|
31301
|
-
const
|
|
31302
|
-
let models = cat.models;
|
|
31303
|
-
if (!activeAcc || !accountHasArgon(activeAcc, this.deps.pool, cat)) models = models.filter((m) => !isArgonModel(m.id));
|
|
31304
|
-
const { entries, dropped } = sanitizeCatalogEntries(models);
|
|
31364
|
+
const { entries, dropped } = sanitizeCatalogEntries(this.deps.catalog.getUnion(accounts, pool));
|
|
31305
31365
|
if (dropped.length > 0) this.warnOnce("catalog-dupes", "model catalog contained duplicate ids [" + dropped.join(", ") + "] — kept first occurrence so DSH does not drop the whole provider group (INVALID_CATALOG)");
|
|
31306
31366
|
const hidden = new Set(cfg.hiddenModels.map((s) => s.trim()));
|
|
31307
31367
|
return entries.filter((m) => !hidden.has(m.id)).map((m) => ({
|
|
@@ -31312,12 +31372,15 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31312
31372
|
}));
|
|
31313
31373
|
}
|
|
31314
31374
|
async resolveModel(_provider, model, _signal) {
|
|
31375
|
+
const pool = this.deps.pool;
|
|
31315
31376
|
const activeAcc = this.getActiveAccount();
|
|
31316
31377
|
const cfg = this.deps.getConfig();
|
|
31317
|
-
const
|
|
31378
|
+
const accounts = pool ? pool.getAccounts().filter((a) => a.enabled) : [];
|
|
31318
31379
|
const rawModel = typeof model === "string" ? model.trim() : "";
|
|
31319
31380
|
const cleanId = rawModel !== "" ? rawModel : cfg.defaultModel;
|
|
31320
|
-
const
|
|
31381
|
+
const unionModels = this.deps.catalog.getUnion(accounts, pool);
|
|
31382
|
+
const allModels = this.deps.catalog.getAllKnownModels(accounts);
|
|
31383
|
+
const entry = unionModels.find((m) => m.id === cleanId) ?? allModels.find((m) => m.id === cleanId) ?? findEntry(this.deps.catalog.get(activeAcc?.id), cleanId) ?? findEntry(this.deps.catalog.get(), cleanId);
|
|
31321
31384
|
const rawName = entry ? entry.name : cleanId;
|
|
31322
31385
|
const name = typeof rawName === "string" && rawName.trim() !== "" ? rawName.trim() : cleanId;
|
|
31323
31386
|
const contextWindow = typeof cfg.contextWindowDefault === "number" && cfg.contextWindowDefault > 0 ? cfg.contextWindowDefault : 2e5;
|
|
@@ -31589,6 +31652,9 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31589
31652
|
}
|
|
31590
31653
|
}
|
|
31591
31654
|
if (!account && this.deps.pool) account = this.deps.pool.selectAccount(family) ?? void 0;
|
|
31655
|
+
if (account && this.deps.pool) {
|
|
31656
|
+
if (this.deps.pool.getPoolData().lastActiveAccountId !== account.id) this.deps.pool.setActiveAccount(account.id, family);
|
|
31657
|
+
}
|
|
31592
31658
|
if (this.deps.pool && this.deps.pool.getAccounts().length > 0 && !account) {
|
|
31593
31659
|
if (cfg.autoFallbackModel) {
|
|
31594
31660
|
const familyModel = {
|
|
@@ -31620,6 +31686,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31620
31686
|
const reasons = accounts.map((a) => typeof pool.explainIneligibility === "function" ? pool.explainIneligibility(a, family) : pool.isAccountEligible(a, family) ? null : "cooldown");
|
|
31621
31687
|
const cooling = reasons.filter((r) => r === "cooldown").length;
|
|
31622
31688
|
const quotaBlocked = reasons.filter((r) => r === "quota").length;
|
|
31689
|
+
const unsupported = reasons.filter((r) => r === "unsupported").length;
|
|
31623
31690
|
const signedOut = accounts.filter((a) => a.authRequired === true).length;
|
|
31624
31691
|
const countdown = pool.getEarliestAvailableCountdown?.(family) ?? pool.getEarliestResetCountdown(family);
|
|
31625
31692
|
if (countdown !== null && countdown > 0 && countdown <= 2e4) {
|
|
@@ -31634,13 +31701,15 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
|
|
|
31634
31701
|
const details = [];
|
|
31635
31702
|
if (cooling > 0) details.push(`${cooling} in cooldown`);
|
|
31636
31703
|
if (quotaBlocked > 0) details.push(`${quotaBlocked} quota-exhausted`);
|
|
31704
|
+
if (unsupported > 0) details.push(`${unsupported} lack ${family} access`);
|
|
31637
31705
|
if (signedOut > 0) details.push(`${signedOut} signed out`);
|
|
31638
31706
|
if (disabled > 0) details.push(`${disabled} disabled`);
|
|
31639
31707
|
const detailStr = details.length > 0 ? ` (${details.join(", ")})` : "";
|
|
31640
31708
|
why = `no account can serve ${family} right now${detailStr}`;
|
|
31641
31709
|
}
|
|
31642
31710
|
const waitStr = countdown !== null && countdown > 0 ? ` (earliest reset in ${Math.ceil(countdown / 1e3)}s)` : "";
|
|
31643
|
-
|
|
31711
|
+
const hint = unsupported > 0 && quotaBlocked === 0 && cooling === 0 ? `No enabled account has access to ${family} (requires a plan with ${family} enabled).` : 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.";
|
|
31712
|
+
throw new LlmError(`All Antigravity accounts are unavailable: ${why}${waitStr}. ${hint}`, Err.AGY_ERROR);
|
|
31644
31713
|
}
|
|
31645
31714
|
}
|
|
31646
31715
|
}
|
|
@@ -33252,7 +33321,8 @@ const HELP$1 = [
|
|
|
33252
33321
|
"- `/agy refresh-quota` — query Google backend for fresh quota %",
|
|
33253
33322
|
"- `/agy clear-cooldown` — reset cooldown timers (and any active low-quota bench)",
|
|
33254
33323
|
"- `/agy remove-account <id>` — delete an account slot",
|
|
33255
|
-
"- `/agy auth` —
|
|
33324
|
+
"- `/agy auth [id|alias|email]` — login to the primary or reauthenticate an existing account",
|
|
33325
|
+
"- `/agy auth-status` — check the current or most recent login result",
|
|
33256
33326
|
"- `/agy auth-code <code>` — finish login by pasting the code (fallback)",
|
|
33257
33327
|
"- `/agy models` — refresh and list discovered models",
|
|
33258
33328
|
"- `/agy mode <skip|plan|accept-edits>` — permission mode (next turn)",
|
|
@@ -33304,7 +33374,7 @@ async function handle$1(deps, raw, invocation) {
|
|
|
33304
33374
|
if (!a.enabled) statusText = " - Status: ⏸️ Disabled";
|
|
33305
33375
|
else if (a.authRequired) statusText = ` - Status: 🔴 Auth required (${a.authError || "sign in again"})`;
|
|
33306
33376
|
else if (cds.length > 0) statusText = ` - ⚠️ ${cds.join("; ")}`;
|
|
33307
|
-
lines.push(`${i + 1}. **${a.alias}** (${a.email || a.id})${isPrimary ? " ⭐ primary" : ""}`, ` - Proxy: ${a.proxyUrl ? redactProxyUrl(a.proxyUrl) : deps.cfg().proxyUrl ? redactProxyUrl(deps.cfg().proxyUrl) : "system default"}`, quotaLine, statusText);
|
|
33377
|
+
lines.push(`${i + 1}. **${a.alias}** (${a.email || "email unknown"}; id: \`${a.id}\`)${isPrimary ? " ⭐ primary" : ""}`, ` - Proxy: ${a.proxyUrl ? redactProxyUrl(a.proxyUrl) : deps.cfg().proxyUrl ? redactProxyUrl(deps.cfg().proxyUrl) : "system default"}`, quotaLine, statusText);
|
|
33308
33378
|
}
|
|
33309
33379
|
return ok$1(lines.join("\n"));
|
|
33310
33380
|
}
|
|
@@ -33323,7 +33393,7 @@ async function handle$1(deps, raw, invocation) {
|
|
|
33323
33393
|
return ok$1([
|
|
33324
33394
|
`**Account slot created: [${acc.alias}]** (id: \`${acc.id}\`)`,
|
|
33325
33395
|
`- Isolated directory: \`${acc.dir}\``,
|
|
33326
|
-
`- Run
|
|
33396
|
+
`- Run \`/agy auth ${acc.id}\` to authenticate this Google account.`,
|
|
33327
33397
|
`- The slot stays OUT of rotation (authRequired) until the login completes and a quota refresh verifies it.`,
|
|
33328
33398
|
`- Once logged in, run: \`/agy pool\` or click 🔄 刷新额度 in WebUI.`
|
|
33329
33399
|
].join("\n"));
|
|
@@ -33507,16 +33577,40 @@ async function handle$1(deps, raw, invocation) {
|
|
|
33507
33577
|
if (sub === "auth") {
|
|
33508
33578
|
const flow = deps.poolAuth?.();
|
|
33509
33579
|
if (!flow) return err$1("auth flow not available");
|
|
33510
|
-
const
|
|
33580
|
+
const selector = parts.slice(1).join(" ");
|
|
33581
|
+
let st;
|
|
33582
|
+
if (!selector) st = await flow.beginPrimary();
|
|
33583
|
+
else {
|
|
33584
|
+
const pool = deps.pool?.();
|
|
33585
|
+
if (!pool) return err$1("Account pool not available");
|
|
33586
|
+
const matches = pool.getAccounts().filter((a) => [
|
|
33587
|
+
a.id,
|
|
33588
|
+
a.alias,
|
|
33589
|
+
a.email
|
|
33590
|
+
].some((value) => value?.toLowerCase() === selector.toLowerCase()));
|
|
33591
|
+
if (matches.length !== 1) return err$1(matches.length ? "Multiple accounts match; use an account ID from /agy pool." : "Account not found; use /agy pool to list account IDs.");
|
|
33592
|
+
const account = matches[0];
|
|
33593
|
+
st = account.systemHome || !account.dir ? await flow.beginPrimary(account.proxyUrl || deps.cfg().proxyUrl || void 0) : await flow.beginAccount(account.id, deps.cfg().proxyUrl || void 0);
|
|
33594
|
+
}
|
|
33511
33595
|
if (st.ok && st.url) return ok$1([
|
|
33512
33596
|
st.browserOpened ? "**浏览器已打开 Google 授权页** — 批准访问后自动完成登录。" : "**请手动打开下面的 URL 完成 Google 授权:**",
|
|
33513
33597
|
"",
|
|
33514
33598
|
st.url,
|
|
33515
33599
|
"",
|
|
33600
|
+
"授权后请在 30 秒内运行 `/agy auth-status` 检查登录结果。",
|
|
33516
33601
|
"备用:授权完成后运行 `/agy auth-code <授权码或完整回调URL>`。"
|
|
33517
33602
|
].join("\n"));
|
|
33518
33603
|
return err$1(`failed to start the login flow (${st.code ?? "request_failed"})`);
|
|
33519
33604
|
}
|
|
33605
|
+
if (sub === "auth-status") {
|
|
33606
|
+
const flow = deps.poolAuth?.();
|
|
33607
|
+
if (!flow) return err$1("auth flow not available");
|
|
33608
|
+
const st = flow.status();
|
|
33609
|
+
if (st.phase === "done") return ok$1(`Login completed${st.alias ? ` for ${st.alias}` : ""}.`);
|
|
33610
|
+
if (st.phase === "failed") return err$1(`Login failed (${st.code ?? "request_failed"}).`);
|
|
33611
|
+
if (st.phase === "waiting" || st.phase === "exchanging") return ok$1(`Login ${st.phase}; authorization is not complete yet.`);
|
|
33612
|
+
return ok$1("No login is in progress.");
|
|
33613
|
+
}
|
|
33520
33614
|
if (sub === "auth-code") {
|
|
33521
33615
|
if (arg === "") return err$1("usage: /agy auth-code <code-or-callback-url>");
|
|
33522
33616
|
const flow = deps.poolAuth?.();
|
|
@@ -34686,11 +34780,15 @@ var PoolAuthFlow = class {
|
|
|
34686
34780
|
statusValue = { phase: "idle" };
|
|
34687
34781
|
doneResetTimer = null;
|
|
34688
34782
|
open;
|
|
34783
|
+
exchange;
|
|
34784
|
+
userEmail;
|
|
34689
34785
|
constructor(pool, quota, log = () => {}, deps = {}) {
|
|
34690
34786
|
this.pool = pool;
|
|
34691
34787
|
this.quota = quota;
|
|
34692
34788
|
this.log = log;
|
|
34693
34789
|
this.open = deps.openBrowser ?? openBrowser;
|
|
34790
|
+
this.exchange = deps.exchangeCode ?? exchangeCode;
|
|
34791
|
+
this.userEmail = deps.fetchUserEmail ?? fetchUserEmail;
|
|
34694
34792
|
}
|
|
34695
34793
|
status() {
|
|
34696
34794
|
return { ...this.statusValue };
|
|
@@ -34784,6 +34882,23 @@ var PoolAuthFlow = class {
|
|
|
34784
34882
|
proxyUrl: proxyUrl || detectSystemProxy()
|
|
34785
34883
|
});
|
|
34786
34884
|
}
|
|
34885
|
+
/** Reauthenticate an existing isolated account without replacing its pool entry. */
|
|
34886
|
+
async beginAccount(accountId, proxyUrl) {
|
|
34887
|
+
const account = this.pool.getAccount(accountId);
|
|
34888
|
+
if (!account || !account.dir || account.systemHome) return {
|
|
34889
|
+
ok: false,
|
|
34890
|
+
phase: "failed",
|
|
34891
|
+
code: "request_failed"
|
|
34892
|
+
};
|
|
34893
|
+
const staging = this.pool.createStagingSlot();
|
|
34894
|
+
return this.startFlow({
|
|
34895
|
+
stagingId: staging.id,
|
|
34896
|
+
dir: staging.dir,
|
|
34897
|
+
accountId,
|
|
34898
|
+
alias: account.alias,
|
|
34899
|
+
proxyUrl: account.proxyUrl || proxyUrl || detectSystemProxy()
|
|
34900
|
+
});
|
|
34901
|
+
}
|
|
34787
34902
|
/** Manual paste fallback: accepts a bare code or the full redirect URL. */
|
|
34788
34903
|
async submitCode(input) {
|
|
34789
34904
|
const flow = this.flow;
|
|
@@ -34830,12 +34945,43 @@ var PoolAuthFlow = class {
|
|
|
34830
34945
|
}
|
|
34831
34946
|
this.setStatus({ phase: "exchanging" });
|
|
34832
34947
|
try {
|
|
34833
|
-
const tokens = await
|
|
34948
|
+
const tokens = await this.exchange(code, flow.verifier, flow.proxyUrl);
|
|
34949
|
+
if (this.flow !== flow) return;
|
|
34950
|
+
if (flow.accountId) {
|
|
34951
|
+
const email = await this.userEmail(tokens.access_token, flow.proxyUrl);
|
|
34952
|
+
if (this.flow !== flow) return;
|
|
34953
|
+
const account = this.pool.getAccount(flow.accountId);
|
|
34954
|
+
if (!account || !account.dir || account.systemHome || !email || !tokens.refresh_token) {
|
|
34955
|
+
this.fail("identity_unverified");
|
|
34956
|
+
return;
|
|
34957
|
+
}
|
|
34958
|
+
const normalized = email.toLowerCase();
|
|
34959
|
+
if (account.email && account.email.toLowerCase() !== normalized || this.pool.getAccounts().some((other) => other.id !== account.id && other.email?.toLowerCase() === normalized)) {
|
|
34960
|
+
this.fail("identity_mismatch");
|
|
34961
|
+
return;
|
|
34962
|
+
}
|
|
34963
|
+
const stagedFile = writeAgyTokenFile(flow.dir, tokens);
|
|
34964
|
+
const targetDir = join(account.dir, ".gemini", "antigravity-cli");
|
|
34965
|
+
mkdirSync(targetDir, { recursive: true });
|
|
34966
|
+
renameSync(stagedFile, join(targetDir, "antigravity-oauth-token"));
|
|
34967
|
+
this.pool.updateAccountQuotas(account.id, {}, email);
|
|
34968
|
+
this.pool.clearAuthRequired(account.id);
|
|
34969
|
+
this.pool.cleanupStagingSlot(flow.dir);
|
|
34970
|
+
this.quota.refreshAccountQuota(account).catch(() => void 0);
|
|
34971
|
+
this.flow = null;
|
|
34972
|
+
if (flow.listener) flow.listener.close().catch(() => void 0);
|
|
34973
|
+
this.setStatus({
|
|
34974
|
+
phase: "done",
|
|
34975
|
+
alias: account.alias,
|
|
34976
|
+
code: "account_activated"
|
|
34977
|
+
});
|
|
34978
|
+
return;
|
|
34979
|
+
}
|
|
34834
34980
|
const tokenFile = writeAgyTokenFile(flow.dir, tokens);
|
|
34835
34981
|
if (flow.primary && process.platform === "win32") try {
|
|
34836
34982
|
writeWindowsCredentialRaw(readFileSync(tokenFile, "utf8"), "gemini:antigravity");
|
|
34837
34983
|
} catch {}
|
|
34838
|
-
const email = await
|
|
34984
|
+
const email = await this.userEmail(tokens.access_token, flow.proxyUrl);
|
|
34839
34985
|
if (flow.primary && process.platform === "win32") try {
|
|
34840
34986
|
writePrimaryCredential({
|
|
34841
34987
|
raw: readFileSync(tokenFile, "utf8"),
|
|
@@ -34871,7 +35017,7 @@ var PoolAuthFlow = class {
|
|
|
34871
35017
|
code: "account_activated"
|
|
34872
35018
|
});
|
|
34873
35019
|
} catch (err) {
|
|
34874
|
-
this.fail("exchange_failed", err);
|
|
35020
|
+
if (this.flow === flow) this.fail("exchange_failed", err);
|
|
34875
35021
|
}
|
|
34876
35022
|
}
|
|
34877
35023
|
fail(code, detail) {
|
|
@@ -35590,6 +35736,7 @@ var QuotaService = class {
|
|
|
35590
35736
|
if (tok.accessToken && (!tok.expiryMs || tok.expiryMs > Date.now() + 6e4)) return tok.accessToken;
|
|
35591
35737
|
if (tok.refreshToken) try {
|
|
35592
35738
|
const refreshed = await refreshTokens(tok.refreshToken, this.proxyFor(account));
|
|
35739
|
+
if (!this.isCurrentAccountGrant(account, tok.refreshToken)) return null;
|
|
35593
35740
|
if (refreshed?.access_token) {
|
|
35594
35741
|
this.persistRefreshedToken(account, {
|
|
35595
35742
|
access_token: refreshed.access_token,
|
|
@@ -35600,11 +35747,20 @@ var QuotaService = class {
|
|
|
35600
35747
|
return refreshed.access_token;
|
|
35601
35748
|
}
|
|
35602
35749
|
} catch (err) {
|
|
35750
|
+
if (!this.isCurrentAccountGrant(account, tok.refreshToken)) return null;
|
|
35603
35751
|
const errMsg = String(err);
|
|
35604
35752
|
if (shouldMarkAuthRequired(void 0, errMsg)) this.pool.markAuthRequired(account.id, errMsg);
|
|
35605
35753
|
}
|
|
35606
35754
|
return tok.accessToken || null;
|
|
35607
35755
|
}
|
|
35756
|
+
isCurrentAccountGrant(account, refreshToken) {
|
|
35757
|
+
if (account.systemHome || !account.dir) return true;
|
|
35758
|
+
try {
|
|
35759
|
+
return parseCredentialDoc(readFileSync(this.getTokenFilePath(account), "utf8"))?.refreshToken === refreshToken;
|
|
35760
|
+
} catch {
|
|
35761
|
+
return false;
|
|
35762
|
+
}
|
|
35763
|
+
}
|
|
35608
35764
|
/**
|
|
35609
35765
|
* Query live user info (email) from Google OAuth userinfo endpoint.
|
|
35610
35766
|
*/
|
|
@@ -37619,6 +37775,7 @@ function apply(ctx, entryConfig = {}) {
|
|
|
37619
37775
|
(async () => {
|
|
37620
37776
|
const cfg = getConfig();
|
|
37621
37777
|
const cat = catalog.get();
|
|
37778
|
+
const allKnown = catalog.getAllKnownModels(pool.getAccounts());
|
|
37622
37779
|
sendJson(res, 200, {
|
|
37623
37780
|
plugin: "dsh-agy-link",
|
|
37624
37781
|
bin: bin(),
|
|
@@ -37638,7 +37795,7 @@ function apply(ctx, entryConfig = {}) {
|
|
|
37638
37795
|
count: cat.models.length,
|
|
37639
37796
|
lastError: cat.lastError ?? null
|
|
37640
37797
|
},
|
|
37641
|
-
catalogModels: sanitizeCatalogEntries(
|
|
37798
|
+
catalogModels: sanitizeCatalogEntries(allKnown).entries,
|
|
37642
37799
|
hiddenModels: cfg.hiddenModels,
|
|
37643
37800
|
autoWarmup: cfg.autoWarmup,
|
|
37644
37801
|
warmupModels: cfg.warmupModels,
|
package/docs/README.en.md
CHANGED
|
@@ -57,6 +57,9 @@ dsh web
|
|
|
57
57
|
# In the chat input:
|
|
58
58
|
/agy status # binary, version, pool and catalog status
|
|
59
59
|
/agy auth # sign the primary account in
|
|
60
|
+
/agy pool # list account IDs
|
|
61
|
+
/agy auth <account-id> # reauthenticate an existing secondary account (also accepts full alias or email)
|
|
62
|
+
/agy auth-status # check the final login result within 30 seconds
|
|
60
63
|
```
|
|
61
64
|
|
|
62
65
|
Add more accounts from the **AGY (n)** badge in the header (browser login), then pick an Antigravity model in `/model`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agy-link",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.18",
|
|
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",
|