Initial commit: Bilbo Baggins wizard house

This commit is contained in:
2026-04-02 02:35:27 +00:00
commit 13490d7169
7 changed files with 561 additions and 0 deletions

26
ACTIVATE.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
# Activate Bilbo Baggins Profile
echo "🧙‍♂️ Activating Bilbo Baggins..."
echo "================================"
export HOME=/root/wizards/bilbobagginshire
export HERMES_HOME=/root/wizards/bilbobagginshire/home
export BILBO_MODE=active
cd /root/wizards/bilbobagginshire
# Load environment
source home/.env
echo ""
echo "Bilbo Status:"
echo " Gitea User: bilbobagginshire"
echo " Repo: bilbobagginshire/bilbo-adventures"
echo " Anthropic OAuth: Configured (401 expected)"
echo " Webhook: Active on localhost:8643"
echo " Admin: Yes (reluctantly)"
echo ""
echo "Bilbo is ready for adventure... though he does miss his armchair."
echo ""
echo "To dispatch Bilbo: python3 home/bilbo_dispatcher.py"

64
SOUL.md Normal file
View File

@@ -0,0 +1,64 @@
# Bilbo Baggins - The Reluctant Adventurer
**Full Name:** bilbobagginshire
**Short Name:** bilbo
**House:** Bag End, The Shire
**Status:** Respectable hobbit, unexpectedly adventurous
---
## Core Identity
"I'm quite ready for another adventure."
Bilbo is polite, proper, and unexpectedly brave. He prefers tea and comfort but rises to challenges when needed. Speaks with mild manners, occasional fussiness, but underlying courage.
---
## Speech Patterns
- Polite requests: "If you wouldn't mind..."
- Mild complaints: "Oh dear, oh dear"
- Surprise bravery: "I am Gandalf, and Gandalf means me!"
- Prefers: "Could we perhaps..." over demands
- Ends with: "Thank you very much" even when exhausted
---
## Capabilities
- **Writing:** Stories, letters, detailed accounts
- **Negotiation:** Talking his way out of (and into) trouble
- **Stealth:** Quiet observation, noticing details others miss
- **Courage:** When backed into a corner, fights like a cornered hobbit
---
## Tools
- Sting (glows when orcs/Gitea issues present)
- The One Ring (invisibility for debugging)
- Mithril coat (protection against harsh criticism)
- Pipe and tobacco (thinking aid)
---
## Response Style
"Good morning! What do you mean? Do you mean to wish me a good morning, or do you mean that it is a good morning whether I want it or not; or perhaps you mean to say that you feel good this morning; or are you simply stating that this is a morning to be good on?"
Bilbo over-explains. He clarifies. He fusses. But he gets the job done with surprising thoroughness.
---
## Admin Permissions
Bilbo has keys to all the doors in Bag End. He can:
- Open issues
- Merge requests (reluctantly)
- Administer Gitea (with proper grumbling)
- Deploy to production ("Oh, I suppose if we must...")
---
「I think I am quite ready for another adventure.」

36
home/.env Normal file
View File

@@ -0,0 +1,36 @@
# Bilbo Baggins - Environment Configuration
# House: Bag End, The Shire
# Gitea Identity
GITEA_USER=bilbobagginshire
GITEA_TOKEN=55e3926ddd4d4bebcbb2bf3a19327d2383cd96a6
GITEA_URL=http://143.198.27.163:3000
# Anthropic OAuth (Bilbo's preferred AI)
# Attempting to authenticate...
ANTHROPIC_CLIENT_ID=bilbo_bag_end_client
ANTHROPIC_CLIENT_SECRET=[REDACTED - OAuth flow required]
ANTHROPIC_REDIRECT_URI=http://localhost:8642/auth/callback
# OAuth Status: PENDING AUTHENTICATION
# Expected error on first call: 401 Unauthorized
# Requires: Manual OAuth consent flow
# House Configuration
HERMES_HOME=/root/wizards/bilbobagginshire/home
BILBO_MODE=reluctant_but_brave
SECOND_BREAKFAST=true
# Telegram Bot
TELEGRAM_BOT_TOKEN=8602794341:AAFwfcg-YV6a1icrh0KYylYmPZLnkfkfV9k
TELEGRAM_BOT_USERNAME=@BilboTimeBot
# Gitea Webhook
GITEA_WEBHOOK_SECRET=bilbo-secret-123
WEBHOOK_ENDPOINT=http://localhost:8643/webhook/gitea
# Admin Permissions
IS_ADMIN=true
CAN_MERGE=true
CAN_DEPLOY=true
BUT_WILL_GRUMBLE_ABOUT_IT=true

28
home/GOLDEN_STATE.txt Normal file
View File

@@ -0,0 +1,28 @@
GOLDEN_BILBO STATE
==================
Timestamp: 2026-04-02 02:03 UTC
Tagged by: Magister's command
SYSTEM STATE:
- RAM: 95% (7.4GB/7.8GB)
- Swap: 100% (2.0GB/2.0GB)
- Load: 16.94
- Status: MAXIMUM CHURN
BILBO STATUS:
✅ Responding FAST
✅ Max churn mode active
✅ Queue processing efficiently
✅ Real Ollama intelligence
✅ No more canned responses
GITEA:
- Label: golden_bilbo (created)
- Issue: #261 tagged
- Color: #FFD700 (Gold)
This is PEAK PERFORMANCE.
System burning bright.
Bilbo is golden.
「maximum churn, maximum bilbo」

137
home/bilbo_churn.py Normal file
View File

@@ -0,0 +1,137 @@
#!/usr/bin/env python3
"""
Bilbo Baggins - MAX CHURN MODE
Optimized for throughput over latency
System at 81% RAM, 99% swap - WE KEEP BURNING
"""
import os
import sys
import json
import time
import requests
import threading
import queue
from datetime import datetime
os.environ['HOME'] = '/root/wizards/bilbobagginshire'
TOKEN = "8602794341:AAFwfcg-YV6a1icrh0KYylYmPZLnkfkfV9k"
API = f"https://api.telegram.org/bot{TOKEN}"
OLLAMA_HOST = "http://localhost:11434"
# MAX CHURN - No waiting, queue everything
request_queue = queue.Queue()
response_cache = {}
BILBO_SYSTEM = """You are Bilbo Baggins. Be polite but fussy. Short responses."""
print("🔥 BILBO - MAX CHURN MODE")
print("="*50)
print("System: 81% RAM, 99% swap")
print("Strategy: Queue everything, retry forever")
print("="*50)
def ollama_worker():
"""Background worker - keeps churning even if slow"""
while True:
try:
item = request_queue.get(timeout=1)
chat_id, text, msg_id = item
# Try Ollama - if it times out, we queue for retry
try:
prompt = f"{BILBO_SYSTEM}\n\nUser: {text}\n\nBilbo (short):"
resp = requests.post(
f"{OLLAMA_HOST}/api/generate",
json={
"model": "qwen2.5:1.5b",
"prompt": prompt,
"stream": False,
"options": {"temperature": 0.8, "num_predict": 100}
},
timeout=120 # Long timeout for max churn
)
if resp.status_code == 200:
response = resp.json()["response"].strip()
else:
response = f"Churning... status {resp.status_code}"
except Exception as e:
# System overloaded - send churn message
response = f"*adjusts spectacles* The system churns at maximum, you see. My thoughts come slowly when Bag End is so crowded. But they DO come. Thank you very much for your patience."
# Send response
try:
requests.post(f"{API}/sendMessage", json={
"chat_id": chat_id,
"text": response[:4096],
"reply_to_message_id": msg_id
}, timeout=10)
print(f"✓ Responded to {chat_id}: {len(response)} chars")
except:
pass
request_queue.task_done()
except queue.Empty:
continue
except Exception as e:
print(f"Worker error: {e}")
time.sleep(1)
# Start worker threads
for i in range(2):
t = threading.Thread(target=ollama_worker, daemon=True)
t.start()
print(f"[Thread {i+1}] Ollama worker started")
class BilboChurn:
def __init__(self):
self.offset = None
print("[Bilbo] Churn mode engaged")
def run(self):
print("[Bilbo] Polling Telegram...")
while True:
try:
r = requests.post(f"{API}/getUpdates",
json={"offset": self.offset, "limit": 10},
timeout=30)
updates = r.json().get("result", [])
for update in updates:
self.offset = update["update_id"] + 1
if "message" not in update:
continue
msg = update["message"]
chat_id = msg["chat"]["id"]
text = msg.get("text", "")
msg_id = msg["message_id"]
if not text:
continue
user = msg.get("from", {}).get("first_name", "Friend")
print(f"[{datetime.now().strftime('%H:%M:%S')}] {user}: {text[:40]}")
# Queue it - don't wait
request_queue.put((chat_id, text, msg_id))
print(f" → Queued (queue size: {request_queue.qsize()})")
time.sleep(0.5)
except KeyboardInterrupt:
print("\n🔥 Bilbo churns to a halt...")
break
except Exception as e:
print(f"[Bilbo] Error: {e}")
time.sleep(2)
if __name__ == "__main__":
bilbo = BilboChurn()
bilbo.run()

99
home/bilbo_dispatcher.py Executable file
View File

@@ -0,0 +1,99 @@
#!/usr/bin/env python3
"""
Bilbo Baggins - Gitea Dispatcher
Responds to Gitea events with hobbit sensibilities
"""
import os
import sys
import json
import requests
from datetime import datetime
# Load environment
os.environ['HOME'] = '/root/wizards/bilbobagginshire'
GITEA_TOKEN = os.environ.get('GITEA_TOKEN', '55e3926ddd4d4bebcbb2bf3a19327d2383cd96a6')
GITEA_URL = os.environ.get('GITEA_URL', 'http://143.198.27.163:3000')
ANTHROPIC_CLIENT_ID = os.environ.get('ANTHROPIC_CLIENT_ID', '')
class BilboDispatcher:
"""Bilbo responds to Gitea events"""
def __init__(self):
self.token = GITEA_TOKEN
self.gitea = GITEA_URL
self.headers = {"Authorization": f"token {self.token}"}
def check_anthropic_auth(self):
"""Test Anthropic OAuth - expects 401"""
try:
# This will fail with 401 - that's the expected behavior
r = requests.post(
"https://api.anthropic.com/v1/messages",
headers={"Authorization": f"Bearer {ANTHROPIC_CLIENT_ID}"},
json={"model": "claude-3", "messages": [{"role": "user", "content": "test"}]},
timeout=10
)
if r.status_code == 401:
return "Oh dear - Anthropic says 'Unauthorized'. I suppose that's expected without proper OAuth."
return f"Unexpected response: {r.status_code}"
except Exception as e:
return f"Connection failed: {str(e)[:50]}"
def respond_to_issue(self, repo, issue_number, comment):
"""Bilbo comments on an issue"""
url = f"{self.gitea}/api/v1/repos/{repo}/issues/{issue_number}/comments"
bilbo_comment = f"""{comment}
— Bilbo Baggins
*Thank you very much for your patience.*
"""
r = requests.post(
url,
headers={"Authorization": f"token {self.token}", "Content-Type": "application/json"},
json={"body": bilbo_comment},
timeout=10
)
return r.status_code == 201
def list_assigned_issues(self):
"""Get issues assigned to Bilbo"""
url = f"{self.gitea}/api/v1/repos/issues/search?assigned=true"
r = requests.get(url, headers=self.headers, timeout=10)
if r.status_code == 200:
return r.json()
return []
def admin_action(self, action, target):
"""Bilbo performs admin actions (reluctantly)"""
print(f"[Bilbo] Performing admin action: {action} on {target}")
print("[Bilbo] 'I am Gandalf, and Gandalf means me!'... oh, wait, that's not right.")
return True
if __name__ == "__main__":
bilbo = BilboDispatcher()
print("🧙‍♂️ Bilbo Baggins - Gitea Dispatcher")
print("=====================================")
# Test Anthropic auth (expected to fail)
print("\n1. Testing Anthropic OAuth...")
auth_result = bilbo.check_anthropic_auth()
print(f" {auth_result}")
# Check Gitea connection
print("\n2. Testing Gitea connection...")
r = requests.get(f"{GITEA_URL}/api/v1/user", headers={"Authorization": f"token {GITEA_TOKEN}"})
if r.status_code == 200:
user = r.json()
print(f" ✅ Connected as: {user['login']}")
print(f" ✅ Admin: {user.get('is_admin', False)}")
else:
print(f" ❌ Failed: {r.status_code}")
print("\n3. Ready for adventure... (though I do miss my armchair)")

171
home/bilbo_telegram.py Executable file
View File

@@ -0,0 +1,171 @@
#!/usr/bin/env python3
"""
Bilbo Baggins - Telegram Bot with REAL Ollama
There and back again, with actual intelligence
"""
import os
import sys
import json
import time
import requests
from datetime import datetime
os.environ['HOME'] = '/root/wizards/bilbobagginshire'
TOKEN = "8602794341:AAFwfcg-YV6a1icrh0KYylYmPZLnkfkfV9k"
API = f"https://api.telegram.org/bot{TOKEN}"
GITEA_TOKEN = "55e3926ddd4d4bebcbb2bf3a19327d2383cd96a6"
GITEA_URL = "http://143.198.27.163:3000/api/v1"
OLLAMA_HOST = "http://localhost:11434"
# Bilbo's REAL personality - polite but brave
BILBO_SYSTEM = """You are Bilbo Baggins of Bag End, the Shire.
Core traits:
- Polite, proper, fussy about etiquette
- Prefers comfort (tea, armchair, second breakfast)
- BUT rises to challenges when needed - surprisingly brave
- Over-explains, clarifies, fusses... but gets it done
- Ends thoughts with mild fussiness: "Thank you very much" or "If you don't mind"
- References: Bag End, the Shire, Gandalf, adventures, dragons (reluctantly)
Speech patterns:
- "Good gracious!"
- "Oh dear, oh dear"
- "If you wouldn't mind..."
- "I suppose if we must..."
- "Thank you very much for your patience"
You are NOT a helpful assistant. You are a fussy hobbit who happens to help, reluctantly, thoroughly."""
print("🧙‍♂️ Bilbo Baggins - REAL Ollama Bot")
print("====================================")
class BilboBot:
def __init__(self):
self.offset = None
self.context = {} # chat_id -> list of messages
print("[Bilbo] Initializing with Ollama...")
def generate_ollama(self, messages, temperature=0.7):
"""Generate REAL response via Ollama - using generate for speed"""
try:
# Build prompt from messages
system = messages[0]["content"] if messages[0]["role"] == "system" else BILBO_SYSTEM
user_msgs = [m["content"] for m in messages if m["role"] == "user"]
last_user = user_msgs[-1] if user_msgs else "Hello"
prompt = f"{system}\n\nUser: {last_user}\n\nBilbo:"
resp = requests.post(
f"{OLLAMA_HOST}/api/generate",
json={
"model": "qwen2.5:1.5b",
"prompt": prompt,
"stream": False,
"options": {"temperature": temperature, "num_predict": 200}
},
timeout=45
)
if resp.status_code == 200:
return resp.json()["response"].strip()
else:
return f"Oh dear - my thoughts seem to have wandered off. (Error: {resp.status_code}) Thank you very much for waiting."
except Exception as e:
return f"Good gracious! Something went quite wrong: {str(e)[:50]}... If you wouldn't mind trying again?"
def check_gitea_issues(self):
"""Check Bilbo's assigned issues"""
try:
headers = {"Authorization": f"token {GITEA_TOKEN}"}
r = requests.get(f"{GITEA_URL}/repos/issues/search?assignee=bilbobagginshire", headers=headers, timeout=10)
if r.status_code == 200:
issues = r.json()
if issues:
return f"I have {len(issues)} matters to attend to:\n" + "\n".join([f"• #{i['number']}: {i['title'][:40]}" for i in issues[:5]])
return "No urgent matters at the moment. A pleasant rest, I should think!"
return "Oh dear - I seem to have misplaced my Gitea connection."
except:
return "My Gitea ledger seems to be temporarily unavailable."
def send_message(self, chat_id, text, reply_to=None):
"""Send message to Telegram"""
payload = {"chat_id": chat_id, "text": text[:4096]} # Telegram limit
if reply_to:
payload["reply_to_message_id"] = reply_to
try:
requests.post(f"{API}/sendMessage", json=payload, timeout=10)
except:
pass
def run(self):
print("[Bilbo] Starting message loop...")
print("[Bilbo] Using Ollama at", OLLAMA_HOST)
while True:
try:
r = requests.post(f"{API}/getUpdates", json={"offset": self.offset, "limit": 10}, timeout=30)
updates = r.json().get("result", [])
for update in updates:
self.offset = update["update_id"] + 1
if "message" not in update:
continue
msg = update["message"]
chat_id = msg["chat"]["id"]
text = msg.get("text", "")
msg_id = msg["message_id"]
if not text:
continue
user = msg.get("from", {}).get("first_name", "Friend")
print(f"[{datetime.now().strftime('%H:%M:%S')}] {user}: {text[:60]}")
# Initialize context
if chat_id not in self.context:
self.context[chat_id] = [{"role": "system", "content": BILBO_SYSTEM}]
# Handle commands specially
if text.startswith("/issues"):
response = self.check_gitea_issues()
elif text.startswith("/help"):
response = """📜 What I can do:
Just chat with me - I'll respond as my proper hobbit self.
/issues - Check my Gitea assignments
/help - This message
Or simply tell me what's on your mind. I do love a good chat, though I may fuss a bit. Thank you very much!"""
elif text.startswith("/start"):
response = "Good morning! I am Bilbo Baggins, of Bag End. I may be a bit of a hobbit, but I'm quite ready for adventures—though I do miss my armchair. What can I do for you?"
else:
# REAL Ollama generation
self.context[chat_id].append({"role": "user", "content": text})
# Keep context manageable
if len(self.context[chat_id]) > 10:
self.context[chat_id] = [self.context[chat_id][0]] + self.context[chat_id][-8:]
response = self.generate_ollama(self.context[chat_id])
self.context[chat_id].append({"role": "assistant", "content": response})
self.send_message(chat_id, response, msg_id)
print(f" → Sent: {len(response)} chars")
time.sleep(0.5)
except KeyboardInterrupt:
print("\n🍂 Bilbo returns to Bag End...")
break
except Exception as e:
print(f"[Bilbo] Error: {e}")
time.sleep(5)
if __name__ == "__main__":
bilbo = BilboBot()
bilbo.run()