Add self-hosted AI worker bootstrap
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
OLLAMA_URL="${OLLAMA_URL:-http://192.168.5.23:11434}"
|
||||
OPEN_WEBUI_URL="${OPEN_WEBUI_URL:-http://192.168.5.26:8085}"
|
||||
GITEA_URL="${GITEA_URL:-http://192.168.5.21:3000}"
|
||||
MODEL="${MODEL:-qwen2.5-coder:7b}"
|
||||
|
||||
echo "Gitea: ${GITEA_URL}"
|
||||
curl -fsSI "${GITEA_URL}/user/login" >/dev/null
|
||||
echo " ok"
|
||||
|
||||
echo "Ollama: ${OLLAMA_URL}"
|
||||
curl -fsS "${OLLAMA_URL}/api/tags" >/tmp/agrarian_ollama_tags.json
|
||||
if ! grep -q "\"${MODEL}\"" /tmp/agrarian_ollama_tags.json; then
|
||||
echo " model ${MODEL} not found"
|
||||
cat /tmp/agrarian_ollama_tags.json
|
||||
exit 1
|
||||
fi
|
||||
echo " ok, model ${MODEL} available"
|
||||
|
||||
echo "Ollama chat smoke test"
|
||||
curl -fsS "${OLLAMA_URL}/api/chat" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"model\":\"${MODEL}\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with exactly: ok\"}],\"stream\":false}" \
|
||||
| grep -Eiq '"content":"[[:space:]]*ok[[:space:]]*"'
|
||||
echo " ok"
|
||||
|
||||
echo "Open WebUI: ${OPEN_WEBUI_URL}"
|
||||
curl -fsSI "${OPEN_WEBUI_URL}" >/dev/null
|
||||
echo " ok"
|
||||
|
||||
echo "Self-hosted AI stack reachable."
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Usage: $0 <task-status-json-or-handoff-text> [extra prompt]" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
STATUS_FILE="$1"
|
||||
EXTRA_PROMPT="${2:-}"
|
||||
|
||||
if [[ ! -f "$STATUS_FILE" ]]; then
|
||||
echo "Missing status/handoff file: $STATUS_FILE" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
OUT_DIR="${ROOT}/Saved/AiEscalations/${STAMP}"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
PROMPT_FILE="${OUT_DIR}/codex_prompt.txt"
|
||||
LOG_FILE="${OUT_DIR}/codex_exec.log"
|
||||
|
||||
{
|
||||
echo "You are Codex being called as an escalation worker for Agrarian."
|
||||
echo "Use the repository at: ${ROOT}"
|
||||
echo
|
||||
echo "Local AI stopped and requested escalation. Review the status below,"
|
||||
echo "inspect the repo, make only the needed changes, run verification, and"
|
||||
echo "summarize the result. Do not hide uncertainty."
|
||||
echo
|
||||
echo "Status / handoff:"
|
||||
cat "$STATUS_FILE"
|
||||
if [[ -n "$EXTRA_PROMPT" ]]; then
|
||||
echo
|
||||
echo "Extra prompt:"
|
||||
echo "$EXTRA_PROMPT"
|
||||
fi
|
||||
} > "$PROMPT_FILE"
|
||||
|
||||
echo "Prompt written to ${PROMPT_FILE}"
|
||||
|
||||
if command -v codex >/dev/null 2>&1; then
|
||||
codex exec "$(cat "$PROMPT_FILE")" 2>&1 | tee "$LOG_FILE"
|
||||
else
|
||||
npx -y @openai/codex exec "$(cat "$PROMPT_FILE")" 2>&1 | tee "$LOG_FILE"
|
||||
fi
|
||||
|
||||
echo "Codex escalation log written to ${LOG_FILE}"
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"task": "",
|
||||
"project": "AgrarianGame",
|
||||
"branch": "",
|
||||
"risk": "low|medium|high",
|
||||
"confidence": 0.0,
|
||||
"attempts": 0,
|
||||
"files_inspected": [],
|
||||
"files_changed": [],
|
||||
"commands_run": [],
|
||||
"tests_passed": false,
|
||||
"build_passed": false,
|
||||
"blocked_reason": "",
|
||||
"recommended_escalation": "none|codex|human",
|
||||
"requested_codex_action": ""
|
||||
}
|
||||
Reference in New Issue
Block a user