Skip to main content

agentmux_srv_core/backend/cli_native/
live.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! [`Env`] for the running srv: the pid table, the process table, the agent
5//! registry and the audit log.
6
7use super::pids;
8use super::reader::{Env, Event};
9use super::sender::{ProcView, SystemProcs};
10
11pub struct LiveEnv;
12
13impl Env for LiveEnv {
14    fn cli_pids(&self) -> Vec<(String, u32)> {
15        pids::snapshot()
16    }
17
18    fn procs(&self) -> &dyn ProcView {
19        &SystemProcs
20    }
21
22    fn agent_name(&self, block_id: &str) -> Option<String> {
23        crate::backend::reactive::get_global_handler().names_for_block(block_id).into_iter().next()
24    }
25
26    fn record(&self, event: Event) {
27        tracing::info!(
28            block_id = %event.block_id,
29            msg_id = %event.msg_id,
30            state = event.state,
31            seen_by = event.seen_by,
32            source = %event.source,
33            "cli-native message"
34        );
35        crate::backend::reactive::get_global_handler().audit_cli_native(&event);
36    }
37}