dsh-agy-link 0.6.30 → 0.6.32

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.32 (2026-11-17)
4
+
5
+ ### English
6
+
7
+ - **Fix(provider): a turn can no longer hang for hours on agy background tasks (merges PR #119).** When a command backgrounds itself (a dev server, or a GUI dialog blocking on an uncaught exception), agy's root agent finishes the reply but then waits up to 4h for the background task. Routine daemon stderr chatter (`fetchAvailableModels`, `token refreshed`, `loadCodeAssist`, …) was re-arming the stderr keepalive watchdog every ~6 minutes, so neither the 10-minute idle budget nor the 240-minute print timeout ever fired and `proc.outcome` never settled — DSH hung at `eventsFrom`. Now background stderr noise is filtered, `root agent idle; waiting …` starts a 5s grace then terminates the process tree (`idleGraceTerminated`), `classifyFailure()` treats that as a normal completion, and a synthetic successful `result` event closes the mapper/usage/finish chain when agy emitted no envelope. `openToolKeys` is released when the model resumes text/thinking or a tool reaches `RUNNING`, and `printTimeoutMinutes` respects `maxTurnMinutes` (default `longToolIdleMinutes: 240` is unchanged).
8
+ - **Refactor(timeouts): `IDLE_BACKGROUND_GRACE_MS` lives in `common/timeouts.ts`** alongside the other deadlines — no second constant inside `process.ts`. `.spec/process-lifecycle.md` documents the termination invariants (local, gitignored).
9
+ - Tests: five subprocess-bounded regressions (idle grace, both message forms, normal-completion classification, `RUNNING` tool card, noise not feeding the watchdog). Thanks to @Ronnoc for the diagnosis and patch.
10
+
11
+ ### 中文
12
+
13
+ - **修复(provider):一轮对话不再因 agy 后台任务挂起数小时(合并 PR #119)。** 命令自行后台化(dev server、未捕获异常卡住的 GUI 弹窗等)时,agy 根 Agent 已产出全部回复,却会为后台任务等待最多 4 小时;守护进程每约 6 分钟打印的例行 stderr 日志(`fetchAvailableModels`、`token refreshed`、`loadCodeAssist` 等)又不断喂狗,10 分钟空闲预算与 240 分钟 print 超时都不会触发,`proc.outcome` 永不 settle,DSH 卡在 `eventsFrom`。现在过滤后台噪声、识别 `root agent idle; waiting …` 后给 5s 宽限并终止进程树(`idleGraceTerminated`),`classifyFailure()` 视为正常完成;若 agy 未发 result envelope,则合成一条成功的 result 事件闭合 mapper/usage/finish 链。模型恢复 text/thinking 或工具进入 `RUNNING` 时释放 `openToolKeys`,`printTimeoutMinutes` 受 `maxTurnMinutes` 约束(缺省 `longToolIdleMinutes: 240` 不变)。
14
+ - **重构(超时常量)**:`IDLE_BACKGROUND_GRACE_MS` 与其他 deadline 一起收敛到 `common/timeouts.ts`,`process.ts` 不再另立常量。`.spec/process-lifecycle.md` 记录终止不变式(本地 gitignored)。
15
+ - 测试:5 条子进程有界回归(idle 宽限、两种文案、正常完成分类、`RUNNING` 工具卡片、噪声不喂狗)。感谢 @Ronnoc 的定位与补丁。
16
+
17
+ ## 0.6.31 (2026-11-16)
18
+
19
+ ### English
20
+
21
+ - **Refactor(host): extract the effort-unsupported persistence into its own store (5-day review).** `createEffortUnsupportedStore()` now owns the file path, the filter/dedupe rules, the picker notification and the live-reload invariant; the composition factory only wires it in. `src/host/services.ts` drops from 599 to 576 lines, giving the three modules that sat on the 600-line ceiling real headroom again. **No behaviour change** — the existing `HostServices` surface and `test/services.test.ts` contract are unchanged, and the new module has its own filesystem-level tests (filtering, invalid/missing file, live reload, dedupe, persistence failure). Architecture/budget gates stay at 215 modules, 0 cycles, 0 violations.
22
+
23
+ ### 中文
24
+
25
+ - **重构(host):把 effort-unsupported 持久化拆成独立 store(5 天全面 review)。** `createEffortUnsupportedStore()` 统一持有文件路径、过滤/去重规则、picker 广播与即时重载不变式;组合工厂只负责装配。`src/host/services.ts` 从 599 行降到 576 行,让三处贴在 600 行上限的模块重新有了余量。**行为零变化**:`HostServices` 对外形状与 `test/services.test.ts` 契约保持不变,新模块自带文件系统级测试(过滤、缺失/非法文件、外部修改即时生效、去重、写盘失败)。架构/预算门禁仍为 215 模块、0 环、0 违规。
26
+
3
27
  ## 0.6.30 (2026-11-16)
4
28
 
5
29
  ### English
@@ -2818,7 +2818,7 @@ var EventMapper = class {
2818
2818
  return;
2819
2819
  }
2820
2820
  if (ev.stepKind === "tool" && ev.tool) {
2821
- if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
2821
+ if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === "RUNNING" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
2822
2822
  if (this.opts.cutOnTool && !this.finished && ev.state === "ACTIVE" && !this.pendingAnnounced.has(ev.stepKey)) {
2823
2823
  this.pendingAnnounced.add(ev.stepKey);
2824
2824
  yield* this.ensureBlock("reasoning");
@@ -2829,6 +2829,7 @@ var EventMapper = class {
2829
2829
  }
2830
2830
  return;
2831
2831
  }
2832
+ if (ev.state === "RUNNING" && ev.tool.output === void 0) ev.tool.output = ev.text !== "" ? ev.text : "Tool is running as a background task";
2832
2833
  if (this.announcedTools.has(ev.stepKey)) return;
2833
2834
  this.announcedTools.add(ev.stepKey);
2834
2835
  if (!this.opts.cutOnTool) return;
@@ -4898,6 +4899,13 @@ function nodeScriptEnv(env) {
4898
4899
  * own idle budget so short-budget tests and genuine idle kills stay prompt.
4899
4900
  */
4900
4901
  const WATCHDOG_GRACE_MS = 5e3;
4902
+ /**
4903
+ * Grace after agy reports `root agent idle; waiting ... for background task(s)`.
4904
+ * The prompt turn's answer is already streamed; a stuck GUI dialog / background
4905
+ * child would otherwise keep print mode alive for hours (issue #119). Short and
4906
+ * fixed so the turn settles promptly instead of hanging DSH's event stream.
4907
+ */
4908
+ const IDLE_BACKGROUND_GRACE_MS = 5e3;
4901
4909
  //#endregion
4902
4910
  //#region src/host/auto-updater.ts
4903
4911
  function nonBlank(v) {
@@ -5059,7 +5067,9 @@ function createRunState(opts) {
5059
5067
  idleBudgetMs: opts.timeoutMs,
5060
5068
  watchdog: null,
5061
5069
  watchdogGraceUsed: false,
5062
- turnCap: null
5070
+ turnCap: null,
5071
+ idleGraceTimer: null,
5072
+ idleGraceTerminated: false
5063
5073
  };
5064
5074
  }
5065
5075
  function spawnAgyChild(opts, env, viaCmd, isNode) {
@@ -5143,6 +5153,9 @@ function armTurnCap(child, opts, state) {
5143
5153
  state.turnCap.unref?.();
5144
5154
  }
5145
5155
  }
5156
+ function isBackgroundStderrNoise(line) {
5157
+ return line.includes("fetchAvailableModels") || line.includes("loadCodeAssist") || line.includes("token refreshed") || line.includes("FetchConfig") || line.includes("ListExperiments") || line.includes("daily-cloudcode-pa.googleapis.com") || line.includes("http_helpers.go");
5158
+ }
5146
5159
  function attachOutputStreams(child, opts, state, refreshWatchdog) {
5147
5160
  const stdoutDecoder = makeLineDecoder(consoleOutputEncoding());
5148
5161
  const stderrDecoder = makeLineDecoder(consoleOutputEncoding());
@@ -5161,9 +5174,21 @@ function attachOutputStreams(child, opts, state, refreshWatchdog) {
5161
5174
  }
5162
5175
  });
5163
5176
  child.stderr?.on("data", (chunk) => {
5164
- if (opts.stderrKeepalive) refreshWatchdog();
5165
5177
  const text = stderrDecoder.push(chunk);
5166
- if (text !== "") state.stderr = (state.stderr + text).slice(-4096);
5178
+ if (text !== "") {
5179
+ state.stderr = (state.stderr + text).slice(-4096);
5180
+ if (/root agent idle;\s*waiting/i.test(text)) {
5181
+ if (!state.idleGraceTimer) {
5182
+ state.idleGraceTimer = setTimeout(() => {
5183
+ if (!state.settled) {
5184
+ state.idleGraceTerminated = true;
5185
+ killTree(child);
5186
+ }
5187
+ }, IDLE_BACKGROUND_GRACE_MS);
5188
+ state.idleGraceTimer.unref?.();
5189
+ }
5190
+ } else if (opts.stderrKeepalive && !isBackgroundStderrNoise(text)) refreshWatchdog();
5191
+ }
5167
5192
  });
5168
5193
  return {
5169
5194
  stdoutDecoder,
@@ -5177,6 +5202,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
5177
5202
  state.settled = true;
5178
5203
  if (state.watchdog) clearTimeout(state.watchdog);
5179
5204
  if (state.turnCap) clearTimeout(state.turnCap);
5205
+ if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
5180
5206
  opts.signal?.removeEventListener("abort", onAbort);
5181
5207
  const stdoutTail = decoders.stdoutDecoder.flush();
5182
5208
  if (stdoutTail !== "") {
@@ -5195,6 +5221,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
5195
5221
  timedOut: state.timedOut,
5196
5222
  aborted: state.aborted,
5197
5223
  capped: state.capped,
5224
+ idleGraceTerminated: state.idleGraceTerminated,
5198
5225
  stdout: state.stdout,
5199
5226
  stderrTail: state.stderr,
5200
5227
  durationMs: Date.now() - started
@@ -5237,6 +5264,7 @@ function startAgyProcess(opts) {
5237
5264
  else state.aborted = true;
5238
5265
  if (state.watchdog) clearTimeout(state.watchdog);
5239
5266
  if (state.turnCap) clearTimeout(state.turnCap);
5267
+ if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
5240
5268
  killTree(child);
5241
5269
  }
5242
5270
  };
@@ -6604,6 +6632,7 @@ function classifyEvent(obj, seq) {
6604
6632
  const text = delta !== void 0 ? delta : extractText(src);
6605
6633
  const stateV = pick(src, ["state"]);
6606
6634
  if (stateV === "ERROR" && toolInfo && !toolInfo.error) toolInfo.error = "tool execution failed";
6635
+ if (stateV === "RUNNING" && toolInfo && toolInfo.output === void 0 && text !== "") toolInfo.output = text;
6607
6636
  const usageRaw = pick(src, ["usage"]);
6608
6637
  return {
6609
6638
  kind: "step",
@@ -33172,7 +33201,8 @@ function createToolWatchdog(log, cfg) {
33172
33201
  const openToolKeys = /* @__PURE__ */ new Set();
33173
33202
  const openToolSince = /* @__PURE__ */ new Map();
33174
33203
  const longToolIdleMinutes = cfg.longToolIdleMinutes > 0 ? cfg.longToolIdleMinutes : 0;
33175
- const printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : 240, Math.ceil(cfg.timeoutMs / 6e4));
33204
+ let printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : Math.ceil(cfg.timeoutMs / 6e4), Math.ceil(cfg.timeoutMs / 6e4));
33205
+ if (cfg.maxTurnMinutes > 0 && printTimeoutMinutes > cfg.maxTurnMinutes) printTimeoutMinutes = cfg.maxTurnMinutes;
33176
33206
  const longToolIdleMs = longToolIdleMinutes > 0 ? longToolIdleMinutes * 6e4 : cfg.timeoutMs;
33177
33207
  const generationIdleMs = Math.max(cfg.timeoutMs, 9e5);
33178
33208
  let runningProc = null;
@@ -33217,18 +33247,27 @@ function createToolWatchdog(log, cfg) {
33217
33247
  apply();
33218
33248
  },
33219
33249
  trackStep: (ev) => {
33220
- if (ev.kind !== "step" || ev.stepKind !== "tool" || ev.tool === void 0) return;
33221
- if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
33222
- if (!openToolKeys.has(ev.stepKey)) {
33223
- openToolKeys.add(ev.stepKey);
33224
- openToolSince.set(ev.stepKey, Date.now());
33250
+ if (ev.kind !== "step") return;
33251
+ if (ev.stepKind === "tool" && ev.tool !== void 0) {
33252
+ if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === "RUNNING" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
33253
+ if (!openToolKeys.has(ev.stepKey)) {
33254
+ openToolKeys.add(ev.stepKey);
33255
+ openToolSince.set(ev.stepKey, Date.now());
33256
+ apply();
33257
+ start();
33258
+ }
33259
+ } else if (openToolKeys.delete(ev.stepKey)) {
33260
+ openToolSince.delete(ev.stepKey);
33225
33261
  apply();
33226
- start();
33262
+ if (openToolKeys.size === 0) stop();
33263
+ }
33264
+ } else if (ev.stepKind === "text" || ev.stepKind === "thinking") {
33265
+ if (openToolKeys.size > 0) {
33266
+ openToolKeys.clear();
33267
+ openToolSince.clear();
33268
+ apply();
33269
+ stop();
33227
33270
  }
33228
- } else if (openToolKeys.delete(ev.stepKey)) {
33229
- openToolSince.delete(ev.stepKey);
33230
- apply();
33231
- if (openToolKeys.size === 0) stop();
33232
33271
  }
33233
33272
  },
33234
33273
  stop: () => {
@@ -33460,6 +33499,7 @@ function classifyFailure(c) {
33460
33499
  code: Err.TIMEOUT,
33461
33500
  message: "agy run was idle for " + c.cfg.timeoutMs + "ms without output" + (c.silentTimeout ? " — agy never emitted a single event; it is likely unable to reach Google (check proxy/network). 无法连接 Google,请检查代理或网络配置" : "")
33462
33501
  };
33502
+ else if (c.outcome.idleGraceTerminated) return null;
33463
33503
  else if (!c.consumable) {
33464
33504
  if (c.sawAuthFailure) return c.transportFailure ? {
33465
33505
  kind: "error",
@@ -33809,6 +33849,18 @@ async function handleAttemptOutcome(deps, input, ctx) {
33809
33849
  deps.clearInFlightPrompt(sessionKey, spawn.prompt);
33810
33850
  recorder.drain(input.agyOnEvent);
33811
33851
  const conversationId = recorder.conversationId();
33852
+ if (!rec.hasResult && outcome.idleGraceTerminated) {
33853
+ const synthResult = {
33854
+ kind: "result",
33855
+ conversationId: conversationId ?? "",
33856
+ ok: true,
33857
+ response: "",
33858
+ usage: rec.finalUsage({}),
33859
+ raw: {}
33860
+ };
33861
+ rec.append(synthResult);
33862
+ input.agyOnEvent?.(synthResult);
33863
+ }
33812
33864
  const { failure, rawErrText, runLogText, silentTimeout } = classifyRun({
33813
33865
  cfg,
33814
33866
  outcome,
package/dist/index.js CHANGED
@@ -1354,6 +1354,7 @@ function classifyEvent(obj, seq) {
1354
1354
  const text = delta !== void 0 ? delta : extractText$1(src);
1355
1355
  const stateV = pick$1(src, ["state"]);
1356
1356
  if (stateV === "ERROR" && toolInfo && !toolInfo.error) toolInfo.error = "tool execution failed";
1357
+ if (stateV === "RUNNING" && toolInfo && toolInfo.output === void 0 && text !== "") toolInfo.output = text;
1357
1358
  const usageRaw = pick$1(src, ["usage"]);
1358
1359
  return {
1359
1360
  kind: "step",
@@ -1945,6 +1946,13 @@ const QUOTA_REFRESH_DEDUP_MS = 9e4;
1945
1946
  * own idle budget so short-budget tests and genuine idle kills stay prompt.
1946
1947
  */
1947
1948
  const WATCHDOG_GRACE_MS = 5e3;
1949
+ /**
1950
+ * Grace after agy reports `root agent idle; waiting ... for background task(s)`.
1951
+ * The prompt turn's answer is already streamed; a stuck GUI dialog / background
1952
+ * child would otherwise keep print mode alive for hours (issue #119). Short and
1953
+ * fixed so the turn settles promptly instead of hanging DSH's event stream.
1954
+ */
1955
+ const IDLE_BACKGROUND_GRACE_MS = 5e3;
1948
1956
  function nonBlank(v) {
1949
1957
  return (v ?? "").trim();
1950
1958
  }
@@ -2122,7 +2130,9 @@ function createRunState(opts) {
2122
2130
  idleBudgetMs: opts.timeoutMs,
2123
2131
  watchdog: null,
2124
2132
  watchdogGraceUsed: false,
2125
- turnCap: null
2133
+ turnCap: null,
2134
+ idleGraceTimer: null,
2135
+ idleGraceTerminated: false
2126
2136
  };
2127
2137
  }
2128
2138
  function spawnAgyChild(opts, env, viaCmd, isNode) {
@@ -2206,6 +2216,9 @@ function armTurnCap(child, opts, state) {
2206
2216
  state.turnCap.unref?.();
2207
2217
  }
2208
2218
  }
2219
+ function isBackgroundStderrNoise(line) {
2220
+ return line.includes("fetchAvailableModels") || line.includes("loadCodeAssist") || line.includes("token refreshed") || line.includes("FetchConfig") || line.includes("ListExperiments") || line.includes("daily-cloudcode-pa.googleapis.com") || line.includes("http_helpers.go");
2221
+ }
2209
2222
  function attachOutputStreams(child, opts, state, refreshWatchdog) {
2210
2223
  const stdoutDecoder = makeLineDecoder(consoleOutputEncoding());
2211
2224
  const stderrDecoder = makeLineDecoder(consoleOutputEncoding());
@@ -2224,9 +2237,21 @@ function attachOutputStreams(child, opts, state, refreshWatchdog) {
2224
2237
  }
2225
2238
  });
2226
2239
  child.stderr?.on("data", (chunk) => {
2227
- if (opts.stderrKeepalive) refreshWatchdog();
2228
2240
  const text = stderrDecoder.push(chunk);
2229
- if (text !== "") state.stderr = (state.stderr + text).slice(-4096);
2241
+ if (text !== "") {
2242
+ state.stderr = (state.stderr + text).slice(-4096);
2243
+ if (/root agent idle;\s*waiting/i.test(text)) {
2244
+ if (!state.idleGraceTimer) {
2245
+ state.idleGraceTimer = setTimeout(() => {
2246
+ if (!state.settled) {
2247
+ state.idleGraceTerminated = true;
2248
+ killTree(child);
2249
+ }
2250
+ }, IDLE_BACKGROUND_GRACE_MS);
2251
+ state.idleGraceTimer.unref?.();
2252
+ }
2253
+ } else if (opts.stderrKeepalive && !isBackgroundStderrNoise(text)) refreshWatchdog();
2254
+ }
2230
2255
  });
2231
2256
  return {
2232
2257
  stdoutDecoder,
@@ -2240,6 +2265,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
2240
2265
  state.settled = true;
2241
2266
  if (state.watchdog) clearTimeout(state.watchdog);
2242
2267
  if (state.turnCap) clearTimeout(state.turnCap);
2268
+ if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
2243
2269
  opts.signal?.removeEventListener("abort", onAbort);
2244
2270
  const stdoutTail = decoders.stdoutDecoder.flush();
2245
2271
  if (stdoutTail !== "") {
@@ -2258,6 +2284,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
2258
2284
  timedOut: state.timedOut,
2259
2285
  aborted: state.aborted,
2260
2286
  capped: state.capped,
2287
+ idleGraceTerminated: state.idleGraceTerminated,
2261
2288
  stdout: state.stdout,
2262
2289
  stderrTail: state.stderr,
2263
2290
  durationMs: Date.now() - started
@@ -2300,6 +2327,7 @@ function startAgyProcess(opts) {
2300
2327
  else state.aborted = true;
2301
2328
  if (state.watchdog) clearTimeout(state.watchdog);
2302
2329
  if (state.turnCap) clearTimeout(state.turnCap);
2330
+ if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
2303
2331
  killTree(child);
2304
2332
  }
2305
2333
  };
@@ -4663,7 +4691,7 @@ var EventMapper = class {
4663
4691
  return;
4664
4692
  }
4665
4693
  if (ev.stepKind === "tool" && ev.tool) {
4666
- if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
4694
+ if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === "RUNNING" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
4667
4695
  if (this.opts.cutOnTool && !this.finished && ev.state === "ACTIVE" && !this.pendingAnnounced.has(ev.stepKey)) {
4668
4696
  this.pendingAnnounced.add(ev.stepKey);
4669
4697
  yield* this.ensureBlock("reasoning");
@@ -4674,6 +4702,7 @@ var EventMapper = class {
4674
4702
  }
4675
4703
  return;
4676
4704
  }
4705
+ if (ev.state === "RUNNING" && ev.tool.output === void 0) ev.tool.output = ev.text !== "" ? ev.text : "Tool is running as a background task";
4677
4706
  if (this.announcedTools.has(ev.stepKey)) return;
4678
4707
  this.announcedTools.add(ev.stepKey);
4679
4708
  if (!this.opts.cutOnTool) return;
@@ -33686,7 +33715,8 @@ function createToolWatchdog(log, cfg) {
33686
33715
  const openToolKeys = /* @__PURE__ */ new Set();
33687
33716
  const openToolSince = /* @__PURE__ */ new Map();
33688
33717
  const longToolIdleMinutes = cfg.longToolIdleMinutes > 0 ? cfg.longToolIdleMinutes : 0;
33689
- const printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : 240, Math.ceil(cfg.timeoutMs / 6e4));
33718
+ let printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : Math.ceil(cfg.timeoutMs / 6e4), Math.ceil(cfg.timeoutMs / 6e4));
33719
+ if (cfg.maxTurnMinutes > 0 && printTimeoutMinutes > cfg.maxTurnMinutes) printTimeoutMinutes = cfg.maxTurnMinutes;
33690
33720
  const longToolIdleMs = longToolIdleMinutes > 0 ? longToolIdleMinutes * 6e4 : cfg.timeoutMs;
33691
33721
  const generationIdleMs = Math.max(cfg.timeoutMs, 9e5);
33692
33722
  let runningProc = null;
@@ -33731,18 +33761,27 @@ function createToolWatchdog(log, cfg) {
33731
33761
  apply();
33732
33762
  },
33733
33763
  trackStep: (ev) => {
33734
- if (ev.kind !== "step" || ev.stepKind !== "tool" || ev.tool === void 0) return;
33735
- if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
33736
- if (!openToolKeys.has(ev.stepKey)) {
33737
- openToolKeys.add(ev.stepKey);
33738
- openToolSince.set(ev.stepKey, Date.now());
33764
+ if (ev.kind !== "step") return;
33765
+ if (ev.stepKind === "tool" && ev.tool !== void 0) {
33766
+ if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === "RUNNING" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
33767
+ if (!openToolKeys.has(ev.stepKey)) {
33768
+ openToolKeys.add(ev.stepKey);
33769
+ openToolSince.set(ev.stepKey, Date.now());
33770
+ apply();
33771
+ start();
33772
+ }
33773
+ } else if (openToolKeys.delete(ev.stepKey)) {
33774
+ openToolSince.delete(ev.stepKey);
33775
+ apply();
33776
+ if (openToolKeys.size === 0) stop();
33777
+ }
33778
+ } else if (ev.stepKind === "text" || ev.stepKind === "thinking") {
33779
+ if (openToolKeys.size > 0) {
33780
+ openToolKeys.clear();
33781
+ openToolSince.clear();
33739
33782
  apply();
33740
- start();
33783
+ stop();
33741
33784
  }
33742
- } else if (openToolKeys.delete(ev.stepKey)) {
33743
- openToolSince.delete(ev.stepKey);
33744
- apply();
33745
- if (openToolKeys.size === 0) stop();
33746
33785
  }
33747
33786
  },
33748
33787
  stop: () => {
@@ -33974,6 +34013,7 @@ function classifyFailure(c) {
33974
34013
  code: Err.TIMEOUT,
33975
34014
  message: "agy run was idle for " + c.cfg.timeoutMs + "ms without output" + (c.silentTimeout ? " — agy never emitted a single event; it is likely unable to reach Google (check proxy/network). 无法连接 Google,请检查代理或网络配置" : "")
33976
34015
  };
34016
+ else if (c.outcome.idleGraceTerminated) return null;
33977
34017
  else if (!c.consumable) {
33978
34018
  if (c.sawAuthFailure) return c.transportFailure ? {
33979
34019
  kind: "error",
@@ -34323,6 +34363,18 @@ async function handleAttemptOutcome(deps, input, ctx) {
34323
34363
  deps.clearInFlightPrompt(sessionKey, spawn.prompt);
34324
34364
  recorder.drain(input.agyOnEvent);
34325
34365
  const conversationId = recorder.conversationId();
34366
+ if (!rec.hasResult && outcome.idleGraceTerminated) {
34367
+ const synthResult = {
34368
+ kind: "result",
34369
+ conversationId: conversationId ?? "",
34370
+ ok: true,
34371
+ response: "",
34372
+ usage: rec.finalUsage({}),
34373
+ raw: {}
34374
+ };
34375
+ rec.append(synthResult);
34376
+ input.agyOnEvent?.(synthResult);
34377
+ }
34326
34378
  const { failure, rawErrText, runLogText, silentTimeout } = classifyRun({
34327
34379
  cfg,
34328
34380
  outcome,
@@ -39116,6 +39168,35 @@ var QuotaService = class {
39116
39168
  }
39117
39169
  };
39118
39170
  //#endregion
39171
+ //#region src/host/effort-unsupported-store.ts
39172
+ function createEffortUnsupportedStore(deps) {
39173
+ const path = () => join(deps.stateDir(), "effort-unsupported.json");
39174
+ const read = () => {
39175
+ try {
39176
+ const raw = existsSync(path()) ? JSON.parse(readFileSync(path(), "utf8")) : [];
39177
+ return Array.isArray(raw) ? raw.filter((m) => typeof m === "string" && m.trim() !== "") : [];
39178
+ } catch {
39179
+ return [];
39180
+ }
39181
+ };
39182
+ const remember = (model) => {
39183
+ const known = read();
39184
+ if (known.some((m) => m.trim().toLowerCase() === model.trim().toLowerCase())) return;
39185
+ const next = [...known, model];
39186
+ try {
39187
+ mkdirSync(deps.stateDir(), { recursive: true });
39188
+ writeFileSync(path(), JSON.stringify(next, null, 2), "utf8");
39189
+ } catch (e) {
39190
+ deps.log?.("failed to persist the effort-unsupported list: " + String(e));
39191
+ }
39192
+ deps.notifyPicker();
39193
+ };
39194
+ return {
39195
+ read,
39196
+ remember
39197
+ };
39198
+ }
39199
+ //#endregion
39119
39200
  //#region src/features/warmup/policy.ts
39120
39201
  /** Canonical model route resolution for upstream Google Cloud Code PA endpoints. */
39121
39202
  function toCanonicalWarmupModel(model) {
@@ -39673,27 +39754,11 @@ function createHostServices(ctx, entryConfig = {}) {
39673
39754
  cfg: getConfig(),
39674
39755
  telemetryFlags: true
39675
39756
  });
39676
- const effortUnsupportedPath = () => join(stateDir(), "effort-unsupported.json");
39677
- const readEffortUnsupported = () => {
39678
- try {
39679
- const raw = existsSync(effortUnsupportedPath()) ? JSON.parse(readFileSync(effortUnsupportedPath(), "utf8")) : [];
39680
- return Array.isArray(raw) ? raw.filter((m) => typeof m === "string" && m.trim() !== "") : [];
39681
- } catch {
39682
- return [];
39683
- }
39684
- };
39685
- const rememberEffortUnsupported = (model) => {
39686
- const known = readEffortUnsupported();
39687
- if (known.some((m) => m.trim().toLowerCase() === model.trim().toLowerCase())) return;
39688
- const next = [...known, model];
39689
- try {
39690
- mkdirSync(stateDir(), { recursive: true });
39691
- writeFileSync(effortUnsupportedPath(), JSON.stringify(next, null, 2), "utf8");
39692
- } catch (e) {
39693
- log("failed to persist the effort-unsupported list: " + String(e));
39694
- }
39695
- notifyPicker();
39696
- };
39757
+ const effortStore = createEffortUnsupportedStore({
39758
+ stateDir,
39759
+ notifyPicker,
39760
+ log
39761
+ });
39697
39762
  /** The DSH session's own workspace (agy runs there, per the translation spec). */
39698
39763
  const sessionWorkspace = (sessionId) => {
39699
39764
  return ctx.get("sessions")?.get(sessionId)?.header?.cwd;
@@ -39782,8 +39847,8 @@ function createHostServices(ctx, entryConfig = {}) {
39782
39847
  log,
39783
39848
  runs,
39784
39849
  getMediaBaseUrl: () => webServerPort.current ? `http://127.0.0.1:${webServerPort.current}/plugins/agy-link/media` : null,
39785
- effortUnsupported: () => readEffortUnsupported(),
39786
- onEffortUnsupported: (model) => rememberEffortUnsupported(model),
39850
+ effortUnsupported: () => effortStore.read(),
39851
+ onEffortUnsupported: (model) => effortStore.remember(model),
39787
39852
  sessionCwd: (sessionId) => sessionWorkspace(sessionId),
39788
39853
  sessionGoal: (sessionId) => {
39789
39854
  try {
@@ -40025,8 +40090,8 @@ function createHostServices(ctx, entryConfig = {}) {
40025
40090
  adapter,
40026
40091
  translation,
40027
40092
  setOverride,
40028
- readEffortUnsupported,
40029
- rememberEffortUnsupported,
40093
+ readEffortUnsupported: effortStore.read,
40094
+ rememberEffortUnsupported: effortStore.remember,
40030
40095
  sessionsSvc,
40031
40096
  sessionAuto,
40032
40097
  get lastRun() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.6.30",
3
+ "version": "0.6.32",
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",