Skip to content

feat(v0.2.1): oauth subscription providers, fairness fixes, test coverage#107

Merged
carlosatta merged 4 commits into
developfrom
feat/passthrough-proxy-issue-100
Jun 14, 2026
Merged

feat(v0.2.1): oauth subscription providers, fairness fixes, test coverage#107
carlosatta merged 4 commits into
developfrom
feat/passthrough-proxy-issue-100

Conversation

@carlosatta

Copy link
Copy Markdown
Contributor

Summary

  • OAuth subscription support: anthropic-oauth (Claude Pro/Max via sk-ant-oat… token) and openai-oauth (ChatGPT Plus/Pro via Codex ~/.codex/auth.json token) — both routes forward requests verbatim to the upstream, swapping only the credential
  • Fairness policy bug fixes (3 bugs): cross-project usage contamination, stable-sort tie-breaking always picking the first model, OAuth models invisible to fairness because trackUsage was never called in the passthrough paths
  • Comprehensive unit test coverage: 50 test files, 1077 tests across service and dashboard packages

What changed

New providers

  • anthropic-oauth: verbatim forward with sk-ant-oat… token + required Anthropic OAuth headers
  • openai-oauth: reads/auto-refreshes Codex token, translates chat/completions to ChatGPT Responses API SSE

Fairness routing fixes

  • fairness.ts: added projectId filter — only records from the current project count
  • router.ts: Math.random() fallback when all policies abstain, replacing the static 0.5 that always picked model[0]
  • oauthForward.ts, openaiOAuthForward.ts: trackUsage called on all exit paths so OAuth models appear in usage records

Dashboard & CLI

  • ModelFormPage: subscription provider UI with instructions callout and token/path input
  • model.ts: --provider help text updated with anthropic-oauth and openai-oauth

Docs & website

  • New guides: docs/guides/claude-subscription.md, docs/guides/openai-subscription.md
  • v0.2.0 versioned docs snapshot

Test plan

  • npm test --workspace=packages/service — 1077 tests, all green
  • npm run typecheck --workspace=packages/service — clean
  • CI Build & Typecheck must pass
  • Manual verification of OAuth passthrough with real Claude Max / ChatGPT Plus tokens

🤖 Generated with Claude Code

carlosatta and others added 4 commits June 13, 2026 16:38
…endpoints (#100)

Any path Routerly does not explicitly handle is now forwarded to the
project's upstream provider with only the API key swapped, making
Routerly a true drop-in replacement for OpenAI, Anthropic, Ollama and
custom providers — today and for any future endpoints they add.

- Extract `resolveProjectByToken()` helper from auth plugin (shared by
  the proxy handler so auth is never bypassed)
- Add `passthrough.ts`: pure helpers (`pickUpstreamModel`,
  `buildUpstreamUrl`, `buildUpstreamHeaders`) + `passthroughHandler`
  registered as Fastify's global setNotFoundHandler
- Register a `*` content-type parser in server.ts to capture non-JSON
  bodies as raw Buffer for verbatim forwarding
- Upstream selection: body `model` field matched to project models,
  else first configured model; Anthropic uses x-api-key, all others
  Bearer — no config required
- Reserved namespaces (`/`, `/health`, `/api/*`, `/dashboard*`) are
  guarded inside the handler and never proxied
- 22 new tests covering all helpers and handler scenarios; existing
  server telemetry test updated to include the new mock stubs

Closes #100

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…pic-oauth and openai-oauth

- Add anthropic-oauth provider: forwards requests verbatim with stored sk-ant-oat… token,
  adds required oauth-2025-04-20 beta header and dangerous-direct-browser-access header
- Add openai-oauth provider: reads Codex token from ~/.codex/auth.json, auto-refreshes
  on expiry, translates chat/completions to ChatGPT Responses API SSE format
- Register both providers in the adapter map and shared providers.json (priced at $0)
- Update anthropic.ts and openai.ts routes with early bypass branches
- Add POST /api/test/openai-oauth management endpoint to verify Codex token
- Update dashboard ModelFormPage with subscription provider UI (instructions, token input)
- Add user-facing guides for Claude and OpenAI subscription setup
- Snapshot versioned docs for v0.2.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three bugs fixed in the fairness routing policy:
- Cross-project contamination: fairness was reading usage records from all projects;
  added projectId filter so only records from the current project are counted
- Stable-sort tie-breaking: when all policies abstained every candidate got 0.5,
  causing the first model in config to always win; replaced with Math.random() so
  traffic distributes uniformly over time
- OAuth models invisible to fairness: forwardOpenAIOAuthSSE and forwardAnthropicOAuth
  never called trackUsage, so openai-oauth and anthropic-oauth always scored 1.0 and
  won every routing decision; trackUsage is now called on all exit paths (0 tokens,
  outcome success/error) in both forward functions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@carlosatta
carlosatta merged commit 952849f into develop Jun 14, 2026
2 checks passed
@carlosatta
carlosatta deleted the feat/passthrough-proxy-issue-100 branch June 14, 2026 12:39
@carlosatta carlosatta added the release/0.3.0 Included in release 0.3.0 label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/0.3.0 Included in release 0.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant