remove hive and agent apis nothing calls: build-log routes, /api/compact, host.sock list, mcp.sock wake
This commit is contained in:
parent
cbfd7b2174
commit
36c7781245
1 changed files with 115 additions and 801 deletions
|
|
@ -9,7 +9,6 @@ use std::sync::Arc;
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use hive_core_agent_sock::{Request, Response};
|
||||
use hive_sh4re::inbox::Message;
|
||||
use hive_sock_client::{LineDeadlines, RequestLine, read_request_line};
|
||||
use tokio::io::{AsyncWriteExt, BufReader};
|
||||
use tokio::net::{UnixListener, UnixStream};
|
||||
|
|
@ -209,7 +208,6 @@ async fn dispatch(
|
|||
handle_recv(coord, agent, *wait_seconds).await
|
||||
}
|
||||
hive_core_agent_sock::Request::Status => handle_status(coord, agent),
|
||||
hive_core_agent_sock::Request::Wake { from, body } => handle_wake(coord, agent, from, body),
|
||||
hive_core_agent_sock::Request::Recent { limit } => handle_recent(coord, agent, *limit),
|
||||
hive_core_agent_sock::Request::SetStatus { text } => handle_set_status(coord, text),
|
||||
hive_core_agent_sock::Request::GetAgentMeta { name } => {
|
||||
|
|
@ -278,28 +276,6 @@ async fn handle_recv(
|
|||
}
|
||||
}
|
||||
|
||||
/// `Wake` — inject a wake into `agent`'s own inbox. Persisted through
|
||||
/// the sqlite broker like any other message so it appears in message history
|
||||
/// for post-mortem.
|
||||
fn handle_wake(
|
||||
coord: &Arc<Coordinator>,
|
||||
agent: &str,
|
||||
from: &str,
|
||||
body: &str,
|
||||
) -> hive_core_agent_sock::Response {
|
||||
match coord.broker.send(&Message {
|
||||
from: hive_sh4re::manager::trusted_sender(from),
|
||||
to: agent.to_owned(),
|
||||
body: body.to_owned(),
|
||||
in_reply_to: None,
|
||||
}) {
|
||||
Ok(()) => hive_core_agent_sock::Response::Ok,
|
||||
Err(e) => hive_core_agent_sock::Response::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// `SetStatus` — validate the status text, then trigger a dashboard
|
||||
/// rescan. The harness has already written the status file to its own
|
||||
/// `state/` dir (it runs as the agent user), so this only refreshes the
|
||||
|
|
@ -461,6 +437,16 @@ mod tests {
|
|||
(dir, Arc::new(coord))
|
||||
}
|
||||
|
||||
/// A verb this daemon no longer serves fails to parse (the connection loop
|
||||
/// answers that with `parse error`, see `serve`) while a served verb parses.
|
||||
#[test]
|
||||
fn a_removed_verb_is_a_parse_error_and_a_served_one_parses() {
|
||||
let removed = br#"{"cmd":"wake","from":"x","body":"y"}"#;
|
||||
let err = serde_json::from_slice::<Request>(removed).expect_err("wake is gone");
|
||||
assert!(err.to_string().contains("unknown variant `wake`"), "{err}");
|
||||
assert!(serde_json::from_slice::<Request>(br#"{"cmd":"status"}"#).is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn serve_answers_an_over_long_line_with_an_error_and_closes() {
|
||||
let (_dir, coord) = coordinator();
|
||||
|
|
|
|||
Loading…
Reference in a new issue