type ask to target as Ident (#2621)

This commit is contained in:
damocles 2026-07-22 18:40:26 +02:00 committed by mara
commit 3df565789c
6 changed files with 12 additions and 3 deletions

2
Cargo.lock generated
View file

@ -1556,6 +1556,7 @@ dependencies = [
"hive-agent-sock", "hive-agent-sock",
"hive-core-agent-sock", "hive-core-agent-sock",
"hive-sh4re", "hive-sh4re",
"hive-types",
"rmcp", "rmcp",
"serde", "serde",
"serde_json", "serde_json",
@ -1662,6 +1663,7 @@ name = "hive-core-agent-sock"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"hive-sh4re", "hive-sh4re",
"hive-types",
"serde", "serde",
] ]

View file

@ -17,6 +17,7 @@ clap.workspace = true
hive-agent-sock.workspace = true hive-agent-sock.workspace = true
hive-core-agent-sock.workspace = true hive-core-agent-sock.workspace = true
hive-sh4re.workspace = true hive-sh4re.workspace = true
hive-types.workspace = true
rmcp.workspace = true rmcp.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true

View file

@ -181,13 +181,17 @@ impl AgentServer {
async fn ask(&self, Parameters(args): Parameters<AskArgs>) -> String { async fn ask(&self, Parameters(args): Parameters<AskArgs>) -> String {
let log = format!("{args:?}"); let log = format!("{args:?}");
run_tool_envelope("ask", log, async move { run_tool_envelope("ask", log, async move {
let to = match args.to.map(|t| hive_types::Ident::parse(&t)).transpose() {
Ok(to) => to,
Err(reason) => return format!("invalid `to` agent name: {reason}"),
};
let (resp, retries) = self let (resp, retries) = self
.dispatch(hive_core_agent_sock::Request::Ask { .dispatch(hive_core_agent_sock::Request::Ask {
question: args.question, question: args.question,
options: args.options, options: args.options,
multi: args.multi, multi: args.multi,
ttl_seconds: args.ttl_seconds, ttl_seconds: args.ttl_seconds,
to: args.to, to,
}) })
.await; .await;
let s = match resp { let s = match resp {

View file

@ -222,7 +222,7 @@ pub(crate) async fn dispatch_shared(
options, options,
*multi, *multi,
*ttl_seconds, *ttl_seconds,
to.as_deref(), to.as_ref().map(hive_types::Ident::as_str),
) )
.map_or_else( .map_or_else(
|message| hive_core_agent_sock::Response::Err { message }, |message| hive_core_agent_sock::Response::Err { message },

View file

@ -8,4 +8,5 @@ workspace = true
[dependencies] [dependencies]
hive-sh4re.workspace = true hive-sh4re.workspace = true
hive-types.workspace = true
serde.workspace = true serde.workspace = true

View file

@ -11,6 +11,7 @@ use hive_sh4re::{
CancelLooseEndKind, ContainerInfo, DeliveredMessage, InboxRow, JournalPriority, LooseEnd, CancelLooseEndKind, ContainerInfo, DeliveredMessage, InboxRow, JournalPriority, LooseEnd,
MatrixIdentity, ReminderStats, ReminderTiming, SchedulePromptPayload, WireSchedule, MatrixIdentity, ReminderStats, ReminderTiming, SchedulePromptPayload, WireSchedule,
}; };
use hive_types::Ident;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// serde `default` helper for `Response::AgentMeta::running` (absent = true). /// serde `default` helper for `Response::AgentMeta::running` (absent = true).
@ -73,7 +74,7 @@ pub enum Request {
#[serde(default)] #[serde(default)]
ttl_seconds: Option<u64>, ttl_seconds: Option<u64>,
#[serde(default)] #[serde(default)]
to: Option<String>, to: Option<Ident>,
}, },
/// Answer a question previously routed to this agent via /// Answer a question previously routed to this agent via
/// `HelperEvent::QuestionAsked`. Authorised callers + threading /// `HelperEvent::QuestionAsked`. Authorised callers + threading