pub struct WorldHost { /* private fields */ }Expand description
Owns the world and the run-id map; drives the world and services control ops.
Implementations§
Source§impl WorldHost
impl WorldHost
Sourcepub fn new(world: PipelineWorld) -> Self
pub fn new(world: PipelineWorld) -> Self
Wrap a world with a fresh interaction hub.
Sourcepub fn with_interactions(
world: PipelineWorld,
interactions: InteractionHub,
) -> Self
pub fn with_interactions( world: PipelineWorld, interactions: InteractionHub, ) -> Self
Wrap a world with a specific interaction hub - the daemon shares one hub between the tool service’s per-agent backends and this host.
Sourcepub fn subagent_sender(&self) -> UnboundedSender<SubAgentOp>
pub fn subagent_sender(&self) -> UnboundedSender<SubAgentOp>
A sender for SubAgentOps. The daemon hands a clone to each agent’s tool
state so the sub-agent tools can reach the world through the host.
Sourcepub fn subscribe(&self) -> Receiver<WorldEvent>
pub fn subscribe(&self) -> Receiver<WorldEvent>
Subscribe to WorldEvents. The HTTP/WS gateway uses this (via the
control transport’s Subscribe) to push updates instead of polling.
Sourcepub fn event_sender(&self) -> Sender<WorldEvent>
pub fn event_sender(&self) -> Sender<WorldEvent>
The world-event sender, handed to the control transport so a Subscribe
connection can stream events.
Sourcepub fn set_spawner(&mut self, spawner: Spawner)
pub fn set_spawner(&mut self, spawner: Spawner)
Install the spawner used to service Spawn control ops. Without one, a
Spawn op replies with an error.
Sourcepub fn set_spawn_preprocessor(&mut self, pp: SpawnPreprocessor)
pub fn set_spawn_preprocessor(&mut self, pp: SpawnPreprocessor)
Install the async hook awaited before each top-level Spawn (see
SpawnPreprocessor).
Sourcepub fn set_reloader(&mut self, reloader: Reloader)
pub fn set_reloader(&mut self, reloader: Reloader)
Install the reloader used to page an unloaded run back in on demand. Without one, an op targeting a run that isn’t in memory just misses.
Sourcepub fn set_force_terminator(&mut self, force_terminator: ForceTerminator)
pub fn set_force_terminator(&mut self, force_terminator: ForceTerminator)
Install the ForceTerminator used to terminate a run on disk when the
world cannot hold it. Without one, a cancel that misses in the world and
can’t be reloaded just misses.
Sourcepub fn set_reaper(&mut self, reaper: Reaper)
pub fn set_reaper(&mut self, reaper: Reaper)
Install the reap hook run just before each terminal agent is despawned, so the daemon can tear down that agent’s sandbox and drop its tool state. Without one, reaping just despawns the entity (the prior behavior).
Sourcepub fn interactions(&self) -> InteractionHub
pub fn interactions(&self) -> InteractionHub
A clone of the interaction hub, for building per-agent backends.
Sourcepub fn world_mut(&mut self) -> &mut PipelineWorld
pub fn world_mut(&mut self) -> &mut PipelineWorld
Mutable access to the underlying world (for the spawner to add agents).
Sourcepub fn register(&mut self, run_id: impl Into<String>, entity: Entity)
pub fn register(&mut self, run_id: impl Into<String>, entity: Entity)
Record the run-id → entity mapping for a freshly-spawned agent.
Sourcepub fn handle(&mut self, op: ControlOp)
pub fn handle(&mut self, op: ControlOp)
Apply one control op and reply on its channel. A dropped reply receiver is harmless (the requester went away).
Sourcepub async fn flush_and_stop(&mut self)
pub async fn flush_and_stop(&mut self)
Flush all queued persistence and stop the hosted world, guaranteeing every
dirty agent’s final snapshot reaches disk (see
PipelineWorld::flush_and_stop). Invoked automatically when Self::serve
returns; also exposed directly for callers that drive the world themselves.
Sourcepub async fn serve(&mut self, control_rx: UnboundedReceiver<ControlOp>)
pub async fn serve(&mut self, control_rx: UnboundedReceiver<ControlOp>)
Run the host: drive the world to quiescence, then park until an async
result wakes it, a control op arrives, or shutdown is signalled. Returns
when shutdown fires or the control channel closes - and before returning,
flushes all queued persistence to disk (Self::flush_and_stop) so a
clean daemon shutdown never loses a dirty agent’s final snapshot.
Auto Trait Implementations§
impl !Freeze for WorldHost
impl !RefUnwindSafe for WorldHost
impl !Sync for WorldHost
impl !UnwindSafe for WorldHost
impl Send for WorldHost
impl Unpin for WorldHost
impl UnsafeUnpin for WorldHost
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.