opencode-qwen-cli-auth 2.0.0 → 2.1.0
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/dist/index.js +24 -13
- package/package.json +1 -1
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
|
|
@@ -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: [
|
|
@@ -176,7 +173,7 @@ export const QwenAuthPlugin = async (_input) => {
|
|
|
176
173
|
"coder-model": {
|
|
177
174
|
id: "coder-model",
|
|
178
175
|
name: "Qwen Coder (Qwen 3.5 Plus)",
|
|
179
|
-
reasoning:
|
|
176
|
+
reasoning: true,
|
|
180
177
|
limit: { context: 1048576, output: 65536 },
|
|
181
178
|
cost: { input: 0, output: 0 },
|
|
182
179
|
modalities: { input: ["text"], output: ["text"] },
|
|
@@ -193,6 +190,20 @@ export const QwenAuthPlugin = async (_input) => {
|
|
|
193
190
|
};
|
|
194
191
|
config.provider = providers;
|
|
195
192
|
},
|
|
193
|
+
/**
|
|
194
|
+
* Gui header DashScope giong CLI goc
|
|
195
|
+
* X-DashScope-CacheControl: enable prompt caching, giam token tieu thu
|
|
196
|
+
* X-DashScope-AuthType: xac dinh auth method cho server
|
|
197
|
+
*/
|
|
198
|
+
"chat.headers": async (_input, output) => {
|
|
199
|
+
try {
|
|
200
|
+
if (output?.headers) {
|
|
201
|
+
output.headers["X-DashScope-CacheControl"] = "enable";
|
|
202
|
+
output.headers["X-DashScope-AuthType"] = "qwen-oauth";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (_) { /* khong de loi hook lam treo request */ }
|
|
206
|
+
},
|
|
196
207
|
};
|
|
197
208
|
};
|
|
198
209
|
export default QwenAuthPlugin;
|
package/package.json
CHANGED