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
impl RelayHost
pub fn new( hosts: Vec<AdapterHost>, max_rounds: usize, ) -> Result<Self, AdapterError>
Sourcepub fn set_event_sink<F>(&mut self, sink: F)
pub fn set_event_sink<F>(&mut self, sink: F)
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.
Sourcepub fn set_roster_names(&mut self, names: Vec<String>)
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.
Sourcepub fn set_roster_identities(&mut self, identities: Vec<String>)
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.
pub fn set_roster_launch_specs(&mut self, specs: Vec<(String, String)>)
Sourcepub fn set_session_metadata_writer(
&mut self,
writer: BufferedSessionMetadataStore,
)
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.
pub fn set_session_metadata_workspace(&mut self, workspace: impl Into<String>)
Sourcepub fn session_metadata(&self) -> SessionMetadata
pub fn session_metadata(&self) -> SessionMetadata
Build the coordinator-owned session snapshot for the active roster.
pub fn roster_names(&self) -> &[String]
pub fn session_ids(&self) -> Vec<Option<String>>
pub async fn start(&mut self) -> AdapterResult<()>
pub async fn stop(&mut self) -> AdapterResult<()>
Sourcepub async fn answer_permission(
&mut self,
slot: RosterSlot,
request_id: String,
answer: PermissionAnswer,
) -> AdapterResult<()>
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.
pub fn pause(&mut self)
pub fn resume(&mut self)
Sourcepub fn set_strategy(&mut self, strategy: CollaborationStrategy)
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.
pub fn strategy(&self) -> CollaborationStrategy
pub fn roster_identity(&self, slot: RosterSlot) -> Option<&str>
pub fn active_slot_for_identity(&self, identity: &str) -> Option<RosterSlot>
Sourcepub async fn set_mode(&mut self, mode: String) -> AdapterResult<()>
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.
pub async fn set_model( &mut self, slot: RosterSlot, model: String, ) -> AdapterResult<()>
Sourcepub async fn set_policy(&mut self, policy: String) -> AdapterResult<()>
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.
pub async fn reload(&mut self, slot: RosterSlot) -> AdapterResult<()>
Sourcepub async fn drop_agent(&mut self, slot: RosterSlot) -> AdapterResult<()>
pub async fn drop_agent(&mut self, slot: RosterSlot) -> AdapterResult<()>
Stop and tombstone an agent while preserving its stable roster slot.
Sourcepub async fn add_agent(
&mut self,
host: AdapterHost,
name: impl Into<String>,
identity: impl Into<String>,
command: impl Into<String>,
) -> AdapterResult<RosterSlot>
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.
Sourcepub fn swap_agents(
&mut self,
first: RosterSlot,
second: RosterSlot,
) -> AdapterResult<()>
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.
pub fn relay(&self) -> &Relay
pub fn next_slot(&self) -> RosterSlot
pub fn relay_mut(&mut self) -> &mut Relay
pub fn cancellation(&self) -> RelayCancellation
Sourcepub fn dispatches(&self) -> &[(RosterSlot, String)]
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.