- Added `chat.rs` for rendering chat messages with timestamps and roles. - Introduced `markdown.rs` for rendering markdown content with styling. - Created `status.rs` to display the application status bar with session and message counts. - Developed `workflow.rs` to show the current workflow status, including tool calls and active jobs. - Established a `theme.rs` for centralized color management across the UI. - Updated `mod.rs` to include new modules and manage rendering logic.
114 lines
2.7 KiB
Rust
114 lines
2.7 KiB
Rust
use std::collections::HashMap;
|
|
use serde::{Deserialize, Serialize};
|
|
use super::script::{ScriptPrimitive, WorkflowScript};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum AgentState {
|
|
Idle,
|
|
Running,
|
|
Completed,
|
|
Failed,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct AgentStatus {
|
|
pub state: AgentState,
|
|
pub started_at: Option<i64>,
|
|
pub completed_at: Option<i64>,
|
|
pub error: Option<String>,
|
|
}
|
|
|
|
impl AgentStatus {
|
|
pub fn new() -> Self {
|
|
AgentStatus {
|
|
state: AgentState::Idle,
|
|
started_at: None,
|
|
completed_at: None,
|
|
error: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct WorkflowAgent {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub status: AgentStatus,
|
|
}
|
|
|
|
impl WorkflowAgent {
|
|
pub fn new(id: String, name: String) -> Self {
|
|
WorkflowAgent {
|
|
id,
|
|
name,
|
|
status: AgentStatus::new(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct WorkflowEngine {
|
|
pub agents: Vec<WorkflowAgent>,
|
|
pub concurrency_cap: usize,
|
|
pub findings: Vec<String>,
|
|
}
|
|
|
|
impl WorkflowEngine {
|
|
pub fn new() -> Self {
|
|
WorkflowEngine {
|
|
agents: Vec::new(),
|
|
concurrency_cap: 5,
|
|
findings: Vec::new(),
|
|
}
|
|
}
|
|
|
|
pub fn with_concurrency_cap(mut self, cap: usize) -> Self {
|
|
self.concurrency_cap = cap;
|
|
self
|
|
}
|
|
|
|
pub fn add_agent(&mut self, agent: WorkflowAgent) {
|
|
self.agents.push(agent);
|
|
}
|
|
}
|
|
|
|
pub fn execute_primitive(primitive: &ScriptPrimitive, args: &HashMap<String, String>) -> anyhow::Result<()> {
|
|
match primitive {
|
|
ScriptPrimitive::Agent(name) => {
|
|
let _agent_name = name;
|
|
let _args = args;
|
|
Ok(())
|
|
}
|
|
ScriptPrimitive::Parallel(scripts) => {
|
|
for script in scripts {
|
|
execute_primitive(script, args)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
ScriptPrimitive::Pipeline(scripts) => {
|
|
for script in scripts {
|
|
execute_primitive(script, args)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
ScriptPrimitive::Phase { name: _name, script } => {
|
|
execute_primitive(script, args)
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn run_workflow(script: &WorkflowScript, args: &HashMap<String, String>) -> anyhow::Result<String> {
|
|
let concurrency_cap = if script.options.max_concurrency > 0 {
|
|
script.options.max_concurrency.min(5)
|
|
} else {
|
|
5
|
|
};
|
|
let _cap = concurrency_cap;
|
|
execute_primitive(&script.script, args)?;
|
|
Ok("workflow completed".to_string())
|
|
}
|
|
|
|
pub fn note_finding(text: &str) {
|
|
let _finding = text;
|
|
}
|