Remove all Matrix/Dendrite infrastructure: - Delete lib/matrix_listener.sh (long-poll daemon), lib/matrix_listener.service (systemd unit), lib/hooks/on-stop-matrix.sh (response streaming hook) - Remove matrix_send() and matrix_send_ctx() from lib/env.sh - Remove MATRIX_HOMESERVER auto-detection, MATRIX_THREAD_MAP from lib/env.sh - Remove [matrix] section parsing from lib/load-project.sh - Remove Matrix hook installation from lib/agent-session.sh - Remove notify/notify_ctx helpers and Matrix thread tracking from dev/dev-agent.sh and action/action-agent.sh - Remove all matrix_send calls from dev-poll.sh, phase-handler.sh, action-poll.sh, vault-poll.sh, vault-fire.sh, vault-reject.sh, review-poll.sh, review-pr.sh, supervisor-poll.sh, formula-session.sh - Remove Matrix listener startup from docker/agents/entrypoint.sh - Remove append_dendrite_compose() and setup_matrix() from bin/disinto - Remove --matrix flag from disinto init - Clean Matrix references from .env.example, projects/*.toml.example, formulas/*.toml, AGENTS.md, BOOTSTRAP.md, README.md, RESOURCES.md, PHASE-PROTOCOL.md, and all agent AGENTS.md/PROMPT.md files Status visibility now via Codeberg PR/issue activity. Human interaction via vault items through forge. Proactive alerts via OpenClaw heartbeats. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
77 lines
2.4 KiB
Bash
Executable file
77 lines
2.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# action-poll.sh — Cron scheduler: find open 'action' issues, spawn action-agent
|
|
#
|
|
# An issue is ready for action if:
|
|
# - It is open and labeled 'action'
|
|
# - No tmux session named action-{project}-{issue_num} is already active
|
|
#
|
|
# Usage:
|
|
# cron every 10min
|
|
# action-poll.sh [projects/foo.toml] # optional project config
|
|
|
|
set -euo pipefail
|
|
|
|
export PROJECT_TOML="${1:-}"
|
|
source "$(dirname "$0")/../lib/env.sh"
|
|
# shellcheck source=../lib/guard.sh
|
|
source "$(dirname "$0")/../lib/guard.sh"
|
|
check_active action
|
|
|
|
LOGFILE="${FACTORY_ROOT}/action/action-poll-${PROJECT_NAME:-default}.log"
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
log() {
|
|
printf '[%s] poll: %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC')" "$*" >> "$LOGFILE"
|
|
}
|
|
|
|
# --- Memory guard ---
|
|
AVAIL_MB=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo)
|
|
if [ "$AVAIL_MB" -lt 2000 ]; then
|
|
log "SKIP: only ${AVAIL_MB}MB available (need 2000MB)"
|
|
exit 0
|
|
fi
|
|
|
|
# --- Find open 'action' issues ---
|
|
log "scanning for open action issues"
|
|
ACTION_ISSUES=$(curl -sf -H "Authorization: token ${FORGE_TOKEN}" \
|
|
"${FORGE_API}/issues?state=open&labels=action&limit=50&type=issues") || true
|
|
|
|
if [ -z "$ACTION_ISSUES" ] || [ "$ACTION_ISSUES" = "null" ]; then
|
|
log "no action issues found"
|
|
exit 0
|
|
fi
|
|
|
|
COUNT=$(printf '%s' "$ACTION_ISSUES" | jq 'length')
|
|
if [ "$COUNT" -eq 0 ]; then
|
|
log "no action issues found"
|
|
exit 0
|
|
fi
|
|
|
|
log "found ${COUNT} open action issue(s)"
|
|
|
|
# Spawn action-agent for each issue that has no active tmux session.
|
|
# Only one agent is spawned per poll to avoid memory pressure; the next
|
|
# poll picks up remaining issues.
|
|
for i in $(seq 0 $((COUNT - 1))); do
|
|
ISSUE_NUM=$(printf '%s' "$ACTION_ISSUES" | jq -r ".[$i].number")
|
|
SESSION="action-${PROJECT_NAME}-${ISSUE_NUM}"
|
|
|
|
if tmux has-session -t "$SESSION" 2>/dev/null; then
|
|
log "issue #${ISSUE_NUM}: session ${SESSION} already active, skipping"
|
|
continue
|
|
fi
|
|
|
|
LOCKFILE="/tmp/action-agent-${ISSUE_NUM}.lock"
|
|
if [ -f "$LOCKFILE" ]; then
|
|
LOCK_PID=$(cat "$LOCKFILE" 2>/dev/null || echo "")
|
|
if [ -n "$LOCK_PID" ] && kill -0 "$LOCK_PID" 2>/dev/null; then
|
|
log "issue #${ISSUE_NUM}: agent starting (PID ${LOCK_PID}), skipping"
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
log "spawning action-agent for issue #${ISSUE_NUM}"
|
|
nohup "${SCRIPT_DIR}/action-agent.sh" "$ISSUE_NUM" "$PROJECT_TOML" >> "$LOGFILE" 2>&1 &
|
|
log "started action-agent PID $! for issue #${ISSUE_NUM}"
|
|
break
|
|
done
|