Skip to main content

vv_agent/runtime/engine/
construction.rs

1use std::path::PathBuf;
2use std::sync::Arc;
3
4use crate::llm::LlmClient;
5use crate::runtime::backends::RuntimeExecutionBackend;
6use crate::tools::{build_default_registry, ToolRegistry};
7use crate::workspace::LocalWorkspaceBackend;
8
9use super::AgentRuntime;
10
11impl<C: LlmClient> AgentRuntime<C> {
12    pub fn new(llm_client: C) -> Self {
13        Self {
14            llm_client,
15            tool_registry: build_default_registry(),
16            default_workspace: None,
17            log_handler: None,
18            log_preview_chars: None,
19            workspace_backend: Arc::new(LocalWorkspaceBackend::new(PathBuf::from("./workspace"))),
20            hooks: Vec::new(),
21            execution_backend: RuntimeExecutionBackend::default(),
22            settings_file: None,
23            default_backend: None,
24            sub_agent_timeout_seconds: 90.0,
25        }
26    }
27
28    pub fn with_tool_registry(mut self, tool_registry: ToolRegistry) -> Self {
29        self.tool_registry = tool_registry;
30        self
31    }
32
33    pub fn with_execution_backend(
34        mut self,
35        execution_backend: impl Into<RuntimeExecutionBackend>,
36    ) -> Self {
37        self.execution_backend = execution_backend.into();
38        self
39    }
40
41    pub fn with_settings_file(mut self, settings_file: impl Into<PathBuf>) -> Self {
42        self.settings_file = Some(settings_file.into());
43        self
44    }
45
46    pub fn with_default_backend(mut self, default_backend: impl Into<String>) -> Self {
47        self.default_backend = Some(default_backend.into());
48        self
49    }
50
51    pub fn with_log_preview_chars(mut self, log_preview_chars: usize) -> Self {
52        self.log_preview_chars = Some(log_preview_chars);
53        self
54    }
55
56    pub fn with_sub_agent_timeout_seconds(mut self, timeout_seconds: f64) -> Self {
57        self.sub_agent_timeout_seconds = timeout_seconds.max(1.0);
58        self
59    }
60}