kotoba_server_workflow/
lib.rs1pub mod handlers;
7pub mod router;
8
9#[cfg(feature = "workflow")]
10pub mod workflow;
11
12pub use handlers::{WorkflowApiHandler, WorkflowStatusHandler};
13pub use router::WorkflowRouter;
14
15use kotoba_server_core::AppRouter;
16
17#[cfg(feature = "workflow")]
18pub use workflow::{WorkflowEngine, WorkflowExecutionId, WorkflowIR, StartWorkflowResponse};
19
20pub trait WorkflowServerExt {
24 fn with_workflow_routes(self) -> Self;
25}
26
27impl WorkflowServerExt for AppRouter {
28 fn with_workflow_routes(self) -> Self {
29 self.merge(WorkflowRouter::new().build())
30 }
31}
32
33#[cfg(feature = "workflow")]
35#[async_trait::async_trait]
36pub trait WorkflowEngineInterface: Send + Sync {
37 async fn start_workflow(
38 &self,
39 workflow: &WorkflowIR,
40 context: serde_json::Value,
41 ) -> Result<WorkflowExecutionId, kotoba_errors::KotobaError>;
42
43 async fn get_execution(
44 &self,
45 execution_id: &WorkflowExecutionId,
46 ) -> Result<Option<WorkflowExecution>, kotoba_errors::KotobaError>;
47
48 async fn list_executions(&self) -> Result<Vec<WorkflowExecution>, kotoba_errors::KotobaError>;
49
50 async fn cancel_execution(
51 &self,
52 execution_id: &WorkflowExecutionId,
53 ) -> Result<(), kotoba_errors::KotobaError>;
54}
55
56#[cfg(feature = "workflow")]
57pub use kotoba_workflow_core::prelude::*;