chore: package send recording and capability tests

This commit is contained in:
zhaoyilun
2026-07-10 14:36:15 +08:00
parent 8cdaa3c0bc
commit 89d7f65b45
10 changed files with 1000 additions and 14 deletions

View File

@@ -0,0 +1,147 @@
param(
[string]$OutputDir = "runs/send-capability-test-package",
[switch]$NoZip
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
$packageDir = Join-Path $repo $OutputDir
$zipPath = "$packageDir.zip"
$helperRelative = Join-Path $OutputDir "runs\win-helper"
$helperDir = Join-Path $packageDir "runs\win-helper"
$helperExe = Join-Path $helperDir "ISphereWinHelper.exe"
$smokeExe = Join-Path $packageDir "isphere-capability-smoke.exe"
if (Test-Path -LiteralPath $packageDir) {
Remove-Item -LiteralPath $packageDir -Recurse -Force
}
if (Test-Path -LiteralPath $zipPath) {
Remove-Item -LiteralPath $zipPath -Force
}
New-Item -ItemType Directory -Force -Path $packageDir | Out-Null
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo "scripts\build-win-helper.ps1") -OutputDir $helperRelative -Platform anycpu
if ($LASTEXITCODE -ne 0) {
throw "build-win-helper.ps1 failed with exit code $LASTEXITCODE"
}
if (-not (Test-Path -LiteralPath $helperExe)) {
throw "helper executable was not created: $helperExe"
}
Push-Location $repo
try {
& go build -o $smokeExe ./cmd/isphere-capability-smoke
if ($LASTEXITCODE -ne 0) {
throw "go build ./cmd/isphere-capability-smoke failed with exit code $LASTEXITCODE"
}
}
finally {
Pop-Location
}
if (-not (Test-Path -LiteralPath $smokeExe)) {
throw "capability smoke executable was not created: $smokeExe"
}
@'
iSphere Send Capability Test Package
LOCAL_LOGIN_UNAVAILABLE: this package does not require local iSphere login.
NO_REAL_SEND: this package does not send real messages or files.
What to run:
1. Extract the zip to a normal folder.
2. Double-click run-capability-test.bat, or run:
.\isphere-capability-smoke.exe
What it tests:
- the MCP server initializes with the expected 9 tools;
- ISphereWinHelper can be called through the packaged helper path;
- receive messages / receive files / search contacts / search groups work against offline fixtures;
- isphere_send_message preview returns planned with no side effects;
- production send returns blocked and production_send_enabled remains false.
What it does not do:
- it does not log in to iSphere;
- it does not click, type, upload, or send;
- it does not hook or inject into the client;
- it does not modify iSphere client data.
Expected final JSON fields:
- ok=true
- tool_count=9
- helper_name=ISphereWinHelper
- send_preview_tool_present=true
- production_send_enabled=false
- local_login_required=false
- no_real_send=true
'@ | Set-Content -LiteralPath (Join-Path $packageDir "README.txt") -Encoding ASCII
@'
Expected capability smoke result:
Required:
- ok = true
- tool_count = 9
- helper_name = ISphereWinHelper
- receive_message_count = 0
- contact_count = 0
- group_count = 0
- file_count = 0
- fixture_receive_message_count = 1
- fixture_contact_count = 1
- fixture_group_count = 1
- fixture_file_count = 1
- fixture_dir_receive_message_count = 1
- fixture_dir_contact_count = 1
- fixture_dir_group_count = 1
- fixture_dir_file_count = 1
- send_preview_tool_present = true
- production_send_enabled = false
- local_login_required = false
- real_isphere_login_required = false
- no_real_send = true
If production_send_enabled is true, treat the package as failed.
If no_real_send is false, treat the package as failed.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "EXPECTED-RESULTS.txt") -Encoding ASCII
@'
@echo off
setlocal
cd /d "%~dp0"
echo Running iSphere capability smoke test...
isphere-capability-smoke.exe
echo exit code: %ERRORLEVEL%
pause
exit /b %ERRORLEVEL%
'@ | Set-Content -LiteralPath (Join-Path $packageDir "run-capability-test.bat") -Encoding ASCII
@'
{
"package": "send-capability-test",
"LOCAL_LOGIN_UNAVAILABLE": true,
"NO_REAL_SEND": true,
"entrypoint": "run-capability-test.bat",
"smoke_exe": "isphere-capability-smoke.exe",
"helper_exe": "runs/win-helper/ISphereWinHelper.exe",
"expected_tool_count": 9,
"production_send_enabled": false
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "CAPABILITY-TEST-MANIFEST.json") -Encoding ASCII
if (-not $NoZip) {
Compress-Archive -Path (Join-Path $packageDir "*") -DestinationPath $zipPath -Force
}
[ordered]@{
ok = $true
package_dir = (Resolve-Path -LiteralPath $packageDir).Path
zip = if (Test-Path -LiteralPath $zipPath) { (Resolve-Path -LiteralPath $zipPath).Path } else { $null }
helper_exe = (Resolve-Path -LiteralPath $helperExe).Path
smoke_exe = (Resolve-Path -LiteralPath $smokeExe).Path
local_login_required = $false
no_real_send = $true
production_send_enabled = $false
} | ConvertTo-Json -Depth 4 -Compress

View File

@@ -44,6 +44,7 @@ What this package does:
- asks the operator to manually send exactly one sandbox message in the official client;
- runs the same read-only recorder after the manual send;
- zips the returned evidence folder.
- provides RUN-RECORDING-SUITE.bat plus numbered 01/02/03 batch files so the operator can run the whole recording flow from this package.
What this package does not do:
- it does not send messages automatically;
@@ -60,6 +61,7 @@ Required rule:
Return:
- run make-return-zip.ps1 and send back the generated zip.
- preferred one-file flow: run RUN-RECORDING-SUITE.bat and follow the pauses.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "README.txt") -Encoding UTF8
@'
@@ -96,6 +98,10 @@ powershell -NoProfile -ExecutionPolicy Bypass -File .\compute-content-hash.ps1 -
3. Do not send anything yet.
4. Run `run-before-recorder.bat`.
Alternative one-file flow:
Run `RUN-RECORDING-SUITE.bat`. It will run the before recorder, pause for the manual one-send action, run the after recorder, and then call the return-zip script.
## Step 3 - Manual one-send action
1. In the official iSphere client, manually send exactly the `content_text_to_send`.
@@ -122,6 +128,8 @@ powershell -NoProfile -ExecutionPolicy Bypass -File .\make-return-zip.ps1
Send back the generated zip file.
You can also run `03-make-return-zip.bat`.
## Required returned evidence
The returned evidence should contain:
@@ -205,6 +213,21 @@ echo Done. Check return-evidence\after.
pause
'@ | Set-Content -LiteralPath (Join-Path $packageDir "run-after-recorder.bat") -Encoding ASCII
@'
@echo off
setlocal
cd /d "%~dp0"
call run-before-recorder.bat
'@ | Set-Content -LiteralPath (Join-Path $packageDir "01-run-before-recorder.bat") -Encoding ASCII
@'
@echo off
setlocal
cd /d "%~dp0"
echo Manual one-send action must already be complete before this step.
call run-after-recorder.bat
'@ | Set-Content -LiteralPath (Join-Path $packageDir "02-run-after-recorder.bat") -Encoding ASCII
@'
param(
[Parameter(Mandatory=$true)]
@@ -256,6 +279,59 @@ Compress-Archive -Path $items -DestinationPath $zip -Force
} | ConvertTo-Json -Depth 4 -Compress
'@ | Set-Content -LiteralPath (Join-Path $packageDir "make-return-zip.ps1") -Encoding ASCII
@'
@echo off
setlocal
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0make-return-zip.ps1"
echo exit code: %ERRORLEVEL%
pause
exit /b %ERRORLEVEL%
'@ | Set-Content -LiteralPath (Join-Path $packageDir "03-make-return-zip.bat") -Encoding ASCII
@'
@echo off
setlocal
cd /d "%~dp0"
echo R6c online sandbox-send recording suite
echo.
echo Step 1: BEFORE read-only recorder.
call "%~dp0run-before-recorder.bat"
echo.
echo Step 2: manual one-send action.
echo In the official iSphere client, manually send exactly one sandbox message.
echo Fill SANDBOX-SEND-INPUTS.json before continuing.
pause
echo.
echo Step 3: AFTER read-only recorder.
call "%~dp0run-after-recorder.bat"
echo.
echo Step 4: make return zip.
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0make-return-zip.ps1"
echo exit code: %ERRORLEVEL%
pause
exit /b %ERRORLEVEL%
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RUN-RECORDING-SUITE.bat") -Encoding ASCII
@'
{
"package": "send-sandbox-gate",
"LOCAL_LOGIN_UNAVAILABLE": true,
"ONLINE_SANDBOX_REQUIRED": true,
"MANUAL_ONE_SEND_ONLY": true,
"DO_NOT_SEND_SECOND_TIME": true,
"entrypoint": "RUN-RECORDING-SUITE.bat",
"numbered_steps": [
"01-run-before-recorder.bat",
"02-run-after-recorder.bat",
"03-make-return-zip.bat"
],
"recorder": "recorder/ISphereLiveProbeRecorder.exe",
"return_inputs": "SANDBOX-SEND-INPUTS.json",
"production_send_enabled": false
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RECORDING-PACKAGE-MANIFEST.json") -Encoding ASCII
if (-not $NoZip) {
Compress-Archive -Path (Join-Path $packageDir "*") -DestinationPath $zipPath -Force
}

View File

@@ -0,0 +1,106 @@
param(
[string]$OutputDir = "runs/send-capability-test-package"
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
$packageScript = Join-Path $repo "scripts\package-send-capability-test.ps1"
function Assert-True([bool]$Condition, [string]$Message) {
if (-not $Condition) {
throw $Message
}
}
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-capability-test.ps1 failed with exit code $LASTEXITCODE"
}
$requiredFiles = @(
"README.txt",
"EXPECTED-RESULTS.txt",
"run-capability-test.bat",
"isphere-capability-smoke.exe",
"runs\win-helper\ISphereWinHelper.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
$expected = Get-Content -LiteralPath (Join-Path $packageRoot "EXPECTED-RESULTS.txt") -Raw
$runner = Get-Content -LiteralPath (Join-Path $packageRoot "run-capability-test.bat") -Raw
foreach ($needle in @(
"LOCAL_LOGIN_UNAVAILABLE",
"NO_REAL_SEND",
"isphere-capability-smoke.exe",
"tool_count",
"production_send_enabled"
)) {
if ($readme -notmatch [regex]::Escape($needle) -and $expected -notmatch [regex]::Escape($needle) -and $runner -notmatch [regex]::Escape($needle)) {
throw "package instructions missing required phrase: $needle"
}
}
if (-not (Test-Path -LiteralPath $zipPath)) {
throw "missing package zip: $zipPath"
}
$smokeOutput = $null
Push-Location $packageRoot
try {
$smokeOutput = & ".\isphere-capability-smoke.exe"
if ($LASTEXITCODE -ne 0) {
throw "isphere-capability-smoke.exe failed with exit code $LASTEXITCODE"
}
}
finally {
Pop-Location
}
$smokeOutput | ForEach-Object { Write-Host $_ }
$lastLine = @($smokeOutput | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) | Select-Object -Last 1
Assert-True (-not [string]::IsNullOrWhiteSpace($lastLine)) "smoke output was empty"
$smokeJson = $lastLine | ConvertFrom-Json
Assert-True ($smokeJson.ok -eq $true) "smoke ok mismatch: $($smokeJson.ok)"
Assert-True ($smokeJson.helper_name -eq "ISphereWinHelper") "smoke helper_name mismatch: $($smokeJson.helper_name)"
Assert-True ($smokeJson.tool_count -eq 9) "smoke tool_count mismatch: $($smokeJson.tool_count)"
Assert-True ($smokeJson.send_preview_tool_present -eq $true) "smoke send_preview_tool_present mismatch: $($smokeJson.send_preview_tool_present)"
Assert-True ($smokeJson.production_send_enabled -eq $false) "smoke production_send_enabled mismatch: $($smokeJson.production_send_enabled)"
Assert-True ($smokeJson.local_login_required -eq $false) "smoke local_login_required mismatch: $($smokeJson.local_login_required)"
Assert-True ($smokeJson.real_isphere_login_required -eq $false) "smoke real_isphere_login_required mismatch: $($smokeJson.real_isphere_login_required)"
Assert-True ($smokeJson.no_real_send -eq $true) "smoke no_real_send mismatch: $($smokeJson.no_real_send)"
[ordered]@{
ok = $true
package_dir = (Resolve-Path -LiteralPath $packageRoot).Path
zip = (Resolve-Path -LiteralPath $zipPath).Path
required_file_count = $requiredFiles.Count
smoke_tool_count = $smokeJson.tool_count
helper_name = $smokeJson.helper_name
send_preview_tool_present = $smokeJson.send_preview_tool_present
production_send_enabled = $smokeJson.production_send_enabled
local_login_required = $false
no_real_send = $true
} | ConvertTo-Json -Depth 6 -Compress

View File

@@ -31,6 +31,11 @@ $requiredFiles = @(
"OPERATOR-STEPS.md",
"SANDBOX-SEND-INPUTS.template.json",
"EXPECTED-RETURN-FILES.txt",
"RUN-RECORDING-SUITE.bat",
"01-run-before-recorder.bat",
"02-run-after-recorder.bat",
"03-make-return-zip.bat",
"RECORDING-PACKAGE-MANIFEST.json",
"run-before-recorder.bat",
"run-after-recorder.bat",
"make-return-zip.ps1",
@@ -54,6 +59,7 @@ foreach ($needle in @(
"ONLINE_SANDBOX_REQUIRED",
"MANUAL_ONE_SEND_ONLY",
"DO_NOT_SEND_SECOND_TIME",
"RUN-RECORDING-SUITE.bat",
"content_sha256",
"idempotency_key",
"success_ack_or_sent_record"