Skip to main content

MobHandle

Struct MobHandle 

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

Clone-cheap, thread-safe handle for interacting with a running mob.

All mutation commands are sent through an mpsc channel to the actor. Read-only operations (roster, state) bypass the actor and read from shared Arc state directly.

Implementations§

Source§

impl MobHandle

Source

pub async fn poll_events( &self, after_cursor: u64, limit: usize, ) -> Result<Vec<MobEvent>, MobError>

Poll mob events from the underlying store.

Source

pub fn status(&self) -> MobState

Current mob lifecycle state (lock-free read).

Source

pub fn definition(&self) -> &MobDefinition

Access the mob definition.

Source

pub fn mob_id(&self) -> &MobId

Mob ID.

Source

pub async fn roster(&self) -> Roster

Snapshot of the current roster.

Source

pub async fn list_members(&self) -> Vec<MobMemberListEntry>

List members as an operational projection surface.

This includes structural roster fields plus current runtime status, error/finality state, and the current session binding when known. It intentionally skips live peer-connectivity fanout so ordinary membership polling cannot stall on comms reachability lookups. For low-level structural roster visibility without runtime projection, use list_all_members.

Source

pub async fn list_members_including_retiring(&self) -> Vec<MobMemberListEntry>

List all members including those in Retiring state, with canonical lifecycle/session projection.

Like list_members, this intentionally avoids live peer-connectivity fanout. Use member_status for deep per-member inspection including live comms reachability.

Source

pub async fn list_all_members(&self) -> Vec<RosterEntry>

List all members including those in Retiring state.

The state field on each RosterEntry distinguishes Active from Retiring. Use this for observability and membership inspection where in-flight retires should be visible.

Source

pub async fn get_member(&self, meerkat_id: &MeerkatId) -> Option<RosterEntry>

Get a specific member entry.

Source

pub async fn member( &self, meerkat_id: &MeerkatId, ) -> Result<MemberHandle, MobError>

Acquire a capability-bearing handle for a specific active member.

Source

pub fn events(&self) -> MobEventsView

Access a read-only events view for polling/replay.

Source

pub async fn record_operator_action_provenance( &self, tool_name: &str, authority_context: &MobToolAuthorityContext, ) -> Result<(), MobError>

Append a dispatcher-owned operator provenance projection.

This is audit/projection data only. It must never become authorization truth.

Source

pub async fn subscribe_agent_events( &self, meerkat_id: &MeerkatId, ) -> Result<EventStream, MobError>

Subscribe to agent-level events for a specific meerkat.

Looks up the meerkat’s session ID from the roster, then subscribes to the session-level event stream via MobSessionService.

Returns MobError::MeerkatNotFound if the meerkat is not in the roster or has no session ID.

Source

pub async fn subscribe_all_agent_events(&self) -> Vec<(MeerkatId, EventStream)>

Subscribe to agent events for all active members (point-in-time snapshot).

Returns one stream per active member that has a session ID. Members spawned after this call are not included — use [subscribe_mob_events] for a continuously updated view.

Source

pub fn subscribe_mob_events(&self) -> MobEventRouterHandle

Subscribe to a continuously-updated, mob-level event bus.

Spawns an independent task that merges per-member session streams, tags each event with [AttributedEvent], and tracks roster changes (spawns/retires) automatically. Drop the returned handle to stop the router.

Source

pub fn subscribe_mob_events_with_config( &self, config: MobEventRouterConfig, ) -> MobEventRouterHandle

Like subscribe_mob_events with explicit config.

Source

pub async fn mcp_server_states(&self) -> BTreeMap<String, bool>

Snapshot of MCP server lifecycle state tracked by this runtime.

Source

pub async fn run_flow( &self, flow_id: FlowId, params: Value, ) -> Result<RunId, MobError>

Start a flow run and return its run ID.

Source

pub async fn run_flow_with_stream( &self, flow_id: FlowId, params: Value, scoped_event_tx: Option<Sender<ScopedAgentEvent>>, ) -> Result<RunId, MobError>

Start a flow run with an optional scoped stream sink.

Source

pub async fn cancel_flow(&self, run_id: RunId) -> Result<(), MobError>

Request cancellation of an in-flight flow run.

Source

pub async fn flow_status( &self, run_id: RunId, ) -> Result<Option<MobRun>, MobError>

Fetch a flow run snapshot from the run store.

Source

pub fn list_flows(&self) -> Vec<FlowId>

List all configured flow IDs in this mob definition.

Source

pub async fn spawn( &self, profile_name: ProfileName, meerkat_id: MeerkatId, initial_message: Option<ContentInput>, ) -> Result<MemberRef, MobError>

Spawn a new member from a profile and return its member reference.

Source

pub async fn spawn_with_binding( &self, profile_name: ProfileName, meerkat_id: MeerkatId, initial_message: Option<ContentInput>, binding: RuntimeBinding, ) -> Result<MemberRef, MobError>

Spawn a new member with an explicit runtime binding.

Source

pub async fn spawn_with_backend( &self, profile_name: ProfileName, meerkat_id: MeerkatId, initial_message: Option<ContentInput>, backend: Option<MobBackendKind>, ) -> Result<MemberRef, MobError>

Spawn a new member from a profile with explicit backend override.

Source

pub async fn spawn_with_options( &self, profile_name: ProfileName, meerkat_id: MeerkatId, initial_message: Option<ContentInput>, runtime_mode: Option<MobRuntimeMode>, backend: Option<MobBackendKind>, ) -> Result<MemberRef, MobError>

Spawn a new member from a profile with explicit runtime mode/backend overrides.

Source

pub async fn attach_existing_session( &self, profile_name: ProfileName, meerkat_id: MeerkatId, session_id: SessionId, runtime_mode: Option<MobRuntimeMode>, backend: Option<MobBackendKind>, ) -> Result<MemberRef, MobError>

Attach an existing session by reusing the mob spawn control-plane path.

Source

pub async fn attach_existing_session_as_orchestrator( &self, profile_name: ProfileName, meerkat_id: MeerkatId, session_id: SessionId, ) -> Result<MemberRef, MobError>

Attach an existing session as the mob orchestrator.

Source

pub async fn attach_existing_session_as_member( &self, profile_name: ProfileName, meerkat_id: MeerkatId, session_id: SessionId, ) -> Result<MemberRef, MobError>

Attach an existing session as a regular mob member.

Source

pub async fn spawn_spec( &self, spec: SpawnMemberSpec, ) -> Result<MemberRef, MobError>

Spawn a member from a fully-specified SpawnMemberSpec.

Source

pub async fn spawn_many( &self, specs: Vec<SpawnMemberSpec>, ) -> Vec<Result<MemberRef, MobError>>

Spawn multiple members in parallel.

Results preserve input order.

Source

pub async fn retire(&self, meerkat_id: MeerkatId) -> Result<(), MobError>

Retire a member, archiving its session and removing trust.

Source

pub async fn respawn( &self, meerkat_id: MeerkatId, initial_message: Option<ContentInput>, ) -> Result<MemberRespawnReceipt, MobRespawnError>

Retire a member and respawn with the same profile, labels, wiring, and mode.

This is a helper convenience over primitive mob behavior, not a machine-owned primitive. Returns a receipt on full success, or a structured error on failure. No rollback is attempted after retire.

Source

pub async fn retire_all(&self) -> Result<(), MobError>

Retire all roster members concurrently in a single actor command.

Source

pub async fn wire<T>(&self, local: MeerkatId, target: T) -> Result<(), MobError>
where T: Into<PeerTarget>,

Wire a local member to either another local member or an external peer.

Source

pub async fn unwire<T>( &self, local: MeerkatId, target: T, ) -> Result<(), MobError>
where T: Into<PeerTarget>,

Unwire a local member from either another local member or an external peer.

Source

pub async fn internal_turn( &self, meerkat_id: MeerkatId, message: impl Into<ContentInput>, ) -> Result<MemberDeliveryReceipt, MobError>

Compatibility wrapper for internal-turn submission.

Prefer MobHandle::member plus MemberHandle::internal_turn for the target 0.5 API shape.

Source

pub async fn stop(&self) -> Result<(), MobError>

Transition Running -> Stopped. Mutation commands are rejected while stopped.

Source

pub async fn resume(&self) -> Result<(), MobError>

Transition Stopped -> Running.

Source

pub async fn complete(&self) -> Result<(), MobError>

Archive all members, emit MobCompleted, and transition to Completed.

Source

pub async fn reset(&self) -> Result<(), MobError>

Wipe all runtime state and transition back to Running.

Like destroy() but keeps the actor alive and transitions to Running instead of Destroyed. The handle remains usable after reset.

Source

pub async fn destroy(&self) -> Result<(), MobError>

Retire active members, clear persisted mob storage, and terminate the actor.

Source

pub async fn task_create( &self, subject: String, description: String, blocked_by: Vec<TaskId>, ) -> Result<TaskId, MobError>

Create a task in the shared mob task board.

Source

pub async fn task_update( &self, task_id: TaskId, status: TaskStatus, owner: Option<MeerkatId>, ) -> Result<(), MobError>

Update task status/owner in the shared mob task board.

Source

pub async fn task_list(&self) -> Result<Vec<MobTask>, MobError>

List tasks from the in-memory task board projection.

Source

pub async fn task_get( &self, task_id: &TaskId, ) -> Result<Option<MobTask>, MobError>

Get a task by ID from the in-memory task board projection.

Source

pub async fn set_spawn_policy( &self, policy: Option<Arc<dyn SpawnPolicy>>, ) -> Result<(), MobError>

Set or clear the spawn policy for automatic member provisioning.

When set, external turns targeting an unknown meerkat ID will consult the policy before returning MeerkatNotFound.

Source

pub async fn shutdown(&self) -> Result<(), MobError>

Shut down the actor. After this, no more commands are accepted.

Source

pub async fn force_cancel_member( &self, meerkat_id: MeerkatId, ) -> Result<(), MobError>

Force-cancel a member’s in-flight turn via session interrupt.

Unlike retire, this does not archive the session or remove the member from the roster — it only cancels the current turn.

Source

pub async fn member_status( &self, meerkat_id: &MeerkatId, ) -> Result<MobMemberSnapshot, MobError>

Get a point-in-time execution snapshot for a member.

This is the deep inspection surface. Unlike list projections, it resolves live peer connectivity when a comms runtime is available.

Source

pub async fn wait_for_kickoff_complete( &self, timeout: Option<Duration>, ) -> Result<Vec<(MeerkatId, MobMemberSnapshot)>, MobError>

Wait until all autonomous members have been admitted to the runtime.

Autonomous members no longer run a separate kickoff turn — their initial prompt is injected through the runtime input path at spawn time. This method returns member snapshots immediately since admission is synchronous.

Source

pub async fn wait_for_members_kickoff_complete( &self, ids: &[MeerkatId], timeout: Option<Duration>, ) -> Result<Vec<(MeerkatId, MobMemberSnapshot)>, MobError>

Wait until the given autonomous members have been admitted to the runtime.

See wait_for_kickoff_complete for details.

Source

pub async fn wait_one( &self, meerkat_id: &MeerkatId, ) -> Result<MobMemberSnapshot, MobError>

Wait for a specific member to reach a terminal state, then return its snapshot.

Polls canonical member classification until terminal.

Source

pub async fn wait_all( &self, meerkat_ids: &[MeerkatId], ) -> Result<Vec<MobMemberSnapshot>, MobError>

Wait for all specified members to reach terminal states.

Source

pub async fn collect_completed(&self) -> Vec<(MeerkatId, MobMemberSnapshot)>

Collect snapshots for all members that have reached terminal states.

Source

pub async fn spawn_helper( &self, meerkat_id: MeerkatId, task: impl Into<String>, options: HelperOptions, ) -> Result<HelperResult, MobError>

Spawn a fresh helper, wait for it to complete, retire it, and return its result.

Helpers are short-lived TurnDriven tasks by default. Their completion truth is the spawn/create boundary plus the canonical post-spawn member snapshot, not full member terminality in the mob lifecycle.

Source

pub async fn fork_helper( &self, source_member_id: &MeerkatId, meerkat_id: MeerkatId, task: impl Into<String>, fork_context: ForkContext, options: HelperOptions, ) -> Result<HelperResult, MobError>

Fork from an existing member’s context, wait for completion, retire, and return.

Like spawn_helper but uses MemberLaunchMode::Fork to share conversation context with the source member.

Trait Implementations§

Source§

impl Clone for MobHandle

Source§

fn clone(&self) -> MobHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more