feat: add work-queue skill for Marcus and Steve
Some checks failed
ci / build-test-push (push) Failing after 29s
Some checks failed
ci / build-test-push (push) Failing after 29s
This commit is contained in:
35
skill/bin/wq_stale_check
Executable file
35
skill/bin/wq_stale_check
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# wq_stale_check — find in_progress items older than timeout, mark blocked
|
||||
|
||||
wq_stale_check() {
|
||||
local timeout_minutes="${1:-30}"
|
||||
|
||||
local items
|
||||
items=$(curl -sf "$API_URL/work?status=in_progress" | jq -r '.[] | @json' 2>/dev/null || echo "")
|
||||
|
||||
if [[ -z "$items" ]]; then
|
||||
echo "No in_progress items found."
|
||||
return 0
|
||||
fi
|
||||
|
||||
local count=0
|
||||
now_ts=$(date -u +%s)
|
||||
|
||||
while IFS= read -r item; do
|
||||
[[ -z "$item" ]] && continue
|
||||
work_id=$(echo "$item" | jq -r '.id')
|
||||
updated_at=$(echo "$item" | jq -r '.updated_at')
|
||||
agent=$(echo "$item" | jq -r '.assigned_agent')
|
||||
age_minutes=$(( (now_ts - $(date -u -d "$updated_at" +%s 2>/dev/null || echo "$now_ts")) / 60 ))
|
||||
|
||||
if [[ "$age_minutes" -gt "$timeout_minutes" ]]; then
|
||||
echo "Stale: $work_id ($agent, ${age_minutes}m old) — marking blocked"
|
||||
curl -sf -X PATCH "$API_URL/work/$work_id" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"status\":\"blocked\",\"notes\":\"Auto-blocked: stale for ${age_minutes} minutes (>$timeout_minutes)\"}" | jq -r '.id' > /dev/null
|
||||
count=$((count + 1))
|
||||
fi
|
||||
done <<< "$items"
|
||||
|
||||
echo "Stale check complete: $count items marked blocked."
|
||||
}
|
||||
Reference in New Issue
Block a user