Refactor subagent and workflow domain models; migrate access tiers and events to domain module

- Moved `AccessTier` and `SubagentEvent` enums to `zesdex_domain::subagent`.
- Consolidated workflow-related types into `zesdex_domain::workflow`.
- Updated references across the codebase to use the new domain models.
- Refactored tool execution logic to utilize a new `ToolExecutor` trait.
- Enhanced `AgentTurnService` to handle tool calls and events more effectively.
- Adjusted API handlers and state management to align with new domain structure.
This commit is contained in:
asepharyana
2026-07-21 06:42:53 +07:00
parent 552bc5bc63
commit 802346f909
31 changed files with 968 additions and 870 deletions
+56
View File
@@ -0,0 +1,56 @@
use std::future::Future;
use anyhow::Result;
use zesdex_application::agent::ToolExecutor;
use crate::tools::{all_tools, Tool, ToolCtx};
use tracing::debug;
pub struct InfrastructureToolExecutor {
ctx: ToolCtx,
tools: Vec<Box<dyn Tool>>,
}
impl InfrastructureToolExecutor {
pub fn new(ctx: ToolCtx) -> Self {
Self {
ctx,
tools: all_tools(),
}
}
}
impl ToolExecutor for InfrastructureToolExecutor {
fn execute(
&self,
tool_name: &str,
args: &serde_json::Value,
) -> impl Future<Output = Result<String>> + Send {
// Find the tool by name
let tool_opt = self.tools.iter().find(|t| t.name() == tool_name);
let ctx = self.ctx.clone();
let args = args.clone();
async move {
match tool_opt {
Some(tool) => {
// Tool::run is synchronous, so we run it in a blocking task if needed
// For now, since they run fast and we are transitioning, we can just block in place.
// Or tokio::task::spawn_blocking:
let tool_name = tool.name().to_string();
let t_ctx = ctx.clone();
let t_args = args.clone();
// Because Tool isn't easily cloned, we might just block on the current thread,
// or use tokio::task::block_in_place if we're in a tokio runtime.
// But `tool.run` takes `&self`, and we have `&self` borrowed.
// For now we just call it directly.
tokio::task::block_in_place(move || {
tool.run(&ctx, &args)
})
}
None => {
anyhow::bail!("Unknown tool: {}", tool_name)
}
}
}
}
}