Skip to main content

Computer

Struct Computer 

Source
pub struct Computer<S: Session> { /* private fields */ }
Expand description

Computer核心结构体 / Core Computer struct

Implementations§

Source§

impl<S: Session> Computer<S>

Source

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

Source

pub fn with_confirm_callback<F>(self, callback: F) -> Self
where F: Fn(&str, &str, &str, &Value) -> bool + Send + Sync + 'static,

设置确认回调函数 / Set confirmation callback function

Source

pub fn name(&self) -> &str

获取计算机名称 / Get computer name

Source

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

Source

pub async fn boot_up(&self) -> ComputerResult<()>

启动Computer / Boot up the computer

Source

pub async fn add_or_update_server( &self, server: MCPServerConfig, ) -> ComputerResult<()>

动态添加或更新服务器配置 / Add or update server configuration dynamically

Source

pub async fn remove_server(&self, server_name: &str) -> ComputerResult<()>

移除服务器配置 / Remove server configuration

Source

pub async fn update_inputs( &self, inputs: HashMap<String, MCPServerInput>, ) -> ComputerResult<()>

更新inputs定义 / Update inputs definition

Source

pub async fn add_or_update_input( &self, input: MCPServerInput, ) -> ComputerResult<()>

添加或更新单个input / Add or update single input

Source

pub async fn remove_input(&self, input_id: &str) -> ComputerResult<bool>

移除input / Remove input

Source

pub async fn get_input( &self, input_id: &str, ) -> ComputerResult<Option<MCPServerInput>>

获取input定义 / Get input definition

Source

pub async fn list_inputs(&self) -> ComputerResult<Vec<MCPServerInput>>

列出所有inputs / List all inputs

Source

pub async fn get_input_value( &self, input_id: &str, ) -> ComputerResult<Option<Value>>

获取输入值 / Get input value

Source

pub async fn set_input_value( &self, input_id: &str, value: Value, ) -> ComputerResult<bool>

设置输入值 / Set input value

Source

pub async fn remove_input_value(&self, input_id: &str) -> ComputerResult<bool>

移除输入值 / Remove input value

Source

pub async fn list_input_values(&self) -> ComputerResult<HashMap<String, Value>>

列出所有输入值 / List all input values

Source

pub async fn clear_input_values( &self, input_id: Option<&str>, ) -> ComputerResult<()>

清空输入值缓存 / Clear input value cache

Source

pub async fn get_available_tools(&self) -> ComputerResult<Vec<Tool>>

获取可用工具列表 / Get available tools list

Source

pub async fn execute_tool( &self, req_id: &str, tool_name: &str, parameters: Value, timeout: Option<f64>, ) -> ComputerResult<CallToolResult>

执行工具调用 / Execute tool call

Source

pub async fn get_tool_history(&self) -> ComputerResult<Vec<ToolCallRecord>>

获取工具调用历史 / Get tool call history

Source

pub async fn get_server_status(&self) -> Vec<(String, bool, String)>

获取服务器状态列表 / Get server status list

Source

pub async fn list_mcp_servers(&self) -> Vec<MCPServerConfig>

列出 MCP 服务器配置 / List MCP server configurations

Source

pub async fn start_mcp_client(&self, server_name: &str) -> ComputerResult<()>

启动 MCP 客户端 / Start MCP client

Source

pub async fn stop_mcp_client(&self, server_name: &str) -> ComputerResult<()>

停止 MCP 客户端 / Stop MCP client

Source

pub async fn is_mcp_manager_initialized(&self) -> bool

检查 MCP Manager 是否已初始化 / Check if MCP Manager is initialized

Source

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

Source

pub async fn connect_socketio( &self, url: &str, _namespace: &str, auth: &Option<String>, _headers: &Option<String>, ) -> ComputerResult<()>

连接Socket.IO服务器 / Connect to Socket.IO server

Source

pub async fn disconnect_socketio(&self) -> ComputerResult<()>

断开Socket.IO连接 / Disconnect Socket.IO

Source

pub async fn join_office( &self, office_id: &str, _computer_name: &str, ) -> ComputerResult<()>

加入办公室 / Join office

Source

pub async fn leave_office(&self) -> ComputerResult<()>

离开办公室 / Leave office

Source

pub async fn emit_update_config(&self) -> ComputerResult<()>

发送配置更新通知 / Emit config update notification

Source

pub async fn shutdown(&self) -> ComputerResult<()>

关闭Computer / Shutdown computer

Trait Implementations§

Source§

impl<S: Session + Clone> Clone for Computer<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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,

处理管理器变更 / Handle manager change

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more