opencode-qwen-cli-auth 1.0.4 → 2.0.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 +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -13
- package/dist/lib/constants.d.ts +2 -2
- package/dist/lib/constants.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Add the plugin to your OpenCode config:
|
|
|
31
31
|
{
|
|
32
32
|
"$schema": "https://opencode.ai/config.json",
|
|
33
33
|
"plugin": ["opencode-qwen-cli-auth"],
|
|
34
|
-
"model": "
|
|
34
|
+
"model": "qwen-code/coder-model"
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -41,16 +41,16 @@ Then sign in:
|
|
|
41
41
|
opencode auth login
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Choose `
|
|
44
|
+
Choose `Qwen Code` -> `Qwen Code (qwen.ai OAuth)`.
|
|
45
45
|
|
|
46
46
|
## Usage
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
opencode run "create a hello world file" --model=
|
|
50
|
-
opencode chat --model=
|
|
49
|
+
opencode run "create a hello world file" --model=qwen-code/coder-model
|
|
50
|
+
opencode chat --model=qwen-code/coder-model
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
Always keep the provider prefix `
|
|
53
|
+
Always keep the provider prefix `qwen-code/` in model configuration.
|
|
54
54
|
|
|
55
55
|
## Configuration
|
|
56
56
|
|
|
@@ -120,7 +120,7 @@ The server is throttling requests. Reduce request frequency and retry later.
|
|
|
120
120
|
Ensure your model is set correctly in OpenCode:
|
|
121
121
|
|
|
122
122
|
```yaml
|
|
123
|
-
model:
|
|
123
|
+
model: qwen-code/coder-model
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
## Clear auth state
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @repository https://github.com/TVD-00/opencode-qwen-cli-auth
|
|
9
9
|
*/
|
|
10
10
|
import { createPKCE, requestDeviceCode, pollForToken, getApiBaseUrl, saveToken, refreshAccessToken, loadStoredToken } from "./lib/auth/auth.js";
|
|
11
|
-
import { PROVIDER_ID, AUTH_LABELS, DEVICE_FLOW } from "./lib/constants.js";
|
|
11
|
+
import { PROVIDER_ID, AUTH_LABELS, DEVICE_FLOW, DEFAULT_QWEN_BASE_URL } from "./lib/constants.js";
|
|
12
12
|
import { logError, logInfo, LOGGING_ENABLED } from "./lib/logger.js";
|
|
13
13
|
/**
|
|
14
14
|
* Lay access token hop le tu SDK auth state, refresh neu het han
|
|
@@ -70,7 +70,7 @@ function getBaseUrl() {
|
|
|
70
70
|
* ```json
|
|
71
71
|
* {
|
|
72
72
|
* "plugin": ["opencode-alibaba-qwen-cli-auth"],
|
|
73
|
-
* "model": "
|
|
73
|
+
* "model": "qwen-code/coder-model"
|
|
74
74
|
* }
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
@@ -80,23 +80,20 @@ export const QwenAuthPlugin = async (_input) => {
|
|
|
80
80
|
provider: PROVIDER_ID,
|
|
81
81
|
/**
|
|
82
82
|
* Loader: lay token + base URL, tra ve cho SDK
|
|
83
|
-
*
|
|
83
|
+
* Pattern giong plugin tham chieu opencode-qwencode-auth
|
|
84
84
|
*/
|
|
85
85
|
async loader(getAuth, provider) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
// Zero cost cho OAuth models (mien phi)
|
|
87
|
+
if (provider?.models) {
|
|
88
|
+
for (const model of Object.values(provider.models)) {
|
|
89
|
+
if (model) model.cost = { input: 0, output: 0 };
|
|
90
|
+
}
|
|
90
91
|
}
|
|
91
92
|
const accessToken = await getValidAccessToken(getAuth);
|
|
92
|
-
if (!accessToken)
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
const baseUrl = getBaseUrl();
|
|
96
|
-
// Tra ve apiKey + baseURL, SDK tu xu ly phan con lai
|
|
93
|
+
if (!accessToken) return null;
|
|
97
94
|
return {
|
|
98
95
|
apiKey: accessToken,
|
|
99
|
-
baseURL:
|
|
96
|
+
baseURL: DEFAULT_QWEN_BASE_URL,
|
|
100
97
|
};
|
|
101
98
|
},
|
|
102
99
|
methods: [
|
|
@@ -161,6 +158,38 @@ export const QwenAuthPlugin = async (_input) => {
|
|
|
161
158
|
},
|
|
162
159
|
],
|
|
163
160
|
},
|
|
161
|
+
/**
|
|
162
|
+
* Dang ky provider qwen-code voi danh sach model
|
|
163
|
+
* Chi dang ky model ma Portal API (OAuth) chap nhan:
|
|
164
|
+
* coder-model va vision-model (theo QWEN_OAUTH_ALLOWED_MODELS cua CLI goc)
|
|
165
|
+
*/
|
|
166
|
+
config: async (config) => {
|
|
167
|
+
const providers = config.provider || {};
|
|
168
|
+
providers[PROVIDER_ID] = {
|
|
169
|
+
npm: "@ai-sdk/openai-compatible",
|
|
170
|
+
name: "Qwen Code",
|
|
171
|
+
options: { baseURL: "https://portal.qwen.ai/v1" },
|
|
172
|
+
models: {
|
|
173
|
+
"coder-model": {
|
|
174
|
+
id: "coder-model",
|
|
175
|
+
name: "Qwen Coder (Qwen 3.5 Plus)",
|
|
176
|
+
reasoning: false,
|
|
177
|
+
limit: { context: 1048576, output: 65536 },
|
|
178
|
+
cost: { input: 0, output: 0 },
|
|
179
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
180
|
+
},
|
|
181
|
+
"vision-model": {
|
|
182
|
+
id: "vision-model",
|
|
183
|
+
name: "Qwen VL Plus (vision)",
|
|
184
|
+
reasoning: false,
|
|
185
|
+
limit: { context: 131072, output: 8192 },
|
|
186
|
+
cost: { input: 0, output: 0 },
|
|
187
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
config.provider = providers;
|
|
192
|
+
},
|
|
164
193
|
};
|
|
165
194
|
};
|
|
166
195
|
export default QwenAuthPlugin;
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/** Plugin identifier */
|
|
5
5
|
export declare const PLUGIN_NAME = "qwen-oauth-plugin";
|
|
6
|
-
/** Provider ID for opencode configuration (used in model references like
|
|
7
|
-
export declare const PROVIDER_ID = "
|
|
6
|
+
/** Provider ID for opencode configuration (used in model references like qwen-code/coder-model) */
|
|
7
|
+
export declare const PROVIDER_ID = "qwen-code";
|
|
8
8
|
/** Dummy API key (actual auth via OAuth) */
|
|
9
9
|
export declare const DUMMY_API_KEY = "qwen-oauth";
|
|
10
10
|
/**
|
package/dist/lib/constants.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/** Plugin identifier */
|
|
5
5
|
export const PLUGIN_NAME = "qwen-oauth-plugin";
|
|
6
|
-
/** Provider ID for opencode configuration (used in model references like
|
|
7
|
-
export const PROVIDER_ID = "
|
|
6
|
+
/** Provider ID for opencode configuration (used in model references like qwen-code/coder-model) */
|
|
7
|
+
export const PROVIDER_ID = "qwen-code";
|
|
8
8
|
/** Dummy API key (actual auth via OAuth) */
|
|
9
9
|
export const DUMMY_API_KEY = "qwen-oauth";
|
|
10
10
|
/**
|
|
@@ -85,7 +85,7 @@ export const PLATFORM_OPENERS = {
|
|
|
85
85
|
};
|
|
86
86
|
/** OAuth authorization labels */
|
|
87
87
|
export const AUTH_LABELS = {
|
|
88
|
-
OAUTH: "Qwen
|
|
88
|
+
OAUTH: "Qwen Code (qwen.ai OAuth)",
|
|
89
89
|
INSTRUCTIONS: "Visit the URL shown in your browser to complete authentication.",
|
|
90
90
|
};
|
|
91
91
|
/** OAuth verification URI parameters */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-qwen-cli-auth",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Qwen OAuth authentication plugin for opencode - use your Qwen account instead of API keys",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"type": "module",
|