dsh-agy-link 0.6.31 → 0.6.33
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 +28 -0
- package/dist/cli-image.mjs +77 -18
- package/dist/index.js +77 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.33 (2026-11-17)
|
|
4
|
+
|
|
5
|
+
### English
|
|
6
|
+
|
|
7
|
+
- **Fix(diagnostics): "model not in catalog" is no longer reported as a missing plan (fixes #120, #122).** `explainIneligibility()` used one `'unsupported'` reason for both "the account has no access to this family/plan" and "this model id isn't in the account's catalog"; `unavailableError()` then always hinted `requires a plan with google enabled`. That sent users account-shopping when every account simply lacked the model. A distinct `'model-unsupported'` reason now produces a targeted message ("not in any enabled account's catalog — refresh the model list or pick a listed model; NOT a missing plan"), while genuine family-level `unsupported` keeps its original wording.
|
|
8
|
+
- **Fix(models): a stale/fallback `agy models` snapshot can no longer veto the account's own quota groups (fixes #122).** `accountSupportsModel()` treated a negative `source: 'discovered'` catalog as authoritative even when the snapshot was captured while agy's auth was unavailable (a static 4/6-item fallback list) or simply stale. A discovered catalog still affirms positively; a *negative* entry now yields to explicit per-model quota evidence, so `gemini-4-hydrogen` from a fresh `/pool/refresh-quota` is selected without manually re-activating every account.
|
|
9
|
+
- Tests: new pure regression file for the reason split and stale-catalog veto, plus an updated error-message assertion. A family with no quota evidence still reports `unsupported`; a catalog with no quota evidence remains authoritative.
|
|
10
|
+
|
|
11
|
+
### 中文
|
|
12
|
+
|
|
13
|
+
- **修复(诊断):「模型不在目录」不再误报为套餐缺失(修复 #120、#122)。** `explainIneligibility()` 把「账号没有该 family/套餐权限」与「该 model id 不在账号目录」都归为 `'unsupported'`,`unavailableError()` 于是一律提示 `requires a plan with google enabled`——用户会误以为掉权限而反复换号,实则所有账号都没有这个型号。现在新增独立的 `'model-unsupported'` 原因,文案改为「不在任何启用账号的目录里——刷新模型列表或换一个已列出的型号;不是套餐问题」;真正的 family 级 `unsupported` 文案保持不变。
|
|
14
|
+
- **修复(模型):陈旧/兜底的 `agy models` 快照不再否决账号自身额度组(修复 #122)。** `accountSupportsModel()` 此前把 `source: 'discovered'` 目录的**否定**结果当权威,即使该快照是 agy 鉴权未就绪时打印的静态 4/6 条兜底清单、或已经陈旧。现在已发现目录仍可**正向确认**模型;但**否定**结果要让位于明确的 per-model 额度证据,因此执行 `/pool/refresh-quota` 后即可选到 `gemini-4-hydrogen`,无需逐账号手工 `set-active` 重探。
|
|
15
|
+
- 测试:新增纯函数回归覆盖原因分流与陈旧目录否决,并更新错误文案断言。无额度证据时 family 仍报 `unsupported`,无额度证据时目录仍为权威。
|
|
16
|
+
|
|
17
|
+
## 0.6.32 (2026-11-17)
|
|
18
|
+
|
|
19
|
+
### English
|
|
20
|
+
|
|
21
|
+
- **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).
|
|
22
|
+
- **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).
|
|
23
|
+
- 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.
|
|
24
|
+
|
|
25
|
+
### 中文
|
|
26
|
+
|
|
27
|
+
- **修复(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` 不变)。
|
|
28
|
+
- **重构(超时常量)**:`IDLE_BACKGROUND_GRACE_MS` 与其他 deadline 一起收敛到 `common/timeouts.ts`,`process.ts` 不再另立常量。`.spec/process-lifecycle.md` 记录终止不变式(本地 gitignored)。
|
|
29
|
+
- 测试:5 条子进程有界回归(idle 宽限、两种文案、正常完成分类、`RUNNING` 工具卡片、噪声不喂狗)。感谢 @Ronnoc 的定位与补丁。
|
|
30
|
+
|
|
3
31
|
## 0.6.31 (2026-11-16)
|
|
4
32
|
|
|
5
33
|
### English
|
package/dist/cli-image.mjs
CHANGED
|
@@ -1481,7 +1481,12 @@ function accountSupportsModel(acc, model, pool, catalog) {
|
|
|
1481
1481
|
if (!model || model.trim() === "") return true;
|
|
1482
1482
|
const clean = model.trim();
|
|
1483
1483
|
if (isArgonModel(clean)) return accountHasArgon(acc, pool, catalog);
|
|
1484
|
-
if (catalog && catalog.source === "discovered" && Array.isArray(catalog.models) && catalog.models.length > 0)
|
|
1484
|
+
if (catalog && catalog.source === "discovered" && Array.isArray(catalog.models) && catalog.models.length > 0) {
|
|
1485
|
+
if (catalog.models.some((m) => modelMatches(clean, m.id))) return true;
|
|
1486
|
+
const familyQuotaModels = acc.quotas?.[modelFamilyOf(clean)]?.models;
|
|
1487
|
+
if (Array.isArray(familyQuotaModels) && familyQuotaModels.some((m) => modelMatches(clean, m.modelId))) return true;
|
|
1488
|
+
return false;
|
|
1489
|
+
}
|
|
1485
1490
|
const family = modelFamilyOf(clean);
|
|
1486
1491
|
const familyQuota = acc.quotas?.[family];
|
|
1487
1492
|
if (familyQuota) {
|
|
@@ -2818,7 +2823,7 @@ var EventMapper = class {
|
|
|
2818
2823
|
return;
|
|
2819
2824
|
}
|
|
2820
2825
|
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))) {
|
|
2826
|
+
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
2827
|
if (this.opts.cutOnTool && !this.finished && ev.state === "ACTIVE" && !this.pendingAnnounced.has(ev.stepKey)) {
|
|
2823
2828
|
this.pendingAnnounced.add(ev.stepKey);
|
|
2824
2829
|
yield* this.ensureBlock("reasoning");
|
|
@@ -2829,6 +2834,7 @@ var EventMapper = class {
|
|
|
2829
2834
|
}
|
|
2830
2835
|
return;
|
|
2831
2836
|
}
|
|
2837
|
+
if (ev.state === "RUNNING" && ev.tool.output === void 0) ev.tool.output = ev.text !== "" ? ev.text : "Tool is running as a background task";
|
|
2832
2838
|
if (this.announcedTools.has(ev.stepKey)) return;
|
|
2833
2839
|
this.announcedTools.add(ev.stepKey);
|
|
2834
2840
|
if (!this.opts.cutOnTool) return;
|
|
@@ -4898,6 +4904,13 @@ function nodeScriptEnv(env) {
|
|
|
4898
4904
|
* own idle budget so short-budget tests and genuine idle kills stay prompt.
|
|
4899
4905
|
*/
|
|
4900
4906
|
const WATCHDOG_GRACE_MS = 5e3;
|
|
4907
|
+
/**
|
|
4908
|
+
* Grace after agy reports `root agent idle; waiting ... for background task(s)`.
|
|
4909
|
+
* The prompt turn's answer is already streamed; a stuck GUI dialog / background
|
|
4910
|
+
* child would otherwise keep print mode alive for hours (issue #119). Short and
|
|
4911
|
+
* fixed so the turn settles promptly instead of hanging DSH's event stream.
|
|
4912
|
+
*/
|
|
4913
|
+
const IDLE_BACKGROUND_GRACE_MS = 5e3;
|
|
4901
4914
|
//#endregion
|
|
4902
4915
|
//#region src/host/auto-updater.ts
|
|
4903
4916
|
function nonBlank(v) {
|
|
@@ -5059,7 +5072,9 @@ function createRunState(opts) {
|
|
|
5059
5072
|
idleBudgetMs: opts.timeoutMs,
|
|
5060
5073
|
watchdog: null,
|
|
5061
5074
|
watchdogGraceUsed: false,
|
|
5062
|
-
turnCap: null
|
|
5075
|
+
turnCap: null,
|
|
5076
|
+
idleGraceTimer: null,
|
|
5077
|
+
idleGraceTerminated: false
|
|
5063
5078
|
};
|
|
5064
5079
|
}
|
|
5065
5080
|
function spawnAgyChild(opts, env, viaCmd, isNode) {
|
|
@@ -5143,6 +5158,9 @@ function armTurnCap(child, opts, state) {
|
|
|
5143
5158
|
state.turnCap.unref?.();
|
|
5144
5159
|
}
|
|
5145
5160
|
}
|
|
5161
|
+
function isBackgroundStderrNoise(line) {
|
|
5162
|
+
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");
|
|
5163
|
+
}
|
|
5146
5164
|
function attachOutputStreams(child, opts, state, refreshWatchdog) {
|
|
5147
5165
|
const stdoutDecoder = makeLineDecoder(consoleOutputEncoding());
|
|
5148
5166
|
const stderrDecoder = makeLineDecoder(consoleOutputEncoding());
|
|
@@ -5161,9 +5179,21 @@ function attachOutputStreams(child, opts, state, refreshWatchdog) {
|
|
|
5161
5179
|
}
|
|
5162
5180
|
});
|
|
5163
5181
|
child.stderr?.on("data", (chunk) => {
|
|
5164
|
-
if (opts.stderrKeepalive) refreshWatchdog();
|
|
5165
5182
|
const text = stderrDecoder.push(chunk);
|
|
5166
|
-
if (text !== "")
|
|
5183
|
+
if (text !== "") {
|
|
5184
|
+
state.stderr = (state.stderr + text).slice(-4096);
|
|
5185
|
+
if (/root agent idle;\s*waiting/i.test(text)) {
|
|
5186
|
+
if (!state.idleGraceTimer) {
|
|
5187
|
+
state.idleGraceTimer = setTimeout(() => {
|
|
5188
|
+
if (!state.settled) {
|
|
5189
|
+
state.idleGraceTerminated = true;
|
|
5190
|
+
killTree(child);
|
|
5191
|
+
}
|
|
5192
|
+
}, IDLE_BACKGROUND_GRACE_MS);
|
|
5193
|
+
state.idleGraceTimer.unref?.();
|
|
5194
|
+
}
|
|
5195
|
+
} else if (opts.stderrKeepalive && !isBackgroundStderrNoise(text)) refreshWatchdog();
|
|
5196
|
+
}
|
|
5167
5197
|
});
|
|
5168
5198
|
return {
|
|
5169
5199
|
stdoutDecoder,
|
|
@@ -5177,6 +5207,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
|
|
|
5177
5207
|
state.settled = true;
|
|
5178
5208
|
if (state.watchdog) clearTimeout(state.watchdog);
|
|
5179
5209
|
if (state.turnCap) clearTimeout(state.turnCap);
|
|
5210
|
+
if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
|
|
5180
5211
|
opts.signal?.removeEventListener("abort", onAbort);
|
|
5181
5212
|
const stdoutTail = decoders.stdoutDecoder.flush();
|
|
5182
5213
|
if (stdoutTail !== "") {
|
|
@@ -5195,6 +5226,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
|
|
|
5195
5226
|
timedOut: state.timedOut,
|
|
5196
5227
|
aborted: state.aborted,
|
|
5197
5228
|
capped: state.capped,
|
|
5229
|
+
idleGraceTerminated: state.idleGraceTerminated,
|
|
5198
5230
|
stdout: state.stdout,
|
|
5199
5231
|
stderrTail: state.stderr,
|
|
5200
5232
|
durationMs: Date.now() - started
|
|
@@ -5237,6 +5269,7 @@ function startAgyProcess(opts) {
|
|
|
5237
5269
|
else state.aborted = true;
|
|
5238
5270
|
if (state.watchdog) clearTimeout(state.watchdog);
|
|
5239
5271
|
if (state.turnCap) clearTimeout(state.turnCap);
|
|
5272
|
+
if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
|
|
5240
5273
|
killTree(child);
|
|
5241
5274
|
}
|
|
5242
5275
|
};
|
|
@@ -5962,6 +5995,7 @@ function unavailableError(pool, family, model) {
|
|
|
5962
5995
|
const cooling = reasons.filter((r) => r === "cooldown").length;
|
|
5963
5996
|
const quotaBlocked = reasons.filter((r) => r === "quota").length;
|
|
5964
5997
|
const unsupported = reasons.filter((r) => r === "unsupported").length;
|
|
5998
|
+
const modelUnsupported = reasons.filter((r) => r === "model-unsupported").length;
|
|
5965
5999
|
const signedOut = accounts.filter((a) => a.authRequired === true).length;
|
|
5966
6000
|
const countdown = pool.getEarliestAvailableCountdown?.(family) ?? pool.getEarliestResetCountdown(family);
|
|
5967
6001
|
let why;
|
|
@@ -5972,12 +6006,13 @@ function unavailableError(pool, family, model) {
|
|
|
5972
6006
|
if (cooling > 0) details.push(`${cooling} in cooldown`);
|
|
5973
6007
|
if (quotaBlocked > 0) details.push(`${quotaBlocked} quota-exhausted`);
|
|
5974
6008
|
if (unsupported > 0) details.push(`${unsupported} lack ${family} access`);
|
|
6009
|
+
if (modelUnsupported > 0) details.push(`${modelUnsupported} lack model "${model ?? ""}" in their catalog`);
|
|
5975
6010
|
if (signedOut > 0) details.push(`${signedOut} signed out`);
|
|
5976
6011
|
if (disabled > 0) details.push(`${disabled} disabled`);
|
|
5977
6012
|
why = `no account can serve ${family} right now${details.length > 0 ? ` (${details.join(", ")})` : ""}`;
|
|
5978
6013
|
}
|
|
5979
6014
|
const waitStr = countdown !== null && countdown > 0 ? ` (earliest reset in ${Math.ceil(countdown / 1e3)}s)` : "";
|
|
5980
|
-
const hint = unsupported > 0 && quotaBlocked === 0 && cooling === 0 ? `No enabled account has access to ${family} (requires a plan with ${family} enabled).` : quotaBlocked > 0 && cooling === 0 ? "Add an account, wait for the quota reset, or run /agy clear-cooldown to override the current quota snapshot." : "Add an account, wait for reset, or run /agy clear-cooldown.";
|
|
6015
|
+
const hint = modelUnsupported > 0 && unsupported === 0 && quotaBlocked === 0 && cooling === 0 ? `Requested model "${model ?? ""}" is not in any enabled account's catalog — refresh the model list (POST /plugins/agy-link/pool/refresh-quota) or pick a listed model. It is NOT a missing ${family} plan.` : unsupported > 0 && quotaBlocked === 0 && cooling === 0 ? `No enabled account has access to ${family} (requires a plan with ${family} enabled).` : quotaBlocked > 0 && cooling === 0 ? "Add an account, wait for the quota reset, or run /agy clear-cooldown to override the current quota snapshot." : "Add an account, wait for reset, or run /agy clear-cooldown.";
|
|
5981
6016
|
return new LlmError(`All Antigravity accounts are unavailable: ${why}${waitStr}. ${hint}`, Err.AGY_ERROR);
|
|
5982
6017
|
}
|
|
5983
6018
|
async function selectSessionAccount(input) {
|
|
@@ -6604,6 +6639,7 @@ function classifyEvent(obj, seq) {
|
|
|
6604
6639
|
const text = delta !== void 0 ? delta : extractText(src);
|
|
6605
6640
|
const stateV = pick(src, ["state"]);
|
|
6606
6641
|
if (stateV === "ERROR" && toolInfo && !toolInfo.error) toolInfo.error = "tool execution failed";
|
|
6642
|
+
if (stateV === "RUNNING" && toolInfo && toolInfo.output === void 0 && text !== "") toolInfo.output = text;
|
|
6607
6643
|
const usageRaw = pick(src, ["usage"]);
|
|
6608
6644
|
return {
|
|
6609
6645
|
kind: "step",
|
|
@@ -6870,7 +6906,7 @@ function explainIneligibility(acc, family, now, pool, model) {
|
|
|
6870
6906
|
if (!acc.enabled) return "disabled";
|
|
6871
6907
|
if (acc.authRequired) return "auth";
|
|
6872
6908
|
if (family === "argon" && !accountHasArgon(acc, pool)) return "unsupported";
|
|
6873
|
-
if (model && pool && typeof pool.isModelSupported === "function" && !pool.isModelSupported(acc, model)) return "unsupported";
|
|
6909
|
+
if (model && pool && typeof pool.isModelSupported === "function" && !pool.isModelSupported(acc, model)) return "model-unsupported";
|
|
6874
6910
|
const cd = acc.cooldowns?.[family];
|
|
6875
6911
|
if (cd && cd.cooldownUntil > now) return "cooldown";
|
|
6876
6912
|
if (isQuotaBenched(acc, family, now)) return "quota";
|
|
@@ -33172,7 +33208,8 @@ function createToolWatchdog(log, cfg) {
|
|
|
33172
33208
|
const openToolKeys = /* @__PURE__ */ new Set();
|
|
33173
33209
|
const openToolSince = /* @__PURE__ */ new Map();
|
|
33174
33210
|
const longToolIdleMinutes = cfg.longToolIdleMinutes > 0 ? cfg.longToolIdleMinutes : 0;
|
|
33175
|
-
|
|
33211
|
+
let printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : Math.ceil(cfg.timeoutMs / 6e4), Math.ceil(cfg.timeoutMs / 6e4));
|
|
33212
|
+
if (cfg.maxTurnMinutes > 0 && printTimeoutMinutes > cfg.maxTurnMinutes) printTimeoutMinutes = cfg.maxTurnMinutes;
|
|
33176
33213
|
const longToolIdleMs = longToolIdleMinutes > 0 ? longToolIdleMinutes * 6e4 : cfg.timeoutMs;
|
|
33177
33214
|
const generationIdleMs = Math.max(cfg.timeoutMs, 9e5);
|
|
33178
33215
|
let runningProc = null;
|
|
@@ -33217,18 +33254,27 @@ function createToolWatchdog(log, cfg) {
|
|
|
33217
33254
|
apply();
|
|
33218
33255
|
},
|
|
33219
33256
|
trackStep: (ev) => {
|
|
33220
|
-
if (ev.kind !== "step"
|
|
33221
|
-
if (
|
|
33222
|
-
if (!
|
|
33223
|
-
openToolKeys.
|
|
33224
|
-
|
|
33257
|
+
if (ev.kind !== "step") return;
|
|
33258
|
+
if (ev.stepKind === "tool" && ev.tool !== void 0) {
|
|
33259
|
+
if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === "RUNNING" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
|
|
33260
|
+
if (!openToolKeys.has(ev.stepKey)) {
|
|
33261
|
+
openToolKeys.add(ev.stepKey);
|
|
33262
|
+
openToolSince.set(ev.stepKey, Date.now());
|
|
33263
|
+
apply();
|
|
33264
|
+
start();
|
|
33265
|
+
}
|
|
33266
|
+
} else if (openToolKeys.delete(ev.stepKey)) {
|
|
33267
|
+
openToolSince.delete(ev.stepKey);
|
|
33268
|
+
apply();
|
|
33269
|
+
if (openToolKeys.size === 0) stop();
|
|
33270
|
+
}
|
|
33271
|
+
} else if (ev.stepKind === "text" || ev.stepKind === "thinking") {
|
|
33272
|
+
if (openToolKeys.size > 0) {
|
|
33273
|
+
openToolKeys.clear();
|
|
33274
|
+
openToolSince.clear();
|
|
33225
33275
|
apply();
|
|
33226
|
-
|
|
33276
|
+
stop();
|
|
33227
33277
|
}
|
|
33228
|
-
} else if (openToolKeys.delete(ev.stepKey)) {
|
|
33229
|
-
openToolSince.delete(ev.stepKey);
|
|
33230
|
-
apply();
|
|
33231
|
-
if (openToolKeys.size === 0) stop();
|
|
33232
33278
|
}
|
|
33233
33279
|
},
|
|
33234
33280
|
stop: () => {
|
|
@@ -33460,6 +33506,7 @@ function classifyFailure(c) {
|
|
|
33460
33506
|
code: Err.TIMEOUT,
|
|
33461
33507
|
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
33508
|
};
|
|
33509
|
+
else if (c.outcome.idleGraceTerminated) return null;
|
|
33463
33510
|
else if (!c.consumable) {
|
|
33464
33511
|
if (c.sawAuthFailure) return c.transportFailure ? {
|
|
33465
33512
|
kind: "error",
|
|
@@ -33809,6 +33856,18 @@ async function handleAttemptOutcome(deps, input, ctx) {
|
|
|
33809
33856
|
deps.clearInFlightPrompt(sessionKey, spawn.prompt);
|
|
33810
33857
|
recorder.drain(input.agyOnEvent);
|
|
33811
33858
|
const conversationId = recorder.conversationId();
|
|
33859
|
+
if (!rec.hasResult && outcome.idleGraceTerminated) {
|
|
33860
|
+
const synthResult = {
|
|
33861
|
+
kind: "result",
|
|
33862
|
+
conversationId: conversationId ?? "",
|
|
33863
|
+
ok: true,
|
|
33864
|
+
response: "",
|
|
33865
|
+
usage: rec.finalUsage({}),
|
|
33866
|
+
raw: {}
|
|
33867
|
+
};
|
|
33868
|
+
rec.append(synthResult);
|
|
33869
|
+
input.agyOnEvent?.(synthResult);
|
|
33870
|
+
}
|
|
33812
33871
|
const { failure, rawErrText, runLogText, silentTimeout } = classifyRun({
|
|
33813
33872
|
cfg,
|
|
33814
33873
|
outcome,
|
package/dist/index.js
CHANGED
|
@@ -559,7 +559,12 @@ function accountSupportsModel(acc, model, pool, catalog) {
|
|
|
559
559
|
if (!model || model.trim() === "") return true;
|
|
560
560
|
const clean = model.trim();
|
|
561
561
|
if (isArgonModel(clean)) return accountHasArgon(acc, pool, catalog);
|
|
562
|
-
if (catalog && catalog.source === "discovered" && Array.isArray(catalog.models) && catalog.models.length > 0)
|
|
562
|
+
if (catalog && catalog.source === "discovered" && Array.isArray(catalog.models) && catalog.models.length > 0) {
|
|
563
|
+
if (catalog.models.some((m) => modelMatches(clean, m.id))) return true;
|
|
564
|
+
const familyQuotaModels = acc.quotas?.[modelFamilyOf(clean)]?.models;
|
|
565
|
+
if (Array.isArray(familyQuotaModels) && familyQuotaModels.some((m) => modelMatches(clean, m.modelId))) return true;
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
563
568
|
const family = modelFamilyOf(clean);
|
|
564
569
|
const familyQuota = acc.quotas?.[family];
|
|
565
570
|
if (familyQuota) {
|
|
@@ -1354,6 +1359,7 @@ function classifyEvent(obj, seq) {
|
|
|
1354
1359
|
const text = delta !== void 0 ? delta : extractText$1(src);
|
|
1355
1360
|
const stateV = pick$1(src, ["state"]);
|
|
1356
1361
|
if (stateV === "ERROR" && toolInfo && !toolInfo.error) toolInfo.error = "tool execution failed";
|
|
1362
|
+
if (stateV === "RUNNING" && toolInfo && toolInfo.output === void 0 && text !== "") toolInfo.output = text;
|
|
1357
1363
|
const usageRaw = pick$1(src, ["usage"]);
|
|
1358
1364
|
return {
|
|
1359
1365
|
kind: "step",
|
|
@@ -1945,6 +1951,13 @@ const QUOTA_REFRESH_DEDUP_MS = 9e4;
|
|
|
1945
1951
|
* own idle budget so short-budget tests and genuine idle kills stay prompt.
|
|
1946
1952
|
*/
|
|
1947
1953
|
const WATCHDOG_GRACE_MS = 5e3;
|
|
1954
|
+
/**
|
|
1955
|
+
* Grace after agy reports `root agent idle; waiting ... for background task(s)`.
|
|
1956
|
+
* The prompt turn's answer is already streamed; a stuck GUI dialog / background
|
|
1957
|
+
* child would otherwise keep print mode alive for hours (issue #119). Short and
|
|
1958
|
+
* fixed so the turn settles promptly instead of hanging DSH's event stream.
|
|
1959
|
+
*/
|
|
1960
|
+
const IDLE_BACKGROUND_GRACE_MS = 5e3;
|
|
1948
1961
|
function nonBlank(v) {
|
|
1949
1962
|
return (v ?? "").trim();
|
|
1950
1963
|
}
|
|
@@ -2122,7 +2135,9 @@ function createRunState(opts) {
|
|
|
2122
2135
|
idleBudgetMs: opts.timeoutMs,
|
|
2123
2136
|
watchdog: null,
|
|
2124
2137
|
watchdogGraceUsed: false,
|
|
2125
|
-
turnCap: null
|
|
2138
|
+
turnCap: null,
|
|
2139
|
+
idleGraceTimer: null,
|
|
2140
|
+
idleGraceTerminated: false
|
|
2126
2141
|
};
|
|
2127
2142
|
}
|
|
2128
2143
|
function spawnAgyChild(opts, env, viaCmd, isNode) {
|
|
@@ -2206,6 +2221,9 @@ function armTurnCap(child, opts, state) {
|
|
|
2206
2221
|
state.turnCap.unref?.();
|
|
2207
2222
|
}
|
|
2208
2223
|
}
|
|
2224
|
+
function isBackgroundStderrNoise(line) {
|
|
2225
|
+
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");
|
|
2226
|
+
}
|
|
2209
2227
|
function attachOutputStreams(child, opts, state, refreshWatchdog) {
|
|
2210
2228
|
const stdoutDecoder = makeLineDecoder(consoleOutputEncoding());
|
|
2211
2229
|
const stderrDecoder = makeLineDecoder(consoleOutputEncoding());
|
|
@@ -2224,9 +2242,21 @@ function attachOutputStreams(child, opts, state, refreshWatchdog) {
|
|
|
2224
2242
|
}
|
|
2225
2243
|
});
|
|
2226
2244
|
child.stderr?.on("data", (chunk) => {
|
|
2227
|
-
if (opts.stderrKeepalive) refreshWatchdog();
|
|
2228
2245
|
const text = stderrDecoder.push(chunk);
|
|
2229
|
-
if (text !== "")
|
|
2246
|
+
if (text !== "") {
|
|
2247
|
+
state.stderr = (state.stderr + text).slice(-4096);
|
|
2248
|
+
if (/root agent idle;\s*waiting/i.test(text)) {
|
|
2249
|
+
if (!state.idleGraceTimer) {
|
|
2250
|
+
state.idleGraceTimer = setTimeout(() => {
|
|
2251
|
+
if (!state.settled) {
|
|
2252
|
+
state.idleGraceTerminated = true;
|
|
2253
|
+
killTree(child);
|
|
2254
|
+
}
|
|
2255
|
+
}, IDLE_BACKGROUND_GRACE_MS);
|
|
2256
|
+
state.idleGraceTimer.unref?.();
|
|
2257
|
+
}
|
|
2258
|
+
} else if (opts.stderrKeepalive && !isBackgroundStderrNoise(text)) refreshWatchdog();
|
|
2259
|
+
}
|
|
2230
2260
|
});
|
|
2231
2261
|
return {
|
|
2232
2262
|
stdoutDecoder,
|
|
@@ -2240,6 +2270,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
|
|
|
2240
2270
|
state.settled = true;
|
|
2241
2271
|
if (state.watchdog) clearTimeout(state.watchdog);
|
|
2242
2272
|
if (state.turnCap) clearTimeout(state.turnCap);
|
|
2273
|
+
if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
|
|
2243
2274
|
opts.signal?.removeEventListener("abort", onAbort);
|
|
2244
2275
|
const stdoutTail = decoders.stdoutDecoder.flush();
|
|
2245
2276
|
if (stdoutTail !== "") {
|
|
@@ -2258,6 +2289,7 @@ function awaitOutcome(child, opts, state, decoders, onAbort, started) {
|
|
|
2258
2289
|
timedOut: state.timedOut,
|
|
2259
2290
|
aborted: state.aborted,
|
|
2260
2291
|
capped: state.capped,
|
|
2292
|
+
idleGraceTerminated: state.idleGraceTerminated,
|
|
2261
2293
|
stdout: state.stdout,
|
|
2262
2294
|
stderrTail: state.stderr,
|
|
2263
2295
|
durationMs: Date.now() - started
|
|
@@ -2300,6 +2332,7 @@ function startAgyProcess(opts) {
|
|
|
2300
2332
|
else state.aborted = true;
|
|
2301
2333
|
if (state.watchdog) clearTimeout(state.watchdog);
|
|
2302
2334
|
if (state.turnCap) clearTimeout(state.turnCap);
|
|
2335
|
+
if (state.idleGraceTimer) clearTimeout(state.idleGraceTimer);
|
|
2303
2336
|
killTree(child);
|
|
2304
2337
|
}
|
|
2305
2338
|
};
|
|
@@ -4663,7 +4696,7 @@ var EventMapper = class {
|
|
|
4663
4696
|
return;
|
|
4664
4697
|
}
|
|
4665
4698
|
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))) {
|
|
4699
|
+
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
4700
|
if (this.opts.cutOnTool && !this.finished && ev.state === "ACTIVE" && !this.pendingAnnounced.has(ev.stepKey)) {
|
|
4668
4701
|
this.pendingAnnounced.add(ev.stepKey);
|
|
4669
4702
|
yield* this.ensureBlock("reasoning");
|
|
@@ -4674,6 +4707,7 @@ var EventMapper = class {
|
|
|
4674
4707
|
}
|
|
4675
4708
|
return;
|
|
4676
4709
|
}
|
|
4710
|
+
if (ev.state === "RUNNING" && ev.tool.output === void 0) ev.tool.output = ev.text !== "" ? ev.text : "Tool is running as a background task";
|
|
4677
4711
|
if (this.announcedTools.has(ev.stepKey)) return;
|
|
4678
4712
|
this.announcedTools.add(ev.stepKey);
|
|
4679
4713
|
if (!this.opts.cutOnTool) return;
|
|
@@ -6898,6 +6932,7 @@ function unavailableError(pool, family, model) {
|
|
|
6898
6932
|
const cooling = reasons.filter((r) => r === "cooldown").length;
|
|
6899
6933
|
const quotaBlocked = reasons.filter((r) => r === "quota").length;
|
|
6900
6934
|
const unsupported = reasons.filter((r) => r === "unsupported").length;
|
|
6935
|
+
const modelUnsupported = reasons.filter((r) => r === "model-unsupported").length;
|
|
6901
6936
|
const signedOut = accounts.filter((a) => a.authRequired === true).length;
|
|
6902
6937
|
const countdown = pool.getEarliestAvailableCountdown?.(family) ?? pool.getEarliestResetCountdown(family);
|
|
6903
6938
|
let why;
|
|
@@ -6908,12 +6943,13 @@ function unavailableError(pool, family, model) {
|
|
|
6908
6943
|
if (cooling > 0) details.push(`${cooling} in cooldown`);
|
|
6909
6944
|
if (quotaBlocked > 0) details.push(`${quotaBlocked} quota-exhausted`);
|
|
6910
6945
|
if (unsupported > 0) details.push(`${unsupported} lack ${family} access`);
|
|
6946
|
+
if (modelUnsupported > 0) details.push(`${modelUnsupported} lack model "${model ?? ""}" in their catalog`);
|
|
6911
6947
|
if (signedOut > 0) details.push(`${signedOut} signed out`);
|
|
6912
6948
|
if (disabled > 0) details.push(`${disabled} disabled`);
|
|
6913
6949
|
why = `no account can serve ${family} right now${details.length > 0 ? ` (${details.join(", ")})` : ""}`;
|
|
6914
6950
|
}
|
|
6915
6951
|
const waitStr = countdown !== null && countdown > 0 ? ` (earliest reset in ${Math.ceil(countdown / 1e3)}s)` : "";
|
|
6916
|
-
const hint = unsupported > 0 && quotaBlocked === 0 && cooling === 0 ? `No enabled account has access to ${family} (requires a plan with ${family} enabled).` : quotaBlocked > 0 && cooling === 0 ? "Add an account, wait for the quota reset, or run /agy clear-cooldown to override the current quota snapshot." : "Add an account, wait for reset, or run /agy clear-cooldown.";
|
|
6952
|
+
const hint = modelUnsupported > 0 && unsupported === 0 && quotaBlocked === 0 && cooling === 0 ? `Requested model "${model ?? ""}" is not in any enabled account's catalog — refresh the model list (POST /plugins/agy-link/pool/refresh-quota) or pick a listed model. It is NOT a missing ${family} plan.` : unsupported > 0 && quotaBlocked === 0 && cooling === 0 ? `No enabled account has access to ${family} (requires a plan with ${family} enabled).` : quotaBlocked > 0 && cooling === 0 ? "Add an account, wait for the quota reset, or run /agy clear-cooldown to override the current quota snapshot." : "Add an account, wait for reset, or run /agy clear-cooldown.";
|
|
6917
6953
|
return new LlmError(`All Antigravity accounts are unavailable: ${why}${waitStr}. ${hint}`, Err.AGY_ERROR);
|
|
6918
6954
|
}
|
|
6919
6955
|
async function selectSessionAccount(input) {
|
|
@@ -7440,7 +7476,7 @@ function explainIneligibility(acc, family, now, pool, model) {
|
|
|
7440
7476
|
if (!acc.enabled) return "disabled";
|
|
7441
7477
|
if (acc.authRequired) return "auth";
|
|
7442
7478
|
if (family === "argon" && !accountHasArgon(acc, pool)) return "unsupported";
|
|
7443
|
-
if (model && pool && typeof pool.isModelSupported === "function" && !pool.isModelSupported(acc, model)) return "unsupported";
|
|
7479
|
+
if (model && pool && typeof pool.isModelSupported === "function" && !pool.isModelSupported(acc, model)) return "model-unsupported";
|
|
7444
7480
|
const cd = acc.cooldowns?.[family];
|
|
7445
7481
|
if (cd && cd.cooldownUntil > now) return "cooldown";
|
|
7446
7482
|
if (isQuotaBenched(acc, family, now)) return "quota";
|
|
@@ -33686,7 +33722,8 @@ function createToolWatchdog(log, cfg) {
|
|
|
33686
33722
|
const openToolKeys = /* @__PURE__ */ new Set();
|
|
33687
33723
|
const openToolSince = /* @__PURE__ */ new Map();
|
|
33688
33724
|
const longToolIdleMinutes = cfg.longToolIdleMinutes > 0 ? cfg.longToolIdleMinutes : 0;
|
|
33689
|
-
|
|
33725
|
+
let printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : Math.ceil(cfg.timeoutMs / 6e4), Math.ceil(cfg.timeoutMs / 6e4));
|
|
33726
|
+
if (cfg.maxTurnMinutes > 0 && printTimeoutMinutes > cfg.maxTurnMinutes) printTimeoutMinutes = cfg.maxTurnMinutes;
|
|
33690
33727
|
const longToolIdleMs = longToolIdleMinutes > 0 ? longToolIdleMinutes * 6e4 : cfg.timeoutMs;
|
|
33691
33728
|
const generationIdleMs = Math.max(cfg.timeoutMs, 9e5);
|
|
33692
33729
|
let runningProc = null;
|
|
@@ -33731,18 +33768,27 @@ function createToolWatchdog(log, cfg) {
|
|
|
33731
33768
|
apply();
|
|
33732
33769
|
},
|
|
33733
33770
|
trackStep: (ev) => {
|
|
33734
|
-
if (ev.kind !== "step"
|
|
33735
|
-
if (
|
|
33736
|
-
if (!
|
|
33737
|
-
openToolKeys.
|
|
33738
|
-
|
|
33771
|
+
if (ev.kind !== "step") return;
|
|
33772
|
+
if (ev.stepKind === "tool" && ev.tool !== void 0) {
|
|
33773
|
+
if (!(ev.state === "DONE" || ev.state === "ERROR" || ev.state === "RUNNING" || ev.state === void 0 && (ev.tool.output !== void 0 || ev.tool.error !== void 0))) {
|
|
33774
|
+
if (!openToolKeys.has(ev.stepKey)) {
|
|
33775
|
+
openToolKeys.add(ev.stepKey);
|
|
33776
|
+
openToolSince.set(ev.stepKey, Date.now());
|
|
33777
|
+
apply();
|
|
33778
|
+
start();
|
|
33779
|
+
}
|
|
33780
|
+
} else if (openToolKeys.delete(ev.stepKey)) {
|
|
33781
|
+
openToolSince.delete(ev.stepKey);
|
|
33782
|
+
apply();
|
|
33783
|
+
if (openToolKeys.size === 0) stop();
|
|
33784
|
+
}
|
|
33785
|
+
} else if (ev.stepKind === "text" || ev.stepKind === "thinking") {
|
|
33786
|
+
if (openToolKeys.size > 0) {
|
|
33787
|
+
openToolKeys.clear();
|
|
33788
|
+
openToolSince.clear();
|
|
33739
33789
|
apply();
|
|
33740
|
-
|
|
33790
|
+
stop();
|
|
33741
33791
|
}
|
|
33742
|
-
} else if (openToolKeys.delete(ev.stepKey)) {
|
|
33743
|
-
openToolSince.delete(ev.stepKey);
|
|
33744
|
-
apply();
|
|
33745
|
-
if (openToolKeys.size === 0) stop();
|
|
33746
33792
|
}
|
|
33747
33793
|
},
|
|
33748
33794
|
stop: () => {
|
|
@@ -33974,6 +34020,7 @@ function classifyFailure(c) {
|
|
|
33974
34020
|
code: Err.TIMEOUT,
|
|
33975
34021
|
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
34022
|
};
|
|
34023
|
+
else if (c.outcome.idleGraceTerminated) return null;
|
|
33977
34024
|
else if (!c.consumable) {
|
|
33978
34025
|
if (c.sawAuthFailure) return c.transportFailure ? {
|
|
33979
34026
|
kind: "error",
|
|
@@ -34323,6 +34370,18 @@ async function handleAttemptOutcome(deps, input, ctx) {
|
|
|
34323
34370
|
deps.clearInFlightPrompt(sessionKey, spawn.prompt);
|
|
34324
34371
|
recorder.drain(input.agyOnEvent);
|
|
34325
34372
|
const conversationId = recorder.conversationId();
|
|
34373
|
+
if (!rec.hasResult && outcome.idleGraceTerminated) {
|
|
34374
|
+
const synthResult = {
|
|
34375
|
+
kind: "result",
|
|
34376
|
+
conversationId: conversationId ?? "",
|
|
34377
|
+
ok: true,
|
|
34378
|
+
response: "",
|
|
34379
|
+
usage: rec.finalUsage({}),
|
|
34380
|
+
raw: {}
|
|
34381
|
+
};
|
|
34382
|
+
rec.append(synthResult);
|
|
34383
|
+
input.agyOnEvent?.(synthResult);
|
|
34384
|
+
}
|
|
34326
34385
|
const { failure, rawErrText, runLogText, silentTimeout } = classifyRun({
|
|
34327
34386
|
cfg,
|
|
34328
34387
|
outcome,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agy-link",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.33",
|
|
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",
|