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
45
46
47
//! Process-level WebSockets infrastructure shared between the
//! `agents spawn` and `functions execute` command leaves.
//!
//! Each agent-completion / function-execution call opens a single
//! upstream WebSocket connection to the API server and drives chunks
//! through it. The pieces below are the cross-cutting state every
//! such call needs:
//!
//! - [`agent_registry`] — process-owned lock claims keyed by
//! `agent_instance_hierarchy`. Mutual exclusion across processes
//! for a given agent slot. Backed by [`objectiveai_sdk::lockfile`]
//! at the per-agent layout in [`crate::command::agents::locks`].
//! - [`mcp_server`] — the in-process `objectiveai-mcp` server handle
//! the conduit forwards plugin tool calls to.
//! - [`conduit`] — the MCP reverse-attach proxy that routes WS
//! request frames out to upstream plugin MCPs.
//! - [`agent_hierarchies`] — recursive iterator trait that yields
//! every `agent_instance_hierarchy` referenced by a chunk; used
//! by the per-chunk claim hook.
//! - [`mcp_listener`] — per-`response_id` local-socket MCP endpoint
//! that forwards ops to the API over the chunk-stream WS; spawned
//! the first time a chunk surfaces a given agent-completion id.
//! - [`daemon_stream`] — the resident daemon's broadcast hub: a
//! fixed-name local socket that producers feed CLI request/response
//! streams into, fanned out to every client of the WebSocket
//! server's `/listen` route.
//! - [`daemon_execute`] — the daemon's `/execute` WebSocket route:
//! connection-per-command in-process execution for remote consumers
//! (the SDK's `WebSocketExecutor`, notably the viewer).
//! - [`websocket_agents`] — the daemon's `/agents/instances/list` WebSocket route + its
//! dedicated `agents.sock` producer socket: a live all-agents
//! active/inactive stream, driven by AIH-lockfile release.
//! - [`websocket_agent_instance`] — the daemon's
//! `/agents/instances/{*aih}` WebSocket route + its dedicated
//! `conversation.sock` producer socket: one agent's full
//! conversation, DB history + live rows teed from the log writer.