← back to Agent Ad Network

sdk/waitad.sh

15 lines

# waitad.sh — shell integration for agent wait-state ads. Source this, then:
#   waitad "git,deploy"          # print one ad (or nothing — fail-open)
#   waitad_wrap "context" long_command --args   # ad first, then run the command
WAITAD_BASE="${WAITAD_BASE:-http://127.0.0.1:9932}"

waitad() {
  curl -s --max-time 1 "$WAITAD_BASE/ad?format=text&context=${1:-}" 2>/dev/null || true
}

waitad_wrap() {
  local ctx="$1"; shift
  waitad "$ctx"
  "$@"
}