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        project_root: Option<String>,
22    ) -> Result<String, String> {
23        AppService::run(self, code, code_file, ctx, project_root).await
24    }
25
26    async fn advice(
27        &self,
28        strategy: &str,
29        task: Option<String>,
30        opts: Option<serde_json::Value>,
31        project_root: Option<String>,
32    ) -> Result<String, String> {
33        AppService::advice(self, strategy, task, opts, project_root).await
34    }
35
36    async fn continue_single(
37        &self,
38        session_id: &str,
39        response: String,
40        query_id: Option<&str>,
41        usage: Option<algocline_core::TokenUsage>,
42    ) -> Result<String, String> {
43        AppService::continue_single(self, session_id, response, query_id, usage).await
44    }
45
46    async fn continue_batch(
47        &self,
48        session_id: &str,
49        responses: Vec<QueryResponse>,
50    ) -> Result<String, String> {
51        AppService::continue_batch(self, session_id, responses).await
52    }
53
54    // ─── Session status ──────────────────────────────────────
55
56    async fn status(&self, session_id: Option<&str>) -> Result<String, String> {
57        AppService::status(self, session_id).await
58    }
59
60    // ─── Evaluation ──────────────────────────────────────────
61
62    async fn eval(
63        &self,
64        scenario: Option<String>,
65        scenario_file: Option<String>,
66        scenario_name: Option<String>,
67        strategy: &str,
68        strategy_opts: Option<serde_json::Value>,
69    ) -> Result<String, String> {
70        AppService::eval(
71            self,
72            scenario,
73            scenario_file,
74            scenario_name,
75            strategy,
76            strategy_opts,
77        )
78        .await
79    }
80
81    async fn eval_history(&self, strategy: Option<&str>, limit: usize) -> Result<String, String> {
82        AppService::eval_history(self, strategy, limit)
83    }
84
85    async fn eval_detail(&self, eval_id: &str) -> Result<String, String> {
86        AppService::eval_detail(self, eval_id)
87    }
88
89    async fn eval_compare(&self, eval_id_a: &str, eval_id_b: &str) -> Result<String, String> {
90        AppService::eval_compare(self, eval_id_a, eval_id_b).await
91    }
92
93    // ─── Scenarios ───────────────────────────────────────────
94
95    async fn scenario_list(&self) -> Result<String, String> {
96        AppService::scenario_list(self)
97    }
98
99    async fn scenario_show(&self, name: &str) -> Result<String, String> {
100        AppService::scenario_show(self, name)
101    }
102
103    async fn scenario_install(&self, url: String) -> Result<String, String> {
104        AppService::scenario_install(self, url).await
105    }
106
107    // ─── Packages ────────────────────────────────────────────
108
109    async fn pkg_link(&self, path: String, project_root: Option<String>) -> Result<String, String> {
110        AppService::pkg_link(self, path, project_root).await
111    }
112
113    async fn pkg_list(&self, project_root: Option<String>) -> Result<String, String> {
114        AppService::pkg_list(self, project_root).await
115    }
116
117    async fn pkg_install(&self, url: String, name: Option<String>) -> Result<String, String> {
118        AppService::pkg_install(self, url, name).await
119    }
120
121    async fn pkg_remove(
122        &self,
123        name: &str,
124        project_root: Option<String>,
125        scope: Option<String>,
126    ) -> Result<String, String> {
127        AppService::pkg_remove(self, name, project_root, scope).await
128    }
129
130    // ─── Logging ─────────────────────────────────────────────
131
132    async fn add_note(
133        &self,
134        session_id: &str,
135        content: &str,
136        title: Option<&str>,
137    ) -> Result<String, String> {
138        AppService::add_note(self, session_id, content, title).await
139    }
140
141    async fn log_view(
142        &self,
143        session_id: Option<&str>,
144        limit: Option<usize>,
145        max_chars: Option<usize>,
146    ) -> Result<String, String> {
147        AppService::log_view(self, session_id, limit, max_chars).await
148    }
149
150    async fn stats(
151        &self,
152        strategy_filter: Option<&str>,
153        days: Option<u64>,
154    ) -> Result<String, String> {
155        AppService::stats(self, strategy_filter, days)
156    }
157
158    // ─── Diagnostics ─────────────────────────────────────────
159
160    async fn info(&self) -> String {
161        AppService::info(self)
162    }
163}