chore(org): rename Architect codename from Aurelius to Helix
This commit is contained in:
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CONFIG_FILE="$SCRIPT_DIR/gate_config.json"
|
||||
|
||||
if [[ $# -ne 4 ]]; then
|
||||
echo "Usage: $0 <tokens> <retries> <minutes> <escalationFlag>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tokens="$1"
|
||||
retries="$2"
|
||||
minutes="$3"
|
||||
escalationFlag="$4"
|
||||
|
||||
for v in "$tokens" "$retries" "$minutes"; do
|
||||
if ! [[ "$v" =~ ^[0-9]+$ ]]; then
|
||||
echo "Invalid numeric input. tokens/retries/minutes must be non-negative integers." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
read_config() {
|
||||
python3 - "$CONFIG_FILE" <<'PY'
|
||||
import json, sys
|
||||
with open(sys.argv[1], 'r', encoding='utf-8') as f:
|
||||
c = json.load(f)
|
||||
print(c['maxTokens'], c['maxRetries'], c['maxMinutes'])
|
||||
PY
|
||||
}
|
||||
|
||||
read -r maxTokens maxRetries maxMinutes < <(read_config)
|
||||
|
||||
flag_lc="$(echo "$escalationFlag" | tr '[:upper:]' '[:lower:]')"
|
||||
if [[ "$flag_lc" == "1" || "$flag_lc" == "true" || "$flag_lc" == "yes" || "$flag_lc" == "y" ]]; then
|
||||
echo "PAUSE_AND_ESCALATE"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if (( tokens > maxTokens || retries > maxRetries || minutes > maxMinutes )); then
|
||||
echo "BLOCK"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "PASS"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user