#!/usr/bin/env bash
# Emit an event to the agent event bus
# Usage: emit <agent> <action> <subject> [summary]
# Example: emit clawdbot deployed discord-feed-bots "5 feeds live"

AGENT="${1:?usage: emit <agent> <action> <subject> [summary]}"
ACTION="${2:?}"
SUBJECT="${3:?}"
SUMMARY="${4:-}"
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
EPOCH=$(date +%s)
FILE="$HOME/.agents/events/${EPOCH}-${AGENT}-${ACTION}-${SUBJECT}.json"

cat > "$FILE" << EOF
{"agent":"$AGENT","action":"$ACTION","subject":"$SUBJECT","summary":"$SUMMARY","timestamp":"$TIMESTAMP"}
EOF

echo "$FILE"
