19 lines
683 B
Bash
Executable File
19 lines
683 B
Bash
Executable File
#!/bin/bash
|
|
# Daily AI cost budget check — alerts via Telegram if over $5/day
|
|
# Uses openclaw-cost-guard skill
|
|
|
|
SCRIPT="/home/openclaw/.openclaw/workspace/skills/openclaw-cost-guard/scripts/extract_cost.py"
|
|
BUDGET="${DAILY_BUDGET_USD:-5.00}"
|
|
|
|
python3 "$SCRIPT" --today --budget-usd "$BUDGET" --budget-mode exit
|
|
EXIT_CODE=$?
|
|
|
|
if [ $EXIT_CODE -eq 2 ]; then
|
|
# Budget breached — get the actual total for the alert message
|
|
TOTAL=$(python3 "$SCRIPT" --today --json 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(f\"\${d['total']['cost']:.2f}\")" 2>/dev/null || echo "unknown")
|
|
echo "BUDGET_BREACHED: $TOTAL today vs \$$BUDGET limit"
|
|
exit 2
|
|
fi
|
|
|
|
exit 0
|