mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-04 14:40:45 +00:00
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>
This commit is contained in:
parent
79adac930f
commit
180dcd8b36
21 changed files with 421 additions and 1709 deletions
|
|
@ -12,7 +12,10 @@ import { Session } from './Session.js';
|
|||
import type { Config, GeminiChat } from '@qwen-code/qwen-code-core';
|
||||
import { ApprovalMode, AuthType } from '@qwen-code/qwen-code-core';
|
||||
import * as core from '@qwen-code/qwen-code-core';
|
||||
import type * as acp from '../acp.js';
|
||||
import type {
|
||||
AgentSideConnection,
|
||||
PromptRequest,
|
||||
} from '@agentclientprotocol/sdk';
|
||||
import type { LoadedSettings } from '../../config/settings.js';
|
||||
import * as nonInteractiveCliCommands from '../../nonInteractiveCliCommands.js';
|
||||
|
||||
|
|
@ -24,7 +27,7 @@ vi.mock('../../nonInteractiveCliCommands.js', () => ({
|
|||
describe('Session', () => {
|
||||
let mockChat: GeminiChat;
|
||||
let mockConfig: Config;
|
||||
let mockClient: acp.Client;
|
||||
let mockClient: AgentSideConnection;
|
||||
let mockSettings: LoadedSettings;
|
||||
let session: Session;
|
||||
let currentModel: string;
|
||||
|
|
@ -76,8 +79,8 @@ describe('Session', () => {
|
|||
requestPermission: vi.fn().mockResolvedValue({
|
||||
outcome: { outcome: 'selected', optionId: 'proceed_once' },
|
||||
}),
|
||||
sendCustomNotification: vi.fn().mockResolvedValue(undefined),
|
||||
} as unknown as acp.Client;
|
||||
extNotification: vi.fn().mockResolvedValue(undefined),
|
||||
} as unknown as AgentSideConnection;
|
||||
|
||||
mockSettings = {
|
||||
merged: {},
|
||||
|
|
@ -103,20 +106,19 @@ describe('Session', () => {
|
|||
['auto-edit', ApprovalMode.AUTO_EDIT],
|
||||
['yolo', ApprovalMode.YOLO],
|
||||
] as const)('maps %s mode', async (modeId, expected) => {
|
||||
const result = await session.setMode({
|
||||
await session.setMode({
|
||||
sessionId: 'test-session-id',
|
||||
modeId,
|
||||
});
|
||||
|
||||
expect(mockConfig.setApprovalMode).toHaveBeenCalledWith(expected);
|
||||
expect(result).toEqual({ modeId });
|
||||
});
|
||||
});
|
||||
|
||||
describe('setModel', () => {
|
||||
it('sets model via config and returns current model', async () => {
|
||||
const requested = `qwen3-coder-plus(${AuthType.USE_OPENAI})`;
|
||||
const result = await session.setModel({
|
||||
await session.setModel({
|
||||
sessionId: 'test-session-id',
|
||||
modelId: ` ${requested} `,
|
||||
});
|
||||
|
|
@ -126,10 +128,6 @@ describe('Session', () => {
|
|||
'qwen3-coder-plus',
|
||||
undefined,
|
||||
);
|
||||
expect(mockConfig.getModel).toHaveBeenCalled();
|
||||
expect(result).toEqual({
|
||||
modelId: `qwen3-coder-plus(${AuthType.USE_OPENAI})`,
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects empty/whitespace model IDs', async () => {
|
||||
|
|
@ -221,7 +219,7 @@ describe('Session', () => {
|
|||
.fn()
|
||||
.mockResolvedValue((async function* () {})());
|
||||
|
||||
const promptRequest: acp.PromptRequest = {
|
||||
const promptRequest: PromptRequest = {
|
||||
sessionId: 'test-session-id',
|
||||
prompt: [
|
||||
{ type: 'text', text: 'Check this file' },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue