UNPKG

codecrucible-synth

Version:

Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability

248 lines 6.8 kB
/** * Voice Value Objects * Immutable domain values for voice configuration * * Living Spiral Council Applied: * - Immutable value objects with built-in validation * - Type safety and business rule enforcement * - No external dependencies */ /** * Voice Style Value Object * Represents the behavioral style of a voice archetype */ export class VoiceStyle { _value; constructor(value) { this._value = value; } get value() { return this._value; } static create(style) { const normalizedStyle = style.toLowerCase().trim(); if (!this.isValidStyle(normalizedStyle)) { throw new Error(`Invalid voice style: ${style}. Must be one of: ${this.getValidStyles().join(', ')}`); } return new VoiceStyle(normalizedStyle); } static experimental() { return new VoiceStyle('experimental'); } static conservative() { return new VoiceStyle('conservative'); } static analytical() { return new VoiceStyle('analytical'); } static systematic() { return new VoiceStyle('systematic'); } static creative() { return new VoiceStyle('creative'); } static practical() { return new VoiceStyle('practical'); } static isValidStyle(style) { return this.getValidStyles().includes(style); } static getValidStyles() { return ['experimental', 'conservative', 'analytical', 'systematic', 'creative', 'practical']; } equals(other) { return this._value === other._value; } toString() { return this._value; } } /** * Voice Temperature Value Object * Represents the creativity/randomness level of a voice (0.0 to 1.0) */ export class VoiceTemperature { _value; constructor(value) { this._value = value; } get value() { return this._value; } static create(temperature) { if (!this.isValidTemperature(temperature)) { throw new Error(`Invalid voice temperature: ${temperature}. Must be between 0.0 and 1.0`); } return new VoiceTemperature(Number(temperature.toFixed(2))); } static conservative() { return new VoiceTemperature(0.3); } static balanced() { return new VoiceTemperature(0.6); } static creative() { return new VoiceTemperature(0.9); } static isValidTemperature(temperature) { return (typeof temperature === 'number' && !isNaN(temperature) && temperature >= 0.0 && temperature <= 1.0); } /** * Check if this temperature is suitable for creative tasks */ isCreative() { return this._value >= 0.7; } /** * Check if this temperature is suitable for analytical tasks */ isAnalytical() { return this._value <= 0.5; } /** * Check if this temperature is balanced */ isBalanced() { return this._value > 0.5 && this._value < 0.7; } equals(other) { return Math.abs(this._value - other._value) < 0.01; } toString() { return this._value.toFixed(2); } } /** * Provider Type Value Object * Represents the type of AI model provider */ export class ProviderType { _value; constructor(value) { this._value = value; } get value() { return this._value; } static create(type) { const normalizedType = type.toLowerCase().trim(); if (!this.isValidType(normalizedType)) { throw new Error(`Invalid provider type: ${type}. Must be one of: ${this.getValidTypes().join(', ')}`); } return new ProviderType(normalizedType); } static ollama() { return new ProviderType('ollama'); } static lmStudio() { return new ProviderType('lm-studio'); } static huggingface() { return new ProviderType('huggingface'); } static auto() { return new ProviderType('auto'); } static isValidType(type) { return this.getValidTypes().includes(type); } static getValidTypes() { return ['ollama', 'lm-studio', 'huggingface', 'auto']; } equals(other) { return this._value === other._value; } toString() { return this._value; } } /** * Model Name Value Object * Represents a validated AI model name */ export class ModelName { _value; constructor(value) { this._value = value; } get value() { return this._value; } static create(name) { const trimmedName = name.trim(); if (!trimmedName || trimmedName.length === 0) { throw new Error('Model name cannot be empty'); } if (trimmedName.length > 100) { throw new Error('Model name cannot exceed 100 characters'); } if (!/^[a-zA-Z0-9\-_:./]+$/.test(trimmedName)) { throw new Error('Model name can only contain letters, numbers, hyphens, underscores, colons, dots, and forward slashes'); } return new ModelName(trimmedName); } equals(other) { return this._value === other._value; } toString() { return this._value; } } /** * Request Priority Value Object * Represents the priority level of a processing request */ export class RequestPriority { _value; _numericValue; constructor(value, numericValue) { this._value = value; this._numericValue = numericValue; } get value() { return this._value; } get numericValue() { return this._numericValue; } static create(priority) { const normalizedPriority = priority.toLowerCase().trim(); switch (normalizedPriority) { case 'low': return new RequestPriority('low', 1); case 'medium': return new RequestPriority('medium', 2); case 'high': return new RequestPriority('high', 3); case 'critical': return new RequestPriority('critical', 4); default: throw new Error(`Invalid priority: ${priority}. Must be one of: low, medium, high, critical`); } } static low() { return new RequestPriority('low', 1); } static medium() { return new RequestPriority('medium', 2); } static high() { return new RequestPriority('high', 3); } static critical() { return new RequestPriority('critical', 4); } isHigherThan(other) { return this._numericValue > other._numericValue; } equals(other) { return this._value === other._value; } toString() { return this._value; } } //# sourceMappingURL=voice-values.js.map