{"_id":"@beshkenadze/opencode-claude-auth","name":"@beshkenadze/opencode-claude-auth","dist-tags":{"latest":"0.7.3"},"versions":{"0.7.3":{"name":"@beshkenadze/opencode-claude-auth","version":"0.7.3","description":"OpenCode plugin that uses your Claude Code credentials — no separate login needed.","private":false,"preferGlobal":true,"main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","type":"module","packageManager":"bun@1.3.10","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./claude-auth-plugin":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./claude-auth-plugin.js":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc && cp src/anthropic-prompt.txt dist/","test":"node --test --experimental-strip-types src/**/*.test.ts","test:models":"bun run build && node scripts/test-models.ts","prepublishOnly":"bun run build && bun test"},"peerDependencies":{"@opencode-ai/plugin":"*"},"devDependencies":{"@opencode-ai/plugin":"latest","@types/node":"^25.5.0","typescript":"^5.0.0"},"keywords":["opencode","claude","anthropic","plugin","auth"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/beshkenadze/opencode-claude-auth.git"},"publishConfig":{"access":"public"},"gitHead":"463b8d640744f8d4f87e9dd51e6774c160571496","_id":"@beshkenadze/opencode-claude-auth@0.7.3","bugs":{"url":"https://github.com/beshkenadze/opencode-claude-auth/issues"},"homepage":"https://github.com/beshkenadze/opencode-claude-auth#readme","_nodeVersion":"25.8.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-3V2YbDmdXy4i/pZOB2GDV0CjHjkD/DmKh/sr4e/iBaEPAoH55cGX4r9xIk+vT9SskVtaTeGg7dg++vqbgQ+ESg==","shasum":"aef760a18fff21b4fe375ac020200a1428da354e","tarball":"https://registry.npmjs.org/@beshkenadze/opencode-claude-auth/-/opencode-claude-auth-0.7.3.tgz","fileCount":25,"unpackedSize":68355,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG18sqAYUl2/pC69mibfBsrMGAI37+R7ftf0xGwP4XJYAiEA7b6pr3grBVDc4+0KlpiAAW2rOyrwdERTtSUhoOGhA0Y="}]},"_npmUser":{"name":"beshkenadze","email":"beshkenadze@gmail.com"},"directories":{},"maintainers":[{"name":"beshkenadze","email":"beshkenadze@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/opencode-claude-auth_0.7.3_1774109516392_0.3325443092537055"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-21T16:11:56.268Z","0.7.3":"2026-03-21T16:11:56.576Z","modified":"2026-03-21T16:11:56.807Z"},"maintainers":[{"name":"beshkenadze","email":"beshkenadze@gmail.com"}],"description":"OpenCode plugin that uses your Claude Code credentials — no separate login needed.","homepage":"https://github.com/beshkenadze/opencode-claude-auth#readme","keywords":["opencode","claude","anthropic","plugin","auth"],"repository":{"type":"git","url":"git+https://github.com/beshkenadze/opencode-claude-auth.git"},"bugs":{"url":"https://github.com/beshkenadze/opencode-claude-auth/issues"},"license":"MIT","readme":"# opencode-claude-auth (personal fork)\n\n[![CI](https://github.com/beshkenadze/opencode-claude-auth/actions/workflows/ci.yml/badge.svg)](https://github.com/beshkenadze/opencode-claude-auth/actions/workflows/ci.yml)\n\nSelf-contained Anthropic auth provider for OpenCode using your Claude Code credentials — no separate login or API key needed.\n\n## How it works\n\nThe plugin registers its own auth provider with a custom fetch handler that intercepts all Anthropic API requests. It reads OAuth tokens from the macOS Keychain (or `~/.claude/.credentials.json` on other platforms), caches them in memory with a 30-second TTL, and handles the full request lifecycle — no builtin Anthropic auth plugin required.\n\nIt also syncs credentials to OpenCode's `auth.json` as a fallback (on Windows, it writes to both `%USERPROFILE%\\.local\\share\\opencode\\auth.json` and `%LOCALAPPDATA%\\opencode\\auth.json` to cover all installation methods). If a token is near expiry, it runs the Claude CLI to trigger a refresh. Background re-sync runs every 5 minutes.\n\n## Prerequisites\n\n- Claude Code installed and authenticated (run `claude` at least once)\n- OpenCode installed\n\nmacOS is preferred (uses Keychain). Linux and Windows work via the credentials file fallback.\n\n## Installation\n\n### Install with AI\n\nPaste this into your AI agent (Claude Code, Cursor, Copilot, etc.):\n\n```\nFetch https://raw.githubusercontent.com/beshkenadze/opencode-claude-auth/security-hardening/installation.md and follow every step exactly as written.\n```\n\n### Manual install\n\n```bash\nbun install -g \"github:beshkenadze/opencode-claude-auth#security-hardening\"\n```\n\nThen add to the `plugin` array in your `opencode.json`:\n\n```json\n{\n  \"plugin\": [\"@beshkenadze/opencode-claude-auth\"]\n}\n```\n\n## Usage\n\nJust run OpenCode. The plugin handles auth automatically — it reads your Claude Code credentials, provides them to the Anthropic API, and refreshes them in the background. If your credentials aren't OAuth-based, the plugin falls through to standard API key auth.\n\n## Supported models\n\n15 supported models. Run `bun run test:models` to verify against your account.\n\n| Model |\n|-------|\n| claude-3-haiku-20240307 |\n| claude-haiku-4-5 |\n| claude-haiku-4-5-20251001 |\n| claude-opus-4-0 |\n| claude-opus-4-1 |\n| claude-opus-4-1-20250805 |\n| claude-opus-4-20250514 |\n| claude-opus-4-5 |\n| claude-opus-4-5-20251101 |\n| claude-opus-4-6 |\n| claude-sonnet-4-0 |\n| claude-sonnet-4-20250514 |\n| claude-sonnet-4-5 |\n| claude-sonnet-4-5-20250929 |\n| claude-sonnet-4-6 |\n\n## Credential sources\n\nThe plugin checks these in order:\n\n1. macOS Keychain (\"Claude Code-credentials\" entry)\n2. `~/.claude/.credentials.json` (fallback, works on all platforms)\n\n## Troubleshooting\n\n| Problem | Solution |\n|---------|----------|\n| \"Credentials not found\" | Run `claude` to authenticate with Claude Code first |\n| \"Keychain is locked\" | Run `security unlock-keychain ~/Library/Keychains/login.keychain-db` |\n| \"Token expired and refresh failed\" | The plugin runs `claude` CLI to refresh automatically. If this fails, re-authenticate manually by running `claude` |\n| Not working on Linux/Windows | Ensure `~/.claude/.credentials.json` exists. Run `claude` to create it |\n| Keychain access denied | Grant access when macOS prompts you |\n| Keychain read timed out | Restart Keychain Access (can happen on macOS Tahoe) |\n| \"Credentials are unavailable or expired\" | Run `claude` to refresh your Claude Code credentials |\n\n## Environment variable overrides\n\nAll configurable parameters can be overridden via environment variables. If Anthropic changes something before we publish an update, set an env var and keep working:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `ANTHROPIC_CLI_VERSION` | Claude CLI version for user-agent and billing headers | `2.1.80` |\n| `ANTHROPIC_USER_AGENT` | Full User-Agent string (overrides CLI version) | `claude-cli/{version} (external, cli)` |\n| `ANTHROPIC_BETA_FLAGS` | Comma-separated beta feature flags | `claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,prompt-caching-scope-2026-01-05` |\n\nExample:\n\n```bash\nexport ANTHROPIC_CLI_VERSION=2.2.0\n```\n\n## How it works (technical)\n\n- Registers an `auth.loader` with a custom `fetch` that intercepts all Anthropic API requests\n- Sets `Authorization: Bearer` with fresh OAuth tokens (cached in memory, 30s TTL)\n- Translates tool names between OpenCode and Anthropic API formats (adds/strips `mcp_` prefix)\n- Buffers SSE response streams at event boundaries for reliable tool name translation\n- Injects Claude Code identity into system prompts via `experimental.chat.system.transform`\n- Sets required API headers (beta flags, billing, user-agent) with model-aware selection\n- Syncs credentials to `auth.json` on startup and every 5 minutes as a fallback\n- On Windows, writes to both `%USERPROFILE%\\.local\\share\\opencode\\auth.json` and `%LOCALAPPDATA%\\opencode\\auth.json`\n- Retries API requests on 429 (rate limit) and 529 (overloaded) with exponential backoff, respecting `retry-after` headers\n- When a token is within 60 seconds of expiry, runs `claude` CLI to trigger a refresh (with one automatic retry)\n- If credentials aren't OAuth-based, the auth loader returns `{}` and falls through to API key auth\n- If credentials are unavailable or unreadable, the plugin disables itself and OpenCode continues without Claude auth\n\n## Disclaimer\n\nThis plugin uses Claude Code's OAuth credentials to authenticate with Anthropic's API. Anthropic's Terms of Service state that Claude Pro/Max subscription tokens should only be used with official Anthropic clients. This plugin exists as a community workaround and may stop working if Anthropic changes their OAuth infrastructure. Use at your own discretion.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-6c8705c389e98195cf1d89ca715b4d22"}