From 1b8ed57a2864d0676ef395e6f6e5e6254a8ce853 Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Tue, 13 May 2025 23:42:23 +0000 Subject: [PATCH 1/7] Start draft PR From 5449ab9e655d9b4dcf9f7b59826730fdc52582d4 Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Tue, 13 May 2025 23:42:44 +0000 Subject: [PATCH 2/7] Add Personality Data Manager interface definition --- src/interfaces/personality-data-manager.ts | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/interfaces/personality-data-manager.ts diff --git a/src/interfaces/personality-data-manager.ts b/src/interfaces/personality-data-manager.ts new file mode 100644 index 00000000..7a0f34b2 --- /dev/null +++ b/src/interfaces/personality-data-manager.ts @@ -0,0 +1,32 @@ +// Personality Data Manager Interface +export interface PersonalityProfile { + id: string; + name: string; + description: string; + tone: string; + samplePrompts: string[]; + version: number; +} + +export interface PersonalityDataManager { + /** + * Load a personality profile by its unique identifier + * @param id Profile identifier + * @returns Loaded personality profile or null if not found + */ + loadProfile(id: string): PersonalityProfile | null; + + /** + * Validate a personality profile's schema + * @param profile Profile to validate + * @returns Boolean indicating validation result or throws detailed error + */ + validateProfile(profile: PersonalityProfile): boolean; + + /** + * Save or update a personality profile + * @param profile Profile to save + * @returns Version number of saved profile + */ + saveProfile(profile: PersonalityProfile): number; +} \ No newline at end of file From 43ecbc4cd2d274232aa0f6ba1ecef4f841d3e82b Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Tue, 13 May 2025 23:42:51 +0000 Subject: [PATCH 3/7] Add Chatbot Engine Adapter interface definition --- src/interfaces/chatbot-engine-adapter.ts | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/interfaces/chatbot-engine-adapter.ts diff --git a/src/interfaces/chatbot-engine-adapter.ts b/src/interfaces/chatbot-engine-adapter.ts new file mode 100644 index 00000000..93ddc060 --- /dev/null +++ b/src/interfaces/chatbot-engine-adapter.ts @@ -0,0 +1,28 @@ +// Chatbot Engine Adapter Interface +import { PersonalityProfile } from './personality-data-manager'; + +export interface ChatHistory { + messages: Array<{ + role: 'user' | 'agent'; + content: string; + }>; +} + +export interface ChatbotEngineAdapter { + /** + * Generate a response from an AI agent + * @param profile Personality profile for response context + * @param history Conversation history + * @returns Generated AI response + */ + generateResponse( + profile: PersonalityProfile, + history: ChatHistory + ): Promise; + + /** + * Check the health and availability of the underlying LLM backend + * @returns Boolean indicating backend readiness + */ + checkBackendHealth(): Promise; +} \ No newline at end of file From afda88cc371fe7408355fc6d52bc5e055e60a8af Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Tue, 13 May 2025 23:42:57 +0000 Subject: [PATCH 4/7] Add Conversation Orchestrator interface definition --- src/interfaces/conversation-orchestrator.ts | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/interfaces/conversation-orchestrator.ts diff --git a/src/interfaces/conversation-orchestrator.ts b/src/interfaces/conversation-orchestrator.ts new file mode 100644 index 00000000..293bdcc2 --- /dev/null +++ b/src/interfaces/conversation-orchestrator.ts @@ -0,0 +1,29 @@ +// Conversation Orchestrator Interface +import { PersonalityProfile } from './personality-data-manager'; +import { ChatbotEngineAdapter } from './chatbot-engine-adapter'; + +export interface OrchestratorAgentReply { + agentId: string; + profile: PersonalityProfile; + reply: string; +} + +export interface ConversationOrchestrator { + /** + * Handle an incoming user message in a conversation session + * @param sessionId Unique session identifier + * @param userMessage Incoming user message + * @returns Array of agent replies + */ + handleMessage( + sessionId: string, + userMessage: string + ): Promise; + + /** + * Initialize a new conversation session + * @param selectedAgentIds Agents to be included in the session + * @returns Unique session identifier + */ + initializeSession(selectedAgentIds: string[]): string; +} \ No newline at end of file From a000f9add2e46be9528a34514b9e49a20e4ed6fd Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Tue, 13 May 2025 23:43:14 +0000 Subject: [PATCH 5/7] Add comprehensive component interface tests --- tests/component-interfaces.test.ts | 110 +++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tests/component-interfaces.test.ts diff --git a/tests/component-interfaces.test.ts b/tests/component-interfaces.test.ts new file mode 100644 index 00000000..356a68e6 --- /dev/null +++ b/tests/component-interfaces.test.ts @@ -0,0 +1,110 @@ +import { PersonalityProfile, PersonalityDataManager } from '../src/interfaces/personality-data-manager'; +import { ChatbotEngineAdapter, ChatHistory } from '../src/interfaces/chatbot-engine-adapter'; +import { ConversationOrchestrator, OrchestratorAgentReply } from '../src/interfaces/conversation-orchestrator'; + +describe('Component Interfaces', () => { + describe('Personality Data Manager', () => { + const mockPersonalityDataManager: PersonalityDataManager = { + loadProfile: (id: string) => { + if (id === 'valid_profile') { + return { + id: 'valid_profile', + name: 'Test Profile', + description: 'A mock profile', + tone: 'philosophical', + samplePrompts: ['What is truth?'], + version: 1 + }; + } + return null; + }, + validateProfile: (profile: PersonalityProfile) => { + return profile.name.length > 0 && profile.samplePrompts.length > 0; + }, + saveProfile: (profile: PersonalityProfile) => { + return profile.version + 1; + } + }; + + it('should load a valid profile', () => { + const profile = mockPersonalityDataManager.loadProfile('valid_profile'); + expect(profile).toBeTruthy(); + expect(profile?.name).toBe('Test Profile'); + }); + + it('should validate profile correctly', () => { + const validProfile: PersonalityProfile = { + id: 'test', + name: 'Valid Profile', + description: 'Test Description', + tone: 'neutral', + samplePrompts: ['Hello'], + version: 1 + }; + expect(mockPersonalityDataManager.validateProfile(validProfile)).toBeTruthy(); + }); + }); + + describe('Chatbot Engine Adapter', () => { + const mockChatbotEngineAdapter: ChatbotEngineAdapter = { + generateResponse: async (profile, history) => { + return `Mocked response for ${profile.name}`; + }, + checkBackendHealth: async () => true + }; + + it('should generate a response', async () => { + const mockProfile: PersonalityProfile = { + id: 'test_profile', + name: 'Test Agent', + description: 'A test agent', + tone: 'formal', + samplePrompts: ['Greetings'], + version: 1 + }; + const mockHistory: ChatHistory = { messages: [] }; + + const response = await mockChatbotEngineAdapter.generateResponse(mockProfile, mockHistory); + expect(response).toContain('Mocked response'); + }); + + it('should check backend health', async () => { + const health = await mockChatbotEngineAdapter.checkBackendHealth(); + expect(health).toBeTruthy(); + }); + }); + + describe('Conversation Orchestrator', () => { + const mockConversationOrchestrator: ConversationOrchestrator = { + handleMessage: async (sessionId, userMessage) => { + const mockReply: OrchestratorAgentReply[] = [{ + agentId: 'agent1', + profile: { + id: 'agent1', + name: 'Test Agent', + description: 'A mock agent', + tone: 'philosophical', + samplePrompts: ['What is meaning?'], + version: 1 + }, + reply: 'A philosophical response' + }]; + return mockReply; + }, + initializeSession: (selectedAgentIds) => { + return 'mock_session_' + selectedAgentIds.join('_'); + } + }; + + it('should handle messages and return agent replies', async () => { + const replies = await mockConversationOrchestrator.handleMessage('session1', 'Hello'); + expect(replies.length).toBeGreaterThan(0); + expect(replies[0].reply).toBe('A philosophical response'); + }); + + it('should initialize a session with selected agents', () => { + const sessionId = mockConversationOrchestrator.initializeSession(['agent1', 'agent2']); + expect(sessionId).toContain('mock_session_agent1_agent2'); + }); + }); +}); \ No newline at end of file From 1b1f8618585e0aa859ebcb5282a8848471616471 Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Tue, 13 May 2025 23:43:21 +0000 Subject: [PATCH 6/7] Add package.json with project dependencies --- package.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 00000000..32d4f6e8 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "multi-agent-chat-platform", + "version": "0.1.0", + "description": "Multi-agent interactive chat platform", + "main": "index.js", + "scripts": { + "test": "jest", + "lint": "eslint . --ext .ts" + }, + "dependencies": { + "typescript": "^4.9.5" + }, + "devDependencies": { + "@types/jest": "^29.5.1", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "eslint": "^8.40.0", + "@typescript-eslint/parser": "^5.59.2", + "@typescript-eslint/eslint-plugin": "^5.59.2" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node" + } +} \ No newline at end of file From da4cf721851f18f89e25fc6b018cc137d296cd30 Mon Sep 17 00:00:00 2001 From: Vuk7912 Date: Tue, 13 May 2025 23:43:25 +0000 Subject: [PATCH 7/7] Add TypeScript configuration file --- tsconfig.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tsconfig.json diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..bfa6eb48 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "outDir": "./dist" + }, + "include": ["src/**/*", "tests/**/*"], + "exclude": ["node_modules"] +} \ No newline at end of file