Spaces:
Running
You are an expert front-end architect and product designer.
Browse filesBuild a single-page web application called “TaskPilot” – a personal AI task agent UI. It should conceptually fuse two archetypes:
– MetaEvolver – adapts strategies and templates over time based on outcomes and feedback.
– AutoLoop – runs step-by-step workflows with progress tracking and loops until completion.
Tech stack
Use React + TypeScript + Vite + Tailwind CSS.
Everything runs client-side with mocked “AI” logic (no real backend calls required).
Core agent logic
Implement a TypeScript class TaskPilotAgent that represents the fusion of MetaEvolver + AutoLoop:
Public methods:
handleUserMessage(message: string, files: UploadedFile[]): Promise<AgentTurn>
startWorkflow(templateId: string, userInputs: Record<string,string>): AgentWorkflow
updateStepStatus(stepId: string, status: "pending" | "in_progress" | "done" | "skipped")
Internals:
Maintain workflows as arrays of WorkflowStep with titles, descriptions, status, and optional related files.
Maintain a policyState object with fields like detailLevel, tone, preferredWorkflowTemplates, recentSuccessRate.
Update policyState in response to thumbs-up/thumbs-down feedback and workflow completions.
AgentTurn should include: response message text, updated steps, a short reasoningTrace string, and the current policyState.
Workflow templates
Hard-code at least three example workflow templates to demonstrate the system:
Template A: “Take a Shopify store live.”
Template B: “Create a simple marketing website.”
Template C: “Review and improve a page’s UI/UX.”
Each template should define a list of WorkflowStep objects and accept simple parameters (like store name or URL) to slightly customize the steps.
Data models (TypeScript interfaces)
ChatMessage: { id: string; role: "user" | "agent"; text: string; timestamp: string; workflowStepId?: string; }
UploadedFile: { id: string; name: string; size: number; type: string; textPreview?: string; }
WorkflowStep: { id: string; title: string; description: string; status: "pending" | "in_progress" | "done" | "skipped"; relatedFiles?: string[]; }
AgentWorkflow: { id: string; name: string; steps: WorkflowStep[]; }
PolicyState: { detailLevel: "low" | "medium" | "high"; tone: "concise" | "neutral" | "detailed"; preferredWorkflowTemplates: string[]; recentSuccessRate: number; }
AgentTurn: { responseMessage: string; steps: WorkflowStep[]; reasoningTrace: string; policyState: PolicyState; }
Layout & components
Build a responsive, 3-panel SPA with Tailwind styling:
Left panel – Chat
Component: ChatPanel.
Shows ChatMessage history as user/agent bubbles.
Bottom area:
Multiline text input.
“Send” button.
Each agent message includes thumbs-up/thumbs-down controls that call back into TaskPilotAgent to update policyState.
Middle panel – Workflows
Component: WorkflowPanel.
Dropdown to select a workflow template (Shopify live, website creation, UI/UX review, and a “Custom” option).
Button to start a workflow via startWorkflow.
Vertical list of WorkflowStep cards showing title, description, and status pill.
Each step card has buttons to set status (Start, Done, Skip) via updateStepStatus.
Right panel – Files & Inspector
Component: FilesInspectorPanel.
File upload area with drag-and-drop and “Browse” button.
List of uploaded files (UploadedFile objects) with remove button.
For text-like files (txt, md, json), use FileReader to populate textPreview with first lines.
Below file list, show:
Current policyState rendered as formatted JSON.
The latest reasoningTrace string from TaskPilotAgent.
File handling
Accept multiple files.
Store them in React state as UploadedFile[].
Provide hooks or callbacks so TaskPilotAgent.handleUserMessage can inspect filenames, types, and textPreview.
Styling & UX
Use Tailwind to create a clean, minimal SaaS UI with a slightly dark theme (e.g., slate backgrounds, subtle cards, clear typography).
Ensure layout is responsive for desktop and tablet.
Project structure
src/main.tsx – Vite/React entry.
src/App.tsx – top-level layout, creates a single TaskPilotAgent instance and passes it to panels via props or context.
src/agent/TaskPilotAgent.ts – contains the agent logic, workflow templates, and policyState management.
src/components/ChatPanel.tsx
src/components/WorkflowPanel.tsx
src/components/FilesInspectorPanel.tsx
Tailwind setup files as required by Vite.
Extensibility notes
In TaskPilotAgent.ts, add clear comments indicating where real LLM calls, external APIs, or persistent storage could be integrated later.
Ensure the app runs from a standard Vite + React + TypeScript + Tailwind setup with npm install and npm run dev.
Files changed (2)
- README.md+8-5
- index.html+789-19
12345678910---title: Taskpilotemoji: 👁colorFrom: redcolorTo: purplesdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213---title: TaskPilot 🚀colorFrom: bluecolorTo: blueemoji: 🐳sdk: staticpinned: falsetags:- deepsite-v3---# Welcome to your new DeepSite project!This project was created with [DeepSite](https://huggingface.co/deepsite).
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><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>"><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><style>@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');body {font-family: 'Inter', sans-serif;background-color: #0f172a;color: #f1f5f9;}.panel-border {border-right: 1px solid #1e293b;}.step-card {transition: all 0.3s ease;}.step-card:hover {transform: translateY(-2px);box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);}.status-pending { background-color: #475569; }.status-in-progress { background-color: #0ea5e9; }.status-done { background-color: #10b981; }.status-skipped { background-color: #64748b; }.file-preview {max-height: 100px;overflow-y: auto;}</style></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 type="text/babel" data-type="module">// Import necessary React featuresconst { useState, useEffect, useRef, createContext, useContext } = React;// Interfacesconst 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, skippedrelatedFiles: []};const AgentWorkflow = {id: '',name: '',steps: []};const PolicyState = {detailLevel: 'medium', // low, medium, hightone: 'neutral', // concise, neutral, detailedpreferredWorkflowTemplates: [],recentSuccessRate: 0.85};const AgentTurn = {responseMessage: '',steps: [],reasoningTrace: '',policyState: PolicyState};// TaskPilotAgent Classclass 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 delayawait new Promise(resolve => setTimeout(resolve, 800));// Simple response logic based on message contentlet 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 contentif (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 inputsconst 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 completionconst 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 templatesif (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 confidentthis.policyState.tone = "detailed";} else {// Decrease preference for current templatesif (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 cautiousthis.policyState.tone = "concise";}}}// Create agent instanceconst agentInstance = new TaskPilotAgent();// Context for sharing agent between componentsconst AgentContext = createContext();// Chat Panel Componentconst 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) => (<divkey={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"><buttononClick={() => onFeedback(true)}className="p-1 text-slate-400 hover:text-green-400 transition-colors"title="Helpful"><i data-feather="thumbs-up"></i></button><buttononClick={() => 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"><textareavalue={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"/><buttontype="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 Componentconst 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><selectvalue={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><inputtype="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>)}<buttononClick={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' && (<buttononClick={() => 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') && (<buttononClick={() => 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' && (<buttononClick={() => 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 Componentconst 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"><buttononClick={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><inputtype="file"ref={fileInputRef}onChange={handleFileChange}multipleclassName="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><buttononClick={() => 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 Componentconst 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 messageconst userMessage = {id: `msg-${Date.now()}`,role: 'user',text: text,timestamp: new Date().toISOString()};setMessages(prev => [...prev, userMessage]);// Get agent responseconst turn = await agentInstance.handleUserMessage(text, files);// Add agent messageconst 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 messageconst 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 messageconst 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 previewif (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"><ChatPanelmessages={messages}onSendMessage={handleSendMessage}onFeedback={handleFeedback}/></div>{/* Workflow Panel - Middle */}<div className="w-1/3 panel-border flex flex-col"><WorkflowPanelworkflows={workflows}onStartWorkflow={handleStartWorkflow}onUpdateStepStatus={handleUpdateStepStatus}/></div>{/* Files & Inspector Panel - Right */}<div className="w-1/3 flex flex-col"><FilesInspectorPanelfiles={files}onFileUpload={handleFileUpload}onRemoveFile={handleRemoveFile}policyState={policyState}reasoningTrace={reasoningTrace}/></div></div></div></AgentContext.Provider>);};// Render the appconst root = ReactDOM.createRoot(document.getElementById('root'));root.render(<App />);</script><script src="https://huggingface.co/deepsite/deepsite-badge.js"></script></body></html>