-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathauthMethods.ts
More file actions
50 lines (46 loc) · 1.3 KB
/
authMethods.ts
File metadata and controls
50 lines (46 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @license
* Copyright 2025 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/
import { AuthType } from '@qwen-code/qwen-code-core';
import type { AuthMethod } from '@agentclientprotocol/sdk';
export function buildAuthMethods(): AuthMethod[] {
return [
{
id: AuthType.USE_OPENAI,
name: 'Use OpenAI API key',
description: 'Requires setting the `OPENAI_API_KEY` environment variable',
_meta: {
type: 'terminal',
args: ['--auth-type=openai'],
},
},
{
id: AuthType.QWEN_OAUTH,
name: 'Qwen OAuth',
description: 'Qwen OAuth (free tier discontinued 2026-04-15)',
_meta: {
type: 'terminal',
args: ['--auth-type=qwen-oauth'],
},
},
];
}
export function filterAuthMethodsById(
authMethods: AuthMethod[],
authMethodId: string,
): AuthMethod[] {
return authMethods.filter((method) => method.id === authMethodId);
}
export function pickAuthMethodsForDetails(details?: string): AuthMethod[] {
const authMethods = buildAuthMethods();
if (!details) {
return authMethods;
}
if (details.includes('qwen-oauth') || details.includes('Qwen OAuth')) {
const narrowed = filterAuthMethodsById(authMethods, AuthType.QWEN_OAUTH);
return narrowed.length ? narrowed : authMethods;
}
return authMethods;
}