# 🔁 dsh-translate - **1024 商店渠道**:先 `npm i -g dsh1024`,再 `dsh1024 plugin --profile web add dsh-translate`(计入 [deepseek1024.com](https://deepseek1024.com) 安装排行)。 **DeepSeek Harness 的厂商参数翻译与确定性 JSON 修复。** *同一请求,适配每家厂商。坏 JSON 修好,绝不编造数据。* **这是厂商参数映射表,不是机器翻译。** > **官方仓库。** 本仓库是 dsh-translate 的唯一官方仓库,由 PerryLink 维护。其他账号下的同名仓库与本项目无关。 [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) [![Gitee](https://img.shields.io/badge/Gitee-mirror-c71d23?logo=gitee)](https://gitee.com/perrylink/dsh-translate) [![DSH plugin](https://img.shields.io/badge/dsh--plugin-✅-green)](https://github.com/topics/dsh-plugin) [![dsh-doctor](https://raw.githubusercontent.com/PerryLink/dsh-plugin-doctor/main/badges/PerryLink__dsh-translate.svg)](https://github.com/PerryLink/dsh-plugin-doctor#verified-徽章) [![DSH Market](https://raw.githubusercontent.com/2BingLing/dsh-market/master/assets/readme/badge-listed-zh.svg)](https://dsh.market/) [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-brightgreen.svg)](#) [![CI](https://img.shields.io/github/actions/workflow/status/PerryLink/dsh-translate/ci.yml?branch=main&label=CI)](https://github.com/PerryLink/dsh-translate/actions) [![Version](https://img.shields.io/github/v/tag/PerryLink/dsh-translate?label=version)](https://github.com/PerryLink/dsh-translate/releases) [![npm version](https://img.shields.io/npm/v/dsh-translate)](https://www.npmjs.com/package/dsh-translate) [![npm downloads](https://img.shields.io/npm/dm/dsh-translate)](https://www.npmjs.com/package/dsh-translate) [![dshfind](https://dshfind.com/api/badge/PerryLink/dsh-translate?metric=downloads&lang=zh)](https://dshfind.com/zh/plugins/PerryLink/dsh-translate?ref=badge) [English](README.md) · [简体中文](README-zh.md) · [Español](README-es.md) · [Português](README-pt.md) · [हिन्दी](README-hi.md)
--- **📖 生态实测知识库**(实测数据,不是营销):[插件开发指南 · 选型实测数据 · 维护取舍判据](https://perrylink.github.io/dsh-plugin-guide/)。 ## ⭐ 如果它帮到了你 这个插件是 [DSH 插件家族](https://github.com/PerryLink)的一员(40+ 个,全部 Apache-2.0)。如果你在用,**给个 star** —— 它不会解锁任何功能,但会让下一个人在搜索里更容易找到它。 *English:* part of a 40+ plugin family for DeepSeek Harness. If it is useful, **a star helps the next person find it** — nothing is gated behind it. ## What is dsh-translate? DeepSeek Harness 的厂商参数翻译与确定性 JSON 修复。 同一请求,适配每家厂商。坏 JSON 修好,绝不编造数据。 ![dsh-translate 终端演示:dsh-translate — /translate openai ernie max_tokens](https://raw.githubusercontent.com/PerryLink/dsh-translate/main/docs/assets/dsh-translate-hero.png) ![Animated terminal demo of dsh-translate](https://raw.githubusercontent.com/PerryLink/dsh-translate/main/docs/assets/dsh-translate-demo.gif) *同一次运行,动图版。* ## 兼容性 | 方面 | 状态 | |---|---| | Harness | 主版本 **`dsh-v0.2.1-alpha.1`**(2026-09-24 核验:双 typecheck 尺子 + `node --test` 80/80 + self-contained/artifacts 门)。npm dev/test 钉号已抬至 `0.1.7-rc.2`;peers 三段式 `>=0.1.2-rc.1 <0.2.0 \|\| >=0.1.5-alpha.1 <0.2.0 \|\| >=0.1.6-0 <0.2.0 \|\| >=0.1.7-0 <0.2.0`。 | | Node | `^22.19.0 \|\| >=24.0.0` | | 形态 | 纯 host JS 插件(无浏览器半) | | 模型 | 任意模型 —— 修复完全确定性,不增加模型调用 | ## 你能得到什么 一个 bundle 里两个相互独立的表面: - **`/translate`** —— 厂商参数翻译表:`temperature`、`top_p`、`max_tokens`、`stop`、`system` 等 13 个规范参数,映射到 **11 家厂商**(OpenAI、ERNIE、Qwen、Anthropic、Google、DeepSeek、Mistral、Cohere、xAI、Groq、Azure)。可查任意两家映射、列出厂商/参数,或用 `lib/rosetta.mjs` 的 `transformRequest` 转换整个标准请求。 - **修复层** —— `tools/post-execute` 监听器 + `fix_json` 工具。当成功的工具结果以字符串携带坏 JSON(schema 根为 string 型或无约束 `json` 型,或工具被按名加入名单)时,确定性地修复:markdown 围栏提取、转义修复、去尾逗号、截断闭合、必填字段以显式 `null` 占位补全。**绝不编造数值** —— 修复后仍违反 schema 的结果失败关闭,失败的工具结果也绝不被翻转为成功。 ```text 工具结果(成功,JSON 文本)──▶ 提取围栏 ──▶ 解析 │ 合法? ──▶ schema 校验 ──▶ accept { kind: 'accept', value }(注册表重新校验+重渲染) │ 损坏 ──▶ 转义 / 去尾逗号 / 闭合 / null 补全 ──▶ 校验 │ 无法修复 ──▶ next()(保留原值)+ translate/fix 审计(只记计数) ``` ## 快速开始 ```sh dsh plugin --profile web add github:PerryLink/dsh-translate ``` ```sh # 1. 把 bundle 装进你的 profile dsh plugin --profile web add github:PerryLink/dsh-translate # 或从 npm 安装(正式发布版) dsh plugin --profile web add dsh-translate # 2. 重启并核实行 dsh --profile web --dump-config | grep -A2 'id: dsh-translate' ``` 然后让 agent 查映射或修复载荷: ``` > /translate openai ernie max_tokens > 用 fix_json 修复: {"a": 1,},schema 为 {"type":"object","properties":{"a":{"type":"integer"}},"required":["a"]} ``` ## 安装与卸载 - **git 通道**(最新 `main`):`dsh plugin --profile web add github:PerryLink/dsh-translate` —— 纯 JS,无构建步骤。 - **npm 通道**(正式发布版):`dsh plugin --profile web add dsh-translate`。 - **tarball 通道**:在本仓库执行 `pnpm pack`,然后 `dsh plugin --profile web add ./dsh-translate-.tgz`。 - **卸载**:`dsh plugin --profile web remove dsh-translate`(或从 profile patch 中删除该行)。 ## 配置 所有可调项都是 Schemastery `Config` 字段(可在 cordis.yml 中修改)。按 id 定向覆盖会替换整行 —— 需要重新声明每个键。`cordis.patch.yml` 内联说明了每个键。 | 键 | 默认值 | 含义 | |---|---|---| | `enabled` | `true` | 总开关;`false` 不注册任何东西 | | `repair.enabled` | `true` | post-execute 修复层开关 | | `repair.toolNames` | `[]` | 额外按名加入修复的 JSON 文本工具(叠加于 string 根/`json` 根 schema) | | `repair.strategies.escapeRepair` | `true` | 转义字符串内的裸控制字符 | | `repair.strategies.trailingComma` | `true` | 删除闭合括号前的逗号 | | `repair.strategies.truncationClosure` | `true` | 闭合因截断而未闭合的字符串或容器 | | `repair.strategies.fieldCompletion` | `true` | 以显式 `null` 占位补全缺失的必填字段 | | `repair.maxSteps` | `8` | 策略应用预算(修复循环轮数,1..64) | | `diffMaxChars` | `200` | 单条日志 diff 片段的字符上限 | | `diffMaxEntries` | `50` | 日志 diff 条目上限 | | `registerCommand` | `true` | 注册 `/translate` 命令 | | `registerTool` | `true` | 注册 `fix_json` 工具 | | `rosettaDataPath` | *(none)* | 可选的外部 rosetta 数据文件(与内置 `lib/rosetta-data.json` 同形);覆盖内置映射表 | profile patch 中的覆盖示例: ```yaml - insert: - id: dsh-translate name: dsh-translate config: enabled: true repair: enabled: true toolNames: ['emit-json'] strategies: escapeRepair: true trailingComma: true truncationClosure: true fieldCompletion: true maxSteps: 8 diffMaxChars: 200 diffMaxEntries: 50 registerCommand: true registerTool: true ``` ## 工具与界面 | 界面 | 类型 | 说明 | |---|---|---| | `/translate` | 命令 | `vendors`、`params`,或 ` [param]` 两两映射 | | `fix_json` | 工具 | `{ text, schema?, strategies? }` → `{ ok, repaired?, diff?, strategies, truncated, validated, error? }`;diff 片段有界且脱敏 | | post-execute 修复 | 监听器 | 对 string 根/`json` 根 schema(加 `repair.toolNames`)的成功字符串结果自动生效;不认领时永远 `next()` | ## 权限与数据 - **权限**:无网络、无子进程、无凭据 —— 只消费官方 `commands` 与 `tools` 服务并写会话日志。 - **数据**:修复绝不编造数值;模型可见的增量只有修复后的规范值与 `fix_json` 的 diff。会话审计事件(`translate/fix`)只记工具名、call id、策略名、编辑条数与截断标志 —— 绝不记载荷。审计写入受宿主会话事件词汇表门控:认识 `translate/fix` 的宿主走两参 append;带 `ignorable` append 信封的宿主带标记写入;无信封宿主(`0.1.0-rc.6`–`0.1.1-rc.2`、`0.1.2-rc.1`)不写审计 —— 工具结果本身仍是模型可见日志。 0.1.2-rc.1(2026-09-04 已适配):会话信封保留 ignorable 字段但仅用于存量日志读取兼容——Session.append 仍无法盖章,门控行为不变。 ## 安全边界 - **只做确定性修复。** 修复是有界文本手术;JSON-Schema-Enforcer-Proxy 上游的 LLM 重试臂被有意不移植 —— post-execute 监听器绝不调用模型。 - **失败关闭。** 无法修复的语法与 schema 违例保持原结果不变(或由 `fix_json` 返回结构化错误);`null` 占位仅在 schema 接受 `null` 时落地。 - **敌意输入有界。** 不支持的 schema 关键字与循环 schema 被拒绝;`oneOf` 校验受深度(`MAX_ONE_OF_DEPTH`)与分支预算(`MAX_ONE_OF_BUDGET`)限制,指数级 schema 无法耗尽进程。 - **载荷零泄漏。** 日志与审计事件绝不包含修复后的载荷;diff 在展示或存储前先截断并限条。 ## 已知限制 - 支持的 JSON Schema 子集与 harness 工具注册表一致(`type`/`oneOf`/`properties`/`required`/`additionalProperties`/`items`/`enum`/`const`);其他关键字按不支持拒绝,而非静默忽略。 - 修复只作用于规范值为 JSON 文本字符串的成功结果;已因 schema 校验失败的结果按失败到达,绝不翻转。 - 翻译表覆盖 11 家厂商 × 13 个规范参数;`extended` 行按公开 API 参考扩展(非上游三家),并在 `lib/rosetta.mjs` 中标注。 - 在既不认识 `translate/fix`、`session.append` 又无 `ignorable` 信封的宿主上(已发布 `0.1.0-rc.6`–`0.1.1-rc.2` 线,以及读取时对未知事件类型 fail-closed 的 `0.1.2-rc.1`),自适应门跳过审计写入,会话日志永不被污染;这些宿主在收录该事件类型前没有 in-log 审计镜像。 ## 开发 ```sh pnpm install # node ^22.19 || >=24 pnpm test # node --test:57 个测试(纯函数套件 + 真实服务装配套件) pnpm run check # tsc checkJs,对照 types.d.ts pnpm run verify:self-contained # 依赖声明全部来自 registry pnpm run verify:artifacts # 纯 Node 下 ESM 面可 import + lib 导出齐全 node scripts/check-readme-sync.mjs # 五语 README 同步门(CI 同样执行) pnpm pack # 发布用 tarball ``` ## 与其他 DSH 插件的互操作 已对照 **DSH `0.2.0-rc.2`**(本 README 面向的运行时)与 2026-10-05 实测的高星插件集验证。 本插件**不干扰**其他插件,包括广泛安装的高星插件: - **无工具名冲突。** 所有工具都带命名空间,不占用任何已被内置工具或其他插件持有的裸名。 - **无服务键冲突。** 不提供任何服务键,因此不存在服务键冲突。 - **无 slot 冲突。** 不注册客户端 slot key,因此不参与 `shadows-shipped-ui` 座位争抢。 - **无 HTTP 路由冲突。** 不注册任何 `webServer` 前缀。 - **无 patch 层冲突。** 组合包 patch 只 `insert` 自己那一行,从不覆写内置行的 `config`。 - **无全局改写。** 不改原型、不改写 `process.env`、不替换全局 fetch dispatcher。 **共享事件监听器在构造上就不互相干扰。** 它用 `ctx.on()` 监听顺序敏感事件 `tools/post-execute` —— Cordis 的**广播**语义:每个监听器都会运行,任何一个都无法饿死其他监听器。**此处每个监听器都通过 `next()` 委托**,因此链条绝不会被短路;改写作用在 `next()` 产出的值上,而不是用它顶替返回: - `tools/post-execute` — also used by `cc-safety-net` (1576★). 静态证据:`dsh-plugin-doctor` 的 K10–K13 在本仓全部为 `pass`。 ## Topics `dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `json-repair`, `schema-validation`, `parameter-mapping`, `llm-api`, `tooling` ## Contributors - [@PerryLink](https://github.com/PerryLink) —— 创建者与维护者:翻译表与修复管线移植、插件表面、测试与五语文档。 ## PerryLink DSH Plugin Family 本项目是 [PerryLink](https://github.com/PerryLink) 维护的 DeepSeek Harness 插件家族成员:**34 个活跃维护**,名册共 **42** 个,其中 **5 个已冻结**、**3 个已退役**——每一个都在下表保留自己的行,原因见「状态」列。如果它能帮到你,其他的也会: | Plugin | 一句话 | 状态 | |---|---|---| | **[dsh-auto-review](https://github.com/PerryLink/dsh-auto-review)** | Second-model auto-review on the approval chain, fail-closed by default | | | **[dsh-autotier](https://github.com/PerryLink/dsh-autotier)** | Automatic strong/cheap model-tier routing with deterministic risk guards and a `/tier` command | | | **[dsh-background-agents](https://github.com/PerryLink/dsh-background-agents)** | Durable background child agents with a Web UI sidebar, messaging and interrupt | 🚫 **已退役** — 见上方说明 | | **[dsh-budget](https://github.com/PerryLink/dsh-budget)** | Cost governance for DeepSeek Harness: budgets, carbon, and latency in one panel. | 🧊 已冻结 — 见仓库 README | | **[dsh-catalog](https://github.com/PerryLink/dsh-catalog)** | DSH Desktop Market standard catalog source for the PerryLink family | | | **[dsh-cert-mcp](https://github.com/PerryLink/dsh-cert-mcp)** | Read-only MCP server exposing the certification registry: grades, snapshots and five-dimension evidence | | | **[dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind)** | Claude Code /rewind-equivalent: snapshots, session forks, one-shot restore | | | **[dsh-claude-move](https://github.com/PerryLink/dsh-claude-move)** | Migrate Claude Code sessions, memory, skills and CLAUDE.md into DSH | 🧊 已冻结 — 见仓库 README | | **[dsh-click](https://github.com/PerryLink/dsh-click)** | Cross-platform native desktop control for DeepSeek Harness — Windows first. | | | **[dsh-composer-history](https://github.com/PerryLink/dsh-composer-history)** | Terminal-style input history for the web composer: arrows, Ctrl+R search | | | **[dsh-data-quality](https://github.com/PerryLink/dsh-data-quality)** | Dataset quality checks and citation cross-checks (the optional numeric bridge consumed here) | | | **[dsh-defend](https://github.com/PerryLink/dsh-defend)** | Prompt-injection, jailbreak, and secret-leak defense for DeepSeek Harness. | 🧊 已冻结 — 见仓库 README | | **[dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck)** | Engineering-discipline guard: requirements grill, test gates, adversary review | | | **[dsh-draw](https://github.com/PerryLink/dsh-draw)** | Unified static-image generation routing for DeepSeek Harness. | 🧊 已冻结 — 见仓库 README | | **[dsh-fast](https://github.com/PerryLink/dsh-fast)** | Read-only performance diagnostics for DeepSeek Harness. | | | **[dsh-fund-research](https://github.com/PerryLink/dsh-fund-research)** | Deterministic research reports for Chinese public mutual funds | | | **[dsh-github](https://github.com/PerryLink/dsh-github)** | GitHub PR/issues integration for DSH, every write gated by approval | | | **[dsh-industry-research](https://github.com/PerryLink/dsh-industry-research)** | Industry research orchestration that seals its deliverables through this plugin's `ctx.researchReport.assemble` | | | **[dsh-laya](https://github.com/PerryLink/dsh-laya)** | Laya typed decisions (`noul`/`choice`/`score`) as a first-class Cordis service and model-visible tools | | | **[dsh-library](https://github.com/PerryLink/dsh-library)** | Local document knowledge base for DeepSeek Harness. | | | **[dsh-local-ai](https://github.com/PerryLink/dsh-local-ai)** | Local-model (Ollama) integration for DeepSeek Harness. | | | **[dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions)** | LSP diagnostics, formatting, completion, code actions and rename over language servers | | | **[dsh-mask](https://github.com/PerryLink/dsh-mask)** | PII masking middleware: anonymize at the model boundary, restore at the display layer | | | **[dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel)** | Read-only MCP runtime panel: /mcp command + Settings tab with status, tools and errors | | | **[dsh-memento](https://github.com/PerryLink/dsh-memento)** | Approval-gated cross-session memory: ctx.memory seam + SQLite + memory tool | | | **[dsh-observe](https://github.com/PerryLink/dsh-observe)** | OpenTelemetry and Langfuse observability exporter for DeepSeek Harness. | | | **[dsh-output-styles](https://github.com/PerryLink/dsh-output-styles)** | Claude Code outputStyles-equivalent runtime style switching | | | **[dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules)** | Claude Code-style declarative allow/deny/ask permission rules with audit | | | **[dsh-plugin-certification](https://github.com/PerryLink/dsh-plugin-certification)** | Community certification registry with repro-checkable grades and badges | | | **[dsh-plugin-doctor](https://github.com/PerryLink/dsh-plugin-doctor)** | Zero-dependency static + sandbox smoke detector for DSH plugins | | | **[dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide)** | Plugin-development knowledge base as an on-demand agent skill | | | **[dsh-plugin-kit](https://github.com/PerryLink/dsh-plugin-kit)** | Shared zero-runtime-dependency toolkit for the PerryLink DSH plugins | | | **[dsh-plugin-upgrade](https://github.com/PerryLink/dsh-plugin-upgrade)** | One-package, one-corridor-index plugin upgrade skill: routes a repository to the matching closed corridor card | | | **[dsh-plugin-upgrade-015](https://github.com/PerryLink/dsh-plugin-upgrade-015)** | Merged `0.1.3-alpha.1` → `0.1.5-rc.1` upgrade corridor card plus a zero-dependency seam scanner | 🚫 已退役 —— 走廊由 `dsh-plugin-upgrade` 承担 | | **[dsh-reach](https://github.com/PerryLink/dsh-reach)** | Multi-channel approval/question bridge: WeChat/Telegram/Feishu, session console | 🧊 已冻结 — 见仓库 README | | **[dsh-research-report](https://github.com/PerryLink/dsh-research-report)** | Verifiable research-report engine: content-addressed evidence ledger and sealed versions | | | **[dsh-score](https://github.com/PerryLink/dsh-score)** | Multi-dimensional quality scoring for DeepSeek Harness plugins. | | | **[dsh-session-pin](https://github.com/PerryLink/dsh-session-pin)** | Pin sessions in the Web sidebar with durable ordering | 🚫 **已退役** — 见上方说明 | | **[dsh-session-sync](https://github.com/PerryLink/dsh-session-sync)** | Cross-device session sync for DeepSeek Harness — a dedicated git mirror of your session store. | | | **[dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security)** | Security-audit skill pack: secret scan, dependency and supply-chain review | | | **[dsh-talk](https://github.com/PerryLink/dsh-talk)** | Voice-first session loop for DeepSeek Harness: talk to it, hear it answer. | | | **[dsh-team-rooms](https://github.com/PerryLink/dsh-team-rooms)** | Cross-session team rooms: shared message bus, task board and timeline | 🚫 **已退役** — 见上方说明 | | **[dsh-test-drive](https://github.com/PerryLink/dsh-test-drive)** | Isolated install-and-smoke test drives for DeepSeek Harness plugins. | | | **[dsh-ticktick](https://github.com/PerryLink/dsh-ticktick)** | TickTick/Dida365 task bridge: session-header panel + 11 tools | | | **[dsh-translate](https://github.com/PerryLink/dsh-translate)** | Vendor parameter translation and deterministic JSON repair for DeepSeek Harness. | | ## License [Apache License 2.0](LICENSE) © 2026 dsh-translate contributors ### 从 DSH Desktop 市场安装 所有 PerryLink 插件均可在 DSH Desktop 内置市场中浏览:**市场 → 来源 → 添加来源 → 粘贴** `https://perrylink-dsh-catalog.perrylink.workers.dev/catalog-source.json` **→ 选中**。安装仍需通过市场的 npm 身份校验与你的确认。