Skip to main content

algocline_app/service/
engine_api_impl.rs

1use algocline_core::{EngineApi, QueryResponse};
2use async_trait::async_trait;
3
4use super::AppService;
5
6/// Delegates each [`EngineApi`] method to the corresponding `AppService`
7/// inherent method via fully-qualified syntax (`AppService::method(self, …)`).
8///
9/// This avoids ambiguity between the trait method and the inherent method
10/// of the same name, preventing accidental infinite recursion if the
11/// inherent method is ever removed or renamed.
12#[async_trait]
13impl EngineApi for AppService {
14    // ─── Core execution ──────────────────────────────────────
15
16    async fn run(
17        &self,
18        code: Option<String>,
19        code_file: Option<String>,
20        ctx: Option<serde_json::Value>,
21    ) -> Result<String, String> {
22        AppService::run(self, code, code_file, ctx).await
23    }
24
25    async fn advice(
26        &self,
27        strategy: &str,
28        task: String,
29        opts: Option<serde_json::Value>,
30    ) -> Result<String, String> {
31        AppService::advice(self, strategy, task, opts).await
32    }
33
34    async fn continue_single(
35        &self,
36        session_id: &str,
37        response: String,
38        query_id: Option<&str>,
39    ) -> Result<String, String> {
40        AppService::continue_single(self, session_id, response, query_id).await
41    }
42
43    async fn continue_batch(
44        &self,
45        session_id: &str,
46        responses: Vec<QueryResponse>,
47    ) -> Result<String, String> {
48        AppService::continue_batch(self, session_id, responses).await
49    }
50
51    // ─── Session status ──────────────────────────────────────
52
53    async fn status(&self, session_id: Option<&str>) -> Result<String, String> {
54        AppService::status(self, session_id).await
55    }
56
57    // ─── Evaluation ──────────────────────────────────────────
58
59    async fn eval(
60        &self,
61        scenario: Option<String>,
62        scenario_file: Option<String>,
63        scenario_name: Option<String>,
64        strategy: &str,
65        strategy_opts: Option<serde_json::Value>,
66    ) -> Result<String, String> {
67        AppService::eval(
68            self,
69            scenario,
70            scenario_file,
71            scenario_name,
72            strategy,
73            strategy_opts,
74        )
75        .await
76    }
77
78    async fn eval_history(&self, strategy: Option<&str>, limit: usize) -> Result<String, String> {
79        AppService::eval_history(self, strategy, limit)
80    }
81
82    async fn eval_detail(&self, eval_id: &str) -> Result<String, String> {
83        AppService::eval_detail(self, eval_id)
84    }
85
86    async fn eval_compare(&self, eval_id_a: &str, eval_id_b: &str) -> Result<String, String> {
87        AppService::eval_compare(self, eval_id_a, eval_id_b).await
88    }
89
90    // ─── Scenarios ───────────────────────────────────────────
91
92    async fn scenario_list(&self) -> Result<String, String> {
93        AppService::scenario_list(self)
94    }
95
96    async fn scenario_show(&self, name: &str) -> Result<String, String> {
97        AppService::scenario_show(self, name)
98    }
99
100    async fn scenario_install(&self, url: String) -> Result<String, String> {
101        AppService::scenario_install(self, url).await
102    }
103
104    // ─── Packages ────────────────────────────────────────────
105
106    async fn pkg_list(&self) -> Result<String, String> {
107        AppService::pkg_list(self).await
108    }
109
110    async fn pkg_install(&self, url: String, name: Option<String>) -> Result<String, String> {
111        AppService::pkg_install(self, url, name).await
112    }
113
114    async fn pkg_remove(&self, name: &str) -> Result<String, String> {
115        AppService::pkg_remove(self, name).await
116    }
117
118    // ─── Logging ─────────────────────────────────────────────
119
120    async fn add_note(
121        &self,
122        session_id: &str,
123        content: &str,
124        title: Option<&str>,
125    ) -> Result<String, String> {
126        AppService::add_note(self, session_id, content, title).await
127    }
128
129    async fn log_view(
130        &self,
131        session_id: Option<&str>,
132        limit: Option<usize>,
133    ) -> Result<String, String> {
134        AppService::log_view(self, session_id, limit).await
135    }
136
137    async fn stats(
138        &self,
139        strategy_filter: Option<&str>,
140        days: Option<u64>,
141    ) -> Result<String, String> {
142        AppService::stats(self, strategy_filter, days)
143    }
144
145    // ─── Diagnostics ─────────────────────────────────────────
146
147    async fn info(&self) -> String {
148        AppService::info(self)
149    }
150}