refactor: typed args for grep, bash, and vision tools
Convert remaining tools from manual args["key"].as_str() parsing to serde Deserialize structs. Also removes the now-unused get_str() helper from grep.rs and simplifies capture_tmux_pane() signature (takes lines directly instead of re-parsing args). All 7 tool modules now use the same typed args pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
74f05924ff
commit
5ae33a48ab
3 changed files with 52 additions and 28 deletions
|
|
@ -7,6 +7,7 @@
|
|||
// display running commands and the user can kill them (Ctrl+K).
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use std::process::Stdio;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -16,6 +17,15 @@ use tokio::sync::Mutex;
|
|||
|
||||
use crate::types::ToolDef;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Args {
|
||||
command: String,
|
||||
#[serde(default = "default_timeout")]
|
||||
timeout_secs: u64,
|
||||
}
|
||||
|
||||
fn default_timeout() -> u64 { 120 }
|
||||
|
||||
/// Info about a running child process, visible to the TUI.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ProcessInfo {
|
||||
|
|
@ -94,8 +104,10 @@ pub fn definition() -> ToolDef {
|
|||
}
|
||||
|
||||
pub async fn run_bash(args: &serde_json::Value, tracker: &ProcessTracker) -> Result<String> {
|
||||
let command = args["command"].as_str().context("command is required")?;
|
||||
let timeout_secs = args["timeout_secs"].as_u64().unwrap_or(120);
|
||||
let a: Args = serde_json::from_value(args.clone())
|
||||
.context("invalid bash arguments")?;
|
||||
let command = &a.command;
|
||||
let timeout_secs = a.timeout_secs;
|
||||
|
||||
let mut child = tokio::process::Command::new("bash")
|
||||
.arg("-c")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue