qwen-code/packages/cli/src/acp-integration/authMethods.ts
mingholy.lmh 180dcd8b36 refactor(acp): migrate ACP integration to use @agentclientprotocol/sdk
- Remove acp.ts and schema.ts in favor of SDK types
- Refactor acpAgent.ts to leverage SDK client
- Update session management types and implementations
- Adjust all test cases for new SDK-based architecture
- Update integration tests and export utilities

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-06 21:57:35 +08:00

51 lines
1.3 KiB
TypeScript

/**
* @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:
'OAuth authentication for Qwen models with free daily requests',
_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;
}