Skip to content

Commit 4dcfa3e

Browse files
committed
fix(code-tools): qwen code auth type incorrect
- fixed #13473
1 parent dcb890f commit 4dcfa3e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/main/services/CodeToolsService.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ class CodeToolsService {
8080
return bunPath
8181
}
8282

83+
/**
84+
* Compare two semantic versions
85+
* @param version1 - First version string (e.g., "1.2.3")
86+
* @param version2 - Second version string (e.g., "1.2.4")
87+
* @returns -1 if version1 < version2, 0 if equal, 1 if version1 > version2
88+
*/
89+
private compareVersions(version1: string, version2: string): number {
90+
const v1Parts = version1.split('.').map(Number)
91+
const v2Parts = version2.split('.').map(Number)
92+
const maxLength = Math.max(v1Parts.length, v2Parts.length)
93+
94+
for (let i = 0; i < maxLength; i++) {
95+
const v1Part = v1Parts[i] || 0
96+
const v2Part = v2Parts[i] || 0
97+
if (v1Part < v2Part) return -1
98+
if (v1Part > v2Part) return 1
99+
}
100+
return 0
101+
}
102+
83103
public async getPackageName(cliTool: string) {
84104
switch (cliTool) {
85105
case codeTools.claudeCode:
@@ -836,10 +856,12 @@ class CodeToolsService {
836856

837857
// Check for updates and auto-update if requested
838858
let updateMessage = ''
859+
let installedVersion: string | null = null
839860
if (isInstalled && options.autoUpdateToLatest) {
840861
logger.info(`Auto update to latest enabled for ${cliTool}`)
841862
try {
842863
const versionInfo = await this.getVersionInfo(cliTool)
864+
installedVersion = versionInfo.installed
843865
if (versionInfo.needsUpdate) {
844866
logger.info(`Update available for ${cliTool}: ${versionInfo.installed} -> ${versionInfo.latest}`)
845867
logger.info(`Auto-updating ${cliTool} to latest version`)
@@ -913,6 +935,18 @@ class CodeToolsService {
913935
baseCommand = `${uvPath} tool run ${packageName}`
914936
}
915937

938+
// Special handling for qwen-code: add --auth-type openai for version >= 0.12.3
939+
if (cliTool === codeTools.qwenCode) {
940+
// Check if installed version is >= 0.12.3
941+
const needsAuthType = installedVersion && this.compareVersions(installedVersion, '0.12.3') >= 0
942+
if (needsAuthType) {
943+
baseCommand = `${baseCommand} --auth-type openai`
944+
logger.info(`qwen-code version ${installedVersion} >= 0.12.3, using --auth-type openai`)
945+
} else {
946+
logger.info(`qwen-code version ${installedVersion || 'unknown'} < 0.12.3, not using --auth-type`)
947+
}
948+
}
949+
916950
// Add configuration parameters for OpenAI Codex using command line args
917951
if (cliTool === codeTools.openaiCodex && env.OPENAI_MODEL_PROVIDER) {
918952
const providerId = env.OPENAI_MODEL_PROVIDER

0 commit comments

Comments
 (0)