UNPKG

contaigents

Version:

Modular AI Content Ecosystem with Audio Generation

58 lines (57 loc) โ€ข 3.24 kB
#!/usr/bin/env node import { Command } from 'commander'; import { ChatService } from '../services/chatService.js'; export function createTestCommandToolCommand() { const command = new Command('test-command-tool'); command .description('Test the command execution tool functionality') .action(async () => { console.log('๐Ÿงช Testing Command Execution Tool...\n'); try { const chatService = new ChatService(process.cwd()); // Create a chat session const session = chatService.createSession({ systemPrompt: `You are a helpful AI assistant with access to command execution tools. When users ask you to run commands, use the execute_command tool to run them safely. Always provide clear information about the command results.` }); console.log(`๐Ÿ’ฌ Created test session: ${session.id}\n`); // Test 1: Ask AI to run pwd command console.log('๐Ÿ“‹ Test 1: Asking AI to run pwd command...'); const response1 = await chatService.sendMessage(session.id, "Please use the execute_command tool to run 'pwd' and tell me what directory we're in.", { provider: 'openai', model: 'gpt-4o-mini', temperature: 0.1 }); console.log('๐Ÿค– AI Response:', response1.content.substring(0, 200) + '...\n'); // Test 2: Ask AI to list files console.log('๐Ÿ“‹ Test 2: Asking AI to list files in current directory...'); const response2 = await chatService.sendMessage(session.id, "Now use the execute_command tool to run 'ls -la' and show me the files in the current directory.", { provider: 'openai', model: 'gpt-4o-mini', temperature: 0.1 }); console.log('๐Ÿค– AI Response:', response2.content.substring(0, 200) + '...\n'); // Test 3: Ask AI to check git status console.log('๐Ÿ“‹ Test 3: Asking AI to check git status...'); const response3 = await chatService.sendMessage(session.id, "Please use the execute_command tool to run 'git status --porcelain' and tell me about any changes in the repository.", { provider: 'openai', model: 'gpt-4o-mini', temperature: 0.1 }); console.log('๐Ÿค– AI Response:', response3.content.substring(0, 200) + '...\n'); // Test 4: Ask AI to check Node.js version console.log('๐Ÿ“‹ Test 4: Asking AI to check Node.js version...'); const response4 = await chatService.sendMessage(session.id, "Use the execute_command tool to run 'node --version' and tell me what version of Node.js we're using.", { provider: 'openai', model: 'gpt-4o-mini', temperature: 0.1 }); console.log('๐Ÿค– AI Response:', response4.content.substring(0, 200) + '...\n'); console.log('โœ… Command execution tool testing completed successfully!'); } catch (error) { console.error('โŒ Error during testing:', error); process.exit(1); } }); return command; }