- packages/protocol: 协议定义(信封/方法/错误码/能力schema/校验/HMAC/ULID) - packages/client: 控制端客户端库(连接/握手/invoke/超时) - apps/agent: Windows 被控端(监听/HMAC认证/能力分发/7项能力/进程执行) - apps/cli: 控制端 CLI(connect/info/status/ps/services/exec/apps/install/list/invoke) - apps/mcp: MCP server(na_* 工具,接入 WorkBuddy) - scripts: install.ps1 / uninstall.ps1(开机自启 + 防火墙 + 密钥生成) - tests/e2e: 端到端测试 13/13 通过(握手/能力/超时强杀/参数校验/鉴权失败/未认证)
35 lines
1.0 KiB
PowerShell
35 lines
1.0 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
nodeagent - uninstall the Windows agent.
|
|
|
|
.DESCRIPTION
|
|
Stops and removes the scheduled task and the firewall rule.
|
|
Keeps the config (~/.nodeagent/agent.json) unless -Purge is given.
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[int]$Port = 8765,
|
|
[switch]$Purge
|
|
)
|
|
|
|
$ErrorActionPreference = "SilentlyContinue"
|
|
|
|
$isAdmin = ([Security.Principal.WindowsPrincipal] `
|
|
[Security.Principal.WindowsIdentity]::GetCurrent()
|
|
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
if (-not $isAdmin) { Write-Host "[x] Please run as Administrator."; exit 1 }
|
|
|
|
Write-Host "[*] Stopping and removing scheduled task..."
|
|
Stop-ScheduledTask -TaskName "nodeagent"
|
|
Unregister-ScheduledTask -TaskName "nodeagent" -Confirm:$false
|
|
|
|
Write-Host "[*] Removing firewall rule..."
|
|
Get-NetFirewallRule -DisplayName "nodeagent (TCP $Port)" | Remove-NetFirewallRule
|
|
|
|
if ($Purge) {
|
|
Write-Host "[*] Purging config..."
|
|
Remove-Item -Recurse -Force (Join-Path $env:USERPROFILE ".nodeagent")
|
|
}
|
|
|
|
Write-Host "[+] Uninstalled."
|