Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest'
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
48 changes: 48 additions & 0 deletions src/interfaces/conversation.interface.ts
Original file line number Diff line number Diff line change
@@ -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;
}[]>;
}
35 changes: 35 additions & 0 deletions src/interfaces/personality.interface.ts
Original file line number Diff line number Diff line change
@@ -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
);
}
29 changes: 29 additions & 0 deletions src/tests/personality.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}