hive-bash-mcp: add kill tool to stop a running or pending bash task
This commit is contained in:
parent
e1b7f7cbec
commit
b16629801b
4 changed files with 291 additions and 60 deletions
|
|
@ -74,7 +74,10 @@ async fn dispatch(req: DaemonRequest) -> DaemonResponse {
|
|||
&& let Some(task) = runner::wait_for_task(&id, wait).await
|
||||
&& matches!(
|
||||
task.status,
|
||||
TaskStatus::Done | TaskStatus::TimedOut | TaskStatus::Interrupted
|
||||
TaskStatus::Done
|
||||
| TaskStatus::TimedOut
|
||||
| TaskStatus::Interrupted
|
||||
| TaskStatus::Killed
|
||||
)
|
||||
{
|
||||
return DaemonResponse::ok(&serde_json::json!({
|
||||
|
|
@ -103,5 +106,30 @@ async fn dispatch(req: DaemonRequest) -> DaemonResponse {
|
|||
let tasks = runner::active_tasks();
|
||||
DaemonResponse::ok(&tasks)
|
||||
}
|
||||
|
||||
DaemonRequest::BashKill { id, force } => {
|
||||
let (killed, was_running) = runner::kill_task(&id, force);
|
||||
if !killed {
|
||||
return DaemonResponse::error(format!(
|
||||
"no running or pending task with id `{id}` (already finished or unknown)"
|
||||
));
|
||||
}
|
||||
let payload = if was_running {
|
||||
serde_json::json!({
|
||||
"id": id,
|
||||
"killed": true,
|
||||
"was_running": true,
|
||||
"signal": if force { "SIGKILL" } else { "SIGINT" },
|
||||
})
|
||||
} else {
|
||||
serde_json::json!({
|
||||
"id": id,
|
||||
"killed": true,
|
||||
"was_running": false,
|
||||
"note": "task was pending — cancelled before it started",
|
||||
})
|
||||
};
|
||||
DaemonResponse::ok(&payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue