@@ -11,10 +11,9 @@ use crate::dto::InitAuth;
1111use crate :: orch:: Orchestrator ;
1212use crate :: services:: { CustomInstructionsService , TemplateService } ;
1313use crate :: tool_registry:: ToolRegistry ;
14- use crate :: workflow_manager:: WorkflowManager ;
1514use crate :: {
1615 AppConfigService , AttachmentService , ConversationService , EnvironmentService ,
17- FileDiscoveryService , ProviderRegistry , ProviderService , Services , Walker ,
16+ FileDiscoveryService , ProviderRegistry , ProviderService , Services , Walker , WorkflowService ,
1817} ;
1918
2019/// ForgeApp handles the core chat functionality by orchestrating various
@@ -24,7 +23,6 @@ pub struct ForgeApp<S> {
2423 services : Arc < S > ,
2524 tool_registry : ToolRegistry < S > ,
2625 authenticator : Authenticator < S > ,
27- workflow_manager : WorkflowManager < S > ,
2826}
2927
3028impl < S : Services > ForgeApp < S > {
@@ -33,7 +31,6 @@ impl<S: Services> ForgeApp<S> {
3331 Self {
3432 tool_registry : ToolRegistry :: new ( services. clone ( ) ) ,
3533 authenticator : Authenticator :: new ( services. clone ( ) ) ,
36- workflow_manager : WorkflowManager :: new ( services. clone ( ) ) ,
3734 services,
3835 }
3936 }
@@ -48,7 +45,7 @@ impl<S: Services> ForgeApp<S> {
4845
4946 // Get the conversation for the chat request
5047 let conversation = services
51- . find ( & chat. conversation_id )
48+ . find_conversation ( & chat. conversation_id )
5249 . await
5350 . unwrap_or_default ( )
5451 . expect ( "conversation for the request should've been created at this point." ) ;
@@ -63,11 +60,7 @@ impl<S: Services> ForgeApp<S> {
6360 let models = services. models ( provider) . await ?;
6461
6562 // Discover files using the discovery service
66- let workflow = self
67- . workflow_manager
68- . read_merged ( None )
69- . await
70- . unwrap_or_default ( ) ;
63+ let workflow = self . services . read_merged ( None ) . await . unwrap_or_default ( ) ;
7164 let max_depth = workflow. max_walker_depth ;
7265 let environment = services. get_environment ( ) ;
7366
@@ -117,15 +110,13 @@ impl<S: Services> ForgeApp<S> {
117110 let stream = MpscStream :: spawn (
118111 |tx : tokio:: sync:: mpsc:: Sender < Result < ChatResponse , anyhow:: Error > > | {
119112 async move {
120- let tx = Arc :: new ( tx) ;
121-
122113 // Execute dispatch and always save conversation afterwards
123114 let mut orch = orch. sender ( tx. clone ( ) ) ;
124115 let dispatch_result = orch. chat ( chat. event ) . await ;
125116
126117 // Always save conversation using get_conversation()
127118 let conversation = orch. get_conversation ( ) . clone ( ) ;
128- let save_result = services. upsert ( conversation) . await ;
119+ let save_result = services. upsert_conversation ( conversation) . await ;
129120
130121 // Send any error to the stream (prioritize dispatch error over save error)
131122 #[ allow( clippy:: collapsible_if) ]
@@ -153,7 +144,7 @@ impl<S: Services> ForgeApp<S> {
153144 // Get the conversation
154145 let mut conversation = self
155146 . services
156- . find ( conversation_id)
147+ . find_conversation ( conversation_id)
157148 . await ?
158149 . ok_or_else ( || anyhow:: anyhow!( "Conversation not found: {}" , conversation_id) ) ?;
159150
@@ -191,7 +182,7 @@ impl<S: Services> ForgeApp<S> {
191182 conversation. context = Some ( compacted_context) ;
192183
193184 // Save the updated conversation
194- self . services . upsert ( conversation) . await ?;
185+ self . services . upsert_conversation ( conversation) . await ?;
195186
196187 // Return the compaction metrics
197188 Ok ( CompactionResult :: new (
@@ -215,13 +206,13 @@ impl<S: Services> ForgeApp<S> {
215206 self . authenticator . logout ( ) . await
216207 }
217208 pub async fn read_workflow ( & self , path : Option < & Path > ) -> Result < Workflow > {
218- self . workflow_manager . read_workflow ( path) . await
209+ self . services . read_workflow ( path) . await
219210 }
220211
221212 pub async fn read_workflow_merged ( & self , path : Option < & Path > ) -> Result < Workflow > {
222- self . workflow_manager . read_merged ( path) . await
213+ self . services . read_merged ( path) . await
223214 }
224215 pub async fn write_workflow ( & self , path : Option < & Path > , workflow : & Workflow ) -> Result < ( ) > {
225- self . workflow_manager . write_workflow ( path, workflow) . await
216+ self . services . write_workflow ( path, workflow) . await
226217 }
227218}
0 commit comments