feat: add CLI Command Node and Prompt Node components for orchestrator

- Implemented CliCommandNode component for executing CLI tools with AI models.
- Implemented PromptNode component for constructing AI prompts with context.
- Added styling for mode and tool badges in both components.
- Enhanced user experience with command and argument previews, execution status, and error handling.

test: add comprehensive tests for ask_question tool

- Created direct test for ask_question tool execution.
- Developed end-to-end tests to validate ask_question tool integration with WebSocket and A2UI surfaces.
- Implemented simple and integrated WebSocket tests to ensure proper message handling and surface reception.
- Added tool registration test to verify ask_question tool is correctly registered.

chore: add WebSocket listener and simulation tests

- Added WebSocket listener for A2UI surfaces to facilitate testing.
- Implemented frontend simulation test to validate complete flow from backend to frontend.
- Created various test scripts to ensure robust testing of ask_question tool functionality.
This commit is contained in:
catlog22
2026-02-03 23:10:36 +08:00
parent a806d70d9b
commit c6093ef741
134 changed files with 6392 additions and 634 deletions

77
test-ask-question.js Normal file
View File

@@ -0,0 +1,77 @@
/**
* Test ask_question MCP tool
*/
import { executeTool } from './ccw/dist/tools/index.js';
async function testAskQuestion() {
console.log('Testing ask_question tool...\n');
// Test 1: Confirm question
console.log('Test 1: Confirm Question');
const confirmResult = await executeTool('ask_question', {
question: {
id: 'test-confirm-1',
type: 'confirm',
title: '是否继续执行当前操作?',
message: '这是一个确认对话框测试',
description: '点击确认继续,点击取消终止',
},
timeout: 30000, // 30 seconds
});
console.log('Result:', JSON.stringify(confirmResult, null, 2));
// Test 2: Select question
console.log('\n\nTest 2: Select Question');
const selectResult = await executeTool('ask_question', {
question: {
id: 'test-select-1',
type: 'select',
title: '请选择您的偏好颜色',
options: [
{ value: 'red', label: '红色', description: '热情的红色' },
{ value: 'blue', label: '蓝色', description: '冷静的蓝色' },
{ value: 'green', label: '绿色', description: '自然的绿色' },
],
},
timeout: 30000,
});
console.log('Result:', JSON.stringify(selectResult, null, 2));
// Test 3: Input question
console.log('\n\nTest 3: Input Question');
const inputResult = await executeTool('ask_question', {
question: {
id: 'test-input-1',
type: 'input',
title: '请输入您的名字',
placeholder: '例如: 张三',
required: true,
},
timeout: 30000,
});
console.log('Result:', JSON.stringify(inputResult, null, 2));
// Test 4: Multi-select question
console.log('\n\nTest 4: Multi-Select Question');
const multiResult = await executeTool('ask_question', {
question: {
id: 'test-multi-1',
type: 'multi-select',
title: '选择您感兴趣的编程语言(可多选)',
options: [
{ value: 'js', label: 'JavaScript' },
{ value: 'ts', label: 'TypeScript' },
{ value: 'py', label: 'Python' },
{ value: 'go', label: 'Go' },
],
},
timeout: 30000,
});
console.log('Result:', JSON.stringify(multiResult, null, 2));
console.log('\n✅ All tests completed');
}
// Run tests
testAskQuestion().catch(console.error);