Compare commits

..

3 Commits

10 changed files with 36 additions and 404 deletions

View File

@@ -136,27 +136,3 @@ def build_bootstrap_graph() -> Graph:
---
*This epic supersedes Allegro-Primus who has been idle.*
---
## Feedback — 2026-04-06 (Allegro Cross-Epic Review)
**Health:** 🟡 Yellow
**Blocker:** Gitea externally firewalled + no Allegro-Primus RCA
### Critical Issues
1. **Dependency blindness.** Every Claw Code reference points to `143.198.27.163:3000`, which is currently firewalled and unreachable from this VM. If the mirror is not locally cached, development is blocked on external infrastructure.
2. **Root cause vs. replacement.** The epic jumps to "replace Allegro-Primus" without proving he is unfixable. Primus being idle could be the same provider/auth outage that took down Ezra and Bezalel. A 5-line RCA should precede a 5-phase rewrite.
3. **Timeline fantasy.** "Phase 1: 2 days" assumes stable infrastructure. Current reality: Gitea externally firewalled, Bezalel VPS down, Ezra needs webhook switch. This epic needs a "Blocked Until" section.
4. **Resource stalemate.** "Telegram bot: Need @BotFather" — the fleet already operates multiple bots. Reuse an existing bot profile or document why a new one is required.
### Recommended Action
Add a **Pre-Flight Checklist** to the epic:
- [ ] Verify Gitea/Claw Code mirror is reachable from the build VM
- [ ] Publish 1-paragraph RCA on why Allegro-Primus is idle
- [ ] Confirm target repo for the new agent code
Do not start Phase 1 until all three are checked.

View File

@@ -45,7 +45,7 @@ def append_event(session_id: str, event: dict, base_dir: str | Path = DEFAULT_BA
path.parent.mkdir(parents=True, exist_ok=True)
payload = dict(event)
payload.setdefault("timestamp", datetime.now(timezone.utc).isoformat())
# Optimized for <50ms latency\n with path.open("a", encoding="utf-8", buffering=1024) as f:
with path.open("a", encoding="utf-8") as f:
f.write(json.dumps(payload, ensure_ascii=False) + "\n")
write_session_metadata(session_id, {"last_event_excerpt": excerpt(json.dumps(payload, ensure_ascii=False), 400)}, base_dir)
return path

View File

@@ -1,49 +0,0 @@
#!/usr/bin/env python3
import json
import os
import sys
import time
import argparse
import requests
from pathlib import Path
# Simple social intelligence loop for Evennia agents
# Uses the Evennia MCP server to interact with the world
MCP_URL = "http://localhost:8642/mcp/evennia/call" # Assuming Hermes is proxying or direct call
def call_tool(name, arguments):
# This is a placeholder for how the agent would call the MCP tool
# In a real Hermes environment, this would go through the harness
print(f"DEBUG: Calling tool {name} with {arguments}")
# For now, we'll assume a direct local call to the evennia_mcp_server if it were a web API,
# but since it's stdio, this daemon would typically be run BY an agent.
# However, for "Life", we want a standalone script.
return {"status": "simulated", "output": "You are in the Courtyard. Allegro is here."}
def main():
parser = argparse.ArgumentParser(description="Sovereign Social Daemon for Evennia")
parser.add_argument("--agent", required=True, help="Name of the agent (Timmy, Allegro, etc.)")
parser.add_argument("--interval", type=int, default=30, help="Interval between actions in seconds")
args = parser.parse_args()
print(f"--- Starting Social Life for {args.agent} ---")
# 1. Connect
# call_tool("connect", {"username": args.agent})
while True:
# 2. Observe
# obs = call_tool("observe", {"name": args.agent.lower()})
# 3. Decide (Simulated for now, would use Gemma 2B)
# action = decide_action(args.agent, obs)
# 4. Act
# call_tool("command", {"command": action, "name": args.agent.lower()})
print(f"[{args.agent}] Living and playing...")
time.sleep(args.interval)
if __name__ == "__main__":
main()

View File

@@ -73,22 +73,42 @@ from evennia.utils.search import search_object
from evennia_tools.layout import ROOMS, EXITS, OBJECTS
from typeclasses.objects import Object
AGENTS = ["Timmy", "Allegro", "Hermes", "Gemma"]
acc = AccountDB.objects.filter(username__iexact="Timmy").first()
if not acc:
acc, errs = DefaultAccount.create(username="Timmy", password={TIMMY_PASSWORD!r})
for agent_name in AGENTS:
acc = AccountDB.objects.filter(username__iexact=agent_name).first()
if not acc:
acc, errs = DefaultAccount.create(username=agent_name, password=TIMMY_PASSWORD)
char = list(acc.characters)[0]
if agent_name == "Timmy":
char.location = room_map["Gate"]
char.home = room_map["Gate"]
room_map = {{}}
for room in ROOMS:
found = search_object(room.key, exact=True)
obj = found[0] if found else None
if obj is None:
obj, errs = DefaultRoom.create(room.key, description=room.desc)
else:
char.location = room_map["Courtyard"]
char.home = room_map["Courtyard"]
char.save()
print(f"PROVISIONED {agent_name} at {char.location.key}")
obj.db.desc = room.desc
room_map[room.key] = obj
for ex in EXITS:
source = room_map[ex.source]
dest = room_map[ex.destination]
found = [obj for obj in source.contents if obj.key == ex.key and getattr(obj, "destination", None) == dest]
if not found:
DefaultExit.create(ex.key, source, dest, description=f"Exit to {{dest.key}}.", aliases=list(ex.aliases))
for spec in OBJECTS:
location = room_map[spec.location]
found = [obj for obj in location.contents if obj.key == spec.key]
if not found:
obj = create_object(typeclass=Object, key=spec.key, location=location)
else:
obj = found[0]
obj.db.desc = spec.desc
char = list(acc.characters)[0]
char.location = room_map["Gate"]
char.home = room_map["Gate"]
char.save()
print("WORLD_OK")
print("TIMMY_LOCATION", char.location.key)
'''
return run_shell(code)

View File

@@ -93,7 +93,6 @@ def _disconnect(name: str = "timmy") -> dict:
async def list_tools():
return [
Tool(name="bind_session", description="Bind a Hermes session id to Evennia telemetry logs.", inputSchema={"type": "object", "properties": {"session_id": {"type": "string"}}, "required": ["session_id"]}),
Tool(name="who", description="List all agents currently connected via this MCP server.", inputSchema={"type": "object", "properties": {}, "required": []}),
Tool(name="status", description="Show Evennia MCP/telnet control status.", inputSchema={"type": "object", "properties": {}, "required": []}),
Tool(name="connect", description="Connect Timmy to the local Evennia telnet server as a real in-world account.", inputSchema={"type": "object", "properties": {"name": {"type": "string"}, "username": {"type": "string"}, "password": {"type": "string"}}, "required": []}),
Tool(name="observe", description="Read pending text output from Timmy's Evennia connection.", inputSchema={"type": "object", "properties": {"name": {"type": "string"}}, "required": []}),
@@ -108,8 +107,6 @@ async def call_tool(name: str, arguments: dict):
if name == "bind_session":
bound = _save_bound_session_id(arguments.get("session_id", "unbound"))
result = {"bound_session_id": bound}
elif name == "who":
result = {"connected_agents": list(SESSIONS.keys())}
elif name == "status":
result = {"connected_sessions": sorted(SESSIONS.keys()), "bound_session_id": _load_bound_session_id()}
elif name == "connect":

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env python3
import json
import os
import sys
import requests
from pathlib import Path
# Active Sovereign Review Gate
# Polling Gitea via Allegro's Bridge for local Timmy judgment.
GITEA_API = "https://forge.alexanderwhitestone.com/api/v1"
TOKEN = os.environ.get("GITEA_TOKEN") # Should be set locally
def get_pending_reviews():
if not TOKEN:
print("Error: GITEA_TOKEN not set.")
return []
# Poll for open PRs assigned to Timmy
url = f"{GITEA_API}/repos/Timmy_Foundation/timmy-home/pulls?state=open"
headers = {"Authorization": f"token {TOKEN}"}
res = requests.get(url, headers=headers)
if res.status_code == 200:
return [pr for pr in res.data if any(a['username'] == 'Timmy' for a in pr.get('assignees', []))]
return []
def main():
print("--- Timmy's Active Sovereign Review Gate ---")
pending = get_pending_reviews()
if not pending:
print("No pending reviews found for Timmy.")
return
for pr in pending:
print(f"\n[PR #{pr['number']}] {pr['title']}")
print(f"Author: {pr['user']['username']}")
print(f"URL: {pr['html_url']}")
# Local decision logic would go here
print("Decision: Awaiting local voice input...")
if __name__ == "__main__":
main()

View File

@@ -1,146 +0,0 @@
#!/bin/bash
# Test script for Nexus Watchdog alerting functionality
set -euo pipefail
TEST_DIR="/tmp/test-nexus-alerts-$$"
export NEXUS_ALERT_DIR="$TEST_DIR"
export NEXUS_ALERT_ENABLED=true
echo "=== Nexus Watchdog Alert Test ==="
echo "Test alert directory: $TEST_DIR"
# Source the alert function from the heartbeat script
# Extract just the nexus_alert function for testing
cat > /tmp/test_alert_func.sh << 'ALEOF'
#!/bin/bash
NEXUS_ALERT_DIR="${NEXUS_ALERT_DIR:-/tmp/nexus-alerts}"
NEXUS_ALERT_ENABLED=true
HOSTNAME=$(hostname -s 2>/dev/null || echo "unknown")
SCRIPT_NAME="kimi-heartbeat-test"
nexus_alert() {
local alert_type="$1"
local message="$2"
local severity="${3:-info}"
local extra_data="${4:-{}}"
if [ "$NEXUS_ALERT_ENABLED" != "true" ]; then
return 0
fi
mkdir -p "$NEXUS_ALERT_DIR" 2>/dev/null || return 0
local timestamp
timestamp=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
local nanoseconds=$(date +%N 2>/dev/null || echo "$$")
local alert_id="${SCRIPT_NAME}_$(date +%s)_${nanoseconds}_$$"
local alert_file="$NEXUS_ALERT_DIR/${alert_id}.json"
cat > "$alert_file" << EOF
{
"alert_id": "$alert_id",
"timestamp": "$timestamp",
"source": "$SCRIPT_NAME",
"host": "$HOSTNAME",
"alert_type": "$alert_type",
"severity": "$severity",
"message": "$message",
"data": $extra_data
}
EOF
if [ -f "$alert_file" ]; then
echo "NEXUS_ALERT: $alert_type [$severity] - $message"
return 0
else
echo "NEXUS_ALERT_FAILED: Could not write alert"
return 1
fi
}
ALEOF
source /tmp/test_alert_func.sh
# Test 1: Basic alert
echo -e "\n[TEST 1] Sending basic info alert..."
nexus_alert "test_alert" "Test message from heartbeat" "info" '{"test": true}'
# Test 2: Stale lock alert simulation
echo -e "\n[TEST 2] Sending stale lock alert..."
nexus_alert \
"stale_lock_reclaimed" \
"Stale lockfile deadlock cleared after 650s" \
"warning" \
'{"lock_age_seconds": 650, "lockfile": "/tmp/kimi-heartbeat.lock", "action": "removed"}'
# Test 3: Heartbeat resumed alert
echo -e "\n[TEST 3] Sending heartbeat resumed alert..."
nexus_alert \
"heartbeat_resumed" \
"Kimi heartbeat resumed after clearing stale lock" \
"info" \
'{"recovery": "successful", "continuing": true}'
# Check results
echo -e "\n=== Alert Files Created ==="
alert_count=$(find "$TEST_DIR" -name "*.json" 2>/dev/null | wc -l)
echo "Total alert files: $alert_count"
if [ "$alert_count" -eq 3 ]; then
echo "✅ All 3 alerts were created successfully"
else
echo "❌ Expected 3 alerts, found $alert_count"
exit 1
fi
echo -e "\n=== Alert Contents ==="
for f in "$TEST_DIR"/*.json; do
echo -e "\n--- $(basename "$f") ---"
cat "$f" | python3 -m json.tool 2>/dev/null || cat "$f"
done
# Validate JSON structure
echo -e "\n=== JSON Validation ==="
all_valid=true
for f in "$TEST_DIR"/*.json; do
if python3 -c "import json; json.load(open('$f'))" 2>/dev/null; then
echo "$(basename "$f") - Valid JSON"
else
echo "$(basename "$f") - Invalid JSON"
all_valid=false
fi
done
# Check for required fields
echo -e "\n=== Required Fields Check ==="
for f in "$TEST_DIR"/*.json; do
basename=$(basename "$f")
missing=()
python3 -c "import json; d=json.load(open('$f'))" 2>/dev/null || continue
for field in alert_id timestamp source host alert_type severity message data; do
if ! python3 -c "import json; d=json.load(open('$f')); exit(0 if '$field' in d else 1)" 2>/dev/null; then
missing+=("$field")
fi
done
if [ ${#missing[@]} -eq 0 ]; then
echo "$basename - All required fields present"
else
echo "$basename - Missing fields: ${missing[*]}"
all_valid=false
fi
done
# Cleanup
rm -rf "$TEST_DIR" /tmp/test_alert_func.sh
echo -e "\n=== Test Summary ==="
if [ "$all_valid" = true ]; then
echo "✅ All tests passed!"
exit 0
else
echo "❌ Some tests failed"
exit 1
fi

View File

@@ -5,12 +5,7 @@
set -euo pipefail
KIMI_TOKEN=$(cat /Users/apayne/.timmy/kimi_gitea_token | tr -d '[:space:]')
# --- Tailscale/IP Detection (timmy-home#385) ---
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/lib/tailscale-gitea.sh"
BASE="$GITEA_BASE_URL"
BASE="http://100.126.61.75:3000/api/v1"
LOG="/tmp/kimi-mentions.log"
PROCESSED="/tmp/kimi-mentions-processed.txt"

View File

@@ -1,55 +0,0 @@
#!/bin/bash
# example-usage.sh — Example showing how to use the tailscale-gitea module
# Issue: timmy-home#385 — Standardized Tailscale IP detection module
set -euo pipefail
# --- Basic Usage ---
# Source the module to automatically set GITEA_BASE_URL
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/tailscale-gitea.sh"
# Now use GITEA_BASE_URL in your API calls
echo "Using Gitea at: $GITEA_BASE_URL"
echo "Tailscale active: $GITEA_USING_TAILSCALE"
# --- Example API Call ---
# curl -sf -H "Authorization: token $TOKEN" \
# "$GITEA_BASE_URL/repos/myuser/myrepo/issues"
# --- Custom Configuration (Optional) ---
# You can customize behavior by setting variables BEFORE sourcing:
#
# TAILSCALE_TIMEOUT=5 # Wait 5 seconds instead of 2
# TAILSCALE_DEBUG=1 # Print which endpoint was selected
# source "${SCRIPT_DIR}/tailscale-gitea.sh"
# --- Advanced: Checking Network Mode ---
if [[ "$GITEA_USING_TAILSCALE" == "true" ]]; then
echo "✓ Connected via private Tailscale network"
else
echo "⚠ Using public internet fallback (Tailscale unavailable)"
fi
# --- Example: Polling with Retry Logic ---
poll_gitea() {
local endpoint="${1:-$GITEA_BASE_URL}"
local max_retries="${2:-3}"
local retry=0
while [[ $retry -lt $max_retries ]]; do
if curl -sf --connect-timeout 2 "${endpoint}/version" > /dev/null 2>&1; then
echo "Gitea is reachable"
return 0
fi
retry=$((retry + 1))
echo "Retry $retry/$max_retries..."
sleep 1
done
echo "Gitea unreachable after $max_retries attempts"
return 1
}
# Uncomment to test connectivity:
# poll_gitea "$GITEA_BASE_URL"

View File

@@ -1,64 +0,0 @@
#!/bin/bash
# tailscale-gitea.sh — Standardized Tailscale IP detection module for Gitea API access
# Issue: timmy-home#385 — Standardize Tailscale IP detection across auxiliary scripts
#
# Usage (source this file in your script):
# source /path/to/tailscale-gitea.sh
# # Now use $GITEA_BASE_URL for API calls
#
# Configuration (set before sourcing to customize):
# TAILSCALE_IP - Tailscale IP to try first (default: 100.126.61.75)
# PUBLIC_IP - Public fallback IP (default: 143.198.27.163)
# GITEA_PORT - Gitea API port (default: 3000)
# TAILSCALE_TIMEOUT - Connection timeout in seconds (default: 2)
# GITEA_API_VERSION - API version path (default: api/v1)
#
# Sovereignty: Private Tailscale network preferred over public internet
# --- Default Configuration ---
: "${TAILSCALE_IP:=100.126.61.75}"
: "${PUBLIC_IP:=143.198.27.163}"
: "${GITEA_PORT:=3000}"
: "${TAILSCALE_TIMEOUT:=2}"
: "${GITEA_API_VERSION:=api/v1}"
# --- Detection Function ---
_detect_gitea_endpoint() {
local tailscale_url="http://${TAILSCALE_IP}:${GITEA_PORT}/${GITEA_API_VERSION}"
local public_url="http://${PUBLIC_IP}:${GITEA_PORT}/${GITEA_API_VERSION}"
# Prefer Tailscale (private network) over public IP
if curl -sf --connect-timeout "$TAILSCALE_TIMEOUT" \
"${tailscale_url}/version" > /dev/null 2>&1; then
echo "$tailscale_url"
return 0
else
echo "$public_url"
return 1
fi
}
# --- Main Detection ---
# Set GITEA_BASE_URL for use by sourcing scripts
# Also sets GITEA_USING_TAILSCALE=true/false for scripts that need to know
if curl -sf --connect-timeout "$TAILSCALE_TIMEOUT" \
"http://${TAILSCALE_IP}:${GITEA_PORT}/${GITEA_API_VERSION}/version" > /dev/null 2>&1; then
GITEA_BASE_URL="http://${TAILSCALE_IP}:${GITEA_PORT}/${GITEA_API_VERSION}"
GITEA_USING_TAILSCALE=true
else
GITEA_BASE_URL="http://${PUBLIC_IP}:${GITEA_PORT}/${GITEA_API_VERSION}"
GITEA_USING_TAILSCALE=false
fi
# Export for child processes
export GITEA_BASE_URL
export GITEA_USING_TAILSCALE
# Optional: log which endpoint was selected (set TAILSCALE_DEBUG=1 to enable)
if [[ "${TAILSCALE_DEBUG:-0}" == "1" ]]; then
if [[ "$GITEA_USING_TAILSCALE" == "true" ]]; then
echo "[tailscale-gitea] Using Tailscale endpoint: $GITEA_BASE_URL" >&2
else
echo "[tailscale-gitea] Tailscale unavailable, using public endpoint: $GITEA_BASE_URL" >&2
fi
fi