merge: add feature contribution registry slice

This commit is contained in:
Keisuke Hirata 2026-06-05 07:25:41 +09:00
commit e3cb29982f
No known key found for this signature in database
5 changed files with 1864 additions and 10 deletions

View File

@ -9,6 +9,7 @@ use session_store::Store;
use tokio::sync::{broadcast, mpsc, oneshot};
use crate::discovery::{PodDiscovery, list_pods_tool, restore_pod_tool, send_to_peer_pod_tool};
use crate::feature::{FeatureRegistryBuilder, builtin::task_feature};
use crate::ipc::alerter::Alerter;
use crate::ipc::notify_buffer::NotifyBuffer;
use crate::ipc::server::SocketServer;
@ -502,8 +503,6 @@ where
let pod_store = pod.store().clone();
let self_parent_socket = pod.callback_socket().cloned();
let worker = pod.worker_mut();
// The Pod's SharedScope (already augmented with the bash-output
// Read rule by the caller) is the single source of truth — every
// ScopedFs (builtin tools, fs_view, compact worker) reads from it,
@ -515,14 +514,19 @@ where
// a clone for the FS view we attach below, since the tools consume
// `fs` itself.
let fs_for_view = fs.clone();
worker.register_tools(tools::builtin_tools(
pod.worker_mut().register_tools(tools::core_builtin_tools(
fs,
tracker.clone(),
task_store,
bash_output_dir,
web_config,
));
let mut feature_registry = FeatureRegistryBuilder::new();
feature_registry.add_module(task_feature(task_store));
let _feature_install_report = pod.install_features(feature_registry);
let worker = pod.worker_mut();
// Memory subsystem opt-in. When `[memory]` is present in the
// manifest, register the memory-specific Read/Write/Edit tools that
// target `<workspace>/memory/` and `<workspace>/knowledge/` with

1827
crates/pod/src/feature.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@ pub mod compact;
pub mod controller;
pub mod discovery;
pub mod entrypoint;
pub mod feature;
pub mod fs_view;
pub mod hook;
pub mod ipc;

View File

@ -28,6 +28,7 @@ use manifest::{
use crate::compact::state::CompactState;
use crate::compact::usage_tracker::UsageTracker;
use crate::feature::{FeatureRegistryBuilder, FeatureRegistryInstallReport};
use crate::hook::{
Hook, HookPreRequestAction, HookRegistryBuilder, OnAbort, OnPromptSubmit, OnTurnEnd,
PostToolCall, PreLlmRequest, PreRequestInfo, PreToolCall,
@ -784,6 +785,15 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
self.worker.as_mut().expect("worker taken during run")
}
/// Install enabled feature modules into the Pod host surfaces.
pub fn install_features(
&mut self,
registry: FeatureRegistryBuilder,
) -> FeatureRegistryInstallReport {
let worker = self.worker.as_mut().expect("worker taken during run");
registry.install_into_worker(worker, &mut self.hook_builder)
}
/// Reference to the store.
pub fn store(&self) -> &St {
&self.store

View File

@ -43,8 +43,9 @@ pub use tracker::Tracker;
pub use web::{web_fetch_tool, web_search_tool};
pub use write::write_tool;
/// Register all builtin tools, wiring them to a shared `ScopedFs`
/// (Pod-process lifetime) and `Tracker` (Pod-process lifetime).
/// Register core builtin tools that do not require Pod-local task state,
/// wiring them to a shared `ScopedFs` (Pod-process lifetime) and `Tracker`
/// (Pod-process lifetime).
///
/// All returned factories share the same tracker instance so that
/// `Read` / `Write` / `Edit` see a consistent history across tool
@ -54,14 +55,13 @@ pub use write::write_tool;
/// caller is responsible for adding that path to the readable scope
/// (see [`manifest::Scope::with_extra_read`]) so the agent can `Read`
/// the saved files.
pub fn builtin_tools(
pub fn core_builtin_tools(
fs: ScopedFs,
tracker: Tracker,
task_store: TaskStore,
bash_output_dir: std::path::PathBuf,
web_config: Option<manifest::WebConfig>,
) -> Vec<llm_worker::tool::ToolDefinition> {
let mut defs = vec![
vec![
read_tool(fs.clone(), tracker.clone()),
write_tool(fs.clone(), tracker.clone()),
edit_tool(fs.clone(), tracker),
@ -70,7 +70,19 @@ pub fn builtin_tools(
bash_tool(fs, bash_output_dir),
web_search_tool(web::WebTools::new(web_config.clone())),
web_fetch_tool(web::WebTools::new(web_config)),
];
]
}
/// Register all builtin tools, including task tools, for callers that are not
/// using the Pod feature registry path.
pub fn builtin_tools(
fs: ScopedFs,
tracker: Tracker,
task_store: TaskStore,
bash_output_dir: std::path::PathBuf,
web_config: Option<manifest::WebConfig>,
) -> Vec<llm_worker::tool::ToolDefinition> {
let mut defs = core_builtin_tools(fs, tracker, bash_output_dir, web_config);
defs.extend(task_tools(task_store));
defs
}