/** * AI инструменты для работы с цветом и стилизацией * * Предоставляет Claude возможности для цветокоррекции, * стилизации и создания визуальных эффектов */ import { ClaudeTool } from "../services/claude-service" /** * Color & Style Tools - 6 инструментов для работы с цветом и стилем */ export const colorStyleTools: ClaudeTool[] = [ { name: "analyze_color_palette", description: "Анализирует цветовую палитру проекта и предлагает улучшения гармонии", input_schema: { type: "object", properties: { analysisScope: { type: "string", enum: ["full-project", "selected-clips", "timeline-range", "current-frame"], description: "Область анализа цветовой палитры", default: "full-project", }, timeRange: { type: "object", properties: { start: { type: "number", description: "Начальное время в секундах" }, end: { type: "number", description: "Конечное время в секундах" }, }, description: "Временной диапазон для анализа", }, colorAnalysisType: { type: "array", items: { type: "string", enum: ["dominant-colors", "color-harmony", "temperature", "saturation", "brightness", "contrast"], }, description: "Типы цветового анализа", default: ["dominant-colors", "color-harmony", "temperature"], }, samplingMethod: { type: "string", enum: ["uniform", "adaptive", "key-frames", "scene-changes"], description: "Метод сэмплирования кадров", default: "adaptive", }, includeHistogram: { type: "boolean", description: "Включить гистограмму цветов", default: true, }, generatePalette: { type: "boolean", description: "Генерировать цветовую палитру", default: true, }, compareWithStandards: { type: "array", items: { type: "string", enum: ["rec709", "rec2020", "dci-p3", "adobe-rgb", "srgb"], }, description: "Сравнить с цветовыми стандартами", }, }, }, }, { name: "apply_cinematic_color_grading", description: "Применяет кинематографическую цветокоррекцию с различными стилями и LUT", input_schema: { type: "object", properties: { gradingStyle: { type: "string", enum: [ "cinematic", "vintage", "modern", "thriller", "romance", "sci-fi", "documentary", "commercial", "custom", ], description: "Стиль цветокоррекции", }, targetClips: { type: "array", items: { type: "string" }, description: "ID клипов для применения цветокоррекции", }, colorProfile: { type: "object", properties: { temperature: { type: "number", minimum: -100, maximum: 100, description: "Цветовая температура", }, tint: { type: "number", minimum: -100, maximum: 100, description: "Оттенок", }, exposure: { type: "number", minimum: -3, maximum: 3, description: "Экспозиция", }, highlights: { type: "number", minimum: -100, maximum: 100, description: "Светлые участки", }, shadows: { type: "number", minimum: -100, maximum: 100, description: "Тени", }, contrast: { type: "number", minimum: -100, maximum: 100, description: "Контраст", }, saturation: { type: "number", minimum: -100, maximum: 100, description: "Насыщенность", }, }, }, lutSettings: { type: "object", properties: { useLUT: { type: "boolean", description: "Использовать LUT" }, lutFile: { type: "string", description: "Путь к LUT файлу" }, lutIntensity: { type: "number", minimum: 0, maximum: 1, description: "Интенсивность LUT", default: 1, }, blendMode: { type: "string", enum: ["normal", "multiply", "screen", "overlay", "soft-light"], description: "Режим наложения LUT", default: "normal", }, }, }, adaptiveCorrection: { type: "boolean", description: "Адаптивная коррекция под контент", default: true, }, preserveSkinTones: { type: "boolean", description: "Сохранять естественные тона кожи", default: true, }, reason: { type: "string", description: "Цель применения цветокоррекции", }, }, required: ["gradingStyle", "reason"], }, }, { name: "create_color_matching", description: "Создает цветовое соответствие между различными клипами и камерами", input_schema: { type: "object", properties: { matchingMethod: { type: "string", enum: ["reference-frame", "shot-matching", "auto-balance", "manual-targets", "histogram-matching"], description: "Метод сопоставления цветов", default: "shot-matching", }, referenceClip: { type: "string", description: "ID клипа-образца для сопоставления", }, targetClips: { type: "array", items: { type: "string" }, description: "ID клипов для корректировки", }, matchingParameters: { type: "object", properties: { matchBrightness: { type: "boolean", description: "Сопоставлять яркость" }, matchContrast: { type: "boolean", description: "Сопоставлять контраст" }, matchColor: { type: "boolean", description: "Сопоставлять цвет" }, matchSaturation: { type: "boolean", description: "Сопоставлять насыщенность" }, preserveHighlights: { type: "boolean", description: "Сохранять блики" }, preserveShadows: { type: "boolean", description: "Сохранять тени" }, }, }, analysisRegions: { type: "array", items: { type: "object", properties: { name: { type: "string", description: "Название области" }, coordinates: { type: "object", properties: { x: { type: "number" }, y: { type: "number" }, width: { type: "number" }, height: { type: "number" }, }, }, weight: { type: "number", minimum: 0, maximum: 1, description: "Вес области при анализе" }, }, }, description: "Области кадра для анализа соответствия", }, tolerance: { type: "number", minimum: 0, maximum: 1, description: "Допустимое отклонение при сопоставлении", default: 0.1, }, previewMode: { type: "boolean", description: "Режим предварительного просмотра", default: true, }, reason: { type: "string", description: "Цель создания цветового соответствия", }, }, required: ["matchingMethod", "targetClips", "reason"], }, }, { name: "generate_style_transfer", description: "Применяет стилистическую передачу для создания художественных эффектов", input_schema: { type: "object", properties: { styleSource: { type: "string", enum: ["reference-image", "artistic-style", "preset", "custom-parameters"], description: "Источник стиля для передачи", }, referenceImagePath: { type: "string", description: "Путь к изображению-образцу стиля", }, artisticStyle: { type: "string", enum: ["oil-painting", "watercolor", "sketch", "impressionist", "pop-art", "vintage", "noir", "sepia"], description: "Художественный стиль", }, transferIntensity: { type: "number", minimum: 0, maximum: 1, description: "Интенсивность применения стиля", default: 0.7, }, targetElements: { type: "array", items: { type: "string", enum: ["colors", "textures", "lighting", "contrast", "composition"], }, description: "Элементы для передачи стиля", default: ["colors", "lighting"], }, processingQuality: { type: "string", enum: ["draft", "preview", "high", "ultra"], description: "Качество обработки", default: "high", }, preserveDetails: { type: "object", properties: { faces: { type: "boolean", description: "Сохранять детали лиц" }, text: { type: "boolean", description: "Сохранять читаемость текста" }, motion: { type: "boolean", description: "Сохранять четкость движения" }, edges: { type: "boolean", description: "Сохранять резкость краев" }, }, }, blendingOptions: { type: "object", properties: { blendMode: { type: "string", enum: ["replace", "overlay", "multiply", "soft-light", "color-dodge"], description: "Режим наложения стиля", }, opacity: { type: "number", minimum: 0, maximum: 1, description: "Прозрачность эффекта", }, maskAreas: { type: "array", items: { type: "string" }, description: "Области для применения маски", }, }, }, reason: { type: "string", description: "Цель применения стилистической передачи", }, }, required: ["styleSource", "reason"], }, }, { name: "create_dynamic_color_schemes", description: "Создает динамические цветовые схемы, адаптирующиеся к содержимому", input_schema: { type: "object", properties: { schemeType: { type: "string", enum: ["complementary", "triadic", "analogous", "monochromatic", "split-complementary", "tetradic"], description: "Тип цветовой схемы", }, adaptationTriggers: { type: "array", items: { type: "string", enum: ["scene-change", "music-beat", "emotional-content", "time-of-day", "action-intensity"], }, description: "Триггеры для изменения схемы", default: ["scene-change", "emotional-content"], }, baseColor: { type: "string", description: "Базовый цвет в hex формате", }, colorMood: { type: "string", enum: ["warm", "cool", "neutral", "vibrant", "muted", "dramatic", "peaceful"], description: "Настроение цветовой схемы", }, transitionSettings: { type: "object", properties: { duration: { type: "number", minimum: 0.1, maximum: 5, description: "Длительность перехода в секундах", default: 1, }, easing: { type: "string", enum: ["linear", "ease-in", "ease-out", "ease-in-out", "bounce"], description: "Функция сглаживания перехода", default: "ease-in-out", }, smoothness: { type: "number", minimum: 0, maximum: 1, description: "Плавность перехода", default: 0.8, }, }, }, intensityMapping: { type: "object", properties: { lowIntensity: { type: "string", description: "Цветовая схема для низкой интенсивности" }, mediumIntensity: { type: "string", description: "Цветовая схема для средней интенсивности" }, highIntensity: { type: "string", description: "Цветовая схема для высокой интенсивности" }, }, }, constraintsSettings: { type: "object", properties: { maintainReadability: { type: "boolean", description: "Поддерживать читаемость текста" }, limitSaturation: { type: "object", properties: { min: { type: "number", minimum: 0, maximum: 1 }, max: { type: "number", minimum: 0, maximum: 1 }, }, }, preserveBrandColors: { type: "boolean", description: "Сохранять брендовые цвета" }, }, }, reason: { type: "string", description: "Цель создания динамической цветовой схемы", }, }, required: ["schemeType", "reason"], }, }, { name: "optimize_visual_consistency", description: "Оптимизирует визуальную консистентность проекта через анализ стиля и цвета", input_schema: { type: "object", properties: { consistencyAspects: { type: "array", items: { type: "string", enum: ["color-temperature", "exposure", "contrast", "saturation", "style", "lighting", "composition"], }, description: "Аспекты для обеспечения консистентности", default: ["color-temperature", "exposure", "contrast"], }, analysisMethod: { type: "string", enum: ["statistical", "perceptual", "technical", "artistic"], description: "Метод анализа консистентности", default: "perceptual", }, toleranceSettings: { type: "object", properties: { colorVariation: { type: "number", minimum: 0, maximum: 1, description: "Допустимое отклонение цвета", default: 0.15, }, exposureVariation: { type: "number", minimum: 0, maximum: 2, description: "Допустимое отклонение экспозиции", default: 0.5, }, contrastVariation: { type: "number", minimum: 0, maximum: 1, description: "Допустимое отклонение контраста", default: 0.2, }, }, }, correctionStrategy: { type: "string", enum: ["automatic", "guided", "manual-review", "preserve-artistic"], description: "Стратегия коррекции", default: "guided", }, priorityWeights: { type: "object", properties: { technicalAccuracy: { type: "number", minimum: 0, maximum: 1, description: "Вес технической точности", }, artisticVision: { type: "number", minimum: 0, maximum: 1, description: "Вес художественного видения", }, viewerComfort: { type: "number", minimum: 0, maximum: 1, description: "Вес комфорта для зрителя", }, }, }, excludeRegions: { type: "array", items: { type: "object", properties: { clipId: { type: "string" }, timeRange: { type: "object", properties: { start: { type: "number" }, end: { type: "number" }, }, }, reason: { type: "string", description: "Причина исключения" }, }, }, description: "Области для исключения из оптимизации", }, generateReport: { type: "boolean", description: "Создать отчет о консистентности", default: true, }, reason: { type: "string", description: "Цель оптимизации визуальной консистентности", }, }, required: ["consistencyAspects", "reason"], }, }, ] /** * Типы результатов выполнения color & style инструментов */ export interface ColorStyleToolResult { success: boolean message: string data?: { colorAnalysis?: any appliedGrading?: any matchingResults?: any styleTransfer?: any colorScheme?: any consistencyReport?: any recommendations?: string[] warnings?: string[] } errors?: string[] nextActions?: string[] } /** * Интерфейс для доступа к системе цвета и стиля */ interface ColorStyleSystemAccess { analyzeColorPalette: (scope: string, types: string[], method: string) => any applyCinematicGrading: (style: string, clips: string[], profile: any, lut: any) => Promise createColorMatching: (method: string, reference: string, targets: string[], params: any) => Promise generateStyleTransfer: (source: string, intensity: number, elements: string[], quality: string) => Promise createDynamicColorSchemes: (type: string, triggers: string[], settings: any) => Promise optimizeVisualConsistency: (aspects: string[], method: string, strategy: string) => Promise getColorStandards: () => any validateColorSpace: (colorSpace: string) => boolean } // Глобальная переменная для доступа к системе цвета и стиля let colorStyleSystemAccess: ColorStyleSystemAccess | null = null /** * Устанавливает доступ к системе цвета и стиля */ export function setColorStyleSystemAccess(access: ColorStyleSystemAccess | null) { colorStyleSystemAccess = access } /** * Выполняет color & style инструмент */ export async function executeColorStyleTool( toolName: string, input: Record, ): Promise { try { switch (toolName) { case "analyze_color_palette": return await analyzeColorPalette(input) case "apply_cinematic_color_grading": return await applyCinematicColorGrading(input) case "create_color_matching": return await createColorMatching(input) case "generate_style_transfer": return await generateStyleTransfer(input) case "create_dynamic_color_schemes": return await createDynamicColorSchemes(input) case "optimize_visual_consistency": return await optimizeVisualConsistency(input) default: return { success: false, message: `Неизвестный color & style инструмент: ${toolName}`, errors: [`Инструмент ${toolName} не найден`], } } } catch (error) { return { success: false, message: `Ошибка выполнения color & style инструмента ${toolName}: ${error instanceof Error ? error.message : String(error)}`, errors: [error instanceof Error ? error.message : String(error)], } } } // Заглушки для функций (в реальной реализации они будут полностью развернуты) async function analyzeColorPalette(_input: Record): Promise { return { success: true, message: "Color palette analyzed", data: { colorAnalysis: {} } } } async function applyCinematicColorGrading(_input: Record): Promise { return { success: true, message: "Cinematic color grading applied", data: { appliedGrading: {} } } } async function createColorMatching(_input: Record): Promise { return { success: true, message: "Color matching created", data: { matchingResults: {} } } } async function generateStyleTransfer(_input: Record): Promise { return { success: true, message: "Style transfer generated", data: { styleTransfer: {} } } } async function createDynamicColorSchemes(_input: Record): Promise { return { success: true, message: "Dynamic color schemes created", data: { colorScheme: {} } } } async function optimizeVisualConsistency(_input: Record): Promise { return { success: true, message: "Visual consistency optimized", data: { consistencyReport: {} } } }