ce2c384387
Migrate to Claude Agent SDK framework (v0.2.0)
...
BREAKING CHANGE: Replaced FastAPI server wrapper with direct Claude Agent SDK integration
## Major Changes
### Architecture
- **OLD:** Bot → FastAPI Server → claude-code-sdk → Claude
- **NEW:** Bot → Claude Agent SDK → Claude (Pro subscription OR API)
- Eliminated HTTP server overhead
- Single-process architecture
### LLM Backend (llm_interface.py)
- Implemented Claude Agent SDK as DEFAULT mode
- Added three-mode architecture:
- agent-sdk (default) - Uses Pro subscription
- direct-api - Pay-per-token Anthropic API
- legacy-server - Backward compat with old setup
- Created async/sync bridge using anyio
- Preserved all existing functionality (17 tools, memory, scheduling)
### Dependencies (requirements.txt)
- Replaced: claude-code-sdk → claude-agent-sdk>=0.1.0
- Added: anyio>=4.0.0 for async bridging
- Removed: fastapi, uvicorn (no longer needed for default mode)
### New Files
- ajarbot.py - Unified launcher with pre-flight checks
- run.bat - Windows one-command launcher (auto-setup)
- pyproject.toml - Python package metadata
- MIGRATION.md - Upgrade guide from old setup
- AGENT_SDK_IMPLEMENTATION.md - Technical documentation
- QUICK_REFERENCE_AGENT_SDK.md - Quick reference card
- test_agent_sdk.py - Comprehensive test suite
### Updated Documentation
- CLAUDE_CODE_SETUP.md - Rewritten for Agent SDK
- README.md - Updated quick start for new default
- .env.example - Added AJARBOT_LLM_MODE configuration
### Deleted Files
- claude_code_server.py - Replaced by agent-sdk integration
- heartbeat.py - Superseded by scheduled_tasks.py
- pulse_brain.py - Unused in production
## Migration Path
Old setup:
1. Start FastAPI server: python claude_code_server.py
2. Start bot: python bot_runner.py
3. Set USE_CLAUDE_CODE_SERVER=true
New setup:
1. Run: run.bat (or python ajarbot.py)
- That's it! Single command.
## Benefits
✅ Zero API costs (uses Claude Pro subscription)
✅ Simplified deployment (no separate server)
✅ Single-command launch (run.bat)
✅ Faster response times (no HTTP overhead)
✅ All functionality preserved (17 tools, memory, adapters)
✅ Backward compatible (old env vars still work)
## Compatibility
- Python 3.10+ required
- Node.js required (for Claude Code CLI bundled with SDK)
- Windows 11 tested and optimized
- All existing tools, memory system, and adapters unchanged
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-15 10:03:11 -07:00
a8665d8c72
Refactor: Clean up obsolete files and organize codebase structure
...
This commit removes deprecated modules and reorganizes code into logical directories:
Deleted files (superseded by newer systems):
- claude_code_server.py (replaced by agent-sdk direct integration)
- heartbeat.py (superseded by scheduled_tasks.py)
- pulse_brain.py (unused in production)
- config/pulse_brain_config.py (obsolete config)
Created directory structure:
- examples/ (7 example files: example_*.py, demo_*.py)
- tests/ (5 test files: test_*.py)
Updated imports:
- agent.py: Removed heartbeat module and all enable_heartbeat logic
- bot_runner.py: Removed heartbeat parameter from Agent initialization
- llm_interface.py: Updated deprecated claude_code_server message
Preserved essential files:
- hooks.py (for future use)
- adapters/skill_integration.py (for future use)
- All Google integration tools (Gmail, Calendar, Contacts)
- GLM provider code (backward compatibility)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-15 09:57:39 -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
0eb5d2cab4
Add Google Contacts integration and fix critical Windows issues
...
- Add People API integration with contact management tools (create, list, get)
- Fix OAuth flow: replace deprecated OOB with localhost callback
- Fix Ctrl+C handling with proper signal handlers for graceful shutdown
- Fix UTF-8 encoding in scheduled_tasks.py for Windows compatibility
- Add users/ directory to gitignore to protect personal data
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-14 15:12:01 -07:00
19af20e700
Fix syntax error in OAuth callback handler reference
2026-02-14 11:42:37 -07:00
dc14baf426
Add Gmail and Google Calendar integration
...
Implements on-demand Google tools (not adapter) for email and calendar access via OAuth2.
Features:
- OAuth2 user consent flow with automatic token refresh
- 3 Gmail tools: send_email, read_emails, get_email
- 3 Calendar tools: read_calendar, create_calendar_event, search_calendar
- Lazy loading pattern for Google clients
- Secure token storage with file permissions
- Browser-based setup: python bot_runner.py --setup-google
Architecture:
- Tools-only approach (zero API calls when not in use)
- User-initiated actions only (no continuous polling)
- MIME message creation for emails with threading support
- HTML to text conversion for email parsing
- ISO 8601 timestamp handling for calendar events
Files added:
- google_tools/oauth_manager.py: OAuth2 flow and token management
- google_tools/gmail_client.py: Gmail API wrapper
- google_tools/calendar_client.py: Calendar API wrapper
- google_tools/utils.py: Email/MIME helpers
- config/scheduled_tasks.yaml: Example scheduled tasks config
Files modified:
- tools.py: Added 6 Google tool handlers with lazy initialization
- bot_runner.py: Added --setup-google command for OAuth authorization
- requirements.txt: Added Google API dependencies
- .gitignore: Added google_credentials.yaml and google_oauth_token.json
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-14 10:29:28 -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
ab3a5afd59
Documentation cleanup and consolidation
...
Removed redundant/outdated files:
- docs/HEARTBEAT_HOOKS.md (legacy, disabled by default)
- docs/QUICK_START_PULSE.md (merged into PULSE_BRAIN.md)
- docs/MONITORING_COMPARISON.md (merged into PULSE_BRAIN.md)
Consolidated monitoring docs:
- Merged 3 monitoring files into comprehensive PULSE_BRAIN.md
- Added Quick Start section to PULSE_BRAIN.md
- Added "Why Pulse & Brain?" comparison section
- Added deprecation notices for Heartbeat system
Updated README.md:
- Clarified Haiku is default model (12x cheaper)
- Added prompt caching info (90% savings on Sonnet)
- Removed duplicate setup instructions
- Linked to SETUP.md for detailed instructions
- Added model switching commands section
Simplified WINDOWS_QUICK_REFERENCE.md:
- Reduced from 224 lines to ~160 lines
- Removed redundant development/deployment sections
- Kept essential quick commands
- Added model switching commands
Updated docs/README.md navigation:
- Removed references to deleted files
- Added deprecation notice for Heartbeat
- Updated learning paths
- Cleaned up file organization section
Result:
- Removed 300+ lines of redundant documentation
- Consolidated 3 monitoring files into 1
- Improved accuracy and clarity
- Easier navigation and maintenance
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2026-02-13 21:06:15 -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