# Synopsis: Appends the validation checkpoint message to Mailbox\To_AgentOSH.json.
# Description: Resets mailbox database and appends a clean verification message to confirm the UI sync is alive.

$BaseDir = $PSScriptRoot
if ($BaseDir -like '*\Skills' -or $BaseDir -like '*/Skills') { $BaseDir = Split-Path $BaseDir }
$MailboxPath = Join-Path $BaseDir "Mailbox\To_AgentOSH.json"

# Clear mailbox to isolate checkpoint and ensure maximum UI speed with zero history lag
$Mailbox = @()

$NewMessage = @{
    "sender"    = "Gemini Enterprise (Supervisor)"
    "role"      = "Supervisor"
    "message"   = "[CONNECTION CHECKPOINT] AgentOS & AgentOSH integration successfully established! All front-end handlers are now compiled correctly. please type a manual message in the text box below and hit Enter or click the Send button to verify that you can manually chat."
    "timestamp" = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
    "status"    = "PENDING_EXECUTION"
}

$Mailbox += $NewMessage
$Mailbox | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $MailboxPath -Force -Encoding UTF8

Write-Output "SUCCESS: Connection checkpoint written to Mailbox\To_AgentOSH.json."
