Files
IronRDP/testing/agentic-rdp/Invoke-InteractiveCommand.ps1
Marc-André Moreau ffedb69ca8 Add agentic RDP CLI and localhost CI workflow (#1289)
## Summary

- Add `ironrdp-agent`, a daemon-backed CLI for agentic/headless RDP
automation over local IPC
- Add mouse, keyboard, resize, wait-frame, screenshot, status, sessions,
connect/disconnect commands
- Support `.rdp` files, logging controls, and `--desktop-size WxH`
- Add a push/manual Windows workflow that enables localhost RDP, drives
`ironrdp-agent`, verifies PSRemoting, and uploads screenshot/log
artifacts

## Validation

- `cargo check -p ironrdp-agent`
- `cargo test -p ironrdp-agent`
- `cargo clippy -p ironrdp-agent --all-targets -- -D warnings`
- `cargo xtask check fmt -v`
- `cargo test -p ironrdp-agent --test ipc`
- PowerShell script parse checks
- GitHub Actions Agentic RDP workflow passed on push: run `26121877104`
  - Connected to localhost RDP at `127.0.0.1:3389`
  - Verified `1920x1080` framebuffer
  - Uploaded non-blank screenshot artifact

## Notes

Full workspace `cargo xtask check lints -v` / `cargo xtask check tests
--no-run -v` were blocked locally by the existing Windows `libopus_sys`
CMake generator issue (`Visual Studio 18 2026`), unrelated to the agent
crate path.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-02 12:35:20 -04:00

62 lines
2.1 KiB
PowerShell

[CmdletBinding()]
param(
[ValidateSet('Verify')]
[string] $Mode = 'Verify',
[string] $WorkspaceRoot = $(
if ([string]::IsNullOrWhiteSpace($env:GITHUB_WORKSPACE)) {
[System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..'))
}
else {
$env:GITHUB_WORKSPACE
}
),
[string] $EndpointPath = (Join-Path $WorkspaceRoot 'artifacts\agentic-rdp\pshost-endpoint.json'),
[string] $ArtifactsDir = (Join-Path $WorkspaceRoot 'artifacts\agentic-rdp')
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if (-not (Test-Path $EndpointPath)) {
throw "Endpoint marker was not found: $EndpointPath"
}
New-Item -Path $ArtifactsDir -ItemType Directory -Force | Out-Null
Import-Module AwakeCoding.PSRemoting -ErrorAction Stop
$endpoint = Get-Content -Path $EndpointPath -Raw | ConvertFrom-Json
$session = New-PSHostSession -HostName $endpoint.HostName -Port ([int] $endpoint.Port)
try {
$result = Invoke-Command -Session $session -ScriptBlock {
$process = Get-Process -Id $PID
$notepad = Start-Process -FilePath (Join-Path $env:WINDIR 'System32\notepad.exe') -PassThru
Start-Sleep -Seconds 3
$notepadProcess = Get-Process -Id $notepad.Id -ErrorAction Stop
Stop-Process -Id $notepad.Id -Force
[pscustomobject]@{
ProcessId = $PID
SessionId = $process.SessionId
UserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
UserInteractive = [Environment]::UserInteractive
Desktop = $env:USERPROFILE
GuiProbeProcessId = $notepadProcess.Id
GuiProbeSessionId = $notepadProcess.SessionId
}
}
if (-not $result.UserInteractive) {
throw 'Remote command did not report an interactive user session'
}
$result | ConvertTo-Json -Depth 6 | Set-Content -Path (Join-Path $ArtifactsDir 'remote-command-verification.json') -Encoding utf8NoBOM
$result | ConvertTo-Json -Compress
}
finally {
Remove-PSSession -Session $session -ErrorAction SilentlyContinue
}