hive-bash-mcp: run tasks under bash instead of sh

This commit is contained in:
damocles 2026-06-19 01:40:09 +02:00 committed by mara
commit 2d97401fc0
3 changed files with 11 additions and 7 deletions

View file

@ -151,7 +151,7 @@ fn render_bash_status(id: &str, resp: Result<DaemonResponse>, waited: bool) -> S
#[derive(Debug, Deserialize, JsonSchema)]
struct BashRunArgs {
/// Shell command to run (passed to `sh -c`).
/// Shell command to run (passed to `bash -c`).
cmd: String,
/// Timeout in seconds. Defaults to `None` (no timeout) — task runs until
/// natural exit. Pass an explicit value to kill the task after N seconds

View file

@ -1,4 +1,4 @@
//! Bash subprocess runner: spawns `sh -c <cmd>` tasks, writes status
//! Bash subprocess runner: spawns `bash -c <cmd>` tasks, writes status
//! files under `harness/bash-tasks/`, and fires hyperhive wake signals
//! on completion. Mirrors the logic previously embedded in `hive-ag3nt`.
//!
@ -400,8 +400,12 @@ async fn run_task(mut task: TaskFile, socket: &Path) {
send_wake(socket, &id, &summary, Some((out_snippet, err_snippet))).await;
}
/// Run `sh -c cmd`, streaming output to files. Returns `(exit_code, timed_out)`.
/// Run `bash -c cmd`, streaming output to files. Returns `(exit_code, timed_out)`.
/// `timeout_secs = None` means no timeout — run until natural exit.
///
/// Tasks run under `bash`, not `sh`: on NixOS `/bin/sh` is bash in POSIX
/// mode, which disables bashisms (arrays, `[[ … ]]`, `local`, process
/// substitution, …). Agents write bash, so we invoke `bash` directly.
async fn exec_cmd(
cmd: &str,
out_path: &Path,
@ -411,7 +415,7 @@ async fn exec_cmd(
use tokio::process::Command;
// SAFETY: `nice` is async-signal-safe and modifies only the calling
// process's scheduling priority before exec. No allocations, no locks.
let mut cmd_builder = Command::new("sh");
let mut cmd_builder = Command::new("bash");
cmd_builder
.arg("-c")
.arg(cmd)

View file

@ -1419,14 +1419,14 @@ in
systemd.services.hive-bash-daemon = {
description = "bash task runner daemon for hive-bash-mcp";
wantedBy = [ "multi-user.target" ];
# The daemon runs every bash task via `Command::new("sh")` and the
# The daemon runs every bash task via `Command::new("bash")` and the
# commands themselves (hive-forge, git, jq, …) resolve from PATH.
# Pre-split this ran inside hive-ag3nt.service and inherited the
# agent's PATH; the standalone daemon needs the same or `sh` itself
# agent's PATH; the standalone daemon needs the same or `bash` itself
# isn't found (spawn fails with ENOENT, the task is marked done in
# 0s with no output / no .out/.err). Mirror the harness unit's PATH:
# NixOS appends `/bin` to each entry → /run/wrappers/bin (setuid
# sudo) + /run/current-system/sw/bin (sh, coreutils, hive-forge, …).
# sudo) + /run/current-system/sw/bin (bash, coreutils, hive-forge, …).
path = [
"/run/wrappers"
"/run/current-system/sw"