feat: add web search and fetch tools

This commit is contained in:
2026-05-29 17:58:11 +09:00
parent 7a6d9c33f3
commit 2be3a5bd36
12 changed files with 1232 additions and 5 deletions
+1
View File
@@ -13,6 +13,7 @@ grep-searcher = "0.1.16"
ignore = "0.4.25"
llm-worker = { workspace = true }
manifest = { workspace = true }
reqwest = { version = "0.13", default-features = false, features = ["json", "native-tls"] }
schemars = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
+5
View File
@@ -28,6 +28,7 @@ mod edit;
mod glob;
mod grep;
mod read;
mod web;
mod write;
pub use bash::bash_tool;
@@ -39,6 +40,7 @@ pub use read::read_tool;
pub use scoped_fs::ScopedFs;
pub use task::{TaskEntry, TaskSnapshot, TaskStatus, TaskStore, task_tools};
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`
@@ -57,6 +59,7 @@ pub fn builtin_tools(
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![
read_tool(fs.clone(), tracker.clone()),
@@ -65,6 +68,8 @@ pub fn builtin_tools(
glob_tool(fs.clone()),
grep_tool(fs.clone()),
bash_tool(fs, bash_output_dir),
web_search_tool(web::WebTools::new(web_config.clone())),
web_fetch_tool(web::WebTools::new(web_config)),
];
defs.extend(task_tools(task_store));
defs
+1 -1
View File
@@ -35,7 +35,7 @@
//! let tracker = Tracker::new(); // session lifetime
//! let bash_outputs = PathBuf::from("/run/insomnia/bash-output");
//! let task_store = tools::TaskStore::new();
//! let defs = builtin_tools(fs, tracker, task_store, bash_outputs);
//! let defs = builtin_tools(fs, tracker, task_store, bash_outputs, None);
//! ```
use std::collections::{HashMap, VecDeque};
File diff suppressed because it is too large Load Diff
+1
View File
@@ -48,6 +48,7 @@ fn setup() -> (TempDir, TempDir, Registry) {
tracker,
TaskStore::new(),
spill.path().to_path_buf(),
None,
));
(dir, spill, reg)
}
+9 -1
View File
@@ -61,6 +61,7 @@ fn setup() -> (TempDir, TempDir, Registry) {
tracker,
TaskStore::new(),
spill.path().to_path_buf(),
None,
));
(dir, spill, reg)
}
@@ -94,6 +95,8 @@ fn builtin_tools_registers_full_set() {
"TaskGet",
"TaskList",
"TaskUpdate",
"WebFetch",
"WebSearch",
"Write"
]
);
@@ -289,7 +292,7 @@ async fn edit_requires_read_across_tools() {
#[tokio::test]
async fn deterministic_tool_order_is_registration_order() {
let (_dir, _spill, reg) = setup();
// Registration order from builtin_tools(): Read, Write, Edit, Glob, Grep, Bash, TaskCreate, TaskList, TaskGet, TaskUpdate
// Registration order from builtin_tools(): Read, Write, Edit, Glob, Grep, Bash, WebSearch, WebFetch, TaskCreate, TaskList, TaskGet, TaskUpdate
let names: Vec<&str> = reg.entries.iter().map(|(m, _)| m.name.as_str()).collect();
assert_eq!(
names,
@@ -300,6 +303,8 @@ async fn deterministic_tool_order_is_registration_order() {
"Glob",
"Grep",
"Bash",
"WebSearch",
"WebFetch",
"TaskCreate",
"TaskList",
"TaskGet",
@@ -319,6 +324,8 @@ fn tool_names_match_reference_spec() {
"Glob",
"Grep",
"Bash",
"WebSearch",
"WebFetch",
"TaskCreate",
"TaskList",
"TaskGet",
@@ -344,6 +351,7 @@ async fn tracker_recent_files_tracks_read_write_edit() {
tracker.clone(),
TaskStore::new(),
spill.path().to_path_buf(),
None,
));
let a = dir.path().join("a.txt");