use super::*;
impl AgentSession {
pub async fn read_file(&self, path: &str) -> Result<String> {
self.read_file_with_options(path, ReadFileOptions::default())
.await
}
pub async fn read_file_with_options(
&self,
path: &str,
options: ReadFileOptions,
) -> Result<String> {
DirectToolRuntime::from_session(self)
.read_file(path, options)
.await
}
pub async fn write_file(&self, path: &str, content: &str) -> Result<ToolCallResult> {
DirectToolRuntime::from_session(self)
.write_file(path, content)
.await
}
pub async fn ls(&self, path: Option<&str>) -> Result<ToolCallResult> {
DirectToolRuntime::from_session(self).ls(path).await
}
pub async fn edit_file(
&self,
path: &str,
old_string: &str,
new_string: &str,
replace_all: bool,
) -> Result<ToolCallResult> {
DirectToolRuntime::from_session(self)
.edit_file(path, old_string, new_string, replace_all)
.await
}
pub async fn patch_file(&self, path: &str, diff: &str) -> Result<ToolCallResult> {
DirectToolRuntime::from_session(self)
.patch_file(path, diff)
.await
}
pub async fn bash(&self, command: &str) -> Result<String> {
DirectToolRuntime::from_session(self).bash(command).await
}
pub async fn glob(&self, pattern: &str) -> Result<Vec<String>> {
DirectToolRuntime::from_session(self).glob(pattern).await
}
pub async fn grep(&self, pattern: &str) -> Result<String> {
DirectToolRuntime::from_session(self).grep(pattern).await
}
pub async fn tool(&self, name: &str, args: serde_json::Value) -> Result<ToolCallResult> {
DirectToolRuntime::from_session(self).call(name, args).await
}
pub fn tool_with_events(
&self,
name: &str,
args: serde_json::Value,
) -> (
mpsc::Receiver<AgentEvent>,
JoinHandle<Result<ToolCallResult>>,
) {
DirectToolRuntime::from_session(self).spawn_call_with_agent_events(name.to_string(), args)
}
}