npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-qwen-auth-plugin

v0.1.4

Published

OpenCode plugin for Qwen OAuth with robust retry, refresh, multi-account pooling, and compatibility policies

Readme

opencode-qwen-oauth

OpenCode plugin for Qwen OAuth with robust retry, refresh, multi-account pooling, and compatibility policies.

Install

Via NPM (Recommended)

npm install opencode-qwen-auth-plugin
# or
bun add opencode-qwen-auth-plugin
# or
pnpm add opencode-qwen-auth-plugin

Then add to your OpenCode config (~/.config/opencode/opencode.json):

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-qwen-auth-plugin@latest"]
}

Run opencode auth login and select the Qwen OAuth option.

From Source

git clone https://github.com/Qiiks/opencode-qwen-oauth.git
cd opencode-qwen-oauth/opencode-qwen-oauth
npm install
npm run build

Add to your opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["./path/to/opencode-qwen-oauth/dist/index.js"]
}

Features

  • Qwen OAuth with device flow + PKCE authentication
  • Multi-account pooling with weighted rotation and automatic cooldown on 429/529
  • Smart retry with class-based idempotency (A/B/C), retry budget, full-jitter backoff, and circuit breaker
  • Model discovery with local cache (TTL + stale fallback)
  • Quota probing surfaced during OAuth login flow
  • Compatibility enforcement against OpenCode version matrix
  • Structured logging with secret redaction

Key Defaults

  • Retry attempts: A=4, B=3 (requires idempotency key), C=1
  • Retry budget: capacity=120, refill 2 tokens/sec
  • Circuit breaker: open at 10 failures within 30s, cooldown 45s, 3 half-open probes
  • Backoff: full jitter, base 250ms, floor 100ms, cap 5000ms
  • Scheduling mode: cache-first (wait for same account when Retry-After is short)
  • Token budget: per-account local budget with refill to avoid bursty 429 storms

Configuration

Environment Variables

  • QWEN_SCHEDULING_MODE=cache-first|balance
  • QWEN_MAX_CACHE_FIRST_WAIT_SECONDS=30
  • QWEN_TOKEN_BUDGET_PER_ACCOUNT=8
  • QWEN_TOKEN_REGEN_PER_MINUTE=2

JSON Config (Preferred)

Located next to opencode.json:

  • Linux/macOS: ~/.config/opencode/qwen-code-oauth.json
  • Windows: C:\Users\<you>\.config\opencode\qwen-code-oauth.json
  • Override: OPENCODE_CONFIG_DIR
{
  "schedulingMode": "cache-first",
  "maxCacheFirstWaitSeconds": 30,
  "tokenBudgetPerAccount": 8,
  "tokenRegenPerMinute": 2
}

Precedence: env vars > JSON config > built-in defaults.

Multi-Account Management

The plugin includes an interactive account manager:

  • Add accounts: Run opencode auth login → select Qwen OAuth → "Add account"
  • Manage accounts: Enable/disable or delete saved accounts
  • Check quotas: View quota status for all saved accounts

Token Storage

  • Native credential source checked first via QWEN_NATIVE_TOKEN_STORE_JSON bridge
  • Encrypted file fallback (disabled by default):
export QWEN_ENABLE_ENCRYPTED_FALLBACK=1
export QWEN_TOKEN_ENCRYPTION_KEY="your-strong-key-material"

Security

  • Do not commit token files
  • Use OS-protected paths and restricted permissions
  • Logs are redacted by default for bearer/auth token patterns

Development

npm install
npm run typecheck
npm test
npm run build

Limitations

  • Quota endpoint availability depends on upstream API exposure
  • Provider-side OAuth flow differences may require updates if upstream contracts change

Troubleshooting

| Error | Solution | |-------|----------| | E_AUTH_HEADLESS_UNSUPPORTED | Run initial OAuth in an interactive terminal | | E_STORAGE_BACKEND_UNAVAILABLE | Provide native token bridge or enable encrypted fallback | | E_COMPAT_VERSION_UNSUPPORTED | Check .omc/contracts/compatibility-matrix.json and pin OpenCode version | | Repeated 429/529 | Reduce concurrent load or add retryExecutor callback |

License

MIT