Skip to content

feat(observer): support Anthropic OAuth for Claude Max/Pro subscriptions#230

Merged
kunickiaj merged 1 commit into
mainfrom
03-15-feat_observer_support_anthropic_oauth_for_claude_max_pro_subscriptions
Mar 15, 2026
Merged

feat(observer): support Anthropic OAuth for Claude Max/Pro subscriptions#230
kunickiaj merged 1 commit into
mainfrom
03-15-feat_observer_support_anthropic_oauth_for_claude_max_pro_subscriptions

Conversation

@kunickiaj
Copy link
Copy Markdown
Owner

@kunickiaj kunickiaj commented Mar 15, 2026

Description

Add a direct API path for Anthropic OAuth tokens from OpenCode's auth cache, mirroring the existing Codex path for OpenAI subscriptions. When OpenCode has cached Anthropic OAuth credentials (Claude Max/Pro), the observer now hits api.anthropic.com/v1/messages with Bearer auth and the oauth-2025-04-20 beta header instead of requiring an API key or claude_sidecar runtime.

New module observer_anthropic.py with headers, payload builder, and SSE stream parser. URL composition uses urllib.parse for safe query parameter handling with custom endpoints.

Type of Change

  • 🚀 Feature (new functionality)

Testing

  • Tests pass locally (pytest)
  • Added/updated tests for changes
  • Manually verified changes work as expected

Checklist

  • Code follows project style (ruff check and ruff format pass)
  • Self-review completed
  • No new warnings introduced

Closes: codemem-gz9

Copy link
Copy Markdown
Owner Author

kunickiaj commented Mar 15, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a000341de1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codemem/observer.py Outdated
Add a direct API path for Anthropic OAuth tokens from OpenCode's auth cache,
mirroring the existing Codex path for OpenAI subscriptions. When OpenCode has
cached Anthropic OAuth credentials (Claude Max/Pro), the observer now hits
api.anthropic.com/v1/messages with Bearer auth and the oauth-2025-04-20 beta
header instead of requiring an API key or claude_sidecar runtime.

New module: observer_anthropic.py (headers, payload, SSE stream parser)
Updated: observer.py (detection, routing, consumer call method)
Closes: codemem-gz9
@kunickiaj kunickiaj force-pushed the 03-15-feat_observer_support_anthropic_oauth_for_claude_max_pro_subscriptions branch from a000341 to 6a2f81e Compare March 15, 2026 18:30
Copy link
Copy Markdown
Owner Author

kunickiaj commented Mar 15, 2026

Merge activity

  • Mar 15, 6:33 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 15, 6:33 PM UTC: @kunickiaj merged this pull request with Graphite.

@kunickiaj kunickiaj merged commit 09e42e7 into main Mar 15, 2026
8 checks passed
@kunickiaj kunickiaj deleted the 03-15-feat_observer_support_anthropic_oauth_for_claude_max_pro_subscriptions branch March 15, 2026 18:34
kunickiaj added a commit that referenced this pull request Mar 15, 2026
## Summary
- Add `/api/observer-status` GET endpoint returning the resolved observer runtime state (provider, model, auth method, token presence)
- Add `probe_available_credentials()` to check OpenCode OAuth cache and env vars for each provider
- Add `ObserverClient.get_status()` for introspecting the active observer's resolved auth path

## Type of Change
- [x] New feature

## Testing
- 9 new tests in `test_observer_status.py` covering credential probing (OAuth, env vars, expired tokens, both providers) and status reporting
- 768 tests pass

## Checklist
- [x] Tests added/updated
- [x] Lint clean
- [x] No secrets or private references

Closes: codemem-yny
Stack: 2/3 (depends on #230)
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