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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! Per-tenant tool allowlist — studio v2.
//!
//! Each subdomain can restrict which built-in tools the agent exposes
//! by writing tool names (one per line) to `.lh_tool_allowlist.txt` in
//! its origin's OPFS root. When the file exists and is non-empty,
//! `chat::start_session` builds a `CapabilitiesConfig` with only those
//! tools enabled. When the file is absent or empty, all tools are
//! available (unrestricted mode — the default).
//!
//! Follows the same OPFS file pattern as `system_prompt.rs`.
//! Now a thin wrapper over [`super::agent_config`] — the allowlist lives
//! in the `agent.json` manifest (with one-time migration from the legacy
//! `.lh_tool_allowlist.txt`). Golden tools that can never be disabled are
//! defined in [`GOLDEN`] and enforced at session start.
use crateBuiltinTool;
/// Tools that are always available regardless of the allowlist, so the
/// owner (or the agent) can never lock themselves out of recovery:
/// `finish` (end a turn), `ask_question` (talk to the user), and
/// `configure_agent` (change/reset the config). Enforced in
/// `chat::start_session` by unioning these into the effective set.
pub const GOLDEN: & = &;
/// Every tool an agent can be granted, grouped for the admin grid: the
/// backend-neutral builtins PLUS the closure tools (`crate::agent_tools::
/// AGENT_TOOLS` — the canonical published surface).
///
/// The grid used to render `BuiltinTool::ALL` alone (19 of ~90). That wasn't
/// just under-reporting (telemetry #76) — closure tools had no checkbox, yet a
/// SAVE writes a non-empty allowlist, and `closure_tool_allowed` grants a
/// closure tool only when the list NAMES it. So saving the all-checked grid
/// silently revoked ~71 tools the owner never chose to remove.
pub
/// Load the tool allowlist for this origin. Returns `None` when
/// unrestricted (all tools enabled).
pub async
/// The saved allowlist as raw NAMES (builtins + closure tools), or `None` when
/// unrestricted. `load()` narrows to `BuiltinTool` for the capabilities config
/// and drops closure names; the grid needs them back to paint its checkboxes.
pub async
/// Persist `names` as the new allowlist — builtins AND closure tools, since
/// `closure_tool_allowed` matches on the raw name. An empty slice reverts to
/// unrestricted.
pub async
/// Whether a NON-builtin closure tool (e.g. the `set_persona` self-edit tool)
/// is permitted by this agent's config. Unrestricted agents get it; a
/// restrictive allowlist must LIST the name to grant it — so a low-autonomy
/// agent never receives `set_persona`. Thin wrapper over
/// [`super::agent_config::closure_tool_allowed`].
pub async
/// Return a human-readable summary for the admin UI.
pub
/// How many distinct tools the grid offers — the honest denominator.
pub