Files
agent-ui/hooks/approval-permission.ps1
josedario87 9bd6123f97 feat: Add transcript-debug page with multi-agent support, hooks approval, and message selection
- Transcript debug: JSONL viewer, parsed chat view, realtime WebSocket updates, session selector
- Multi-agent: ejecutor, nucleo000, and claude (global ~/.claude/projects/) with agent switcher
- Hooks approval: permission/plan request forwarding via PowerShell hooks, long-poll API, UI modals
- Chat features: session ID copy, select mode with checkboxes, multi-select copy, select all/deselect all
- File watchers for all agent transcript directories with polling fallback on Windows
2026-02-18 23:55:09 -06:00

30 lines
1.3 KiB
PowerShell

# Long-poll hooks-approval for PermissionRequest decisions
# Reads hook stdin, POSTs to backend, waits up to 125s for UI response
# Returns hookSpecificOutput JSON per Claude Code PermissionRequest docs
param([string]$agent = "ejecutor")
$logFile = "$PSScriptRoot/../.claude-$agent/debug/hooks.log"
$ts = Get-Date -Format "HH:mm:ss.fff"
$b = [Console]::In.ReadToEnd()
Add-Content $logFile "[$ts] [PERM] Hook fired for agent=$agent stdin_len=$($b.Length)"
try {
$j = $b | ConvertFrom-Json
Add-Content $logFile "[$ts] [PERM] tool=$($j.tool_name) session=$($j.session_id)"
} catch {
Add-Content $logFile "[$ts] [PERM] WARN: stdin not valid JSON"
}
try {
Add-Content $logFile "[$ts] [PERM] POSTing to backend..."
$r = Invoke-RestMethod -Uri 'http://localhost:4101/api/hooks-approval/permission' -Method POST -Body $b -ContentType 'application/json' -TimeoutSec 125
$ts2 = Get-Date -Format "HH:mm:ss.fff"
if ($r -and $r.hookSpecificOutput) {
$out = $r | ConvertTo-Json -Depth 10 -Compress
Add-Content $logFile "[$ts2] [PERM] Got response: $out"
$out
} else {
Add-Content $logFile "[$ts2] [PERM] Empty/timeout response (no hookSpecificOutput)"
}
} catch {
$ts2 = Get-Date -Format "HH:mm:ss.fff"
Add-Content $logFile "[$ts2] [PERM] ERROR: $($_.Exception.Message)"
}