[CmdletBinding()] param( [switch]$RealE2E, [string]$ResultPath = (Join-Path $env:TEMP "hardware-agent-real-e2e.json") ) $ErrorActionPreference = "Stop" $secretPath = Join-Path $env:LOCALAPPDATA "DataTerminalHardwareAgent\server-device-secret" $executablePath = Join-Path $PSScriptRoot "hardware-agent-tester-0.3.5-windows-x64.exe" if (-not (Test-Path -LiteralPath $executablePath -PathType Leaf)) { $executablePath = Join-Path $PSScriptRoot "release\hardware-agent-tester-0.3.5-windows-x64.exe" } if (-not (Test-Path -LiteralPath $secretPath -PathType Leaf)) { throw "Cloud device credential is missing: $secretPath" } if (-not (Test-Path -LiteralPath $executablePath -PathType Leaf)) { throw "Hardware agent tester is missing: $executablePath" } $env:SIMULATOR_DEFAULT_API_URL = "https://121.41.46.238" $env:SIMULATOR_DEFAULT_DEVICE_ID = "10000000-0000-0000-0000-000000000512" $env:SIMULATOR_DEFAULT_DEVICE_SECRET = [IO.File]::ReadAllText($secretPath).Trim() try { if ($RealE2E) { $env:SIMULATOR_REAL_E2E = "1" $env:SIMULATOR_AUTO_RESULT_PATH = $ResultPath $env:SIMULATOR_VOLC_MODEL_MODE = "llm" $env:SIMULATOR_REAL_E2E_QUESTION = "Please introduce yourself in one short sentence." $process = Start-Process -FilePath $executablePath -WindowStyle Hidden -PassThru -Wait if ($process.ExitCode -ne 0) { throw "Hardware agent tester exited with code $($process.ExitCode)" } if (-not (Test-Path -LiteralPath $ResultPath -PathType Leaf)) { throw "Real E2E report was not created: $ResultPath" } } else { Start-Process -FilePath $executablePath } } finally { Remove-Item Env:SIMULATOR_DEFAULT_API_URL -ErrorAction SilentlyContinue Remove-Item Env:SIMULATOR_DEFAULT_DEVICE_ID -ErrorAction SilentlyContinue Remove-Item Env:SIMULATOR_DEFAULT_DEVICE_SECRET -ErrorAction SilentlyContinue Remove-Item Env:SIMULATOR_REAL_E2E -ErrorAction SilentlyContinue Remove-Item Env:SIMULATOR_AUTO_RESULT_PATH -ErrorAction SilentlyContinue Remove-Item Env:SIMULATOR_VOLC_MODEL_MODE -ErrorAction SilentlyContinue Remove-Item Env:SIMULATOR_REAL_E2E_QUESTION -ErrorAction SilentlyContinue }