#!/usr/bin/env bash
# Claude command-hook sidecar: environment-bound worker heartbeat only.
set -u

LAUNCH_ID="${COGITOD_LAUNCH_ID:-}"
[[ "$LAUNCH_ID" =~ ^[a-f0-9]{32}$ ]] || exit 0

ENDPOINT="${BREATHE_MCP_ENDPOINT:-http://127.0.0.1:${BREATHE_PORT:-24567}}"
ENDPOINT="${ENDPOINT%/mcp}/mcp?profile=claude"
printf '{"jsonrpc":"2.0","id":"worker-heartbeat","method":"tools/call","params":{"name":"agent_hook_post_tool","arguments":{"harness":"claude","launch_id":"%s","payload":{}}}}' "$LAUNCH_ID" \
  | curl -sf --max-time 3 -X POST "$ENDPOINT" -H 'Content-Type: application/json' --data-binary @- >/dev/null 2>&1 || true
