Faça funcionar a página e simular a contração de um agente
Browse files- index.html +190 -10
index.html
CHANGED
|
@@ -68,11 +68,11 @@
|
|
| 68 |
<h1 class="text-xl font-bold text-gray-900">AgentFlow Builder</h1>
|
| 69 |
</div>
|
| 70 |
<div class="flex items-center space-x-4">
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
<i data-feather="save" class="w-4 h-4"></i>
|
| 77 |
<span>Save</span>
|
| 78 |
</button>
|
|
@@ -231,7 +231,6 @@
|
|
| 231 |
</div>
|
| 232 |
</div>
|
| 233 |
</div>
|
| 234 |
-
|
| 235 |
<script>
|
| 236 |
document.addEventListener('DOMContentLoaded', function() {
|
| 237 |
feather.replace();
|
|
@@ -243,8 +242,9 @@
|
|
| 243 |
let offsetX = 0;
|
| 244 |
let offsetY = 0;
|
| 245 |
let connections = [];
|
| 246 |
-
|
| 247 |
-
|
|
|
|
| 248 |
document.querySelectorAll('.node[draggable="true"]').forEach(node => {
|
| 249 |
node.addEventListener('dragstart', function(e) {
|
| 250 |
e.dataTransfer.setData('text/plain', JSON.stringify({
|
|
@@ -492,7 +492,6 @@
|
|
| 492 |
makeNodeDraggable(node);
|
| 493 |
addConnectionPoints(node);
|
| 494 |
});
|
| 495 |
-
|
| 496 |
// Add some sample connections
|
| 497 |
setTimeout(() => {
|
| 498 |
createConnection(
|
|
@@ -504,7 +503,188 @@
|
|
| 504 |
{ node: 'output-1', type: 'input' }
|
| 505 |
);
|
| 506 |
}, 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
});
|
| 508 |
-
|
| 509 |
</body>
|
| 510 |
</html>
|
|
|
|
| 68 |
<h1 class="text-xl font-bold text-gray-900">AgentFlow Builder</h1>
|
| 69 |
</div>
|
| 70 |
<div class="flex items-center space-x-4">
|
| 71 |
+
<button id="run-agent" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center space-x-2">
|
| 72 |
+
<i data-feather="play" class="w-4 h-4"></i>
|
| 73 |
+
<span>Run Agent</span>
|
| 74 |
+
</button>
|
| 75 |
+
<button class="px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors flex items-center space-x-2">
|
| 76 |
<i data-feather="save" class="w-4 h-4"></i>
|
| 77 |
<span>Save</span>
|
| 78 |
</button>
|
|
|
|
| 231 |
</div>
|
| 232 |
</div>
|
| 233 |
</div>
|
|
|
|
| 234 |
<script>
|
| 235 |
document.addEventListener('DOMContentLoaded', function() {
|
| 236 |
feather.replace();
|
|
|
|
| 242 |
let offsetX = 0;
|
| 243 |
let offsetY = 0;
|
| 244 |
let connections = [];
|
| 245 |
+
let isRunning = false;
|
| 246 |
+
let currentExecution = null;
|
| 247 |
+
// Drag and drop functionality
|
| 248 |
document.querySelectorAll('.node[draggable="true"]').forEach(node => {
|
| 249 |
node.addEventListener('dragstart', function(e) {
|
| 250 |
e.dataTransfer.setData('text/plain', JSON.stringify({
|
|
|
|
| 492 |
makeNodeDraggable(node);
|
| 493 |
addConnectionPoints(node);
|
| 494 |
});
|
|
|
|
| 495 |
// Add some sample connections
|
| 496 |
setTimeout(() => {
|
| 497 |
createConnection(
|
|
|
|
| 503 |
{ node: 'output-1', type: 'input' }
|
| 504 |
);
|
| 505 |
}, 100);
|
| 506 |
+
|
| 507 |
+
// Run Agent functionality
|
| 508 |
+
document.getElementById('run-agent').addEventListener('click', function() {
|
| 509 |
+
if (isRunning) {
|
| 510 |
+
stopExecution();
|
| 511 |
+
} else {
|
| 512 |
+
startExecution();
|
| 513 |
+
}
|
| 514 |
+
});
|
| 515 |
+
|
| 516 |
+
function startExecution() {
|
| 517 |
+
if (isRunning) return;
|
| 518 |
+
|
| 519 |
+
isRunning = true;
|
| 520 |
+
const runButton = document.getElementById('run-agent');
|
| 521 |
+
runButton.innerHTML = '<i data-feather="square" class="w-4 h-4"></i><span>Stop</span>';
|
| 522 |
+
feather.replace();
|
| 523 |
+
runButton.classList.remove('bg-blue-600', 'hover:bg-blue-700');
|
| 524 |
+
runButton.classList.add('bg-red-600', 'hover:bg-red-700');
|
| 525 |
+
|
| 526 |
+
// Reset all nodes to default state
|
| 527 |
+
document.querySelectorAll('.node[data-node-id]').forEach(node => {
|
| 528 |
+
node.classList.remove('executing', 'success', 'error');
|
| 529 |
+
});
|
| 530 |
+
|
| 531 |
+
// Simulate agent execution flow
|
| 532 |
+
currentExecution = simulateAgentExecution();
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
function stopExecution() {
|
| 536 |
+
isRunning = false;
|
| 537 |
+
const runButton = document.getElementById('run-agent');
|
| 538 |
+
runButton.innerHTML = '<i data-feather="play" class="w-4 h-4"></i><span>Run Agent</span>';
|
| 539 |
+
feather.replace();
|
| 540 |
+
runButton.classList.remove('bg-red-600', 'hover:bg-red-700');
|
| 541 |
+
runButton.classList.add('bg-blue-600', 'hover:bg-blue-700');
|
| 542 |
+
|
| 543 |
+
if (currentExecution) {
|
| 544 |
+
clearTimeout(currentExecution);
|
| 545 |
+
currentExecution = null;
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
// Reset all nodes
|
| 549 |
+
document.querySelectorAll('.node[data-node-id]').forEach(node => {
|
| 550 |
+
node.classList.remove('executing', 'success', 'error');
|
| 551 |
+
});
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
function simulateAgentExecution() {
|
| 555 |
+
const nodes = {
|
| 556 |
+
'input-1': document.querySelector('[data-node-id="input-1"]'),
|
| 557 |
+
'agent-1': document.querySelector('[data-node-id="agent-1"]'),
|
| 558 |
+
'tool-1': document.querySelector('[data-node-id="tool-1"]'),
|
| 559 |
+
'output-1': document.querySelector('[data-node-id="output-1"]')
|
| 560 |
+
};
|
| 561 |
+
|
| 562 |
+
let step = 0;
|
| 563 |
+
|
| 564 |
+
function executeStep() {
|
| 565 |
+
if (!isRunning) return;
|
| 566 |
+
|
| 567 |
+
switch(step) {
|
| 568 |
+
case 0:
|
| 569 |
+
// Input node processing
|
| 570 |
+
highlightNode(nodes['input-1'], 'executing');
|
| 571 |
+
setTimeout(() => {
|
| 572 |
+
highlightNode(nodes['input-1'], 'success');
|
| 573 |
+
step++;
|
| 574 |
+
executeStep();
|
| 575 |
+
}, 1000);
|
| 576 |
+
break;
|
| 577 |
+
|
| 578 |
+
case 1:
|
| 579 |
+
// LLM Agent processing
|
| 580 |
+
highlightNode(nodes['agent-1'], 'executing');
|
| 581 |
+
setTimeout(() => {
|
| 582 |
+
highlightNode(nodes['agent-1'], 'success');
|
| 583 |
+
step++;
|
| 584 |
+
executeStep();
|
| 585 |
+
}, 2000);
|
| 586 |
+
break;
|
| 587 |
+
|
| 588 |
+
case 2:
|
| 589 |
+
// Tool processing (Web Search)
|
| 590 |
+
highlightNode(nodes['tool-1'], 'executing');
|
| 591 |
+
setTimeout(() => {
|
| 592 |
+
highlightNode(nodes['tool-1'], 'success');
|
| 593 |
+
step++;
|
| 594 |
+
executeStep();
|
| 595 |
+
}, 1500);
|
| 596 |
+
break;
|
| 597 |
+
|
| 598 |
+
case 3:
|
| 599 |
+
// Output node
|
| 600 |
+
highlightNode(nodes['output-1'], 'executing');
|
| 601 |
+
setTimeout(() => {
|
| 602 |
+
highlightNode(nodes['output-1'], 'success');
|
| 603 |
+
// Execution complete
|
| 604 |
+
setTimeout(() => {
|
| 605 |
+
stopExecution();
|
| 606 |
+
showExecutionResult();
|
| 607 |
+
}, 500);
|
| 608 |
+
break;
|
| 609 |
+
}
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
executeStep();
|
| 613 |
+
return currentExecution;
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
function highlightNode(node, state) {
|
| 617 |
+
node.classList.remove('executing', 'success', 'error');
|
| 618 |
+
if (state) {
|
| 619 |
+
node.classList.add(state);
|
| 620 |
+
|
| 621 |
+
// Add pulsing animation for executing state
|
| 622 |
+
if (state === 'executing') {
|
| 623 |
+
node.style.animation = 'pulse 1.5s infinite';
|
| 624 |
+
} else {
|
| 625 |
+
node.style.animation = '';
|
| 626 |
+
}
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
function showExecutionResult() {
|
| 630 |
+
// Create a simple result modal
|
| 631 |
+
const modal = document.createElement('div');
|
| 632 |
+
modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50';
|
| 633 |
+
modal.innerHTML = `
|
| 634 |
+
<div class="bg-white rounded-xl p-6 max-w-md w-full mx-4">
|
| 635 |
+
<div class="flex items-center justify-between mb-4">
|
| 636 |
+
<h3 class="text-lg font-semibold text-gray-900">Execution Complete</h3>
|
| 637 |
+
<button onclick="this.parentElement.parentElement.remove()" class="text-gray-400 hover:text-gray-600">
|
| 638 |
+
<i data-feather="x" class="w-5 h-5"></i>
|
| 639 |
+
</button>
|
| 640 |
+
</div>
|
| 641 |
+
<div class="space-y-3">
|
| 642 |
+
<div class="flex items-center space-x-2 text-green-600">
|
| 643 |
+
<i data-feather="check-circle" class="w-5 h-5"></i>
|
| 644 |
+
<span class="text-sm font-medium">Agent executed successfully!</span>
|
| 645 |
+
</div>
|
| 646 |
+
<div class="bg-gray-50 rounded-lg p-4">
|
| 647 |
+
<h4 class="text-xs font-medium text-gray-700 mb-2">Execution Log</h4>
|
| 648 |
+
<div class="text-xs text-gray-600 space-y-1">
|
| 649 |
+
<div>✓ Input processed</div>
|
| 650 |
+
<div>✓ LLM reasoning completed</div>
|
| 651 |
+
<div>✓ Web search executed</div>
|
| 652 |
+
<div>✓ Output generated</div>
|
| 653 |
+
</div>
|
| 654 |
+
</div>
|
| 655 |
+
<div class="mt-6 flex justify-end">
|
| 656 |
+
<button onclick="this.parentElement.parentElement.parentElement.remove()" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
|
| 657 |
+
Close
|
| 658 |
+
</button>
|
| 659 |
+
</div>
|
| 660 |
+
`;
|
| 661 |
+
document.body.appendChild(modal);
|
| 662 |
+
feather.replace();
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
// Add CSS for execution states
|
| 666 |
+
const style = document.createElement('style');
|
| 667 |
+
style.textContent = `
|
| 668 |
+
.node.executing {
|
| 669 |
+
border-color: #3B82F6 !important;
|
| 670 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
|
| 671 |
+
}
|
| 672 |
+
.node.success {
|
| 673 |
+
border-color: #10B981 !important;
|
| 674 |
+
box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
|
| 675 |
+
}
|
| 676 |
+
.node.error {
|
| 677 |
+
border-color: #EF4444 !important;
|
| 678 |
+
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
|
| 679 |
+
}
|
| 680 |
+
@keyframes pulse {
|
| 681 |
+
0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
|
| 682 |
+
70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
|
| 683 |
+
100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
|
| 684 |
+
}
|
| 685 |
+
`;
|
| 686 |
+
document.head.appendChild(style);
|
| 687 |
});
|
| 688 |
+
</script>
|
| 689 |
</body>
|
| 690 |
</html>
|