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
//! What a host may read of a session's tools.
use std::sync::Arc;
use rho_sdk::tool::Tool;
use crate::tools::{
mcp::{McpCatalog, McpSessionReport},
sdk_registry::AppToolSet,
todo::TodoState,
};
use crate::{
app::subagent_manager::SubagentManager,
tools::{process::ProcessManager, workflow_tracker::WorkflowRunTracker},
};
/// A read-only view of a session's tools, for hosts that list what the
/// session offers or reach its background work. It reaches nothing the
/// runtime owns: binding the tools to the session's file or search, or
/// taking a plan decision.
#[derive(Clone, Copy)]
pub(crate) struct SessionTools<'a>(&'a AppToolSet);
impl<'a> SessionTools<'a> {
pub(super) fn of(tools: &'a AppToolSet) -> Self {
Self(tools)
}
/// A view of `tools`, for host tests that have no runtime.
#[cfg(test)]
pub(in crate::app) fn of_tool_set_for_tests(tools: &'a AppToolSet) -> Self {
Self(tools)
}
/// Whether the session offers a tool named `name`.
pub(crate) fn contains(self, name: &str) -> bool {
self.0.contains(name)
}
/// The tool the session offers as `name`, to call outside a model turn.
pub(crate) fn tool_named(self, name: &str) -> Option<Arc<dyn Tool>> {
self.0.tool_named(name)
}
pub(crate) fn mcp_catalog(self) -> &'a McpCatalog {
self.0.mcp_catalog()
}
pub(crate) fn mcp_report(self) -> &'a McpSessionReport {
self.0.mcp_report()
}
/// The session's A2UI surfaces, when it offers the `ui` tool.
pub(crate) fn surfaces(self) -> Option<&'a crate::tools::ui::SurfaceHost> {
self.0.surfaces()
}
/// The session's side of the daemon's pull request service, when it
/// offers the pull request tools.
pub(crate) fn pull_requests(self) -> Option<&'a crate::app::pull_requests::PullRequestInbox> {
self.0.pull_requests()
}
/// The session's todo checklist, shared with its `todo` tool.
pub(crate) fn todo_state(self) -> TodoState {
self.0.todo_state()
}
/// The session's background processes, when it may run any. Only the
/// daemon's T3 wake watchers read them.
pub(crate) fn processes(self) -> Option<&'a ProcessManager> {
self.0.processes()
}
/// The session's in-process subagents, when it may start any. Only the
/// daemon's idle watcher reads them.
pub(crate) fn subagents(self) -> Option<&'a SubagentManager> {
self.0.subagents()
}
/// The session's workflow runs (see [`Self::processes`]).
pub(crate) fn workflow_tracker(self) -> &'a WorkflowRunTracker {
self.0.workflow_tracker()
}
}