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:
@@ -82,19 +82,47 @@ async fn handle_socket(mut socket: WebSocket, state: Arc<WsState>) {
|
||||
let api_key = std::env::var("OPENAI_API_KEY").unwrap_or_default();
|
||||
let model = val.get("model").and_then(|v| v.as_str()).unwrap_or("gpt-4o").to_string();
|
||||
|
||||
let params = zesdex_infrastructure::agent::AgentTurnParams {
|
||||
let params = zesdex_domain::agent::AgentTurnParams {
|
||||
messages: vec![zesdex_domain::core::ChatMessage::user(prompt)],
|
||||
session_dir,
|
||||
workspace_roots,
|
||||
session_dir: session_dir.clone(),
|
||||
workspace_roots: workspace_roots.clone(),
|
||||
turn_events: turn_events.clone(),
|
||||
in_flight,
|
||||
abort,
|
||||
api_key,
|
||||
model,
|
||||
api_key: api_key.clone(),
|
||||
model: model.clone(),
|
||||
api_base: None,
|
||||
};
|
||||
|
||||
zesdex_infrastructure::agent::spawn_agent_turn(params);
|
||||
let client = std::sync::Arc::new(zesdex_infrastructure::llm::provider::LlmClient::new(
|
||||
api_key,
|
||||
model,
|
||||
None,
|
||||
));
|
||||
|
||||
let tool_ctx = zesdex_infrastructure::tools::ToolCtx::builder()
|
||||
.session_dir(session_dir)
|
||||
.workspaces(workspace_roots)
|
||||
.turn_events(turn_events.clone())
|
||||
.build();
|
||||
|
||||
let tool_executor = std::sync::Arc::new(
|
||||
zesdex_infrastructure::tools::executor::InfrastructureToolExecutor::new(tool_ctx),
|
||||
);
|
||||
|
||||
let tools = zesdex_infrastructure::tools::all_tools();
|
||||
let defs = zesdex_infrastructure::tools::tool_defs(&tools);
|
||||
|
||||
let turn_service = zesdex_application::agent::turn_service::AgentTurnServiceImpl::new(
|
||||
client,
|
||||
tool_executor,
|
||||
defs,
|
||||
);
|
||||
|
||||
use zesdex_application::agent::AgentTurnService;
|
||||
tokio::spawn(async move {
|
||||
let _ = turn_service.run_turn(params).await;
|
||||
});
|
||||
|
||||
let tx_clone = tx.clone();
|
||||
tokio::spawn(async move {
|
||||
|
||||
Reference in New Issue
Block a user