Fix agent hook script stdin handling

Agent hook scripts now properly consume stdin data before exiting, preventing broken pipe errors when the system tries to send data to agents. This fix applies across all script types (POSIX, batch, PowerShell, Git Bash) and includes new tests to verify the behavior works correctly.