dsh-agy-link 0.6.16 → 0.6.17

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.17 (2026-11-11)
4
+
5
+ ### English
6
+
7
+ - **Feat(auth): reauthenticate an existing pool account in place — `/agy auth <id|alias|email>`, final result via `/agy auth-status`.** (thanks @Ronnoc, #96)
8
+ - 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).
9
+ - 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.
10
+ - 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.
11
+
12
+ ### 中文
13
+
14
+ - **新增(auth):原地重登已有账号——`/agy auth <ID|别名|邮箱>`,最终结果用 `/agy auth-status` 查看。**(感谢 @Ronnoc,#96)
15
+ - 副账号凭据缺失/失效时,不必再「删除后重建」(会丢配置与本地状态):浏览器流程先写入 staging 槽位并校验 Google 身份,再把新 token **原子地** rename 到该账号独立的 `.gemini/antigravity-cli`(0600 权限)。
16
+ - 替换前的身份校验:必须是隔离账号(不是 system-HOME 主账号);已记录邮箱的账号要求邮箱一致;同一邮箱不得属于池中**其他**账号。缺邮箱/缺 refresh token/身份不符或重复 → `identity_unverified` / `identity_mismatch`,旧凭据保持不动。
17
+ - 流程具备「旧流程不写盘」的过期保护,成功后清除 `authRequired`、记录邮箱并刷新该账号配额;任何输出都不打印凭据值。
18
+
19
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.6.16...v0.6.17
20
+
3
21
  ## 0.6.16 (2026-11-10)
4
22
 
5
23
  ### 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
  ```
@@ -29544,7 +29544,7 @@ async function acquireCredentialSlot(account, pool, options = {}) {
29544
29544
  const afterRaw = io.readSlot();
29545
29545
  const afterFingerprint = credentialFingerprint(afterRaw);
29546
29546
  if (sameCredentialGrant(afterRaw, accountRaw)) {
29547
- if (afterRaw && afterRaw !== accountRaw) writeFileAtomic(accountFile, afterRaw);
29547
+ if (afterRaw && afterRaw !== accountRaw && readTokenFileRaw(accountFile) === accountRaw) writeFileAtomic(accountFile, afterRaw);
29548
29548
  } 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
29549
  } finally {
29550
29550
  try {
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
@@ -29840,7 +29840,7 @@ async function acquireCredentialSlot(account, pool, options = {}) {
29840
29840
  const afterRaw = io.readSlot();
29841
29841
  const afterFingerprint = credentialFingerprint(afterRaw);
29842
29842
  if (sameCredentialGrant$1(afterRaw, accountRaw)) {
29843
- if (afterRaw && afterRaw !== accountRaw) writeFileAtomic(accountFile, afterRaw);
29843
+ if (afterRaw && afterRaw !== accountRaw && readTokenFileRaw(accountFile) === accountRaw) writeFileAtomic(accountFile, afterRaw);
29844
29844
  } 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
29845
  } finally {
29846
29846
  try {
@@ -33252,7 +33252,8 @@ const HELP$1 = [
33252
33252
  "- `/agy refresh-quota` — query Google backend for fresh quota %",
33253
33253
  "- `/agy clear-cooldown` — reset cooldown timers (and any active low-quota bench)",
33254
33254
  "- `/agy remove-account <id>` — delete an account slot",
33255
- "- `/agy auth` — Google login for the primary account (opens the browser)",
33255
+ "- `/agy auth [id|alias|email]` — login to the primary or reauthenticate an existing account",
33256
+ "- `/agy auth-status` — check the current or most recent login result",
33256
33257
  "- `/agy auth-code <code>` — finish login by pasting the code (fallback)",
33257
33258
  "- `/agy models` — refresh and list discovered models",
33258
33259
  "- `/agy mode <skip|plan|accept-edits>` — permission mode (next turn)",
@@ -33304,7 +33305,7 @@ async function handle$1(deps, raw, invocation) {
33304
33305
  if (!a.enabled) statusText = " - Status: ⏸️ Disabled";
33305
33306
  else if (a.authRequired) statusText = ` - Status: 🔴 Auth required (${a.authError || "sign in again"})`;
33306
33307
  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);
33308
+ 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
33309
  }
33309
33310
  return ok$1(lines.join("\n"));
33310
33311
  }
@@ -33323,7 +33324,7 @@ async function handle$1(deps, raw, invocation) {
33323
33324
  return ok$1([
33324
33325
  `**Account slot created: [${acc.alias}]** (id: \`${acc.id}\`)`,
33325
33326
  `- Isolated directory: \`${acc.dir}\``,
33326
- `- Run in terminal: \`HOME="${acc.dir}" agy\` to authenticate this Google account.`,
33327
+ `- Run \`/agy auth ${acc.id}\` to authenticate this Google account.`,
33327
33328
  `- The slot stays OUT of rotation (authRequired) until the login completes and a quota refresh verifies it.`,
33328
33329
  `- Once logged in, run: \`/agy pool\` or click 🔄 刷新额度 in WebUI.`
33329
33330
  ].join("\n"));
@@ -33507,16 +33508,40 @@ async function handle$1(deps, raw, invocation) {
33507
33508
  if (sub === "auth") {
33508
33509
  const flow = deps.poolAuth?.();
33509
33510
  if (!flow) return err$1("auth flow not available");
33510
- const st = await flow.beginPrimary();
33511
+ const selector = parts.slice(1).join(" ");
33512
+ let st;
33513
+ if (!selector) st = await flow.beginPrimary();
33514
+ else {
33515
+ const pool = deps.pool?.();
33516
+ if (!pool) return err$1("Account pool not available");
33517
+ const matches = pool.getAccounts().filter((a) => [
33518
+ a.id,
33519
+ a.alias,
33520
+ a.email
33521
+ ].some((value) => value?.toLowerCase() === selector.toLowerCase()));
33522
+ 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.");
33523
+ const account = matches[0];
33524
+ 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);
33525
+ }
33511
33526
  if (st.ok && st.url) return ok$1([
33512
33527
  st.browserOpened ? "**浏览器已打开 Google 授权页** — 批准访问后自动完成登录。" : "**请手动打开下面的 URL 完成 Google 授权:**",
33513
33528
  "",
33514
33529
  st.url,
33515
33530
  "",
33531
+ "授权后请在 30 秒内运行 `/agy auth-status` 检查登录结果。",
33516
33532
  "备用:授权完成后运行 `/agy auth-code <授权码或完整回调URL>`。"
33517
33533
  ].join("\n"));
33518
33534
  return err$1(`failed to start the login flow (${st.code ?? "request_failed"})`);
33519
33535
  }
33536
+ if (sub === "auth-status") {
33537
+ const flow = deps.poolAuth?.();
33538
+ if (!flow) return err$1("auth flow not available");
33539
+ const st = flow.status();
33540
+ if (st.phase === "done") return ok$1(`Login completed${st.alias ? ` for ${st.alias}` : ""}.`);
33541
+ if (st.phase === "failed") return err$1(`Login failed (${st.code ?? "request_failed"}).`);
33542
+ if (st.phase === "waiting" || st.phase === "exchanging") return ok$1(`Login ${st.phase}; authorization is not complete yet.`);
33543
+ return ok$1("No login is in progress.");
33544
+ }
33520
33545
  if (sub === "auth-code") {
33521
33546
  if (arg === "") return err$1("usage: /agy auth-code <code-or-callback-url>");
33522
33547
  const flow = deps.poolAuth?.();
@@ -34686,11 +34711,15 @@ var PoolAuthFlow = class {
34686
34711
  statusValue = { phase: "idle" };
34687
34712
  doneResetTimer = null;
34688
34713
  open;
34714
+ exchange;
34715
+ userEmail;
34689
34716
  constructor(pool, quota, log = () => {}, deps = {}) {
34690
34717
  this.pool = pool;
34691
34718
  this.quota = quota;
34692
34719
  this.log = log;
34693
34720
  this.open = deps.openBrowser ?? openBrowser;
34721
+ this.exchange = deps.exchangeCode ?? exchangeCode;
34722
+ this.userEmail = deps.fetchUserEmail ?? fetchUserEmail;
34694
34723
  }
34695
34724
  status() {
34696
34725
  return { ...this.statusValue };
@@ -34784,6 +34813,23 @@ var PoolAuthFlow = class {
34784
34813
  proxyUrl: proxyUrl || detectSystemProxy()
34785
34814
  });
34786
34815
  }
34816
+ /** Reauthenticate an existing isolated account without replacing its pool entry. */
34817
+ async beginAccount(accountId, proxyUrl) {
34818
+ const account = this.pool.getAccount(accountId);
34819
+ if (!account || !account.dir || account.systemHome) return {
34820
+ ok: false,
34821
+ phase: "failed",
34822
+ code: "request_failed"
34823
+ };
34824
+ const staging = this.pool.createStagingSlot();
34825
+ return this.startFlow({
34826
+ stagingId: staging.id,
34827
+ dir: staging.dir,
34828
+ accountId,
34829
+ alias: account.alias,
34830
+ proxyUrl: account.proxyUrl || proxyUrl || detectSystemProxy()
34831
+ });
34832
+ }
34787
34833
  /** Manual paste fallback: accepts a bare code or the full redirect URL. */
34788
34834
  async submitCode(input) {
34789
34835
  const flow = this.flow;
@@ -34830,12 +34876,43 @@ var PoolAuthFlow = class {
34830
34876
  }
34831
34877
  this.setStatus({ phase: "exchanging" });
34832
34878
  try {
34833
- const tokens = await exchangeCode(code, flow.verifier, flow.proxyUrl);
34879
+ const tokens = await this.exchange(code, flow.verifier, flow.proxyUrl);
34880
+ if (this.flow !== flow) return;
34881
+ if (flow.accountId) {
34882
+ const email = await this.userEmail(tokens.access_token, flow.proxyUrl);
34883
+ if (this.flow !== flow) return;
34884
+ const account = this.pool.getAccount(flow.accountId);
34885
+ if (!account || !account.dir || account.systemHome || !email || !tokens.refresh_token) {
34886
+ this.fail("identity_unverified");
34887
+ return;
34888
+ }
34889
+ const normalized = email.toLowerCase();
34890
+ if (account.email && account.email.toLowerCase() !== normalized || this.pool.getAccounts().some((other) => other.id !== account.id && other.email?.toLowerCase() === normalized)) {
34891
+ this.fail("identity_mismatch");
34892
+ return;
34893
+ }
34894
+ const stagedFile = writeAgyTokenFile(flow.dir, tokens);
34895
+ const targetDir = join(account.dir, ".gemini", "antigravity-cli");
34896
+ mkdirSync(targetDir, { recursive: true });
34897
+ renameSync(stagedFile, join(targetDir, "antigravity-oauth-token"));
34898
+ this.pool.updateAccountQuotas(account.id, {}, email);
34899
+ this.pool.clearAuthRequired(account.id);
34900
+ this.pool.cleanupStagingSlot(flow.dir);
34901
+ this.quota.refreshAccountQuota(account).catch(() => void 0);
34902
+ this.flow = null;
34903
+ if (flow.listener) flow.listener.close().catch(() => void 0);
34904
+ this.setStatus({
34905
+ phase: "done",
34906
+ alias: account.alias,
34907
+ code: "account_activated"
34908
+ });
34909
+ return;
34910
+ }
34834
34911
  const tokenFile = writeAgyTokenFile(flow.dir, tokens);
34835
34912
  if (flow.primary && process.platform === "win32") try {
34836
34913
  writeWindowsCredentialRaw(readFileSync(tokenFile, "utf8"), "gemini:antigravity");
34837
34914
  } catch {}
34838
- const email = await fetchUserEmail(tokens.access_token, flow.proxyUrl);
34915
+ const email = await this.userEmail(tokens.access_token, flow.proxyUrl);
34839
34916
  if (flow.primary && process.platform === "win32") try {
34840
34917
  writePrimaryCredential({
34841
34918
  raw: readFileSync(tokenFile, "utf8"),
@@ -34871,7 +34948,7 @@ var PoolAuthFlow = class {
34871
34948
  code: "account_activated"
34872
34949
  });
34873
34950
  } catch (err) {
34874
- this.fail("exchange_failed", err);
34951
+ if (this.flow === flow) this.fail("exchange_failed", err);
34875
34952
  }
34876
34953
  }
34877
34954
  fail(code, detail) {
@@ -35590,6 +35667,7 @@ var QuotaService = class {
35590
35667
  if (tok.accessToken && (!tok.expiryMs || tok.expiryMs > Date.now() + 6e4)) return tok.accessToken;
35591
35668
  if (tok.refreshToken) try {
35592
35669
  const refreshed = await refreshTokens(tok.refreshToken, this.proxyFor(account));
35670
+ if (!this.isCurrentAccountGrant(account, tok.refreshToken)) return null;
35593
35671
  if (refreshed?.access_token) {
35594
35672
  this.persistRefreshedToken(account, {
35595
35673
  access_token: refreshed.access_token,
@@ -35600,11 +35678,20 @@ var QuotaService = class {
35600
35678
  return refreshed.access_token;
35601
35679
  }
35602
35680
  } catch (err) {
35681
+ if (!this.isCurrentAccountGrant(account, tok.refreshToken)) return null;
35603
35682
  const errMsg = String(err);
35604
35683
  if (shouldMarkAuthRequired(void 0, errMsg)) this.pool.markAuthRequired(account.id, errMsg);
35605
35684
  }
35606
35685
  return tok.accessToken || null;
35607
35686
  }
35687
+ isCurrentAccountGrant(account, refreshToken) {
35688
+ if (account.systemHome || !account.dir) return true;
35689
+ try {
35690
+ return parseCredentialDoc(readFileSync(this.getTokenFilePath(account), "utf8"))?.refreshToken === refreshToken;
35691
+ } catch {
35692
+ return false;
35693
+ }
35694
+ }
35608
35695
  /**
35609
35696
  * Query live user info (email) from Google OAuth userinfo endpoint.
35610
35697
  */
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.16",
3
+ "version": "0.6.17",
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",