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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Per-rmcp-session in-memory map of [`SessionState`]. Populated by
//! [`crate::header_session_manager::HeaderSessionManager`] on every
//! `initialize` (fresh, no-session-id POST, or lazy-rehydration of
//! a reconnect with an id we haven't seen this process lifetime),
//! consumed by every tool handler before dispatching to the
//! executor.
//!
//! FULL-REPLACE semantics on every record: a reconnect with a new
//! header set wholesale replaces the prior entry, and missing
//! headers become `None` (filter values) / `true` (root) on the new
//! struct. Mirrors the lifecycle of
//! `objectiveai-mcp-proxy::Session::transient_headers` and the
//! `SessionRegistry` in `psychological-operations-x-api-mcp`.
//!
//! In-memory only. A process restart silently flushes the map; the
//! CLI re-sends the headers on its next request, and the
//! lazy-rehydration path re-captures them.
use HashMap;
use Arc;
use ClientObjectiveaiMcpEntry;
use AgentArguments;
use SessionId;
use RwLock;
/// Per-session state recorded by the header parser. Wraps the
/// legacy [`AgentArguments`] identity bag alongside the three
/// optional `X-OBJECTIVEAI-MCP-*` filter values, so a single
/// `(record, get, remove)` call cycle covers both. The wrapper
/// shape keeps the registry's inner map single — one entry per
/// session, projected by callers via `.args` or the `mcp_*`
/// fields as needed.
///
/// `mcp_root` resolves to `true` when the
/// `X-OBJECTIVEAI-MCP-ROOT` header is absent on connect — the
/// header parser writes the resolved value here, so anything
/// stored is the final per-session decision. `mcp_tools` /
/// `mcp_plugins` are `None` when the corresponding header is
/// absent ⇒ no filter at list time. `Some(vec![])` means
/// "explicitly allow none."
/// Shared registry of per-session [`SessionState`]. Cheap to clone
/// (the inner state is `Arc`'d).