dsh-model-health 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -43
  3. package/package.json +4 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 oxlyn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,81 +1,112 @@
1
1
  # dsh-model-health
2
2
 
3
- > DeepSeek Harness (DSH) 插件:在设置页展示「模型健康」面板——列出所有已配置模型,并支持一键批量测试可用性与延迟。
3
+ [![npm version](https://img.shields.io/npm/v/dsh-model-health.svg)](https://www.npmjs.com/package/dsh-model-health)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](#license)
4
5
 
5
- ## 功能 / Features
6
-
7
- 读取 `$DSH_HOME/settings.yaml`(默认 `~/.dsh/settings.yaml`),提供三种使用方式:
8
-
9
- | # | 形式 | 入口 | 说明 |
10
- |---|------|------|------|
11
- | 1 | 设置页面板「模型健康」 | Web UI → 设置 → 模型健康 | React 表格:Provider / 模型 ID / 名称 / 上下文窗口 / 最大输出 / 输入模态 / API 协议 / BaseURL 等列(可选列可切换显示) |
12
- | 2 | 一键测试全部 | 面板内「测试全部」按钮 | 并发(上限 6)对每个模型发一次 `max_tokens=1` 的最小 chat completions 请求,10s 超时;逐行显示 可用 / 不可用 / 跳过 / 延迟,失败原因悬停查看,结果持久化到 localStorage |
13
- | 3 | Tool 插件 `list_models` | 对话中调用 | 返回 Markdown 表格,供模型在对话中查看模型清单 |
6
+ > DeepSeek Harness (DSH) 插件:在设置页提供「模型健康」面板——列出所有已配置模型,并一键批量测试可用性与延迟。
7
+ >
8
+ > English documentation: [README_EN](README_EN.md)
14
9
 
15
- 支持 `llm-pi-ai`(多协议自定义提供商)与 `llm-deepseek`(官方)两类配置;测试支持 `openai-completions` 与 `deepseek` 协议,其余标记为「跳过」。API Key 通过 DSH credential service 解析,不会输出到浏览器。
10
+ ![模型健康面板](snapshot.png)
16
11
 
17
12
  ## 安装 / Install
18
13
 
19
- 一句话安装(npm 包,发布后可用):
14
+ ### npm 安装(推荐)
20
15
 
21
16
  ```sh
22
- dsh plugin --profile my-profile add dsh-model-health
17
+ dsh plugin --profile web add dsh-model-health
23
18
  ```
24
19
 
25
- ## 源码安装 / Install from source
20
+ ### 源码安装
26
21
 
27
22
  ```sh
28
- git clone https://github.com/<你的用户名>/dsh-model-health.git
23
+ git clone https://github.com/oxlyn/dsh-model-health.git
29
24
  cd dsh-model-health
30
25
  pnpm install
31
26
  pnpm run build # tsc → dist/index.js (pure ESM) + dist/client.js
32
27
 
33
28
  # 在插件的父目录执行(dsh plugin add 的相对路径锚定调用目录):
34
29
  cd ..
35
- dsh plugin --profile my-profile add ./dsh-model-health
36
- dsh --profile my-profile
30
+ dsh plugin --profile web add ./dsh-model-health
31
+ dsh web
37
32
  # 启动日志应出现:[dsh-model-health] ready — tool "list_models" + routes GET /api/model-health/json, POST /api/model-health/test
38
33
  ```
39
34
 
40
- 无 API key 也可验证加载:
35
+ ### 验证 / Verify
36
+
37
+ 安装后打开 `dsh web` → 设置 → 模型健康,应能看到已配置模型表格。无 API key 也可验证插件加载:
41
38
 
42
39
  ```sh
43
- dsh --profile my-profile --dump-config | grep dsh-model-health # 配置层含本行
40
+ dsh --profile web --dump-config | grep dsh-model-health # 配置层含本行
44
41
  ```
45
42
 
46
- ## Dependencies pinned / 依赖锁定
43
+ ## 功能 / Features
47
44
 
48
- - `@deepseek-ai/dsh-tools`: `0.1.0-rc.8` (exact — the **`next`**-tag line; npm `latest` is stale).
49
- - `@deepseek-ai/cordis`: `^4.0.1` (peerDependency — host provides it; types-only in code).
45
+ 读取 `$DSH_HOME/settings.yaml`(默认 `~/.dsh/settings.yaml`),提供三种使用方式:
46
+
47
+ | # | 形式 | 入口 | 说明 |
48
+ |---|------|------|------|
49
+ | 1 | 「模型健康」面板 | Web UI → 设置 → 模型健康 | React 表格:Provider / 模型 ID / 名称 / 上下文窗口 / 最大输出 / 输入模态 / API 协议 / BaseURL,可选列可切换显示 |
50
+ | 2 | 测试全部 | 面板内「测试全部」按钮 | 并发(上限 6)对每个模型发一次 `max_tokens=1` 的最小 chat completions 请求,10s 超时;逐行显示 可用 / 不可用 / 跳过 / 延迟,失败原因悬停查看,结果持久化到 localStorage |
51
+ | 3 | Tool 插件 `list_models` | 对话中调用 | 返回 Markdown 表格,供模型在对话中查看模型清单 |
52
+
53
+ **特性一览:**
50
54
 
51
- ## Pitfalls / 坑(从真实 spike 提炼,防呆)
55
+ - 支持 `llm-pi-ai`(多协议自定义提供商)与 `llm-deepseek`(官方)两类配置来源
56
+ - 可用性测试支持 `openai-completions` 与 `deepseek` 协议,其余协议自动标记「跳过」
57
+ - API Key 通过 DSH credential service(`ctx.credentials.resolve`)解析,密钥不会输出到浏览器
58
+ - 测试结果(状态/延迟/错误)持久化到 localStorage,刷新页面后仍可见
52
59
 
53
- 1. Node version: DSH requires Node ^22.19.0 || >=24.0.0. Older Node (e.g. v22.17) only warns EBADENGINE but may hit runtime issues — upgrade if you can.
54
- - Node 版本:DSH 要求 ^22.19.0 || >=24.0.0。旧版本(如 v22.17)只告警 EBADENGINE,不阻断,但建议升级。
60
+ ## 实现方式 / How it works
55
61
 
56
- 2. npm dist-tag trap (the big one): `@deepseek-ai/dsh-tools` `latest` is a STALE 0.0.1-rc.1; the real line is under the `next` tag (0.1.0-rc.x). This scaffold pins the next-tag version for you — never `npm i @deepseek-ai/dsh-tools` over it.
57
- - npm dist-tag 坑(最大):`@deepseek-ai/dsh-tools` 的 latest 是过期的 0.0.1-rc.1,正确版本在 next tag。本脚手架已锁 next 版本,勿再手动 npm i 覆盖。
62
+ 插件分为 host 侧与 client 侧两部分(`package.json` 的 `dsh.client` 字段声明 client 入口):
63
+
64
+ ```
65
+ ┌─ host 侧 src/index.ts → dist/index.js ─────────────────────────┐
66
+ │ - ctx.tools.register:注册 list_models 工具(Markdown 表格输出) │
67
+ │ - ctx.webServer.register: │
68
+ │ GET /api/model-health/json 读取并解析 settings.yaml → JSON │
69
+ │ POST /api/model-health/test 对单模型发最小请求测可用性/延迟 │
70
+ │ - 解析 DSH credential service 获取 API Key │
71
+ └──────────────────────────────────────────────────────────────────┘
72
+ │ fetch
73
+ ┌─ client 侧 src/client.js(浏览器端模块)──────────────────────────┐
74
+ │ - 通过 settings.section slot 注入「模型健康」面板 │
75
+ │ - React(宿主提供)渲染表格 + 状态徽章 + hover 错误提示 │
76
+ │ - 「测试全部」:worker pool 限并发 6,逐个更新行状态 │
77
+ └──────────────────────────────────────────────────────────────────┘
78
+ ```
58
79
 
59
- 3. Version-line alignment: keep every `@deepseek-ai/dsh-*` package on the same `0.1.0-rc.x` line so pnpm does not install two module copies.
60
- - 版本线对齐:所有 @deepseek-ai/dsh-* 包统一用同一 0.1.0-rc.x 线,避免 pnpm 装两份模块。
80
+ 技术要点:纯 ESM(`"type": "module"`)、cordis 作为 peerDependency 由宿主提供(仅编译期 import type)、服务依赖通过 `export const inject = ['tools', 'webServer', 'credentials']` 声明。
61
81
 
62
- 4. `@deepseek-ai/cordis` is a peerDependency: import only `type { Context }` (erased at compile). At runtime the host hands you `ctx` — never import cordis values at runtime.
63
- - @deepseek-ai/cordis 是 peerDep:只 import type(编译期擦除),运行时 ctx 由宿主传入。
82
+ ## 环境要求 / Requirements
64
83
 
65
- 5. Pure ESM: package.json must set `"type": "module"`; build with `module: esnext` + `moduleResolution: bundler` to keep bare specifiers.
66
- - 纯 ESM:package.json 必须 "type": "module";tsc 用 module:esnext + moduleResolution:bundler 保留 bare specifier。
84
+ - Node `^22.19.0 || >=24.0.0`(DSH 宿主要求)
85
+ - pnpm(源码构建用)
67
86
 
68
- 6. `dsh plugin add <dir>` anchors relative paths to the INVOKING directory — run it from the parent directory, not from inside the plugin.
69
- - dsh plugin add <dir> 的相对路径锚定调用目录——要在插件的父目录执行。
87
+ ## 开发 / Development
70
88
 
71
- 7. In the bundle `cordis.patch.yml`, `name` is a package name (resolved via node_modules / `$DSH_HOME/profiles/node_modules`), not a relative path.
72
- - bundle 的 cordis.patch.yml 里 name 用包名(走 node_modules 解析),不要用相对路径。
89
+ ```sh
90
+ pnpm install
91
+ pnpm run typecheck # 类型检查
92
+ pnpm run build # 构建 dist/
93
+ ```
73
94
 
74
- 8. Registrations are effects: `ctx.tools.register()` / `ctx.on()` auto-dispose on unload. Wrap your OWN resources (timers/connections) in `ctx.effect(() => { acquire; return cleanup })`.
75
- - 注册是 effect:ctx.tools.register()/ctx.on() 卸载自动清理;自己的资源(timer/连接)要包 ctx.effect(() => {…; return cleanup})。
95
+ 项目结构:
96
+
97
+ ```
98
+ dsh-model-health/
99
+ ├── src/index.ts # host 侧:tool + HTTP 路由
100
+ ├── src/client.js # client 侧:设置页面板(浏览器模块)
101
+ ├── cordis.patch.yml # bundle 层声明(id/name 走包名解析)
102
+ └── dist/ # 构建产物(发布包含在 files 字段中)
103
+ ```
104
+
105
+ ## 依赖锁定 / Dependencies
106
+
107
+ - `@deepseek-ai/dsh-tools`: `0.1.0-rc.8` (exact — the **`next`**-tag line; npm `latest` is stale).
108
+ - `@deepseek-ai/cordis`: `^4.0.1` (peerDependency — host provides it; types-only in code).
76
109
 
77
- 9. Load order = service dependencies, never file order: `export const inject = ['tools']` makes the plugin wait until `ctx.tools` is ready.
78
- - 加载顺序靠服务依赖(inject),不靠文件顺序。
110
+ ## License
79
111
 
80
- 10. Full end-to-end (model actually calls your tool) needs `DEEPSEEK_API_KEY`; without it `--verify` proves load/list/event, and the model call fails with MISSING_CREDENTIAL.
81
- - 端到端(模型真正调工具)需 DEEPSEEK_API_KEY;无 key 时 --verify 只能证明加载/列出/事件,模型调用会 MISSING_CREDENTIAL。
112
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-health",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "DSH plugin that lists all configured models with availability/latency testing, by reading $DSH_HOME/settings.yaml.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,14 +32,15 @@
32
32
  "typecheck": "tsc -p tsconfig.json --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@deepseek-ai/dsh-tools": "0.1.0-rc.8",
36
35
  "js-yaml": "^4.1.0"
37
36
  },
38
37
  "peerDependencies": {
39
- "@deepseek-ai/cordis": "^4.0.1"
38
+ "@deepseek-ai/cordis": "^4.0.1",
39
+ "@deepseek-ai/dsh-tools": "0.1.0-rc.8"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@deepseek-ai/cordis": "^4.0.1",
43
+ "@deepseek-ai/dsh-tools": "0.1.0-rc.8",
43
44
  "@types/js-yaml": "^4.0.9",
44
45
  "@types/node": "^22.10.0",
45
46
  "typescript": "^5.6.0"