Skip to content

Releases

v1.0.0: dsh-webp-relabel 1.0.0

Choose a tag to compare

@lilinhua0413 lilinhua0413 released this 12 Oct 14:51

Relabels DSH's normalized WebP request images as image/png, so local OpenAI-compatible vision servers (LM Studio, llama.cpp) accept pasted screenshots instead of rejecting the whole request.

The error this fixes

Pasting a screenshot into DeepSeek Harness and picking a local vision model produced:

'url' field must be a base64 encoded image.

The image was fine — the label was not.

Why it happens

dsh-attachment-local picks the container from the alpha channel (hasAlpha ? "image/webp" : "image/jpeg"), so screenshots are stored as WebP. dsh-llm-pi-ai then writes version.mediaType straight into the OpenAI image_url payload. Servers that allowlist PNG/JPEG labels for that field reject the call, even though the bytes decode perfectly well.

The fix

Wrap attachments.readImageRequest() and return the same bytes under a compatible label. No transcoding, no extra dependencies. Measured against LM Studio:

payload result
webp bytes + image/webp ❌ HTTP 400 'url' field must be a base64 encoded image.
webp bytes + image/png ✅ HTTP 200, image understood
png bytes + image/png ✅ HTTP 200
png bytes + image/webp ❌ HTTP 400

Install

dsh plugin --profile <your-profile> add https://github.com/lilinhua0413/dsh-webp-relabel/releases/download/v1.0.0/dsh-webp-relabel-1.0.0.tgz

If it installs but never shows up in the plugin list, also add dsh-webp-relabel to dsh.profile.bundles in your profile's package.json — or install through the in-app plugin manager, which handles that step for you.

Configuration

Defaults ship with the bundle. To override, add this to your profile's cordis.patch.yml:

- id: dsh-webp-relabel
  config:
    from: image/webp
    to: image/png     # image/jpeg also works
    debug: false      # silence the per-image log line

Verified

  • 7 unit tests (npm test), including that the patch survives Cordis's traceable Proxy and fully restores itself on unload
  • End-to-end: the model correctly reads text drawn into an alpha PNG that DSH normalized to WebP

Limitations

  • The label does not match the container (bytes stay WebP). That is correct for servers validating the label; a provider checking magic bytes would need real transcoding.
  • Applies to every provider, because readImageRequest() cannot see the target route.

简体中文

把 DSH 归一化出来的 WebP 请求图片重标记为 image/png,让本地 OpenAI 兼容的视觉模型(LM Studio、llama.cpp)愿意接收粘贴的截图,而不是直接拒掉整条请求。

报错:'url' field must be a base64 encoded image. —— 图没问题,标签不对。

原因:dsh-attachment-local 按 alpha 通道选容器(hasAlpha ? "image/webp" : "image/jpeg"),截图带 alpha 于是被存成 WebP;dsh-llm-pi-ai 再把 version.mediaType 直接写进 OpenAI 的 image_url。只允许 PNG/JPEG 标签的服务器就会拒绝,尽管字节本身完全能解码。

做法:包装 attachments.readImageRequest(),字节一个不改,只换标签。不需要转码,也没有额外依赖。

安装:

dsh plugin --profile <你的 profile> add https://github.com/lilinhua0413/dsh-webp-relabel/releases/download/v1.0.0/dsh-webp-relabel-1.0.0.tgz

若装上了但插件列表里看不到,请把 dsh-webp-relabel 加进 profile package.json 的 dsh.profile.bundles,或改用 GUI 插件管理器安装(它会自动处理这一步)。

配置:默认值随包提供,覆盖写在 profile 的 cordis.patch.yml(见上方英文段的 YAML)。

验证:7 个单测(npm test)+ 端到端(模型能读出带 alpha 的 PNG 上的文字)。

限制:标签与容器不一致(字节仍是 WebP),仅适用于校验标签的服务器;对所有 provider 生效。