dsh-agent-control-center 0.3.1 → 0.4.1
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 +85 -0
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/client.js +1142 -18
- package/docs/01-CONTRACT.md +1 -1
- package/docs/05-ACCEPTANCE-EVIDENCE.md +79 -0
- package/docs/07-GUIDE.md +1 -1
- package/docs/08-COMPATIBILITY.md +23 -4
- package/docs/09-ARCHITECTURE.md +2 -2
- package/docs/12-PLUGIN-HEALTH.md +49 -0
- package/docs/13-PAGE-REGRESSION-0.4.0.md +47 -0
- package/index.js +4 -1
- package/lib/core/caps.js +28 -7
- package/lib/core/compat.js +16 -5
- package/lib/core/http.js +17 -1
- package/lib/core/index.js +15 -1
- package/lib/core/store.js +5 -1
- package/lib/core/tools-view.js +92 -0
- package/lib/modules/b-tools.js +62 -38
- package/lib/modules/e-meta.js +12 -10
- package/lib/modules/j-instruction.js +162 -2
- package/lib/modules/l-health.js +862 -0
- package/package.json +1 -1
- package/scripts/verify.mjs +1 -0
- package/src/client/i18n/health.js +260 -0
- package/src/client/pages/health.js +832 -0
- package/src/client/pages/tools.js +42 -16
package/docs/01-CONTRACT.md
CHANGED
|
@@ -39,7 +39,7 @@ dsh-agent-control-center/
|
|
|
39
39
|
| HTTP 前缀 | `/__agent-control-center`(GET `/health`,POST `/api`) |
|
|
40
40
|
| 自有存储 | `$DSH_HOME/dsh-agent-control-center/` |
|
|
41
41
|
| locale 命名空间 | `acc` |
|
|
42
|
-
| 版本 | `0.
|
|
42
|
+
| 版本 | `0.4.1` |
|
|
43
43
|
| 兼容声明 | `dsh.compatibility.dsh = ">=0.2.1-rc.1 <0.3.0"`,`engines.dsh` 同区间 |
|
|
44
44
|
|
|
45
45
|
`package.json` 关键字段(照抄,勿改语义):
|
|
@@ -284,3 +284,82 @@ curl -s http://127.0.0.1:38080/__agent-control-center/health
|
|
|
284
284
|
- `instruction.compare` 的 `sameText` 只对「同一 cwd 且两侧都未被截断」有意义;跨 cwd 比较时差异来自不同目录的指令链,页面已用解释文案区分。
|
|
285
285
|
- 会话导出对超大会话(1.9 万事件)耗时 6.2 s,且必然截断;这是只读导出的固有代价,未做流式/分页。
|
|
286
286
|
- 两个新页面只由各自作者做过 mock 与旧实例降级验证,**合并后未做逐项交互回归**(本轮只做了渲染/空态/错误态断言)。
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
# 附:0.4.0 验收补充(2026-11-29)
|
|
291
|
+
|
|
292
|
+
0.1.0 / 0.2.0 / 0.3.0 的结论仍然有效。0.4.0 新增「插件与设置体检」模块与指令趋势记录。
|
|
293
|
+
|
|
294
|
+
## 测试
|
|
295
|
+
|
|
296
|
+
- `node --test tests/*.test.mjs` → **361 / 361 pass**(0.3.0 为 332)。
|
|
297
|
+
- 新增:`tests/health-check.test.mjs`(26)、instruction 趋势 2 个用例、路径围栏例外 1 个用例。
|
|
298
|
+
- 修了两个真实缺陷并同步更新其测试:`store.updateState` 丢弃 `void` mutator 的草稿(静默丢写)、测试里 400×10ms 的模块就绪预算在并行下会误报(改为 15s 上限)。
|
|
299
|
+
|
|
300
|
+
## 真机(隔离 profile `accverify`,12 模块)
|
|
301
|
+
|
|
302
|
+
| 项 | 结果 |
|
|
303
|
+
|---|---|
|
|
304
|
+
| `/health` | `version 0.4.0`,12 模块:`health=FULL(5)`;其余与 0.3.0 一致 |
|
|
305
|
+
| `health.plugins` | 161 ms,206 行;5 条 anomaly 全部 `unaddressable`(`cordis:include` 等内置行不能用 profile patch 控制) |
|
|
306
|
+
| `health.settings` | 34 ms,22 个命名空间;`own:{ns:'acc',declared:true,enabled:true}`;`redactionVerified:true`(`secrets` 均已脱敏,响应里只有键名) |
|
|
307
|
+
| `health.sections` | 285–430 ms,静态扫描 37 个包 / 5 个文件;命中 `websearch`(`@240xu/dsh-websearch`)+ 本插件常量行;0 冲突;跳过原因如实返回(见限制) |
|
|
308
|
+
| `health.compat` | `level:'full'`、`version:'0.2.2-rc.5'`、`readOnly:false`、`source:'compatibility.current'` |
|
|
309
|
+
| `instruction.trend` | 生成一次「按文件」视图后 `totalSamples:1`、`recordedDays:1`,样本写入插件状态 |
|
|
310
|
+
| `instruction.preview` | 76,631 B、`exact:true`(与 0.3.0 一致) |
|
|
311
|
+
|
|
312
|
+
## 浏览器(真实 Chrome headless)
|
|
313
|
+
|
|
314
|
+
- 导航 **12 项**、mid 布局 2 个组分隔符。
|
|
315
|
+
- `Health check` 页:21,276 字符,4 个状态块(206 插件 / 22 命名空间 / 0 冲突 / compat full)、插件表、命名空间表、section 表、anomalies 与 note 全渲染,**0 错误态、0 console/pageerror**。
|
|
316
|
+
- `Instruction preview` 页在 12 页下仍渲染 60,432 字符(012 页共存无回归)。
|
|
317
|
+
- 验收脚本最终 **8/8**:首轮曾因固定等待 4s 而误判 Instruction 页(实际 60,432 字符、0 错误),改为轮询「Loading 消失」后通过。
|
|
318
|
+
- 截图:`docs/assets/health.png`。
|
|
319
|
+
|
|
320
|
+
## 未验证 / 已知限制(0.4.0 新增部分)
|
|
321
|
+
|
|
322
|
+
- `health.sections` 是**静态扫描**:只覆盖构建产物里的字面量注册,注释中的 `settings.section` 与 `id:` 也会被计入(噪声可能);动态生成 id 的插件会漏检。
|
|
323
|
+
- 本插件自身 bundle 若以 `link:` 装在被围栏拒绝的路径(当前即如此),其 section 行来自插件常量并标 `scanned:false`,不是扫描结果。
|
|
324
|
+
- 「声明未装 / 装了未启用」两类异常仍由 `readOnlyReason` 与 profile patch 行间接推断,未读取插件运行态。
|
|
325
|
+
- 逐页交互回归:12 页首屏全部 0 错误态,但完整交互清单未跑完(子代理进程在环境重启后中断)。已采集的部分与问题清单见 `docs/13-PAGE-REGRESSION-0.4.0.md`;其中最实的问题是 **Tools 首屏 5.7 s**(`tools.list` 实测 5,407 ms / `tools.summary` 2,366 ms,357 个会话冷启动)。
|
|
326
|
+
- 「配置漂移」(profile 的 cordis.patch.yml 行 vs 运行时挂载)**未实现**:读取 `$DSH_HOME/profiles/<p>/cordis.patch.yml` 被路径围栏按设计拒绝(该文件可含插件密钥),本轮只放行了 `profiles/<p>/node_modules/**` 与目录遍历。要做这个功能必须先决定是否接受读取该文件,或改由 `configEditor` 提供等价信息。
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
# 附:0.4.1 验收补充(2026-11-29,宿主 0.2.3-alpha.3)
|
|
331
|
+
|
|
332
|
+
0.4.1 是一次兼容性发布:宿主从 `0.2.2-rc.5` 换成了 `0.2.3-alpha.3`(`/opt/dsh-0233`),两处被本插件读取的 API 改了名。
|
|
333
|
+
|
|
334
|
+
## 漂移与适配
|
|
335
|
+
|
|
336
|
+
| 能力 | 0.2.2 | 0.2.3 | 适配 |
|
|
337
|
+
|---|---|---|---|
|
|
338
|
+
| tools | `definitions()` / `schemas()` | `getAll()` / `get()`(`schemas()` 不再公开) | `lib/core/tools-view.js` + `caps.js` 的 `ALTERNATES` |
|
|
339
|
+
| connection | `requestRejection()` | `admit()` → `{rejection}` / `{peer}` | `lib/core/http.js` |
|
|
340
|
+
|
|
341
|
+
未适配时的实测症状:`tools` 能力缺失 → 模块 Tools **BLOCKED**、`tools.list` 404;`connection` 缺失 → 21 项能力只剩 20 项。
|
|
342
|
+
|
|
343
|
+
## 真机(隔离 profile `accverify`,12 模块)
|
|
344
|
+
|
|
345
|
+
| 项 | 结果 |
|
|
346
|
+
|---|---|
|
|
347
|
+
| `/health` | `version 0.4.1`;宿主 `0.2.3-alpha.3`;`compat {level:'full', tested:true, readOnly:false, reasons:[]}`;能力 **21/21**;12 模块 **11 FULL + recovery PARTIAL** |
|
|
348
|
+
| `tools` 能力 | `{present:true, methods:['getAll','get']}` |
|
|
349
|
+
| `connection` 能力 | `{present:true, methods:['admit']}` |
|
|
350
|
+
| `tools.list` 冷 / 热 | 3,873 ms / **11 ms**(共享历史折叠 + 60 s memo;`refresh:true` 强制重扫) |
|
|
351
|
+
| `tools.detail`(scoped) | `schemaSource:'scoped'`、`definitionAvailable:true` —— 修复了「行说已注册、详情说注册表没有该名称」 |
|
|
352
|
+
| `instruction.trend` | 写入成功(`totalSamples:4`),证明写入路径在新宿主上仍可用 |
|
|
353
|
+
| `instruction.preview` | 136 ms,76,631 B,`exact:true` |
|
|
354
|
+
|
|
355
|
+
## 浏览器(真实 Chrome headless,v0.4.1)
|
|
356
|
+
|
|
357
|
+
**19/19 通过**,0 console error、0 pageerror:
|
|
358
|
+
|
|
359
|
+
- 12 页全部渲染且 0 错误态;首屏:Overview 4 ms、Usage 30 ms、Restart 3 ms、Agent info 508 ms、Sessions 510 ms、Export 510 ms、Instruction 1,018 ms、Diagnostics 1,013 ms、AGENTS.md 1,190 ms、Health 1,561 ms、Tools 5,570 ms(冷历史扫描,见下「已知」)
|
|
360
|
+
- 展开一个真实工具行后按 Esc:**收起该行且 Settings 保持打开**;搜索框有内容时按 Esc:清空输入且 Settings 保持打开
|
|
361
|
+
|
|
362
|
+
## 已知 / 未解决
|
|
363
|
+
|
|
364
|
+
- **Tools 首屏仍 5.5 s(冷)**:历史折叠默认扫 25 个会话、5 s 时间预算;热读 11 ms。下一步计划把历史统计拆成首屏后加载(页面先出注册表,历史徽标随后填充),而不是降低默认扫描上限。
|
|
365
|
+
- `tools.schemas()` 在 0.2.3 不再公开,因此 `schemaProjection` 诊断项在新宿主上恒为 `available:false`(已标注原因,不影响工具清单与 schema 详情)。
|
package/docs/07-GUIDE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 用户指南:从「我想做什么」出发
|
|
2
2
|
|
|
3
|
-
> 适用版本 **0.
|
|
3
|
+
> 适用版本 **0.4.1**,目标宿主 DSH **0.2.2-rc.5**(兼容区间 `>=0.2.1-rc.1 <0.3.0`)。
|
|
4
4
|
> 本文按**任务**组织,只描述本插件在真实界面上能做什么、失败时看到什么、提示是什么意思。
|
|
5
5
|
> 安装、权限边界、配置字段和刻意限制见 [README.zh.md](../README.zh.md);
|
|
6
6
|
> 内部实现(模块、请求流、存储、扩展点)见 [09-ARCHITECTURE.md](09-ARCHITECTURE.md);
|
package/docs/08-COMPATIBILITY.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 兼容性与降级(DSH 版本 / 能力矩阵)
|
|
2
2
|
|
|
3
3
|
> 实现:`lib/core/compat.js`(纯函数 + 一次版本探测);测试:`tests/compat.test.mjs`。
|
|
4
|
-
> 目标宿主:DSH `0.2.2-rc.5`(`/opt/dsh-0222
|
|
4
|
+
> 目标宿主:DSH `0.2.2-rc.5`(`/opt/dsh-0222`)与 `0.2.3-alpha.3`(`/opt/dsh-0233`,v0.4.1 起)。本文件描述**已经发生的事实**与**可复算的判定规则**,不描述期望。
|
|
5
5
|
> 证据标签沿用 `docs/01-CONTRACT.md` §5:`VERIFIED`(本机实测观察)、`SOURCE-CONFIRMED`(读到宿主源码/类型)、`INFERRED`(由源码推定未实测)、`UNKNOWN`。
|
|
6
6
|
|
|
7
7
|
---
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
|---|---|---|
|
|
59
59
|
| `MIN_SUPPORTED` | `0.2.0` | 兼容层愿意推理的最低版本。**低于** `DECLARED_MIN`(`0.2.1-rc.1`)是有意的:宿主自身会用 `engines.dsh` 拦掉,但版本豁免/源码运行仍要让插件给出结论而不是假设 |
|
|
60
60
|
| `DECLARED_MIN` | `0.2.1-rc.1` | `package.json` 的 `engines.dsh` / `dsh.compatibility.dsh` 下限(与 `package.json` 的一致性有测试) |
|
|
61
|
-
| `TESTED` | `['0.2.2-rc.5']` | 真正跑过/推导过能力矩阵的版本 |
|
|
62
|
-
| `MAX_TESTED` | `0.2.
|
|
61
|
+
| `TESTED` | `['0.2.2-rc.5', '0.2.3-alpha.3']` | 真正跑过/推导过能力矩阵的版本 |
|
|
62
|
+
| `MAX_TESTED` | `0.2.3-alpha.3` | 由 `TESTED` 推导(最大值),`full` 只可能出现在这段区间 |
|
|
63
63
|
| `DECLARED_MAX` | `0.3.0`(**不含**) | `package.json` 声明的上限;`>= 0.3.0` 属于新一代 API,未测 |
|
|
64
64
|
|
|
65
65
|
### 已测/未测矩阵
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
| `0.1.x` | INFERRED | `unsupported` | true | 低于 `MIN_SUPPORTED`,`version-below-minimum` |
|
|
70
70
|
| `0.2.0` | INFERRED(无实测) | `degraded` | false | `version-below-declared` + `version-untested`;只在宿主版本豁免时可出现 |
|
|
71
71
|
| `0.2.1-rc.1` ~ `0.2.1-rc.x` | 声明下限,**未实测** | `degraded` | false | `version-untested`;能力矩阵推定与 0.2.2 同构(INFERRED) |
|
|
72
|
-
| `0.2.2-rc.5` | **VERIFIED
|
|
72
|
+
| `0.2.2-rc.5` | **VERIFIED**(`/opt/dsh-0222`) | `full`(21/21 能力齐全时) | false | v0.1.0–v0.4.0 的验收基线 |
|
|
73
|
+
| `0.2.3-alpha.3` | **VERIFIED**(`/opt/dsh-0233`,v0.4.1) | `full`(21/21 能力齐全,12 模块 11 FULL + recovery PARTIAL) | false | 见 §7 的 API 漂移表 |
|
|
73
74
|
| `0.2.2`(正式)/`0.2.3-alpha.1` | 未实测,在声明范围内 | `degraded` | false | `version-above-tested`:可能含新 API,写入仍允许 |
|
|
74
75
|
| `0.3.0+` | **UNKNOWN** | `degraded` | **true** | `version-above-declared`:跨代,默认只读 |
|
|
75
76
|
|
|
@@ -200,3 +201,21 @@
|
|
|
200
201
|
| `0.3.0` 只读策略可能过于保守 | 跨代默认只读 | 实测 0.3.x 后按 §7.4 抬 `MAX_TESTED`/`DECLARED_MAX`,只读自动解除 |
|
|
201
202
|
| 版本来源依赖 `profileContext` 形状 | 宿主改字段名→退回 `argv`;两者皆失→只读 | 新增来源只需在 `detectVersion` 候选中加一项并补测试 |
|
|
202
203
|
| `DSH_INSTALL_DIR` 在本机不存在 | 现有 `f-diagnostics`/`h-overview` 显示版本未知 | 接线时优先用 `createCompatibility`(内部首选 `profileContext`),并考虑把两个模块改为读兼容层结论 |
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 7. `0.2.3-alpha.3` 的 API 漂移与适配(v0.4.1)
|
|
208
|
+
|
|
209
|
+
0.2.3 改了两处本插件实际读取的宿主 API。两处都不是破坏性的语义变化,只是**改名**;适配后 `evaluate()` 在 `0.2.3-alpha.3` 上给出 `level:'full'、tested:true、readOnly:false`。
|
|
210
|
+
|
|
211
|
+
| 能力 | 0.2.2 | 0.2.3 | 适配位置 |
|
|
212
|
+
|---|---|---|---|
|
|
213
|
+
| `tools` | `definitions(scope)` + `schemas(scope)` | `getAll(scope)` + `get(name, scope)`(`schemas()` 不再公开) | `lib/core/tools-view.js`(`readDefinitions` / `readSchemaProjection` / `isExecutable`);`caps.js` 的 `ALTERNATES` 接受任一完整方法族 |
|
|
214
|
+
| `connection` | `requestRejection(request)` → `401 \| 403 \| undefined` | `admit(request)` → `{ rejection } \| { peer }` | `lib/core/http.js`(`rejectionOf()` 两条分支,`{peer}` 视为放行);`caps.js` 的 `ALTERNATES` 同样接受两族 |
|
|
215
|
+
|
|
216
|
+
规则与取舍:
|
|
217
|
+
|
|
218
|
+
1. **只有整族齐全才算 present**。半套(例如只有 `getAll` 没有 `get`)判为缺失并把两族名字都写进 `detail`,避免“看起来能用、实际半坏”。
|
|
219
|
+
2. **`schemas()` 缺失是降级而非阻断**。它只用于“模型面投影核对”这一诊断项;`tools.schemaProjection` 会标 `available:false` 并给出原因,工具清单照常工作。
|
|
220
|
+
3. **`executable()` → `get()` 的语义差**。`executable(name, scope)` 表示“带 `when` 条件的工具不算可执行”;`get(name, scope)` 只表示“该作用域能看到”。因此 `isExecutable()` 优先用 `executable()`,没有时才退回 `get()`,且 `get()` 抛错(同名多定义)时返回 `null`(未知),不猜。
|
|
221
|
+
4. **`admit()` 的放行分支**。`{ peer }` 表示通过;`{ rejection: 401 | 403 }` 转成对应状态码;其它异常值按 `403`。`admit()` 抛错时退回本插件的兜底判定(Host 头白名单 + 回环)。
|
package/docs/09-ARCHITECTURE.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
DSH Web GUI (browser)
|
|
27
27
|
├── Settings dialog
|
|
28
28
|
│ └── settings.section id=agent-control-center order=200 ← client.js
|
|
29
|
-
│ └──
|
|
29
|
+
│ └── 12 pages (client-side secondary navigation)
|
|
30
30
|
└── HTTP (same origin)
|
|
31
31
|
└── /__agent-control-center/health GET
|
|
32
32
|
└── /__agent-control-center/api POST {method, params}
|
|
@@ -42,7 +42,7 @@ DSH Web GUI (browser)
|
|
|
42
42
|
|
|
43
43
|
### 2.1 入口 `index.js`
|
|
44
44
|
|
|
45
|
-
- 导出:`name`、`VERSION`(`0.
|
|
45
|
+
- 导出:`name`、`VERSION`(`0.4.1`,与 `package.json` 同步)、`HTTP_PREFIX`(`/__agent-control-center`)、`inject = []`、`apply(ctx, rawConfig)`。
|
|
46
46
|
- `inject = []` 是硬约束:**任何宿主服务缺失都不阻止插件激活**,只让对应模块降级为 PARTIAL/BLOCKED。
|
|
47
47
|
- 启动序列(`apply`):
|
|
48
48
|
1. `normalizeConfig(rawConfig)`:未知字段/类型错误/越界 → **加载期直接抛错**(fail loud,不做静默兜底);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# 模块 L · 插件与设置体检(Plugin health)
|
|
2
|
+
|
|
3
|
+
> 只读:不安装、不启用、不修改任何插件或配置;最多给出「建议动作」文本。
|
|
4
|
+
|
|
5
|
+
## 为什么需要
|
|
6
|
+
|
|
7
|
+
设置页由多个客户端插件各自注册 `settings.section`。两个插件抢同一个 id、或本插件那一行被禁用,都不会报错,只会在界面上表现为「入口消失 / 出现两个相同项 / 配置不生效」。本页把这四类事实摊开:
|
|
8
|
+
|
|
9
|
+
| 证据 | 来源 | 能证明什么 | 不能证明什么 |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| 插件清单 | `pluginManager.listPlugins()` | 装了哪些插件、能否通过 profile patch 控制(`patchId` / `readOnlyReason`) | 插件是否真的在运行 |
|
|
12
|
+
| 设置命名空间 | `settings.describe({redactSecrets:true})` | 22 个命名空间、revision、密钥键名、脱敏是否生效 | 页面怎么渲染 |
|
|
13
|
+
| section 清单 | **静态扫描**客户端 bundle | 构建产物里**字面量**注册的 section id 与 owner | 动态拼出的 id;被围栏拒绝的路径 |
|
|
14
|
+
| 兼容结论 | `core.compatibility` 的活值 | 宿主版本/能力/是否只读 | 具体某个方法为何降级 |
|
|
15
|
+
|
|
16
|
+
## section 冲突检测的方式与局限
|
|
17
|
+
|
|
18
|
+
宿主把 `settings.section` 定义在客户端 slot 层,Host 侧 `settings.describe()` **没有 section 概念**(返回的是 `{ns, schema, value, revision, secrets}`)。因此冲突只能靠读已装插件的客户端 bundle:
|
|
19
|
+
|
|
20
|
+
- 扫描 `$DSH_HOME/profiles/*/node_modules/**` 下的候选产物:`client.js`、`index.js`、`lib/client.js`、`lib/client/index.js`、`dist/client.js`、`dist/client/index.js`;
|
|
21
|
+
- 定位 `settings.section` 字面量,在其后 600 字符窗口里取 `id:` / `id =` 的字符串值(真实插件形如 `ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: 'websearch', order: 16 }))`);没有 `id` 时回退取 `name`;
|
|
22
|
+
- `settings.section.icon` 这类**子 slot** 不算 section,已排除;
|
|
23
|
+
- 单文件 ≤ 4 MiB、总读取 ≤ 24 MiB、最多 200 个文件,超限的包会列进「跳过原因」而不是静默漏掉。
|
|
24
|
+
|
|
25
|
+
**局限必须记住**:静态扫描只覆盖构建产物里的字面量,运行时动态生成 id 的插件会漏检;本插件自己的 bundle 若以 `link:` 安装在 `$DSH_HOME` 之外(被路径围栏拒绝读取),则改用插件内常量 `agent-control-center` 补一行并标 `scanned:false`。
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
- `health.plugins()` → `{available, source:'pluginManager', items:[{entryId,moduleName,patchId,readOnlyReason}], anomalies:[{kind,detail}]}`
|
|
30
|
+
- `health.settings()` → `{available, namespaces:[{ns,revision,autoGenerate,hasValue,secretKeys}], own:{ns:'acc',declared,enabled}, redactionVerified, note}`
|
|
31
|
+
- `health.sections()` → `{available, method:'static-scan', scanned:{packages,files}, sections:[{id,owner,file}], conflicts:[{kind,id,owners,suggestion}], own, note}`
|
|
32
|
+
- `health.compat()` → `{available, level, version, readOnly, reasons, source}`
|
|
33
|
+
- `health.summary()` → `{generatedAt, plugins:{total,anomalies}, settings:{...}, sections:{count,conflicts}, compat:{level,readOnly}, worst:{severity,id}}`
|
|
34
|
+
|
|
35
|
+
## 真机观察(accverify,2026-11-29,12 模块)
|
|
36
|
+
|
|
37
|
+
| 项 | 结果 |
|
|
38
|
+
|---|---|
|
|
39
|
+
| 插件 | 206 行,5 条 anomaly(全部是 `unaddressable`:如 `cordis:include`、`@deepseek-ai/dsh-…` 内置行无法用 profile patch 控制) |
|
|
40
|
+
| 设置命名空间 | 22 个,`own:{ns:'acc', declared:true, enabled:true}`,`redactionVerified:true` |
|
|
41
|
+
| section 扫描 | 37 个包 / 5 个文件 / 285–430 ms,命中 `websearch`(`@240xu/dsh-websearch`)与本插件自身常量行;**0 冲突** |
|
|
42
|
+
| 兼容 | `level:'full'`、`version:'0.2.2-rc.5'`、`readOnly:false`,`source:'compatibility.current'` |
|
|
43
|
+
| 最差项 | `plugins`(warn)——只因 206 行里有 5 行不可寻址,属正常现象,页面已写明 |
|
|
44
|
+
|
|
45
|
+
## 限制
|
|
46
|
+
|
|
47
|
+
- 「声明了但没装」「装了但没启用」两类异常当前由 `pluginManager` 的 `readOnlyReason` 与 profile patch 行共同推断;与插件实际 enabled 状态存在观测差,页面以 `anomalies.detail` 明示推断依据。
|
|
48
|
+
- 静态扫描不解析 AST:注释里出现 `settings.section` 与 `id:` 也会被计入(真实 bundle 里注释较多,可能产生噪声)。
|
|
49
|
+
- 兼容结论读的是宿主活值,不重新探测每个方法;单个方法为何降级仍要看 Diagnostics 页。
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 逐页浏览回归报告(12 页,真实 Chrome,accverify)
|
|
2
|
+
|
|
3
|
+
> 数据来源:本轮子代理在 17:36–17:51 于运行实例上采集的 `regression-data.json` / `probe_interact.json` / `extra-results.json`,其进程在环境重启后中断,报告由 lead 从原始数据重建。**不含逐页完整交互清单**(见「未覆盖」)。
|
|
4
|
+
|
|
5
|
+
## 首屏
|
|
6
|
+
|
|
7
|
+
| 页面 | 首屏 ms | 文本字符 | 出现 Loading | 错误态块 |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| Overview | 334 | 1483 | False | 0 |
|
|
10
|
+
| AGENTS.md | 1576 | 1143 | True | 0 |
|
|
11
|
+
| Tools | 5712 | 4262 | True | 0 |
|
|
12
|
+
| Sessions | 2460 | 6423 | True | 0 |
|
|
13
|
+
| Usage | 405 | 2368 | True | 0 |
|
|
14
|
+
| Agent info | 708 | 1067 | True | 0 |
|
|
15
|
+
| Instruction preview | 2168 | 60137 | True | 0 |
|
|
16
|
+
| Templates | 402 | 1636 | True | 0 |
|
|
17
|
+
| Diagnostics | 2395 | 9616 | True | 0 |
|
|
18
|
+
| Export | 922 | 3251 | True | 0 |
|
|
19
|
+
| Restart & Resume | 343 | 663 | False | 0 |
|
|
20
|
+
| tools_esc | None | None | None | None |
|
|
21
|
+
| health_extra | None | 0 | None | None |
|
|
22
|
+
|
|
23
|
+
12 页全部 0 错误态块;慢页:Tools 5.7 s(对应 `tools.list` 实测 5.4 s)、Instruction 2.2 s、Diagnostics 2.4 s、Sessions 2.5 s。
|
|
24
|
+
|
|
25
|
+
## 交互证据(已采集到的部分)
|
|
26
|
+
|
|
27
|
+
- Sessions:Archived 切换后列表由 50 行变为 8/8 行;勾选一行出现 `1 selected` 工具条;展开一行出现详情。
|
|
28
|
+
- Agent info:Presets 视图由 1 行变 4 行;Export 视图渲染 `{schemaVersion, exportedAt, presets, agents, models}` 且声明不含密钥。
|
|
29
|
+
- Instruction preview:会话下拉 51 个选项;选中后进入 `by session` 视图(2,554 字符);Compare 视图 2,654 字符。
|
|
30
|
+
- Templates:进入模板详情(2,390 字符);Apply 打开确认对话框并出现 diff(3,670 字符)。
|
|
31
|
+
- Diagnostics:4 个统计卡(Error 0 / Warning 2 / Unknown 1 / OK 19);点 Warning 过滤生效;展开「Most severe」组可读到证据切片。
|
|
32
|
+
- Health check:1,118 ms 进入、20,982 字符、就绪态。
|
|
33
|
+
|
|
34
|
+
## 发现的问题
|
|
35
|
+
|
|
36
|
+
| 级别 | 页面 | 现象 | 判断 |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| S2 | Tools | 首屏 5.7 s;`tools.list` 实测 **5,407 ms**,`tools.summary` 2,366 ms(357 个会话下冷启动) | 真实性能问题:首次扫描历史无上限,需分页/时间窗或预热缓存 |
|
|
39
|
+
| S3 | Sessions | 脚本按「Activity statistics」tab 定位超时 | 脚本假设错误:该页只有 All chats / Archived 两个 tab,统计是区块;非产品问题 |
|
|
40
|
+
| S3 | Diagnostics | `collapsed_evidence_present=false`(脚本期望默认折叠) | 默认展开,脚本断言方向错;非产品问题 |
|
|
41
|
+
| S3 | Tools | `tools_read_cold` 记录 95 s 且 ok=false | 与 `tools.callers` 方法不存在(`not_found`)相关,属脚本调用错误方法;非产品问题 |
|
|
42
|
+
| S4 | 全部 | 无 console error / pageerror | 通过 |
|
|
43
|
+
|
|
44
|
+
## 未覆盖(诚实缺口)
|
|
45
|
+
|
|
46
|
+
- Overview 的卡片跳转、AGENTS.md 的选中刷新、Usage 的日期切换、Restart & Resume 的扫描:脚本在环境重启后中断,未采到结果。
|
|
47
|
+
- 截图 23 张(`01-overview.png` … `12-*`)在 `/tmp/ux/regress/`,未逐张目视复核。
|
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { createRegistry } from './lib/core/registry.js'
|
|
|
15
15
|
|
|
16
16
|
export const name = 'dsh-agent-control-center'
|
|
17
17
|
/** Plugin version, mirrored in package.json. */
|
|
18
|
-
export const VERSION = '0.
|
|
18
|
+
export const VERSION = '0.4.1'
|
|
19
19
|
/** Browser transport prefix. The client fetches it document-relative. */
|
|
20
20
|
export const HTTP_PREFIX = '/__agent-control-center'
|
|
21
21
|
|
|
@@ -58,6 +58,7 @@ const MODULE_MANIFEST = Object.freeze([
|
|
|
58
58
|
{ id: 'recovery', load: () => import('./lib/modules/i-recovery.js') },
|
|
59
59
|
{ id: 'instruction', load: () => import('./lib/modules/j-instruction.js') },
|
|
60
60
|
{ id: 'export', load: () => import('./lib/modules/k-export.js') },
|
|
61
|
+
{ id: 'health', load: () => import('./lib/modules/l-health.js') },
|
|
61
62
|
])
|
|
62
63
|
|
|
63
64
|
/**
|
|
@@ -128,6 +129,8 @@ export function apply(ctx, rawConfig) {
|
|
|
128
129
|
// Compatibility verdict: probed once after mount, then reported in /health
|
|
129
130
|
// so a page can warn before a write on an untested host version.
|
|
130
131
|
const compatibility = createCompatibility({ ctx: routeCtx, caps: core.caps, log: log.info })
|
|
132
|
+
// Modules may read the live verdict (health.compat prefers it over re-evaluating).
|
|
133
|
+
core.compatibility = compatibility
|
|
131
134
|
let compatDetected = false
|
|
132
135
|
void compatibility
|
|
133
136
|
.ensure()
|
package/lib/core/caps.js
CHANGED
|
@@ -14,7 +14,9 @@ const REQUIRED = Object.freeze({
|
|
|
14
14
|
workspaceRegistry: ['list', 'archiveSession', 'unarchiveSession'],
|
|
15
15
|
workspaceController: ['archiveSession', 'unarchiveSession'],
|
|
16
16
|
workspaceFiles: ['read', 'stat', 'list'],
|
|
17
|
-
|
|
17
|
+
// Host 0.2.3 replaced `definitions()` / `schemas()` with `getAll()` / `get()`.
|
|
18
|
+
// `tools` counts as present when either API family is complete (see ALTERNATES).
|
|
19
|
+
tools: ['getAll', 'get'],
|
|
18
20
|
settings: ['describe'],
|
|
19
21
|
credentials: ['listRecords'],
|
|
20
22
|
configEditor: ['entries'],
|
|
@@ -25,11 +27,23 @@ const REQUIRED = Object.freeze({
|
|
|
25
27
|
pluginManager: ['listPlugins', 'listBundles'],
|
|
26
28
|
storage: ['form'],
|
|
27
29
|
webServer: ['register'],
|
|
28
|
-
connection: ['
|
|
30
|
+
connection: ['admit'], // 0.2.3 replaced `requestRejection()`; see ALTERNATES
|
|
29
31
|
commands: ['list'],
|
|
30
32
|
systemPrompt: [],
|
|
31
33
|
})
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Alternative method families for one capability. A capability is present when
|
|
37
|
+
* any family is fully available, so a host that renamed its API is still read.
|
|
38
|
+
* The legacy 0.2.x tools surface (`definitions` + `schemas`) and the 0.2.3 one
|
|
39
|
+
* (`getAll` + `get`) are both accepted; `methods` reports whichever matched.
|
|
40
|
+
* @type {Record<string, readonly (readonly string[])[]>}
|
|
41
|
+
*/
|
|
42
|
+
const ALTERNATES = Object.freeze({
|
|
43
|
+
tools: Object.freeze([['getAll', 'get'], ['definitions', 'schemas']]),
|
|
44
|
+
connection: Object.freeze([['admit'], ['requestRejection']]),
|
|
45
|
+
})
|
|
46
|
+
|
|
33
47
|
/**
|
|
34
48
|
* @param {{ ctx: { get(name: string): unknown }, log?: (message: string) => void }} options
|
|
35
49
|
*/
|
|
@@ -54,12 +68,19 @@ export function createCaps(options) {
|
|
|
54
68
|
if (known === undefined) return { present: false, methods: [], detail: '未知能力' }
|
|
55
69
|
const service = read(name)
|
|
56
70
|
if (service === undefined || service === null) return { present: false, methods: [], detail: '宿主未提供该服务' }
|
|
57
|
-
const methods = []
|
|
58
|
-
for (const method of known) {
|
|
59
|
-
const value = /** @type {Record<string, unknown>} */ (service)[method]
|
|
60
|
-
if (typeof value === 'function') methods.push(method)
|
|
61
|
-
}
|
|
62
71
|
if (known.length === 0) return { present: true, methods: [], detail: '' }
|
|
72
|
+
const table = /** @type {Record<string, unknown>} */ (service)
|
|
73
|
+
const has = (/** @type {string} */ method) => typeof table[method] === 'function'
|
|
74
|
+
const alternates = ALTERNATES[name]
|
|
75
|
+
if (alternates !== undefined) {
|
|
76
|
+
// One whole family must be there; a half-renamed host counts as absent.
|
|
77
|
+
const family = alternates.find((candidate) => candidate.every(has)) ?? null
|
|
78
|
+
if (family === null) {
|
|
79
|
+
return { present: false, methods: [], detail: `缺少方法族:${alternates.map((candidate) => candidate.join(' + ')).join(' 或 ')}` }
|
|
80
|
+
}
|
|
81
|
+
return { present: true, methods: [...family], detail: '' }
|
|
82
|
+
}
|
|
83
|
+
const methods = known.filter(has)
|
|
63
84
|
const missing = known.filter((method) => !methods.includes(method))
|
|
64
85
|
return {
|
|
65
86
|
present: methods.length > 0,
|
package/lib/core/compat.js
CHANGED
|
@@ -28,12 +28,14 @@ import path from 'node:path'
|
|
|
28
28
|
export const MIN_SUPPORTED = '0.2.0'
|
|
29
29
|
|
|
30
30
|
/** DSH versions the plugin has actually been exercised against. */
|
|
31
|
-
export const TESTED = Object.freeze([
|
|
31
|
+
export const TESTED = Object.freeze([
|
|
32
|
+
'0.2.2-rc.5',
|
|
33
|
+
// Exercised end to end on 0.2.3-alpha.3: the tools registry surface was renamed
|
|
34
|
+
// (`definitions`/`schemas` → `getAll`/`get`) and `connection.requestRejection`
|
|
35
|
+
// became `admit(request)`; both are read through adapters now.
|
|
36
|
+
'0.2.3-alpha.3',
|
|
37
|
+
])
|
|
32
38
|
|
|
33
|
-
/** Highest measured DSH version; versions above it run degraded, never blocked. */
|
|
34
|
-
export const MAX_TESTED = TESTED.reduce((highest, version) =>
|
|
35
|
-
compareVersions(version, highest) > 0 ? version : highest,
|
|
36
|
-
)
|
|
37
39
|
|
|
38
40
|
/** Lower bound declared in `package.json` (`dsh.compatibility.dsh` / `engines.dsh`). */
|
|
39
41
|
export const DECLARED_MIN = '0.2.1-rc.1'
|
|
@@ -262,6 +264,15 @@ export function compareVersions(a, b) {
|
|
|
262
264
|
return 0
|
|
263
265
|
}
|
|
264
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Highest measured DSH version; versions above it run degraded, never blocked.
|
|
269
|
+
* Computed after {@link compareVersions} exists so a multi-entry {@link TESTED}
|
|
270
|
+
* list does not compare versions before the parser is initialised.
|
|
271
|
+
*/
|
|
272
|
+
export const MAX_TESTED = TESTED.reduce((highest, version) =>
|
|
273
|
+
compareVersions(version, highest) > 0 ? version : highest,
|
|
274
|
+
)
|
|
275
|
+
|
|
265
276
|
/* ------------------------------------------------------------------------- */
|
|
266
277
|
/* Capability normalization */
|
|
267
278
|
/* ------------------------------------------------------------------------- */
|
package/lib/core/http.js
CHANGED
|
@@ -133,7 +133,7 @@ function fallbackRejection(request) {
|
|
|
133
133
|
* prefix: string,
|
|
134
134
|
* version: string,
|
|
135
135
|
* log: (message: string) => void,
|
|
136
|
-
* getConnection?: () => { requestRejection?: (request: unknown) => 401 | 403 | undefined } | undefined,
|
|
136
|
+
* getConnection?: () => { requestRejection?: (request: unknown) => 401 | 403 | undefined, admit?: (request: unknown) => { rejection?: unknown } | unknown } | undefined,
|
|
137
137
|
* dispatch: (method: string, params: Record<string, unknown>, context: object) => Promise<unknown>,
|
|
138
138
|
* health: () => unknown,
|
|
139
139
|
* onRejected?: (info: { path: string, method: string, status: 401 | 403, address: string }) => void,
|
|
@@ -148,6 +148,9 @@ export function createHttp(options) {
|
|
|
148
148
|
/** @param {import('node:http').IncomingMessage} request @returns {401 | 403 | undefined} */
|
|
149
149
|
function rejectionOf(request) {
|
|
150
150
|
const connection = options.getConnection?.()
|
|
151
|
+
// 0.2.2 exposed `requestRejection(request)`; 0.2.3 replaced it with
|
|
152
|
+
// `admit(request)`, which answers `{ rejection }` for a refusal and a peer
|
|
153
|
+
// for an admitted request.
|
|
151
154
|
if (connection !== undefined && typeof connection.requestRejection === 'function') {
|
|
152
155
|
try {
|
|
153
156
|
return connection.requestRejection(request)
|
|
@@ -156,6 +159,19 @@ export function createHttp(options) {
|
|
|
156
159
|
return fallbackRejection(request)
|
|
157
160
|
}
|
|
158
161
|
}
|
|
162
|
+
if (connection !== undefined && typeof connection.admit === 'function') {
|
|
163
|
+
try {
|
|
164
|
+
const admission = connection.admit(request)
|
|
165
|
+
if (admission !== null && typeof admission === 'object' && 'rejection' in admission) {
|
|
166
|
+
const status = /** @type {{ rejection?: unknown }} */ (admission).rejection
|
|
167
|
+
return status === 401 || status === 403 ? status : 403
|
|
168
|
+
}
|
|
169
|
+
return undefined
|
|
170
|
+
} catch (error) {
|
|
171
|
+
log(`connection.admit failed: ${String(error?.message ?? error)}`)
|
|
172
|
+
return fallbackRejection(request)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
159
175
|
return fallbackRejection(request)
|
|
160
176
|
}
|
|
161
177
|
|
package/lib/core/index.js
CHANGED
|
@@ -139,7 +139,21 @@ export function createCore(options) {
|
|
|
139
139
|
if (top === 'llm.env' || top === '.npmrc' || top === '.credentials.yaml' || top.startsWith('.credentials') || top.startsWith('.workbuddy')) {
|
|
140
140
|
return '该路径属于宿主凭据/密钥,插件不读取也不写入'
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
// The settings-section scan reads plugin bundles: package code, never user
|
|
143
|
+
// data. `profiles/<name>/node_modules/**` is allowed for reads and writes
|
|
144
|
+
// are still refused by the write allow-list in module A.
|
|
145
|
+
if (top === 'profiles') {
|
|
146
|
+
const parts = relative.split(path.sep)
|
|
147
|
+
// Plugin code lives under `node_modules`; the scan reads that subtree.
|
|
148
|
+
if (parts.length >= 3 && parts[2] === 'node_modules') return null
|
|
149
|
+
// Directory traversal (`profiles`, `profiles/<name>`) is allowed so a
|
|
150
|
+
// caller can list packages. Profile files never are: a file name in this
|
|
151
|
+
// tree carries an extension (`.npmrc`, `cordis.patch.yml`, `package.json`),
|
|
152
|
+
// a profile directory name does not.
|
|
153
|
+
if (parts.length <= 2 && !path.basename(relative).includes('.')) return null
|
|
154
|
+
return '该目录属于宿主内部数据,插件不读取也不写入'
|
|
155
|
+
}
|
|
156
|
+
if (top === 'storages' || top === 'skills' || top === '.git') {
|
|
143
157
|
return '该目录属于宿主内部数据,插件不读取也不写入'
|
|
144
158
|
}
|
|
145
159
|
return null
|
package/lib/core/store.js
CHANGED
|
@@ -125,7 +125,11 @@ export function createStore(options) {
|
|
|
125
125
|
async function updateState(mutate) {
|
|
126
126
|
return withLock('state', async () => {
|
|
127
127
|
const current = await readState()
|
|
128
|
-
|
|
128
|
+
// A mutator may either return a replacement document or mutate the draft
|
|
129
|
+
// it receives; both forms must persist, so the draft is kept when the
|
|
130
|
+
// mutator returns nothing (its `void` return type documents that form).
|
|
131
|
+
const working = structuredClone(current)
|
|
132
|
+
const draft = mutate(working) ?? working
|
|
129
133
|
const next = { ...draft, version: STATE_VERSION }
|
|
130
134
|
await writeJsonAtomic(paths.state, next)
|
|
131
135
|
return next
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool registry reads across host API generations.
|
|
3
|
+
*
|
|
4
|
+
* DSH 0.2.2 exposed `definitions(scope)` and `schemas(scope)`; 0.2.3 replaced
|
|
5
|
+
* them with `get(name, scope)` / `getAll(scope)` and dropped the schema
|
|
6
|
+
* projection from the public surface. Modules read through this adapter so a
|
|
7
|
+
* renamed host API degrades one diagnostic, never a whole module.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-agent-control-center/core/tools-view
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {any} tools host `tools` service (already checked for existence)
|
|
14
|
+
* @returns {'getAll' | 'definitions' | null} the family this host speaks
|
|
15
|
+
*/
|
|
16
|
+
export function toolsApiKind(tools) {
|
|
17
|
+
if (typeof tools?.getAll === 'function') return 'getAll'
|
|
18
|
+
if (typeof tools?.definitions === 'function') return 'definitions'
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Read one registry view: the unscoped view when `scope` is omitted, otherwise
|
|
24
|
+
* the view that scope sees.
|
|
25
|
+
*
|
|
26
|
+
* @param {any} tools host `tools` service
|
|
27
|
+
* @param {unknown} [scope] Agent object or preset scope key
|
|
28
|
+
* @returns {{ ok: boolean, definitions: readonly unknown[], detail?: string }}
|
|
29
|
+
*/
|
|
30
|
+
export function readDefinitions(tools, scope) {
|
|
31
|
+
if (toolsApiKind(tools) === 'getAll') {
|
|
32
|
+
const definitions = scope === undefined ? tools.getAll() : tools.getAll(scope)
|
|
33
|
+
return { ok: true, definitions: Array.isArray(definitions) ? definitions : [] }
|
|
34
|
+
}
|
|
35
|
+
if (toolsApiKind(tools) === 'definitions') {
|
|
36
|
+
const definitions = scope === undefined ? tools.definitions() : tools.definitions(scope)
|
|
37
|
+
return { ok: true, definitions: Array.isArray(definitions) ? definitions : [] }
|
|
38
|
+
}
|
|
39
|
+
return { ok: false, definitions: [], detail: '宿主 tools 服务既没有 getAll() 也没有 definitions()' }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Project the model-facing schema list, when the host still exposes it.
|
|
44
|
+
*
|
|
45
|
+
* @param {any} tools host `tools` service
|
|
46
|
+
* @returns {{ available: boolean, count: number | null, reason: string | null }}
|
|
47
|
+
*/
|
|
48
|
+
export function readSchemaProjection(tools) {
|
|
49
|
+
if (typeof tools?.schemas !== 'function') {
|
|
50
|
+
return {
|
|
51
|
+
available: false,
|
|
52
|
+
count: null,
|
|
53
|
+
reason: '宿主 tools 服务没有 schemas()(0.2.3 起该投影不再公开),无法核对模型面投影',
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const schemas = tools.schemas()
|
|
58
|
+
return { available: true, count: Array.isArray(schemas) ? schemas.length : null, reason: null }
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return { available: false, count: null, reason: String(/** @type {any} */ (error)?.message ?? error).slice(0, 200) }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether one name is executable for a scope. The host expresses `when`-gated
|
|
66
|
+
* tools as a `get()`/`executable()` miss; without either method the answer is
|
|
67
|
+
* unknown rather than assumed.
|
|
68
|
+
*
|
|
69
|
+
* @param {any} tools host `tools` service
|
|
70
|
+
* @param {string} name tool name
|
|
71
|
+
* @param {unknown} [scope] Agent object or preset scope key
|
|
72
|
+
* @returns {boolean | null} true = executable, false = registered but gated, null = unknown
|
|
73
|
+
*/
|
|
74
|
+
export function isExecutable(tools, name, scope) {
|
|
75
|
+
if (typeof tools?.executable === 'function') {
|
|
76
|
+
try {
|
|
77
|
+
return tools.executable(name, scope) !== undefined
|
|
78
|
+
} catch {
|
|
79
|
+
return null
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (typeof tools?.get === 'function') {
|
|
83
|
+
try {
|
|
84
|
+
return (scope === undefined ? tools.get(name) : tools.get(name, scope)) !== undefined
|
|
85
|
+
} catch {
|
|
86
|
+
// `get()` throws for an ambiguous name; that is a registry conflict, not
|
|
87
|
+
// a statement about execution.
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null
|
|
92
|
+
}
|