opencode-qwen-oauth 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,14 +15,15 @@ Qwen OAuth authentication plugin for [OpenCode](https://opencode.ai) - authentic
15
15
 
16
16
  - 🔐 **OAuth Device Flow** - PKCE-secured authentication, works in headless/CI environments
17
17
  - 🔄 **Automatic Token Refresh** - Tokens are refreshed before expiry
18
+ - 💾 **Persistent Credentials** - Tokens saved to `~/.qwen/oauth_creds.json` for persistence across sessions
18
19
  - 🌐 **Auto Browser Open** - Automatically opens browser for authentication
19
20
  - 📝 **File Logging** - All OAuth activity logged to `~/.config/opencode/logs/qwen-oauth.log`
20
- - 🐛 **Debug Mode** - Enable verbose output with `QWEN_OAUTH_DEBUG=true`
21
21
  - 🚀 **Easy Install** - One-command installation with CLI tool
22
- - 🎯 **Custom Headers** - Automatically adds Qwen-specific headers to API requests
22
+ - 🎯 **Custom Headers** - Automatically adds Qwen-specific headers (X-DashScope-*) to API requests
23
23
  - ⚙️ **Optimized Parameters** - Pre-configured temperature and topP settings for Qwen models
24
24
  - 🌍 **Environment Variables** - Exposes Qwen credentials to shell environments
25
25
  - 📊 **Event Monitoring** - Tracks authentication and session events for debugging
26
+ - ⏱️ **Request Throttling** - Built-in rate limiting to avoid 429 errors
26
27
 
27
28
  ## Quick Start
28
29
 
@@ -58,15 +59,15 @@ Select **"Qwen Code (qwen.ai OAuth)"** and follow the device flow instructions.
58
59
  ### Use Qwen Models
59
60
 
60
61
  ```
61
- /model qwen/qwen3-coder-plus
62
+ /model qwen/coder-model
62
63
  ```
63
64
 
64
65
  ## Models
65
66
 
66
- | Model | Context | Features |
67
- |-------|---------|----------|
68
- | `qwen3-coder-plus` | 1M tokens | Optimized for coding |
69
- | `qwen3-vl-plus` | 256K tokens | Vision + language |
67
+ | Model | Context | Output | Features |
68
+ |-------|---------|--------|----------|
69
+ | `coder-model` | 1M tokens | 64K | Optimized for coding |
70
+ | `vision-model` | 128K tokens | 32K | Vision + language |
70
71
 
71
72
  ## Configuration
72
73
 
@@ -106,13 +107,17 @@ If you prefer manual setup, add to `.opencode/opencode.json`:
106
107
  "baseURL": "https://portal.qwen.ai/v1"
107
108
  },
108
109
  "models": {
109
- "qwen3-coder-plus": {
110
- "id": "qwen3-coder-plus",
111
- "name": "Qwen3 Coder Plus"
110
+ "coder-model": {
111
+ "id": "coder-model",
112
+ "name": "Qwen Coder",
113
+ "limit": { "context": 1048576, "output": 65536 },
114
+ "modalities": { "input": ["text"], "output": ["text"] }
112
115
  },
113
- "qwen3-vl-plus": {
114
- "id": "qwen3-vl-plus",
115
- "name": "Qwen3 VL Plus",
116
+ "vision-model": {
117
+ "id": "vision-model",
118
+ "name": "Qwen Vision",
119
+ "limit": { "context": 131072, "output": 32768 },
120
+ "modalities": { "input": ["text", "image"], "output": ["text"] },
116
121
  "attachment": true
117
122
  }
118
123
  }
@@ -196,6 +201,14 @@ sudo dnf install xdg-utils
196
201
  sudo pacman -S xdg-utils
197
202
  ```
198
203
 
204
+ ### Credentials File
205
+ Credentials are saved to `~/.qwen/oauth_creds.json` (compatible with qwen-code CLI):
206
+ ```
207
+ ~/.qwen/oauth_creds.json
208
+ ```
209
+
210
+ This allows sharing authentication between OpenCode plugin and qwen-code CLI.
211
+
199
212
  ### Check logs
200
213
  ```bash
201
214
  cat ~/.config/opencode/logs/qwen-oauth.log
@@ -216,7 +229,7 @@ This plugin implements OAuth 2.0 Device Flow (RFC 8628) with PKCE:
216
229
  ### Security Features
217
230
  - ✅ Uses PKCE (RFC 7636) for enhanced security
218
231
  - ✅ No client secret required (safer for public clients)
219
- - ✅ Tokens stored in OpenCode's secure auth storage
232
+ - ✅ Tokens stored in OpenCode's auth system and `~/.qwen/oauth_creds.json` for persistence
220
233
  - ✅ All OAuth activity logged for auditing
221
234
  - ✅ Sensitive data sanitized in logs
222
235
 
@@ -274,8 +287,10 @@ Monitors session events (creation, errors) for debugging and logging.
274
287
 
275
288
  #### `chat.headers` Hook
276
289
  Injects custom headers for Qwen API requests:
277
- - `X-Qwen-Client: OpenCode`
278
- - `X-Qwen-Plugin-Version: 1.1.0`
290
+ - `User-Agent: QwenCode/0.10.3 (platform)`
291
+ - `X-DashScope-CacheControl: enable`
292
+ - `X-DashScope-UserAgent: QwenCode/0.10.3 (platform)`
293
+ - `X-DashScope-AuthType: qwen-oauth`
279
294
 
280
295
  #### `chat.params` Hook
281
296
  Optimizes model parameters for Qwen:
@@ -294,9 +309,12 @@ opencode-qwen-oauth/
294
309
  ├── src/ # TypeScript source files
295
310
  │ ├── index.ts # Main plugin with hooks
296
311
  │ ├── oauth.ts # OAuth device flow logic
312
+ │ ├── credentials.ts # Credential storage (~/.qwen/)
297
313
  │ ├── pkce.ts # PKCE implementation
298
314
  │ ├── browser.ts # Browser opening utility
299
315
  │ ├── logger.ts # Logging utilities
316
+ │ ├── request-queue.ts # Rate limiting
317
+ │ ├── diagnostic.ts # Diagnostics CLI
300
318
  │ └── constants.ts # API constants
301
319
  ├── bin/ # CLI scripts
302
320
  │ └── install.js # Installer script
package/bin/install.js CHANGED
@@ -148,7 +148,7 @@ function install() {
148
148
 
149
149
  opencodePackage.dependencies = opencodePackage.dependencies || {};
150
150
  if (!opencodePackage.dependencies["opencode-qwen-oauth"]) {
151
- opencodePackage.dependencies["opencode-qwen-oauth"] = "^2.3.0";
151
+ opencodePackage.dependencies["opencode-qwen-oauth"] = "^2.3.1";
152
152
  log("Added 'opencode-qwen-oauth' to .opencode/package.json dependencies");
153
153
  }
154
154
 
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- const PLUGIN_VERSION = "2.3.0";
8
+ const PLUGIN_VERSION = "2.3.1";
9
9
  const QWEN_CODE_VERSION = "0.10.3";
10
10
  const TOKEN_CACHE_DURATION = 5 * 60 * 1000;
11
11
  const REFRESH_BEFORE_EXPIRY_MS = 5 * 60 * 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-qwen-oauth",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Qwen OAuth authentication plugin for OpenCode - authenticate with Qwen.ai using OAuth device flow",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",