dsh-agy-link 0.6.27 → 0.6.29

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,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.29 (2026-11-15)
4
+
5
+ ### English
6
+
7
+ - **Fix(models): a transient refusal can no longer blacklist a model's reasoning efforts (fixes #115).** When agy's model-config fetch fails (e.g. a `loadCodeAssist` TLS timeout), its print-mode validation emits a perfectly well-formed `--effort is not supported for model "X"` even though `agy models` lists that level. `streamWithEffortRetry()` learned ANY such refusal as a static capability: the model went into `effort-unsupported.json`, `resolveModel()` stopped advertising `reasoning`, and DSH then rejected later turns with `UNSUPPORTED_REASONING_EFFORT` while the live catalog still showed `xhigh`. A new `ModelCatalog.advertisedEfforts()` collects the efforts the **discovered** catalog (base + per-account) advertises; a refusal that contradicts it is still replayed without `--effort` (the #67 invariant) but is NOT persisted. Fallback entries are deliberately not evidence.
8
+ - **Fix(models): `effort-unsupported.json` is now live-reloaded.** The host no longer caches the file for the process lifetime, and `EffortPolicy` rebuilds when the seed changes (keeping refusals learned in the current process), so an operator clearing a false entry no longer needs to restart DSH.
9
+ - Tests: real discovered-catalog regression (refusal not learned, effort row preserved), external-edit visibility, and file re-read. Thanks to @AlaIchhe for the timeline, transcript evidence and the minimal reproduction.
10
+
11
+ ### 中文
12
+
13
+ - **修复(模型):瞬时拒绝不再把模型的思考档位永久拉黑(修复 #115)。** agy 在模型配置拉取失败(如 `loadCodeAssist` TLS 超时)时,print-mode 硬校验会输出**格式完全合法**的 `--effort is not supported for model "X"`,而 `agy models` 明明列着该档位。`streamWithEffortRetry()` 此前把任何这类拒绝当作静态能力学习:写入 `effort-unsupported.json`、`resolveModel()` 不再发布 `reasoning`,于是 DSH 后续轮次直接抛 `UNSUPPORTED_REASONING_EFFORT`,档位行永久消失,而实时目录仍显示 `xhigh`。新增 `ModelCatalog.advertisedEfforts()` 汇总**已发现**目录(base + 各账号)声明的档位;与目录矛盾的拒绝仍按 #67 重放一次(不带 `--effort`),但**不落盘、不收回能力声明**。fallback 阵容是静态镜像,不作为证据。
14
+ - **修复(模型):`effort-unsupported.json` 现在即时生效。** 宿主不再对文件做进程级缓存,`EffortPolicy` 在 seed 变化时重建(保留本进程学到的条目),运维清空误学条目后无需重启 DSH。
15
+ - 测试:真实已发现目录回归(矛盾拒绝不学习、档位行保留)、外部修改即时可见、文件重读。感谢 @AlaIchhe 提供时间线、transcript 证据与最小复现。
16
+
17
+ ## 0.6.28 (2026-11-15)
18
+
19
+ ### English
20
+
21
+ - **Fix(auth): a terminal TOS quarantine can no longer be cleared by the same warmup request (fixes #114).** v0.6.26 correctly marked a `TOS_VIOLATION` account `authRequired`, but `handlePoolWarmup` then ran an unconditional `refreshAccountQuota(acc, true)`; the quota pipeline (and boot hygiene / token refresh) calls `clearAuthRequired` on any successful refresh. A banned account still has a valid refresh token, so the flag was set and cleared within one HTTP request, and `needsAuthReverify` would have retried it every 10 minutes. `clearAuthRequired(id, force = false)` now refuses to lift a terminal ban; only **explicit user actions** (a completed OAuth login or a fresh credential import) pass `force: true`. `needsAuthReverify()` excludes terminal errors. Regression tests: pure classifier, real `AccountPoolManager` stickiness, and a route-level warmup → forced quota refresh → still `authRequired` test.
22
+
23
+ ### 中文
24
+
25
+ - **修复(认证):TOS 终态隔离不再被同一轮 warmup 清除(修复 #114)。** v0.6.26 已正确把 `TOS_VIOLATION` 账号标为 `authRequired`,但 `handlePoolWarmup` 随后无条件执行 `refreshAccountQuota(acc, true)`,而配额流水线(以及启动凭据恢复、token 刷新)在任何一次刷新成功后都会调用 `clearAuthRequired`。被停用账号的 refresh_token 仍然有效,于是「打标记 → 清标记」发生在同一次 HTTP 请求内,`needsAuthReverify` 还会每 10 分钟重试一次。现在 `clearAuthRequired(id, force = false)` 拒绝解除终态封禁;只有**显式用户操作**(完成 OAuth 登录、重新导入凭据)传入 `force: true`。`needsAuthReverify()` 也排除终态错误。回归测试覆盖:纯分类器、真实 `AccountPoolManager` 的粘性,以及路由级「预热 → 强制配额刷新 → authRequired 仍为真」。
26
+
3
27
  ## 0.6.27 (2026-11-15)
4
28
 
5
29
  ### English
@@ -1491,6 +1491,16 @@ function accountSupportsModel(acc, model, pool, catalog) {
1491
1491
  if (acc.quotas && Object.keys(acc.quotas).length > 0 && acc.quotas.google !== void 0) return false;
1492
1492
  return true;
1493
1493
  }
1494
+ /**
1495
+ * A flagged account whose flag is old enough (or whose flag predates the
1496
+ * authMarkedAt bookkeeping) may be re-verified in the background. If the
1497
+ * stored token still works the flag clears itself; if not, the flag is
1498
+ * simply re-stamped.
1499
+ */
1500
+ /** A terminal account ban (Google TOS_VIOLATION) is not a transient auth error. */
1501
+ function isTerminalAuthError(message) {
1502
+ return typeof message === "string" && /TOS_VIOLATION/i.test(message);
1503
+ }
1494
1504
  function defaultPoolData() {
1495
1505
  return {
1496
1506
  version: 1,
@@ -3763,6 +3773,9 @@ var EffortPolicy = class {
3763
3773
  log;
3764
3774
  onLearned;
3765
3775
  cache = null;
3776
+ seedKey = "";
3777
+ /** Models learned in THIS process: survive an external edit of the seed. */
3778
+ learned = /* @__PURE__ */ new Set();
3766
3779
  constructor(seed, log, onLearned) {
3767
3780
  this.seed = seed;
3768
3781
  this.log = log;
@@ -3784,15 +3797,19 @@ var EffortPolicy = class {
3784
3797
  const set = this.models();
3785
3798
  if (this.isUnsupported(model)) return;
3786
3799
  set.add(model);
3800
+ this.learned.add(model);
3787
3801
  this.log?.("agy refused --effort for model \"" + model + "\" — it is now run without an effort flag (effort support is advisory in the catalog; see issue #67)");
3788
3802
  try {
3789
3803
  this.onLearned?.(model);
3790
3804
  } catch {}
3791
3805
  }
3792
3806
  models() {
3793
- if (this.cache === null) {
3794
- const seeded = this.seed() ?? [];
3795
- this.cache = new Set((Array.isArray(seeded) ? seeded : []).filter((m) => typeof m === "string" && m.trim() !== ""));
3807
+ const raw = this.seed() ?? [];
3808
+ const seeded = (Array.isArray(raw) ? raw : []).filter((m) => typeof m === "string" && m.trim() !== "");
3809
+ const key = seeded.join("\0");
3810
+ if (this.cache === null || key !== this.seedKey) {
3811
+ this.seedKey = key;
3812
+ this.cache = /* @__PURE__ */ new Set([...seeded, ...this.learned]);
3796
3813
  }
3797
3814
  return this.cache;
3798
3815
  }
@@ -4247,6 +4264,26 @@ var ModelCatalog = class ModelCatalog {
4247
4264
  hasAccountCatalog(accountId) {
4248
4265
  return this.accountCatalogs.has(accountId);
4249
4266
  }
4267
+ /**
4268
+ * Effort ids the LIVE DISCOVERED catalog advertises for one model (across the
4269
+ * base catalog and every per-account catalog). Fallback entries are excluded:
4270
+ * they are a static mirror, not proof about the installed agy build.
4271
+ *
4272
+ * Used to reject false "--effort is not supported" refusals: agy's print-mode
4273
+ * validation emits that text when its model-config fetch fails, even though
4274
+ * `agy models` lists the level (issue #115).
4275
+ */
4276
+ advertisedEfforts(modelId) {
4277
+ const out = /* @__PURE__ */ new Set();
4278
+ for (const cat of [this.current, ...this.accountCatalogs.values()]) {
4279
+ if (cat.source !== "discovered") continue;
4280
+ for (const m of cat.models) {
4281
+ if (m.id !== modelId || !Array.isArray(m.efforts)) continue;
4282
+ for (const e of m.efforts) if (typeof e === "string" && e !== "") out.add(e);
4283
+ }
4284
+ }
4285
+ return [...out];
4286
+ }
4250
4287
  /** Refresh if stale; never throws — failures keep the previous catalog. */
4251
4288
  async refreshIfNeeded(accountId) {
4252
4289
  if (this.refreshing) return this.refreshing;
@@ -4531,7 +4568,7 @@ async function* streamWithEffortRetry(deps, options) {
4531
4568
  const rawMsg = String(failure?.message ?? "");
4532
4569
  const refused = parseEffortUnsupported(rawMsg);
4533
4570
  if (refused !== null) {
4534
- deps.learnEffortUnsupported(refused);
4571
+ if (deps.catalogAdvertisesEffort?.(refused) !== true) deps.learnEffortUnsupported(refused);
4535
4572
  continue;
4536
4573
  }
4537
4574
  const unrecog = parseModelNotRecognized(rawMsg);
@@ -7135,9 +7172,19 @@ var PoolAdmin = class {
7135
7172
  delete acc.authMarkedAt;
7136
7173
  this.deps.persist();
7137
7174
  }
7138
- clearAuthRequired(id) {
7175
+ /**
7176
+ * Drop the "needs re-login" flag.
7177
+ *
7178
+ * Automatic paths (a successful quota/token refresh, boot-time credential
7179
+ * recovery) must NOT lift a TERMINAL TOS ban: those accounts still have a
7180
+ * valid refresh token, so every refresh would succeed and clear the ban
7181
+ * (issue #114). `force` is reserved for explicit user actions — a completed
7182
+ * re-login or a fresh credential import.
7183
+ */
7184
+ clearAuthRequired(id, force = false) {
7139
7185
  const acc = this.account(id);
7140
7186
  if (!acc) return;
7187
+ if (!force && isTerminalAuthError(acc.authError)) return;
7141
7188
  delete acc.authRequired;
7142
7189
  delete acc.authError;
7143
7190
  delete acc.authMarkedAt;
@@ -7954,8 +8001,8 @@ var AccountPoolManager = class {
7954
8001
  resetAccountIdentity(id, newEmail) {
7955
8002
  this.admin.resetAccountIdentity(id, newEmail);
7956
8003
  }
7957
- clearAuthRequired(id) {
7958
- this.admin.clearAuthRequired(id);
8004
+ clearAuthRequired(id, force = false) {
8005
+ this.admin.clearAuthRequired(id, force);
7959
8006
  }
7960
8007
  /** Drop an email label that is provably wrong (e.g. a foreign token overwrote it). */
7961
8008
  clearAccountEmail(id) {
@@ -34010,6 +34057,7 @@ var AgyAdapter = class extends LlmAdapter {
34010
34057
  yield* streamWithEffortRetry({
34011
34058
  streamAttempt: (opts, suppressEffort) => this.streamAttempt(opts, suppressEffort),
34012
34059
  learnEffortUnsupported: (model) => this.learnEffortUnsupported(model),
34060
+ catalogAdvertisesEffort: (model) => this.deps.catalog.advertisedEfforts(model).length > 0,
34013
34061
  onModelUnsupported: (unrecog) => {
34014
34062
  const fam = modelFamilyOf(unrecog);
34015
34063
  const pool = this.deps.pool;
package/dist/index.js CHANGED
@@ -595,9 +595,14 @@ const AUTH_REVERIFY_DELAY_MS = 6e5;
595
595
  * stored token still works the flag clears itself; if not, the flag is
596
596
  * simply re-stamped.
597
597
  */
598
+ /** A terminal account ban (Google TOS_VIOLATION) is not a transient auth error. */
599
+ function isTerminalAuthError(message) {
600
+ return typeof message === "string" && /TOS_VIOLATION/i.test(message);
601
+ }
598
602
  function needsAuthReverify(account, now = Date.now()) {
599
603
  if (!account.enabled) return false;
600
604
  if (!account.authRequired) return false;
605
+ if (isTerminalAuthError(account.authError)) return false;
601
606
  if (typeof account.authMarkedAt !== "number") return true;
602
607
  return now - account.authMarkedAt > AUTH_REVERIFY_DELAY_MS;
603
608
  }
@@ -966,6 +971,26 @@ var ModelCatalog = class ModelCatalog {
966
971
  hasAccountCatalog(accountId) {
967
972
  return this.accountCatalogs.has(accountId);
968
973
  }
974
+ /**
975
+ * Effort ids the LIVE DISCOVERED catalog advertises for one model (across the
976
+ * base catalog and every per-account catalog). Fallback entries are excluded:
977
+ * they are a static mirror, not proof about the installed agy build.
978
+ *
979
+ * Used to reject false "--effort is not supported" refusals: agy's print-mode
980
+ * validation emits that text when its model-config fetch fails, even though
981
+ * `agy models` lists the level (issue #115).
982
+ */
983
+ advertisedEfforts(modelId) {
984
+ const out = /* @__PURE__ */ new Set();
985
+ for (const cat of [this.current, ...this.accountCatalogs.values()]) {
986
+ if (cat.source !== "discovered") continue;
987
+ for (const m of cat.models) {
988
+ if (m.id !== modelId || !Array.isArray(m.efforts)) continue;
989
+ for (const e of m.efforts) if (typeof e === "string" && e !== "") out.add(e);
990
+ }
991
+ }
992
+ return [...out];
993
+ }
969
994
  /** Refresh if stale; never throws — failures keep the previous catalog. */
970
995
  async refreshIfNeeded(accountId) {
971
996
  if (this.refreshing) return this.refreshing;
@@ -5593,6 +5618,9 @@ var EffortPolicy = class {
5593
5618
  log;
5594
5619
  onLearned;
5595
5620
  cache = null;
5621
+ seedKey = "";
5622
+ /** Models learned in THIS process: survive an external edit of the seed. */
5623
+ learned = /* @__PURE__ */ new Set();
5596
5624
  constructor(seed, log, onLearned) {
5597
5625
  this.seed = seed;
5598
5626
  this.log = log;
@@ -5614,15 +5642,19 @@ var EffortPolicy = class {
5614
5642
  const set = this.models();
5615
5643
  if (this.isUnsupported(model)) return;
5616
5644
  set.add(model);
5645
+ this.learned.add(model);
5617
5646
  this.log?.("agy refused --effort for model \"" + model + "\" — it is now run without an effort flag (effort support is advisory in the catalog; see issue #67)");
5618
5647
  try {
5619
5648
  this.onLearned?.(model);
5620
5649
  } catch {}
5621
5650
  }
5622
5651
  models() {
5623
- if (this.cache === null) {
5624
- const seeded = this.seed() ?? [];
5625
- this.cache = new Set((Array.isArray(seeded) ? seeded : []).filter((m) => typeof m === "string" && m.trim() !== ""));
5652
+ const raw = this.seed() ?? [];
5653
+ const seeded = (Array.isArray(raw) ? raw : []).filter((m) => typeof m === "string" && m.trim() !== "");
5654
+ const key = seeded.join("\0");
5655
+ if (this.cache === null || key !== this.seedKey) {
5656
+ this.seedKey = key;
5657
+ this.cache = /* @__PURE__ */ new Set([...seeded, ...this.learned]);
5626
5658
  }
5627
5659
  return this.cache;
5628
5660
  }
@@ -5866,7 +5898,7 @@ async function* streamWithEffortRetry(deps, options) {
5866
5898
  const rawMsg = String(failure?.message ?? "");
5867
5899
  const refused = parseEffortUnsupported(rawMsg);
5868
5900
  if (refused !== null) {
5869
- deps.learnEffortUnsupported(refused);
5901
+ if (deps.catalogAdvertisesEffort?.(refused) !== true) deps.learnEffortUnsupported(refused);
5870
5902
  continue;
5871
5903
  }
5872
5904
  const unrecog = parseModelNotRecognized(rawMsg);
@@ -7710,9 +7742,19 @@ var PoolAdmin = class {
7710
7742
  delete acc.authMarkedAt;
7711
7743
  this.deps.persist();
7712
7744
  }
7713
- clearAuthRequired(id) {
7745
+ /**
7746
+ * Drop the "needs re-login" flag.
7747
+ *
7748
+ * Automatic paths (a successful quota/token refresh, boot-time credential
7749
+ * recovery) must NOT lift a TERMINAL TOS ban: those accounts still have a
7750
+ * valid refresh token, so every refresh would succeed and clear the ban
7751
+ * (issue #114). `force` is reserved for explicit user actions — a completed
7752
+ * re-login or a fresh credential import.
7753
+ */
7754
+ clearAuthRequired(id, force = false) {
7714
7755
  const acc = this.account(id);
7715
7756
  if (!acc) return;
7757
+ if (!force && isTerminalAuthError(acc.authError)) return;
7716
7758
  delete acc.authRequired;
7717
7759
  delete acc.authError;
7718
7760
  delete acc.authMarkedAt;
@@ -8221,8 +8263,8 @@ var AccountPoolManager = class {
8221
8263
  resetAccountIdentity(id, newEmail) {
8222
8264
  this.admin.resetAccountIdentity(id, newEmail);
8223
8265
  }
8224
- clearAuthRequired(id) {
8225
- this.admin.clearAuthRequired(id);
8266
+ clearAuthRequired(id, force = false) {
8267
+ this.admin.clearAuthRequired(id, force);
8226
8268
  }
8227
8269
  /** Drop an email label that is provably wrong (e.g. a foreign token overwrote it). */
8228
8270
  clearAccountEmail(id) {
@@ -34529,6 +34571,7 @@ var AgyAdapter = class extends LlmAdapter {
34529
34571
  yield* streamWithEffortRetry({
34530
34572
  streamAttempt: (opts, suppressEffort) => this.streamAttempt(opts, suppressEffort),
34531
34573
  learnEffortUnsupported: (model) => this.learnEffortUnsupported(model),
34574
+ catalogAdvertisesEffort: (model) => this.deps.catalog.advertisedEfforts(model).length > 0,
34532
34575
  onModelUnsupported: (unrecog) => {
34533
34576
  const fam = modelFamilyOf(unrecog);
34534
34577
  const pool = this.deps.pool;
@@ -37521,7 +37564,7 @@ var PoolAuthFlow = class {
37521
37564
  } catch {}
37522
37565
  if (alias?.trim()) this.pool.setAccountAlias(existing.id, alias.trim());
37523
37566
  if (proxyUrl?.trim()) this.pool.setAccountProxy(existing.id, proxyUrl.trim());
37524
- this.pool.clearAuthRequired(existing.id);
37567
+ this.pool.clearAuthRequired(existing.id, true);
37525
37568
  this.pool.clearCooldown(existing.id, void 0, true);
37526
37569
  this.pool.updateAccountQuotas(existing.id, existing.quotas ?? {}, email);
37527
37570
  this.quota.refreshAccountQuota(existing).catch(() => void 0);
@@ -37634,7 +37677,7 @@ var PoolAuthFlow = class {
37634
37677
  renameSync(stagedFile, targetFile);
37635
37678
  saveCredentialBackup(targetFile);
37636
37679
  this.pool.updateAccountQuotas(account.id, {}, email);
37637
- this.pool.clearAuthRequired(account.id);
37680
+ this.pool.clearAuthRequired(account.id, true);
37638
37681
  this.pool.cleanupStagingSlot(flow.dir);
37639
37682
  this.quota.refreshAccountQuota(account).catch(() => void 0);
37640
37683
  this.flow = null;
@@ -39629,24 +39672,21 @@ function createHostServices(ctx, entryConfig = {}) {
39629
39672
  telemetryFlags: true
39630
39673
  });
39631
39674
  const effortUnsupportedPath = () => join(stateDir(), "effort-unsupported.json");
39632
- let effortUnsupportedCache = null;
39633
39675
  const readEffortUnsupported = () => {
39634
- if (effortUnsupportedCache !== null) return effortUnsupportedCache;
39635
39676
  try {
39636
39677
  const raw = existsSync(effortUnsupportedPath()) ? JSON.parse(readFileSync(effortUnsupportedPath(), "utf8")) : [];
39637
- effortUnsupportedCache = Array.isArray(raw) ? raw.filter((m) => typeof m === "string" && m.trim() !== "") : [];
39678
+ return Array.isArray(raw) ? raw.filter((m) => typeof m === "string" && m.trim() !== "") : [];
39638
39679
  } catch {
39639
- effortUnsupportedCache = [];
39680
+ return [];
39640
39681
  }
39641
- return effortUnsupportedCache;
39642
39682
  };
39643
39683
  const rememberEffortUnsupported = (model) => {
39644
39684
  const known = readEffortUnsupported();
39645
39685
  if (known.some((m) => m.trim().toLowerCase() === model.trim().toLowerCase())) return;
39646
- effortUnsupportedCache = [...known, model];
39686
+ const next = [...known, model];
39647
39687
  try {
39648
39688
  mkdirSync(stateDir(), { recursive: true });
39649
- writeFileSync(effortUnsupportedPath(), JSON.stringify(effortUnsupportedCache, null, 2), "utf8");
39689
+ writeFileSync(effortUnsupportedPath(), JSON.stringify(next, null, 2), "utf8");
39650
39690
  } catch (e) {
39651
39691
  log("failed to persist the effort-unsupported list: " + String(e));
39652
39692
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.6.27",
3
+ "version": "0.6.29",
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",