把 WebP 附件图片转码成 PNG,让带 alpha 通道的图能在无法解码 WebP 的 LLM 后端上加载(例如 llama.cpp)。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:MrGnUm/dsh-image-webp-to-png
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
A DeepSeek Harness (DSH) bundle that fixes the 400: Failed to load image or audio file error you get when sending alpha-channel images to a backend that
cannot decode WebP — most notably llama.cpp (its vision decoder is stb_image,
which has no WebP support).
It is an installable plugin: it lives in your profile, is re-applied on every DSH
start, and survives DSH updates without touching the root-owned
/usr/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-attachment-local
file.
Why images fail
DSH normalizes every attached image in dsh-attachment-local. The codec choice is
hard-coded (encodingLadder):
const mediaType = hasAlpha ? "image/webp" : "image/jpeg";
So any image with an alpha channel is re-encoded to WebP. (A clean 8-bit sRGB image with no metadata that fits the size/limit budget passes through as-is; opaque images become JPEG.)
- Opaque → JPEG → llama.cpp decodes it fine.
- Alpha → WebP → llama.cpp's
stb_imagecannot decode WebP → the request is rejected with400 {"code":400,"message":"Failed to load image or audio file"}and the server logsE mtmd_helper_bitmap_init_from_buf: failed to decode webp buffer.
There is no configuration knob in dsh-attachment-local to change this codec,
and the server side (llama.cpp) is not going to add a WebP decoder, so the fix
belongs on the client.
How the bundle fixes it
The adapter (e.g. dsh-llm-pi-ai, used by your fedotov provider) builds the
outgoing request by calling the attachment seam:
attachments.readImageRequest(ref, target, signal) // -> { data, mediaType, width, height, ... }
This bundle wraps that one seam method at DSH start (idempotently, guarded by a
Symbol). Whenever the underlying store returns a WebP request-image, the
wrapper transparently re-encodes those bytes to PNG:
- PNG preserves the alpha channel (JPEG would flatten it).
- PNG is decodable by every backend (llama.cpp, OpenAI-compatible, …).
- Dimensions are unchanged (pure format conversion, no resize).
- The result is cached by
variantId, so a given image is re-encoded once.
Everything else passes through untouched (JPEG stays JPEG, PNG stays PNG).
The wrapper is fail-open: if sharp is missing, a decode fails, or the seam is
not ready at load time, the original WebP result is returned unchanged and DSH
keeps working exactly as before. This bundle can never block or fail a request.
Files
dsh-image-webp-to-png/
├── package.json # bundle manifest (dsh.bundle.patch)
├── cordis.patch.yml # self-declares the entry (id: image-webp-to-png)
├── lib/index.mjs # the bundle: wrap(attachments) + webpToPng()
├── install.sh # install into a profile (default: web)
└── uninstall.sh # remove from a profile
Install
Requirements: pnpm on PATH, and a DSH profile (default ~/.dsh/profiles/web).
cd dsh-image-webp-to-png
./install.sh # -> ~/.dsh/profiles/web
# or a different profile:
DSH_PROFILE_DIR=/path/to/profile ./install.sh
install.sh (idempotent, backs up package.json first):
- Adds
dsh-image-webp-to-pngas alink:dependency pointing at this directory. - Adds it to the profile's
dsh.profile.bundlesarray. - Runs
pnpm installin the profile to create the symlink + update the lockfile.
The fix takes effect on the next DSH web session (immediately if the profile
has patchReload: "live").
Install from GitHub
Repo: MrGnUm/dsh-image-webp-to-png
(private). From any machine with pnpm, git, and access to the repo — HTTPS
clone works with the gh credential helper (no token prompt):
git clone https://github.com/MrGnUm/dsh-image-webp-to-png.git
cd dsh-image-webp-to-png
./install.sh # -> ~/.dsh/profiles/web
Then restart the DSH web session (or it hot-reloads if the profile has
patchReload: "live"). Remove later with ./uninstall.sh.
Verify
Send an alpha-channel image (a PNG with transparency) to your fedotov model
and ask it to describe it. Before the bundle: 400 … Failed to load image or audio file. After: the model describes the image.
You can also watch the DSH logs for the one-time line:
dsh-image-webp-to-png: wrapped attachments.readImageRequest (WebP -> PNG).
Revert
./uninstall.sh # clean removal
# or, using the backup install.sh made:
./uninstall.sh ~/.dsh/profiles/web/package.json.bak-<timestamp>
For the admin (server side, optional)
The client-side fix above is sufficient. If you would rather fix it at the source,
the root cause is the hard-coded hasAlpha ? "image/webp" : "image/jpeg" in
dsh-attachment-local/lib/index.js (encodingLadder, and the matching
pipeline.webp(...) branch in encode()). Upstream has no option to emit PNG for
alpha images; a small patch adding a PNG branch (and bumping the
request-image-v6 transform version so stale WebP cache entries are regenerated)
would remove the need for this bundle.
Compatibility notes
- Works with any DSH profile that mounts the local attachment store
(
LocalAttachmentStore). If a future DSH changes the seam method name (readImageRequest) or its return shape, the wrapper degrades to a no-op (fail-open) and the original behaviour resumes. sharpis resolved from the DSH installation (/usr/lib/node_modules/@deepseek-ai/dsh/node_modules/sharp); this bundle has no runtime dependencies of its own.
链接
同类插件
yjh051108/dsh-routing-suite★ 6997
一个仓库三件套:DSH 插件包的运行时注入器(注入、热重载、卸载、开发侧挂区一键转正、路由自愈,外带设置页插件管理:列出、卸载、拖入文件夹内化)、任务感知的思维模式路由 agent 预设(router-standard / router-spec / router-react)、以及分级两级任务协议(commit_star / lock_stage / revise_do / edit_plan / mark_task / redteam_verdict 六个工具,任务状态落盘)。注入器实现直接在库内,安装的是它自己的行为而不是一份依赖清单。
strukto-ai/mirage#dsh★ 3696
把文件系统与 bash 提供者换成 mirage 虚拟工作区:文件工具与 shell 命令作用于挂载的资源(RAM、S3、Redis、Slack、Gmail、Notion、Postgres)而非宿主磁盘,支持按挂载点设置读/写/执行模式、按命令选择沙箱(进程内 monty、pyodide、quickjs;远程 docker、e2b、daytona),并可在虚拟终端中安装 CLI(git、gh、slack、linear、ntn、gws,或自行注册的程序树)作为命令头词。
hust-open-atom-club/oh-dsh★ 322
社区发行版:TUI、桌面端与 Web UI 统一体验,分层安装、一步到位。
weijiafu14/pi2dsh★ 217
Pi Host ABI 兼容引擎:装一次之后,npm 上的 Pi 扩展原包经 `dsh plugin add <pi-package>` 直接作为 DSH 原生插件挂载。已在官方 DSH 上端到端验证 pi-mcp-adapter(完整 MCP 管理面:OAuth、resources、prompts、MCP Apps、elicitation、sampling)、@tintinweb/pi-subagents、pi-code、pi-hermes-memory、pi-background-tasks;`pi2dsh inspect` 在安装前报告一个包的兼容情况。
Fishquito7/dsh-skill-mcp-panel★ 203
在 DSH Web 设置中管理技能与 MCP 服务器:技能卡片热启停、工作区作用域、分组、批量迁移与拖拽导入,以及 stdio/HTTP MCP 增删改查、连接测试、密钥脱敏,并附带统一 dsh-panel 命令行。
MichengAI/dsh-skills-manager★ 194
在设置里管理本地 DSH 技能,并只读查看公共 Agent 技能。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。