Skip to main content

incurs_codemode/
service.rs

1use async_trait::async_trait;
2use serde_json::Value;
3
4use crate::{CodeModeRunOptions, ExecutionState, SearchOutput};
5
6/// Send-safe lifecycle boundary used by transports and native actor handles.
7#[async_trait]
8pub trait CodeModeService: Send + Sync {
9    /// Searches current connector methods and saved snippets.
10    async fn search(&self, query: String) -> Result<SearchOutput, String>;
11
12    /// Starts an execution and returns its durable running state.
13    async fn execute(
14        &self,
15        code: String,
16        options: CodeModeRunOptions,
17    ) -> Result<ExecutionState, String>;
18
19    /// Returns one bounded execution snapshot by identifier.
20    ///
21    /// Oversized values remain artifact references so transports can return the
22    /// snapshot before retrieving a selected artifact.
23    async fn execution(&self, execution_id: String) -> Result<ExecutionState, String>;
24
25    /// Returns one artifact owned by an execution.
26    async fn artifact(&self, execution_id: String, artifact_id: String) -> Result<Value, String>;
27
28    /// Approves a pending action and drives the next replay pass.
29    async fn approve(
30        &self,
31        execution_id: String,
32        seq: u64,
33        options: CodeModeRunOptions,
34    ) -> Result<ExecutionState, String>;
35
36    /// Rejects a pending action.
37    async fn reject(&self, execution_id: String, seq: u64) -> Result<ExecutionState, String>;
38
39    /// Cancels a running or paused execution.
40    async fn cancel(&self, execution_id: String) -> Result<ExecutionState, String>;
41}