spyfree/dsh-media-guard0

dsh-media-guard

DSH 媒体守护插件:提供确定性的媒体预算限制与安全的请求投影,防止超额消耗。

AI 分析

核心用途是限制多模态请求中的图片/视频数据大小。适合需要严格控制多模态 API 流量消耗、防止因大图上传导致高额账单的用户。

包名
dsh-media-guard
版本
0.1.0-alpha.1
许可证
MIT
最近更新
2026年8月17日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:spyfree/dsh-media-guard

Configuration

Override the plugin row from your profile's cordis.patch.yml with a flat patch entry targeting the row id (the same form DSH's own bundles use):

- id: media-guard
  config:
    mode: protect            # observe | optimize | protect
    log: false               # true prints a one-line summary per projection
    budget:
      maxMediaBlocks: 8
      maxSerializedMediaBytes: 2097152
      maxDecodedMediaBytes: 1572864
      maxSerializedBytesPerImage: 524288
    profiles:                # keyed by the request's provider route id
      my-vision-gateway:
        maxSerializedMediaBytes: 12582912
        maxDecodedMediaBytes: 9437184

A profiles entry is more specific than the top-level budget, so for the fields it declares it wins on its route even when both are set.

Modes:

  • observe: inventory and report only;
  • optimize: compress but do not externalize;
  • protect: compress, then externalize overflow media (default).

enabled: false bypasses the guard entirely. Every config field is validated individually; an invalid value falls back to its protective default and is reported — a broken config can never widen a budget or switch the guard off.

Unlike the Pi original there are no built-in provider profiles: DSH provider routes are deployment-defined, so every route gets the conservative default until you declare a profile for it.