🚀 Complete LangMem Implementation with Advanced Features
## 🎯 Major Features Added ### Analytics System - Added comprehensive memory analytics (src/api/analytics.py) - User statistics, memory relationships, clusters, and trends - System health monitoring and metrics - New analytics endpoints in main API ### Performance Optimization - Created performance optimizer (src/api/performance_optimizer.py) - Database indexing and query optimization - Connection pooling and performance monitoring - Optimization script for production deployment ### Alternative Messaging System - Matrix messaging integration (scripts/claude-messaging-system.py) - Home Assistant room communication - Real-time message monitoring and notifications - Alternative to Signal bridge authentication ### Signal Bridge Investigation - Signal bridge authentication scripts and troubleshooting - Comprehensive authentication flow implementation - Bridge status monitoring and verification tools ## 📊 API Enhancements - Added analytics endpoints (/v1/analytics/*) - Enhanced memory storage with fact extraction - Improved error handling and logging - Performance monitoring decorators ## 🛠️ New Scripts & Tools - claude-messaging-system.py - Matrix messaging interface - optimize-performance.py - Performance optimization utility - Signal bridge authentication and verification tools - Message sending and monitoring utilities ## 📚 Documentation Updates - Updated README.md with new features and endpoints - Added IMPLEMENTATION_STATUS.md with complete system overview - Comprehensive API documentation - Alternative messaging system documentation ## 🎉 System Status - All core features implemented and operational - Production-ready with comprehensive testing - Alternative communication system working - Full documentation and implementation guide 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
166
scripts/complete-signal-auth.py
Normal file
166
scripts/complete-signal-auth.py
Normal file
@@ -0,0 +1,166 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Complete Signal bridge authentication by checking login status and attempting proper authentication
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import httpx
|
||||
import json
|
||||
|
||||
MATRIX_HOMESERVER = "https://matrix.klas.chat"
|
||||
CLAUDE_ACCESS_TOKEN = "syt_Y2xhdWRl_CoBgPoHbtMOxhvOUcMnz_2WRPZJ"
|
||||
SIGNAL_BRIDGE_BOT_ID = "@signalbot:matrix.klas.chat"
|
||||
BRIDGE_DM_ROOM_ID = "!oBnnfKDprgMEHNhNjL:matrix.klas.chat"
|
||||
|
||||
async def send_bridge_command(command, explanation=""):
|
||||
"""Send a command to the Signal bridge bot"""
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
headers = {
|
||||
"Authorization": f"Bearer {CLAUDE_ACCESS_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
print(f"🤖 Sending: {command}")
|
||||
if explanation:
|
||||
print(f" {explanation}")
|
||||
|
||||
response = await client.post(
|
||||
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{BRIDGE_DM_ROOM_ID}/send/m.room.message",
|
||||
headers=headers,
|
||||
json={
|
||||
"msgtype": "m.text",
|
||||
"body": command
|
||||
}
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
print(f"✅ Command sent: {command}")
|
||||
await asyncio.sleep(3) # Wait longer for response
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to send command: {response.status_code}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error sending command: {e}")
|
||||
return False
|
||||
|
||||
async def get_bridge_room_messages(limit=10):
|
||||
"""Get recent messages from the Signal bridge DM room"""
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
headers = {"Authorization": f"Bearer {CLAUDE_ACCESS_TOKEN}"}
|
||||
|
||||
response = await client.get(
|
||||
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{BRIDGE_DM_ROOM_ID}/messages",
|
||||
headers=headers,
|
||||
params={"limit": limit, "dir": "b"}
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
return data.get("chunk", [])
|
||||
else:
|
||||
print(f"❌ Failed to get messages: {response.status_code}")
|
||||
return []
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error getting bridge messages: {e}")
|
||||
return []
|
||||
|
||||
async def check_login_status():
|
||||
"""Check current login status"""
|
||||
print("📋 Checking current login status...")
|
||||
|
||||
await send_bridge_command("list-logins", "Check existing logins")
|
||||
|
||||
messages = await get_bridge_room_messages(5)
|
||||
recent_bot_messages = [
|
||||
msg for msg in messages
|
||||
if msg.get("sender") == SIGNAL_BRIDGE_BOT_ID
|
||||
and msg.get("type") == "m.room.message"
|
||||
]
|
||||
|
||||
print("🔔 Recent bot responses:")
|
||||
for msg in recent_bot_messages[:3]: # Show last 3 responses
|
||||
body = msg.get("content", {}).get("body", "")
|
||||
print(f" → {body}")
|
||||
|
||||
return recent_bot_messages
|
||||
|
||||
async def attempt_manual_authentication():
|
||||
"""Try to authenticate manually with Signal bridge"""
|
||||
print("\n🔐 Attempting manual authentication...")
|
||||
|
||||
# First check if we have any existing logins
|
||||
await check_login_status()
|
||||
|
||||
# Try to get version info
|
||||
print("\n📱 Getting bridge version...")
|
||||
await send_bridge_command("version", "Get bridge version")
|
||||
|
||||
# Check messages
|
||||
messages = await get_bridge_room_messages(5)
|
||||
recent_bot_messages = [
|
||||
msg for msg in messages
|
||||
if msg.get("sender") == SIGNAL_BRIDGE_BOT_ID
|
||||
and msg.get("type") == "m.room.message"
|
||||
]
|
||||
|
||||
print("🔔 Recent responses:")
|
||||
for msg in recent_bot_messages[:3]:
|
||||
body = msg.get("content", {}).get("body", "")
|
||||
print(f" → {body}")
|
||||
|
||||
# Try to initiate login process
|
||||
print("\n🚀 Initiating login process...")
|
||||
await send_bridge_command("login", "Start login process")
|
||||
|
||||
# Check for QR code or other authentication responses
|
||||
await asyncio.sleep(2)
|
||||
messages = await get_bridge_room_messages(5)
|
||||
recent_bot_messages = [
|
||||
msg for msg in messages
|
||||
if msg.get("sender") == SIGNAL_BRIDGE_BOT_ID
|
||||
and msg.get("type") == "m.room.message"
|
||||
]
|
||||
|
||||
print("🔔 Authentication responses:")
|
||||
for msg in recent_bot_messages[:3]:
|
||||
body = msg.get("content", {}).get("body", "")
|
||||
print(f" → {body}")
|
||||
|
||||
# Check if we got a QR code link
|
||||
if "sgnl://linkdevice" in body:
|
||||
print(f"🔗 QR Code link detected: {body}")
|
||||
print("📱 To complete authentication:")
|
||||
print(" 1. Open Signal app on your phone")
|
||||
print(" 2. Go to Settings > Linked devices")
|
||||
print(" 3. Tap 'Link New Device'")
|
||||
print(" 4. Scan the QR code or use the link above")
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
async def main():
|
||||
"""Main function"""
|
||||
print("🌉 Signal Bridge Authentication Completion")
|
||||
print("=" * 50)
|
||||
|
||||
# Check current status
|
||||
await check_login_status()
|
||||
|
||||
# Try manual authentication
|
||||
has_auth_method = await attempt_manual_authentication()
|
||||
|
||||
if has_auth_method:
|
||||
print("\n✅ Authentication method available!")
|
||||
print("📱 Complete the authentication using your Signal app")
|
||||
print("🔍 After scanning QR code, run this script again to verify")
|
||||
else:
|
||||
print("\n❌ No authentication method available")
|
||||
print("💡 This may require manual intervention or bridge configuration")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user