chore: remove temporary python mcp layer

This commit is contained in:
zhaoyilun
2026-07-05 14:56:41 +08:00
parent 573a09ade3
commit 87e0e47fbf
26 changed files with 122 additions and 6501 deletions

View File

@@ -1,124 +0,0 @@
param(
[string]$OutputDir = "runs/native-helper",
[string]$Configuration = "Release",
[ValidateSet("x86", "anycpu")]
[string]$Platform = "x86"
)
$ErrorActionPreference = "Stop"
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
$source = Join-Path $repo "native/ISphereOfflineLabHelper/Program.cs"
$outDirPath = Join-Path $repo $OutputDir
$outExe = Join-Path $outDirPath "ISphereOfflineLabHelper.exe"
$stubSource = Join-Path $outDirPath "IMPP.Resource.stub.cs"
$stubResources = Join-Path $outDirPath "IMPP.Resource.Properties.Resources.resources"
$stubDll = Join-Path $outDirPath "IMPP.Resource.dll"
if (-not (Test-Path -LiteralPath $source)) {
throw "source not found: $source"
}
$candidates = @(
"$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\csc.exe",
"$env:WINDIR\Microsoft.NET\Framework\v4.0.30319\csc.exe"
)
$csc = $candidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
if (-not $csc) {
throw ".NET Framework csc.exe v4.0.30319 not found"
}
New-Item -ItemType Directory -Force -Path $outDirPath | Out-Null
Add-Type -AssemblyName System.Drawing
$resourceNameFile = Join-Path $repo "native/ISphereOfflineLabHelper/resource-names.txt"
$resourceNames = New-Object System.Collections.Generic.SortedSet[string]([System.StringComparer]::Ordinal)
if (Test-Path -LiteralPath $resourceNameFile) {
Get-Content -LiteralPath $resourceNameFile | ForEach-Object {
$name = $_.Trim()
if ($name) {
[void]$resourceNames.Add($name)
}
}
}
foreach ($name in @(
"about_logo",
"ipload_2",
"login_backimg",
"sys_Logo_BackImg",
"sys_Logo_16",
"sys_logo_50",
"sys_logo_all",
"sys_logo_offline16",
"sys_small",
"toolstript_search_background",
"window_default_head"
)) {
[void]$resourceNames.Add($name)
}
$resourceWriter = New-Object System.Resources.ResourceWriter($stubResources)
try {
$bitmap = New-Object System.Drawing.Bitmap 1, 1
$bitmap.SetPixel(0, 0, [System.Drawing.Color]::Transparent)
foreach ($name in $resourceNames) {
$resourceWriter.AddResource($name, $bitmap)
}
}
finally {
$resourceWriter.Generate()
$resourceWriter.Close()
}
@"
namespace IMPP.Resource.Properties
{
internal static class Resources
{
}
}
"@ | Set-Content -LiteralPath $stubSource -Encoding UTF8
& $csc `
/nologo `
/target:library `
/platform:$Platform `
/optimize+ `
/out:$stubDll `
/reference:System.dll `
/reference:System.Drawing.dll `
/resource:$stubResources,IMPP.Resource.Properties.Resources.resources `
$stubSource
if ($LASTEXITCODE -ne 0) {
throw "IMPP.Resource stub compilation failed with exit code $LASTEXITCODE"
}
& $csc `
/nologo `
/target:exe `
/platform:$Platform `
/optimize+ `
/warn:0 `
/out:$outExe `
/reference:System.dll `
/reference:System.Core.dll `
/reference:System.Web.Extensions.dll `
/reference:System.Windows.Forms.dll `
/reference:System.Drawing.dll `
$source
if ($LASTEXITCODE -ne 0) {
throw "native helper compilation failed with exit code $LASTEXITCODE"
}
$result = [ordered]@{
ok = $true
configuration = $Configuration
platform = $Platform
csc = $csc
source = $source
output = $outExe
resource_stub = $stubDll
}
$result | ConvertTo-Json -Depth 4 -Compress

View File

@@ -0,0 +1,122 @@
param(
[string]$HelperExe = "runs/win-helper/ISphereWinHelper.exe",
[switch]$SkipBuild
)
$ErrorActionPreference = "Stop"
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
$helperPath = Join-Path $repo $HelperExe
function Invoke-HelperJson([hashtable]$Request) {
$json = $Request | ConvertTo-Json -Depth 8 -Compress
$output = $json | & $helperPath --json
if ($LASTEXITCODE -ne 0) {
throw "helper exited with code $LASTEXITCODE"
}
try {
return $output | ConvertFrom-Json
}
catch {
throw "helper output was not JSON: $output"
}
}
if (-not $SkipBuild) {
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo "scripts\build-win-helper.ps1") | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "build-win-helper.ps1 failed with exit code $LASTEXITCODE"
}
}
if (-not (Test-Path -LiteralPath $helperPath)) {
throw "helper not found: $helperPath"
}
$version = Invoke-HelperJson @{
protocol = "isphere.helper.v1"
request_id = "verify-version"
op = "version"
timeout_ms = 5000
args = @{}
}
if (-not $version.ok -or $version.data.helper_name -ne "ISphereWinHelper") {
throw "version check failed: $($version | ConvertTo-Json -Depth 8 -Compress)"
}
$selfCheck = Invoke-HelperJson @{
protocol = "isphere.helper.v1"
request_id = "verify-self-check"
op = "self_check"
timeout_ms = 5000
args = @{}
}
if (-not $selfCheck.ok) {
throw "self_check failed: $($selfCheck | ConvertTo-Json -Depth 8 -Compress)"
}
$scan = Invoke-HelperJson @{
protocol = "isphere.helper.v1"
request_id = "verify-scan"
op = "scan_windows"
timeout_ms = 5000
args = @{ include_all_visible = $true }
}
if (-not $scan.ok -or $null -eq $scan.data.windows) {
throw "scan_windows failed: $($scan | ConvertTo-Json -Depth 8 -Compress)"
}
$dumpMissing = Invoke-HelperJson @{
protocol = "isphere.helper.v1"
request_id = "verify-dump-missing"
op = "dump_uia"
timeout_ms = 5000
args = @{ hwnd = "0x0"; max_depth = 1; include_text = $true; max_children = 20 }
}
if ($dumpMissing.ok -or $dumpMissing.error.code -notin @("WINDOW_NOT_FOUND", "UIA_DUMP_FAILED")) {
throw "dump_uia missing-window check failed: $($dumpMissing | ConvertTo-Json -Depth 8 -Compress)"
}
$title = "Codex WinHelper Verify " + [guid]::NewGuid().ToString("N").Substring(0, 8)
$formScript = "Add-Type -AssemblyName System.Windows.Forms; `$form = New-Object System.Windows.Forms.Form; `$form.Text = '$title'; `$form.Width = 420; `$form.Height = 180; `$button = New-Object System.Windows.Forms.Button; `$button.Text = 'ProbeButton'; `$button.Dock = 'Fill'; `$form.Controls.Add(`$button); [void]`$form.ShowDialog()"
$process = Start-Process powershell -ArgumentList @("-NoProfile", "-Command", $formScript) -PassThru
try {
$candidate = $null
for ($i = 0; $i -lt 20 -and -not $candidate; $i++) {
Start-Sleep -Milliseconds 500
$scanForForm = Invoke-HelperJson @{
protocol = "isphere.helper.v1"
request_id = "verify-form-scan"
op = "scan_windows"
timeout_ms = 5000
args = @{ include_all_visible = $true }
}
$candidate = $scanForForm.data.windows | Where-Object { $_.title -eq $title } | Select-Object -First 1
}
if (-not $candidate) {
throw "verification form window not found"
}
$dump = Invoke-HelperJson @{
protocol = "isphere.helper.v1"
request_id = "verify-form-dump"
op = "dump_uia"
timeout_ms = 5000
args = @{ hwnd = $candidate.hwnd; max_depth = 4; include_text = $true; max_children = 80 }
}
if (-not $dump.ok -or $dump.data.root.control_type -ne "Window") {
throw "dump_uia form check failed: $($dump | ConvertTo-Json -Depth 12 -Compress)"
}
}
finally {
if ($process -and -not $process.HasExited) {
Stop-Process -Id $process.Id -Force
}
}
[ordered]@{
ok = $true
helper = (Resolve-Path -LiteralPath $helperPath).Path
version = $version.data.helper_version
scan_window_count = $scan.data.windows.Count
uia_available = $selfCheck.data.uia_available
} | ConvertTo-Json -Depth 4 -Compress