pub struct AgentRuntime {
config: Arc<Config>,
root: PathBuf,
store: AgentRunStore,
tools: Arc<ToolRegistry>,
models: Arc<ModelRegistry>,
policy: RuntimePolicy,
approvals: Arc<dyn ApprovalHandler>,
resources: Arc<BTreeMap<String, LoadedAgentResource>>,
tool_bindings: Arc<BTreeMap<String, LoadedToolResource>>,
execution: Option<ExecutionContext>,
context_builder: Arc<dyn RunContextBuilder>,
}Fields§
§config: Arc<Config>§root: PathBuf§store: AgentRunStore§tools: Arc<ToolRegistry>§models: Arc<ModelRegistry>§policy: RuntimePolicy§approvals: Arc<dyn ApprovalHandler>§resources: Arc<BTreeMap<String, LoadedAgentResource>>§tool_bindings: Arc<BTreeMap<String, LoadedToolResource>>§execution: Option<ExecutionContext>§context_builder: Arc<dyn RunContextBuilder>Implementations§
Source§impl AgentRuntime
impl AgentRuntime
fn uses_unrecoverable_tool(&self, resource: &LoadedAgentResource) -> bool
pub(super) fn selected_binding_metadata( &self, resource: &LoadedAgentResource, ) -> Result<Value>
pub(super) fn selected_binding_metadata_with( &self, resource: &LoadedAgentResource, external: Option<&ToolRegistry>, ) -> Result<Value>
fn binding( &self, resource: &LoadedAgentResource, schema_version: i64, ) -> Result<String>
pub(super) async fn checkpoint( &self, id: &str, resource: &LoadedAgentResource, checkpoint_context: CheckpointContext<'_>, turn: u32, baseline: Option<&AgentRun>, ) -> Result<()>
Sourcepub async fn continue_run(
&self,
id: &str,
resource: &LoadedAgentResource,
input: &str,
cancel: Receiver<bool>,
) -> Result<AgentRun>
pub async fn continue_run( &self, id: &str, resource: &LoadedAgentResource, input: &str, cancel: Receiver<bool>, ) -> Result<AgentRun>
Continue one exact suspended control exchange without creating a new run.
Source§impl AgentRuntime
impl AgentRuntime
Sourcepub fn with_resources(
self,
resources: BTreeMap<String, LoadedAgentResource>,
) -> Self
pub fn with_resources( self, resources: BTreeMap<String, LoadedAgentResource>, ) -> Self
Supply an immutable resource catalog from the same resolution context as the root. Child names never trigger a second filesystem discovery.
pub(super) fn validate_delegation( &self, parent: &LoadedAgentResource, arguments: &Value, ) -> Result<()>
pub(super) async fn invoke( &self, id: &str, call_id: &str, parent: &LoadedAgentResource, arguments: Value, ) -> Result<Value>
Source§impl AgentRuntime
impl AgentRuntime
pub(super) async fn external_tools( &self, id: &str, resource: &LoadedAgentResource, ) -> Result<(ToolRegistry, Vec<Session>)>
pub(super) async fn approve_invocation( &self, id: &str, call_id: &str, tool: &str, arguments: &Value, authorization: Authorization, ) -> Result<()>
Source§impl AgentRuntime
impl AgentRuntime
Sourcepub async fn new(
config: Config,
root: &Path,
models: ModelRegistry,
) -> Result<Self>
pub async fn new( config: Config, root: &Path, models: ModelRegistry, ) -> Result<Self>
Initialize runtime history and bind all context reads to this config/DB.
pub(crate) async fn new_initialized( config: Config, root: &Path, models: ModelRegistry, ) -> Result<Self>
async fn from_initialized_config( config: Config, root: PathBuf, models: ModelRegistry, ) -> Result<Self>
Sourcepub fn with_policy(
self,
policy: RuntimePolicy,
approvals: Arc<dyn ApprovalHandler>,
) -> Self
pub fn with_policy( self, policy: RuntimePolicy, approvals: Arc<dyn ApprovalHandler>, ) -> Self
A trusted host may supply an explicit policy and approval UI. Agent TOML cannot change this ceiling. By default privileged calls need approval, and the library denies approvals until a handler is installed.
Sourcepub async fn with_tool_bindings(
self,
directories: &[ResourceDirectory],
) -> Result<Self>
pub async fn with_tool_bindings( self, directories: &[ResourceDirectory], ) -> Result<Self>
Resolve and bind standalone tool resources through the trusted core catalog. Host authority is the existing workspace read boundary; resources only narrow it.
Sourcepub async fn with_tool_binding_catalog(
self,
directories: &[ResourceDirectory],
catalog: &ToolImplementationCatalog,
authority: Arc<HostToolAuthority>,
) -> Result<Self>
pub async fn with_tool_binding_catalog( self, directories: &[ResourceDirectory], catalog: &ToolImplementationCatalog, authority: Arc<HostToolAuthority>, ) -> Result<Self>
Bind resources using a catalog and authority supplied by a trusted embedding host.
async fn bind_tool_resources( self, directories: &[ResourceDirectory], catalog: &ToolImplementationCatalog, authority: Arc<HostToolAuthority>, ) -> Result<Self>
pub fn store(&self) -> &AgentRunStore
Sourcepub async fn run(
&self,
resource: &LoadedAgentResource,
input: &str,
cancel: Receiver<bool>,
) -> Result<AgentRun>
pub async fn run( &self, resource: &LoadedAgentResource, input: &str, cancel: Receiver<bool>, ) -> Result<AgentRun>
Return persisted terminal state even for expected execution failures, so callers always receive a run ID. Storage errors remain ordinary errors.
Sourcepub(crate) async fn execute_existing_run(
&self,
run: &AgentRun,
resource: &LoadedAgentResource,
cancel: Receiver<bool>,
) -> Result<AgentRun>
pub(crate) async fn execute_existing_run( &self, run: &AgentRun, resource: &LoadedAgentResource, cancel: Receiver<bool>, ) -> Result<AgentRun>
Drive a root run whose creation was atomically linked by the task store.
async fn drive( &self, run: &AgentRun, resource: &LoadedAgentResource, request: Option<RestoredRequest>, start_turn: u32, cancel: Receiver<bool>, files: &RunFiles, ) -> Result<AgentRun>
fn remaining_time( &self, run: &AgentRun, resource: &LoadedAgentResource, ) -> Result<Duration>
fn declarations(&self, resource: &LoadedAgentResource) -> Result<Vec<ModelTool>>
fn declarations_with( &self, resource: &LoadedAgentResource, external: &ToolRegistry, ) -> Result<Vec<ModelTool>>
async fn execute( &self, run: &AgentRun, resource: &LoadedAgentResource, input: &str, restored: Option<RestoredRequest>, start_turn: u32, files: &RunFiles, pending_suspension: &mut Option<Value>, ) -> Result<RunOutcome>
async fn prepare_selected_tools( &self, id: &str, resource: &LoadedAgentResource, external: &ToolRegistry, context: &ToolContext, ) -> Result<()>
Trait Implementations§
Source§impl Clone for AgentRuntime
impl Clone for AgentRuntime
Source§fn clone(&self) -> AgentRuntime
fn clone(&self) -> AgentRuntime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AgentRuntime
impl !UnwindSafe for AgentRuntime
impl Freeze for AgentRuntime
impl Send for AgentRuntime
impl Sync for AgentRuntime
impl Unpin for AgentRuntime
impl UnsafeUnpin for AgentRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more