import React from 'react'; import { useCopilotAction } from '@copilotkit/react-core'; import { blogWriterApi, BlogOutlineSection } from '../../services/blogWriterApi'; const useCopilotActionTyped = useCopilotAction as any; interface EnhancedOutlineActionsProps { outline: BlogOutlineSection[]; onOutlineUpdated: (outline: BlogOutlineSection[]) => void; } export const EnhancedOutlineActions: React.FC = ({ outline, onOutlineUpdated }) => { // Enhanced Outline Actions useCopilotActionTyped({ name: 'enhanceSection', description: 'Enhance a specific outline section with AI improvements', parameters: [ { name: 'sectionId', type: 'string', description: 'ID of the section to enhance', required: true }, { name: 'focus', type: 'string', description: 'Enhancement focus (SEO, engagement, depth, etc.)', required: false } ], handler: async ({ sectionId, focus = 'general improvement' }: { sectionId: string; focus?: string }) => { const section = outline.find(s => s.id === sectionId); if (!section) return { success: false, message: 'Section not found' }; try { const enhancedSection = await blogWriterApi.enhanceSection(section, focus); onOutlineUpdated(outline.map(s => s.id === sectionId ? enhancedSection : s)); return { success: true, message: `Enhanced section "${section.heading}" with focus on ${focus}`, enhanced_section: enhancedSection }; } catch (error) { return { success: false, message: `Enhancement failed: ${error}` }; } }, render: ({ status }: any) => { if (status === 'inProgress' || status === 'executing') { return (

✨ Enhancing Section

• Analyzing section content and structure...

• Generating enhanced subheadings and key points...

• Optimizing for better engagement and SEO...

); } return null; } }); useCopilotActionTyped({ name: 'optimizeOutline', description: 'Optimize entire outline for better flow, SEO, and engagement', parameters: [ { name: 'focus', type: 'string', description: 'Optimization focus (flow, SEO, engagement, etc.)', required: false } ], handler: async ({ focus = 'general optimization' }: { focus?: string }) => { if (outline.length === 0) return { success: false, message: 'No outline to optimize' }; try { const optimizedOutline = await blogWriterApi.optimizeOutline({ outline }, focus); onOutlineUpdated(optimizedOutline.outline); return { success: true, message: `Optimized outline with focus on ${focus}`, optimized_outline: optimizedOutline.outline }; } catch (error) { return { success: false, message: `Optimization failed: ${error}` }; } }, render: ({ status }: any) => { if (status === 'inProgress' || status === 'executing') { return (

🎯 Optimizing Outline

• Analyzing outline structure and flow...

• Optimizing headings for SEO and engagement...

• Improving narrative progression and reader experience...

); } return null; } }); useCopilotActionTyped({ name: 'rebalanceOutline', description: 'Rebalance word count distribution across outline sections', parameters: [ { name: 'targetWords', type: 'number', description: 'Target total word count', required: false } ], handler: async ({ targetWords = 1500 }: { targetWords?: number }) => { if (outline.length === 0) return { success: false, message: 'No outline to rebalance' }; try { const rebalancedOutline = await blogWriterApi.rebalanceOutline({ outline }, targetWords); onOutlineUpdated(rebalancedOutline.outline); return { success: true, message: `Rebalanced outline for ${targetWords} words`, rebalanced_outline: rebalancedOutline.outline }; } catch (error) { return { success: false, message: `Rebalancing failed: ${error}` }; } }, render: ({ status }: any) => { if (status === 'inProgress' || status === 'executing') { return (

⚖️ Rebalancing Word Counts

• Calculating optimal word distribution...

• Adjusting section word counts...

• Ensuring balanced content structure...

); } return null; } }); return null; // This component only provides the CopilotKit actions, no UI };