Skip to content

Split translation providers into six presets; fix popup version - #8

Merged
ycosine merged 1 commit into
mainfrom
agent/provider-presets
Jul 16, 2026
Merged

Split translation providers into six presets; fix popup version#8
ycosine merged 1 commit into
mainfrom
agent/provider-presets

Conversation

@ycosine

@ycosine ycosine commented Jul 16, 2026

Copy link
Copy Markdown
Owner

What changed

The provider picker now offers six providers instead of three:

Provider Kind Required config Default model
Google free endpoint
DeepL REST API key
Anthropic (new) native Claude Messages API via @anthropic-ai/sdk API key claude-opus-4-8 (editable)
DeepSeek (new) chat-completions, pinned to api.deepseek.com API key deepseek-chat (editable)
OpenAI (new) chat-completions, pinned to api.openai.com/v1 API key gpt-4o-mini (editable)
Custom any OpenAI-compatible endpoint base URL + model + key

Anthropic provider

  • Built on the official @anthropic-ai/sdk (browser mode in the MV3 service worker; host permission scopes the origin)
  • Streams via the Messages API SSE and feeds the existing TR_TRANSLATE_PARTIAL pipeline, so Claude subtitle translations render token-by-token like DeepSeek
  • No temperature sent (removed on Opus 4.7+ — would 400); typed SDK error classes mapped to the existing TranslationError codes; refusal stop reason surfaced as an error instead of an empty translation
  • Validation uses the free count_tokens endpoint (checks both key and model id)
  • Default model is claude-opus-4-8; for faster/cheaper subtitle translation users can set claude-haiku-4-5 in the model field

DeepSeek / OpenAI presets

  • Implemented as configurations of the existing chat-completions core (streaming, JSON fallback, retry/backoff all inherited)
  • Base URL is pinned by the preset and no longer part of the credential form; model is prefilled and editable
  • Existing users on "OpenAI-compatible" (now labeled Custom) keep working unchanged — same stored id, same credentials

Misc

  • Popup readiness/summary logic understands fixed-endpoint presets (key-only = ready)
  • New glyphs for Anthropic / DeepSeek / Custom in popup and options
  • Host permissions: api.anthropic.com, api.deepseek.com, api.openai.com
  • Popup version fix: header showed a hardcoded v0.1; it now reads chrome.runtime.getManifest().version

Validation

  • pnpm type-check, pnpm lint, content-script tests (25), pnpm build all green; built manifest carries the new host permissions and the popup bundle no longer contains the hardcoded version
  • Mock-fetch harness: DeepSeek requests hit the pinned URL with the default model (and honor a model override); Anthropic provider exercised through the real SDK against a mocked Messages API for both non-streaming and SSE streaming paths (partials + final text correct, no temperature in the request body)
  • Not yet run against live Anthropic/DeepSeek/OpenAI keys — worth a smoke test of the Options "Test" button per provider before release

🤖 Generated with Claude Code

- add a native Anthropic provider built on @anthropic-ai/sdk: Claude
  Messages API with SSE streaming into the existing TR_TRANSLATE_PARTIAL
  pipeline, typed error mapping, and free count-tokens validation;
  default model claude-opus-4-8, editable in Options
- flatten DeepSeek and OpenAI out of the generic OpenAI-compatible
  provider into first-class presets with pinned base URLs and default
  models (deepseek-chat / gpt-4o-mini) — only an API key is required;
  the generic provider remains as "Custom" for any compatible endpoint
- provider picker now offers Google, DeepL, Anthropic, DeepSeek,
  OpenAI, and Custom, each with its own glyph; popup readiness/summary
  logic understands the fixed-endpoint presets
- add api.anthropic.com / api.deepseek.com / api.openai.com host
  permissions
- popup header version was hardcoded as v0.1 — now reads
  chrome.runtime.getManifest().version

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ycosine
ycosine merged commit 972696d into main Jul 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant