pub struct Computer<S: Session> { /* private fields */ }Expand description
Computer核心结构体 / Core Computer struct
Implementations§
Source§impl<S: Session> Computer<S>
impl<S: Session> Computer<S>
Sourcepub fn new(
name: impl Into<String>,
session: S,
inputs: Option<HashMap<String, MCPServerInput>>,
mcp_servers: Option<HashMap<String, MCPServerConfig>>,
auto_connect: bool,
auto_reconnect: bool,
) -> Self
pub fn new( name: impl Into<String>, session: S, inputs: Option<HashMap<String, MCPServerInput>>, mcp_servers: Option<HashMap<String, MCPServerConfig>>, auto_connect: bool, auto_reconnect: bool, ) -> Self
创建新的Computer实例 / Create new Computer instance
Sourcepub fn with_confirm_callback<F>(self, callback: F) -> Self
pub fn with_confirm_callback<F>(self, callback: F) -> Self
设置确认回调函数 / Set confirmation callback function
Sourcepub fn get_socketio_client(
&self,
) -> Arc<RwLock<Option<Arc<SmcpComputerClient>>>>
pub fn get_socketio_client( &self, ) -> Arc<RwLock<Option<Arc<SmcpComputerClient>>>>
获取 Socket.IO 客户端引用 / Get Socket.IO client reference 返回 Arc 包装的客户端,确保其生命周期 Returns Arc-wrapped client, ensuring its lifetime
Sourcepub async fn boot_up(&self) -> ComputerResult<()>
pub async fn boot_up(&self) -> ComputerResult<()>
启动Computer / Boot up the computer
Sourcepub async fn add_or_update_server(
&self,
server: MCPServerConfig,
) -> ComputerResult<()>
pub async fn add_or_update_server( &self, server: MCPServerConfig, ) -> ComputerResult<()>
动态添加或更新服务器配置 / Add or update server configuration dynamically
Sourcepub async fn remove_server(&self, server_name: &str) -> ComputerResult<()>
pub async fn remove_server(&self, server_name: &str) -> ComputerResult<()>
移除服务器配置 / Remove server configuration
Sourcepub async fn update_inputs(
&self,
inputs: HashMap<String, MCPServerInput>,
) -> ComputerResult<()>
pub async fn update_inputs( &self, inputs: HashMap<String, MCPServerInput>, ) -> ComputerResult<()>
更新inputs定义 / Update inputs definition
Sourcepub async fn add_or_update_input(
&self,
input: MCPServerInput,
) -> ComputerResult<()>
pub async fn add_or_update_input( &self, input: MCPServerInput, ) -> ComputerResult<()>
添加或更新单个input / Add or update single input
Sourcepub async fn remove_input(&self, input_id: &str) -> ComputerResult<bool>
pub async fn remove_input(&self, input_id: &str) -> ComputerResult<bool>
移除input / Remove input
Sourcepub async fn get_input(
&self,
input_id: &str,
) -> ComputerResult<Option<MCPServerInput>>
pub async fn get_input( &self, input_id: &str, ) -> ComputerResult<Option<MCPServerInput>>
获取input定义 / Get input definition
Sourcepub async fn list_inputs(&self) -> ComputerResult<Vec<MCPServerInput>>
pub async fn list_inputs(&self) -> ComputerResult<Vec<MCPServerInput>>
列出所有inputs / List all inputs
Sourcepub async fn get_input_value(
&self,
input_id: &str,
) -> ComputerResult<Option<Value>>
pub async fn get_input_value( &self, input_id: &str, ) -> ComputerResult<Option<Value>>
获取输入值 / Get input value
Sourcepub async fn set_input_value(
&self,
input_id: &str,
value: Value,
) -> ComputerResult<bool>
pub async fn set_input_value( &self, input_id: &str, value: Value, ) -> ComputerResult<bool>
设置输入值 / Set input value
Sourcepub async fn remove_input_value(&self, input_id: &str) -> ComputerResult<bool>
pub async fn remove_input_value(&self, input_id: &str) -> ComputerResult<bool>
移除输入值 / Remove input value
Sourcepub async fn list_input_values(&self) -> ComputerResult<HashMap<String, Value>>
pub async fn list_input_values(&self) -> ComputerResult<HashMap<String, Value>>
列出所有输入值 / List all input values
Sourcepub async fn clear_input_values(
&self,
input_id: Option<&str>,
) -> ComputerResult<()>
pub async fn clear_input_values( &self, input_id: Option<&str>, ) -> ComputerResult<()>
清空输入值缓存 / Clear input value cache
Sourcepub async fn get_available_tools(&self) -> ComputerResult<Vec<Tool>>
pub async fn get_available_tools(&self) -> ComputerResult<Vec<Tool>>
获取可用工具列表 / Get available tools list
Sourcepub async fn execute_tool(
&self,
req_id: &str,
tool_name: &str,
parameters: Value,
timeout: Option<f64>,
) -> ComputerResult<CallToolResult>
pub async fn execute_tool( &self, req_id: &str, tool_name: &str, parameters: Value, timeout: Option<f64>, ) -> ComputerResult<CallToolResult>
执行工具调用 / Execute tool call
Sourcepub async fn get_tool_history(&self) -> ComputerResult<Vec<ToolCallRecord>>
pub async fn get_tool_history(&self) -> ComputerResult<Vec<ToolCallRecord>>
获取工具调用历史 / Get tool call history
Sourcepub async fn get_server_status(&self) -> Vec<(String, bool, String)>
pub async fn get_server_status(&self) -> Vec<(String, bool, String)>
获取服务器状态列表 / Get server status list
Sourcepub async fn list_mcp_servers(&self) -> Vec<MCPServerConfig>
pub async fn list_mcp_servers(&self) -> Vec<MCPServerConfig>
列出 MCP 服务器配置 / List MCP server configurations
Sourcepub async fn start_mcp_client(&self, server_name: &str) -> ComputerResult<()>
pub async fn start_mcp_client(&self, server_name: &str) -> ComputerResult<()>
启动 MCP 客户端 / Start MCP client
Sourcepub async fn stop_mcp_client(&self, server_name: &str) -> ComputerResult<()>
pub async fn stop_mcp_client(&self, server_name: &str) -> ComputerResult<()>
停止 MCP 客户端 / Stop MCP client
Sourcepub async fn is_mcp_manager_initialized(&self) -> bool
pub async fn is_mcp_manager_initialized(&self) -> bool
检查 MCP Manager 是否已初始化 / Check if MCP Manager is initialized
Sourcepub async fn set_socketio_client(&self, client: Arc<SmcpComputerClient>)
pub async fn set_socketio_client(&self, client: Arc<SmcpComputerClient>)
设置Socket.IO客户端 / Set Socket.IO client 此方法会替换现有的 client(如果有)并保持强引用 This method replaces existing client (if any) and keeps strong reference
Sourcepub async fn connect_socketio(
&self,
url: &str,
_namespace: &str,
auth: &Option<String>,
_headers: &Option<String>,
) -> ComputerResult<()>
pub async fn connect_socketio( &self, url: &str, _namespace: &str, auth: &Option<String>, _headers: &Option<String>, ) -> ComputerResult<()>
连接Socket.IO服务器 / Connect to Socket.IO server
Sourcepub async fn disconnect_socketio(&self) -> ComputerResult<()>
pub async fn disconnect_socketio(&self) -> ComputerResult<()>
断开Socket.IO连接 / Disconnect Socket.IO
Sourcepub async fn join_office(
&self,
office_id: &str,
_computer_name: &str,
) -> ComputerResult<()>
pub async fn join_office( &self, office_id: &str, _computer_name: &str, ) -> ComputerResult<()>
加入办公室 / Join office
Sourcepub async fn leave_office(&self) -> ComputerResult<()>
pub async fn leave_office(&self) -> ComputerResult<()>
离开办公室 / Leave office
Sourcepub async fn emit_update_config(&self) -> ComputerResult<()>
pub async fn emit_update_config(&self) -> ComputerResult<()>
发送配置更新通知 / Emit config update notification
Sourcepub async fn shutdown(&self) -> ComputerResult<()>
pub async fn shutdown(&self) -> ComputerResult<()>
关闭Computer / Shutdown computer
Trait Implementations§
Source§impl<S: Session> ManagerChangeHandler for Computer<S>
impl<S: Session> ManagerChangeHandler for Computer<S>
Source§fn on_change<'life0, 'async_trait>(
&'life0 self,
message: ManagerChangeMessage,
) -> Pin<Box<dyn Future<Output = ComputerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_change<'life0, 'async_trait>(
&'life0 self,
message: ManagerChangeMessage,
) -> Pin<Box<dyn Future<Output = ComputerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<S> !Freeze for Computer<S>
impl<S> !RefUnwindSafe for Computer<S>
impl<S> Send for Computer<S>
impl<S> Sync for Computer<S>
impl<S> Unpin for Computer<S>where
S: Unpin,
impl<S> UnsafeUnpin for Computer<S>where
S: UnsafeUnpin,
impl<S> !UnwindSafe for Computer<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more