()
| 64 | } |
| 65 | |
| 66 | private ensureClient(): OpenAI { |
| 67 | if (!this.client) { |
| 68 | // Create the client instance with dummy key initially |
| 69 | // The API key will be updated dynamically via ensureAuthenticated |
| 70 | this.client = new OpenAI({ |
| 71 | apiKey: "dummy-key-will-be-replaced", |
| 72 | baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1", |
| 73 | defaultHeaders: { |
| 74 | "User-Agent": `QwenCode/1.0.0 (${os.platform()}; ${os.arch()})`, |
| 75 | "X-DashScope-CacheControl": "enable", |
| 76 | "X-DashScope-UserAgent": `QwenCode/1.0.0 (${os.platform()}; ${os.arch()})`, |
| 77 | "X-DashScope-AuthType": "qwen-oauth", |
| 78 | }, |
| 79 | timeout: this.timeoutMs, |
| 80 | }) |
| 81 | } |
| 82 | return this.client |
| 83 | } |
| 84 | |
| 85 | private async loadCachedQwenCredentials(): Promise<QwenOAuthCredentials> { |
| 86 | try { |
no outgoing calls
no test coverage detected