pub struct Runtime {
pub config: ConfigToml,
pub model_registry: ModelRegistry,
pub thread_manager: ThreadManager,
pub tool_registry: Arc<ToolRegistry>,
pub mcp_manager: Arc<McpManager>,
pub exec_policy: ExecPolicyEngine,
pub hooks: HookDispatcher,
pub jobs: JobManager,
}Expand description
Top-level runtime combining config, model registry, threads, tools, MCP, and hooks.
Fields§
§config: ConfigTomlResolved application configuration.
model_registry: ModelRegistryRegistry of available model providers.
thread_manager: ThreadManagerManages conversation thread lifecycle.
tool_registry: Arc<ToolRegistry>Registry of callable tools.
mcp_manager: Arc<McpManager>Manager for MCP server connections.
exec_policy: ExecPolicyEngineEngine for evaluating execution policy decisions.
hooks: HookDispatcherDispatcher for lifecycle hooks.
jobs: JobManagerManager for background job lifecycle.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(
config: ConfigToml,
model_registry: ModelRegistry,
state: StateStore,
tool_registry: Arc<ToolRegistry>,
mcp_manager: Arc<McpManager>,
exec_policy: ExecPolicyEngine,
hooks: HookDispatcher,
) -> Self
pub fn new( config: ConfigToml, model_registry: ModelRegistry, state: StateStore, tool_registry: Arc<ToolRegistry>, mcp_manager: Arc<McpManager>, exec_policy: ExecPolicyEngine, hooks: HookDispatcher, ) -> Self
Constructs a new Runtime, loading existing jobs from the state store.
Sourcepub async fn handle_thread(
&mut self,
req: ThreadRequest,
) -> Result<ThreadResponse>
pub async fn handle_thread( &mut self, req: ThreadRequest, ) -> Result<ThreadResponse>
Dispatches a thread request (create, start, resume, fork, list, read, etc.).
Sourcepub async fn handle_prompt(
&mut self,
req: PromptRequest,
cli_overrides: &CliRuntimeOverrides,
) -> Result<PromptResponse>
pub async fn handle_prompt( &mut self, req: PromptRequest, cli_overrides: &CliRuntimeOverrides, ) -> Result<PromptResponse>
Resolves the model for a prompt, records the message, and returns the response.
Sourcepub async fn invoke_tool(
&self,
call: ToolCall,
approval_mode: AskForApproval,
cwd: &Path,
) -> Result<Value>
pub async fn invoke_tool( &self, call: ToolCall, approval_mode: AskForApproval, cwd: &Path, ) -> Result<Value>
Evaluates execution policy and dispatches a tool call.
Sourcepub async fn mcp_startup(&self) -> McpStartupCompleteEvent
pub async fn mcp_startup(&self) -> McpStartupCompleteEvent
Starts all configured MCP servers and emits startup events via hooks.
Sourcepub fn app_status(&self) -> AppResponse
pub fn app_status(&self) -> AppResponse
Returns the current application status including all jobs and their history.
Sourcepub fn provider_default(&self) -> ProviderKind
pub fn provider_default(&self) -> ProviderKind
Returns the default model provider from the resolved configuration.
Sourcepub fn save_thread_checkpoint(
&self,
thread_id: &str,
checkpoint_id: &str,
state: &Value,
) -> Result<()>
pub fn save_thread_checkpoint( &self, thread_id: &str, checkpoint_id: &str, state: &Value, ) -> Result<()>
Saves a named checkpoint for a thread.
Sourcepub fn load_thread_checkpoint(
&self,
thread_id: &str,
checkpoint_id: Option<&str>,
) -> Result<Option<Value>>
pub fn load_thread_checkpoint( &self, thread_id: &str, checkpoint_id: Option<&str>, ) -> Result<Option<Value>>
Loads a checkpoint for a thread. Pass None for the latest.
Sourcepub fn enqueue_job(&mut self, name: impl Into<String>) -> Result<JobRecord>
pub fn enqueue_job(&mut self, name: impl Into<String>) -> Result<JobRecord>
Enqueues a new background job and persists it immediately.
Sourcepub fn set_job_running(&mut self, job_id: &str) -> Result<()>
pub fn set_job_running(&mut self, job_id: &str) -> Result<()>
Transitions a job to running and persists the change.
Sourcepub fn update_job_progress(
&mut self,
job_id: &str,
progress: u8,
detail: Option<String>,
) -> Result<()>
pub fn update_job_progress( &mut self, job_id: &str, progress: u8, detail: Option<String>, ) -> Result<()>
Updates a job’s progress and persists the change.
Sourcepub fn complete_job(&mut self, job_id: &str) -> Result<()>
pub fn complete_job(&mut self, job_id: &str) -> Result<()>
Marks a job as completed and persists the change.
Sourcepub fn fail_job(
&mut self,
job_id: &str,
detail: impl Into<String>,
) -> Result<()>
pub fn fail_job( &mut self, job_id: &str, detail: impl Into<String>, ) -> Result<()>
Marks a job as failed and persists the change.
Sourcepub fn cancel_job(&mut self, job_id: &str) -> Result<()>
pub fn cancel_job(&mut self, job_id: &str) -> Result<()>
Cancels a job and persists the change.
Sourcepub fn pause_job(&mut self, job_id: &str, detail: Option<String>) -> Result<()>
pub fn pause_job(&mut self, job_id: &str, detail: Option<String>) -> Result<()>
Pauses a job and persists the change.
Sourcepub fn resume_job(&mut self, job_id: &str, detail: Option<String>) -> Result<()>
pub fn resume_job(&mut self, job_id: &str, detail: Option<String>) -> Result<()>
Resumes a paused job and persists the change.
Sourcepub fn job_history(&self, job_id: &str) -> Vec<JobHistoryEntry>
pub fn job_history(&self, job_id: &str) -> Vec<JobHistoryEntry>
Returns the state-transition history for a job.