Spaces:
Running
Running
Download index.html from Destiny369963/taskpilot: direct link, hf CLI and curl.
- Browser
- Download file 40 kB
-
https://huggingface.co/spaces/Destiny369963/taskpilot/resolve/main/index.html
- Command line
-
hf download hf://spaces/Destiny369963/taskpilot/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Destiny369963/taskpilot/resolve/main/index.html
40 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta name="description" content="TaskPilot is your personal AI task agent that helps you manage workflows, track tasks, and provide insights."> | |
| <meta name="keywords" content="AI, task management, workflow, productivity, automation"> | |
| <title>TaskPilot - Your Personal AI Task Agent</title> | |
| <link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🚀</text></svg>"> | |
| <link rel="stylesheet" href="style.css"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script> | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| primary: { | |
| 50: '#fff1f2', | |
| 100: '#ffe4e6', | |
| 200: '#fecdd3', | |
| 300: '#fda4af', | |
| 400: '#fb7185', | |
| 500: '#f43f5e', | |
| 600: '#e11d48', | |
| 700: '#be123c', | |
| 800: '#9f1239', | |
| 900: '#881337', | |
| 950: '#4c0519' | |
| }, | |
| secondary: { | |
| 50: '#fefce8', | |
| 100: '#fef9c3', | |
| 200: '#fef08a', | |
| 300: '#fde047', | |
| 400: '#facc15', | |
| 500: '#eab308', | |
| 600: '#ca8a04', | |
| 700: '#a16207', | |
| 800: '#854d0e', | |
| 900: '#713f12', | |
| 950: '#422006' | |
| } | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| </head> | |
| <body class="bg-slate-900 text-slate-100 min-h-screen"> | |
| <div id="root" class="min-h-screen"></div> | |
| <!-- React & ReactDOM --> | |
| <script src="https://unpkg.com/react@18/umd/react.development.js"></script> | |
| <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script> | |
| <!-- Babel for JSX processing --> | |
| <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
| <!-- Main App Script --> | |
| <script src="script.js"></script> | |
| <script type="text/babel" data-type="module"> | |
| // Import necessary React features | |
| const { useState, useEffect, useRef, createContext, useContext } = React; | |
| // Interfaces | |
| const ChatMessage = { | |
| id: '', | |
| role: 'user', // or 'agent' | |
| text: '', | |
| timestamp: '', | |
| workflowStepId: undefined | |
| }; | |
| const UploadedFile = { | |
| id: '', | |
| name: '', | |
| size: 0, | |
| type: '', | |
| textPreview: undefined | |
| }; | |
| const WorkflowStep = { | |
| id: '', | |
| title: '', | |
| description: '', | |
| status: 'pending', // pending, in_progress, done, skipped | |
| relatedFiles: [] | |
| }; | |
| const AgentWorkflow = { | |
| id: '', | |
| name: '', | |
| steps: [] | |
| }; | |
| const PolicyState = { | |
| detailLevel: 'medium', // low, medium, high | |
| tone: 'neutral', // concise, neutral, detailed | |
| preferredWorkflowTemplates: [], | |
| recentSuccessRate: 0.85 | |
| }; | |
| const AgentTurn = { | |
| responseMessage: '', | |
| steps: [], | |
| reasoningTrace: '', | |
| policyState: PolicyState | |
| }; | |
| // TaskPilotAgent Class | |
| class TaskPilotAgent { | |
| constructor() { | |
| this.policyState = { ...PolicyState }; | |
| this.workflows = []; | |
| this.workflowTemplates = { | |
| 'shopify': { | |
| id: 'shopify', | |
| name: 'Take a Shopify store live', | |
| steps: [ | |
| { id: 's1', title: 'Configure domain settings', description: 'Set up custom domain for the store', status: 'pending', relatedFiles: [] }, | |
| { id: 's2', title: 'Add payment gateways', description: 'Configure accepted payment methods', status: 'pending', relatedFiles: [] }, | |
| { id: 's3', title: 'Set up shipping zones', description: 'Define shipping regions and rates', status: 'pending', relatedFiles: [] }, | |
| { id: 's4', title: 'Review tax settings', description: 'Configure tax calculations for products', status: 'pending', relatedFiles: [] }, | |
| { id: 's5', title: 'Launch store', description: 'Remove password protection and go live', status: 'pending', relatedFiles: [] } | |
| ] | |
| }, | |
| 'website': { | |
| id: 'website', | |
| name: 'Create a simple marketing website', | |
| steps: [ | |
| { id: 'w1', title: 'Define target audience', description: 'Identify key demographics and personas', status: 'pending', relatedFiles: [] }, | |
| { id: 'w2', title: 'Create site map', description: 'Plan website structure and navigation', status: 'pending', relatedFiles: [] }, | |
| { id: 'w3', title: 'Design homepage layout', description: 'Create wireframes for key landing page', status: 'pending', relatedFiles: [] }, | |
| { id: 'w4', title: 'Develop core pages', description: 'Build About, Services, and Contact pages', status: 'pending', relatedFiles: [] }, | |
| { id: 'w5', title: 'Test and launch', description: 'Perform QA testing and deploy to production', status: 'pending', relatedFiles: [] } | |
| ] | |
| }, | |
| 'ux-review': { | |
| id: 'ux-review', | |
| name: 'Review and improve a page’s UI/UX', | |
| steps: [ | |
| { id: 'u1', title: 'Heuristic evaluation', description: 'Assess against UX best practices', status: 'pending', relatedFiles: [] }, | |
| { id: 'u2', title: 'User flow analysis', description: 'Map current navigation paths', status: 'pending', relatedFiles: [] }, | |
| { id: 'u3', title: 'Accessibility check', description: 'Verify WCAG compliance standards', status: 'pending', relatedFiles: [] }, | |
| { id: 'u4', title: 'Performance audit', description: 'Analyze loading times and optimizations', status: 'pending', relatedFiles: [] }, | |
| { id: 'u5', title: 'Implement improvements', description: 'Apply recommended changes to interface', status: 'pending', relatedFiles: [] } | |
| ] | |
| } | |
| }; | |
| } | |
| async handleUserMessage(message, files = []) { | |
| // Mock AI processing delay | |
| await new Promise(resolve => setTimeout(resolve, 800)); | |
| // Simple response logic based on message content | |
| let response = "I've received your message. How can I assist you further?"; | |
| let reasoning = "Processed user input"; | |
| if (message.toLowerCase().includes("hello") || message.toLowerCase().includes("hi")) { | |
| response = "Hello! I'm TaskPilot, your AI task assistant. How can I help you today?"; | |
| reasoning = "Greeting detected, provided welcome message"; | |
| } else if (message.toLowerCase().includes("help")) { | |
| response = "I can help you manage workflows, track tasks, and provide insights. Try asking me to start a workflow or analyze a task."; | |
| reasoning = "Help request detected, provided assistance options"; | |
| } else if (files.length > 0) { | |
| response = `I see you've uploaded ${files.length} file(s). I can analyze these to help with your tasks.`; | |
| reasoning = "Files detected in message, acknowledged attachment"; | |
| } | |
| // Update policy based on message content | |
| if (message.length > 100) { | |
| this.policyState.detailLevel = "detailed"; | |
| reasoning += ". User provided detailed input, increasing detail level."; | |
| } else if (message.length < 20) { | |
| this.policyState.detailLevel = "concise"; | |
| reasoning += ". User provided brief input, setting concise mode."; | |
| } | |
| return { | |
| responseMessage: response, | |
| steps: this.workflows.length > 0 ? [...this.workflows[0].steps] : [], | |
| reasoningTrace: reasoning, | |
| policyState: { ...this.policyState } | |
| }; | |
| } | |
| startWorkflow(templateId, userInputs = {}) { | |
| const template = this.workflowTemplates[templateId]; | |
| if (!template) { | |
| throw new Error(`Template ${templateId} not found`); | |
| } | |
| // Customize steps based on user inputs | |
| const customizedSteps = template.steps.map(step => { | |
| let description = step.description; | |
| if (templateId === 'shopify' && userInputs.storeName) { | |
| description = description.replace('store', `${userInputs.storeName} store`); | |
| } | |
| return { ...step, description }; | |
| }); | |
| const workflow = { | |
| id: `wf-${Date.now()}`, | |
| name: template.name, | |
| steps: customizedSteps | |
| }; | |
| this.workflows = [workflow]; | |
| return workflow; | |
| } | |
| updateStepStatus(stepId, status) { | |
| for (const workflow of this.workflows) { | |
| const step = workflow.steps.find(s => s.id === stepId); | |
| if (step) { | |
| step.status = status; | |
| break; | |
| } | |
| } | |
| // Update policy based on completion | |
| const allSteps = this.workflows.flatMap(wf => wf.steps); | |
| const completedSteps = allSteps.filter(s => s.status === 'done').length; | |
| const totalSteps = allSteps.length; | |
| if (totalSteps > 0) { | |
| this.policyState.recentSuccessRate = completedSteps / totalSteps; | |
| } | |
| return this.workflows.length > 0 ? [...this.workflows[0].steps] : []; | |
| } | |
| handleFeedback(isPositive) { | |
| if (isPositive) { | |
| // Increase preference for current templates | |
| if (this.workflows.length > 0) { | |
| const currentTemplate = this.workflows[0].name; | |
| if (!this.policyState.preferredWorkflowTemplates.includes(currentTemplate)) { | |
| this.policyState.preferredWorkflowTemplates.push(currentTemplate); | |
| } | |
| } | |
| // Adjust tone to be more confident | |
| this.policyState.tone = "detailed"; | |
| } else { | |
| // Decrease preference for current templates | |
| if (this.workflows.length > 0) { | |
| const currentTemplate = this.workflows[0].name; | |
| this.policyState.preferredWorkflowTemplates = | |
| this.policyState.preferredWorkflowTemplates.filter(t => t !== currentTemplate); | |
| } | |
| // Adjust tone to be more cautious | |
| this.policyState.tone = "concise"; | |
| } | |
| } | |
| } | |
| // Create agent instance | |
| const agentInstance = new TaskPilotAgent(); | |
| // Context for sharing agent between components | |
| const AgentContext = createContext(); | |
| // Chat Panel Component | |
| const ChatPanel = ({ messages, onSendMessage, onFeedback }) => { | |
| const [inputText, setInputText] = useState(''); | |
| const messagesEndRef = useRef(null); | |
| const scrollToBottom = () => { | |
| messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); | |
| }; | |
| useEffect(() => { | |
| scrollToBottom(); | |
| }, [messages]); | |
| const handleSubmit = (e) => { | |
| e.preventDefault(); | |
| if (inputText.trim()) { | |
| onSendMessage(inputText); | |
| setInputText(''); | |
| } | |
| }; | |
| return ( | |
| <div className="flex flex-col h-full"> | |
| <div className="p-4 border-b border-slate-800"> | |
| <h2 className="text-xl font-bold text-primary-400">TaskPilot Chat</h2> | |
| <p className="text-sm text-slate-400">Your AI task assistant</p> | |
| </div> | |
| <div className="flex-1 overflow-y-auto p-4 space-y-4"> | |
| {messages.map((msg) => ( | |
| <div | |
| key={msg.id} | |
| className={`p-4 rounded-lg max-w-[80%] ${ | |
| msg.role === 'user' | |
| ? 'bg-slate-800 ml-auto' | |
| : 'bg-slate-700 mr-auto' | |
| }`} | |
| > | |
| <div className="flex items-start gap-2"> | |
| {msg.role === 'agent' && ( | |
| <div className="mt-1 flex-shrink-0 w-6 h-6 rounded-full bg-primary-500 flex items-center justify-center"> | |
| <i data-feather="cpu" className="w-4 h-4"></i> | |
| </div> | |
| )} | |
| <div className="flex-1"> | |
| <p className="whitespace-pre-wrap">{msg.text}</p> | |
| {msg.role === 'agent' && ( | |
| <div className="flex gap-2 mt-2"> | |
| <button | |
| onClick={() => onFeedback(true)} | |
| className="p-1 text-slate-400 hover:text-green-400 transition-colors" | |
| title="Helpful" | |
| > | |
| <i data-feather="thumbs-up"></i> | |
| </button> | |
| <button | |
| onClick={() => onFeedback(false)} | |
| className="p-1 text-slate-400 hover:text-red-400 transition-colors" | |
| title="Not helpful" | |
| > | |
| <i data-feather="thumbs-down"></i> | |
| </button> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| ))} | |
| <div ref={messagesEndRef} /> | |
| </div> | |
| <form onSubmit={handleSubmit} className="p-4 border-t border-slate-800"> | |
| <div className="flex gap-2"> | |
| <textarea | |
| value={inputText} | |
| onChange={(e) => setInputText(e.target.value)} | |
| placeholder="Message TaskPilot..." | |
| className="flex-1 bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500 resize-none" | |
| rows="2" | |
| /> | |
| <button | |
| type="submit" | |
| className="bg-primary-600 hover:bg-primary-700 text-white rounded-lg px-4 py-2 font-medium transition-colors flex items-center gap-2" | |
| > | |
| <i data-feather="send"></i> | |
| Send | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| ); | |
| }; | |
| // Workflow Panel Component | |
| const WorkflowPanel = ({ workflows, onStartWorkflow, onUpdateStepStatus }) => { | |
| const [selectedTemplate, setSelectedTemplate] = useState(''); | |
| const [userInputs, setUserInputs] = useState({}); | |
| const handleStartWorkflow = () => { | |
| if (selectedTemplate) { | |
| onStartWorkflow(selectedTemplate, userInputs); | |
| setUserInputs({}); | |
| } | |
| }; | |
| const currentWorkflow = workflows.length > 0 ? workflows[0] : null; | |
| return ( | |
| <div className="flex flex-col h-full"> | |
| <div className="p-4 border-b border-slate-800"> | |
| <h2 className="text-xl font-bold text-primary-400">Workflows</h2> | |
| <p className="text-sm text-slate-400">Manage your task sequences</p> | |
| </div> | |
| {!currentWorkflow ? ( | |
| <div className="p-4 space-y-4"> | |
| <div> | |
| <label className="block text-sm font-medium mb-2">Select Template</label> | |
| <select | |
| value={selectedTemplate} | |
| onChange={(e) => setSelectedTemplate(e.target.value)} | |
| className="w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500" | |
| > | |
| <option value="">Choose a workflow...</option> | |
| <option value="shopify">Take a Shopify store live</option> | |
| <option value="website">Create a simple marketing website</option> | |
| <option value="ux-review">Review and improve a page's UI/UX</option> | |
| </select> | |
| </div> | |
| {selectedTemplate === 'shopify' && ( | |
| <div> | |
| <label className="block text-sm font-medium mb-2">Store Name</label> | |
| <input | |
| type="text" | |
| value={userInputs.storeName || ''} | |
| onChange={(e) => setUserInputs({...userInputs, storeName: e.target.value})} | |
| placeholder="Enter store name" | |
| className="w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500" | |
| /> | |
| </div> | |
| )} | |
| <button | |
| onClick={handleStartWorkflow} | |
| disabled={!selectedTemplate} | |
| className={`w-full py-2 px-4 rounded-lg font-medium transition-colors ${ | |
| selectedTemplate | |
| ? 'bg-primary-600 hover:bg-primary-700 text-white' | |
| : 'bg-slate-800 text-slate-500 cursor-not-allowed' | |
| }`} | |
| > | |
| Start Workflow | |
| </button> | |
| </div> | |
| ) : ( | |
| <div className="flex-1 overflow-y-auto"> | |
| <div className="p-4 border-b border-slate-800"> | |
| <div className="flex justify-between items-center"> | |
| <h3 className="font-semibold">{currentWorkflow.name}</h3> | |
| <span className="text-xs bg-slate-800 px-2 py-1 rounded"> | |
| {currentWorkflow.steps.filter(s => s.status === 'done').length}/{currentWorkflow.steps.length} completed | |
| </span> | |
| </div> | |
| </div> | |
| <div className="p-4 space-y-4"> | |
| {currentWorkflow.steps.map((step) => ( | |
| <div key={step.id} className="step-card bg-slate-800 rounded-lg p-4 border border-slate-700"> | |
| <div className="flex justify-between items-start"> | |
| <div> | |
| <h4 className="font-medium">{step.title}</h4> | |
| <p className="text-sm text-slate-400 mt-1">{step.description}</p> | |
| </div> | |
| <span className={`px-2 py-1 rounded-full text-xs font-medium capitalize ${ | |
| step.status === 'pending' ? 'status-pending' : | |
| step.status === 'in_progress' ? 'status-in-progress' : | |
| step.status === 'done' ? 'status-done' : 'status-skipped' | |
| }`}> | |
| {step.status.replace('_', ' ')} | |
| </span> | |
| </div> | |
| <div className="flex gap-2 mt-3"> | |
| {step.status === 'pending' && ( | |
| <button | |
| onClick={() => onUpdateStepStatus(step.id, 'in_progress')} | |
| className="text-xs bg-blue-600 hover:bg-blue-700 text-white px-2 py-1 rounded transition-colors" | |
| > | |
| Start | |
| </button> | |
| )} | |
| {(step.status === 'pending' || step.status === 'in_progress') && ( | |
| <button | |
| onClick={() => onUpdateStepStatus(step.id, 'done')} | |
| className="text-xs bg-green-600 hover:bg-green-700 text-white px-2 py-1 rounded transition-colors" | |
| > | |
| Mark Done | |
| </button> | |
| )} | |
| {step.status === 'pending' && ( | |
| <button | |
| onClick={() => onUpdateStepStatus(step.id, 'skipped')} | |
| className="text-xs bg-slate-700 hover:bg-slate-600 text-white px-2 py-1 rounded transition-colors" | |
| > | |
| Skip | |
| </button> | |
| )} | |
| </div> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| }; | |
| // Files Inspector Panel Component | |
| const FilesInspectorPanel = ({ files, onFileUpload, onRemoveFile, policyState, reasoningTrace }) => { | |
| const fileInputRef = useRef(null); | |
| const handleFileChange = (e) => { | |
| const newFiles = Array.from(e.target.files); | |
| onFileUpload(newFiles); | |
| }; | |
| const triggerFileInput = () => { | |
| fileInputRef.current.click(); | |
| }; | |
| return ( | |
| <div className="flex flex-col h-full"> | |
| <div className="p-4 border-b border-slate-800"> | |
| <h2 className="text-xl font-bold text-primary-400">Files & Inspector</h2> | |
| <p className="text-sm text-slate-400">Manage attachments and view insights</p> | |
| </div> | |
| <div className="p-4 border-b border-slate-800"> | |
| <button | |
| onClick={triggerFileInput} | |
| className="w-full py-2 px-4 bg-slate-800 hover:bg-slate-700 border border-dashed border-slate-600 rounded-lg flex flex-col items-center justify-center gap-2 transition-colors" | |
| > | |
| <i data-feather="upload" className="text-slate-400"></i> | |
| <span className="text-sm">Drag & drop files or click to browse</span> | |
| <input | |
| type="file" | |
| ref={fileInputRef} | |
| onChange={handleFileChange} | |
| multiple | |
| className="hidden" | |
| /> | |
| </button> | |
| </div> | |
| <div className="flex-1 overflow-y-auto p-4 space-y-4"> | |
| <div> | |
| <h3 className="font-medium mb-2">Uploaded Files ({files.length})</h3> | |
| {files.length === 0 ? ( | |
| <p className="text-sm text-slate-500 italic">No files uploaded yet</p> | |
| ) : ( | |
| <div className="space-y-2"> | |
| {files.map((file) => ( | |
| <div key={file.id} className="bg-slate-800 rounded-lg p-3 border border-slate-700"> | |
| <div className="flex justify-between"> | |
| <div className="flex items-center gap-2"> | |
| <i data-feather="file-text" className="text-slate-400"></i> | |
| <div> | |
| <p className="text-sm font-medium truncate max-w-[160px]">{file.name}</p> | |
| <p className="text-xs text-slate-500">{(file.size / 1024).toFixed(1)} KB</p> | |
| </div> | |
| </div> | |
| <button | |
| onClick={() => onRemoveFile(file.id)} | |
| className="text-slate-500 hover:text-red-400" | |
| > | |
| <i data-feather="x"></i> | |
| </button> | |
| </div> | |
| {file.textPreview && ( | |
| <div className="mt-2 text-xs bg-slate-900 p-2 rounded file-preview"> | |
| <pre className="whitespace-pre-wrap">{file.textPreview}</pre> | |
| </div> | |
| )} | |
| </div> | |
| ))} | |
| </div> | |
| )} | |
| </div> | |
| <div> | |
| <h3 className="font-medium mb-2">Policy State</h3> | |
| <div className="bg-slate-800 rounded-lg p-3 border border-slate-700"> | |
| <pre className="text-xs overflow-x-auto">{JSON.stringify(policyState, null, 2)}</pre> | |
| </div> | |
| </div> | |
| <div> | |
| <h3 className="font-medium mb-2">Reasoning Trace</h3> | |
| <div className="bg-slate-800 rounded-lg p-3 border border-slate-700"> | |
| <p className="text-sm">{reasoningTrace || 'No reasoning trace available'}</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| }; | |
| // Main App Component | |
| const App = () => { | |
| const [messages, setMessages] = useState([ | |
| { | |
| id: '1', | |
| role: 'agent', | |
| text: 'Hello! I\'m TaskPilot, your AI task assistant. I can help you manage workflows, track tasks, and provide insights. What would you like to work on today?', | |
| timestamp: new Date().toISOString() | |
| } | |
| ]); | |
| const [files, setFiles] = useState([]); | |
| const [workflows, setWorkflows] = useState([]); | |
| const [policyState, setPolicyState] = useState(agentInstance.policyState); | |
| const [reasoningTrace, setReasoningTrace] = useState(''); | |
| const handleSendMessage = async (text) => { | |
| // Add user message | |
| const userMessage = { | |
| id: `msg-${Date.now()}`, | |
| role: 'user', | |
| text: text, | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages(prev => [...prev, userMessage]); | |
| // Get agent response | |
| const turn = await agentInstance.handleUserMessage(text, files); | |
| // Add agent message | |
| const agentMessage = { | |
| id: `msg-${Date.now() + 1}`, | |
| role: 'agent', | |
| text: turn.responseMessage, | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages(prev => [...prev, agentMessage]); | |
| setPolicyState(turn.policyState); | |
| setReasoningTrace(turn.reasoningTrace); | |
| }; | |
| const handleStartWorkflow = (templateId, userInputs) => { | |
| try { | |
| const workflow = agentInstance.startWorkflow(templateId, userInputs); | |
| setWorkflows([workflow]); | |
| // Add notification message | |
| const templateNames = { | |
| 'shopify': 'Shopify Store Launch', | |
| 'website': 'Marketing Website Creation', | |
| 'ux-review': 'UI/UX Review' | |
| }; | |
| const message = { | |
| id: `msg-${Date.now()}`, | |
| role: 'agent', | |
| text: `I've started the "${templateNames[templateId]}" workflow for you. You can track progress in the Workflows panel.`, | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages(prev => [...prev, message]); | |
| } catch (error) { | |
| console.error('Error starting workflow:', error); | |
| } | |
| }; | |
| const handleUpdateStepStatus = (stepId, status) => { | |
| const updatedSteps = agentInstance.updateStepStatus(stepId, status); | |
| setWorkflows(prev => prev.length > 0 ? [{...prev[0], steps: updatedSteps}] : []); | |
| setPolicyState({...agentInstance.policyState}); | |
| }; | |
| const handleFeedback = (isPositive) => { | |
| agentInstance.handleFeedback(isPositive); | |
| setPolicyState({...agentInstance.policyState}); | |
| // Add confirmation message | |
| const message = { | |
| id: `msg-${Date.now()}`, | |
| role: 'agent', | |
| text: isPositive | |
| ? 'Thanks for the feedback! I\'ll continue providing responses like this.' | |
| : 'Thanks for the feedback. I\'ll adjust my approach accordingly.', | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages(prev => [...prev, message]); | |
| }; | |
| const handleFileUpload = (newFiles) => { | |
| const processedFiles = newFiles.map(file => { | |
| const reader = new FileReader(); | |
| let textPreview = ''; | |
| // For text files, read content preview | |
| if (file.type.startsWith('text/') || file.name.endsWith('.json')) { | |
| reader.onload = (e) => { | |
| textPreview = e.target.result.substring(0, 200); | |
| setFiles(prev => prev.map(f => | |
| f.name === file.name ? {...f, textPreview} : f | |
| )); | |
| }; | |
| reader.readAsText(file); | |
| } | |
| return { | |
| id: `file-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, | |
| name: file.name, | |
| size: file.size, | |
| type: file.type, | |
| textPreview | |
| }; | |
| }); | |
| setFiles(prev => [...prev, ...processedFiles]); | |
| }; | |
| const handleRemoveFile = (fileId) => { | |
| setFiles(prev => prev.filter(file => file.id !== fileId)); | |
| }; | |
| useEffect(() => { | |
| feather.replace(); | |
| }, [messages, files, workflows]); | |
| return ( | |
| <AgentContext.Provider value={agentInstance}> | |
| <div className="flex flex-col h-screen"> | |
| {/* Header */} | |
| <header className="bg-slate-800 border-b border-slate-700 p-4"> | |
| <div className="flex items-center justify-between"> | |
| <div className="flex items-center gap-3"> | |
| <div className="w-10 h-10 rounded-lg bg-gradient-to-br from-primary-500 to-secondary-500 flex items-center justify-center"> | |
| <i data-feather="cpu" className="text-white"></i> | |
| </div> | |
| <div> | |
| <h1 className="text-xl font-bold">TaskPilot</h1> | |
| <p className="text-xs text-slate-400">Your Personal AI Task Agent</p> | |
| </div> | |
| </div> | |
| <div className="flex items-center gap-2"> | |
| <span className="px-2 py-1 bg-slate-700 text-xs rounded-full">MetaEvolver</span> | |
| <span className="px-2 py-1 bg-slate-700 text-xs rounded-full">AutoLoop</span> | |
| </div> | |
| </div> | |
| </header> | |
| {/* Main Content */} | |
| <div className="flex flex-1 overflow-hidden"> | |
| {/* Chat Panel - Left */} | |
| <div className="w-1/3 panel-border flex flex-col"> | |
| <ChatPanel | |
| messages={messages} | |
| onSendMessage={handleSendMessage} | |
| onFeedback={handleFeedback} | |
| /> | |
| </div> | |
| {/* Workflow Panel - Middle */} | |
| <div className="w-1/3 panel-border flex flex-col"> | |
| <WorkflowPanel | |
| workflows={workflows} | |
| onStartWorkflow={handleStartWorkflow} | |
| onUpdateStepStatus={handleUpdateStepStatus} | |
| /> | |
| </div> | |
| {/* Files & Inspector Panel - Right */} | |
| <div className="w-1/3 flex flex-col"> | |
| <FilesInspectorPanel | |
| files={files} | |
| onFileUpload={handleFileUpload} | |
| onRemoveFile={handleRemoveFile} | |
| policyState={policyState} | |
| reasoningTrace={reasoningTrace} | |
| /> | |
| </div> | |
| </div> | |
| </div> | |
| </AgentContext.Provider> | |
| ); | |
| }; | |
| // Render the app | |
| const root = ReactDOM.createRoot(document.getElementById('root')); | |
| root.render(<App />); | |
| </script> | |
| <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script> | |
| </body> | |
| </html> | |