MCPcopy Create free account
hub / github.com/GCWing/BitFun / build_tool_context

Function build_tool_context

src/apps/desktop/src/api/tool_api.rs:117–186  ·  view source on GitHub ↗
(workspace_path: Option<&str>)

Source from the content-addressed store, hash-verified

115}
116
117async fn build_tool_context(workspace_path: Option<&str>) -> ToolUseContext {
118 let normalized_workspace_path = workspace_path
119 .map(str::trim)
120 .filter(|path| !path.is_empty());
121
122 let workspace = match normalized_workspace_path {
123 Some(path) => {
124 if let Some(entry) = lookup_remote_connection(path).await {
125 let identity = workspace_session_identity(
126 path,
127 Some(&entry.connection_id),
128 Some(&entry.ssh_host),
129 )
130 .unwrap_or_else(|| {
131 bitfun_core::service::remote_ssh::workspace_state::WorkspaceSessionIdentity {
132 hostname: entry.ssh_host.clone(),
133 logical_workspace_path: entry.remote_root.clone(),
134 remote_connection_id: Some(entry.connection_id.clone()),
135 }
136 });
137 Some(WorkspaceBinding::new_remote(
138 None,
139 PathBuf::from(path),
140 entry.connection_id,
141 entry.connection_name,
142 identity,
143 ))
144 } else {
145 Some(WorkspaceBinding::new(None, PathBuf::from(path)))
146 }
147 }
148 None => None,
149 };
150
151 let workspace_services = match workspace.as_ref() {
152 Some(binding) if binding.is_remote() => {
153 let connection_id = binding.connection_id().map(str::to_string);
154 match (connection_id, get_remote_workspace_manager()) {
155 (Some(connection_id), Some(manager)) => {
156 match (
157 manager.get_file_service().await,
158 manager.get_ssh_manager().await,
159 ) {
160 (Some(file_service), Some(ssh_manager)) => Some(remote_workspace_services(
161 connection_id,
162 file_service,
163 ssh_manager,
164 binding.root_path_string(),
165 )),
166 _ => None,
167 }
168 }
169 _ => None,
170 }
171 }
172 Some(binding) => Some(local_workspace_services(binding.root_path_string())),
173 None => None,
174 };

Callers 2

validate_tool_inputFunction · 0.85
execute_toolFunction · 0.85

Calls 12

lookup_remote_connectionFunction · 0.85
local_workspace_servicesFunction · 0.85
get_file_serviceMethod · 0.80
get_ssh_managerMethod · 0.80
root_path_stringMethod · 0.80
is_emptyMethod · 0.45
cloneMethod · 0.45
is_remoteMethod · 0.45
connection_idMethod · 0.45

Tested by

no test coverage detected