mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-11-01 02:10:50 +08:00
feat(mcp): 用 MCP 服务替换内置 AI Agent (#319)
在现有 HTTP 服务挂载 /mcp,让外部 AI 经共享 API Key 调用原分辨率截图、批量键鼠、ATX/WOL 和虚拟介质八个工具。所有调用共用有界 FIFO 和全局限流,复用现有采集管线与硬件控制器。 移除内置模型调用、网页 Agent 面板及旧配置,设置页提供可持续查看的 Key、统一的地址/密钥复制样式。补齐 DEB 的 libudev1 运行依赖。 验证:583 项 Rust 库测试、前端生产构建、ARMv7 设备视觉操作与介质/WOL 实测,以及默认 Release 构建和 DEB 包校验通过。 Refs #319
This commit is contained in:
28
src/state.rs
28
src/state.rs
@@ -4,7 +4,6 @@ use tokio::sync::{broadcast, watch, Mutex, RwLock};
|
||||
use crate::atx::AtxController;
|
||||
use crate::audio::AudioController;
|
||||
use crate::auth::{SessionStore, TwoFactorService, UserStore};
|
||||
use crate::computer_use::ComputerUseManager;
|
||||
use crate::config::ConfigStore;
|
||||
use crate::db::DatabasePool;
|
||||
#[cfg(unix)]
|
||||
@@ -15,6 +14,7 @@ use crate::events::{
|
||||
};
|
||||
use crate::extensions::{ExtensionId, ExtensionManager};
|
||||
use crate::hid::HidController;
|
||||
use crate::mcp::{McpHardware, McpService};
|
||||
#[cfg(unix)]
|
||||
use crate::msd::MsdController;
|
||||
#[cfg(unix)]
|
||||
@@ -72,7 +72,7 @@ pub struct AppState {
|
||||
pub stream_manager: Arc<VideoStreamManager>,
|
||||
pub webrtc: Arc<WebRtcStreamer>,
|
||||
pub hid: Arc<HidController>,
|
||||
pub computer_use: Arc<ComputerUseManager>,
|
||||
pub mcp: Arc<McpService>,
|
||||
#[cfg(unix)]
|
||||
pub msd: Arc<RwLock<Option<MsdController>>>,
|
||||
pub atx: Arc<RwLock<Option<AtxController>>>,
|
||||
@@ -104,7 +104,6 @@ impl AppState {
|
||||
stream_manager: Arc<VideoStreamManager>,
|
||||
webrtc: Arc<WebRtcStreamer>,
|
||||
hid: Arc<HidController>,
|
||||
computer_use: Arc<ComputerUseManager>,
|
||||
#[cfg(unix)] msd: Option<MsdController>,
|
||||
atx: Option<AtxController>,
|
||||
audio: Arc<AudioController>,
|
||||
@@ -138,6 +137,23 @@ impl AppState {
|
||||
data_dir.clone(),
|
||||
);
|
||||
|
||||
let atx = Arc::new(RwLock::new(atx));
|
||||
let config_apply_locks = ConfigApplyLocks::new();
|
||||
let hardware = McpHardware {
|
||||
config: config.clone(),
|
||||
atx: atx.clone(),
|
||||
wol_history: db.wol_history(),
|
||||
#[cfg(unix)]
|
||||
msd: msd.clone(),
|
||||
#[cfg(unix)]
|
||||
otg_lock: config_apply_locks.otg.clone(),
|
||||
};
|
||||
let mcp = McpService::new(
|
||||
config.clone(),
|
||||
hid.clone(),
|
||||
stream_manager.clone(),
|
||||
hardware,
|
||||
);
|
||||
Arc::new(Self {
|
||||
db,
|
||||
config,
|
||||
@@ -149,10 +165,10 @@ impl AppState {
|
||||
stream_manager,
|
||||
webrtc,
|
||||
hid,
|
||||
computer_use,
|
||||
mcp,
|
||||
#[cfg(unix)]
|
||||
msd,
|
||||
atx: Arc::new(RwLock::new(atx)),
|
||||
atx,
|
||||
audio,
|
||||
usb,
|
||||
remote_access,
|
||||
@@ -163,7 +179,7 @@ impl AppState {
|
||||
watchdog: Arc::new(WatchdogController::new()),
|
||||
shutdown_tx,
|
||||
revoked_sessions: Arc::new(RwLock::new(VecDeque::new())),
|
||||
config_apply_locks: ConfigApplyLocks::new(),
|
||||
config_apply_locks,
|
||||
data_dir,
|
||||
#[cfg(unix)]
|
||||
uac_playback,
|
||||
|
||||
Reference in New Issue
Block a user