claude: pipe prompt via stdin (variadic --allowedTools was eating it); + ManagerRequest::Status
This commit is contained in:
parent
9eab28a716
commit
accb1445e3
5 changed files with 34 additions and 10 deletions
|
|
@ -9,7 +9,7 @@ use hive_ag3nt::events::{Bus, LiveEvent};
|
|||
use hive_ag3nt::login::{self, LoginState};
|
||||
use hive_ag3nt::{DEFAULT_SOCKET, DEFAULT_WEB_PORT, client, mcp, web_ui};
|
||||
use hive_sh4re::{AgentRequest, AgentResponse};
|
||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||
use tokio::process::Command;
|
||||
|
||||
#[derive(Parser)]
|
||||
|
|
@ -211,6 +211,11 @@ fn format_wake_prompt(label: &str, from: &str, body: &str) -> String {
|
|||
/// the hyperhive MCP surface auto-approved. Bash pattern allow-list is on
|
||||
/// the backlog (CLAUDE.md).
|
||||
async fn run_turn(prompt: &str, mcp_config: &Path, bus: &Bus) -> Result<()> {
|
||||
// Don't pass the prompt as a positional arg: `--allowedTools <tools...>`
|
||||
// and `--tools <tools...>` are variadic in claude-code, and the
|
||||
// trailing positional gets swallowed into one of them — claude then
|
||||
// errors with "Input must be provided either through stdin or as a
|
||||
// prompt argument when using --print". Pipe via stdin instead.
|
||||
let mut child = Command::new("claude")
|
||||
.arg("--print")
|
||||
.arg("--verbose")
|
||||
|
|
@ -224,11 +229,16 @@ async fn run_turn(prompt: &str, mcp_config: &Path, bus: &Bus) -> Result<()> {
|
|||
.arg(mcp::builtin_tools_arg())
|
||||
.arg("--allowedTools")
|
||||
.arg(mcp::allowed_tools_arg())
|
||||
.arg(prompt)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()?;
|
||||
|
||||
if let Some(mut stdin) = child.stdin.take() {
|
||||
stdin.write_all(prompt.as_bytes()).await?;
|
||||
stdin.shutdown().await.ok();
|
||||
drop(stdin); // signal EOF to claude
|
||||
}
|
||||
let stdout = child.stdout.take().expect("piped stdout");
|
||||
let stderr = child.stderr.take().expect("piped stderr");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue