multicast_codemode/
service.rs1use async_trait::async_trait;
2use serde_json::Value;
3
4use crate::{CodeModeRunOptions, ExecutionState, SearchOutput, Snippet};
5
6#[async_trait]
8#[allow(
9 clippy::double_must_use,
10 reason = "async_trait annotates generated futures"
11)]
12pub trait CodeModeService: Send + Sync {
13 async fn install_workflows(
15 &self,
16 _definitions: std::collections::BTreeMap<String, crate::WorkflowDefinition>,
17 ) -> Result<(), String> {
18 if _definitions.is_empty() {
19 Ok(())
20 } else {
21 Err("This host does not support callable workflow definitions".into())
22 }
23 }
24 async fn prepare(&self, _code: String) -> Result<ExecutionState, String> {
27 Err("This host does not support prepared execution".into())
28 }
29
30 async fn recover(
33 &self,
34 execution_id: String,
35 _options: CodeModeRunOptions,
36 ) -> Result<ExecutionState, String> {
37 self.execution(execution_id).await
38 }
39 fn supports_retained_execution(&self) -> bool {
42 false
43 }
44
45 async fn approve_detached(
47 &self,
48 _execution_id: String,
49 _seq: u64,
50 _options: CodeModeRunOptions,
51 ) -> Result<ExecutionState, String> {
52 Err("This host does not support detached approval".into())
53 }
54
55 async fn execute_retained(
57 &self,
58 _code: String,
59 _retention_ms: u64,
60 _options: CodeModeRunOptions,
61 ) -> Result<ExecutionState, String> {
62 Err("This host does not support retained asynchronous execution".into())
63 }
64
65 async fn search(&self, query: String) -> Result<SearchOutput, String>;
67
68 async fn execute(
70 &self,
71 code: String,
72 options: CodeModeRunOptions,
73 ) -> Result<ExecutionState, String>;
74
75 async fn execution(&self, execution_id: String) -> Result<ExecutionState, String>;
80
81 async fn resume(
85 &self,
86 _execution_id: String,
87 _options: CodeModeRunOptions,
88 ) -> Result<ExecutionState, String> {
89 Err("This host does not support resuming interrupted executions".into())
90 }
91
92 async fn artifact(&self, execution_id: String, artifact_id: String) -> Result<Value, String>;
94
95 async fn approve(
97 &self,
98 execution_id: String,
99 seq: u64,
100 options: CodeModeRunOptions,
101 ) -> Result<ExecutionState, String>;
102
103 async fn reject(&self, execution_id: String, seq: u64) -> Result<ExecutionState, String>;
105
106 async fn cancel(&self, execution_id: String) -> Result<ExecutionState, String>;
108
109 async fn save_snippet(
111 &self,
112 _name: String,
113 _description: String,
114 _execution_id: String,
115 _input_schema: Option<Value>,
116 ) -> Result<Snippet, String> {
117 Err("This host does not support saving snippets".into())
118 }
119
120 async fn publish_snippet(
122 &self,
123 _name: String,
124 _description: String,
125 _code: String,
126 _input_schema: Option<Value>,
127 ) -> Result<Snippet, String> {
128 Err("This host does not support publishing snippets".into())
129 }
130
131 async fn snippets(&self) -> Result<Vec<Snippet>, String> {
133 Err("This host does not support listing snippets".into())
134 }
135
136 async fn delete_snippet(&self, _name: String) -> Result<bool, String> {
138 Err("This host does not support deleting snippets".into())
139 }
140}