use crate::sandbox::Sandbox;
use crate::tools::{ToolCtx, ToolOutcome};
use schemars::JsonSchema;
use serde::Deserialize;
use serde_json::json;
use std::sync::Arc;
#[derive(Deserialize, JsonSchema)]
pub struct KillArgs {
pub id: String,
}
pub async fn kill(
_sandbox: Arc<dyn Sandbox>,
args: KillArgs,
ctx: ToolCtx,
) -> Result<ToolOutcome, String> {
if ctx.tasks.kill(&args.id) {
Ok(json!({ "status": "killed", "id": args.id }).into())
} else {
Err(format!("未找到后台任务: {}", args.id))
}
}