class AgenticCell extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } static get observedAttributes() { return ['agent-type', 'input', 'output', 'status', 'timestamp', 'has-previous']; } attributeChangedCallback(name, oldValue, newValue) { if (oldValue !== newValue) { this.render(); } } render() { const agentType = this.getAttribute('agent-type') || 'researcher'; const input = this.getAttribute('input') || ''; const output = this.getAttribute('output') ? JSON.parse(this.getAttribute('output')) : null; const status = this.getAttribute('status') || 'idle'; const timestamp = this.getAttribute('timestamp') || new Date().toISOString(); const hasPrevious = this.hasAttribute('has-previous'); const agentIcons = { 'researcher': 'search', 'analyst': 'bar-chart-2', 'data-visualizer': 'pie-chart', 'summarizer': 'file-text' }; const statusColors = { 'idle': 'bg-gray-200', 'loading': 'bg-blue-200 animate-pulse-slow', 'success': 'bg-green-200', 'error': 'bg-red-200' }; this.shadowRoot.innerHTML = `
${agentType} ${status !== 'idle' ? ` ${status === 'loading' ? 'Running...' : status} ${new Date(timestamp).toLocaleString()} ` : ''}
${output?.metadata?.requires_human_check ? `
${output.metadata.human_check_status === 'approved' ? '✅ Approved' : output.metadata.human_check_status === 'rejected' ? '❌ Rejected' : '🧍 Pending Review'}
` : ''}
${output ? `
Output
${output.tools_used ? `
Tools used:
${output.tools_used.map(tool => ` ${tool.name} `).join('')}
` : ''} ${output.metadata ? `
Provenance & Metadata
` : ''} ` : `
No output yet. Run the cell to see results.
`}
`; // Add event listener for the run button const runBtn = this.shadowRoot.querySelector('.run-btn'); runBtn.addEventListener('click', () => { const cellId = this.getAttribute('id'); mockRunCell(cellId); }); // Initialize feather icons if (window.feather) { window.feather.replace(); } } } customElements.define('agentic-cell', AgenticCell);