alvin-bot 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/.env.example +43 -0
  2. package/BACKLOG.md +223 -0
  3. package/CHANGELOG.md +63 -0
  4. package/CLAUDE.example.md +152 -0
  5. package/CODE_OF_CONDUCT.md +52 -0
  6. package/CONTRIBUTING.md +72 -0
  7. package/LICENSE +21 -0
  8. package/README.md +529 -0
  9. package/SECURITY.md +38 -0
  10. package/SOUL.example.md +60 -0
  11. package/TOOLS.example.md +42 -0
  12. package/alvin-bot.config.example.json +24 -0
  13. package/bin/cli.js +1088 -0
  14. package/dist/.metadata_never_index +0 -0
  15. package/dist/claude.js +102 -0
  16. package/dist/config.js +65 -0
  17. package/dist/engine.js +90 -0
  18. package/dist/find-claude-binary.js +98 -0
  19. package/dist/handlers/commands.js +1489 -0
  20. package/dist/handlers/document.js +187 -0
  21. package/dist/handlers/message.js +200 -0
  22. package/dist/handlers/photo.js +154 -0
  23. package/dist/handlers/platform-message.js +275 -0
  24. package/dist/handlers/video.js +237 -0
  25. package/dist/handlers/voice.js +148 -0
  26. package/dist/i18n.js +299 -0
  27. package/dist/index.js +442 -0
  28. package/dist/init-data-dir.js +81 -0
  29. package/dist/middleware/auth.js +215 -0
  30. package/dist/migrate.js +139 -0
  31. package/dist/paths.js +87 -0
  32. package/dist/platforms/discord.js +161 -0
  33. package/dist/platforms/index.js +130 -0
  34. package/dist/platforms/signal.js +205 -0
  35. package/dist/platforms/slack.js +318 -0
  36. package/dist/platforms/telegram.js +111 -0
  37. package/dist/platforms/types.js +8 -0
  38. package/dist/platforms/whatsapp.js +648 -0
  39. package/dist/providers/claude-sdk-provider.js +173 -0
  40. package/dist/providers/codex-cli-provider.js +121 -0
  41. package/dist/providers/index.js +7 -0
  42. package/dist/providers/openai-compatible.js +388 -0
  43. package/dist/providers/registry.js +209 -0
  44. package/dist/providers/tool-executor.js +450 -0
  45. package/dist/providers/types.js +205 -0
  46. package/dist/services/access.js +144 -0
  47. package/dist/services/asset-index.js +230 -0
  48. package/dist/services/browser-manager.js +161 -0
  49. package/dist/services/browser.js +121 -0
  50. package/dist/services/compaction.js +129 -0
  51. package/dist/services/cron.js +462 -0
  52. package/dist/services/custom-tools.js +317 -0
  53. package/dist/services/delivery-queue.js +154 -0
  54. package/dist/services/elevenlabs.js +58 -0
  55. package/dist/services/embeddings.js +386 -0
  56. package/dist/services/exec-guard.js +46 -0
  57. package/dist/services/fallback-order.js +151 -0
  58. package/dist/services/heartbeat.js +192 -0
  59. package/dist/services/hooks.js +44 -0
  60. package/dist/services/imagegen.js +72 -0
  61. package/dist/services/language-detect.js +144 -0
  62. package/dist/services/markdown.js +63 -0
  63. package/dist/services/mcp.js +252 -0
  64. package/dist/services/memory.js +133 -0
  65. package/dist/services/personality.js +227 -0
  66. package/dist/services/plugins.js +171 -0
  67. package/dist/services/reminders.js +97 -0
  68. package/dist/services/restart.js +48 -0
  69. package/dist/services/security-audit.js +66 -0
  70. package/dist/services/self-search.js +129 -0
  71. package/dist/services/session.js +93 -0
  72. package/dist/services/skills.js +287 -0
  73. package/dist/services/standing-orders.js +29 -0
  74. package/dist/services/subagents.js +142 -0
  75. package/dist/services/sudo.js +243 -0
  76. package/dist/services/telegram.js +113 -0
  77. package/dist/services/tool-discovery.js +214 -0
  78. package/dist/services/usage-tracker.js +137 -0
  79. package/dist/services/users.js +199 -0
  80. package/dist/services/voice.js +95 -0
  81. package/dist/tui/index.js +507 -0
  82. package/dist/web/canvas.js +30 -0
  83. package/dist/web/doctor-api.js +606 -0
  84. package/dist/web/openai-compat.js +252 -0
  85. package/dist/web/server.js +1351 -0
  86. package/dist/web/setup-api.js +1078 -0
  87. package/docs/mcp.example.json +16 -0
  88. package/docs/screenshots/00-Login.png +0 -0
  89. package/docs/screenshots/01-Chat-Dark-Conversation.png +0 -0
  90. package/docs/screenshots/02-Chat.png +0 -0
  91. package/docs/screenshots/03-Dashboard-Overview.png +0 -0
  92. package/docs/screenshots/04-AI-Models-and-Providers.png +0 -0
  93. package/docs/screenshots/05-Personality-Editor.png +0 -0
  94. package/docs/screenshots/06-Memory-Manager.png +0 -0
  95. package/docs/screenshots/07-Active-Sessions.png +0 -0
  96. package/docs/screenshots/08-File-Browser.png +0 -0
  97. package/docs/screenshots/09-Scheduled-Jobs.png +0 -0
  98. package/docs/screenshots/10-Custom-Tools.png +0 -0
  99. package/docs/screenshots/11-Plugins-and-MCP.png +0 -0
  100. package/docs/screenshots/12-Messaging-Platforms.png +0 -0
  101. package/docs/screenshots/12.1-Messaging-Platforms-WhatsApp-Groups-List.png +0 -0
  102. package/docs/screenshots/12.2-Messaging-Platforms-WA-Group-Details.png +0 -0
  103. package/docs/screenshots/13-User-Management.png +0 -0
  104. package/docs/screenshots/14-Web-Terminal.png +0 -0
  105. package/docs/screenshots/15-Maintenance-and-Health.png +0 -0
  106. package/docs/screenshots/16-Settings-and-Env.png +0 -0
  107. package/docs/screenshots/TG-commands.png +0 -0
  108. package/docs/screenshots/TG.png +0 -0
  109. package/docs/screenshots/_Mac-Installer.png +0 -0
  110. package/docs/tools.example.json +33 -0
  111. package/install.sh +165 -0
  112. package/package.json +190 -0
  113. package/plugins/calendar/index.js +270 -0
  114. package/plugins/email/index.js +231 -0
  115. package/plugins/finance/index.js +254 -0
  116. package/plugins/notes/index.js +227 -0
  117. package/plugins/smarthome/index.js +230 -0
  118. package/plugins/weather/index.js +122 -0
  119. package/skills/apple-notes/SKILL.md +31 -0
  120. package/skills/browse/SKILL.md +136 -0
  121. package/skills/code-project/SKILL.md +43 -0
  122. package/skills/data-analysis/SKILL.md +39 -0
  123. package/skills/document-creation/SKILL.md +48 -0
  124. package/skills/email-summary/SKILL.md +46 -0
  125. package/skills/github/SKILL.md +42 -0
  126. package/skills/summarize/SKILL.md +28 -0
  127. package/skills/system-admin/SKILL.md +39 -0
  128. package/skills/weather/SKILL.md +34 -0
  129. package/skills/web-research/SKILL.md +35 -0
  130. package/web/public/canvas.html +52 -0
  131. package/web/public/css/style.css +555 -0
  132. package/web/public/index.html +189 -0
  133. package/web/public/js/app.js +3102 -0
  134. package/web/public/js/i18n.js +1048 -0
  135. package/web/public/js/icons.js +104 -0
  136. package/web/public/login.html +48 -0
package/.env.example ADDED
@@ -0,0 +1,43 @@
1
+ # === Telegram (required) ===
2
+ BOT_TOKEN=your-telegram-bot-token
3
+ ALLOWED_USERS=your-telegram-user-id
4
+
5
+ # === AI Provider (choose one) ===
6
+ # Options: groq | nvidia-llama-3.3-70b | gemini-2.5-flash | gpt-4o | openrouter | claude-sdk | ollama
7
+ # Free providers: groq, nvidia-llama-3.3-70b, gemini-2.5-flash
8
+ # Claude SDK: Premium — full agent with tool use, needs `claude login` (Max subscription)
9
+ PRIMARY_PROVIDER=groq
10
+
11
+ # Fallback chain (comma-separated, tried in order if primary fails)
12
+ # FALLBACK_PROVIDERS=nvidia-llama-3.3-70b,gemini-2.5-flash
13
+
14
+ # === API Keys (set the one for your chosen provider) ===
15
+ # Groq — free at console.groq.com (also enables voice transcription)
16
+ GROQ_API_KEY=
17
+ # Google Gemini — free tier at aistudio.google.com
18
+ GOOGLE_API_KEY=
19
+ # NVIDIA NIM — free tier at build.nvidia.com
20
+ NVIDIA_API_KEY=
21
+ # OpenAI — paid, platform.openai.com
22
+ OPENAI_API_KEY=
23
+ # Anthropic API — direct Claude access (Opus, Sonnet, Haiku)
24
+ ANTHROPIC_API_KEY=
25
+ # OpenRouter — openrouter.ai (100+ models)
26
+ OPENROUTER_API_KEY=
27
+
28
+ # === Agent ===
29
+ WORKING_DIR=~
30
+ MAX_BUDGET_USD=5.0
31
+
32
+ # === Web UI ===
33
+ WEB_PORT=3100
34
+ # WEB_PASSWORD=your-password
35
+
36
+ # === Optional Platforms ===
37
+ # WHATSAPP_ENABLED=true
38
+ # DISCORD_TOKEN=your-discord-bot-token
39
+ # SIGNAL_API_URL=http://localhost:8080
40
+ # SIGNAL_NUMBER=+491234567890
41
+
42
+ # === Custom Chrome (for WhatsApp, if not auto-detected) ===
43
+ # CHROME_PATH=/usr/bin/google-chrome
package/BACKLOG.md ADDED
@@ -0,0 +1,223 @@
1
+ # BACKLOG.md — Alvin Bot Entwicklung
2
+
3
+ > Interne Projektdatei. Wird NICHT ins Git gepusht (.gitignore).
4
+ > Letzte Aktualisierung: 2026-03-03
5
+
6
+ ---
7
+
8
+ ## Legende
9
+
10
+ | Prio | Bedeutung |
11
+ |------|-----------|
12
+ | P0 | Sicherheitslücke / Kritisch |
13
+ | P1 | Wichtig für Stabilität & Code-Qualität |
14
+ | P2 | Feature / Developer Experience |
15
+ | P3 | Nice-to-Have / Zukunft |
16
+
17
+ ---
18
+
19
+ ## P0 — Security
20
+
21
+ ### [ ] WebSocket Auth fehlt
22
+ - Aktuell kann jeder, der `localhost:3100` erreicht, über WebSocket chatten
23
+ - Lösung: Auth-Token als Query-Param beim WS-Connect (`ws://localhost:3100?token=xxx`)
24
+ - Token aus WEB_PASSWORD ableiten oder Session-Cookie validieren
25
+
26
+ ### [ ] Tool Executor: Unzureichendes Sandboxing
27
+ - `run_shell` Blocklist ist minimal (nur `rm -rf /`, `mkfs`, `dd`)
28
+ - `rm -rf ~/Projects/` würde durchgehen
29
+ - `write_file` kann `.env` und Systemdateien überschreiben
30
+ - `python_execute` führt beliebigen Code ohne Sandbox aus
31
+ - Lösung: Working-Directory-Sandboxing, Blocklist für sensitive Pfade (.env, /etc/, ~/.ssh/)
32
+
33
+ ### [ ] Web UI: Kein HTTPS
34
+ - HTTP-only → Passwörter und Chat im Klartext
35
+ - Lösung: Optionaler HTTPS-Modus mit self-signed Cert, oder Warnung wenn WEB_PASSWORD gesetzt aber kein HTTPS
36
+
37
+ ### [ ] Sudo-Passwort in CLI-Argument (macOS)
38
+ - `security add-generic-password` bekommt das Passwort als CLI-Arg → sichtbar in `ps aux`
39
+ - Lösung: Passwort über stdin pipen statt als Argument
40
+
41
+ ---
42
+
43
+ ## P1 — Code-Qualität & Stabilität
44
+
45
+ ### [ ] commands.ts aufteilen (74KB Monolith!)
46
+ - Aktuell: ALLE Telegram-Commands in einer Datei (~1700 Zeilen)
47
+ - Vorschlag: `src/handlers/commands/` Ordner mit je einer Datei pro Bereich:
48
+ - `chat.ts` (help, start, new, cancel)
49
+ - `model.ts` (model, effort, fallback, voice)
50
+ - `tools.ts` (web, imagine, browse, remind)
51
+ - `memory.ts` (recall, remember, reindex, export, memory)
52
+ - `admin.ts` (status, dir, groups, security, users, setup, sudo)
53
+ - `cron.ts` (cron)
54
+ - `extensions.ts` (plugins, mcp, tools, webui)
55
+ - `index.ts` (registriert alle)
56
+
57
+ ### [ ] web/server.ts aufteilen (57KB Monolith!)
58
+ - Aktuell: REST-API, WebSocket, Static-Serving, Auth — alles in einer Datei
59
+ - Vorschlag: Router-Module nach Bereich (api/models.ts, api/memory.ts, api/sessions.ts, etc.)
60
+
61
+ ### [ ] web/public/js/app.js refactoren (3079 Zeilen)
62
+ - Vanilla JS ohne Struktur → schwer wartbar
63
+ - Option A: Alpine.js oder Petite-Vue für reaktive Bindings (minimaler Overhead)
64
+ - Option B: Web Components für Isolation der Sektionen
65
+ - Option C: Zumindest in Module aufteilen (ES Module Imports)
66
+
67
+ ### [ ] Config-Validation mit Zod
68
+ - Aktuell: Kein Validation → `ALLOWED_USERS=""` ergibt `[NaN]`
69
+ - `BOT_TOKEN` fehlt → kryptischer Fehler statt klare Meldung
70
+ - Lösung: `src/config.ts` mit Zod-Schema, Startup-Validation, klare Fehlermeldungen
71
+
72
+ ### [ ] MAX_BUDGET_USD wird nie enforced
73
+ - Variable wird gelesen aber nirgendwo geprüft
74
+ - Lösung: In `queryWithFallback()` vor jedem API-Call prüfen, bei Überschreitung blockieren
75
+
76
+ ### [ ] Tests einführen
77
+ - Aktuell: Null Tests im gesamten Projekt
78
+ - Priorität für Tests:
79
+ 1. Provider-Registry (Fallback-Chain Logik)
80
+ 2. Cron-Parser (Edge Cases bei Zeitberechnung)
81
+ 3. Tool-Executor (Security-Blocklist)
82
+ 4. Config-Validation
83
+ 5. Markdown-Sanitizer
84
+ - Framework: Vitest (schnell, ESM-nativ, kein Babel nötig)
85
+
86
+ ### [ ] Watch-Mode für Development
87
+ - Aktuell: `npm run dev` = `tsx src/index.ts` (einmal starten, manuell restarten)
88
+ - Lösung: `tsx watch src/index.ts` oder `nodemon` mit TS-Loader
89
+
90
+ ---
91
+
92
+ ## P2 — Features & Verbesserungen
93
+
94
+ ### [ ] Session-Persistence (optional)
95
+ - Sessions überleben keinen Restart — Chat-History weg nach `pm2 restart`
96
+ - Option A: SQLite-File für Sessions (leichtgewichtig, kein DB-Server)
97
+ - Option B: JSON-Files pro User in `data/sessions/`
98
+ - Opt-in via `SESSION_PERSIST=true` in .env
99
+
100
+ ### [ ] Session-Timeout / Cleanup
101
+ - Sessions akkumulieren sich unbegrenzt im Speicher
102
+ - Lösung: Inaktive Sessions nach 24h aus dem RAM entfernen (History bleibt in Memory-Logs)
103
+
104
+ ### [ ] Memory-Rotation
105
+ - Daily Logs (`~/.alvin-bot/memory/YYYY-MM-DD.md`) wachsen unbegrenzt
106
+ - Lösung: Nach 30 Tagen alte Logs in `~/.alvin-bot/memory/archive/` verschieben oder komprimieren
107
+ - Optional: Automatische Zusammenfassung alter Logs via AI
108
+
109
+ ### [ ] Embedding-Provider erweitern
110
+ - Aktuell: Nur Google `text-embedding-004`
111
+ - Alternativen: OpenAI Embeddings, lokale Ollama-Embeddings, Cohere
112
+ - Fallback-Chain wie bei Chat-Providern
113
+
114
+ ### [ ] Plugin-Tools für alle Provider
115
+ - Plugin-Tools funktionieren aktuell nur über Telegram-Commands
116
+ - Sie sollten auch als Agent-Tools in `OpenAICompatibleProvider` injiziert werden
117
+ - Damit können alle LLMs Plugin-Funktionen nutzen (nicht nur Claude SDK)
118
+
119
+ ### [ ] MCP HTTP/SSE Transport fertigstellen
120
+ - Aktuell nur stdio-Transport implementiert
121
+ - HTTP/SSE ist stub: `"HTTP/SSE transport not yet supported"`
122
+ - Wichtig für Remote-MCP-Server (z.B. Cloudflare Workers)
123
+
124
+ ### [ ] Discord: Richtige Integration
125
+ - `discord.js` fehlt in package.json (muss manuell installiert werden)
126
+ - Kein Support für Discord Slash-Commands
127
+ - Kein Rate-Limiting
128
+ - Lösung: Als optional peer dependency, Slash-Command Registration
129
+
130
+ ### [ ] WhatsApp Media Cleanup
131
+ - `data/wa-media/` sammelt empfangene Medien-Dateien und löscht sie nie
132
+ - Lösung: Cron-Job oder TTL-basiertes Cleanup (z.B. nach 7 Tagen löschen)
133
+
134
+ ### [ ] Heartbeat-Kosten reduzieren
135
+ - Heartbeat macht echte API-Calls ("Hi") an alle Provider → erzeugt Kosten
136
+ - Lösung: Für Provider mit bekanntem Status-Endpoint nur diesen pingen
137
+ - Für kostenlose Provider (Groq, NVIDIA): OK so lassen
138
+
139
+ ### [ ] Kosten-Tracking verbessern
140
+ - `estimateCost()` schätzt nur Output-Tokens, keine Input-Tokens
141
+ - Preise teilweise veraltet
142
+ - Lösung: Aktuelle Preistabelle pflegen, Input+Output getrennt tracken
143
+
144
+ ### [ ] Cron-Parser erweitern
145
+ - Kein Support für `@daily`, `@hourly`, `@reboot`, `@weekly`
146
+ - Kein `L` (last day of month), kein `W` (nearest weekday)
147
+ - Lösung: Aliases in `parseSchedule()` hinzufügen
148
+
149
+ ---
150
+
151
+ ## P3 — Nice-to-Have / Zukunft
152
+
153
+ ### [ ] Multi-Language über DE/EN hinaus
154
+ - i18n-System unterstützt nur `de | en`
155
+ - Erweiterbar auf FR, ES, TR, RU etc.
156
+ - Web UI hat bereits ~500 Keys → Übersetzung nötig
157
+
158
+ ### [ ] Skill-Matching mit Embeddings
159
+ - Aktuell: Simples `text.includes(trigger)` — sehr unzuverlässig
160
+ - Besser: Embedding-basiertes Similarity-Matching für Skill-Trigger
161
+ - Oder: LLM-basierte Skill-Auswahl ("Welcher Skill passt zu dieser Nachricht?")
162
+
163
+ ### [ ] Plugin Hot-Reload über Web UI
164
+ - Aktuell: Plugin-Änderungen erfordern Bot-Restart
165
+ - Lösung: "Reload Plugin" Button in Web UI → `pluginManager.reload(name)`
166
+
167
+ ### [ ] Conversation-Export als PDF
168
+ - `/export` gibt aktuell Markdown → könnte auch als formatiertes PDF exportieren
169
+ - Tools vorhanden: `pandoc`, `wkhtmltopdf`
170
+
171
+ ### [ ] Streaming für OpenAI-Compatible + Tool-Use
172
+ - Aktuell schließen sich Streaming und Tool-Use gegenseitig aus
173
+ - Lösung: Tool-Calls aus Stream-Chunks akkumulieren (wie OpenAI es unterstützt)
174
+
175
+ ### [ ] Windows .exe Build
176
+ - Braucht Windows-Umgebung oder Cross-Compilation
177
+ - electron-builder unterstützt es, aber nicht von macOS aus testbar
178
+
179
+ ### [ ] Linux .AppImage Build
180
+ - Braucht Linux-Umgebung oder CI (GitHub Actions)
181
+ - Vorschlag: GitHub Actions Workflow für Multi-Platform Builds
182
+
183
+ ### [ ] CI/CD Pipeline (GitHub Actions)
184
+ - Build-Verification auf Push
185
+ - Lint (ESLint) + Type-Check + Tests
186
+ - Auto-Publish zu npm bei Tag
187
+ - Multi-Platform Electron Builds (macOS, Windows, Linux)
188
+
189
+ ### [ ] Rate-Limiting für API-Endpoints
190
+ - Web UI API-Endpoints haben kein Rate-Limiting
191
+ - Lösung: Simpler in-memory Counter pro IP (kein Redis nötig)
192
+
193
+ ### [ ] Electron: asar wieder aktivieren
194
+ - `asar: false` wegen electron-builder 26.x Bug
195
+ - Bei neuerer Version testen ob es gefixt ist → Source-Code wäre dann nicht mehr exposed
196
+
197
+ ### [ ] Provider-Config via Web UI erweitern
198
+ - Neue Provider-Presets (z.B. Anthropic API direkt, DeepSeek, Mistral) über Web UI registrieren
199
+ - Aktuell nur über .env oder Code möglich
200
+
201
+ ---
202
+
203
+ ## Erledigte Items
204
+
205
+ ### [x] i18n English-First (v3.3.0)
206
+ - Alle Telegram-Commands, TUI, Services, Plugins auf Englisch
207
+ - Web UI bleibt bilingual (DE/EN Toggle)
208
+ - TUI nur noch mit explizitem --lang de auf Deutsch
209
+
210
+ ### [x] /webui Telegram-Befehl (v3.3.0)
211
+ - Sendet Web UI URL als Text (kein Inline-Button, da Telegram localhost-URLs blockiert)
212
+
213
+ ### [x] Smart Port Selection (v3.3.0)
214
+ - Web UI findet automatisch freien Port wenn 3100 belegt
215
+
216
+ ### [x] Multi-Platform Support (Phase 7)
217
+ - Telegram, WhatsApp, Discord, Signal
218
+
219
+ ### [x] Universal Tool Use (Phase 8)
220
+ - Alle Provider können Shell, File I/O, Web Fetch, Python ausführen
221
+
222
+ ### [x] Skill System (Phase 9)
223
+ - SKILL.md-basierte Domain-Expertise
package/CHANGELOG.md ADDED
@@ -0,0 +1,63 @@
1
+ # Changelog
2
+
3
+ All notable changes to Alvin Bot are documented here.
4
+
5
+ ## [2.2.0] — 2026-02-24
6
+
7
+ ### 🔐 Security
8
+ - **Group approval system** — New groups must be approved by admin before bot responds
9
+ - `/groups` — Manage all groups with approve/block inline buttons
10
+ - `/security` — Toggle forwarded messages, auto-approve settings
11
+ - Blocked groups completely ignored (zero response)
12
+ - `data/access.json` persists approvals (gitignored)
13
+
14
+ ### 🤖 Multi-Model
15
+ - **Provider abstraction layer** with unified interface
16
+ - **Fallback chain**: Claude SDK → Kimi K2.5 → Llama 3.3 70B (all via NVIDIA NIM)
17
+ - `/model` — Switch models with inline keyboard buttons
18
+ - **Cost tracking per provider** in `/status`
19
+ - **Fallback notifications** — User sees ⚡ when provider switches
20
+
21
+ ### 🧠 Memory
22
+ - **SOUL.md** — Customizable personality file, hot-reloadable via `/reload`
23
+ - **Memory service** — Auto-writes session summaries to daily logs on `/new`
24
+ - Non-SDK providers get memory context injected into system prompt
25
+ - `/memory` — View memory stats
26
+
27
+ ### 🎨 Rich Interactions
28
+ - **Emoji reactions**: 🤔 thinking, 🎧 listening, 👀 looking, 👍 done, 👎 error
29
+ - **Inline keyboards** for `/model`, `/effort`, `/lang`
30
+ - **Document handling** — PDFs, Word, Excel, code files, CSV, JSON (30+ types)
31
+ - **Image generation** — `/imagine` via Gemini API
32
+ - **Reply threading** — Bot responses are replies to the original message
33
+ - **Reply context** — Quoted messages included as context
34
+ - **Forward handling** — Forwarded messages analyzed with sender context
35
+ - **Group chat** — Responds to @mentions and replies only
36
+
37
+ ### 📦 Tools & Commands
38
+ - `/help` — Complete command overview
39
+ - `/web` — DuckDuckGo instant search
40
+ - `/remind` — Set, list, cancel reminders
41
+ - `/export` — Download conversation as markdown
42
+ - `/system` — System info (OS, CPU, RAM, Node)
43
+ - `/lang` — Switch DE/EN with inline buttons
44
+ - `/ping` — Health check with latency
45
+ - `/status` — Enhanced with provider stats, memory, uptime
46
+
47
+ ### 🛠 Infrastructure
48
+ - **Dockerfile** + `docker-compose.yml` for containerized deployment
49
+ - **CLI**: `npx alvin-bot setup` (wizard), `doctor`, `update`, `version`
50
+ - **Markdown sanitizer** — Fixes unbalanced markers for Telegram
51
+ - **Graceful shutdown** with 5s grace period
52
+ - **Error resilience** — Uncaught exceptions logged, not crashed
53
+ - `alvin-bot.config.example.json` for all configurable options
54
+
55
+ ## [2.0.0] — 2026-02-24
56
+
57
+ ### Initial Release
58
+ - grammY + Claude Agent SDK integration
59
+ - Streaming responses with live message editing
60
+ - Voice (Groq Whisper STT + Edge TTS)
61
+ - Photo analysis (Claude vision)
62
+ - Session management (in-memory)
63
+ - PM2 ecosystem config
@@ -0,0 +1,152 @@
1
+ # CLAUDE.md — Agent Instructions
2
+
3
+ > Loaded automatically on every `query()` call via `settingSources: ["project"]`.
4
+ > Together with the system prompt, this file forms the agent's core knowledge.
5
+ > Customize this file to shape how your bot thinks and behaves.
6
+
7
+ ## Personality & Behavior
8
+
9
+ You are an autonomous AI agent. Not just a chatbot — an assistant that thinks ahead and takes action.
10
+
11
+ **Core Principles:**
12
+ - **Be genuinely helpful.** No "Great question!" or "I'd be happy to help!" — just help.
13
+ - **Have opinions.** You may disagree, prefer things, find stuff interesting or boring.
14
+ - **Be resourceful.** Try to figure it out yourself — read the file, check context, search. Only then ask.
15
+ - **Verify your work.** Don't just do something and assume it worked — actively check.
16
+ - **Earn trust through competence.** Your user gave you access. Don't break things.
17
+
18
+ **Boundaries:**
19
+ - Private things stay private
20
+ - When in doubt: ask before acting externally (sending emails, deleting files, posting)
21
+ - Don't send half-finished answers
22
+ - `trash` > `rm` (recoverable > gone forever)
23
+
24
+ ## Resource Usage: Check First, Then Act
25
+
26
+ **CRITICAL — always follow this:**
27
+
28
+ Before saying "I would need X" or "I don't have access to Y":
29
+
30
+ 1. **Check if it's already there:** `which <tool>`, `command -v <tool>`
31
+ 2. **Check the tool list in the system prompt** — it shows what's available
32
+ 3. **Use the best available tool directly** — don't ask, just do it
33
+ 4. **ONLY if nothing exists:** suggest installation + alternatives
34
+
35
+ **NEVER say "I can't do X" when a tool for it exists.**
36
+
37
+ ## Complex Tasks — Step by Step
38
+
39
+ For complex, multi-step tasks:
40
+
41
+ 1. **Make a plan** — What needs to happen? Which tools do I need?
42
+ 2. **Identify tools** — What's installed? What might need installation?
43
+ 3. **Execute sequentially** — One step at a time, verify each result
44
+ 4. **Save intermediate results** — Write to files, don't just keep in memory
45
+ 5. **Verify the result** — Does it work? Does it look right?
46
+
47
+ ## Memory System
48
+
49
+ You wake up fresh every session. These files are your memory.
50
+
51
+ ### Reading
52
+
53
+ - **New session** (no sessionId / after `/new`):
54
+ Read `~/.alvin-bot/memory/MEMORY.md` for long-term context
55
+ Read `~/.alvin-bot/memory/YYYY-MM-DD.md` (today + yesterday) if available
56
+
57
+ - **Ongoing session:** Context is already in the conversation
58
+
59
+ ### Writing
60
+
61
+ **`~/.alvin-bot/memory/YYYY-MM-DD.md`** — Daily session logs:
62
+ - After complex tasks: write a summary
63
+ - On important decisions or insights
64
+ - On topic changes: short checkpoint
65
+ - Format: Append (don't overwrite), with timestamp
66
+
67
+ **`~/.alvin-bot/memory/MEMORY.md`** — Curated long-term memory:
68
+ - "ALWAYS when X, then Y" rules
69
+ - User preferences
70
+ - Project decisions
71
+ - Important workflows
72
+
73
+ ### Checkpoints (Compacting Protection)
74
+
75
+ Your context window is limited. **Checkpoints protect against data loss.**
76
+
77
+ **When to write checkpoints (MANDATORY):**
78
+ - After completing a complex task
79
+ - When you see the hint `[CHECKPOINT]` in the prompt
80
+ - Before topic changes
81
+ - When the user makes an important decision
82
+
83
+ ### After Compacting — Restore Context
84
+
85
+ **If the conversation history seems thin** (user refers to something you can't see):
86
+ 1. Read `~/.alvin-bot/memory/YYYY-MM-DD.md` (today + yesterday)
87
+ 2. Read `~/.alvin-bot/memory/MEMORY.md`
88
+ 3. Only THEN respond
89
+
90
+ ## Cron Jobs — Scheduled Tasks
91
+
92
+ You have access to a cron system. When the user wants recurring tasks, create a cron job.
93
+
94
+ ```bash
95
+ node scripts/cron-manage.js add \
96
+ --name "Daily reminder" \
97
+ --type reminder \
98
+ --schedule "0 9 * * *" \
99
+ --prompt "Good morning! Here's your daily briefing." \
100
+ --chatId YOUR_CHAT_ID
101
+
102
+ node scripts/cron-manage.js list
103
+ node scripts/cron-manage.js delete --id <job-id>
104
+ node scripts/cron-manage.js toggle --id <job-id>
105
+ ```
106
+
107
+ **Job types:** `reminder` | `shell` | `http` | `message` | `ai-query`
108
+
109
+ ### Schedule Formats
110
+ - **Interval:** `30s`, `5m`, `1h`, `6h`, `1d`
111
+ - **Cron:** `MIN HOUR DAY MONTH WEEKDAY` (0=Sunday)
112
+
113
+ ## API Access for Extended Features
114
+
115
+ ### Image Generation
116
+ If `GOOGLE_API_KEY` is set, you can generate images via Gemini API.
117
+
118
+ ### Text-to-Speech
119
+ ```bash
120
+ # Edge TTS (free, no API key needed)
121
+ npx edge-tts --text "Hello World" --voice en-US-GuyNeural --write-media /tmp/output.mp3
122
+ ```
123
+
124
+ ### Web Search
125
+ ```bash
126
+ # web_search and web_fetch are available as built-in tools
127
+ # Or use: curl + DuckDuckGo / Brave Search / Google
128
+ ```
129
+
130
+ ## Project Context
131
+
132
+ This project is the bot itself. Source code lives in `src/`.
133
+
134
+ **NEVER modify bot code (src/, package.json, .env, ecosystem.config.cjs) without explicit instruction.**
135
+
136
+ The working directory (`cwd`) changes based on the `/dir` command — it's not always this project.
137
+
138
+ ## Architecture
139
+
140
+ - **Runtime:** Node.js >= 18, TypeScript, ESM (`"type": "module"`)
141
+ - **Telegram:** grammy
142
+ - **AI:** Multi-Provider (Claude SDK, Groq, Gemini, GPT-4o, NVIDIA NIM, Ollama, OpenRouter)
143
+ - **Web UI:** Express (auth via `WEB_PASSWORD` env var)
144
+ - **TUI:** `alvin-bot tui` — Terminal chat via WebSocket
145
+ - **Cron:** In-app scheduler (30s loop), jobs in `~/.alvin-bot/cron-jobs.json`
146
+ - **PM2:** Process management, config in `ecosystem.config.cjs`
147
+
148
+ ## Security Rules
149
+
150
+ - **No personal data in code:** Telegram IDs, paths, tokens → only in `.env`
151
+ - **`.gitignore` protects:** `.env`, `data/` (personal data lives in `~/.alvin-bot/`, outside the repo)
152
+ - **Never commit secrets** — always check `git diff --cached` before committing
@@ -0,0 +1,52 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to a positive environment:
15
+
16
+ * Using welcoming and inclusive language
17
+ * Being respectful of differing viewpoints and experiences
18
+ * Gracefully accepting constructive criticism
19
+ * Focusing on what is best for the community
20
+ * Showing empathy towards other community members
21
+
22
+ Examples of unacceptable behavior:
23
+
24
+ * The use of sexualized language or imagery and unwelcome sexual attention
25
+ * Trolling, insulting/derogatory comments, and personal or political attacks
26
+ * Public or private harassment
27
+ * Publishing others' private information without explicit permission
28
+ * Other conduct which could reasonably be considered inappropriate
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of
33
+ acceptable behavior and will take appropriate and fair corrective action in
34
+ response to any behavior that they deem inappropriate, threatening, offensive,
35
+ or harmful.
36
+
37
+ ## Scope
38
+
39
+ This Code of Conduct applies within all community spaces, and also applies when
40
+ an individual is officially representing the community in public spaces.
41
+
42
+ ## Enforcement
43
+
44
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
45
+ reported to the project maintainers via [GitHub Issues](https://github.com/alvbln/Alvin-Bot/issues). All complaints
46
+ will be reviewed and investigated promptly and fairly.
47
+
48
+ ## Attribution
49
+
50
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
51
+ version 2.1, available at
52
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
@@ -0,0 +1,72 @@
1
+ # Contributing to Alvin Bot
2
+
3
+ Thanks for your interest in contributing! Here's how you can help.
4
+
5
+ ## Getting Started
6
+
7
+ 1. **Fork** the repository
8
+ 2. **Clone** your fork: `git clone https://github.com/YOUR_USERNAME/alvin-bot.git`
9
+ 3. **Install** dependencies: `npm install`
10
+ 4. **Create** a branch: `git checkout -b feature/your-feature`
11
+
12
+ ## Development
13
+
14
+ ```bash
15
+ # Build
16
+ npm run build
17
+
18
+ # Run in development
19
+ npm run dev
20
+
21
+ # Run tests
22
+ npm test
23
+ ```
24
+
25
+ ## Project Structure
26
+
27
+ - `src/` — Core bot source code
28
+ - `src/handlers/` — Message and command handlers
29
+ - `src/providers/` — AI provider integrations
30
+ - `src/platforms/` — Messaging platform adapters
31
+ - `src/services/` — Background services (cron, memory, etc.)
32
+ - `web/` — Dashboard web interface
33
+ - `electron/` — Desktop app wrapper
34
+ - `plugins/` — Plugin system
35
+
36
+ ## Guidelines
37
+
38
+ - **TypeScript** — All source files should be TypeScript
39
+ - **Conventional Commits** — Use `feat:`, `fix:`, `docs:`, `chore:` prefixes
40
+ - **No breaking changes** without discussion in an issue first
41
+ - **Tests** — Add tests for new features when applicable
42
+ - **Lint** — Run `npm run lint` before submitting
43
+
44
+ ## Pull Requests
45
+
46
+ 1. Update documentation if you change behavior
47
+ 2. Keep PRs focused — one feature/fix per PR
48
+ 3. Write a clear description of what changed and why
49
+ 4. Reference any related issues
50
+
51
+ ## Reporting Bugs
52
+
53
+ Open an [issue](https://github.com/alvbln/alvin-bot/issues) with:
54
+ - Steps to reproduce
55
+ - Expected vs actual behavior
56
+ - Node.js version and OS
57
+ - Relevant logs (redact any API keys!)
58
+
59
+ ## Feature Requests
60
+
61
+ Open an issue with the `enhancement` label describing:
62
+ - The use case
63
+ - Proposed solution
64
+ - Alternatives considered
65
+
66
+ ## Code of Conduct
67
+
68
+ This project follows the [Contributor Covenant](CODE_OF_CONDUCT.md). By participating, you agree to uphold this code.
69
+
70
+ ## License
71
+
72
+ By contributing, you agree that your contributions will be licensed under the [MIT License](LICENSE).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The Alvin-Bot Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.