param( [string]$OutputDir = "runs/send-sandbox-gate-package" ) $ErrorActionPreference = "Stop" Set-StrictMode -Version Latest $repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path $packageScript = Join-Path $repo "scripts\package-send-sandbox-gate.ps1" if (-not (Test-Path -LiteralPath $packageScript)) { throw "missing package script: $packageScript" } $packageRoot = Join-Path $repo $OutputDir $zipPath = "$packageRoot.zip" if (Test-Path -LiteralPath $packageRoot) { Remove-Item -LiteralPath $packageRoot -Recurse -Force } if (Test-Path -LiteralPath $zipPath) { Remove-Item -LiteralPath $zipPath -Force } & powershell -NoProfile -ExecutionPolicy Bypass -File $packageScript -OutputDir $OutputDir if ($LASTEXITCODE -ne 0) { throw "package-send-sandbox-gate.ps1 failed with exit code $LASTEXITCODE" } $requiredFiles = @( "README.txt", "OPERATOR-STEPS.md", "SANDBOX-SEND-INPUTS.template.json", "EXPECTED-RETURN-FILES.txt", "run-before-recorder.bat", "run-after-recorder.bat", "make-return-zip.ps1", "recorder\ISphereLiveProbeRecorder.exe", "recorder\variants\ISphereLiveProbeRecorder-x86.exe" ) foreach ($relative in $requiredFiles) { $path = Join-Path $packageRoot $relative if (-not (Test-Path -LiteralPath $path)) { throw "missing package file: $relative" } } $readme = Get-Content -LiteralPath (Join-Path $packageRoot "README.txt") -Raw $steps = Get-Content -LiteralPath (Join-Path $packageRoot "OPERATOR-STEPS.md") -Raw $expected = Get-Content -LiteralPath (Join-Path $packageRoot "EXPECTED-RETURN-FILES.txt") -Raw foreach ($needle in @( "LOCAL_LOGIN_UNAVAILABLE", "ONLINE_SANDBOX_REQUIRED", "MANUAL_ONE_SEND_ONLY", "DO_NOT_SEND_SECOND_TIME", "content_sha256", "idempotency_key", "success_ack_or_sent_record" )) { if ($readme -notmatch [regex]::Escape($needle) -and $steps -notmatch [regex]::Escape($needle) -and $expected -notmatch [regex]::Escape($needle)) { throw "package instructions missing required phrase: $needle" } } if (-not (Test-Path -LiteralPath $zipPath)) { throw "missing package zip: $zipPath" } $result = [ordered]@{ ok = $true package_dir = (Resolve-Path -LiteralPath $packageRoot).Path zip = (Resolve-Path -LiteralPath $zipPath).Path required_file_count = $requiredFiles.Count local_login_required = $false online_sandbox_required = $true production_send_enabled = $false } $result | ConvertTo-Json -Depth 4 -Compress