返回目录
模型与 MCP 插件

dsh-ghost-downloader

Lemon140339/dsh-ghost-downloader

给 agent 一条真正的下载路径:大文件走本地 Ghost Downloader 多连接,小文件直连,GitHub 链接自动兜底。DeepSeek Harness 插件。

Stars
0
Forks
0
Issues
0
更新
5 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:Lemon140339/dsh-ghost-downloader

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-ghost-downloader

English | 中文

version license ci platform harness

A DeepSeek Harness plugin that downloads files for a session over the faster of two paths: the local Ghost Downloader (multi-connection, resumable, visible in its window) or a plain one-connection fetch inside the plugin. It registers a ghost_download tool for every agent in the profile.

The plugin, its tests and this documentation were written in one session by the deepseek-flash model inside DeepSeek Harness.

Why this plugin exists

The problem. An agent that needs a real file — a model checkpoint, a dataset, a video clip, an ISO — has no good way to get it inside a session. web_fetch returns decoded text. Shelling out to curl gives you one connection, no resume, no progress you can see, and a file that may land outside the workspace where later reads are blocked. On many hosts a single connection is throttled to a crawl; and the public GitHub mirrors that exist for blocked networks are slower than GitHub itself whenever GitHub is reachable.

What changes.

  • A real download path. ghost_download writes the file to disk and returns its path and state, so the next step can use it instead of working around a missing tool.
  • The downloader only where it pays. Large files on hosts that allow ranged requests go to Ghost's multi-connection engine; small files and non-ranged servers are fetched over one connection, because handing those to Ghost costs more than the extra connections save. The choice is made per URL, from measured signals — not by file extension.
  • GitHub handled by reality. Download directly when GitHub is reachable, and fall back to the downloader's proxy chain only when it is not, because those mirrors solve reachability rather than speed.
  • Files land where the agent can use them. They arrive in the session workspace, so later reads, moves and edits stay inside the sandbox instead of asking for approvals.
  • Failures are visible and bounded. A stalled transfer aborts instead of hanging a turn; a rejected link is reported with the downloader's own reason; a link the server already answered with 404/410 never becomes a task.

What you get in practice. Downloads stop being a blocking shell command: a Ghost task keeps running while the conversation moves on, the agent can poll for "done" instead of guessing, and a broken route falls over to one that works instead of failing silently.

When it is not worth it. Files of a few megabytes from a fast host are fine with plain curl. Tasks cannot be paused or cancelled through the agent — use Ghost's window for that. And it is Windows-only, because Ghost Downloader is.

Requirements

OS Windows 10 or 11 (Ghost Downloader is a Windows application)
Harness DeepSeek Harness ^0.2.1-rc.3 — the plugin API surface it was written against is 0.2.2-rc.3
Node 20 or newer, as bundled in the Harness
Downloader Ghost Downloader 4.5.x, aria2 RPC enabled (the default), GitHub acceleration optional

engines.dsh in package.json is enforced by the plugin manager: installing on an older Harness is refused rather than silently half-working.

Install

This is a DeepSeek Harness bundle installed from its directory; it is not published on npm.

  1. git clone https://github.com/Lemon140339/dsh-ghost-downloader
  2. In DeepSeek Harness open Plugins → Add plugin and pick the cloned folder.
  3. Open a new session: ghost_download is now available to every agent in the profile.

Requires Ghost Downloader installed, with its aria2 RPC enabled (the default). The plugin finds the executable itself; set ghostExe only for an unusual layout.

To disable it, switch the bundle off in Plugins; to remove it, delete the bundle there and the cloned folder. Nothing is written into the downloader, so uninstalling leaves Ghost exactly as it was.

First check after install

  1. Plugins shows a row titled Ghost downloads with the download arrow icon.
  2. Ask an agent to download something small, or call the tool directly: ghost_download { "action": "add", "urls": ["https://example.com/file.zip"] }.
  3. The result names a path under <session workspace>/downloads, and the file is there with the expected size.
  4. { "action": "list" } shows the task if Ghost handled it; status reports it either way.

What it does

  • add — takes 1–10 URLs and returns one handle per file: URL, actual file name, absolute path, status, and via (which path was used).
  • status — reports status, size and errors for files submitted earlier.
  • wait — polls until the files finish or a timeout expires (default 30 s).
  • list — the newest Ghost tasks, optionally filtered to one folder.

mode overrides the routing: auto (default), ghost, or direct.

Files land in <session workspace>/downloads unless dir says otherwise, and the folder is created on demand. Ghost writes with its own OS account, so the file appears directly in the workspace and later reads, moves and edits stay inside the sandbox. Only per-task options (dir, out, header) are sent over the RPC: the downloader's own configuration is never read, written or changed.

The status returned by add is the state observed when the task was confirmed: small files are usually already COMPLETED, anything large is still RUNNING. Follow with status or wait for the final state — a path is usable only once it reports COMPLETED.

How auto chooses

Ghost only wins when a server limits a single connection. When the link is already saturated, Ghost's extra connections reach the same total and its submission handoff is pure loss. So auto:

  1. non-HTTP link (magnet, ed2k) or an .m3u8 playlist → Ghost (only it can handle those);
  2. server answers 404/410 → rejected before submission (no task, no downloader notification);
  3. server without ranged requests, or a file under autoGhostBytes (32 MiB) → direct;
  4. unknown size or failed probe → Ghost (it discovers the size and retries);
  5. otherwise a ranged file of at least autoGhostBytes → Ghost.

GitHub links

GitHub gets its own rule. The downloader reaches GitHub through public mirror proxies, which exist for networks where github.com is blocked or crawling — when GitHub itself is reachable they are usually slower, and the downloader's eight workers do not help much through them. So auto downloads from GitHub directly and hands the link to the proxy chain only when that fails (connection error or a transfer that stalls for 15 s). githubRoute pins the behaviour: auto (default), ghost (always proxy), direct (never proxy).

The downloader ships its GitHub acceleration disabled (GitHub.Enabled in its UserConfig.json); with it off, a link handed over is fetched directly, exactly like this plugin's own path. The tool reads that switch (it never writes it) and says so when a fallback runs while the switch is off.

Why 32 MiB

A single connection usually already saturates a home link, so Ghost only matches it there; the gain appears on hosts that throttle one connection, where extra connections recover throughput (bounded by the host's per-IP limit, not by the worker count). Below roughly 10 MiB, Ghost's fixed handoff cost dominates and it loses outright. autoGhostBytes is the crossover knob; mode overrides the guess per call when you know the host better than the heuristic.

A throughput probe was tried and rejected: sampling the first megabytes reads far below the sustained rate while CDN fill-in is still happening, so it misclassified fast mirrors as slow and routed them to Ghost. Size and ranged support are the reliable cheap signals.

Usage

ghost_download { "action": "add", "urls": ["https://example.com/big.iso"] }
ghost_download { "action": "status", "paths": ["./downloads/big.iso"] }
ghost_download { "action": "wait", "paths": ["./downloads/big.iso"], "timeoutMs": 90000 }
ghost_download { "action": "add", "urls": ["https://example.com/a.zip"], "mode": "ghost" }
ghost_download { "action": "add", "urls": ["https://example.com/a.zip"], "dir": "C:/Downloads" }
ghost_download { "action": "add", "urls": ["https://example.com/private.bin"], "headers": { "Referer": "https://example.com/" } }

Paths may be absolute or relative to the session workspace.

Configuration

Set these on the plugin's row in the profile patch; every key has a working default.

key default meaning
rpcPort 16800 Ghost's Aria2Rpc.Port
rpcHost 127.0.0.1 RPC host
ghostExe auto-detected executable used when the port is silent
autoLaunch true start Ghost instead of failing
defaultDirName downloads folder created under the session workspace
autoGhostBytes 33554432 (32 MiB) size at or above which auto considers Ghost
githubRoute auto auto = direct first, proxy chain on failure; ghost = always proxy; direct = never proxy
launchTimeoutMs 30000 how long to wait for a started Ghost
maxWaitMs 120000 upper bound for one wait call
dataDir %LOCALAPPDATA%\GhostDownloader where Ghost keeps tasks.jsonl and its log
ledgerPath / logPath derived from dataDir individual overrides
confirmMs 6000 window for confirming that Ghost created a task

Finding Ghost Downloader

With ghostExe empty the plugin looks, in order:

  1. the Windows uninstall entry (any of HKLM 64-bit, HKLM 32-bit, HKCU) whose DisplayName mentions Ghost Downloader — its InstallLocation;
  2. the usual install folders derived from the environment: %ProgramFiles%, %ProgramFiles(x86)%, %LOCALAPPDATA%, %APPDATA%, each with Ghost Downloader, Programs\Ghost Downloader and GhostDownloader appended;
  3. inside the chosen folder, Ghost-Downloader-3.exe or the first Ghost-Downloader*.exe.

If nothing is found, the tool reports that and asks for ghostExe instead of guessing. Point dataDir at a nonstandard location when Ghost was installed in portable mode, and rpcPort when Aria2Rpc.Port was changed in UserConfig.json.

What it touches on your machine

  • Reads, never writes: Ghost's tasks.jsonl (task status), its GhostDownloader.log (why a submission was refused), and UserConfig.json (only the GitHub.Enabled switch, to explain a fallback).
  • Writes: only the destination folder for the files you asked for, via a temporary file that is renamed on completion.
  • Network: the URLs you ask for, plus 127.0.0.1:<rpcPort> for Ghost's RPC.
  • Processes: starts the Ghost executable when its RPC port is silent and autoLaunch is on; never stops it.

Troubleshooting

symptom likely cause what to do
Ghost Downloader is not answering on 127.0.0.1:16800 Ghost is not running and autoLaunch is off start Ghost, or set autoLaunch: true
could not find its executable unusual install location or portable setup set ghostExe (and dataDir if needed)
status stays RUNNING and wait times out Ghost keeps retrying a broken connection check the link in Ghost's window; it may resume by itself
GitHub download falls back and still fails GitHub unreachable and Ghost's GitHub acceleration is off enable it in Ghost's settings, or set githubRoute: "ghost"
no percentage while a task runs Ghost rewrites its ledger only on state changes expect status only; progress appears when the task finishes
Windows toast "链接解析失败" from Ghost Ghost's own notification for a failed link rejections for 404/410 are pre-screened; for other failures adjust Ghost's Notice settings

Limitations

  • Ghost 4.5.7's RPC implements only aria2.getVersion and aria2.addUri. The tool cannot pause, resume, cancel or remove a task, and status comes from Ghost's ledger rather than the RPC. Use Ghost's window for task control.
  • A rejected submission (unreachable host, HTTP error, unsupported link) creates no task; Ghost writes the reason only to its log, so the tool reports FAILED with that log message. A submission whose task never appears is UNKNOWN, not a fake success.
  • Ghost preallocates the target file, so a full-size file does not mean the download finished. The .ghd sidecar marks an unfinished task, and the ledger is rewritten only on state changes, so there is no live percentage to report.
  • A URL the server answers with 404 or 410 is rejected before submission, so it creates no task and no downloader notification. Every other failure does create a task, and Ghost Downloader shows its own notification for it.
  • The direct path has no resume: a dropped connection loses that file's progress. Files it writes are invisible to list (they are not Ghost tasks), though status still reports them from the filesystem. A transfer with no data for 15 s is aborted rather than left waiting.
  • GitHub proxy sites are third-party services: the downloader probes them, uses whichever answers, and retries another on failure. Content arrives unchanged (verify with the asset's own checksum or signature), but their speed and availability are outside this plugin's control.

Development

node test/routing.test.mjs   # routing rules, no network
node test/tool.test.mjs      # tool layer, needs the local test server
node test/verify.mjs         # Ghost client, needs Ghost running + the test server
node test/bench.mjs          # optional three-way speed comparison
python test/serve.py 18080   # local ranged file server for the tests above

Changelog

See CHANGELOG.md.

License

MIT. See LICENSE.

Not affiliated with the Ghost Downloader project; this plugin only talks to its local aria2-compatible JSON-RPC endpoint.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。