Skip to content

Instantly share code, notes, and snippets.

@jerilkuriakose
Last active June 13, 2026 19:41
Show Gist options
  • Select an option

  • Save jerilkuriakose/7cf94af3e96526f9f14d0c28b6c26b69 to your computer and use it in GitHub Desktop.

Select an option

Save jerilkuriakose/7cf94af3e96526f9f14d0c28b6c26b69 to your computer and use it in GitHub Desktop.
ready-check
#!/usr/bin/env bash
#
# ready-check.sh — verify the Part 2 "readiness gate"
# Companion to "Coding Agents over Telegram, Part 2: From Zero to an Agent That Answers".
#
# Confirms your config is locked down, the gateway is up, the pane exists, and routing is wired.
# It cannot prove the agent *replied* in Telegram (that's the one manual check) — do that too.
#
# Usage:
# AGENT_ID=my-agent PANE=mybox:1.1 ./ready-check.sh
#
# Tunables (env vars):
# OPENCLAW_CONFIG config path (default ~/.openclaw/openclaw.json)
# LOG gateway log (default ~/.openclaw/logs/openclaw.log; falls back to /tmp)
# AGENT_ID your agent id (for the routing check)
# PANE your tmux pane target, e.g. mybox:1.1
set -uo pipefail
CONFIG="${OPENCLAW_CONFIG:-$HOME/.openclaw/openclaw.json}"
LOG="${LOG:-$HOME/.openclaw/logs/openclaw.log}"
[ -f "$LOG" ] || LOG="$(ls -t /tmp/openclaw/openclaw-*.log 2>/dev/null | head -1 || true)"
AGENT_ID="${AGENT_ID:-}"
PANE="${PANE:-}"
FAILED=0
pass() { printf ' \033[1;32m✓\033[0m %s\n' "$*"; }
fail() { printf ' \033[1;31m✗\033[0m %s\n' "$*"; FAILED=1; }
note() { printf ' \033[1;33m·\033[0m %s\n' "$*"; }
echo "OpenClaw readiness check"
echo " config: $CONFIG"
echo " log: ${LOG:-<none found>}"
echo
# 1. config parses
if python3 -c "import json,sys; json.load(open('$CONFIG'))" 2>/dev/null; then
pass "config is valid JSON"
else
fail "config is missing or not valid JSON"
fi
# 2. config is locked down (allowlist + allowFrom + requireMention:false + a topic->agent route)
locked="$(python3 - "$CONFIG" <<'PY' 2>/dev/null
import json, sys
try:
c = json.load(open(sys.argv[1]))
except Exception:
print("ERR"); raise SystemExit
for acct in c.get("channels", {}).get("telegram", {}).get("accounts", {}).values():
for g in acct.get("groups", {}).values():
if (g.get("groupPolicy") == "allowlist" and g.get("allowFrom")
and g.get("requireMention") is False and g.get("topics")):
print("LOCKED"); raise SystemExit
print("OPEN")
PY
)"
case "$locked" in
LOCKED) pass "group is locked down (allowlist + allowFrom + requireMention:false + topic route)";;
OPEN) fail "group not fully locked down — need groupPolicy:allowlist, allowFrom, requireMention:false, and a topic->agentId";;
*) fail "could not read group policy from config";;
esac
# 3. gateway reported ready
if [ -n "$LOG" ] && grep -qa 'gateway ready' "$LOG" 2>/dev/null; then
pass "gateway reported 'gateway ready'"
else
fail "no 'gateway ready' line in the log — is the gateway running?"
fi
# 4. pane exists
if [ -n "$PANE" ]; then
if tmux has-session -t "${PANE%%:*}" 2>/dev/null; then
pass "tmux session for pane $PANE exists"
else
fail "tmux session for pane $PANE not found"
fi
else
note "set PANE=<session:window.pane> to check your agent's pane"
fi
# 5. routing: a topic session file for this agent
if [ -n "$AGENT_ID" ]; then
if ls -1 "$HOME/.openclaw/agents/$AGENT_ID/sessions/"*topic-* >/dev/null 2>&1; then
pass "routing: topic session files exist for agent '$AGENT_ID'"
else
note "no topic session files yet for '$AGENT_ID' — send a message in the topic, then re-run"
fi
else
note "set AGENT_ID=<your-agent-id> to check routing"
fi
echo
if [ "$FAILED" -eq 0 ]; then
echo "READY (also confirm manually: typing 'status' in your topic gets a reply)"
else
echo "NOT READY — fix the ✗ items above, then re-run"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment