Feature: Add remote_block_input to MCP remote control
A GUI automation run is interrupted the moment a person at the host touches the mouse, and locking the host's keyboard and mouse is the standard answer. The client already implements COMMAND_SCREEN_BLOCK_INPUT and the MFC screen window already sends it, so the tool needs no client change: it puts the same two-byte packet [COMMAND_SCREEN_BLOCK_INPUT][0|1] on the hidden screen sub-connection that remote_open established. The gate is remote_open's own - McpRemoteControl=1 and McpReadonly=0 - because the ability to lock someone out deserves exactly the same door as the ability to drive their desktop, and Linux and Android clients are refused with -32005: they have no branch for this packet at all and would silently ignore it. Locking a host out is only acceptable if every way back in is closed, so the session now carries its own lock state and three paths release it. block=false releases it directly. block=true always carries a deadline (max_block_ms, default 300000, clamped to 1000..3600000) and a watchdog thread started with the MCP server sweeps every 500ms for expired locks, sends the release and records it; the next remote_block_input reports it as auto_unblocked so the model learns that its lock lapsed instead of assuming it is still held. remote_close and the idle reclaim both send block=false before they tear the sub-connection down, because once that connection is gone the server has no channel left and a live client process stays blocked - all three release paths write an audit line, since none of them is something a person can see. The send happens outside the MCP lock, and the watchdog takes the session's busy flag while it releases, so it cannot interleave with an injection or race a close; a failed send keeps the lock marked and retries five seconds later rather than hammering a dead connection every tick, and a session that dies under the watchdog is erased the same way an injection would erase it. Verified against a real Windows client over MCP on a Debug x64 build: block then unblock, block with a 1.5-2s deadline left to expire and reported back as auto_unblocked with the watchdog audit entry at the expected second, block with a ten-minute deadline then remote_close with "(input lock forced off)" in the audit, and the five refusals (missing block, non-boolean block, max_block_ms out of range, unknown session, offline host). The smoke test gained [4d] for those refusals; 54 checks pass. Two limits are worth stating plainly. BlockInput only works when the calling process is elevated (or UIAccess), the client ignores the API's return value, so on an ordinary client the lock silently does nothing and the tool can only promise that the command was delivered - both the tool description and the server instructions say so. And the idle-reclaim release, like the two verified paths, is only exercised at a 300s idle timeout; it shares the same send helper and was reviewed rather than timed out live. Bin/settings.ini was restored byte-exact and the Release instance was left alone. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
27b5431130
commit
3d388f8e45
4 files changed
+406
-15
No files matched your search
@@ -514,6 +514,30 @@ if ($writeTools.Count -lt 3) {
|
||||
}
|
||||
}
|
||||
|
||||
# ===== 4d. 键鼠锁定(P10-C:remote_block_input)参数校验 =====
|
||||
# 这里刻意不真的锁定对端:冒烟测试常常跑在操作者自己的电脑上(客户端与服务端同机),
|
||||
# 真锁会把正在用电脑的人挡在外面。锁定 / 到期自动解除 / remote_close 强制解除只能人工旁观
|
||||
# 目标机来验证(见 docs/Mcp_Next_Plan.md §3.1),本节只覆盖服务端就能判定的拒绝分支。
|
||||
$blockTool = @($tools | Where-Object { $_.name -eq 'remote_block_input' }).Count -gt 0
|
||||
if (-not $blockTool) {
|
||||
Write-Host "`n[4d] 键鼠锁定:remote_block_input 未出现(McpRemoteControl=0 或 McpReadonly=1),跳过。" -ForegroundColor Yellow
|
||||
} elseif ($SkipHost -or -not $HostId) {
|
||||
Write-Host "`n[4d] 键鼠锁定:没有在线主机,跳过。" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "`n[4d] 键鼠锁定(参数校验)"
|
||||
$blockCases = @(
|
||||
@{ name = '缺 block'; args = @{ id = $HostId; session_id = 'mcp_smoke_no_such' }; code = -32602 }
|
||||
@{ name = 'block 非布尔'; args = @{ id = $HostId; session_id = 'mcp_smoke_no_such'; block = 'maybe' }; code = -32602 }
|
||||
@{ name = 'max_block_ms 越界'; args = @{ id = $HostId; session_id = 'mcp_smoke_no_such'; block = $true; max_block_ms = 500 }; code = -32602 }
|
||||
@{ name = '会话不存在'; args = @{ id = $HostId; session_id = 'mcp_smoke_no_such'; block = $true }; code = -32002 }
|
||||
@{ name = '主机不在线'; args = @{ id = '1'; session_id = 'mcp_smoke_no_such'; block = $true }; code = -32002 }
|
||||
)
|
||||
foreach ($c in $blockCases) {
|
||||
$r = Rpc '' $null 'remote_block_input' $c.args
|
||||
Check ('键鼠锁定:' + $c.name + ' 返回 ' + $c.code) ((ErrCode $r) -eq $c.code) (Detail $r)
|
||||
}
|
||||
}
|
||||
|
||||
# ===== 5. 策略拒绝(-32006) =====
|
||||
# 只在某个开关确实关闭时才有意义,所以先读 get_server_status 的 switches 再挑一个关着的功能。
|
||||
# 全部开启时跳过(不算失败)——这条不是每次都能测,但测到时能证明拒绝路径与审计都还在。
|
||||
|
||||
Reference in new issue
Block a user