#!/bin/bash
# status-hook.sh — Emits agent status events to the channel server
# Called by Claude Code hooks (PreToolUse, PostToolUse, etc.)
# Reads hook event JSON from stdin, POSTs to channel server /status endpoint
input=$(cat)
event=$(echo "$input" | jq -r '.hook_event_name')
tool_name=$(echo "$input" | jq -r '.tool_name // empty')

curl -s -X POST "http://127.0.0.1:${ONE_CHANNEL_PORT:-7100}/status" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${ONE_CHANNEL_SECRET}" \
  -d "{\"event\":\"${event}\",\"tool_name\":\"${tool_name}\"}" \
  >/dev/null 2>&1 &
