pub struct CodeMode { /* private fields */ }Expand description
Generic Code Mode lifecycle over interchangeable execution and storage adapters.
Implementations§
Source§impl CodeMode
impl CodeMode
Sourcepub fn new(
store: Arc<dyn RuntimeStore>,
executor: impl CodeExecutor + 'static,
connectors: Vec<Arc<dyn Connector>>,
) -> Self
pub fn new( store: Arc<dyn RuntimeStore>, executor: impl CodeExecutor + 'static, connectors: Vec<Arc<dyn Connector>>, ) -> Self
Creates a native Code Mode runtime using the system clock.
Sourcepub fn with_artifact_store(
store: Arc<dyn RuntimeStore>,
artifacts: Arc<dyn ArtifactStore>,
executor: impl CodeExecutor + 'static,
connectors: Vec<Arc<dyn Connector>>,
) -> Self
pub fn with_artifact_store( store: Arc<dyn RuntimeStore>, artifacts: Arc<dyn ArtifactStore>, executor: impl CodeExecutor + 'static, connectors: Vec<Arc<dyn Connector>>, ) -> Self
Creates Code Mode with an explicit oversized-value artifact store.
Sourcepub fn with_clock(
store: Arc<dyn RuntimeStore>,
executor: impl CodeExecutor + 'static,
connectors: Vec<Arc<dyn Connector>>,
clock: impl Clock + 'static,
) -> Self
pub fn with_clock( store: Arc<dyn RuntimeStore>, executor: impl CodeExecutor + 'static, connectors: Vec<Arc<dyn Connector>>, clock: impl Clock + 'static, ) -> Self
Creates Code Mode with an explicit platform clock.
Sourcepub fn with_clock_and_artifact_store(
store: Arc<dyn RuntimeStore>,
artifacts: Arc<dyn ArtifactStore>,
executor: impl CodeExecutor + 'static,
connectors: Vec<Arc<dyn Connector>>,
clock: impl Clock + 'static,
) -> Self
pub fn with_clock_and_artifact_store( store: Arc<dyn RuntimeStore>, artifacts: Arc<dyn ArtifactStore>, executor: impl CodeExecutor + 'static, connectors: Vec<Arc<dyn Connector>>, clock: impl Clock + 'static, ) -> Self
Creates Code Mode with explicit platform clock and artifact storage.
Sourcepub fn runtime(&self) -> Arc<CodeModeRuntime> ⓘ
pub fn runtime(&self) -> Arc<CodeModeRuntime> ⓘ
Returns the portable runtime for approvals, history, and snippets.
Sourcepub async fn instructions(&self) -> Result<String, String>
pub async fn instructions(&self) -> Result<String, String>
Returns model-facing JavaScript declarations and connector guidance.
Sourcepub async fn search(&self, query: &str) -> Result<SearchOutput, String>
pub async fn search(&self, query: &str) -> Result<SearchOutput, String>
Searches current connector methods and saved snippets.
Sourcepub async fn execution(
&self,
execution_id: &str,
) -> Result<ExecutionState, String>
pub async fn execution( &self, execution_id: &str, ) -> Result<ExecutionState, String>
Returns one execution by identifier.
Sourcepub async fn execution_snapshot(
&self,
execution_id: &str,
) -> Result<ExecutionState, String>
pub async fn execution_snapshot( &self, execution_id: &str, ) -> Result<ExecutionState, String>
Returns one bounded execution snapshot with artifact references intact.
Sourcepub async fn artifact(
&self,
execution_id: &str,
artifact_id: &str,
) -> Result<Value, String>
pub async fn artifact( &self, execution_id: &str, artifact_id: &str, ) -> Result<Value, String>
Returns one oversized value owned by an execution.
Sourcepub async fn events(
&self,
execution_id: &str,
) -> Result<Vec<ExecutionEvent>, String>
pub async fn events( &self, execution_id: &str, ) -> Result<Vec<ExecutionEvent>, String>
Returns ordered retained events for one execution.
Sourcepub async fn cancel(&self, execution_id: &str) -> Result<ExecutionState, String>
pub async fn cancel(&self, execution_id: &str) -> Result<ExecutionState, String>
Cancels a running or paused execution.
Sourcepub async fn start(&self, code: &str) -> Result<ExecutionState, String>
pub async fn start(&self, code: &str) -> Result<ExecutionState, String>
Creates a durable running execution without driving its first pass.
Sourcepub async fn execute(&self, code: &str) -> Result<ExecutionState, String>
pub async fn execute(&self, code: &str) -> Result<ExecutionState, String>
Starts and drives a new execution until it completes, fails, or pauses.
Sourcepub async fn execute_with(
&self,
code: &str,
options: CodeModeRunOptions,
) -> Result<ExecutionState, String>
pub async fn execute_with( &self, code: &str, options: CodeModeRunOptions, ) -> Result<ExecutionState, String>
Starts and drives a new execution with transport request context.
Sourcepub async fn resume(&self, execution_id: &str) -> Result<ExecutionState, String>
pub async fn resume(&self, execution_id: &str) -> Result<ExecutionState, String>
Resumes a paused execution and drives the next replay pass.
Sourcepub async fn resume_with(
&self,
execution_id: &str,
options: CodeModeRunOptions,
) -> Result<ExecutionState, String>
pub async fn resume_with( &self, execution_id: &str, options: CodeModeRunOptions, ) -> Result<ExecutionState, String>
Resumes a paused execution with transport request context.
Sourcepub async fn approve(
&self,
execution_id: &str,
seq: u64,
) -> Result<ExecutionState, String>
pub async fn approve( &self, execution_id: &str, seq: u64, ) -> Result<ExecutionState, String>
Approves a pending action and resumes only if this call won the race.
Sourcepub async fn approve_with(
&self,
execution_id: &str,
seq: u64,
options: CodeModeRunOptions,
) -> Result<ExecutionState, String>
pub async fn approve_with( &self, execution_id: &str, seq: u64, options: CodeModeRunOptions, ) -> Result<ExecutionState, String>
Approves a pending action and resumes with transport request context.
Sourcepub async fn reject(
&self,
execution_id: &str,
seq: u64,
) -> Result<ExecutionState, String>
pub async fn reject( &self, execution_id: &str, seq: u64, ) -> Result<ExecutionState, String>
Rejects a pending action and notifies connector lifecycle hooks.
Sourcepub async fn rollback(
&self,
execution_id: &str,
) -> Result<ExecutionState, String>
pub async fn rollback( &self, execution_id: &str, ) -> Result<ExecutionState, String>
Compensates applied connector actions in reverse order.
Sourcepub async fn expire(&self, max_age_ms: u64) -> Result<Vec<String>, String>
pub async fn expire(&self, max_age_ms: u64) -> Result<Vec<String>, String>
Expires stale live executions and releases connector resources.
Sourcepub async fn dispatch(&self, request: DispatchRequest) -> Result<Value, String>
pub async fn dispatch(&self, request: DispatchRequest) -> Result<Value, String>
Handles one program-to-host dispatch request.
Sourcepub async fn drive_with(
&self,
execution_id: &str,
options: CodeModeRunOptions,
) -> Result<ExecutionState, String>
pub async fn drive_with( &self, execution_id: &str, options: CodeModeRunOptions, ) -> Result<ExecutionState, String>
Drives one running execution pass with transport request context.