Spaces:
Running
Running
File size: 40,032 Bytes
b99833e 4daef3d b99833e 4daef3d b99833e 4daef3d b99833e 4daef3d b99833e 4daef3d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 | <!DOCTYPE html>
<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>
|