1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Process-wide shared reference to the active [`AgentBus`].
//!
//! Spawned sub-agent sessions (created via the `spawn` tool) need to publish
//! on the same bus as their parent, but the tool trait's [`execute`] method
//! takes only a [`serde_json::Value`] — there is no way to thread the parent
//! bus through the call chain without changing every tool.
//!
//! Entrypoints (CLI `run`, `serve`, `tui`, `ralph`) call [`set_global`] once
//! after constructing their bus; factories that build child sessions call
//! [`global`] to attach the same bus.
//!
//! The global is set **at most once** per process. Subsequent calls to
//! [`set_global`] are no-ops.
use ;
use AgentBus;
static GLOBAL_BUS: = new;
/// Install the process-wide bus. Idempotent — first writer wins.
/// Return a clone of the process-wide bus, if one has been installed.