liminal_server/config/types/agents.rs
1//! ACCESS-013 R2: where the agent registry's bounds are written.
2
3use super::ServerConfig;
4use crate::agents::config::AgentsConfig;
5
6impl ServerConfig {
7 /// The registry's bounds from whichever place writes them: `[agents]` at
8 /// the top level, else `[auth.lys.agents]`; `None` when neither does.
9 #[must_use]
10 pub fn agents_config(&self) -> Option<AgentsConfig> {
11 self.agents.or_else(|| {
12 self.auth
13 .as_ref()
14 .and_then(|auth| auth.lys.as_ref())
15 .and_then(|lys| lys.agents)
16 })
17 }
18
19 /// The place [`Self::agents_config`] answers from, as the started line
20 /// and `liminal check` say it: `top`, `auth.lys` or `none`.
21 #[must_use]
22 pub fn agents_place(&self) -> &'static str {
23 if self.agents.is_some() {
24 "top"
25 } else if self.agents_config().is_some() {
26 "auth.lys"
27 } else {
28 "none"
29 }
30 }
31}