dsh-bili-scroll
c1overzz
DSH 插件:每天替你刷一轮 B站,读字幕挑出值得的、写一份日报,值得的 @ 你
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:yorelog/dsh-open-model
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Local open-model hub for DeepSeek Harness (dsh). One Host bundle covers the whole loop: search → download → discover/register → start inference → release when idle, with a Windows runtime (llama-server) and an Apple Silicon runtime (mlxcel-server), mirror/proxy support for mainland networks, and zh/en output that follows the session language.
| Platform | Runtime | Model formats | Notes |
|---|---|---|---|
| Windows x64 | llama-server |
GGUF | releases from ggml-org/llama.cpp; CPU / CUDA (+ cudart) / Vulkan |
| macOS arm64 | mlxcel-server |
MLX, safetensors | Homebrew first, GitHub archive second, source build documented as last resort |
| macOS x64 | — | — | runtime_status reports mlxcel as unsupported |
| Linux | — | — | llama-server is not managed here; tools report the platform as unsupported |
| Tool | Purpose |
|---|---|
model_search |
Search HuggingFace / hf-mirror / ModelScope; returns repo ids, stats, tags, homepage, a slim file list and a downloadHint |
model_download |
Download via the hub CLI (SDK fallback) with mirrored endpoint + proxy, progress, resume and optional background mode |
model_download_status |
Byte progress, speed, ETA, and cancellation |
model_scan |
Scan model roots; format and quantization come from file headers / sibling metadata |
model_register |
Register a discovered or downloaded model (by path or scan id) |
model_load |
Start the platform runtime, record PID/port/timestamps, wait for health |
model_unload |
Graceful stop, then forced kill after the grace period |
model_infer |
OpenAI-compatible chat/completions call; refreshes lastUsedAt |
runtime_status |
Runtime availability, path, version, missing CUDA DLLs, registered models |
runtime_install |
Install llama-server (Windows) or mlxcel (Apple Silicon) |
The prompt section lists every registered model as id · format · quant · loaded, so the model knows what is available without a tool round-trip. It also
reports which download transport was verified in this environment.
All fields are optional; the row's config is validated by Schemastery when the
Host resolves it, and by a Standard-Schema fallback otherwise. Every field is
declared volatile, so a settings write is committed into the running plugin
instead of restarting it: the plugin resolves its config through those live
references on every use, and a saved value (the model folder, for example)
applies immediately without stopping a loaded model. The row still restarts,
and tears down owned servers, when its ordinary options — not its config —
change.
| Field | Default | Meaning |
|---|---|---|
modelRoots |
[] → ${DSH_HOME}/models |
Extra/discovery roots scanned by model_scan |
runtimeDir |
'' |
Directory holding llama-server / mlxcel-server |
idleTimeoutMs |
300000 |
Release a model after this much inactivity |
idleCheckIntervalMs |
30000 |
Idle sweep period |
defaultSource |
hf-mirror |
Used when a tool call omits source |
hfEndpoint |
'' → HF_ENDPOINT → official Hub |
Endpoint for source=huggingface |
hfMirrorEndpoint |
https://hf-mirror.com |
Endpoint injected as HF_ENDPOINT for source=hf-mirror |
modelscopeEndpoint |
https://modelscope.cn |
Domestic or international ModelScope site |
proxy |
{} |
A URL string, or { http, https, all, noProxy } |
githubProxyPrefix |
'' |
Prefix for GitHub release URLs, used only after a direct failure |
backend |
auto |
llama.cpp Windows backend: auto/cpu/cuda/vulkan |
locale |
auto |
auto/zh/en; auto follows the session |
serverHost |
127.0.0.1 |
Inference bind address |
loadTimeoutMs |
180000 |
Startup health timeout |
stopGraceMs |
10000 |
Grace between SIGTERM/taskkill and forced kill |
requestTimeoutMs |
120000 |
model_infer timeout |
scanDepth |
4 |
model_scan recursion depth |
downloadMethod |
auto |
auto/cli/sdk |
llamaArgs / mlxcelArgs |
[] |
Extra argv appended to the server |
Example profile patch:
- id: dsh-open-model
name: 'dsh-open-model'
config:
idleTimeoutMs: 300000
proxy:
https: http://127.0.0.1:7890
githubProxyPrefix: https://gh-proxy.com/
modelscopeEndpoint: https://www.modelscope.ai
hf-mirror sets HF_ENDPOINT for the
child process, so a user's global HuggingFace configuration cannot redirect a
download to the wrong host.HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY are written in both
cases. Empty inherited or configured values are deleted, because an empty
proxy variable makes most HTTP stacks silently connect directly.curl -x; otherwise Node's fetch is used.modelscope.cn and
modelscope.ai; the endpoint you configure is the endpoint that receives the
token from your environment (MODELSCOPE_API_TOKEN).githubProxyPrefix or
the proxyPrefix argument — nothing is hardcoded.| Path | Content |
|---|---|
${DSH_HOME}/model-hub/registry.json |
Registered models, runtime state (pid/port/startedAt/lastUsedAt) |
${DSH_HOME}/model-hub/runtimes.json |
Discovered runtime cache (path/version/backend) |
${DSH_HOME}/model-hub/downloads.json |
Download journal (bounded) |
${DSH_HOME}/model-hub/state.json |
Recent automatic releases |
${DSH_HOME}/runtimes/... |
Runtimes installed by this plugin |
${DSH_HOME}/models/... |
Default download/scan root |
Every write is temp-file + rename. Reads tolerate a missing or corrupt file: the registry resets to empty with a warning instead of blocking activation, and runtime entries whose PID no longer exists are cleared on load.
model_infer refreshes lastUsedAt before and after the request, so a long
generation is never reaped mid-flight.ctx.effect; its disposer clears the timer.ctx.effect disposes the supervisor and the download manager:
every child process this plugin spawned is killed, and runtime fields are
cleared, so hot reload leaves no orphaned server.taskkill /T (there is no SIGTERM for
console apps); a server that ignores it is escalated to /F after
stopGraceMs and the tool reports the escalation.general.file_type maps to a quantization label (Q4_K_M, Q8_0, …). When
an older converter omits general.file_type, the tensor table's dominant
ggml type supplies the label. The filename is used only when the header is
unreadable, and quantEvidence reports which source decided.__metadata__.config.json, weights, and a quantization block
(bits/group size) is recognized as MLX and reported as mlx-<bits>bit-g<group>.Config is a real Schemastery schema. A linked profile package cannot resolve
the Host's dependency graph through normal ESM lookup, so the plugin imports the
exact @deepseek-ai/schemastery file the Harness loads (derived from the Host
entry script and process.resourcesPath) and falls back to a Standard-Schema
object only when that lookup fails. The result is a Config row that Settings and
the Config inspector can project, with descriptions and defaults.
Every field is marked .volatile(), which is what lets the Host settings service
expose it to a live form. The plugin ships that form itself and opts out of the
auto-generated page (settings.configure({ auto: false })).
Open Settings → Open Model Hub in the Web GUI. The page has four tabs:
Overridden marker with a per-field reset, and revision-fenced writes. Saving
persists into the profile patch and applies immediately: the values are
volatile, so the running plugin picks them up in place — no restart, no
stopped model server, downloads and the registry untouched.The dashboard talks to the Host through the plugin's own same-origin JSON bridge
(POST /api/open-model/status and POST /api/open-model/tool). The bridge only
accepts browser same-origin requests and an allowlist of this plugin's tool
names; it exposes no arbitrary service call. It lives on the loopback Web server
only. The configuration form itself rides the shared settings transport
(ctx.configForms).
The page is a plain-JS Client half (client.js), imports no Harness Client
package, and uses --dsw-alias-* theme tokens only, so it inherits light/dark
themes. Add client.js and the dsh.client block to the bundle manifest when
packing.
The bundle ships icon.svg, exported as ./icon and declared as
package.json#icon, and the Settings page repeats the same artwork in its
header. The Settings navigation glyph itself is shell-owned: the shell maps each
section id to a built-in icon and falls back to the gear, so a plugin cannot
supply its own nav glyph through the slot contract.
The Host half registers an OpenAI-compatible LLM provider route named
open-model through ctx.llm.registerAdapter(). Every registered model appears
in the GUI model picker under Open Model Hub; selecting one makes it the
session model, so normal chat and agent runs use the local server directly
instead of calling model_infer.
The adapter resolves the model's live loopback port, auto-loads the model on
first use, and translates the server's SSE stream into the Harness chunk
protocol (text, reasoning, tool calls, usage, finish). Models with an in-flight
provider request are excluded from the idle reaper. runtime_status reports
LLM provider: open-model is registered with N model(s).
qwen2.5 gguf, choose a source, and press Search. (You can also ask the
assistant to run model_search in chat.)*Q4_K_M.gguf to fetch one
quantization, then press Download. Files land in
<model root>/<owner>/<name> — by default
${DSH_HOME}/models/<owner>/<name> (on this machine
C:\Users\zhou\.dsh\models\...).llama-server; MLX models by mlxcel-server on Apple Silicon. Idle servers
are released after idleTimeoutMs (5 minutes by default).Tool descriptions are English model-facing protocol text; every tool result, error, install instruction and release notice follows the session locale.
plugin_manager install_bundle target: <absolute path to this directory>
Install is local-directory based; there are no runtime dependencies. Then verify:
cordis_inspect_query Service.Tool.listTools # 10 model_* / runtime_* tools
cordis_inspect_query Config.listConfigs # this row's schema
node test/selftest.mjs
The self-test builds synthetic GGUF/safetensors/MLX fixtures, imports the real Host JSON-Schema subset validator when available, and checks schemas, outputs, registry atomicity/corruption tolerance, quantization detection, proxy-env sanitization and the prompt section in both languages.
runtime_status lists missing
cudart64_* / cublas64_* / cublasLt64_* next to the executable or on
PATH — it does not download them silently.cargo build --release --features metal,accelerate)
require the Rust/Metal toolchain and are documented, not automated.dsh-open-model 是 DeepSeek Harness 的本地开源模型中枢,覆盖
搜索 → 下载 → 发现/注册 → 启动推理 → 空闲释放 全流程,在 Host 侧同时管理
Windows 的 llama-server 与 Apple Silicon 的 mlxcel-server,并针对国内网络做了
镜像与代理适配。
| 工具 | 作用 |
|---|---|
model_search |
搜索 HuggingFace / hf-mirror / ModelScope,返回 repoId、下载量、标签、主页、精简文件列表与 downloadHint |
model_download |
通过 CLI(SDK 兜底)下载,注入镜像端点与代理,支持进度、断点续传与后台模式 |
model_download_status |
字节进度、速度、ETA 与取消 |
model_scan |
扫描模型根目录,格式与量化来自文件头/同目录元数据 |
model_register |
按路径或扫描 id 写入注册表 |
model_load |
启动运行时,记录 PID/端口/时间并等待健康检查 |
model_unload |
先优雅终止,超时后强制结束 |
model_infer |
发送 OAI 兼容请求,并刷新 lastUsedAt |
runtime_status |
报告运行时可用性、路径、版本、缺失的 CUDA DLL 与已注册模型 |
runtime_install |
Windows 安装 llama-server,Apple Silicon 安装 mlxcel |
已注册模型会以 id · 格式 · 量化 · 是否已加载 的精简清单进入系统提示词,并按
ctx.locale/会话语言切换中英文;工具输出、错误消息、安装指引、空闲释放通知同样双语化。
${DSH_HOME}/model-hub/,运行时安装到 ${DSH_HOME}/runtimes/,默认模型根目录
是 ${DSH_HOME}/models。在 Web 界面打开 设置 → 开源模型中枢,页面分四个标签页:
已覆盖 标记与单项“恢复默认”,写入带版本校验;
保存会持久化到 profile patch 并立即生效:值通过 volatile 引用就地提交,不重启插件行,
运行中的模型不会停止,下载与注册表原样保留。搜索与下载、扫描与运行状态通过插件自己的同源 JSON 桥
(POST /api/open-model/status、POST /api/open-model/tool)访问 Host:只接受浏览器
同源请求,且只允许本插件白名单内的工具名,不暴露任意服务调用;桥只存在于回环 Web 服务。
配置表单仍走共享设置通道(ctx.configForms)。
界面是纯 JS 客户端半(client.js),不引入 Harness 客户端包,只使用
--dsw-alias-* 主题令牌,自动适配亮/暗主题,并随界面语言中英切换。
插件自带 icon.svg(通过 ./icon 导出,并在 package.json#icon 声明),设置页头部
也使用同一图标。设置左侧导航的图标由 shell 按 section id 写死(未知 id 回退为齿轮),
插件无法通过槽位契约提供自定义导航图标。
Host 侧通过 ctx.llm.registerAdapter() 注册了一个名为 open-model 的 OpenAI 兼容
提供商。所有已注册模型会出现在界面顶部的模型选择器里(分组名 Open Model Hub),
选中后即可作为会话模型直接对话/跑 Agent,不再需要调用 model_infer。
适配器会解析模型当前的本地端口、首次使用时自动加载,并把 llama-server 的 SSE 流转成
Harness 的 chunk 协议(文本、推理、工具调用、用量、结束)。有进行中请求的模型不会被
空闲释放扫描停掉。runtime_status 会报告
LLM provider: open-model is registered with N model(s)。
qwen2.5 gguf,选来源后点搜索
(也可以在对话里让我调用 model_search)。*Q4_K_M.gguf,只下载需要的量化,点下载。
文件会落到 <模型根目录>/<owner>/<name>,默认是
${DSH_HOME}/models/<owner>/<name>(本机为 C:\Users\zhou\.dsh\models\...)。idleTimeoutMs(默认 5 分钟)会自动释放。hfEndpoint、hfMirrorEndpoint、modelscopeEndpoint,
不会把 huggingface.co 写死在请求里;hf-mirror 会给子进程注入
HF_ENDPOINT,不依赖用户全局配置。HTTP_PROXY/HTTPS_PROXY/ALL_PROXY/NO_PROXY(大小写都写);
空字符串一律删除,避免“空代理 = 静默直连”。curl -x,否则用 Node fetch。githubProxyPrefix 或 proxyPrefix 参数,插件内不硬编码
任何代理地址。MODELSCOPE_API_TOKEN
并在配置里选择对应站点。lastUsedAt,长请求不会被空闲扫描误杀。ctx.effect 注册的定时器执行(默认每 30s 检查一次,默认 5 分钟空闲)。把本目录的绝对路径交给 plugin_manager install_bundle 即可;安装后用
cordis_inspect_query 查询 Tool.listTools 与 Config.listConfigs 确认工具与配置
schema。自测脚本为 node test/selftest.mjs。
runtime_status 会检查并提示缺失项,但不会
静默下载。cargo build --release --features metal,accelerate)需要 Rust 与
Metal 工具链,仅作为文档化的最后手段,未自动化。CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。