Repository navigation
Releases
v0.4.3
从 0.2.1 到 0.4.3 的完整变化:新增免 Key 的公共接口引擎并设为默认,翻译链路、并发与错误处理重做,补上缓存、限流与一次性隐私告知,卡片交互补齐触摸与固定。
中文
新增功能
- 新增免 Key 的「免费 API」引擎并设为默认:走腾讯、微软 Bing、火山、MyMemory 的公共接口,不需要账号、Key 或 token,装完即用;harness 自带大模型保留为另一个引擎。
- 自动模式按实测质量依次尝试四家接口,失败的一家按 30 秒起步、逐次翻倍、上限五分钟冷却,单个接口挂掉不会让后续翻译都耗在超时上。
- 设置页可在两个引擎间切换:选「免费 API」只显示主语言、翻译服务和超时,选「大模型」才显示模型、推理等级、最大输出 token 与温度;可指定具体 provider/model,留空则跟随会话默认模型。
- 翻译结果会被复用:同一段文本十分钟内再译直接命中缓存并标注「已缓存」;「重试」刻意绕过缓存重新请求。
- 每个页面每分钟最多发起 60 次翻译请求,超出后提示稍后再试;「重试」穿透接口冷却的能力也限制为最快 3 秒一次。
- 首次使用免费引擎时,卡片内一次性说明划选文本已发送到第三方翻译服务,并提示可改用大模型;确认后不再出现。
- 划词支持手指与触控笔划选,长按选中后松手即出现按钮,不再只响应鼠标。
- 固定住的译文卡片不再被下一次翻译替换:它留在原位,正在翻译的也会继续译完。
问题修复
- 修复取消翻译经常失效的问题:取消改为按调用方自铸的 run 令牌匹配,页面刷新、开多个标签页后依然有效;此前用的是客户端与 Host 各自维护、启动后必然错位的计数器。
- 修复一个标签页的翻译会取消另一个标签页翻译的问题:并发状态从「每进程一份」改为「每客户端一份」。
- 修复被取消的翻译让卡片永远停在「翻译中…」的问题:取消现在是有文案、可重试的终态。
- 修复 provider 或模型列表卡住时整个翻译请求无限期挂起的问题:模型/服务查找与流式输出共用同一个截止时间。
- 修复超时填大数会让每次翻译都瞬间「超时」的问题:数值字段补上上限(超时 600000 毫秒,避开底层定时器的 32 位溢出)。
- 修复设置页数字框清空后被当成 0、保存时被 Host 拒绝的问题;数值超出范围现在会指名报错。
- 修复两个标签页同时改设置互相覆盖的问题:只写本次真正改动过的字段,未触碰的字段会跟随其它标签页的保存更新。
- 修复接口把原文原样退回时被当成译文展示的问题:整条链都只回原文时标注「未翻译(原文返回)」,而不是谎报译文、也不再谎报接口故障。
- 修复纯数字、表情等非字母文本被原样退回时被当成译文的问题。
- 修复免费 API 请求超过 2000 字符被静默截断的问题:卡片现在提示译文可能被截断。
- 修复 MyMemory 返回的 HTML 实体(
"、')原样显示在卡片上的问题。 - 修复跨行划选时按钮跑到最宽一行右缘、压住无关内容的问题:现在锚定在划选结束的位置。
- 修复浮层
pointer-events与 shell 样式打平、谁后加载谁生效的问题:改为内联样式并提高选择器特异性,避免全屏浮层吞掉整个应用的点击。 - 修复界面被渲染进 shadow root 时无法识别自身、卡片定位测量失败的问题。
- 修复热重载或重复挂载时两个实例互相干扰、彼此丢弃在途结果的问题:可变状态从模块级改为每实例持有。
- 修复 Bing 接口首次并发调用重复请求门户页、生成两份临时会话的问题,以及每次接口尝试都会留下一个未清理的最长 15 秒定时器的问题。
- 修复默认模型只在插件挂载时解析一次、之后注册的模型服务看不到的问题。
- 修复翻译错误直接显示 Host 或厂商原始英文(可能包含密钥、内部地址)的问题:主文案一律走本地化字典,诊断信息脱敏后另起一行。
体验优化
- 译文卡片底栏标明实际生效的一方——免费 API 显示应答的服务、大模型显示模型——并标注方向、推理等级、token 消耗、缓存命中与截断。
- 免费 API 全链失败时,卡片逐家列出失败原因(冷却中 / 不支持该语言 / 文本过长 / 返回了原文 / 请求失败),并提示可点「重试」立即强制再试。
- 设置页底部的主行动作改为「放弃修改 / 保存」,DOM 顺序与视觉顺序一致,Tab 顺序跟着眼睛走。
- 设置页字段的「已覆盖 / 恢复默认」徽章实时跟随草稿:改一个值立即亮起,恢复默认立即熄灭,无需先保存。
- 插件在插件页有了自己的标题、描述与图标;README 重写为纯用户向文档,截图更新到当前界面,并明确写出免费引擎的两点风险。
- 错误码成为与语言无关的契约,卡片按读者语言渲染。
其他变更
- 默认引擎变更,需要知悉:0.2.1 只有 harness 大模型一条路径,划选文本不会离开你配置的模型管道;0.4 起默认走公共免费接口,划选文本会发送到第三方。不接受的话,在插件设置里把引擎改成「大模型」。
- 安装方式变更,需要迁移:0.2 系列的动态插件与
--patch覆盖层加载不再支持,插件必须以 bundle 形态装成 profile 里的一行。用覆盖层装的旧行没有正确的插件 id,设置页不会出现,需要卸掉重装。 - 接口搬运:业务接口从未认证的
/translator/api前缀迁移到四条经认证的/api/translator/*Fetch 路由,由 DSH 的 Host/Origin 校验与浏览器认证保护;因此 0.2.1 时代针对0.0.0.0绑定的启动告警随之移除。 - 设置传输变更:设置卡从
settingsScope迁移到官方configForms加插件自己的页面,配置导出为Configschema,全部可编辑字段标记.volatile(),保存即时生效、无需重启插件。 - 要求 DSH ≥ 0.2.1-alpha.1、Node ≥ 22.19;更新插件后需要重启 DSH 实例以加载新的 Host 半边。
lib/构建产物随仓库提交,git 安装无需构建脚本;npm run check现在同时校验语法、构建产物一致性与 85 项回归测试,并接入 CI。- 移除动态插件形态、
stability/目录与本地开发覆盖层;截图脚本改为复用机器上已有的 Chromium。
English
The full change set from 0.2.1 to 0.4.3: a keyless public-endpoint engine added and made the default, the translation path, concurrency and error handling reworked, caching, metering and a one-time privacy notice added, and the card's interaction completed with touch and pinning.
New Features
- Add a keyless Free API engine and make it the default: it goes through the public endpoints of Tencent, Microsoft Bing, Volcengine and MyMemory with no account, key or token. The harness's own LLM stays available as the other engine.
- Automatic mode walks the four endpoints in measured quality order, benching a failing one with a 30-second cooldown that doubles up to five minutes, so one dead endpoint no longer makes every later translation wait out a timeout.
- The settings page switches between the two engines: Free API shows only the primary language, the service and the timeout; Model swaps in the model, reasoning effort, max tokens and temperature. A specific provider/model can be pinned, and leaving it empty follows the session default.
- A finished translation is reused: the same passage translated again within ten minutes hits the cache and is marked cached. Retry deliberately skips the cache and asks again.
- Each page may make 60 translation requests a minute, after which the card asks you to wait. The Retry button still reaches past provider cooldowns, but at most once every three seconds.
- The first translation with the free engine says, once, in the card, that the selected text was sent to a third-party service, and points at the Model engine. After that it does not appear again.
- The selection button answers touch and pen input — a long press raises it on release — instead of only the mouse.
- A pinned card is no longer replaced by the next translation: it keeps its place, and one that is still translating finishes.
Bug Fixes
- Fix cancellation failing so often: a cancel is now matched by a run token the caller mints, so it keeps working after a page reload and with several tabs open. It used to compare two counters, one per side, that could never re-align after a restart.
- Fix a translation in one tab cancelling the translation in another: in-flight state is kept per client instead of per process.
- Fix a cancelled translation leaving the card on "Translating…" forever: a cancellation is now a terminal state with its own label and a Retry.
- Fix the whole request hanging indefinitely when a provider or its model list stalls: the model/service lookup and the stream now share one deadline.
- Fix every translation timing out instantly when the timeout was set to a large number: the numeric fields have ceilings now (600000 ms for the timeout, above which the underlying timer overflows 32 bits).
- Fix a cleared number box being read as 0 and refused by the Host on save; an out-of-range value is now named instead.
- Fix two tabs editing the settings overwriting each other: only the fields changed in this form are written, and untouched fields follow a save made elsewhere.
- Fix an endpoint returning the source unchanged being shown as a translation: when the whole chain only echoes, the card says not translated (source returned) instead of claiming a translation or blaming the endpoints.
- Fix digits, emoji and other letterless text being passed off as translations when echoed back.
- Fix free-API requests longer than 2000 characters being truncated silently: the card now says the translation may be truncated.
- Fix MyMemory's HTML entities (
",') reaching the card verbatim. - Fix the button landing on the widest line's right edge, over unrelated content, when the selection wraps lines: it anchors where the selection ended.
- Fix the overlay's
pointer-eventstying with the shell's rule, where whichever stylesheet loaded later won: it is set inline as well, with a more specific selector, so the full-viewport layer cannot swallow the application's clicks. - Fix the overlay failing to recognise itself and measuring the card wrongly when a slot renders it into a shadow root.
- Fix two instances interfering with each other on hot reload or a repeated mount, each discarding the other's in-flight result: the mutable state moved from module scope into the instance.
- Fix Bing's first concurrent calls loading the portal page twice and minting two sessions, and fix every endpoint attempt leaving an uncleared timer of up to fifteen seconds.
- Fix the default model being resolved only once, at plugin mount, leaving a model service registered later invisible.
- Fix translation errors printing the Host's or a provider's raw English, which could carry a key or an internal address: the primary line is always localized, and diagnostics are redacted onto a second line.
Improvements
- The card's footer names what actually answered — the endpoint for Free API, the model for Model — along with the direction, reasoning effort, token usage, a cache hit and truncation.
- When the whole free-API chain fails, the card lists each endpoint's reason (cooling down / target unsupported / text too long / echoed the source / request failed) and points at Retry to force an immediate attempt.
- The settings page's primary actions are Discard changes / Save, in DOM order as well as on screen, so tab order follows the eye.
- A field's Overridden / Reset to default badge follows the draft live: changing a value lights it, restoring the default clears it, with no save needed.
- The plugin has its own title, description and icon on the Plugins page; the README is rewritten for users, the screenshots are current, and the free engine's two caveats are stated plainly.
- Error codes are a locale-independent contract, rendered by the card in the reader's language.
Chores
- The default engine changed, and it matters: 0.2.1 had only the harness model, so selected text never left the model pipeline you configured. Since 0.4 the default goes through public endpoints, so the selected text is sent to a third party. Switch the engine to Model in the plugin settings if that is not acceptable.
- The installation form changed, and needs migrating: the 0.2 line's dynamic plugin and
--patchoverlay loading are gone; the plugin installs as a bundle — one row in the profile. An overlay row carries the wrong plugin id, so its settings page never appears and it has to be removed and reinstalled. - The route moved: the business API went from the unauthenticated
/translator/apiprefix to four authenticated/api/translator/*Fetch routes, behind DSH's Host/Origin fence and browser authentication; the 0.2.1-era startup warning for a0.0.0.0bind went away with it. - The settings transport changed: the card moved from
settingsScopeto the officialconfigFormsplus the plugin's own page, with the configuration exported as aConfigschema whose editable fields are all.volatile()— a save takes effect immediately, with no plugin reload. - Requires DSH ≥ 0.2.1-alpha.1 and Node ≥ 22.19. Restart the DSH instance after u...
dsh-translator v0.2.1
新增功能
- 插件配置全面对齐 DSH 官方机制:导出
Configschema,全部参数支持在cordis.yml行配置中覆盖,并与设置卡片分层(部署默认 ← 用户覆盖) - 设置卡片迁移至官方
settingsScope设置总线:写入带 revision 并发保护,字段级set/unset精确落盘 - 划词按钮更换为通用翻译图标(lucide languages,文/A),不再依赖语言;按钮、卡片、配置卡与错误提示支持中英双语,语言选项始终显示各语言母语名
- 翻译失败改为稳定错误码契约(无可用模型 / 翻译超时 / 模型调用失败等),并附带详细上下文
问题修复
- 修复关闭翻译卡片时因函数作用域引用错误导致的页面报错
- 修复模型流式响应停滞时翻译请求无期限挂起:超时 / 取消 / 替换现为真实中止底层请求(AbortSignal),停滞 30 秒后稳定落定为「翻译超时」
- 修复旧配置把整份默认值写入用户层,导致设置卡每个字段都显示「已覆盖」的问题
- 服务以
0.0.0.0绑定对外暴露时,启动即给出响亮警告,提示翻译 API 对当前网络开放
体验优化
- 「已覆盖 / 恢复默认」徽章实时跟随编辑:改一个值立即亮起,恢复默认立即熄灭,无需先保存
- README 精简为纯用户向文档,移除开发覆盖层、行配置与演示录屏章节;四张截图更新为当前界面(通用图标、真实模型信息)
- 移除动态插件维护快照,仅保留单一打包实现;固化 17 项 host 回归测试与本地客户端冒烟工具
New Features
- Plugin configuration aligned with the official DSH mechanisms: exported
Configschema, every tunable overridable fromcordis.yml, layered under the settings card (deployment defaults ← user overrides) by @nicearrack - Config card moved to the official
settingsScopetransport: revision-fenced writes, per-fieldset/unsetby @nicearrack - The selection button now uses the universal lucide "languages" (文/A) icon; button, cards and error strings are bilingual (zh/en), language options keep their own names by @nicearrack
- Stable error-code contract for translation failures (no model / timeout / model call failed) with details by @nicearrack
Bug Fixes
- Fix the page error raised when closing the translation card (
refreshButtonscope) by @nicearrack - Fix translations hanging forever on a stalled provider stream: timeout / cancel / supersede now really abort the underlying request (AbortSignal); stalls settle as "timeout" in ~30s by @nicearrack
- Fix stale user-layer config (old full-default writes) marking every field as overridden by @nicearrack
- Loud startup warning when the harness binds
0.0.0.0and the translation API is exposed to the network by @nicearrack
Improvements
- Override badges follow the draft in real time — light up on change, clear on restore, no save needed by @nicearrack
- README trimmed to user-facing content (dev overlay, row config and demo recording removed); screenshots refreshed to the current UI by @nicearrack
- Single packaged implementation (dynamic-plugin snapshot removed); host regression suite (17 cases) and local client smoke tooling by @nicearrack
Full Changelog: v0.2.0...v0.2.1
dsh-translator v0.2.0
功能与体验
这次更新把划词翻译从「固定中英互译」升级成可配置的多语言翻译:语言、方向、模型和推理等级都能在 DSH 设置里自己定,译文卡片也会显示用到的模型与 token 消耗。
- 新增划词翻译配置面板(DSH 设置 → 插件 → 划词翻译):
- 主语言:简体中文 / 繁體中文 / 日本語 / 한국어 / Русский(默认简体中文)
- 模型:可指定具体模型,留空则跟随会话默认模型
- 推理等级:off / low / high / max(默认 low)
- 超时、最大输出 token、温度
- 每个字段带「已覆盖 / 恢复默认」;草稿式修改,保存 / 放弃修改
- 方向自动判断:选中的文字属于配置的主语言 → 翻译成英文;否则 → 翻译成主语言
- 译文卡片底部新增 meta 行:方向 · 所用模型 · 推理等级 · token 消耗(模型不报用量时自动估算)
- 点击即复制:点击译文、原文或错误信息即可复制,带「已复制」提示
- 兼容无推理能力的模型:模型不支持对应 effort 时自动省略并重试——本地 OpenAI 兼容端点不再报 "does not support reasoning effort"
- 配置文案随 DSH 语言切换(中文 / English),语言名本地化显示
- 配置卡片样式与 DSH 原生插件一致(圆角下拉菜单、字段徽标、同款按钮)
- 配置持久化在 DSH settings 服务(per-profile)
Features
This release turns the plugin from a fixed Chinese ↔ English tool into a configurable multi-language one: language, direction, model and reasoning effort are all settable in DSH settings, and the translation card now shows the model and token usage.
- New plugin configuration panel (DSH Settings → Plugins → 划词翻译):
- Primary language: Simplified / Traditional Chinese, Japanese, Korean, Russian (default Simplified Chinese)
- Model: pick a specific model, or leave it empty to follow the session default
- Reasoning effort: off / low / high / max (default low)
- Timeout, max tokens, temperature
- Per-field "Overridden / Restore default"; staged edits with Save / Discard
- Automatic direction: selected text in the primary language → English; otherwise → the primary language
- Footer meta line on the translation card: direction · model · reasoning effort · token consumption (estimated when the provider reports none)
- Click to copy: click the translation, the source text, or an error message — with a "已复制 / Copied" hint
- Models without reasoning support no longer fail: an unsupported effort is omitted (and retried) automatically, so local OpenAI-compatible endpoints no longer report "does not support reasoning effort"
- Config labels and UI text follow the DSH locale (Chinese / English), including localized language names
- Configuration card styling matches DSH's native plugin cards (rounded dropdown menus, field badges, matching buttons)
- Configuration persists through the DSH settings service (per-profile)
安装 / 更新
安装:dsh plugin --profile web add @nicearrack/dsh-translator@0.2.0
更新:dsh plugin --profile web update @nicearrack/dsh-translator
新版本刚发布时 npm 元数据可能有传播延迟,@latest 若仍指向旧版请钉住 0.2.0;更新后重启 DSH 实例(dsh --profile web)加载新 host 包。
Install / Update
Install: dsh plugin --profile web add @nicearrack/dsh-translator@0.2.0
Update: dsh plugin --profile web update @nicearrack/dsh-translator
npm metadata may lag right after a publish — pin 0.2.0 if @latest still resolves to an older version; restart the DSH instance (dsh --profile web) after updating.
Full Changelog: v0.1.1...v0.2.0
dsh-translator v0.1.1
dsh-translator v0.1.1
拖拽与置顶的译文卡片,让长对话里的翻译更顺手:卡片可随意拖动、可置顶锁定;流式输出期间不再抖动或被误关,页面滚动也不会把它挤走。
Features
- 可拖拽卡片 — 拖动卡片头部即可移动,松手后停在哪就留在哪
- 可置顶卡片 — 置顶后锁定拖拽、Esc 与点击空白关闭(仅关闭按钮有效);一次仅一张卡片,杜绝层叠嵌套
- 流式稳定 — 输出期间按钮与卡片不再闪烁或消失,内容滚动时卡片保持原位
- 向量图标 — 卡片底部右侧新增空心/实心置顶引脚与配套 X 关闭图标,对齐紧凑
- 交互细节 — 悬浮「译」按钮仅在划选结束(mouseup)后出现;滚动不再关闭卡片;卡片打开时隐藏按钮(一次性触发),选区仍存活时关闭卡片后按钮重新出现
Docs
dsh-translator v0.1.0
dsh-translator v0.1.0
有道风格划词翻译插件:在 DSH Web GUI 中划选任意文本,选区右上角浮现悬浮「译」按钮,点击即出译文卡片。翻译由 harness 自带大模型完成——零 API key、不依赖第三方接口,选中文本不离开你已配置的模型管道。
Features
- 任意位置划词(消息/侧栏/输入框/文本域),悬浮按钮跟随选区,适配明暗主题
- 中英方向自动判断(中文 → English,其余 → 简体中文)
- 译文卡片:原文、方向徽标、译文、失败重试;Esc / 点击空白 / 滚动关闭
- harness 原生模型翻译(
ctx.llm.stream):30s 超时、max-tokens 截断提示、在途请求取消、并发/竞态防护 - 打包形态:
dsh.bundle+dsh.client,支持 npm / 本地 / git 三种安装(dsh plugin add)