feat: add send connector preflight probes
This commit is contained in:
@@ -80,6 +80,20 @@ if (-not $runtimeProbe.ok -or $runtimeProbe.data.probe_mode -ne "read_only_proce
|
||||
throw "probe_client_runtime failed: $($runtimeProbe | ConvertTo-Json -Depth 8 -Compress)"
|
||||
}
|
||||
|
||||
$entrypointProbe = Invoke-HelperJson @{
|
||||
protocol = "isphere.helper.v1"
|
||||
request_id = "verify-send-entrypoints"
|
||||
op = "probe_send_entrypoints"
|
||||
timeout_ms = 5000
|
||||
args = @{}
|
||||
}
|
||||
if (-not $entrypointProbe.ok -or $entrypointProbe.data.probe_mode -ne "read_only_send_entrypoint_metadata" -or $null -eq $entrypointProbe.data.entrypoints) {
|
||||
throw "probe_send_entrypoints failed: $($entrypointProbe | ConvertTo-Json -Depth 8 -Compress)"
|
||||
}
|
||||
if ($entrypointProbe.data.safety.sent_message -or $entrypointProbe.data.safety.uploaded_file -or $entrypointProbe.data.safety.clicked_ui) {
|
||||
throw "probe_send_entrypoints safety flags failed: $($entrypointProbe | ConvertTo-Json -Depth 8 -Compress)"
|
||||
}
|
||||
|
||||
$dumpMissing = Invoke-HelperJson @{
|
||||
protocol = "isphere.helper.v1"
|
||||
request_id = "verify-dump-missing"
|
||||
@@ -92,8 +106,52 @@ if ($dumpMissing.ok -or $dumpMissing.error.code -notin @("WINDOW_NOT_FOUND", "UI
|
||||
}
|
||||
|
||||
$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
|
||||
$formScriptPath = Join-Path $env:TEMP ("codex-winhelper-form-" + [guid]::NewGuid().ToString("N") + ".ps1")
|
||||
$formScript = @"
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
`$form = New-Object System.Windows.Forms.Form
|
||||
`$form.Text = '$title'
|
||||
`$form.Width = 620
|
||||
`$form.Height = 420
|
||||
`$layout = New-Object System.Windows.Forms.TableLayoutPanel
|
||||
`$layout.Dock = 'Fill'
|
||||
`$layout.RowCount = 6
|
||||
`$layout.ColumnCount = 1
|
||||
`$form.Controls.Add(`$layout)
|
||||
`$search = New-Object System.Windows.Forms.TextBox
|
||||
`$search.Name = 'skinAlphaTxt'
|
||||
`$search.Text = 'search placeholder'
|
||||
`$search.Dock = 'Fill'
|
||||
`$layout.Controls.Add(`$search)
|
||||
`$recv = New-Object System.Windows.Forms.RichTextBox
|
||||
`$recv.Name = 'rtbRecvMessage'
|
||||
`$recv.Text = ''
|
||||
`$recv.Dock = 'Fill'
|
||||
`$layout.Controls.Add(`$recv)
|
||||
`$send = New-Object System.Windows.Forms.RichTextBox
|
||||
`$send.Name = 'rtbSendMessage'
|
||||
`$send.Text = ''
|
||||
`$send.Dock = 'Fill'
|
||||
`$layout.Controls.Add(`$send)
|
||||
`$button = New-Object System.Windows.Forms.Button
|
||||
`$button.Name = 'btnSend'
|
||||
`$button.Text = 'Send'
|
||||
`$button.Dock = 'Fill'
|
||||
`$layout.Controls.Add(`$button)
|
||||
`$file = New-Object System.Windows.Forms.Button
|
||||
`$file.Name = 'btnFile'
|
||||
`$file.Text = 'File'
|
||||
`$file.Dock = 'Fill'
|
||||
`$layout.Controls.Add(`$file)
|
||||
`$offline = New-Object System.Windows.Forms.Label
|
||||
`$offline.Name = 'offlineSendBlocker'
|
||||
`$offline.Text = 'Offline send blocker'
|
||||
`$offline.Dock = 'Fill'
|
||||
`$layout.Controls.Add(`$offline)
|
||||
[void]`$form.ShowDialog()
|
||||
"@
|
||||
Set-Content -LiteralPath $formScriptPath -Value $formScript -Encoding UTF8
|
||||
$process = Start-Process powershell -ArgumentList @("-NoProfile", "-ExecutionPolicy", "Bypass", "-File", $formScriptPath) -PassThru
|
||||
try {
|
||||
$candidate = $null
|
||||
for ($i = 0; $i -lt 20 -and -not $candidate; $i++) {
|
||||
@@ -121,11 +179,31 @@ try {
|
||||
if (-not $dump.ok -or $dump.data.root.control_type -ne "Window") {
|
||||
throw "dump_uia form check failed: $($dump | ConvertTo-Json -Depth 12 -Compress)"
|
||||
}
|
||||
|
||||
$sendUiaProbe = Invoke-HelperJson @{
|
||||
protocol = "isphere.helper.v1"
|
||||
request_id = "verify-send-uia-controls"
|
||||
op = "probe_send_uia_controls"
|
||||
timeout_ms = 5000
|
||||
args = @{ hwnd = $candidate.hwnd; max_depth = 6; max_children = 120 }
|
||||
}
|
||||
if (-not $sendUiaProbe.ok -or $sendUiaProbe.data.probe_mode -ne "read_only_uia_send_control_classifier") {
|
||||
throw "probe_send_uia_controls failed: $($sendUiaProbe | ConvertTo-Json -Depth 12 -Compress)"
|
||||
}
|
||||
if (-not $sendUiaProbe.data.flags.has_search_edit -or -not $sendUiaProbe.data.flags.has_send_editor -or -not $sendUiaProbe.data.flags.has_send_button -or -not $sendUiaProbe.data.flags.has_file_menu -or -not $sendUiaProbe.data.flags.offline_blocker_visible) {
|
||||
throw "probe_send_uia_controls missing expected synthetic controls: $($sendUiaProbe | ConvertTo-Json -Depth 12 -Compress)"
|
||||
}
|
||||
if ($sendUiaProbe.data.safety.sent_message -or $sendUiaProbe.data.safety.uploaded_file -or $sendUiaProbe.data.safety.clicked_ui -or $sendUiaProbe.data.safety.typed_text) {
|
||||
throw "probe_send_uia_controls safety flags failed: $($sendUiaProbe | ConvertTo-Json -Depth 12 -Compress)"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if ($process -and -not $process.HasExited) {
|
||||
Stop-Process -Id $process.Id -Force
|
||||
}
|
||||
if (Test-Path -LiteralPath $formScriptPath) {
|
||||
Remove-Item -LiteralPath $formScriptPath -Force
|
||||
}
|
||||
}
|
||||
|
||||
[ordered]@{
|
||||
@@ -134,5 +212,7 @@ finally {
|
||||
version = $version.data.helper_version
|
||||
scan_window_count = $scan.data.windows.Count
|
||||
runtime_probe_target_count = $runtimeProbe.data.target_count
|
||||
send_entrypoint_probe_mode = $entrypointProbe.data.probe_mode
|
||||
synthetic_send_uia_route_hint = $sendUiaProbe.data.flags.route_hint
|
||||
uia_available = $selfCheck.data.uia_available
|
||||
} | ConvertTo-Json -Depth 4 -Compress
|
||||
|
||||
Reference in New Issue
Block a user