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
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Telegram Platform Adapter
3
+ *
4
+ * Wraps grammy Bot into the PlatformAdapter interface.
5
+ * This is the reference implementation — all other adapters follow this pattern.
6
+ */
7
+ import { Bot, InputFile } from "grammy";
8
+ import { config } from "../config.js";
9
+ import { authMiddleware } from "../middleware/auth.js";
10
+ let _telegramState = {
11
+ status: "disconnected",
12
+ botName: null,
13
+ botUsername: null,
14
+ connectedAt: null,
15
+ error: null,
16
+ };
17
+ export function getTelegramState() {
18
+ return { ..._telegramState };
19
+ }
20
+ /** Called from index.ts when grammy bot connects (since we don't use TelegramAdapter yet) */
21
+ export function setTelegramConnected(botName, botUsername) {
22
+ _telegramState.status = "connected";
23
+ _telegramState.botName = botName;
24
+ _telegramState.botUsername = botUsername;
25
+ _telegramState.connectedAt = Date.now();
26
+ }
27
+ export class TelegramAdapter {
28
+ platform = "telegram";
29
+ bot;
30
+ handler = null;
31
+ constructor() {
32
+ this.bot = new Bot(config.botToken);
33
+ }
34
+ /** Get the underlying grammy Bot instance (for command registration). */
35
+ getBot() {
36
+ return this.bot;
37
+ }
38
+ async start() {
39
+ // Auth middleware
40
+ this.bot.use(authMiddleware);
41
+ // Route raw messages to the platform handler
42
+ this.bot.on("message:text", async (ctx) => {
43
+ if (!this.handler)
44
+ return;
45
+ if (ctx.message?.text?.startsWith("/"))
46
+ return; // Commands handled separately
47
+ const msg = {
48
+ platform: "telegram",
49
+ messageId: String(ctx.message?.message_id),
50
+ chatId: String(ctx.chat?.id),
51
+ userId: String(ctx.from?.id),
52
+ userName: ctx.from?.first_name || "Unknown",
53
+ userHandle: ctx.from?.username,
54
+ text: ctx.message?.text || "",
55
+ isGroup: ctx.chat?.type !== "private",
56
+ isMention: false, // Handled by group middleware
57
+ isReplyToBot: false,
58
+ replyToText: ctx.message?.reply_to_message?.text,
59
+ };
60
+ await this.handler(msg);
61
+ });
62
+ _telegramState.status = "connecting";
63
+ await this.bot.start({
64
+ onStart: () => {
65
+ const me = this.bot.botInfo;
66
+ _telegramState.status = "connected";
67
+ _telegramState.botName = me.first_name || null;
68
+ _telegramState.botUsername = me.username || null;
69
+ _telegramState.connectedAt = Date.now();
70
+ console.log(`📱 Telegram adapter started (@${me.username})`);
71
+ },
72
+ });
73
+ }
74
+ async stop() {
75
+ this.bot.stop();
76
+ }
77
+ async sendText(chatId, text, options) {
78
+ const parseMode = options?.parseMode === "html" ? "HTML"
79
+ : options?.parseMode === "markdown" ? "Markdown"
80
+ : undefined;
81
+ await this.bot.api.sendMessage(Number(chatId), text, {
82
+ parse_mode: parseMode,
83
+ reply_parameters: options?.replyTo ? { message_id: Number(options.replyTo) } : undefined,
84
+ });
85
+ }
86
+ async sendPhoto(chatId, photo, caption) {
87
+ const input = typeof photo === "string" ? new InputFile(photo) : new InputFile(photo, "photo.jpg");
88
+ await this.bot.api.sendPhoto(Number(chatId), input, { caption });
89
+ }
90
+ async sendDocument(chatId, doc, fileName, caption) {
91
+ const input = typeof doc === "string" ? new InputFile(doc) : new InputFile(doc, fileName);
92
+ await this.bot.api.sendDocument(Number(chatId), input, { caption });
93
+ }
94
+ async sendVoice(chatId, audio) {
95
+ const input = typeof audio === "string" ? new InputFile(audio) : new InputFile(audio, "voice.ogg");
96
+ await this.bot.api.sendVoice(Number(chatId), input);
97
+ }
98
+ async react(chatId, messageId, emoji) {
99
+ try {
100
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
+ await this.bot.api.setMessageReaction(Number(chatId), Number(messageId), [{ type: "emoji", emoji: emoji }]);
102
+ }
103
+ catch { /* Reactions not supported */ }
104
+ }
105
+ async setTyping(chatId) {
106
+ await this.bot.api.sendChatAction(Number(chatId), "typing");
107
+ }
108
+ onMessage(handler) {
109
+ this.handler = handler;
110
+ }
111
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Platform Abstraction — Unified interface for all messaging platforms.
3
+ *
4
+ * Every platform adapter implements PlatformAdapter.
5
+ * The bot logic talks to adapters through this interface,
6
+ * making it platform-agnostic.
7
+ */
8
+ export {};