diff --git a/package.json b/package.json new file mode 100644 index 00000000..65b07521 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "multi-agent-chat-platform", + "version": "0.1.0", + "description": "Multi-agent interactive chat platform", + "scripts": { + "test": "jest", + "lint": "eslint . --ext .ts" + }, + "dependencies": { + "typescript": "^4.5.4" + }, + "devDependencies": { + "@types/jest": "^27.4.0", + "jest": "^27.4.7", + "ts-jest": "^27.1.2", + "eslint": "^8.6.0", + "@typescript-eslint/parser": "^5.8.1", + "@typescript-eslint/eslint-plugin": "^5.8.1" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node" + } +} \ No newline at end of file diff --git a/src/interfaces/system-interfaces.ts b/src/interfaces/system-interfaces.ts new file mode 100644 index 00000000..d263e1ff --- /dev/null +++ b/src/interfaces/system-interfaces.ts @@ -0,0 +1,87 @@ +/** + * Comprehensive system-wide interfaces for multi-agent chat platform + * Defines core interfaces and type contracts for each component + */ + +// Personality Profile Interface +export interface PersonalityProfile { + id: string; + name: string; + description: string; + tone: string; + samplePrompts: string[]; + version: string; +} + +// Chat Message Interface +export interface ChatMessage { + id: string; + sessionId: string; + agentId: string; + content: string; + timestamp: number; + type: 'user' | 'agent'; +} + +// Conversation Session Interface +export interface ConversationSession { + id: string; + participants: string[]; + messages: ChatMessage[]; + startTime: number; + lastActivityTime: number; + status: 'active' | 'completed' | 'terminated'; +} + +// API Response Interface +export interface ApiResponse { + success: boolean; + data?: T; + error?: string; +} + +// Engine Adapter Response Interface +export interface LLMResponse { + text: string; + confidence: number; + tokens: number; +} + +// Agent Deployment Status Interface +export interface AgentDeploymentStatus { + agentId: string; + containerStatus: 'running' | 'stopped' | 'error'; + healthCheck: { + cpu: number; + memory: number; + uptime: number; + }; +} + +// Validation Utility +export class InterfaceValidator { + static validatePersonalityProfile(profile: PersonalityProfile): boolean { + const requiredFields = ['id', 'name', 'description', 'tone']; + + // Check required fields exist + for (const field of requiredFields) { + if (!profile[field]) { + console.error(`Missing required field: ${field}`); + return false; + } + } + + // Additional validation rules + if (profile.name.length < 2 || profile.name.length > 50) { + console.error('Invalid name length'); + return false; + } + + if (profile.samplePrompts && profile.samplePrompts.length > 10) { + console.error('Too many sample prompts'); + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/tests/interface-validation.test.ts b/tests/interface-validation.test.ts new file mode 100644 index 00000000..019fc635 --- /dev/null +++ b/tests/interface-validation.test.ts @@ -0,0 +1,68 @@ +import { + PersonalityProfile, + InterfaceValidator, + ChatMessage, + ConversationSession +} from '../src/interfaces/system-interfaces'; + +describe('System Interface Validation', () => { + describe('PersonalityProfile Validation', () => { + const validProfile: PersonalityProfile = { + id: 'peter_disciple', + name: 'Peter', + description: 'Passionate apostle', + tone: 'zealous', + samplePrompts: ['Tell me about faith'], + version: '1.0.0' + }; + + const invalidProfiles = [ + { ...validProfile, name: 'P' }, // Too short name + { ...validProfile, name: '' }, // Empty name + { + ...validProfile, + samplePrompts: new Array(15).fill('test prompt') // Too many prompts + } + ]; + + test('Valid profile passes validation', () => { + expect(InterfaceValidator.validatePersonalityProfile(validProfile)).toBe(true); + }); + + test.each(invalidProfiles)('Invalid profile is rejected', (profile) => { + expect(InterfaceValidator.validatePersonalityProfile(profile)).toBe(false); + }); + }); + + describe('ChatMessage Creation', () => { + const validMessage: ChatMessage = { + id: 'msg_123', + sessionId: 'session_456', + agentId: 'peter_disciple', + content: 'Hello, I am Peter!', + timestamp: Date.now(), + type: 'agent' + }; + + test('Chat message can be created with valid data', () => { + expect(validMessage).toBeDefined(); + expect(validMessage.type).toBe('agent'); + }); + }); + + describe('Conversation Session Management', () => { + const validSession: ConversationSession = { + id: 'last_supper_session', + participants: ['peter_disciple', 'john_disciple'], + messages: [], + startTime: Date.now(), + lastActivityTime: Date.now(), + status: 'active' + }; + + test('Conversation session initializes correctly', () => { + expect(validSession.status).toBe('active'); + expect(validSession.participants).toHaveLength(2); + }); + }); +}); \ No newline at end of file