pub struct AgentProcessRegistry {
inner: Mutex<HashMap<String, RegistryEntry>>,
broker: Option<Arc<Broker>>,
config: Mutex<Option<Arc<ConfigState>>>,
}Fields§
§inner: Mutex<HashMap<String, RegistryEntry>>§broker: Option<Arc<Broker>>§config: Mutex<Option<Arc<ConfigState>>>Live settings, read per spawn so a settings.json change applies to the
next agent spawn. None in tests and before bootstrap wires it.
Implementations§
Source§impl AgentProcessRegistry
impl AgentProcessRegistry
pub fn new(broker: Option<Arc<Broker>>) -> Self
Sourcepub fn set_config(&self, config: Arc<ConfigState>)
pub fn set_config(&self, config: Arc<ConfigState>)
Attach the live settings (bootstrap).
Sourcepub fn agent_below_normal_priority(&self) -> bool
pub fn agent_below_normal_priority(&self) -> bool
The agent:belownormalpriority setting; true when unset or when no
settings are attached.
Sourcepub fn set_below_normal_priority(
&self,
block_id: &str,
on: bool,
) -> Result<(), String>
pub fn set_below_normal_priority( &self, block_id: &str, on: bool, ) -> Result<(), String>
Apply (or lift) the below-normal priority limit on block_id’s tree.
Sourcepub fn ensure_tracker(&self, block_id: &str) -> Arc<dyn TrackerHandle> ⓘ
pub fn ensure_tracker(&self, block_id: &str) -> Arc<dyn TrackerHandle> ⓘ
Ensure a tracker exists for this block. Idempotent — calling twice for the same block returns the existing tracker so the job survives controller re-creation (e.g. on /clear).
Sourcepub fn ensure_tracker_kind(
&self,
block_id: &str,
agent: bool,
) -> Arc<dyn TrackerHandle> ⓘ
pub fn ensure_tracker_kind( &self, block_id: &str, agent: bool, ) -> Arc<dyn TrackerHandle> ⓘ
ensure_tracker for an agent’s block
(agent) or a terminal a person types in. The kind matters on every
Unix, where an agent gets a cgroup or the best-effort scan tracker (its
whole tree ends with it) and a terminal keeps Unix semantics: what the
user nohups outlives it.
Sourcepub fn assign_kind(
&self,
block_id: &str,
pid: u32,
agent: bool,
) -> Result<(), String>
pub fn assign_kind( &self, block_id: &str, pid: u32, agent: bool, ) -> Result<(), String>
Assign a freshly-spawned agent/shell PID to block_id’s tracker
(creating it if needed) and remember it as a root.
The tracker is an agent’s or a terminal’s (see
ensure_tracker_kind).
Sourcepub fn adopt(&self, block_id: &str, pid: u32) -> Result<bool, String>
pub fn adopt(&self, block_id: &str, pid: u32) -> Result<bool, String>
Add pid to block_id’s tracker if it has one, without marking it a
root. Ok(false) when the block has no tracker.
Sourcepub fn remove(&self, block_id: &str)
pub fn remove(&self, block_id: &str)
Drop a block’s tracker — call when the pane closes. The tracker’s
Drop impl kills the whole process tree (KILL_ON_JOB_CLOSE on
Windows, cgroup.kill on Linux; nothing on the stub).
Sourcepub fn list_block(&self, block_id: &str) -> Vec<TrackedProcess>
pub fn list_block(&self, block_id: &str) -> Vec<TrackedProcess>
Processes the agent started through its tools (see
agent_started) — for the RPC endpoint, Swarm and the pane-close
confirmation. Excludes the CLI itself, conhost and MCP servers;
kill_tree still takes all of them.
Sourcepub fn members_by_block(&self) -> Vec<BlockMembers>
pub fn members_by_block(&self) -> Vec<BlockMembers>
Every tracked block’s members for Tower: PIDs (plumbing included), the roots, the tracker’s confidence and the tree’s CPU account. The trackers are queried outside the registry lock.
Sourcepub fn confidence_of(&self, block_id: &str) -> TrackingConfidence
pub fn confidence_of(&self, block_id: &str) -> TrackingConfidence
Confidence of a block’s tracker — drives the “tracking is best-effort on macOS” badge in the swarm UI.
Sourcepub fn terminate(&self, block_id: &str) -> bool
pub fn terminate(&self, block_id: &str) -> bool
Ask everything in block_id’s tree to exit (SIGTERM on Linux), the
graceful step before remove kills what’s left.
false when nothing was asked (no tracker, or no graceful signal).
Sourcepub fn member_count(&self, block_id: &str) -> usize
pub fn member_count(&self, block_id: &str) -> usize
Every process in block_id’s tree, plumbing included; 0 without a
tracker.
Sourcepub fn kill_tree(&self, block_id: &str) -> bool
pub fn kill_tree(&self, block_id: &str) -> bool
Kill the entire process tree for a given block. Returns true
if a tracker was found (the kill was dispatched). Does NOT
synchronously wait for descendants to actually exit — the
poller’s next tick will pick up the state changes and emit
agent:process-exited events the frontend can react to.
Sourcepub fn kill_pid(&self, block_id: &str, pid: u32) -> bool
pub fn kill_pid(&self, block_id: &str, pid: u32) -> bool
Kill a single PID if it’s a member of the given block’s tree.
Returns true if the tracker was found and the PID matched.
Sourcepub fn poll_and_emit(&self)
pub fn poll_and_emit(&self)
Poll every tracked block’s membership and diff against the
last-known set. Emits agent:process-added / -exited events
for each delta.
Called by a background Tokio task on a ~2s interval.
Auto Trait Implementations§
impl !Freeze for AgentProcessRegistry
impl !RefUnwindSafe for AgentProcessRegistry
impl !UnwindSafe for AgentProcessRegistry
impl Send for AgentProcessRegistry
impl Sync for AgentProcessRegistry
impl Unpin for AgentProcessRegistry
impl UnsafeUnpin for AgentProcessRegistry
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§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>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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