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 +34 -16
- package/bin/install.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
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/
|
|
62
|
+
/model qwen/coder-model
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
## Models
|
|
65
66
|
|
|
66
|
-
| Model | Context | Features |
|
|
67
|
-
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
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
|
-
"
|
|
110
|
-
"id": "
|
|
111
|
-
"name": "
|
|
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
|
-
"
|
|
114
|
-
"id": "
|
|
115
|
-
"name": "
|
|
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
|
|
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
|
-
- `
|
|
278
|
-
- `X-
|
|
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.
|
|
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
package/package.json
CHANGED