[translator] Add Anthropic, Gemini and OpenRouter completion helpers (no vendor dependencies)
メンテナーはふだん 1 日以内に返信
@SearheiParkhamchuk がすでに取り組んでいます。
2026年8月25日 から。
評価
この issue はまだ評価されていません。
説明
Summary
Ship a completion helper per vendor — anthropicComplete, geminiComplete, openRouterComplete
— alongside the existing openAIComplete. Each knows how to call its service and carries no
dependency on that service's SDK: the consumer constructs the client, the helper builds the request.
Cover Anthropic, Google Gemini and OpenRouter as documented recipes built on
createTranslationProvider({ complete }) — not as built-in adapters shipping optional SDKs.
Revision history — read this before re-litigating the shape
Revision 1 (original). Three adapters under src/translation-providers/, each with its own
optionalDependency and lazy loader, mirroring what createOpenAIProvider did.
This issue was rewritten on 2026-08-28. It previously asked for three adapters under
src/translation-providers/, each with its own optionalDependency and lazy loader. That premise
died with the decision in #101 to deprecate the built-in OpenAI adapter and remove it in the next
major (docs/DEPRECATIONS.md#built-in-openai-adapter). Shipping three more of the thing we are
removing would have been the package arguing with itself.
Revision 2 (2026-08-28, superseded within the day). Documentation only — three README recipes, no
package code. Written while #101 looked like it was deprecating the whole OpenAI adapter.
Revision 3 (2026-08-28, current). #101 landed with a narrower boundary
(docs/DEPRECATIONS.md#openai-client-construction): what is deprecated is the layer that builds the
SDK client and carries openai as an optional dependency. openAIComplete stays and is public —
the request body, the structured-output envelope choice, reading the reply and turning a schema
rejection into advice all cost no dependency. So the OpenAI answer is neither an adapter nor a recipe;
it is a vendor helper with no vendor dependency, and the other three should match it.
Why this shape
The expensive part of an adapter was never knowing how to call a service. It was carrying that
service's SDK as an optional dependency of ours — a lazy import shaped around deployment
file-tracers that resolve import() statically, plus a classifier telling "not installed" from
"installed but broken" across four runtimes' wordings. All of that exists so a package the consumer
may not have can be absent safely.
A completion helper skips the whole problem: it takes a client the consumer already constructed, so
there is nothing to load, nothing to guard, and no entry in optionalDependencies. The knowledge
stays with us, where one fix serves everyone; the dependency stays with them, where the version is
theirs.
No new package code is planned. If writing the three recipes surfaces something genuinely shared
— the same helper needed by all three and by the OpenAI recipe — that is a finding worth raising,
but it does not get built speculatively: the package's own rule is no abstraction without at least
two real callers already in the codebase, and a recipe in the README is not a caller.
Proposed change
One helper per vendor, following openAIComplete's shape: a CompletionFn factory taking a client
and a model, returning the function createTranslationProvider({ complete }) wants. Where the vendors
genuinely diverge is structured output, and that is what each helper has to get right:
- Anthropic — the Messages API has no
json_objectmode. Use a tool-shaped schema so the reply is
a validated object rather than prose. - Google Gemini —
responseMimeType: "application/json"plus an explicit response schema. The
OpenAI-compatible endpoint exists but lags on schema support; use the native shape. - OpenRouter — the OpenAI wire format with a different
baseURL, so this one may be a thin
configuration ofopenAICompleterather than a helper of its own — decide once the other two are
written.modelhas no sensible default. Structured-output support varies per upstream model, so
the helper must make thejson_objectfallback easy and say plainly that key-set validation is then
the guarantee. The optionalHTTP-Referer/X-Titleattribution headers belong in its options.
Each client type is a decision, not a default. openAIComplete takes OpenAIClientShape — a
hand-written structural slice of the SDK client, so a real new OpenAI() satisfies it unwrapped. That
pattern is sound as a convenience but must not be copied by reflex; see the analysis in
docs/plans/2026-08-28-provider-review-findings.md ("Is imitating a vendor's interface a sound
pattern?"). The test to apply per vendor: does a real client satisfy the slice without the consumer
constructing anything? If yes, mirror the OpenAI approach. If no, the helper takes an input in our
own vocabulary instead.
Acceptance criteria
-
anthropicCompleteandgeminiCompleteare exported from the package root with@sinceJSDoc
and a README note; OpenRouter either gets its own or is documented as a configuration of
openAIComplete, whichever the investigation shows. - No new runtime dependency and no new
optionalDependenciesentry. This is the criterion the
whole shape exists to satisfy. - Each helper names its structured-output approach and what key preservation rests on: the API
when a schema is enforced, this package's key-set validation when it is not. - The client type of each helper is justified against the test above, and the justification is
recorded — not just chosen. - Unit tests per helper against a stub client: happy path, key-set mismatch, unparseable reply,
and the vendor's own schema-rejection wording mapped to a useful message. - A README recipe per vendor showing client construction plus the helper, in the three-line shape
openAICompletenow uses. - A comparison table saying which vendor can prevent a dropped key and which can only have it
detected. - The "Pluggable providers" line stops implying OpenAI is special.
- [ ] README carries a recipe for each of Anthropic, Gemini and OpenRouter, each a complete,
copy-paste createTranslationProvider({ complete }) call.
- [ ] The recipes type-check, not just read well — a compile-only fixture per vendor.
(Superseded: with a helper per vendor the recipes are three lines and the helpers carry their own
tests, so a separate compile-only fixture buys nothing.)
Notes
The three helpers are independent and can land separately.
Depends on #101 (the layering, and the narrowed OpenAI deprecation) landing first.
Part of #98 — that epic's framing needs the same correction.
- 主要言語
- TypeScript
- スター
- 34
- フォーク
- 5
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 41
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
focusreactive/payload-plugins のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
focusreactive/payload-plugins#279 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
focusreactive/payload-plugins#263 ·
メンテナーはふだん 1 日以内に返信
-
comments, seo, analytics, and presets publish ESM that fails to load in Node.js (follow-up to #149)オープン
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
focusreactive/payload-plugins#240 ·
メンテナーはふだん 1 日以内に返信
-
released released on @next
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
focusreactive/payload-plugins#210 · コメント 10 件 ·
メンテナーはふだん 1 日以内に返信
-
[translator] Re-extract the traversal engine into its own package再び着手できるかも @SearheiParkhamchuk が 41 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンchore low priority translator
focusreactive/payload-plugins#203 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
focusreactive/payload-plugins の issue をすべて見る
似ている issue
-
verified whatsapp
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
openidconnect: option to use client_secret_post (client_id with "-" rejected by LemonLDAP::NG 2.21)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
MTES-MCT/monitorenv#3257 ·
メンテナーはふだん 1 日以内に返信