Files
isphere-ai-bridge/scripts/verify-send-file-sandbox-gate-package.ps1
2026-07-11 00:08:56 +08:00

103 lines
3.3 KiB
PowerShell

param(
[string]$OutputDir = "runs/send-file-sandbox-gate-package"
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
$packageScript = Join-Path $repo "scripts\package-send-file-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-file-sandbox-gate.ps1 failed with exit code $LASTEXITCODE"
}
$requiredFiles = @(
"README.txt",
"OPERATOR-FILE-STEPS.md",
"RETURN-FILE-CHECKLIST.md",
"FILE-SEND-INPUTS.schema.json",
"FILE-SEND-INPUTS.template.json",
"EXPECTED-FILE-RETURN-FILES.txt",
"RUN-FILE-RECORDING-SUITE.bat",
"01-run-before-file-recorder.bat",
"02-run-after-file-recorder.bat",
"03-create-file-return-zip.bat",
"FILE-RECORDING-PACKAGE-MANIFEST.json",
"run-before-file-recorder.bat",
"run-after-file-recorder.bat",
"CREATE-FILE-RETURN-ZIP.ps1",
"capability\isphere-capability-smoke.exe",
"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"
}
}
$instructionText = @(
Get-Content -LiteralPath (Join-Path $packageRoot "README.txt") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "OPERATOR-FILE-STEPS.md") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "RETURN-FILE-CHECKLIST.md") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "EXPECTED-FILE-RETURN-FILES.txt") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "FILE-SEND-INPUTS.template.json") -Raw
) -join "`n"
foreach ($needle in @(
"LOCAL_LOGIN_UNAVAILABLE",
"ONLINE_SANDBOX_REQUIRED",
"MANUAL_ONE_FILE_SEND_ONLY",
"DO_NOT_SEND_SECOND_FILE",
"RUN-FILE-RECORDING-SUITE.bat",
"FILE-SEND-INPUTS.json",
"ISPHERE_SEND_FILE_ALLOWED_DIR",
"sandbox_file_path",
"file_sha256",
"file_size_bytes",
"idempotency_key",
"operator_started_at_local",
"operator_clicked_send_file_at_local",
"operator_observed_file_success_at_local",
"before_recorder_present",
"after_recorder_present",
"file_upload_or_sent_record_present",
"duplicate_second_file_send_attempted",
"production_file_send_enabled"
)) {
if ($instructionText -notmatch [regex]::Escape($needle)) {
throw "package instructions missing required phrase: $needle"
}
}
if (-not (Test-Path -LiteralPath $zipPath)) {
throw "missing package zip: $zipPath"
}
[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_file_send_enabled = $false
} | ConvertTo-Json -Depth 4 -Compress