Files
zesdex/src/tool/utility/pong.rs
T

45 lines
1.2 KiB
Rust
Raw Normal View History

//! Trivial connectivity-check tool.
//!
//! Flow: read the optional `message` argument → echo it back prefixed
//! with `"pong: "`, defaulting to `"pong"` when no message is supplied.
//!
//! Why: gives callers a cheap, dependency-free way to verify the tool
//! harness is reachable and responding before running real work.
use serde_json::{json, Value};
use anyhow::Result;
use super::super::Tool;
use super::super::ToolCtx;
/// Tool that echoes back a message; used for connectivity/latency checks.
pub struct Pong;
impl Tool for Pong {
fn name(&self) -> &'static str {
"pong"
}
fn description(&self) -> &'static str {
"Simple connectivity check. Echoes back any input for health checks and latency testing."
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "Message to echo back"
}
}
})
}
fn run(&self, _ctx: &ToolCtx, args: &Value) -> Result<String> {
let msg = args.get("message")
.and_then(|v| v.as_str())
.unwrap_or("pong");
Ok(format!("pong: {}", msg))
}
}