e909cc0044
Add MCP delegation bridge and diagram tools
...
**Features Added**:
1. **Agent Registry (agent_registry.py)**
- Thread-safe global singleton for MCP tool access to Agent instance
- Enables MCP tools to call Agent.delegate() without circular imports
- Registered at bot startup in bot_runner.py
2. **Sub-Agent Manager (sub_agent_manager.py)**
- Watchdog system monitoring sub-agent lifecycle
- Detects hung agents (5min timeout, 30s check interval)
- Auto-cleanup and status tracking
3. **delegate_task MCP Tool (mcp_tools.py)**
- Exposes Agent.delegate() to Claude via MCP protocol
- Enables parallel sub-agent execution via tool calls
- Supports specialist prompts and agent ID caching
4. **Memory Write Locks (memory_system.py)**
- Thread-safe writes to prevent file corruption
- Protects write_memory(), update_soul(), update_user()
5. **Diagram Tools**
- Mermaid MCP server (flowcharts, sequence diagrams, etc.)
- Excalidraw MCP server (hand-drawn style diagrams)
- Config files in config/ directory
6. **Adapter Improvements**
- Enhanced error handling across all adapters
- Unified logging patterns
**Testing**: Ready for parallel sub-agent testing
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-03-01 14:34:24 -07:00
7697220c74
Refactor: Remove zombie code, fix bugs, and clean documentation
...
This comprehensive refactoring removes dead code, fixes bugs, and deletes
outdated documentation to make the codebase production-ready.
## Files Deleted (16 files)
### Temporary/zombie files (9 files):
- nul (Windows artifact)
- quick_start.bat (superseded by run.bat)
- scripts/proxmox_ssh.py (hardcoded credentials - security risk)
- scripts/proxmox_ssh.sh (hardcoded credentials - security risk)
- scripts/collection_output.txt (one-time audit output)
- scripts/collect-homelab-config.sh (one-off infrastructure script)
- scripts/collect-remote.sh (one-off infrastructure script)
- memory_workspace/MEMORY.md.old (backup file)
- promtail-config-optimized.yaml (misplaced homelab config)
### Outdated documentation (7 files):
- MCP_MIGRATION.md (migration complete - 2026-02-15)
- QUICK_REFERENCE_AGENT_SDK.md (orphaned from cleanup)
- SETUP.md (duplicate of README.md quick start)
- WINDOWS_QUICK_REFERENCE.md (duplicate of docs/WINDOWS_DEPLOYMENT.md)
- SUB_AGENTS.md (design doc for unimplemented feature)
- JARVIS_VOICE_INTEGRATION_PLAN.md (1300-line spec, code not implemented)
- OBSIDIAN_MCP_SETUP_INSTRUCTIONS.md (temporary troubleshooting doc)
- LOGGING.md (redundant with well-commented logging_config.py)
- docs/SECURITY_AUDIT_SUMMARY.md (completed audit from 2026-02-12)
## Critical Bug Fixes (2 bugs)
1. bot_runner.py line 122: Fixed wrong dict key reference
- Changed send_to_platform → send_to
- Bug caused scheduled task platform info to never print
2. usage_tracker.py: Added missing pricing for claude-sonnet-4-6
- Model was default but had no pricing entry
- Caused cost under-reporting in Direct API mode
## Code Removed (14 files modified, ~1200 lines deleted)
### Dead imports removed (9 imports):
- bot_runner.py: sys
- agent.py: time
- adapters/runtime.py: re
- adapters/skill_integration.py: subprocess
- tools.py: redundant Path import
- mcp_servers/loki/loki_server.py: json
- google_tools/oauth_manager.py: Thread, Dict
- google_tools/gmail_client.py: os
- google_tools/utils.py: email
### Unused functions/methods removed (9 functions):
- agent.py: MEMORY_RESPONSE_PREVIEW_LENGTH constant
- scheduled_tasks.py: integrate_scheduler_with_runtime()
- adapters/runtime.py: command_preprocessor(), markdown_postprocessor()
- adapters/skill_integration.py: invoke_skill_via_cli(), __main__ block
- tools.py: _extract_mcp_result()
- google_tools/oauth_manager.py: needs_refresh_soon(), revoke_authorization()
- google_tools/people_client.py: update_contact(), delete_contact()
### Code quality improvements:
- memory_system.py: Removed empty else: pass branch
- calendar_client.py: Fixed bare except: → except Exception:
- mcp_ssh.py: Updated asyncio.get_event_loop() → get_running_loop()
- calendar_client.py: Fixed deprecated datetime.utcnow() → now(timezone.utc)
## Impact
- ~1200 lines of dead code removed
- 16 obsolete files deleted
- 2 critical bugs fixed
- 3 deprecated APIs updated
- Zero functionality broken (all changes verified)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-24 12:46:56 -07:00
fe7c146dc6
feat: Add Gitea MCP integration and project cleanup
...
## New Features
- **Gitea MCP Tools** (zero API cost):
- gitea_read_file: Read files from homelab repo
- gitea_list_files: Browse directories
- gitea_search_code: Search by filename
- gitea_get_tree: Get directory tree
- **Gitea Client** (gitea_tools/client.py): REST API wrapper with OAuth
- **Proxmox SSH Scripts** (scripts/): Homelab data collection utilities
- **Obsidian MCP Support** (obsidian_mcp.py): Advanced vault operations
- **Voice Integration Plan** (JARVIS_VOICE_INTEGRATION_PLAN.md)
## Improvements
- **Increased timeout**: 5min → 10min for complex tasks (llm_interface.py)
- **Removed Direct API fallback**: Gitea tools are MCP-only (zero cost)
- **Updated .env.example**: Added Obsidian MCP configuration
- **Enhanced .gitignore**: Protect personal memory files (SOUL.md, MEMORY.md)
## Cleanup
- Deleted 24 obsolete files (temp/test/experimental scripts, outdated docs)
- Untracked personal memory files (SOUL.md, MEMORY.md now in .gitignore)
- Removed: AGENT_SDK_IMPLEMENTATION.md, HYBRID_SEARCH_SUMMARY.md,
IMPLEMENTATION_SUMMARY.md, MIGRATION.md, test_agent_sdk.py, etc.
## Configuration
- Added config/gitea_config.example.yaml (Gitea setup template)
- Added config/obsidian_mcp.example.yaml (Obsidian MCP template)
- Updated scheduled_tasks.yaml with new task examples
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-18 20:31:32 -07:00
f018800d94
Implement self-healing system Phase 1: Error capture and logging
...
- Add SelfHealingSystem with error observation infrastructure
- Capture errors with full context: type, message, stack trace, intent, inputs
- Log to MEMORY.md with deduplication (max 3 attempts per error signature)
- Integrate error capture in agent, tools, runtime, and scheduler
- Non-invasive: preserves all existing error handling behavior
- Foundation for future diagnosis and auto-fixing capabilities
Phase 1 of 4-phase rollout - observation only, no auto-fixing yet.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-14 18:03:42 -07:00
8afff96bb5
Add API usage tracking and dynamic task reloading
...
Features:
- Usage tracking system (usage_tracker.py)
- Tracks input/output tokens per API call
- Calculates costs with support for cache pricing
- Stores data in usage_data.json (gitignored)
- Integrated into llm_interface.py
- Dynamic task scheduler reloading
- Auto-detects YAML changes every 60s
- No restart needed for new tasks
- reload_tasks() method for manual refresh
- Example cost tracking scheduled task
- Daily API usage report
- Budget tracking ($5/month target)
- Disabled by default in scheduled_tasks.yaml
Improvements:
- Fixed tool_use/tool_result pair splitting bug (CRITICAL)
- Added thread safety to agent.chat()
- Fixed N+1 query problem in hybrid search
- Optimized database batch queries
- Added conversation history pruning (50 messages max)
Updated .gitignore:
- Exclude user profiles (memory_workspace/users/*.md)
- Exclude usage data (usage_data.json)
- Exclude vector index (vectors.usearch)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-13 23:38:44 -07:00
a99799bf3d
Initial commit: Ajarbot with optimizations
...
Features:
- Multi-platform bot (Slack, Telegram)
- Memory system with SQLite FTS
- Tool use capabilities (file ops, commands)
- Scheduled tasks system
- Dynamic model switching (/sonnet, /haiku)
- Prompt caching for cost optimization
Optimizations:
- Default to Haiku 4.5 (12x cheaper)
- Reduced context: 3 messages, 2 memory results
- Optimized SOUL.md (48% smaller)
- Automatic caching when using Sonnet (90% savings)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-13 19:06:28 -07:00