Skip to content

Commit c9fb609

Browse files
refactor: provider qwen-code separado com nome Qwen Code
- Cria provider 'qwen-code' separado do 'alibaba' - Nome do provider: 'Qwen Code' - Label do método OAuth: 'Qwen Code (qwen.ai OAuth)' - Remove opção 'Importar do qwen-code' - Remove '(OAuth)' dos nomes dos modelos - Mantém apenas 2 modelos: qwen3-coder-plus e qwen3-coder-flash
1 parent bef9396 commit c9fb609

2 files changed

Lines changed: 10 additions & 39 deletions

File tree

src/constants.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Based on qwen-code implementation
44
*/
55

6+
// Provider ID - cria provider separado para OAuth
7+
export const QWEN_PROVIDER_ID = 'qwen-code';
8+
69
// OAuth Device Flow Endpoints (descobertos do qwen-code)
710
export const QWEN_OAUTH_CONFIG = {
811
baseUrl: 'https://chat.qwen.ai',
@@ -36,15 +39,15 @@ export const CALLBACK_PORT = 14561;
3639
export const QWEN_MODELS = {
3740
'qwen3-coder-plus': {
3841
id: 'qwen3-coder-plus',
39-
name: 'Qwen3 Coder Plus (OAuth)',
42+
name: 'Qwen3 Coder Plus',
4043
contextWindow: 1048576, // 1M tokens
4144
maxOutput: 65536, // 64K tokens
4245
description: 'Most capable Qwen coding model with 1M context window',
4346
cost: { input: 0, output: 0 }, // Free via OAuth
4447
},
4548
'qwen3-coder-flash': {
4649
id: 'qwen3-coder-flash',
47-
name: 'Qwen3 Coder Flash (OAuth)',
50+
name: 'Qwen3 Coder Flash',
4851
contextWindow: 1048576,
4952
maxOutput: 65536,
5053
description: 'Faster Qwen coding model for quick responses',

src/index.ts

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { existsSync } from 'node:fs';
99
import { spawn } from 'node:child_process';
1010

11-
import { QWEN_MODELS, QWEN_API_CONFIG } from './constants.js';
11+
import { QWEN_PROVIDER_ID, QWEN_API_CONFIG, QWEN_MODELS } from './constants.js';
1212
import type { QwenCredentials } from './types.js';
1313
import {
1414
loadCredentials,
@@ -66,7 +66,7 @@ export function checkExistingCredentials(): QwenCredentials | null {
6666
export const QwenAuthPlugin = async (_input: unknown) => {
6767
return {
6868
auth: {
69-
provider: 'qwen',
69+
provider: QWEN_PROVIDER_ID,
7070

7171
loader: async (
7272
getAuth: () => Promise<{ type: string; access?: string; refresh?: string; expires?: number }>,
@@ -124,7 +124,7 @@ export const QwenAuthPlugin = async (_input: unknown) => {
124124
methods: [
125125
{
126126
type: 'oauth',
127-
label: 'Login com Qwen (Device Flow)',
127+
label: 'Qwen Code (qwen.ai OAuth)',
128128
authorize: async () => {
129129
const { verifier, challenge } = generatePKCE();
130130

@@ -184,43 +184,15 @@ export const QwenAuthPlugin = async (_input: unknown) => {
184184
}
185185
},
186186
},
187-
{
188-
type: 'oauth',
189-
label: 'Importar do qwen-code',
190-
authorize: async () => {
191-
const creds = checkExistingCredentials();
192-
193-
if (creds) {
194-
return {
195-
url: '',
196-
instructions: 'Credenciais encontradas! Pressione Enter.',
197-
method: 'code',
198-
callback: async () => ({
199-
type: 'success',
200-
access: creds.accessToken,
201-
refresh: creds.refreshToken || '',
202-
expires: creds.expiryDate || Date.now() + 3600000,
203-
}),
204-
};
205-
}
206-
207-
return {
208-
url: '',
209-
instructions: 'Credenciais não encontradas. Execute "qwen" primeiro.',
210-
method: 'code',
211-
callback: async () => ({ type: 'failed' }),
212-
};
213-
},
214-
},
215187
],
216188
},
217189

218190
config: async (config: Record<string, unknown>) => {
219191
const providers = (config.provider as Record<string, unknown>) || {};
220192

221-
providers.qwen = {
193+
providers[QWEN_PROVIDER_ID] = {
222194
npm: '@ai-sdk/openai-compatible',
223-
name: 'Qwen (OAuth)',
195+
name: 'Qwen Code',
224196
options: { baseURL: QWEN_API_CONFIG.baseUrl },
225197
models: Object.fromEntries(
226198
Object.entries(QWEN_MODELS).map(([id, m]) => [
@@ -239,10 +211,6 @@ export const QwenAuthPlugin = async (_input: unknown) => {
239211

240212
config.provider = providers;
241213
},
242-
243-
event: async () => {
244-
// Event handler
245-
},
246214
};
247215
};
248216

0 commit comments

Comments
 (0)