agent_permissions, agent_term and subagent_term take their wire contracts from swarm-wire
This commit is contained in:
parent
c06b1325e7
commit
839efd1642
1 changed files with 661 additions and 607 deletions
|
|
@ -35,7 +35,7 @@ use futures_util::{Stream, StreamExt as _, stream};
|
|||
use hive_types::term_msg::{SEND_ICON, TURN_ICON, send_recipient, turn_sender};
|
||||
use serde::Deserialize;
|
||||
use swarm_controller_api::messages::SwarmMessage;
|
||||
use swarm_queue_client::agent_term;
|
||||
use swarm_wire::agent_term;
|
||||
use utoipa::IntoParams;
|
||||
|
||||
use crate::routes::{AppState, error_problem};
|
||||
|
|
@ -104,12 +104,9 @@ pub(crate) async fn stream_messages(
|
|||
)
|
||||
})?;
|
||||
|
||||
let subscriber = crate::term_stream::subscribe(
|
||||
&client,
|
||||
swarm_queue_client::term_subject_wildcard(),
|
||||
"messages",
|
||||
)
|
||||
.await?;
|
||||
let subscriber =
|
||||
crate::term_stream::subscribe(&client, swarm_wire::term_subject_wildcard(), "messages")
|
||||
.await?;
|
||||
let roster: Arc<HashSet<String>> = Arc::new(roster.into_iter().collect());
|
||||
let history = history(&client, &roster, minutes).await;
|
||||
let seen: HashSet<SwarmMessage> = history.iter().cloned().collect();
|
||||
|
|
@ -170,7 +167,7 @@ async fn agent_history(
|
|||
let replayed = crate::term_stream::replay(
|
||||
&client,
|
||||
&agent_term::stream_name(&agent),
|
||||
swarm_queue_client::term_subject(&agent),
|
||||
swarm_wire::term_subject(&agent),
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
|
@ -203,7 +200,7 @@ fn live(
|
|||
/// The agent a main terminal subject belongs to. A subagent's subject has
|
||||
/// more tokens and names none.
|
||||
fn agent_of(subject: &str) -> Option<&str> {
|
||||
let agent = subject.strip_prefix(&swarm_queue_client::term_subject(""))?;
|
||||
let agent = subject.strip_prefix(&swarm_wire::term_subject(""))?;
|
||||
(!agent.is_empty() && !agent.contains('.')).then_some(agent)
|
||||
}
|
||||
|
||||
|
|
@ -307,12 +304,12 @@ mod tests {
|
|||
let nats = TestNats::start();
|
||||
let client = nats.client().await;
|
||||
let subscriber = client
|
||||
.subscribe(swarm_queue_client::term_subject_wildcard())
|
||||
.subscribe(swarm_wire::term_subject_wildcard())
|
||||
.await
|
||||
.expect("subscribe");
|
||||
let mut messages = Box::pin(live(subscriber, roster()));
|
||||
let atlas = swarm_queue_client::term_subject("atlas");
|
||||
let iris = swarm_queue_client::term_subject("iris");
|
||||
let atlas = swarm_wire::term_subject("atlas");
|
||||
let iris = swarm_wire::term_subject("iris");
|
||||
|
||||
publish(
|
||||
&client,
|
||||
|
|
@ -350,7 +347,7 @@ mod tests {
|
|||
.await;
|
||||
publish(
|
||||
&client,
|
||||
swarm_queue_client::subagent_term::subject("atlas", "scout"),
|
||||
swarm_wire::subagent_term::subject("atlas", "scout"),
|
||||
row(SEND_ICON, "send* → iris", "from a subagent"),
|
||||
)
|
||||
.await;
|
||||
|
|
@ -366,7 +363,7 @@ mod tests {
|
|||
let nats = TestNats::start();
|
||||
let client = nats.client().await;
|
||||
for agent in ["atlas", "iris"] {
|
||||
agent_term::open_or_create(&client, agent)
|
||||
swarm_queue_client::agent_term::open_or_create(&client, agent)
|
||||
.await
|
||||
.expect("the stream");
|
||||
}
|
||||
|
|
@ -381,8 +378,8 @@ mod tests {
|
|||
.as_secs();
|
||||
let now = iso8601_utc(i64::try_from(secs).expect("fits"));
|
||||
let earlier = iso8601_utc(i64::try_from(secs - 600).expect("fits"));
|
||||
let atlas = swarm_queue_client::term_subject("atlas");
|
||||
let iris = swarm_queue_client::term_subject("iris");
|
||||
let atlas = swarm_wire::term_subject("atlas");
|
||||
let iris = swarm_wire::term_subject("iris");
|
||||
publish(&client, atlas, stamped(&now, "send* → iris", "newer")).await;
|
||||
publish(
|
||||
&client,
|
||||
|
|
|
|||
Loading…
Reference in a new issue