Skip to content

PLUGIN: Claude OAuth — complete subscription connection - #492

Open
sunrisegm wants to merge 3 commits into
leookun:mainfrom
sunrisegm:feat/claude-oauth-plugin
Open

sunrisegm wants to merge 3 commits into
leookun:mainfrom
sunrisegm:feat/claude-oauth-plugin

Conversation

@sunrisegm

@sunrisegm sunrisegm commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

Add a complete Claude subscription OAuth provider plugin, based on clean upstream commit 9a8fde2 with no unrelated local changes.

  • Browser authorization using host-owned state/PKCE validation and a localhost callback.
  • Profile lookup, host-owned private credential persistence, refresh-token rotation/coalescing, and one pre-output HTTP 401 retry.
  • Paginated upstream model discovery with capability metadata.
  • Anthropic Messages streaming with images, tool calls, ordered signed/redacted thinking replay, usage, cancellation, and strict truncated-stream handling.
  • Explicit account states for authorization failures and HTTP 429 cooldown.
  • Bundling, documentation, 32 unit tests, an actual sandboxed-worker integration test, and a dedicated Deno CI job pinned to the host runtime version.

Structure

.github/workflows/ci.yml          # Run Claude plugin checks on Deno 2.9.6
server/
├── plugins/build-in/claude-auth/ # OAuth, accounts, models, Messages adapter, tests, documentation
└── src/plugin/
    ├── builtin.rs               # Bundle the plugin in release builds
    └── worker.rs                # Exclude auxiliary fetches from model-call recording

The host change prevents an auxiliary OAuth refresh from claiming the model-call recorder and persisting token request/response bodies with detailed logging enabled. Only inference streams now claim that recorder; a Rust regression test covers this behavior. No frontend, database schema, or provider-independent history changes are included.

Verification completed locally

Linux, Rust 1.98.1, in isolated Docker build environments using this checkout:

  • cargo fmt --all -- --check: passed.
  • cargo clippy --locked --workspace --all-targets -- -D warnings: passed.
  • cargo test --locked --workspace --all-targets -- --test-threads=2: 306 passed, 0 failed. Includes 20 plugin-host tests and the credential-recording regression.
  • cargo build --locked --offline --workspace: passed, server and desktop debug binaries linked.

Deno 2.9.6, matching server/src/plugin/asset.rs:

  • Type check, lint, and formatting: passed.
  • Unit tests: 32 passed, 0 failed.
  • deno task test:host: 1 passed. Starts the actual SDK worker with host sandbox restrictions and drives OAuth completion, profile/model lookup, automatic refresh, streamed events, resource patches, and stream cleanup through the JSON protocol. Upstream responses are mocked.
  • Plugin descriptor loading under host sandbox flags: passed.

Frontend, Node 22.23.2:

  • npm run check: passed (both TypeScript checks and Vite production build; 1,849 modules transformed).
  • Existing dependencies were mounted read-only. A fresh npm ci was attempted but hit a registry download timeout; a fresh dependency install is therefore not verified.

Live Claude verification — 2026-09-30

A temporary, memory-only harness invoked the actual plugin modules with explicit browser consent:

  • Browser callback and state validation: passed.
  • Authorization-code exchange and profile lookup: passed.
  • Refresh-token rotation: passed.
  • Model discovery: 13 models returned.
  • A short streamed text request to claude-haiku-4-5-20251001: passed.

The requested scopes were user:profile user:inference. This live request succeeded without impersonating Claude Code, injecting an official-client system identity, or forging a CLI version. Tokens remained in process memory and were not written to files, Git, or the running application's profile.

Remaining coverage boundaries

  • Live testing covered one account and one model, not every returned model or account type.
  • Tool calling, thinking replay, rate-limit handling, and error paths were exercised with mocks, not live calls.
  • Full graphical desktop sign-in, persistence/restart recovery, macOS/Windows builds, and release installers were not tested locally.
  • Upstream GitHub Actions require maintainer approval for this fork PR; local results are not presented as completed hosted CI.

Status

The plugin is a complete Claude subscription connection: sign-in, token refresh, model discovery, and streamed inference. Anthropic's authentication policy still governs how subscription credentials may be used.

Use a build containing the host recording fix rather than installing this plugin into an unpatched release. See server/plugins/build-in/claude-auth/README.md for installation, lifecycle, storage/crash limitations, and protocol sources.

@sunrisegm
sunrisegm marked this pull request as ready for review September 30, 2026 19:03
Co-authored-by: Cursor <cursoragent@cursor.com>
@sunrisegm sunrisegm changed the title feat(plugins): add experimental Claude OAuth provider feat(plugins): add Claude OAuth provider Sep 30, 2026
@sunrisegm sunrisegm changed the title feat(plugins): add Claude OAuth provider Claude OAuth: complete subscription connection Sep 30, 2026
@sunrisegm sunrisegm changed the title Claude OAuth: complete subscription connection PLUGIN: Claude OAuth — complete subscription connection Sep 30, 2026
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