Adicionar delegação automática entre agentes coordenadores

This commit is contained in:
Frederico Castro
2026-02-28 01:59:38 -03:00
parent 96733b55cd
commit f6bf7ce0ed
3 changed files with 58 additions and 1 deletions

View File

@@ -192,6 +192,8 @@ const AgentsUI = {
const retryMax = document.getElementById('agent-retry-max');
if (retryMax) retryMax.value = '3';
AgentsUI._populateDelegateSelect('');
const secretsSection = document.getElementById('agent-secrets-section');
if (secretsSection) secretsSection.hidden = true;
@@ -250,6 +252,8 @@ const AgentsUI = {
const retryMax = document.getElementById('agent-retry-max');
if (retryMax) retryMax.value = (agent.config && agent.config.maxRetries) || '3';
AgentsUI._populateDelegateSelect(agent.config?.delegateTo || '', agent.id);
const secretsSection = document.getElementById('agent-secrets-section');
if (secretsSection) secretsSection.hidden = false;
@@ -296,6 +300,7 @@ const AgentsUI = {
permissionMode: document.getElementById('agent-permission-mode')?.value || '',
retryOnFailure: !!document.getElementById('agent-retry-toggle')?.checked,
maxRetries: parseInt(document.getElementById('agent-retry-max')?.value) || 3,
delegateTo: document.getElementById('agent-delegate-to')?.value || '',
},
};
@@ -468,6 +473,14 @@ const AgentsUI = {
});
},
_populateDelegateSelect(currentValue, excludeId) {
const select = document.getElementById('agent-delegate-to');
if (!select) return;
const activeAgents = AgentsUI.agents.filter(a => a.status === 'active' && a.id !== excludeId);
select.innerHTML = '<option value="">Nenhum</option>' +
activeAgents.map(a => `<option value="${a.id}" ${a.id === currentValue ? 'selected' : ''}>${Utils.escapeHtml(a.agent_name || a.name)}</option>`).join('');
},
_setupModalListeners() {
const retryToggle = document.getElementById('agent-retry-toggle');
const retryMaxGroup = document.getElementById('agent-retry-max-group');