Wire up find_path tool in agent2 (#35799)

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Ben Brandt 2025-08-08 00:21:26 +02:00 committed by GitHub
parent 11efa32fa7
commit 90fa921756
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 669 additions and 247 deletions

View file

@ -19,11 +19,20 @@ impl AgentTool for EchoTool {
"echo".into()
}
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
false
fn kind(&self) -> acp::ToolKind {
acp::ToolKind::Other
}
fn run(self: Arc<Self>, input: Self::Input, _cx: &mut App) -> Task<Result<String>> {
fn initial_title(&self, _: Self::Input) -> SharedString {
"Echo".into()
}
fn run(
self: Arc<Self>,
input: Self::Input,
_event_stream: ToolCallEventStream,
_cx: &mut App,
) -> Task<Result<String>> {
Task::ready(Ok(input.text))
}
}
@ -44,11 +53,20 @@ impl AgentTool for DelayTool {
"delay".into()
}
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
false
fn initial_title(&self, input: Self::Input) -> SharedString {
format!("Delay {}ms", input.ms).into()
}
fn run(self: Arc<Self>, input: Self::Input, cx: &mut App) -> Task<Result<String>>
fn kind(&self) -> acp::ToolKind {
acp::ToolKind::Other
}
fn run(
self: Arc<Self>,
input: Self::Input,
_event_stream: ToolCallEventStream,
cx: &mut App,
) -> Task<Result<String>>
where
Self: Sized,
{
@ -71,16 +89,28 @@ impl AgentTool for ToolRequiringPermission {
"tool_requiring_permission".into()
}
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
true
fn kind(&self) -> acp::ToolKind {
acp::ToolKind::Other
}
fn run(self: Arc<Self>, _input: Self::Input, cx: &mut App) -> Task<Result<String>>
fn initial_title(&self, _input: Self::Input) -> SharedString {
"This tool requires permission".into()
}
fn run(
self: Arc<Self>,
input: Self::Input,
event_stream: ToolCallEventStream,
cx: &mut App,
) -> Task<Result<String>>
where
Self: Sized,
{
cx.foreground_executor()
.spawn(async move { Ok("Allowed".to_string()) })
let auth_check = self.authorize(input, event_stream);
cx.foreground_executor().spawn(async move {
auth_check.await?;
Ok("Allowed".to_string())
})
}
}
@ -96,11 +126,20 @@ impl AgentTool for InfiniteTool {
"infinite".into()
}
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
false
fn kind(&self) -> acp::ToolKind {
acp::ToolKind::Other
}
fn run(self: Arc<Self>, _input: Self::Input, cx: &mut App) -> Task<Result<String>> {
fn initial_title(&self, _input: Self::Input) -> SharedString {
"This is the tool that never ends... it just goes on and on my friends!".into()
}
fn run(
self: Arc<Self>,
_input: Self::Input,
_event_stream: ToolCallEventStream,
cx: &mut App,
) -> Task<Result<String>> {
cx.foreground_executor().spawn(async move {
future::pending::<()>().await;
unreachable!()
@ -137,11 +176,20 @@ impl AgentTool for WordListTool {
"word_list".into()
}
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
false
fn initial_title(&self, _input: Self::Input) -> SharedString {
"List of random words".into()
}
fn run(self: Arc<Self>, _input: Self::Input, _cx: &mut App) -> Task<Result<String>> {
fn kind(&self) -> acp::ToolKind {
acp::ToolKind::Other
}
fn run(
self: Arc<Self>,
_input: Self::Input,
_event_stream: ToolCallEventStream,
_cx: &mut App,
) -> Task<Result<String>> {
Task::ready(Ok("ok".to_string()))
}
}