dsh-agy-link 0.6.46 → 0.6.48

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,67 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.48 (2026-11-20)
4
+
5
+ ### English
6
+
7
+ - **Fix(idle-grace): three linked causes of `INVALID_OUTPUT: agy stream ended without a result event` (merges PR #147).** Follow-up to #144/#146, from a report that the failure could still replay three times within milliseconds on continuation retries:
8
+ - **`waiting up to <duration> for N background task(s)`** is a second wording agy emits (e.g. `waiting up to 240m0s for 1 background task(s)`). `backgroundTasksFrom()` only matched `waiting for N`, so this variant returned `null` and the reaper was still armed for a positive count. The regex now accepts the optional `up to <duration>` segment.
9
+ - **An empty error result no longer hides the recoverable reply.** On SIGTERM agy can flush `{ ok: false, response: '' }`; `hasResult` counted that envelope, so the `idleGraceTerminated` recovery was skipped while `EventMapper` ignored the empty result without finishing. The guard is now `hasConsumableResult` (ok, or non-empty response), so a usable reply or the explicit notice is always appended.
10
+ - **A settled recording with no finishable event stops replaying.** When a continuation had no consumable result and no cuttable tool step after its resume point, every DSH retry re-drove the same dead recording (~20 ms each) until retries were exhausted. `hasFinishableEventFrom()` makes the adapter forget such a recording and spawn a fresh attempt instead. **This is the part that goes beyond what shipped in v0.6.47**, which only checked the result dimension — a recording cut mid-tool-step now resumes instead of re-running the work.
11
+ - Note: v0.6.47 independently landed the first two items and the `recording` helpers; this merge keeps that structure and takes the wider adapter predicate plus PR #147's regression suite (4 new tests, 347 lines).
12
+
13
+ ### 中文
14
+
15
+ - **修复(idle-grace):`INVALID_OUTPUT: agy stream ended without a result event` 的三条关联成因(合并 PR #147)。** 是 #144/#146 的后续,源于「该失败在续接重试时仍会在毫秒级重复三次」的报告:
16
+ - **`waiting up to <duration> for N background task(s)`** 是 agy 的第二种措辞(例如 `waiting up to 240m0s for 1 background task(s)`)。`backgroundTasksFrom()` 只匹配 `waiting for N`,该变体返回 `null`,于是正数计数下收割器仍会被武装。正则现在接受可选的 `up to <duration>` 片段。
17
+ - **空的错误 result 不再掩盖可恢复的回复。** SIGTERM 时 agy 可能刷出 `{ ok: false, response: '' }`;`hasResult` 把这个信封算作结果,导致 `idleGraceTerminated` 的恢复逻辑被跳过,而 `EventMapper` 又忽略空结果、不置 finished。判据改为 `hasConsumableResult`(ok 或非空 response),因此总会补上可用回复或明确提示。
18
+ - **没有可完成事件的 settled recording 不再被重放。** 续接点在可消费 result 与可切割工具步骤之后都没有事件时,DSH 每次重试都会重驱同一份死 recording(每次约 20ms)直到重试耗尽。`hasFinishableEventFrom()` 让适配器遗忘这种 recording 并新起一次尝试。**这部分超出 v0.6.47 已发布的内容**——它只检查 result 维度;在工具步骤中途被切断的 recording 现在会续接,而不是重跑已有工作。
19
+ - 说明:v0.6.47 已独立落地前两项与 `recording` 辅助方法;本次合并保留其结构,吸收更宽的适配器判据与 PR #147 的回归测试(4 条新用例,347 行)。
20
+
21
+ ## 0.6.47 (2026-11-20)
22
+
23
+ ### English
24
+
25
+ - **Perf(translation): warm persistent `agy` worker pool + `low` default effort + zero-enrichment aux path.**
26
+ - Added `TranslationWorkerPool` (`src/features/translation/worker.ts`) for POSIX hosts: keeps at most one warm `agy -p --output-format stream-json --input-format stream-json --mode plan` child (`cwd = tmpdir()`, no `--add-dir` / `--disable-slash-commands`) keyed by `${accountId}|${model}|${effort}`, with idle TTL (`5m`) and turn/char recycle (`8` turns / `32,000` chars). Subsequent translations skip the ~8–9s cold CLI startup and exit wait (~4–9s end-to-end vs ~20–40s before). Windows keeps `ctx.llm.stream` to preserve OS Credential Manager slot locking.
27
+ - Changed default `translateEffort` from `medium` to `low` (plain-language rewriting does not benefit from extended chain-of-thought latency) and updated the four locale hints accordingly.
28
+ - Auxiliary non-image runs (`isAux && !isImage`) now skip `SubagentTracker` and SQLite thought/tool-arg polling in `driveSpan`, and `startAttemptProcess` eagerly persists successful conversation bindings on `result` so rapid back-to-back bound calls never race child exit.
29
+ - **Fix(accounts/models): zero-redundancy per-account model lists, orchestrator model eligibility, and authoritative catalog attribution.**
30
+ - Fixed false `lack model "gemini-pro-orchestrator-neon" in their catalog` rejections on Pro/Ultra accounts: Google's REST `fetchAvailableModels` breakdown never includes CLI-synthesized orchestrator slugs (`gemini-pro-orchestrator-neon`, `gemini-pro-orchestrator-g1-pro`), so whenever an account's per-account `agy models` cache was absent or stale, `accountSupportsModel` vetoed it. `accountSupportsModel` now recognizes backing quota evidence (`gemini-4-neon` for `gemini-pro-orchestrator-neon`, Argon access for `gemini-pro-orchestrator-g1-pro`) and `baseModelSlug` strips `-xhigh` and `-tiered-*` suffixes; global `ModelCatalog.refresh()` now also attributes its result to the exact `probedAccount.id` it ran under, and the issue-#125 self-heal `refreshQuota` also warms undiscovered accounts.
31
+ - Added `buildAccountModelRows()` (`src/common/account-models.ts`) and surfaced `status.accountModels` (keyed by account id) from each account's real `agy models` discovery; `status.catalog.count` now tracks the active account's actual supported model count.
32
+ - Account cards render the deduplicated per-account list (with effort tags when applicable) instead of raw 30+ row REST quota dumps, filtering `-sonar`/`-image` noise, folding `-tiered`/effort suffixes in fallback mode, and leaving unknown quota percentages blank instead of fabricating `100%`.
33
+ - `POST /plugins/agy-link/pool/refresh-quota` now passes `id` to `catalog.forceRefresh(id)` on single-account sync and triggers `catalog.warmAccounts()` on full sync.
34
+ - **Fix(credentials): guard macOS/Linux `systemHome` against stale Keychain/disk clobbering and disabled-primary fallback.**
35
+ - When refreshing an OAuth token for `systemHome` (`acc_primary`) on macOS/Linux, `getValidAccessToken` re-verifies the live OS Keychain `refreshToken` before persisting and discards the response if the user switched accounts in `Antigravity.app` mid-flight; `persistRefreshedToken` also avoids creating a new disk token file under real `HOME` when none exists.
36
+ - Global `ModelCatalog` discovery now strictly skips disabled/unhealthy `lastActiveAccountId` and `primaryAccountId` entries and refuses to fall back to unisolated real `HOME` when all pool accounts are disabled.
37
+ - **Fix(quota): distinguish `VALIDATION_REQUIRED` and `TOS_VIOLATION` from free-tier `403 PERMISSION_DENIED` refusals.**
38
+ - `classifySummaryRefusal()` now checks `TOS_VIOLATION` and `VALIDATION_REQUIRED` BEFORE the generic `403 PERMISSION_DENIED` free-tier branch, preventing Pro/Ultra accounts that require Google web verification from being mislabeled as "free-tier · weekly quota only". Extracts Google's `validation_url` into `quotaUnavailable.actionUrl` and renders a red warning banner with a direct "Verify now" link in the console (all 4 locales).
39
+ - **Fix(adapter): eliminate `agy stream ended without a result event` crashes and dead 3x retry replays on idle-grace termination.**
40
+ - When `agy 1.5+` catches `SIGTERM` from the idle-grace reaper, it can emit a bare `{ ok: false, response: '' }` error result before exiting — which `EventMapper` ignores while `rec.hasResult` became `true`, skipping synthetic reply recovery and settling `failureInfo = null` (causing `agy stream ended without a result event` followed by 3 identical dead-recording replays). `handleAttemptOutcome` now checks for a *consumable* result (`ok || response !== ''`) before skipping recovery, and `AgyAdapter` forgets a settled recording lacking any consumable result past the cursor on retry instead of re-driving it.
41
+ - **Fix(client): eliminate Antigravity console/menu scroll flicker.**
42
+ - Static unreported (`—`) quota bars no longer run infinite `.agy-shimmer-track` GPU animations (shimmer runs only during active refresh), removed `contain: paint` / `transform: translateZ(0)` / `isolation: isolate` from `.agy-shimmer-track` and `transform` / `filter` from `.agy-btn:hover` / `.agy-card-hover`, and added ref-counted `acquireOverlaySuspend()` while `SettingsSection` is mounted so scrolling inside DSH's native Settings -> Antigravity view suspends background conversation scanners.
43
+
44
+ ### 中文
45
+
46
+ - **性能(翻译):常驻热进程池 + 默认 `low` 思考档 + 辅助通道免 SQLite 轮询。**
47
+ - 在 macOS/Linux 新增常驻翻译进程池 `TranslationWorkerPool`(`src/features/translation/worker.ts`):最多保留 1 个 `agy -p --output-format stream-json --input-format stream-json --mode plan`(`cwd = tmpdir()`,不传 `--add-dir` 与 `--disable-slash-commands`),按 `${accountId}|${model}|${effort}` 复用,空闲 `5m` 或累计 `8` 轮 / `32,000` 字符自动回收;后续翻译免除约 8–9 秒 CLI 冷启动与退出等待(端到端降至约 4–9 秒)。Windows 维持 `ctx.llm.stream` 以遵守系统凭据槽互斥锁。
48
+ - 默认 `translateEffort` 由 `medium` 调整为 `low`(口语化「译成人话」无需冗长思维链),同步更新四语言提示文案。
49
+ - 非生图辅助调用(`isAux && !isImage`)跳过 `SubagentTracker` 与 `driveSpan` 的 SQLite 思考/工具参数重试轮询,并在 `result` 成功事件到达时即刻落盘会话绑定,避免连续调用与子进程退出竞态。
50
+ - **修复(账号/模型列表与选号):单账号模型展示 0 冗余、修复编排模型误判不可用及全局发现目录归属。**
51
+ - 修复 Pro/Ultra 账号偶发误报 `lack model "gemini-pro-orchestrator-neon" in their catalog`:Google REST 配额接口(`fetchAvailableModels`)不会返回 CLI 虚拟编排模型(`gemini-pro-orchestrator-neon`、`gemini-pro-orchestrator-g1-pro`),导致账号尚未预热单账号 `agy models` 目录(如刚重启或刚加号)或缓存陈旧时被 `accountSupportsModel` 误拒。现支持分别通过 `gemini-4-neon` 配额与 Argon 权限证据识别编排模型,`baseModelSlug` 同步兼容 `-xhigh` 与 `-tiered-*` 后缀;全局 `ModelCatalog.refresh()` 成功时同步写入实际被探测的 `probedAccount.id` 账号目录,选号自愈 `refreshQuota` 亦补齐 `warmAccounts()`。
52
+ - 新增纯投影模块 `buildAccountModelRows()`(`src/common/account-models.ts`),并在 `/plugins/agy-link/status` 返回分账号发现目录 `accountModels`;`catalog.count` 同步对齐当前活跃账号真实可用模型数。
53
+ - 账号卡片展开列表不再直接平铺原始 REST 配额里的 30+ 冗余行,而是优先展示该账号自身 `agy models` 发现的去重模型与档位,回退时自动折叠 `-tiered`/档位后缀、过滤 `-sonar`/`-image` 内部项、按名称去重,且未知余量留空不伪造 `100%`。
54
+ - `POST /plugins/agy-link/pool/refresh-quota` 单账号刷新时显式传 `catalog.forceRefresh(id)`,全量刷新时同步触发 `catalog.warmAccounts()`。
55
+ - **修复(凭据隔离):加固 macOS/Linux `systemHome` 防切号踩踏与禁用主账号回退防护。**
56
+ - 非 Windows 下刷新 `systemHome`(`acc_primary`)OAuth token 落盘前,再次校验实时系统钥匙串 `refreshToken` 未切换;若刷新途中用户在 `Antigravity.app` 切号则丢弃旧响应,且当真实 `HOME` 下原本无磁盘 token 文件时不新建残片。
57
+ - `ModelCatalog` 全局发现回退严格跳过已停用或异常的 `lastActiveAccountId` / `primaryAccountId`,池内全部账号禁用时拒绝回退真实 `HOME` 触发无隔离探测。
58
+ - **修复(额度提示):区分 `VALIDATION_REQUIRED` / `TOS_VIOLATION` 与免费账号 `403 PERMISSION_DENIED`。**
59
+ - `classifySummaryRefusal()` 现优先识别 `TOS_VIOLATION` 与 `VALIDATION_REQUIRED`,不再把需要 Google 网页验证的 Pro/Ultra 账号误报为「免费账号 · 仅限周配额」;并从 403 响应提取 `validation_url` 存入 `quotaUnavailable.actionUrl`,在控制台以红色提示条直接给出「前往验证」链接(四语言)。
60
+ - **修复(运行稳定性):消除 `agy stream ended without a result event` 偶发失败与 3 次无效重放。**
61
+ - `agy 1.5+` 收到空闲收割 `SIGTERM` 时可能先吐出一个空的 `{ ok: false, response: '' }` 结果信封:`EventMapper` 会忽略该空错误,但原先 `rec.hasResult` 已为 `true` 导致跳过 SQLite 末条回复恢复并落入 `failureInfo = null`,进而触发 `agy stream ended without a result event` 且重试时 3 次重放同一条死记录。现改为判断是否存在可消费结果(`ok || response !== ''`),且续接命中无结果的已结束记录时主动忘记旧记录重新恢复。
62
+ - **修复(客户端):根治滚动 Antigravity 控制台/设置菜单闪屏。**
63
+ - 静态未上报(`—`)的配额条不再常驻无限 `.agy-shimmer-track` 动画(仅真正刷新中显示),移除 `.agy-shimmer-track` 的 `contain: paint` / `transform: translateZ(0)` / `isolation: isolate` 及 `.agy-btn:hover` / `.agy-card-hover` 的 `transform` / `filter` 合成层抖动,并为原生设置页挂载的 `SettingsSection` 增加引用计数 `acquireOverlaySuspend()` 暂停后台会话 DOM 扫描器。
64
+
3
65
  ## 0.6.46 (2026-11-20)
4
66
 
5
67
  ### English
@@ -162,7 +162,7 @@ function defaultConfig() {
162
162
  warmupModels: [PREFERRED_GEMINI_FLASH, PREFERRED_CLAUDE],
163
163
  autoTranslate: false,
164
164
  translateModel: PREFERRED_GEMINI_FLASH,
165
- translateEffort: "medium",
165
+ translateEffort: "low",
166
166
  translateTargetLanguage: "中文(简体)",
167
167
  translateMaxChars: 8e3,
168
168
  translateMaxTokens: 4096,
@@ -1480,7 +1480,7 @@ function accountHasArgon(acc, pool, catalog) {
1480
1480
  if (catalog && catalog.source === "discovered") return catalog.models?.some((m) => isArgonModel(m.id)) ?? false;
1481
1481
  return false;
1482
1482
  }
1483
- const EFFORT_SUFFIX_RE = /-(?:low|medium|high|tiered|thinking)$/i;
1483
+ const EFFORT_SUFFIX_RE = /-(?:tiered-)?(?:low|medium|high|xhigh|tiered|thinking)$/i;
1484
1484
  /**
1485
1485
  * Return the un-tiered base model slug (e.g. claude-opus-4-6-thinking -> claude-opus-4-6,
1486
1486
  * claude-opus-5-5-high -> claude-opus-5-5).
@@ -1502,6 +1502,14 @@ function modelMatches(requestedModel, candidateModelId) {
1502
1502
  if (r === c) return true;
1503
1503
  return baseModelSlug(r) === baseModelSlug(c);
1504
1504
  }
1505
+ function quotaSupportsModel(acc, clean, pool, catalog) {
1506
+ const familyQuotaModels = acc.quotas?.[modelFamilyOf(clean)]?.models;
1507
+ if (Array.isArray(familyQuotaModels) && familyQuotaModels.some((m) => modelMatches(clean, m.modelId))) return true;
1508
+ const lower = clean.toLowerCase();
1509
+ if (lower === "gemini-pro-orchestrator-neon") return Array.isArray(familyQuotaModels) && familyQuotaModels.some((m) => modelMatches("gemini-4-neon", m.modelId));
1510
+ if (lower === "gemini-pro-orchestrator-g1-pro") return accountHasArgon(acc, pool, catalog);
1511
+ return false;
1512
+ }
1505
1513
  /**
1506
1514
  * Determine whether a managed account supports a specific model.
1507
1515
  * If the account's quota or discovered catalog enumerates models for that family,
@@ -1514,14 +1522,13 @@ function accountSupportsModel(acc, model, pool, catalog) {
1514
1522
  if (isArgonModel(clean)) return accountHasArgon(acc, pool, catalog);
1515
1523
  if (catalog && catalog.source === "discovered" && Array.isArray(catalog.models) && catalog.models.length > 0) {
1516
1524
  if (catalog.models.some((m) => modelMatches(clean, m.id))) return true;
1517
- const familyQuotaModels = acc.quotas?.[modelFamilyOf(clean)]?.models;
1518
- if (Array.isArray(familyQuotaModels) && familyQuotaModels.some((m) => modelMatches(clean, m.modelId))) return true;
1525
+ if (quotaSupportsModel(acc, clean, pool, catalog)) return true;
1519
1526
  return false;
1520
1527
  }
1521
1528
  const family = modelFamilyOf(clean);
1522
1529
  const familyQuota = acc.quotas?.[family];
1523
1530
  if (familyQuota) {
1524
- if (Array.isArray(familyQuota.models) && familyQuota.models.length > 0) return familyQuota.models.some((m) => modelMatches(clean, m.modelId));
1531
+ if (Array.isArray(familyQuota.models) && familyQuota.models.length > 0) return quotaSupportsModel(acc, clean, pool, catalog);
1525
1532
  return true;
1526
1533
  }
1527
1534
  if (acc.quotas && Object.keys(acc.quotas).length > 0 && acc.quotas.google !== void 0) return false;
@@ -2490,6 +2497,27 @@ var RunRecording = class {
2490
2497
  get hasResult() {
2491
2498
  return this.events.some((e) => e.kind === "result");
2492
2499
  }
2500
+ /** Whether a result event that EventMapper will finish on (ok, or non-empty error response) was recorded. */
2501
+ get hasConsumableResult() {
2502
+ const r = this.getResultEvent();
2503
+ return r !== null && (r.ok || r.response !== "");
2504
+ }
2505
+ /**
2506
+ * Whether any recorded event at or after `from` can finish a span cleanly
2507
+ * (a consumable result envelope, or a completed tool step when `cutOnTool`
2508
+ * is enabled). A settled recording with `failureInfo === null` and no such
2509
+ * event would otherwise replay `INVALID_OUTPUT: agy stream ended without a
2510
+ * result event` on every continuation retry.
2511
+ */
2512
+ hasFinishableEventFrom(from, cutOnTool = true) {
2513
+ for (let i = Math.max(0, from); i < this.events.length; i++) {
2514
+ const ev = this.events[i];
2515
+ if (ev === void 0) continue;
2516
+ if (ev.kind === "result" && (ev.ok || ev.response !== "")) return true;
2517
+ if (cutOnTool && ev.kind === "step" && ev.stepKind === "tool" && ev.tool !== void 0 && (ev.state === "DONE" || ev.state === "ERROR" || ev.state === "RUNNING" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) return true;
2518
+ }
2519
+ return false;
2520
+ }
2493
2521
  /** The last result envelope's finish-relevant projection, when one arrived. */
2494
2522
  getResultEvent() {
2495
2523
  for (let i = this.events.length - 1; i >= 0; i--) {
@@ -2501,6 +2529,20 @@ var RunRecording = class {
2501
2529
  }
2502
2530
  return null;
2503
2531
  }
2532
+ /**
2533
+ * True when at least one consumable `result` event (`ok` or non-empty
2534
+ * `response`) exists at index >= `from`. A settled recording with
2535
+ * `failureInfo === null` and no consumable result at `>= from` would always
2536
+ * fail with `agy stream ended without a result event` if re-driven.
2537
+ */
2538
+ hasConsumableResultFrom(from) {
2539
+ const start = Math.max(0, from);
2540
+ for (let i = start; i < this.events.length; i++) {
2541
+ const ev = this.events[i];
2542
+ if (ev !== void 0 && ev.kind === "result" && (ev.ok || ev.response !== "")) return true;
2543
+ }
2544
+ return false;
2545
+ }
2504
2546
  /** Event at an absolute index (bounds-checked). */
2505
2547
  eventAt(index) {
2506
2548
  return this.events[index];
@@ -3864,7 +3906,7 @@ async function resolveEventToolArgs(rec, ev, i, resolved) {
3864
3906
  }
3865
3907
  }
3866
3908
  }
3867
- async function* driveSpan(deps, rec, from, cutOnTool, useCodeWrapper, goalContext, supportsGoalUpdate, supportsPlanExit, signal, compactionNotice) {
3909
+ async function* driveSpan(deps, rec, from, cutOnTool, useCodeWrapper, goalContext, supportsGoalUpdate, supportsPlanExit, signal, compactionNotice, skipDbEnrichment = false) {
3868
3910
  if (signal?.aborted) {
3869
3911
  rec.requestAbort?.();
3870
3912
  yield {
@@ -3882,14 +3924,14 @@ async function* driveSpan(deps, rec, from, cutOnTool, useCodeWrapper, goalContex
3882
3924
  deps.runs.remember(rec);
3883
3925
  deps.runs.pin(rec.runId);
3884
3926
  try {
3885
- yield* driveSpanBody(deps, rec, from, cutOnTool, useCodeWrapper, goalContext, supportsGoalUpdate, supportsPlanExit, signal, compactionNotice);
3927
+ yield* driveSpanBody(deps, rec, from, cutOnTool, useCodeWrapper, goalContext, supportsGoalUpdate, supportsPlanExit, signal, compactionNotice, skipDbEnrichment);
3886
3928
  } finally {
3887
3929
  deps.runs.unpin(rec.runId);
3888
3930
  deps.runs.remember(rec);
3889
3931
  }
3890
3932
  }
3891
3933
  /** Body of {@link driveSpan}: map recorded events until the span finishes. */
3892
- async function* driveSpanBody(deps, rec, from, cutOnTool, useCodeWrapper, goalContext, supportsGoalUpdate, supportsPlanExit, signal, compactionNotice) {
3934
+ async function* driveSpanBody(deps, rec, from, cutOnTool, useCodeWrapper, goalContext, supportsGoalUpdate, supportsPlanExit, signal, compactionNotice, skipDbEnrichment = false) {
3893
3935
  const queue = new ChunkQueue();
3894
3936
  let abortedLocally = false;
3895
3937
  const onAbort = () => {
@@ -3930,9 +3972,11 @@ async function* driveSpanBody(deps, rec, from, cutOnTool, useCodeWrapper, goalCo
3930
3972
  try {
3931
3973
  for await (const ev of rec.eventsFrom(from)) {
3932
3974
  if (abortedLocally || signal?.aborted) break;
3933
- await resolveEventThought(rec, ev, i, resolvedThoughts, pendingThoughtSteps);
3934
- if (pendingThoughtSteps.size > 0) await resolvePendingThoughts(rec, ev, resolvedThoughts, pendingThoughtSteps);
3935
- await resolveEventToolArgs(rec, ev, i, resolved);
3975
+ if (!skipDbEnrichment) {
3976
+ await resolveEventThought(rec, ev, i, resolvedThoughts, pendingThoughtSteps);
3977
+ if (pendingThoughtSteps.size > 0) await resolvePendingThoughts(rec, ev, resolvedThoughts, pendingThoughtSteps);
3978
+ await resolveEventToolArgs(rec, ev, i, resolved);
3979
+ }
3936
3980
  for (const ch of mapper.map(ev, i)) queue.push(ch);
3937
3981
  i++;
3938
3982
  if (mapper.isFinished) {
@@ -4783,7 +4827,7 @@ var ModelCatalog = class ModelCatalog {
4783
4827
  const ac = new AbortController();
4784
4828
  const timer = setTimeout(() => ac.abort(), 3e4);
4785
4829
  try {
4786
- const { stdout, stderr } = await this.discover(ac.signal, accountId);
4830
+ const { stdout, stderr, accountId: probedAccountId } = await this.discover(ac.signal, accountId);
4787
4831
  if (isUnauthenticatedModelsFallback(stdout, stderr)) {
4788
4832
  const msg = "agy models returned unauthenticated fallback output";
4789
4833
  if (accountId) {
@@ -4812,7 +4856,10 @@ var ModelCatalog = class ModelCatalog {
4812
4856
  if (accountId) {
4813
4857
  this.accountCatalogs.set(accountId, newCatalog);
4814
4858
  if (this.current.source !== "discovered") this.current = newCatalog;
4815
- } else this.current = newCatalog;
4859
+ } else {
4860
+ this.current = newCatalog;
4861
+ if (probedAccountId) this.accountCatalogs.set(probedAccountId, newCatalog);
4862
+ }
4816
4863
  this.persistToDisk();
4817
4864
  if (changed && announce) this.onUpdate?.();
4818
4865
  return;
@@ -5307,7 +5354,7 @@ function preemptAgyAutoUpdate(env = process.env, now = Date.now()) {
5307
5354
  * boundary cut the line), which keeps the conservative "arm the grace" path.
5308
5355
  */
5309
5356
  function backgroundTasksFrom(text) {
5310
- const match = /root agent idle;\s*waiting\s+for\s+(\d+)\s+background/i.exec(text);
5357
+ const match = /root agent idle;\s*waiting(?:\s+up\s+to\s+\S+)?\s+for\s+(\d+)\s+background/i.exec(text);
5311
5358
  if (match === null) return null;
5312
5359
  const count = Number(match[1]);
5313
5360
  return Number.isSafeInteger(count) && count >= 0 ? count : null;
@@ -34101,7 +34148,7 @@ function buildSpawnArgs(input, printTimeoutMinutes, log) {
34101
34148
  };
34102
34149
  }
34103
34150
  /** Create the recording, parser, HOME snapshot and tool watchdog for one run. */
34104
- function createAttemptRecorder(deps, cfg, account, initialConversationId) {
34151
+ function createAttemptRecorder(deps, cfg, account, initialConversationId, trackSubagents = true) {
34105
34152
  const rec = deps.runs.create();
34106
34153
  rec.accountHome = account && account.dir ? account.dir : void 0;
34107
34154
  const conversationsDir = conversationsDirFor(rec.accountHome);
@@ -34109,7 +34156,7 @@ function createAttemptRecorder(deps, cfg, account, initialConversationId) {
34109
34156
  const parser = new StreamJsonParser();
34110
34157
  deps.onParser?.(parser);
34111
34158
  const watchdog = createToolWatchdog(deps.log, cfg);
34112
- const tracker = new SubagentTracker({
34159
+ const tracker = trackSubagents ? new SubagentTracker({
34113
34160
  conversationId: initialConversationId,
34114
34161
  resumed: Boolean(initialConversationId),
34115
34162
  accountHome: rec.accountHome,
@@ -34120,7 +34167,7 @@ function createAttemptRecorder(deps, cfg, account, initialConversationId) {
34120
34167
  noteActivity: () => {
34121
34168
  watchdog.markEvent();
34122
34169
  }
34123
- });
34170
+ }) : void 0;
34124
34171
  const state = {
34125
34172
  rec,
34126
34173
  parser,
@@ -34130,8 +34177,8 @@ function createAttemptRecorder(deps, cfg, account, initialConversationId) {
34130
34177
  printTimeoutMinutes: watchdog.printTimeoutMinutes,
34131
34178
  attachProcess: (proc) => {
34132
34179
  watchdog.attach(proc);
34133
- tracker.start();
34134
- proc.outcome.finally(() => tracker.stop());
34180
+ tracker?.start();
34181
+ proc.outcome.finally(() => tracker?.stop());
34135
34182
  },
34136
34183
  feedLine: (line, onEvent, onFirstEvent) => {
34137
34184
  watchdog.markEvent();
@@ -34139,11 +34186,11 @@ function createAttemptRecorder(deps, cfg, account, initialConversationId) {
34139
34186
  for (const ev of parser.feed(line + "\n")) {
34140
34187
  if (ev.kind === "init" && ev.conversationId) {
34141
34188
  state.streamCid = ev.conversationId;
34142
- tracker.setConversationId(ev.conversationId);
34189
+ tracker?.setConversationId(ev.conversationId);
34143
34190
  }
34144
34191
  if (ev.kind === "result" && ev.conversationId !== "") {
34145
34192
  state.streamCid = ev.conversationId;
34146
- tracker.setConversationId(ev.conversationId);
34193
+ tracker?.setConversationId(ev.conversationId);
34147
34194
  }
34148
34195
  watchdog.trackStep(ev);
34149
34196
  rec.append(ev);
@@ -34156,7 +34203,7 @@ function createAttemptRecorder(deps, cfg, account, initialConversationId) {
34156
34203
  for (const ev of parser.flush()) {
34157
34204
  if (ev.kind === "result" && ev.conversationId !== "") {
34158
34205
  state.streamCid = ev.conversationId;
34159
- tracker.setConversationId(ev.conversationId);
34206
+ tracker?.setConversationId(ev.conversationId);
34160
34207
  }
34161
34208
  rec.append(ev);
34162
34209
  if (typeof onEvent === "function") try {
@@ -34166,7 +34213,7 @@ function createAttemptRecorder(deps, cfg, account, initialConversationId) {
34166
34213
  },
34167
34214
  stop: () => {
34168
34215
  watchdog.stop();
34169
- tracker.stop();
34216
+ tracker?.stop();
34170
34217
  },
34171
34218
  conversationId: () => state.streamCid ?? diffConversations(before, conversationsDir).conversationId
34172
34219
  };
@@ -34230,6 +34277,19 @@ async function waitForRunSettle(run, timeoutMs) {
34230
34277
  }
34231
34278
  return run.isSettled;
34232
34279
  }
34280
+ function persistBindingOnResult(deps, input, recorder, ev) {
34281
+ if (ev.kind !== "result" || !ev.ok || looksLikeTosViolation(ev.response) || !input.persistBinding || input.sessionAccountKey === "" || deps.isSuperseded(input.sessionKey, recorder.rec)) return;
34282
+ const finalId = input.binding !== void 0 ? input.binding.conversationId : ev.conversationId || recorder.streamCid;
34283
+ if (!finalId) return;
34284
+ const mergedImages = input.binding?.sentImageIds || input.newlySentImageIds.length > 0 ? [.../* @__PURE__ */ new Set([...input.binding?.sentImageIds ?? [], ...input.newlySentImageIds])] : void 0;
34285
+ deps.store.set(input.sessionAccountKey, {
34286
+ conversationId: finalId,
34287
+ lastMessageCount: input.messages.length,
34288
+ updatedAt: Date.now(),
34289
+ model: input.activeModel,
34290
+ ...mergedImages && mergedImages.length > 0 ? { sentImageIds: mergedImages } : {}
34291
+ });
34292
+ }
34233
34293
  /**
34234
34294
  * Spawn the child under the held slot. Installs the line callback (parser feed
34235
34295
  * + tool watchdog + first-event hand-off), registers the run for steer
@@ -34273,9 +34333,10 @@ async function startAttemptProcess(deps, input, spawn, recorder, slot) {
34273
34333
  stdinPayload: spawn.stdinPayload,
34274
34334
  preemptAutoUpdate: cfg.suppressAgyAutoUpdate,
34275
34335
  stderrKeepalive: true,
34276
- onLine: (line) => {
34277
- recorder.feedLine(line, input.agyOnEvent, () => slotHandoff?.onFirstEvent());
34278
- }
34336
+ onLine: (line) => recorder.feedLine(line, (ev) => {
34337
+ persistBindingOnResult(deps, input, recorder, ev);
34338
+ input.agyOnEvent?.(ev);
34339
+ }, () => slotHandoff?.onFirstEvent())
34279
34340
  });
34280
34341
  spawned = true;
34281
34342
  recorder.attachProcess(proc);
@@ -34785,7 +34846,7 @@ async function handleAttemptOutcome(deps, input, ctx) {
34785
34846
  deps.clearInFlightPrompt(sessionKey, spawn.prompt);
34786
34847
  recorder.drain(input.agyOnEvent);
34787
34848
  const conversationId = recorder.conversationId();
34788
- if (!rec.hasResult && outcome.idleGraceTerminated) {
34849
+ if (!rec.hasConsumableResult && outcome.idleGraceTerminated) {
34789
34850
  const recovered = conversationId === null ? "" : recoverFinalReply(conversationId, rec.accountHome);
34790
34851
  const synthResult = {
34791
34852
  kind: "result",
@@ -35091,13 +35152,14 @@ var AgyAdapter = class extends LlmAdapter {
35091
35152
  if (continuation !== null) {
35092
35153
  const rec = this.deps.runs.get(continuation.runId);
35093
35154
  const deadFailure = rec !== void 0 && rec.isSettled ? rec.failureInfo : null;
35094
- if (rec !== void 0 && !(deadFailure !== null && this.claimFailover(sessionKey, deadFailure.code))) {
35155
+ const deadNoResult = rec !== void 0 && rec.isSettled && deadFailure === null && !rec.hasFinishableEventFrom(continuation.eventIndex + 1, hasToolSupport);
35156
+ if (rec !== void 0 && !deadNoResult && !(deadFailure !== null && this.claimFailover(sessionKey, deadFailure.code))) {
35095
35157
  yield* driveSpan(this.deps, rec, continuation.eventIndex + 1, hasToolSupport, isCodeMode, goalContext, supportsGoalUpdate, supportsPlanExit, options.signal);
35096
35158
  return;
35097
35159
  }
35098
35160
  if (rec !== void 0) {
35099
35161
  this.deps.runs.forget(continuation.runId);
35100
- this.warnOnce("dead-continuation:" + continuation.runId, "agy run " + continuation.runId + " settled in " + (deadFailure?.code ?? "") + " — retrying this step instead of replaying it" + (deadFailure?.code === Err.NETWORK && this.sharesSingleEgress() ? " on the same account (shared egress)" : " on another account"));
35162
+ this.warnOnce("dead-continuation:" + continuation.runId, deadNoResult ? "agy run " + continuation.runId + " settled without a consumable result — retrying this step instead of replaying it" : "agy run " + continuation.runId + " settled in " + (deadFailure?.code ?? "") + " — retrying this step instead of replaying it" + (deadFailure?.code === Err.NETWORK && this.sharesSingleEgress() ? " on the same account (shared egress)" : " on another account"));
35101
35163
  } else this.warnOnce("stale-continuation:" + continuation.runId, "agy run " + continuation.runId + " is no longer available in memory (server restarted?) — falling back to fresh turn prompt assembly");
35102
35164
  }
35103
35165
  const catalog = this.deps.catalog.get();