blob: 1909adfdc58e4f69c56a5de299f74858c634f431 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
param(
[string]$BundlePath = 'build\Release\publish\winagent-sandbox-mcp',
[switch]$StopOnly
)
$ErrorActionPreference = 'Stop'
$repository = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$bundle = [IO.Path]::GetFullPath((Join-Path $repository $BundlePath))
$publishRoot = [IO.Path]::GetFullPath((Join-Path $repository 'build\Release\publish'))
if (-not $bundle.StartsWith($publishRoot + [IO.Path]::DirectorySeparatorChar, [StringComparison]::OrdinalIgnoreCase)) {
throw 'BundlePath must remain inside build\Release\publish.'
}
$agent = Join-Path $bundle 'agent-mcp.exe'
$configuration = Join-Path $bundle 'agent.yaml'
$matching = Get-Process -Name 'agent-mcp' -ErrorAction SilentlyContinue | Where-Object {
try { [IO.Path]::GetFullPath($_.Path).Equals($agent, [StringComparison]::OrdinalIgnoreCase) }
catch { $false }
}
foreach ($process in $matching) {
Stop-Process -Id $process.Id -Force
$process.WaitForExit()
Write-Output "Stopped published agent-mcp PID $($process.Id)."
}
if ($StopOnly) { exit 0 }
if (-not (Test-Path -LiteralPath $agent) -or -not (Test-Path -LiteralPath $configuration)) {
throw 'Published agent-mcp executable or configuration is missing.'
}
$started = Start-Process -FilePath $agent -ArgumentList @($configuration) -WorkingDirectory $bundle -WindowStyle Hidden -PassThru
Write-Output "Started published agent-mcp PID $($started.Id)."
|