Implement Complete Workflow Execution Engine
Added full workflow execution engine that actually runs workflow steps:
Server-Side (server.js):
- executeWorkflowSteps() - Main workflow orchestration function
- executeCommandStep() - Executes commands on target workers
- waitForCommandResult() - Polls for command completion
- Support for step types: execute, wait, prompt (prompt skipped for now)
- Sequential step execution with failure handling
- Worker targeting: "all" or specific worker IDs/names
- Automatic status updates (running -> completed/failed)
- Real-time WebSocket broadcasts for step progress
- Command result tracking with command_id for workflows
- Only updates status for non-workflow quick commands
Client-Side (index.html):
- Enhanced formatLogEntry() with workflow-specific log types
- step_started - Shows step number and name with amber color
- step_completed - Shows completion with green checkmark
- waiting - Displays wait duration
- no_workers - Error when no workers available
- worker_offline - Warning for offline workers
- workflow_error - Critical workflow errors
- Better visual feedback for workflow progress
Workflow Definition Format:
{
"steps": [
{
"name": "Step Name",
"type": "execute",
"targets": ["all"] or ["worker-name"],
"command": "your command here"
},
{
"type": "wait",
"duration": 5
}
]
}
Features:
- Executes steps sequentially
- Stops on first failure
- Supports multiple workers per step
- Real-time progress updates
- Comprehensive logging
- Terminal-themed workflow logs
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1835,6 +1835,70 @@
|
||||
`;
|
||||
}
|
||||
|
||||
// Workflow step logs
|
||||
if (log.action === 'step_started') {
|
||||
return `
|
||||
<div class="log-entry" style="border-left-color: var(--terminal-amber);">
|
||||
<div class="log-timestamp">[${timestamp}]</div>
|
||||
<div class="log-title" style="color: var(--terminal-amber);">▶️ Step ${log.step}: ${log.step_name}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (log.action === 'step_completed') {
|
||||
return `
|
||||
<div class="log-entry" style="border-left-color: var(--terminal-green);">
|
||||
<div class="log-timestamp">[${timestamp}]</div>
|
||||
<div class="log-title" style="color: var(--terminal-green);">✓ Step ${log.step} Completed: ${log.step_name}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (log.action === 'waiting') {
|
||||
return `
|
||||
<div class="log-entry" style="border-left-color: var(--terminal-amber);">
|
||||
<div class="log-timestamp">[${timestamp}]</div>
|
||||
<div class="log-title" style="color: var(--terminal-amber);">⏳ Waiting ${log.duration} seconds...</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (log.action === 'no_workers') {
|
||||
return `
|
||||
<div class="log-entry failed">
|
||||
<div class="log-timestamp">[${timestamp}]</div>
|
||||
<div class="log-title">✗ Step ${log.step}: No Workers Available</div>
|
||||
<div class="log-details">
|
||||
<div class="log-field">${escapeHtml(log.message)}</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (log.action === 'worker_offline') {
|
||||
return `
|
||||
<div class="log-entry" style="border-left-color: #ff4444;">
|
||||
<div class="log-timestamp">[${timestamp}]</div>
|
||||
<div class="log-title" style="color: #ff4444;">⚠️ Worker Offline</div>
|
||||
<div class="log-details">
|
||||
<div class="log-field"><span class="log-label">Worker ID:</span> ${log.worker_id}</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (log.action === 'workflow_error') {
|
||||
return `
|
||||
<div class="log-entry failed">
|
||||
<div class="log-timestamp">[${timestamp}]</div>
|
||||
<div class="log-title">✗ Workflow Error</div>
|
||||
<div class="log-details">
|
||||
<div class="log-field"><span class="log-label">Error:</span> ${escapeHtml(log.error)}</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// Fallback for unknown log types
|
||||
return `<div class="log-entry"><pre>${JSON.stringify(log, null, 2)}</pre></div>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user