feat: add a-route uia send connector
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
|
||||
@@ -100,7 +100,7 @@ func main() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
|
||||
for _, key := range []string{"ISPHERE_PACKET_LOG_FILE", "ISPHERE_PACKET_LOG_DIR", "ISPHERE_MSGLIB_SIDECAR_EXE", "ISPHERE_MSGLIB_SQLITE_DLL", "ISPHERE_MSGLIB_DB", "ISPHERE_MSGLIB_PASSWORD", "ISPHERE_SEND_FILE_ALLOWED_DIR", "ISPHERE_SEND_FILE_AUDIT_PATH", "ISPHERE_SEND_FILE_IDEMPOTENCY_PATH"} {
|
||||
for _, key := range []string{"ISPHERE_PACKET_LOG_FILE", "ISPHERE_PACKET_LOG_DIR", "ISPHERE_MSGLIB_SIDECAR_EXE", "ISPHERE_MSGLIB_SQLITE_DLL", "ISPHERE_MSGLIB_DB", "ISPHERE_MSGLIB_PASSWORD", "ISPHERE_SEND_PRODUCTION_ENABLED", "ISPHERE_SEND_CONNECTOR_MODE", "ISPHERE_SEND_UIA_HELPER_PATH", "ISPHERE_SEND_UIA_HWND", "ISPHERE_SEND_UIA_EDITOR_AUTOMATION_ID", "ISPHERE_SEND_UIA_BUTTON_AUTOMATION_ID", "ISPHERE_SEND_UIA_TIMEOUT_SECONDS", "ISPHERE_SEND_FILE_ALLOWED_DIR", "ISPHERE_SEND_FILE_AUDIT_PATH", "ISPHERE_SEND_FILE_IDEMPOTENCY_PATH"} {
|
||||
if err := os.Unsetenv(key); err != nil {
|
||||
fail("server/env", err)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
param(
|
||||
param(
|
||||
[string]$HelperExe = "runs/win-helper/ISphereWinHelper.exe",
|
||||
[switch]$SkipBuild
|
||||
)
|
||||
@@ -107,6 +107,7 @@ if ($dumpMissing.ok -or $dumpMissing.error.code -notin @("WINDOW_NOT_FOUND", "UI
|
||||
|
||||
$title = "Codex WinHelper Verify " + [guid]::NewGuid().ToString("N").Substring(0, 8)
|
||||
$formScriptPath = Join-Path $env:TEMP ("codex-winhelper-form-" + [guid]::NewGuid().ToString("N") + ".ps1")
|
||||
$sendActionMarkerPath = Join-Path $env:TEMP ("codex-winhelper-send-marker-" + [guid]::NewGuid().ToString("N") + ".json")
|
||||
$formScript = @"
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
`$form = New-Object System.Windows.Forms.Form
|
||||
@@ -137,6 +138,10 @@ Add-Type -AssemblyName System.Windows.Forms
|
||||
`$button.Name = 'btnSend'
|
||||
`$button.Text = 'Send'
|
||||
`$button.Dock = 'Fill'
|
||||
`$button.Add_Click({
|
||||
`$payload = [ordered]@{ clicked = `$true; text = `$send.Text } | ConvertTo-Json -Compress
|
||||
Set-Content -LiteralPath '$sendActionMarkerPath' -Value `$payload -Encoding UTF8
|
||||
})
|
||||
`$layout.Controls.Add(`$button)
|
||||
`$file = New-Object System.Windows.Forms.Button
|
||||
`$file.Name = 'btnFile'
|
||||
@@ -196,6 +201,42 @@ try {
|
||||
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)"
|
||||
}
|
||||
$sendContent = "Codex synthetic UIA send " + [guid]::NewGuid().ToString("N").Substring(0, 8)
|
||||
$sha = [System.Security.Cryptography.SHA256]::Create()
|
||||
try {
|
||||
$bytes = [System.Text.Encoding]::UTF8.GetBytes($sendContent)
|
||||
$sendContentHash = -join ($sha.ComputeHash($bytes) | ForEach-Object { $_.ToString("x2") })
|
||||
}
|
||||
finally {
|
||||
$sha.Dispose()
|
||||
}
|
||||
$sendAction = Invoke-HelperJson @{
|
||||
protocol = "isphere.helper.v1"
|
||||
request_id = "verify-uia-send-message"
|
||||
op = "uia_send_message"
|
||||
timeout_ms = 5000
|
||||
args = @{
|
||||
hwnd = $candidate.hwnd
|
||||
send_editor_automation_id = "rtbSendMessage"
|
||||
send_button_automation_id = "btnSend"
|
||||
target_ref = "synthetic:verify"
|
||||
content_text = $sendContent
|
||||
content_sha256 = $sendContentHash
|
||||
}
|
||||
}
|
||||
if (-not $sendAction.ok -or $sendAction.data.action_mode -ne "uia_send_message" -or -not $sendAction.data.sent_message -or -not $sendAction.data.typed_text -or -not $sendAction.data.clicked_ui) {
|
||||
throw "uia_send_message failed: $($sendAction | ConvertTo-Json -Depth 12 -Compress)"
|
||||
}
|
||||
for ($i = 0; $i -lt 20 -and -not (Test-Path -LiteralPath $sendActionMarkerPath); $i++) {
|
||||
Start-Sleep -Milliseconds 100
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $sendActionMarkerPath)) {
|
||||
throw "uia_send_message did not trigger synthetic send button marker"
|
||||
}
|
||||
$marker = Get-Content -LiteralPath $sendActionMarkerPath -Raw | ConvertFrom-Json
|
||||
if (-not $marker.clicked -or $marker.text -ne $sendContent) {
|
||||
throw "uia_send_message marker mismatch: $($marker | ConvertTo-Json -Compress)"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if ($process -and -not $process.HasExited) {
|
||||
@@ -204,6 +245,9 @@ finally {
|
||||
if (Test-Path -LiteralPath $formScriptPath) {
|
||||
Remove-Item -LiteralPath $formScriptPath -Force
|
||||
}
|
||||
if (Test-Path -LiteralPath $sendActionMarkerPath) {
|
||||
Remove-Item -LiteralPath $sendActionMarkerPath -Force
|
||||
}
|
||||
}
|
||||
|
||||
[ordered]@{
|
||||
@@ -214,5 +258,6 @@ finally {
|
||||
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
|
||||
synthetic_uia_send_action = $sendAction.data.action_mode
|
||||
uia_available = $selfCheck.data.uia_available
|
||||
} | ConvertTo-Json -Depth 4 -Compress
|
||||
|
||||
Reference in New Issue
Block a user