dsh-agy-link 0.6.49 → 0.6.50
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 +16 -0
- package/dist/cli-image.mjs +48 -4
- package/dist/index.js +69 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.50 (2026-11-21)
|
|
4
|
+
|
|
5
|
+
### English
|
|
6
|
+
|
|
7
|
+
- **Fix(watchdog): a scheduled wake-up no longer releases the idle-grace exemption on its own status line (fixes #148).** When agy hands work to the background it asks the model for a short status update before it prints the idle line, so the sequence was: tool returns `state === 'RUNNING'` → `text`/`thinking` step → `root agent idle; waiting …`. `text`/`thinking` cleared the subagent exemption and `RUNNING` counted as a completed hand-off, so nothing held the exemption when the idle line finally arrived.
|
|
8
|
+
- A `schedule` step that returns `RUNNING` is now tracked until it reports a terminal state, and that wait holds the exemption independently; a `text`/`thinking` step no longer cancels it (it still restores the normal idle *budget*, which is a different concern).
|
|
9
|
+
- **`run_command` is deliberately excluded.** agy also uses it for daemons (dev servers, watchers) that never report back, and reclaiming those is exactly what #119 exists for — #124's test pins that. A backgrounded *build* is protected by agy's own count instead (`waiting for N background task(s)` with N > 0 disarms the reaper, shipped in v0.6.46/0.6.48), which needs no exemption and cannot resurrect the daemon case.
|
|
10
|
+
- **Fix(mcp-bridge): `/tools` now lists the caller's own tool surface (fixes #150).** The endpoint called `svc.schemas()` with no scope, so every tool registered inside a DSH preset (`present`, `todo_write`, `job_*`, `schedule_*`, `office_*`) was invisible to an allowlisted agy child even though `/call` could invoke it. The session→agent resolution that `/call` already performed is now a shared `resolveSessionAgent()` used by both endpoints, including the bare-sub-agent-key retry with the `session-` prefix.
|
|
11
|
+
|
|
12
|
+
### 中文
|
|
13
|
+
|
|
14
|
+
- **修复(watchdog):定时唤醒不再因为自己的状态提示而解除 idle-grace 豁免(修复 #148)。** agy 把工作交给后台时,要求模型先发一句简短状态更新,然后才打印 idle 行,于是顺序是:工具返回 `state === 'RUNNING'` → `text`/`thinking` 步骤 → `root agent idle; waiting …`。而 `text`/`thinking` 会清掉子代理豁免,`RUNNING` 又被当作「已完成交接」,等 idle 行真正出现时已没有任何东西撑着豁免。
|
|
15
|
+
- 返回 `RUNNING` 的 `schedule` 步骤现在被跟踪到它有终态为止,这个等待**独立**持有豁免;`text`/`thinking` 不再取消它(它仍然负责把空闲**预算**恢复正常,那是另一件事)。
|
|
16
|
+
- **`run_command` 被刻意排除。** agy 也用它启动永不回报的守护进程(dev server、watcher),而回收这类进程正是 #119 存在的理由——#124 的测试锁定着这一点。而后台化的**构建**由 agy 自己的计数保护(`waiting for N background task(s)`,N > 0 时不武装收割器,v0.6.46/0.6.48 已发布),既不需要豁免,也不会把守护进程那一类放回来。
|
|
17
|
+
- **修复(mcp-bridge):`/tools` 现在列出调用者自己的工具面(修复 #150)。** 该端点用无 scope 的 `svc.schemas()`,导致注册在 DSH preset 里的工具(`present`、`todo_write`、`job_*`、`schedule_*`、`office_*`)对已加入白名单的 agy 子进程完全不可见,尽管 `/call` 其实能调用它们。`/call` 原本就有的 session→agent 解析被提取为共用的 `resolveSessionAgent()`,两个端点都用它,包括「裸子会话 key 加 `session-` 前缀重试」的行为。
|
|
18
|
+
|
|
3
19
|
## 0.6.49 (2026-11-20)
|
|
4
20
|
|
|
5
21
|
### English
|
package/dist/cli-image.mjs
CHANGED
|
@@ -6887,6 +6887,19 @@ const SUBAGENT_COLLAB_TOOLS = /* @__PURE__ */ new Set([
|
|
|
6887
6887
|
"run_workflow",
|
|
6888
6888
|
"swarm"
|
|
6889
6889
|
]);
|
|
6890
|
+
/**
|
|
6891
|
+
* Tools that hand work to the BACKGROUND and return `state === 'RUNNING'` with a
|
|
6892
|
+
* DETERMINISTIC finish: a scheduled wake-up reports back when its timer fires.
|
|
6893
|
+
* The root agent idles until then, so the reaper stays suspended for the wait
|
|
6894
|
+
* (issue #148).
|
|
6895
|
+
*
|
|
6896
|
+
* `run_command` is deliberately NOT here: agy also uses it for daemons (dev
|
|
6897
|
+
* servers, watchers) that never report back, and reclaiming those is exactly
|
|
6898
|
+
* what #119 exists for. A backgrounded BUILD is protected by agy's own count
|
|
6899
|
+
* instead — `waiting for N background task(s)` with N > 0 keeps the reaper
|
|
6900
|
+
* disarmed (see idle-line.ts).
|
|
6901
|
+
*/
|
|
6902
|
+
const BACKGROUND_WAIT_TOOLS = /* @__PURE__ */ new Set(["schedule"]);
|
|
6890
6903
|
function resolveWatchdogBudgets(cfg) {
|
|
6891
6904
|
const longToolIdleMinutes = cfg.longToolIdleMinutes > 0 ? cfg.longToolIdleMinutes : 0;
|
|
6892
6905
|
let printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : Math.ceil(cfg.timeoutMs / 6e4), Math.ceil(cfg.timeoutMs / 6e4));
|
|
@@ -6911,6 +6924,36 @@ function isToolStepCompleted(ev) {
|
|
|
6911
6924
|
* build, …) — issue #33 — so the watchdog raises the idle budget; bare
|
|
6912
6925
|
* generation gets a bounded floor so a hung SSE stream can fail and rotate.
|
|
6913
6926
|
*/
|
|
6927
|
+
/**
|
|
6928
|
+
* Tracks backgrounded hand-offs whose completion agy will report later
|
|
6929
|
+
* (`schedule`). They hold the idle-grace exemption on their own: the mapper
|
|
6930
|
+
* treats `RUNNING` as a completed hand-off, so they never appear in
|
|
6931
|
+
* `openToolKeys`, yet the root agent is still waiting on them (issue #148).
|
|
6932
|
+
*/
|
|
6933
|
+
function createBackgroundWaits(onChange) {
|
|
6934
|
+
const keys = /* @__PURE__ */ new Set();
|
|
6935
|
+
return {
|
|
6936
|
+
note(stepKey, name, state, completed) {
|
|
6937
|
+
if (!BACKGROUND_WAIT_TOOLS.has(name)) return;
|
|
6938
|
+
const before = keys.size;
|
|
6939
|
+
if (state === "RUNNING") keys.add(stepKey);
|
|
6940
|
+
else if (completed) keys.delete(stepKey);
|
|
6941
|
+
if (keys.size !== before) onChange();
|
|
6942
|
+
},
|
|
6943
|
+
get active() {
|
|
6944
|
+
return keys.size > 0;
|
|
6945
|
+
},
|
|
6946
|
+
clear() {
|
|
6947
|
+
keys.clear();
|
|
6948
|
+
}
|
|
6949
|
+
};
|
|
6950
|
+
}
|
|
6951
|
+
/** Heartbeat log line: what the turn is waiting on and for how long. */
|
|
6952
|
+
function heartbeatMessage(openCount, oldestAt, sinceOutput, longToolIdleMs) {
|
|
6953
|
+
const mins = Math.max(1, Math.round((Date.now() - (openCount === 0 && sinceOutput > 0 ? sinceOutput : oldestAt)) / 6e4));
|
|
6954
|
+
const budget = Math.round(longToolIdleMs / 6e4) + "m";
|
|
6955
|
+
return openCount > 0 ? "agy tool step still running: " + openCount + " open, oldest " + mins + "m (idle budget " + budget + ") — the turn is waiting on agy" : "agy run still working: no new output for " + mins + "m (idle budget " + budget + ") — the turn is waiting on agy; press Stop to cancel";
|
|
6956
|
+
}
|
|
6914
6957
|
function createToolWatchdog(log, cfg) {
|
|
6915
6958
|
const openToolKeys = /* @__PURE__ */ new Set();
|
|
6916
6959
|
const openToolSince = /* @__PURE__ */ new Map();
|
|
@@ -6922,8 +6965,9 @@ function createToolWatchdog(log, cfg) {
|
|
|
6922
6965
|
const TOOL_HEARTBEAT_MS = 3e5;
|
|
6923
6966
|
let toolHeartbeat = null;
|
|
6924
6967
|
let idleGraceExempt = false;
|
|
6968
|
+
const backgroundWaits = createBackgroundWaits(() => syncIdleGraceExempt());
|
|
6925
6969
|
const syncIdleGraceExempt = () => {
|
|
6926
|
-
const next = awaitingSubagent || openToolKeys.size > 0;
|
|
6970
|
+
const next = awaitingSubagent || openToolKeys.size > 0 || backgroundWaits.active;
|
|
6927
6971
|
if (next === idleGraceExempt) return;
|
|
6928
6972
|
idleGraceExempt = next;
|
|
6929
6973
|
runningProc?.exemptIdleGrace(next);
|
|
@@ -6952,9 +6996,7 @@ function createToolWatchdog(log, cfg) {
|
|
|
6952
6996
|
}
|
|
6953
6997
|
let oldest = Date.now();
|
|
6954
6998
|
for (const startedAt of openToolSince.values()) if (startedAt < oldest) oldest = startedAt;
|
|
6955
|
-
|
|
6956
|
-
const mins = Math.max(1, Math.round((Date.now() - oldest) / 6e4));
|
|
6957
|
-
log?.(openToolKeys.size > 0 ? "agy tool step still running: " + openToolKeys.size + " open, oldest " + mins + "m (idle budget " + Math.round(longToolIdleMs / 6e4) + "m) — the turn is waiting on agy" : "agy run still working: no new output for " + mins + "m (idle budget " + Math.round(longToolIdleMs / 6e4) + "m) — the turn is waiting on agy; press Stop to cancel");
|
|
6999
|
+
log?.(heartbeatMessage(openToolKeys.size, oldest, lastOutputAt, longToolIdleMs));
|
|
6958
7000
|
}, TOOL_HEARTBEAT_MS);
|
|
6959
7001
|
toolHeartbeat.unref?.();
|
|
6960
7002
|
};
|
|
@@ -6975,6 +7017,7 @@ function createToolWatchdog(log, cfg) {
|
|
|
6975
7017
|
if (ev.kind !== "step") return;
|
|
6976
7018
|
if (ev.stepKind === "tool" && ev.tool !== void 0) {
|
|
6977
7019
|
if (SUBAGENT_COLLAB_TOOLS.has(ev.tool.name)) setAwaitingSubagent(!isStepFailedOrCanceled(ev));
|
|
7020
|
+
backgroundWaits.note(ev.stepKey, ev.tool.name, ev.state, isToolStepCompleted(ev));
|
|
6978
7021
|
if (!isToolStepCompleted(ev)) {
|
|
6979
7022
|
if (!openToolKeys.has(ev.stepKey)) {
|
|
6980
7023
|
openToolKeys.add(ev.stepKey);
|
|
@@ -7002,6 +7045,7 @@ function createToolWatchdog(log, cfg) {
|
|
|
7002
7045
|
awaitingSubagent = false;
|
|
7003
7046
|
openToolKeys.clear();
|
|
7004
7047
|
openToolSince.clear();
|
|
7048
|
+
backgroundWaits.clear();
|
|
7005
7049
|
syncIdleGraceExempt();
|
|
7006
7050
|
}
|
|
7007
7051
|
};
|
package/dist/index.js
CHANGED
|
@@ -34344,6 +34344,19 @@ const SUBAGENT_COLLAB_TOOLS = /* @__PURE__ */ new Set([
|
|
|
34344
34344
|
"run_workflow",
|
|
34345
34345
|
"swarm"
|
|
34346
34346
|
]);
|
|
34347
|
+
/**
|
|
34348
|
+
* Tools that hand work to the BACKGROUND and return `state === 'RUNNING'` with a
|
|
34349
|
+
* DETERMINISTIC finish: a scheduled wake-up reports back when its timer fires.
|
|
34350
|
+
* The root agent idles until then, so the reaper stays suspended for the wait
|
|
34351
|
+
* (issue #148).
|
|
34352
|
+
*
|
|
34353
|
+
* `run_command` is deliberately NOT here: agy also uses it for daemons (dev
|
|
34354
|
+
* servers, watchers) that never report back, and reclaiming those is exactly
|
|
34355
|
+
* what #119 exists for. A backgrounded BUILD is protected by agy's own count
|
|
34356
|
+
* instead — `waiting for N background task(s)` with N > 0 keeps the reaper
|
|
34357
|
+
* disarmed (see idle-line.ts).
|
|
34358
|
+
*/
|
|
34359
|
+
const BACKGROUND_WAIT_TOOLS = /* @__PURE__ */ new Set(["schedule"]);
|
|
34347
34360
|
function resolveWatchdogBudgets(cfg) {
|
|
34348
34361
|
const longToolIdleMinutes = cfg.longToolIdleMinutes > 0 ? cfg.longToolIdleMinutes : 0;
|
|
34349
34362
|
let printTimeoutMinutes = Math.max(longToolIdleMinutes > 0 ? longToolIdleMinutes : Math.ceil(cfg.timeoutMs / 6e4), Math.ceil(cfg.timeoutMs / 6e4));
|
|
@@ -34368,6 +34381,36 @@ function isToolStepCompleted(ev) {
|
|
|
34368
34381
|
* build, …) — issue #33 — so the watchdog raises the idle budget; bare
|
|
34369
34382
|
* generation gets a bounded floor so a hung SSE stream can fail and rotate.
|
|
34370
34383
|
*/
|
|
34384
|
+
/**
|
|
34385
|
+
* Tracks backgrounded hand-offs whose completion agy will report later
|
|
34386
|
+
* (`schedule`). They hold the idle-grace exemption on their own: the mapper
|
|
34387
|
+
* treats `RUNNING` as a completed hand-off, so they never appear in
|
|
34388
|
+
* `openToolKeys`, yet the root agent is still waiting on them (issue #148).
|
|
34389
|
+
*/
|
|
34390
|
+
function createBackgroundWaits(onChange) {
|
|
34391
|
+
const keys = /* @__PURE__ */ new Set();
|
|
34392
|
+
return {
|
|
34393
|
+
note(stepKey, name, state, completed) {
|
|
34394
|
+
if (!BACKGROUND_WAIT_TOOLS.has(name)) return;
|
|
34395
|
+
const before = keys.size;
|
|
34396
|
+
if (state === "RUNNING") keys.add(stepKey);
|
|
34397
|
+
else if (completed) keys.delete(stepKey);
|
|
34398
|
+
if (keys.size !== before) onChange();
|
|
34399
|
+
},
|
|
34400
|
+
get active() {
|
|
34401
|
+
return keys.size > 0;
|
|
34402
|
+
},
|
|
34403
|
+
clear() {
|
|
34404
|
+
keys.clear();
|
|
34405
|
+
}
|
|
34406
|
+
};
|
|
34407
|
+
}
|
|
34408
|
+
/** Heartbeat log line: what the turn is waiting on and for how long. */
|
|
34409
|
+
function heartbeatMessage(openCount, oldestAt, sinceOutput, longToolIdleMs) {
|
|
34410
|
+
const mins = Math.max(1, Math.round((Date.now() - (openCount === 0 && sinceOutput > 0 ? sinceOutput : oldestAt)) / 6e4));
|
|
34411
|
+
const budget = Math.round(longToolIdleMs / 6e4) + "m";
|
|
34412
|
+
return openCount > 0 ? "agy tool step still running: " + openCount + " open, oldest " + mins + "m (idle budget " + budget + ") — the turn is waiting on agy" : "agy run still working: no new output for " + mins + "m (idle budget " + budget + ") — the turn is waiting on agy; press Stop to cancel";
|
|
34413
|
+
}
|
|
34371
34414
|
function createToolWatchdog(log, cfg) {
|
|
34372
34415
|
const openToolKeys = /* @__PURE__ */ new Set();
|
|
34373
34416
|
const openToolSince = /* @__PURE__ */ new Map();
|
|
@@ -34379,8 +34422,9 @@ function createToolWatchdog(log, cfg) {
|
|
|
34379
34422
|
const TOOL_HEARTBEAT_MS = 3e5;
|
|
34380
34423
|
let toolHeartbeat = null;
|
|
34381
34424
|
let idleGraceExempt = false;
|
|
34425
|
+
const backgroundWaits = createBackgroundWaits(() => syncIdleGraceExempt());
|
|
34382
34426
|
const syncIdleGraceExempt = () => {
|
|
34383
|
-
const next = awaitingSubagent || openToolKeys.size > 0;
|
|
34427
|
+
const next = awaitingSubagent || openToolKeys.size > 0 || backgroundWaits.active;
|
|
34384
34428
|
if (next === idleGraceExempt) return;
|
|
34385
34429
|
idleGraceExempt = next;
|
|
34386
34430
|
runningProc?.exemptIdleGrace(next);
|
|
@@ -34409,9 +34453,7 @@ function createToolWatchdog(log, cfg) {
|
|
|
34409
34453
|
}
|
|
34410
34454
|
let oldest = Date.now();
|
|
34411
34455
|
for (const startedAt of openToolSince.values()) if (startedAt < oldest) oldest = startedAt;
|
|
34412
|
-
|
|
34413
|
-
const mins = Math.max(1, Math.round((Date.now() - oldest) / 6e4));
|
|
34414
|
-
log?.(openToolKeys.size > 0 ? "agy tool step still running: " + openToolKeys.size + " open, oldest " + mins + "m (idle budget " + Math.round(longToolIdleMs / 6e4) + "m) — the turn is waiting on agy" : "agy run still working: no new output for " + mins + "m (idle budget " + Math.round(longToolIdleMs / 6e4) + "m) — the turn is waiting on agy; press Stop to cancel");
|
|
34456
|
+
log?.(heartbeatMessage(openToolKeys.size, oldest, lastOutputAt, longToolIdleMs));
|
|
34415
34457
|
}, TOOL_HEARTBEAT_MS);
|
|
34416
34458
|
toolHeartbeat.unref?.();
|
|
34417
34459
|
};
|
|
@@ -34432,6 +34474,7 @@ function createToolWatchdog(log, cfg) {
|
|
|
34432
34474
|
if (ev.kind !== "step") return;
|
|
34433
34475
|
if (ev.stepKind === "tool" && ev.tool !== void 0) {
|
|
34434
34476
|
if (SUBAGENT_COLLAB_TOOLS.has(ev.tool.name)) setAwaitingSubagent(!isStepFailedOrCanceled(ev));
|
|
34477
|
+
backgroundWaits.note(ev.stepKey, ev.tool.name, ev.state, isToolStepCompleted(ev));
|
|
34435
34478
|
if (!isToolStepCompleted(ev)) {
|
|
34436
34479
|
if (!openToolKeys.has(ev.stepKey)) {
|
|
34437
34480
|
openToolKeys.add(ev.stepKey);
|
|
@@ -34459,6 +34502,7 @@ function createToolWatchdog(log, cfg) {
|
|
|
34459
34502
|
awaitingSubagent = false;
|
|
34460
34503
|
openToolKeys.clear();
|
|
34461
34504
|
openToolSince.clear();
|
|
34505
|
+
backgroundWaits.clear();
|
|
34462
34506
|
syncIdleGraceExempt();
|
|
34463
34507
|
}
|
|
34464
34508
|
};
|
|
@@ -37305,6 +37349,25 @@ function settledToolResult(result, callId) {
|
|
|
37305
37349
|
* may arrive later (optional service): pass a thunk.
|
|
37306
37350
|
*/
|
|
37307
37351
|
function startMcpBridge(opts) {
|
|
37352
|
+
/**
|
|
37353
|
+
* Resolve the DSH agent that owns the request's `X-DSH-Session`.
|
|
37354
|
+
*
|
|
37355
|
+
* Shared by `/tools` and `/call`: a preset-scoped tool only exists for a
|
|
37356
|
+
* caller scope, so listing without one hides every tool registered inside a
|
|
37357
|
+
* preset (`present`, `todo_write`, `schedule_*`, `office_*`) even when the
|
|
37358
|
+
* allowlist names it (issue #150). DSH session keys come in two forms — a
|
|
37359
|
+
* top-level web session is `session-<uuid>`, a sub-agent/fork session is a
|
|
37360
|
+
* bare `<uuid>` — so the value is tried as given first (a bare sub-agent key
|
|
37361
|
+
* must not be rewritten) and retried once with the `session-` prefix only
|
|
37362
|
+
* when that finds nothing.
|
|
37363
|
+
*/
|
|
37364
|
+
const resolveSessionAgent = async (req) => {
|
|
37365
|
+
const sessionHeader = String(req.headers["x-dsh-session"] ?? "");
|
|
37366
|
+
const resolveSession = async (id) => id === "" ? void 0 : await Promise.resolve(opts.resolveAgent?.(id));
|
|
37367
|
+
const agent = await resolveSession(sessionHeader);
|
|
37368
|
+
if (agent === void 0 && sessionHeader !== "" && !sessionHeader.startsWith("session-")) return await resolveSession("session-" + sessionHeader);
|
|
37369
|
+
return agent;
|
|
37370
|
+
};
|
|
37308
37371
|
const token = randomBytes(24).toString("hex");
|
|
37309
37372
|
let callSeq = 0;
|
|
37310
37373
|
const server = createServer((req, res) => {
|
|
@@ -37323,7 +37386,7 @@ function startMcpBridge(opts) {
|
|
|
37323
37386
|
const allow = opts.allowlist().split(",").map((s) => s.trim()).filter(Boolean);
|
|
37324
37387
|
const allowSet = new Set(allow);
|
|
37325
37388
|
const used = /* @__PURE__ */ new Set();
|
|
37326
|
-
sendJson$1(res, 200, { tools: svc.schemas().filter((t) => allow.length === 0 || allowSet.has(t.name)).filter((t) => !INTERNAL_TOOL_NAMES.has(t.name)).map((t) => {
|
|
37389
|
+
sendJson$1(res, 200, { tools: svc.schemas(await resolveSessionAgent(req)).filter((t) => allow.length === 0 || allowSet.has(t.name)).filter((t) => !INTERNAL_TOOL_NAMES.has(t.name)).map((t) => {
|
|
37327
37390
|
const base = toMcpName(t.name);
|
|
37328
37391
|
let name = base;
|
|
37329
37392
|
for (let i = 2; used.has(name); i++) name = base + "__" + i;
|
|
@@ -37375,10 +37438,7 @@ function startMcpBridge(opts) {
|
|
|
37375
37438
|
return;
|
|
37376
37439
|
}
|
|
37377
37440
|
try {
|
|
37378
|
-
const
|
|
37379
|
-
const resolveSession = async (id) => id === "" ? void 0 : await Promise.resolve(opts.resolveAgent?.(id));
|
|
37380
|
-
let agent = await resolveSession(sessionHeader);
|
|
37381
|
-
if (agent === void 0 && sessionHeader !== "" && !sessionHeader.startsWith("session-")) agent = await resolveSession("session-" + sessionHeader);
|
|
37441
|
+
const agent = await resolveSessionAgent(req);
|
|
37382
37442
|
const controller = new AbortController();
|
|
37383
37443
|
const abortIfOpen = () => {
|
|
37384
37444
|
if (!res.writableEnded) controller.abort();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agy-link",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.50",
|
|
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",
|