diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..00fbf314 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + roots: ['/src'], + transform: { + '^.+\\.tsx?$': 'ts-jest' + }, + testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'] +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..c28b14f8 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "multi-agent-chat-platform", + "version": "0.1.0", + "scripts": { + "test": "jest", + "lint": "eslint . --ext .ts" + }, + "devDependencies": { + "@types/jest": "^27.0.0", + "typescript": "^4.5.0", + "jest": "^27.0.0", + "ts-jest": "^27.0.0", + "eslint": "^8.0.0" + } +} \ No newline at end of file diff --git a/src/interfaces/conversation.interface.ts b/src/interfaces/conversation.interface.ts new file mode 100644 index 00000000..b619dde7 --- /dev/null +++ b/src/interfaces/conversation.interface.ts @@ -0,0 +1,48 @@ +import { PersonalityProfile } from './personality.interface'; + +/** + * Represents a message in a conversation + */ +export interface ChatMessage { + id: string; + agentId: string; + content: string; + timestamp: Date; +} + +/** + * Defines the interface for managing conversation state + */ +export interface ConversationState { + sessionId: string; + participants: PersonalityProfile[]; + messages: ChatMessage[]; + + /** + * Add a new message to the conversation + * @param message Message to be added + */ + addMessage(message: ChatMessage): void; + + /** + * Get the conversation history + * @returns Array of messages in chronological order + */ + getMessageHistory(): ChatMessage[]; +} + +/** + * Conversation Orchestrator interface + */ +export interface ConversationOrchestrator { + /** + * Handle an incoming user message + * @param sessionId Unique session identifier + * @param userMessage User's input message + * @returns Responses from participating agents + */ + handleMessage(sessionId: string, userMessage: string): Promise<{ + agentId: string; + response: string; + }[]>; +} \ No newline at end of file diff --git a/src/interfaces/personality.interface.ts b/src/interfaces/personality.interface.ts new file mode 100644 index 00000000..6a9f13ad --- /dev/null +++ b/src/interfaces/personality.interface.ts @@ -0,0 +1,35 @@ +/** + * Interface for Personality Profile + * Defines the structure and validation rules for agent personalities + */ +export interface PersonalityProfile { + id: string; + name: string; + description: string; + tone: 'serious' | 'playful' | 'scholarly'; + samplePrompts: string[]; + + // Validation metadata + version: string; + createdAt: Date; + lastUpdated: Date; +} + +/** + * Type guard for validating PersonalityProfile + * @param profile Potential personality profile to validate + * @returns Boolean indicating if profile is valid + */ +export function isValidPersonalityProfile(profile: any): profile is PersonalityProfile { + return ( + typeof profile === 'object' && + typeof profile.id === 'string' && + typeof profile.name === 'string' && + typeof profile.description === 'string' && + ['serious', 'playful', 'scholarly'].includes(profile.tone) && + Array.isArray(profile.samplePrompts) && + profile.samplePrompts.every((prompt: any) => typeof prompt === 'string') && + profile.createdAt instanceof Date && + profile.lastUpdated instanceof Date + ); +} \ No newline at end of file diff --git a/src/tests/personality.test.ts b/src/tests/personality.test.ts new file mode 100644 index 00000000..390e93bb --- /dev/null +++ b/src/tests/personality.test.ts @@ -0,0 +1,29 @@ +import { isValidPersonalityProfile, PersonalityProfile } from '../interfaces/personality.interface'; + +describe('Personality Profile Validation', () => { + const validProfile: PersonalityProfile = { + id: 'test-profile-1', + name: 'Test Agent', + description: 'A test personality profile', + tone: 'scholarly', + samplePrompts: ['Hello', 'How are you?'], + version: '1.0.0', + createdAt: new Date(), + lastUpdated: new Date() + }; + + const invalidProfiles = [ + {}, // Empty object + { id: 123 }, // Invalid type for id + { ...validProfile, tone: 'undefined-tone' }, // Invalid tone + { ...validProfile, samplePrompts: [123] } // Invalid prompt type + ]; + + test('valid profile should pass validation', () => { + expect(isValidPersonalityProfile(validProfile)).toBeTruthy(); + }); + + test.each(invalidProfiles)('invalid profile should fail validation', (profile) => { + expect(isValidPersonalityProfile(profile)).toBeFalsy(); + }); +}); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..387e8f4a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules"] +} \ No newline at end of file