Skip to main content

everruns_host/
extensions.rs

1//! Neutral extension seams for services layered above the execution host.
2
3use async_trait::async_trait;
4use everruns_core::execution_loading::SessionStore;
5use everruns_core::session_files::SessionFileSystem;
6use everruns_core::session_task::SessionTaskRegistry;
7use everruns_core::subagent_delegation::SubagentSessionDelegate;
8use everruns_core::tool_context::ToolContextExtensions;
9use everruns_core::tools::ToolRegistry;
10use everruns_provider::error::Result;
11use everruns_provider::tool_types::ToolDefinition;
12use everruns_provider::typed_id::SessionId;
13use std::sync::Arc;
14
15/// Factory for type-erased tool services supplied by a higher-level host.
16pub type ToolContextExtensionsFactory =
17    Arc<dyn Fn(i64, SessionId) -> ToolContextExtensions + Send + Sync>;
18
19/// Factory for the neutral subagent delegate supplied by a higher-level host.
20pub type SubagentDelegateFactory =
21    Arc<dyn Fn(i64, SessionId) -> Arc<dyn SubagentSessionDelegate> + Send + Sync>;
22
23/// Adds higher-level, execution-time tools without coupling the host to their
24/// implementation crate.
25#[async_trait]
26pub trait HostToolAugmentor: Send + Sync {
27    /// Return contribution IDs muted by a higher-level capability config.
28    fn disabled_hook_contributions(
29        &self,
30        _capability_id: &str,
31        _config: &serde_json::Value,
32    ) -> Vec<String> {
33        Vec::new()
34    }
35
36    /// Add definitions that should be visible to the model for this turn.
37    async fn augment_reason_tools(
38        &self,
39        session_id: SessionId,
40        session_store: Arc<dyn SessionStore>,
41        task_registry: Option<Arc<dyn SessionTaskRegistry>>,
42        definitions: &mut Vec<ToolDefinition>,
43    ) -> Result<()>;
44
45    /// Add executable tools requested by the reason phase to the act registry.
46    async fn augment_act_tools(
47        &self,
48        session_id: SessionId,
49        session_store: Arc<dyn SessionStore>,
50        task_registry: Option<Arc<dyn SessionTaskRegistry>>,
51        file_store: Arc<dyn SessionFileSystem>,
52        requested_definitions: &[ToolDefinition],
53        registry: &mut ToolRegistry,
54    ) -> Result<()>;
55}