Skip to main content

RelayHost

Struct RelayHost 

Source
pub struct RelayHost { /* private fields */ }
Expand description

Sequential multi-adapter runner. It intentionally never polls two adapters concurrently: the next prompt depends on the prior response.

Implementations§

Source§

impl RelayHost

Source

pub fn new( hosts: Vec<AdapterHost>, max_rounds: usize, ) -> Result<Self, AdapterError>

Source

pub fn set_event_sink<F>(&mut self, sink: F)
where F: Fn(AgentEvent) + Send + Sync + 'static,

Send each normalized event to a client while a turn is being drained. The callback runs synchronously on the relay task and should only enqueue the event; expensive rendering must happen outside the callback.

Source

pub fn set_roster_names(&mut self, names: Vec<String>)

Install catalog-backed names for first-turn introductions. Direct scripted/custom adapters retain deterministic Agent N fallbacks.

Source

pub fn set_roster_identities(&mut self, identities: Vec<String>)

Install catalog identities used by the launcher and persisted session metadata. Names remain a separate display concern, so custom adapters can retain friendly labels while still restoring by stable identity.

Source

pub fn set_roster_launch_specs(&mut self, specs: Vec<(String, String)>)

Source

pub fn set_session_metadata_writer( &mut self, writer: BufferedSessionMetadataStore, )

Attach a background metadata writer. Runtime changes enqueue complete snapshots; no metadata filesystem work runs on the terminal thread.

Source

pub fn set_session_metadata_workspace(&mut self, workspace: impl Into<String>)

Source

pub fn session_metadata(&self) -> SessionMetadata

Build the Python-compatible flattened session metadata snapshot for the current active roster and owner.

Source

pub fn roster_names(&self) -> &[String]

Source

pub fn session_ids(&self) -> Vec<Option<String>>

Source

pub async fn start(&mut self) -> AdapterResult<()>

Source

pub async fn stop(&mut self) -> AdapterResult<()>

Source

pub async fn answer_permission( &mut self, slot: RosterSlot, request_id: String, answer: PermissionAnswer, ) -> AdapterResult<()>

Forward a normalized permission answer to the adapter owning slot. This keeps protocol-specific response framing out of the relay and UI.

Source

pub fn pause(&mut self)

Source

pub fn resume(&mut self)

Source

pub fn set_strategy(&mut self, strategy: CollaborationStrategy)

Select how future non-direct turns are routed. Queued prompts and the shared context remain intact when a user changes this setting.

Source

pub fn strategy(&self) -> CollaborationStrategy

Source

pub async fn set_mode(&mut self, mode: String) -> AdapterResult<()>

Apply one semantic mode to every active adapter that advertises mode support. Native adapters may translate the policy to their own IDs.

Source

pub async fn set_policy(&mut self, policy: String) -> AdapterResult<()>

Translate a CodeSwarm semantic policy to each adapter’s currently advertised native mode, falling back to conventional IDs before the first catalog update arrives.

Source

pub async fn reload(&mut self, slot: RosterSlot) -> AdapterResult<()>

Source

pub async fn drop_agent(&mut self, slot: RosterSlot) -> AdapterResult<()>

Stop and tombstone a peer while preserving its stable roster slot. Owner removal remains a deliberate error; callers should close or promote through a higher-level coordinator instead.

Source

pub async fn add_agent( &mut self, host: AdapterHost, name: impl Into<String>, identity: impl Into<String>, command: impl Into<String>, ) -> AdapterResult<RosterSlot>

Start and append a new adapter in the next stable roster slot. The adapter is started before it becomes visible to the relay, so a failed add cannot leave a half-active slot behind.

Source

pub async fn promote_owner(&mut self, slot: RosterSlot) -> AdapterResult<()>

Promote an active peer to the owner slot without restarting it. The former owner is stopped and retained as a tombstoned stable slot, so queued targets and future reloads cannot silently change identity.

Source

pub fn swap_agents( &mut self, first: RosterSlot, second: RosterSlot, ) -> AdapterResult<()>

Reorder two live adapters without restarting either process. The logical slot wrapper keeps normalized events, reducer state, and permission routing aligned with the new roster order.

Source

pub fn relay(&self) -> &Relay

Source

pub fn next_slot(&self) -> RosterSlot

Source

pub fn relay_mut(&mut self) -> &mut Relay

Source

pub fn cancellation(&self) -> RelayCancellation

Source

pub fn dispatches(&self) -> &[(RosterSlot, String)]

Prompts sent to adapters, in causal dispatch order. This is useful to diagnostics and makes the context-routing boundary observable without exposing protocol-specific adapter internals.

Source

pub async fn run_turn( &mut self, task: impl Into<String>, first_slot: RosterSlot, ) -> AdapterResult<RelayDecision>

Source

pub async fn run_turn_with_permissions( &mut self, task: impl Into<String>, first_slot: RosterSlot, permissions: &mut UnboundedReceiver<RelayPermissionAnswer>, ) -> AdapterResult<RelayDecision>

Trait Implementations§

Source§

impl Debug for RelayHost

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.