ralph_workflow/app/
runtime_factory.rs1use crate::config::Config;
8use crate::logger::{Colors, Logger};
9use crate::pipeline::PipelineRuntime;
10use crate::prompts::registry::AgentRegistry;
11use crate::workspace::Workspace;
12use crate::ProcessExecutor;
13use std::sync::Arc;
14
15pub struct PipelineRuntimeFactoryParams<'a> {
16 pub timer: &'a mut crate::pipeline::Timer,
17 pub logger: &'a Logger,
18 pub colors: &'a Colors,
19 pub config: &'a Config,
20 pub executor: &'a dyn ProcessExecutor,
21 pub executor_arc: Arc<dyn ProcessExecutor>,
22 pub workspace: &'a dyn Workspace,
23 pub workspace_arc: Arc<dyn Workspace>,
24}
25
26pub fn create_agent_registry() -> Result<AgentRegistry, anyhow::Error> {
27 AgentRegistry::new().map_err(|e| {
28 anyhow::anyhow!("Failed to load built-in default agents config (examples/agents.toml): {e}")
29 })
30}
31
32pub fn create_timer() -> crate::pipeline::Timer {
33 crate::pipeline::Timer::new()
34}
35
36pub fn create_git_helpers() -> crate::git_helpers::GitHelpers {
37 crate::git_helpers::GitHelpers::new()
38}
39
40pub fn create_pipeline_runtime<'a>(
41 params: PipelineRuntimeFactoryParams<'a>,
42) -> PipelineRuntime<'a> {
43 let PipelineRuntimeFactoryParams {
44 timer,
45 logger,
46 colors,
47 config,
48 executor,
49 executor_arc,
50 workspace,
51 workspace_arc,
52 } = params;
53
54 PipelineRuntime {
55 timer,
56 logger,
57 colors,
58 config,
59 executor,
60 executor_arc,
61 workspace,
62 workspace_arc,
63 }
64}
65
66pub fn create_effect_handler() -> crate::app::effect_handler::RealAppEffectHandler {
67 crate::app::effect_handler::RealAppEffectHandler::new()
68}
69
70pub fn create_main_effect_handler(
71 initial_state: crate::reducer::state::PipelineState,
72) -> crate::reducer::MainEffectHandler {
73 crate::reducer::MainEffectHandler::new(initial_state)
74}
75
76pub fn create_cleanup_guard<'a>(
77 logger: &'a Logger,
78 workspace: &'a dyn crate::workspace::Workspace,
79 owned: bool,
80) -> crate::app::runner::pipeline_execution::CommandExitCleanupGuard<'a> {
81 let guard = crate::app::runner::pipeline_execution::CommandExitCleanupGuard::new(
82 logger, workspace, owned,
83 );
84 guard
85}