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>
This commit is contained in:
2026-02-13 19:06:28 -07:00
commit a99799bf3d
58 changed files with 11434 additions and 0 deletions

75
example_bot_usage.py Normal file
View File

@@ -0,0 +1,75 @@
"""
Example: Using the adapter system programmatically.
Demonstrates how to integrate adapters into your own code,
rather than using the bot_runner.py CLI.
"""
import asyncio
from adapters.base import AdapterConfig
from adapters.runtime import (
AdapterRuntime,
command_preprocessor,
markdown_postprocessor,
)
from adapters.slack.adapter import SlackAdapter
from adapters.telegram.adapter import TelegramAdapter
from agent import Agent
async def main() -> None:
# 1. Create the agent
agent = Agent(
provider="claude",
workspace_dir="./memory_workspace",
enable_heartbeat=False,
)
# 2. Create runtime
runtime = AdapterRuntime(agent)
# 3. Add preprocessors and postprocessors
runtime.add_preprocessor(command_preprocessor)
runtime.add_postprocessor(markdown_postprocessor)
# 4. Configure Slack adapter
slack_adapter = SlackAdapter(AdapterConfig(
platform="slack",
enabled=True,
credentials={
"bot_token": "xoxb-YOUR-TOKEN",
"app_token": "xapp-YOUR-TOKEN",
},
))
runtime.add_adapter(slack_adapter)
# 5. Configure Telegram adapter
telegram_adapter = TelegramAdapter(AdapterConfig(
platform="telegram",
enabled=True,
credentials={"bot_token": "YOUR-TELEGRAM-TOKEN"},
settings={"parse_mode": "Markdown"},
))
runtime.add_adapter(telegram_adapter)
# 6. Map users (optional)
runtime.map_user("slack:U12345", "alice")
runtime.map_user("telegram:123456789", "alice")
# 7. Start runtime
await runtime.start()
# 8. Keep running
try:
print("Bot is running! Press Ctrl+C to stop.")
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
print("\nStopping...")
finally:
await runtime.stop()
if __name__ == "__main__":
asyncio.run(main())