@ebowwa/channel-telegram 1.9.0

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 (88) hide show
  1. package/README.md +58 -0
  2. package/dist/api/fetch-retry.d.ts +5 -0
  3. package/dist/api/fetch-retry.d.ts.map +1 -0
  4. package/dist/api/fetch-retry.js +35 -0
  5. package/dist/api/fetch-retry.js.map +1 -0
  6. package/dist/api/keys.d.ts +9 -0
  7. package/dist/api/keys.d.ts.map +1 -0
  8. package/dist/api/keys.js +23 -0
  9. package/dist/api/keys.js.map +1 -0
  10. package/dist/commands/clear.d.ts +6 -0
  11. package/dist/commands/clear.d.ts.map +1 -0
  12. package/dist/commands/clear.js +11 -0
  13. package/dist/commands/clear.js.map +1 -0
  14. package/dist/commands/doppler.d.ts +8 -0
  15. package/dist/commands/doppler.d.ts.map +1 -0
  16. package/dist/commands/doppler.js +64 -0
  17. package/dist/commands/doppler.js.map +1 -0
  18. package/dist/commands/git.d.ts +8 -0
  19. package/dist/commands/git.d.ts.map +1 -0
  20. package/dist/commands/git.js +70 -0
  21. package/dist/commands/git.js.map +1 -0
  22. package/dist/commands/help.d.ts +8 -0
  23. package/dist/commands/help.d.ts.map +1 -0
  24. package/dist/commands/help.js +26 -0
  25. package/dist/commands/help.js.map +1 -0
  26. package/dist/commands/index.d.ts +19 -0
  27. package/dist/commands/index.d.ts.map +1 -0
  28. package/dist/commands/index.js +36 -0
  29. package/dist/commands/index.js.map +1 -0
  30. package/dist/commands/logs.d.ts +8 -0
  31. package/dist/commands/logs.d.ts.map +1 -0
  32. package/dist/commands/logs.js +28 -0
  33. package/dist/commands/logs.js.map +1 -0
  34. package/dist/commands/resources.d.ts +6 -0
  35. package/dist/commands/resources.d.ts.map +1 -0
  36. package/dist/commands/resources.js +34 -0
  37. package/dist/commands/resources.js.map +1 -0
  38. package/dist/commands/start.d.ts +8 -0
  39. package/dist/commands/start.d.ts.map +1 -0
  40. package/dist/commands/start.js +20 -0
  41. package/dist/commands/start.js.map +1 -0
  42. package/dist/commands/status.d.ts +8 -0
  43. package/dist/commands/status.d.ts.map +1 -0
  44. package/dist/commands/status.js +14 -0
  45. package/dist/commands/status.js.map +1 -0
  46. package/dist/commands/tools.d.ts +6 -0
  47. package/dist/commands/tools.d.ts.map +1 -0
  48. package/dist/commands/tools.js +18 -0
  49. package/dist/commands/tools.js.map +1 -0
  50. package/dist/commands/toolsoutput.d.ts +11 -0
  51. package/dist/commands/toolsoutput.d.ts.map +1 -0
  52. package/dist/commands/toolsoutput.js +35 -0
  53. package/dist/commands/toolsoutput.js.map +1 -0
  54. package/dist/commands/types.d.ts +18 -0
  55. package/dist/commands/types.d.ts.map +1 -0
  56. package/dist/commands/types.js +5 -0
  57. package/dist/commands/types.js.map +1 -0
  58. package/dist/conversation-memory.d.ts +21 -0
  59. package/dist/conversation-memory.d.ts.map +1 -0
  60. package/dist/conversation-memory.js +51 -0
  61. package/dist/conversation-memory.js.map +1 -0
  62. package/dist/index.d.ts +37 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +530 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/types.d.ts +20 -0
  67. package/dist/types.d.ts.map +1 -0
  68. package/dist/types.js +5 -0
  69. package/dist/types.js.map +1 -0
  70. package/package.json +55 -0
  71. package/src/api/fetch-retry.ts +46 -0
  72. package/src/api/keys.ts +21 -0
  73. package/src/commands/clear.ts +13 -0
  74. package/src/commands/doppler.ts +74 -0
  75. package/src/commands/git.ts +77 -0
  76. package/src/commands/help.ts +38 -0
  77. package/src/commands/index.ts +46 -0
  78. package/src/commands/logs.ts +38 -0
  79. package/src/commands/resources.ts +44 -0
  80. package/src/commands/start.ts +31 -0
  81. package/src/commands/status.ts +26 -0
  82. package/src/commands/tools.ts +23 -0
  83. package/src/commands/toolsoutput.ts +50 -0
  84. package/src/commands/types.ts +24 -0
  85. package/src/conversation-memory.ts +57 -0
  86. package/src/index.ts +614 -0
  87. package/src/todo +11 -0
  88. package/src/types.ts +21 -0
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # GLM Daemon Telegram Bot
2
+
3
+ Telegram adapter for GLM Daemon with ButlerAgent personality.
4
+
5
+ ## Setup
6
+
7
+ 1. **Install dependencies:**
8
+ ```bash
9
+ bun install
10
+ ```
11
+
12
+ 2. **Configure Doppler secrets:**
13
+ ```
14
+ TELEGRAM_BOT_TOKEN=<your-bot-token>
15
+ TELEGRAM_TEST_CHAT_ID=<your-chat-id> # Optional, for test message
16
+ GLM_API_KEY=<your-api-key>
17
+ DOPPLER_TOKEN=<your-doppler-token>
18
+ ```
19
+
20
+ 3. **Build:**
21
+ ```bash
22
+ bun run build
23
+ ```
24
+
25
+ 4. **Run:**
26
+ ```bash
27
+ bun run start
28
+ ```
29
+
30
+ Or with Doppler:
31
+ ```bash
32
+ doppler run -- bun run start
33
+ ```
34
+
35
+ ## Getting Telegram Credentials
36
+
37
+ 1. **Create a bot:**
38
+ - Message [@BotFather](https://t.me/botfather) on Telegram
39
+ - Send `/newbot`
40
+ - Follow the prompts
41
+ - Copy the bot token (format: `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`)
42
+
43
+ 2. **Get your Chat ID:**
44
+ - Message [@userinfobot](https://t.me/userinfobot) on Telegram
45
+ - It will reply with your chat ID
46
+ - Add this to Doppler as `TELEGRAM_TEST_CHAT_ID`
47
+
48
+ ## Features
49
+
50
+ - ✅ Natural conversation with ButlerAgent personality
51
+ - ✅ Context-aware responses (remembers username, name)
52
+ - ✅ Long message chunking (4096 char limit)
53
+ - ✅ Error handling with graceful fallbacks
54
+ - ✅ Test message on startup
55
+
56
+ ## Deployment
57
+
58
+ See `TICKET.md` for deployment details.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Fetch with retry and exponential backoff for 429 handling
3
+ */
4
+ export declare function fetchWithRetry(url: string, options: RequestInit, maxRetries?: number, baseDelay?: number): Promise<Response>;
5
+ //# sourceMappingURL=fetch-retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-retry.d.ts","sourceRoot":"","sources":["../../src/api/fetch-retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EACpB,UAAU,SAAI,EACd,SAAS,SAAO,GACf,OAAO,CAAC,QAAQ,CAAC,CAkCnB"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Fetch with retry and exponential backoff for 429 handling
3
+ */
4
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
5
+ export async function fetchWithRetry(url, options, maxRetries = 3, baseDelay = 1000) {
6
+ let lastError = null;
7
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
8
+ try {
9
+ const response = await fetch(url, options);
10
+ if (response.status === 429) {
11
+ const retryAfter = response.headers.get('Retry-After');
12
+ const delay = retryAfter
13
+ ? parseInt(retryAfter) * 1000
14
+ : baseDelay * Math.pow(2, attempt);
15
+ console.log(`[429] Rate limited, retrying in ${delay}ms (attempt ${attempt + 1}/${maxRetries})`);
16
+ await sleep(delay);
17
+ continue;
18
+ }
19
+ if (!response.ok) {
20
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
21
+ }
22
+ return response;
23
+ }
24
+ catch (error) {
25
+ lastError = error;
26
+ if (attempt < maxRetries - 1) {
27
+ const delay = baseDelay * Math.pow(2, attempt);
28
+ console.log(`[Retry] Attempt ${attempt + 1} failed: ${lastError.message}, retrying in ${delay}ms`);
29
+ await sleep(delay);
30
+ }
31
+ }
32
+ }
33
+ throw lastError;
34
+ }
35
+ //# sourceMappingURL=fetch-retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-retry.js","sourceRoot":"","sources":["../../src/api/fetch-retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAA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,OAAO,CAAC,CAAC;gBAC/C,OAAO,CAAC,GAAG,CAAC,mBAAmB,OAAO,GAAG,CAAC,YAAY,SAAS,CAAC,OAAO,iBAAiB,KAAK,IAAI,CAAC,CAAC;gBACnG,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,CAAC;AAClB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * API Key Resolution - supports rolling keys
3
+ */
4
+ /**
5
+ * Get Z.AI API key from environment
6
+ * Supports single key or JSON array of keys for rolling key rotation
7
+ */
8
+ export declare function getZAIKey(): string | null;
9
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/api/keys.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,IAAI,CAYzC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * API Key Resolution - supports rolling keys
3
+ */
4
+ /**
5
+ * Get Z.AI API key from environment
6
+ * Supports single key or JSON array of keys for rolling key rotation
7
+ */
8
+ export function getZAIKey() {
9
+ const keyValue = process.env.Z_AI_API_KEY || process.env.ANTHROPIC_API_KEYS;
10
+ if (!keyValue)
11
+ return null;
12
+ try {
13
+ const keysArray = JSON.parse(keyValue);
14
+ if (Array.isArray(keysArray) && keysArray.length > 0) {
15
+ return keysArray[0];
16
+ }
17
+ }
18
+ catch {
19
+ return keyValue;
20
+ }
21
+ return keyValue;
22
+ }
23
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/api/keys.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC5E,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrD,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * /clear command - Reset conversation memory
3
+ */
4
+ import type { CommandRegistrar } from './types';
5
+ export declare const registerClearCommand: CommandRegistrar;
6
+ //# sourceMappingURL=clear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,oBAAoB,EAAE,gBAMlC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * /clear command - Reset conversation memory
3
+ */
4
+ export const registerClearCommand = (bot, memory) => {
5
+ bot.onText(/\/clear/, async (msg) => {
6
+ const chatId = msg.chat.id;
7
+ memory.clear(chatId);
8
+ await bot.sendMessage(chatId, '🧹 Conversation memory cleared. Starting fresh!');
9
+ });
10
+ };
11
+ //# sourceMappingURL=clear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.js","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,CAAC,MAAM,oBAAoB,GAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACpE,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,iDAAiD,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * /doppler command - Check Doppler config
3
+ */
4
+ import TelegramBot from 'node-telegram-bot-api';
5
+ import { ConversationMemory } from '../conversation-memory';
6
+ import type { Tool } from '../types';
7
+ export declare function registerDopplerCommand(bot: TelegramBot, _memory: ConversationMemory, _tools: Tool[]): void;
8
+ //# sourceMappingURL=doppler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doppler.d.ts","sourceRoot":"","sources":["../../src/commands/doppler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,IAAI,EAAE,GACb,IAAI,CA4DN"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * /doppler command - Check Doppler config
3
+ */
4
+ import { execSync } from 'child_process';
5
+ export function registerDopplerCommand(bot, _memory, _tools) {
6
+ bot.onText(/\/doppler(?:\s+(.+))?/, async (msg, match) => {
7
+ const chatId = msg.chat.id;
8
+ const subCommand = match?.[1]?.trim();
9
+ try {
10
+ if (subCommand === 'secrets') {
11
+ let statusMsg = 'Doppler Secrets\n\n';
12
+ try {
13
+ const secrets = execSync('doppler secrets --plain 2>&1 | cut -d\'\\t\' -f1', {
14
+ encoding: 'utf-8',
15
+ cwd: '/root'
16
+ });
17
+ const secretList = secrets.trim().split('\n').filter(s => s.length > 0);
18
+ statusMsg += `Found ${secretList.length} secrets:\n\n`;
19
+ statusMsg += secretList.slice(0, 20).join('\n');
20
+ if (secretList.length > 20) {
21
+ statusMsg += `\n... and ${secretList.length - 20} more`;
22
+ }
23
+ }
24
+ catch (e) {
25
+ statusMsg += `Error: ${e.message}`;
26
+ }
27
+ await bot.sendMessage(chatId, statusMsg);
28
+ }
29
+ else {
30
+ let statusMsg = '*Doppler Status*\n\n';
31
+ try {
32
+ // Get project - extract value from table output
33
+ const projectRaw = execSync('doppler configure get project 2>/dev/null', { encoding: 'utf-8', cwd: '/root' });
34
+ const projectMatch = projectRaw.match(/│\s*project\s*│\s*(\S+)\s*│/);
35
+ const project = projectMatch ? projectMatch[1] : 'Not set';
36
+ // Get config - extract value from table output
37
+ const configRaw = execSync('doppler configure get config 2>/dev/null', { encoding: 'utf-8', cwd: '/root' });
38
+ const configMatch = configRaw.match(/│\s*config\s*│\s*(\S+)\s*│/);
39
+ const config = configMatch ? configMatch[1] : 'Not set';
40
+ statusMsg += `Project: \`${project}\`\n`;
41
+ statusMsg += `Config: \`${config}\`\n`;
42
+ const tokenCheck = execSync('doppler me 2>&1 | head -5', { encoding: 'utf-8', cwd: '/root' });
43
+ if (tokenCheck.includes('WORKPLACE') || tokenCheck.includes('TOKEN PREVIEW')) {
44
+ statusMsg += `Token: Valid`;
45
+ }
46
+ else {
47
+ statusMsg += `Token: Not configured`;
48
+ }
49
+ statusMsg += `\n\n_Commands:_\n`;
50
+ statusMsg += `/doppler secrets - List secret names`;
51
+ }
52
+ catch {
53
+ statusMsg += `Not configured\n\n`;
54
+ statusMsg += `Run: \`doppler setup\``;
55
+ }
56
+ await bot.sendMessage(chatId, statusMsg, { parse_mode: 'Markdown' });
57
+ }
58
+ }
59
+ catch (error) {
60
+ await bot.sendMessage(chatId, `Error: ${error.message}`);
61
+ }
62
+ });
63
+ }
64
+ //# sourceMappingURL=doppler.js.map
@@ -0,0 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BAAmB,CAAC;oBACjC,SAAS,IAAI,sCAAsC,CAAC;gBACtD,CAAC;gBAAC,MAAM,CAAC;oBACP,SAAS,IAAI,oBAAoB,CAAC;oBAClC,SAAS,IAAI,wBAAwB,CAAC;gBACxC,CAAC;gBAED,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,UAAW,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * /git command - Check git status & GitHub auth
3
+ */
4
+ import TelegramBot from 'node-telegram-bot-api';
5
+ import { ConversationMemory } from '../conversation-memory';
6
+ import type { Tool } from '../types';
7
+ export declare function registerGitCommand(bot: TelegramBot, _memory: ConversationMemory, _tools: Tool[]): void;
8
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/commands/git.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,IAAI,EAAE,GACb,IAAI,CA+DN"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * /git command - Check git status & GitHub auth
3
+ */
4
+ import { execSync } from 'child_process';
5
+ export function registerGitCommand(bot, _memory, _tools) {
6
+ bot.onText(/\/git(?:\s+(.+))?/, async (msg, match) => {
7
+ const chatId = msg.chat.id;
8
+ const subCommand = match?.[1]?.trim();
9
+ try {
10
+ if (subCommand === 'auth') {
11
+ let statusMsg = 'GitHub Auth\n\n';
12
+ try {
13
+ const deviceResp = execSync('gh auth login --web --git-protocol https 2>&1 | head -20', {
14
+ encoding: 'utf-8',
15
+ timeout: 8000,
16
+ cwd: '/root'
17
+ });
18
+ const codeMatch = deviceResp.match(/verification code:\s*([A-Z0-9-]+)/i);
19
+ const urlMatch = deviceResp.match(/https:\/\/github\.com\/login\/device[^\s]*/);
20
+ if (codeMatch && urlMatch) {
21
+ statusMsg += `Code: ${codeMatch[1]}\n`;
22
+ statusMsg += `URL: ${urlMatch[0]}\n\n`;
23
+ statusMsg += `Open URL and enter code to authenticate.`;
24
+ }
25
+ else {
26
+ statusMsg += deviceResp.slice(0, 500);
27
+ }
28
+ }
29
+ catch (e) {
30
+ statusMsg += `Error: ${e.message}`;
31
+ }
32
+ await bot.sendMessage(chatId, statusMsg);
33
+ }
34
+ else {
35
+ let statusMsg = 'Git Status\n\n';
36
+ try {
37
+ const authStatus = execSync('gh auth status 2>&1', { encoding: 'utf-8', cwd: '/root' });
38
+ const loggedIn = authStatus.includes('Logged in');
39
+ const accountMatch = authStatus.match(/account\s+(\w+)/i);
40
+ statusMsg += `GitHub: ${loggedIn ? 'Connected' : 'Not logged in'}\n`;
41
+ if (accountMatch)
42
+ statusMsg += `Account: ${accountMatch[1]}\n`;
43
+ if (!loggedIn)
44
+ statusMsg += `\nUse /git auth to authenticate`;
45
+ }
46
+ catch {
47
+ statusMsg += `GitHub: Not authenticated\n`;
48
+ statusMsg += `Use /git auth to login\n`;
49
+ }
50
+ try {
51
+ const branch = execSync('git rev-parse --abbrev-ref HEAD 2>/dev/null', { encoding: 'utf-8', cwd: '/root' }).trim();
52
+ const ahead = execSync('git rev-list --count @{upstream}..HEAD 2>/dev/null || echo 0', { encoding: 'utf-8', cwd: '/root' }).trim();
53
+ const dirty = execSync('git status --porcelain 2>/dev/null | wc -l', { encoding: 'utf-8', cwd: '/root' }).trim();
54
+ statusMsg += `\nRepo:\n`;
55
+ statusMsg += `Branch: ${branch}\n`;
56
+ statusMsg += `Ahead: ${ahead} commits\n`;
57
+ statusMsg += `Modified: ${dirty} files`;
58
+ }
59
+ catch {
60
+ statusMsg += `\nRepo: Not a git repo or error`;
61
+ }
62
+ await bot.sendMessage(chatId, statusMsg);
63
+ }
64
+ }
65
+ catch (error) {
66
+ await bot.sendMessage(chatId, `Error: ${error.message}`);
67
+ }
68
+ });
69
+ }
70
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/commands/git.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,MAAM,UAAU,kBAAkB,CAChC,GAAgB,EAChB,OAA2B,EAC3B,MAAc;IAEd,GAAG,CAAC,MAAM,CAAC,mBAAmB,EAAE,KAAK,EAAE,GAAwB,EAAE,KAA6B,EAAE,EAAE;QAChG,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QAEtC,IAAI,CAAC;YACH,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;gBAC1B,IAAI,SAAS,GAAG,iBAAiB,CAAC;gBAClC,IAAI,CAAC;oBACH,MAAM,UAAU,GAAG,QAAQ,CAAC,0DAA0D,EAAE;wBACtF,QAAQ,EAAE,OAAO;wBACjB,OAAO,EAAE,IAAI;wBACb,GAAG,EAAE,OAAO;qBACb,CAAC,CAAC;oBACH,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;oBACzE,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;oBAEhF,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;w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OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;oBACnH,MAAM,KAAK,GAAG,QAAQ,CAAC,8DAA8D,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;oBACnI,MAAM,KAAK,GAAG,QAAQ,CAAC,4CAA4C,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;oBAEjH,SAAS,IAAI,WAAW,CAAC;oBACzB,SAAS,IAAI,WAAW,MAAM,IAAI,CAAC;oBACnC,SAAS,IAAI,UAAU,KAAK,YAAY,CAAC;oBACzC,SAAS,IAAI,aAAa,KAAK,QAAQ,CAAC;gBAC1C,CAAC;gBAAC,MAAM,CAAC;oBACP,SAAS,IAAI,iCAAiC,CAAC;gBACjD,CAAC;gBAED,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,UAAW,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * /help command - Show help message
3
+ */
4
+ import TelegramBot from 'node-telegram-bot-api';
5
+ import { ConversationMemory } from '../conversation-memory';
6
+ import type { Tool } from '../types';
7
+ export declare function registerHelpCommand(bot: TelegramBot, _memory: ConversationMemory, _tools: Tool[]): void;
8
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,IAAI,EAAE,GACb,IAAI,CAyBN"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * /help command - Show help message
3
+ */
4
+ export function registerHelpCommand(bot, _memory, _tools) {
5
+ bot.onText(/\/help/, async (msg) => {
6
+ const chatId = msg.chat.id;
7
+ await bot.sendMessage(chatId, '📚 *GLM Daemon Bot Help*\n\n' +
8
+ '🧠 Powered by GLM-4.7 via Z.AI API\n\n' +
9
+ '*Commands:*\n' +
10
+ '/start - Show welcome message\n' +
11
+ '/status - Check API status\n' +
12
+ '/git - Check git status & GitHub auth\n' +
13
+ '/git auth - Start GitHub auth flow\n' +
14
+ '/doppler - Check Doppler config\n' +
15
+ '/doppler secrets - List secret names\n' +
16
+ '/tools - Show available AI tools\n' +
17
+ '/clear - Clear conversation memory\n' +
18
+ '/resources - Show system resources\n' +
19
+ '/logs [n] - Show last n log lines\n' +
20
+ '/toolsoutput [on|off] - Toggle tool output messages\n' +
21
+ '/help - Show this help\n\n' +
22
+ '*Usage:*\n' +
23
+ 'Just send any message and I\\\'ll respond with AI assistance!', { parse_mode: 'Markdown' });
24
+ });
25
+ }
26
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,UAAU,mBAAmB,CACjC,GAAgB,EAChB,OAA2B,EAC3B,MAAc;IAEd,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAwB,EAAE,EAAE;QACtD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,GAAG,CAAC,WAAW,CACnB,MAAM,EACN,8BAA8B;YAC9B,wCAAwC;YACxC,eAAe;YACf,iCAAiC;YACjC,8BAA8B;YAC9B,yCAAyC;YACzC,sCAAsC;YACtC,mCAAmC;YACnC,wCAAwC;YACxC,oCAAoC;YACpC,sCAAsC;YACtC,sCAAsC;YACtC,qCAAqC;YACrC,uDAAuD;YACvD,4BAA4B;YAC5B,YAAY;YACZ,+DAA+D,EAC/D,EAAE,UAAU,EAAE,UAAU,EAAE,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Command index - Exports all command registrars
3
+ */
4
+ export { registerStartCommand } from './start';
5
+ export { registerStatusCommand } from './status';
6
+ export { registerHelpCommand } from './help';
7
+ export { registerGitCommand } from './git';
8
+ export { registerDopplerCommand } from './doppler';
9
+ export { registerLogsCommand } from './logs';
10
+ export { registerClearCommand } from './clear';
11
+ export { registerToolsCommand } from './tools';
12
+ export { registerResourcesCommand } from './resources';
13
+ export type { CommandRegistrar, CommandContext } from './types';
14
+ import type TelegramBot from 'node-telegram-bot-api';
15
+ /**
16
+ * Register all commands with the bot
17
+ */
18
+ export declare function registerAllCommands(bot: TelegramBot, memory: import('../conversation-memory').ConversationMemory, tools: import('../index').Tool[]): void;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhE,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAC;AAYrD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,OAAO,wBAAwB,EAAE,kBAAkB,EAC3D,KAAK,EAAE,OAAO,UAAU,EAAE,IAAI,EAAE,GAC/B,IAAI,CAUN"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Command index - Exports all command registrars
3
+ */
4
+ export { registerStartCommand } from './start';
5
+ export { registerStatusCommand } from './status';
6
+ export { registerHelpCommand } from './help';
7
+ export { registerGitCommand } from './git';
8
+ export { registerDopplerCommand } from './doppler';
9
+ export { registerLogsCommand } from './logs';
10
+ export { registerClearCommand } from './clear';
11
+ export { registerToolsCommand } from './tools';
12
+ export { registerResourcesCommand } from './resources';
13
+ import { registerStartCommand } from './start';
14
+ import { registerStatusCommand } from './status';
15
+ import { registerHelpCommand } from './help';
16
+ import { registerGitCommand } from './git';
17
+ import { registerDopplerCommand } from './doppler';
18
+ import { registerLogsCommand } from './logs';
19
+ import { registerClearCommand } from './clear';
20
+ import { registerToolsCommand } from './tools';
21
+ import { registerResourcesCommand } from './resources';
22
+ /**
23
+ * Register all commands with the bot
24
+ */
25
+ export function registerAllCommands(bot, memory, tools) {
26
+ registerStartCommand(bot, memory, tools);
27
+ registerStatusCommand(bot, memory, tools);
28
+ registerHelpCommand(bot, memory, tools);
29
+ registerGitCommand(bot, memory, tools);
30
+ registerDopplerCommand(bot, memory, tools);
31
+ registerLogsCommand(bot, memory, tools);
32
+ registerClearCommand(bot, memory, tools);
33
+ registerToolsCommand(bot, memory, tools);
34
+ registerResourcesCommand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AAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC1C,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACxC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACvC,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3C,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACxC,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACzC,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACzC,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * /logs command - Show systemd journal logs
3
+ */
4
+ import TelegramBot from 'node-telegram-bot-api';
5
+ import { ConversationMemory } from '../conversation-memory';
6
+ import type { Tool } from '../types';
7
+ export declare function registerLogsCommand(bot: TelegramBot, _memory: ConversationMemory, _tools: Tool[]): void;
8
+ //# sourceMappingURL=logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,IAAI,EAAE,GACb,IAAI,CAwBN"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * /logs command - Show systemd journal logs
3
+ */
4
+ import { execSync } from 'child_process';
5
+ export function registerLogsCommand(bot, _memory, _tools) {
6
+ bot.onText(/\/logs(?:\s+(\d+))?/, async (msg, match) => {
7
+ const chatId = msg.chat.id;
8
+ const lines = match?.[1] ? parseInt(match[1]) : 20;
9
+ try {
10
+ const logs = execSync(`journalctl -u telegram-bot -n ${Math.min(lines, 100)} --no-pager 2>&1`, {
11
+ encoding: 'utf-8',
12
+ cwd: '/root'
13
+ });
14
+ // Truncate if too long for Telegram
15
+ const maxLen = 4000;
16
+ let output = logs.trim();
17
+ if (output.length > maxLen) {
18
+ output = '...\n' + output.slice(-maxLen);
19
+ }
20
+ // Send without Markdown to avoid parsing errors with log content
21
+ await bot.sendMessage(chatId, `System Logs (last ${lines} lines)\n\n${output}`);
22
+ }
23
+ catch (error) {
24
+ await bot.sendMessage(chatId, `Error reading logs: ${error.message}`);
25
+ }
26
+ });
27
+ }
28
+ //# sourceMappingURL=logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,MAAM,UAAU,mBAAmB,CACjC,GAAgB,EAChB,OAA2B,EAC3B,MAAc;IAEd,GAAG,CAAC,MAAM,CAAC,qBAAqB,EAAE,KAAK,EAAE,GAAwB,EAAE,KAA6B,EAAE,EAAE;QAClG,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEnD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,iCAAiC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,kBAAkB,EAAE;gBAC7F,QAAQ,EAAE,OAAO;gBACjB,GAAG,EAAE,OAAO;aACb,CAAC,CAAC;YAEH,oCAAoC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC;YACpB,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACzB,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;gBAC3B,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;YAED,iEAAiE;YACjE,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,qBAAqB,KAAK,cAAc,MAAM,EAAE,CAAC,CAAC;QAClF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,uBAAwB,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACnF,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * /resources command - Show system resources
3
+ */
4
+ import type { CommandRegistrar } from './types';
5
+ export declare const registerResourcesCommand: CommandRegistrar;
6
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/commands/resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,wBAAwB,EAAE,gBAoCtC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * /resources command - Show system resources
3
+ */
4
+ import { execSync } from 'child_process';
5
+ export const registerResourcesCommand = (bot) => {
6
+ bot.onText(/\/resources/, async (msg) => {
7
+ const chatId = msg.chat.id;
8
+ try {
9
+ const loadAvg = execSync('cat /proc/loadavg', { encoding: 'utf-8' }).trim().split(' ').slice(0, 3).join(', ');
10
+ const cpuCount = execSync('nproc', { encoding: 'utf-8' }).trim();
11
+ const memInfo = execSync('free -m | grep Mem', { encoding: 'utf-8' });
12
+ const memMatch = memInfo.match(/Mem:\s+(\d+)\s+(\d+)\s+(\d+)/);
13
+ const memTotal = memMatch ? Math.round(parseInt(memMatch[1]) / 1024) : 0;
14
+ const memUsed = memMatch ? Math.round(parseInt(memMatch[2]) / 1024) : 0;
15
+ const memPercent = memMatch ? Math.round((parseInt(memMatch[2]) / parseInt(memMatch[1])) * 100) : 0;
16
+ const diskInfo = execSync('df -h / | tail -1', { encoding: 'utf-8' });
17
+ const diskMatch = diskInfo.match(/\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\d+%)/);
18
+ const diskUsed = diskMatch ? diskMatch[2] : '?';
19
+ const diskTotal = diskMatch ? diskMatch[1] : '?';
20
+ const diskPercent = diskMatch ? diskMatch[4] : '?';
21
+ const uptime = execSync('uptime -p 2>/dev/null || uptime', { encoding: 'utf-8' }).trim().replace('up ', '');
22
+ await bot.sendMessage(chatId, `*System Resources*\n\n` +
23
+ `*CPU:* ${cpuCount} cores\n` +
24
+ `*Load:* ${loadAvg}\n\n` +
25
+ `*Memory:* ${memUsed}/${memTotal}GB (${memPercent}%)\n` +
26
+ `*Disk:* ${diskUsed}/${diskTotal} (${diskPercent})\n\n` +
27
+ `*Uptime:* ${uptime}`, { parse_mode: 'Markdown' });
28
+ }
29
+ catch (error) {
30
+ await bot.sendMessage(chatId, `Error reading resources: ${error.message}`);
31
+ }
32
+ });
33
+ };
34
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/commands/resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,CAAC,MAAM,wBAAwB,GAAqB,CAAC,GAAG,EAAE,EAAE;IAChE,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAE3B,IAAI,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zE,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAChD,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACjD,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAEnD,MAAM,MAAM,GAAG,QAAQ,CAAC,iCAAiC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAE5G,MAAM,GAAG,CAAC,WAAW,CACnB,MAAM,EACN,wBAAwB;gBACxB,UAAU,QAAQ,UAAU;gBAC5B,WAAW,OAAO,MAAM;gBACxB,aAAa,OAAO,IAAI,QAAQ,OAAO,UAAU,MAAM;gBACvD,WAAW,QAAQ,IAAI,SAAS,KAAK,WAAW,OAAO;gBACvD,aAAa,MAAM,EAAE,EACrB,EAAE,UAAU,EAAE,UAAU,EAAE,CAC3B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,4BAA6B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACxF,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * /start command - Show welcome message
3
+ */
4
+ import TelegramBot from 'node-telegram-bot-api';
5
+ import { ConversationMemory } from '../conversation-memory';
6
+ import type { Tool } from '../types';
7
+ export declare function registerStartCommand(bot: TelegramBot, _memory: ConversationMemory, _tools: Tool[]): void;
8
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,IAAI,EAAE,GACb,IAAI,CAkBN"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * /start command - Show welcome message
3
+ */
4
+ export function registerStartCommand(bot, _memory, _tools) {
5
+ bot.onText(/\/start/, async (msg) => {
6
+ const chatId = msg.chat.id;
7
+ await bot.sendMessage(chatId, '👋 Hello! I\'m GLM Daemon Telegram Bot.\n\n' +
8
+ '🧠 Powered by GLM-4.7 via Z.AI API\n\n' +
9
+ 'Commands:\n' +
10
+ '/start - Show this message\n' +
11
+ '/status - Check API status\n' +
12
+ '/git - Check git status & GitHub auth\n' +
13
+ '/doppler - Check Doppler config\n' +
14
+ '/tools - Show available AI tools\n' +
15
+ '/clear - Clear conversation memory\n' +
16
+ '/help - Show help\n\n' +
17
+ 'Or just send any message for AI assistance!');
18
+ });
19
+ }
20
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,UAAU,oBAAoB,CAClC,GAAgB,EAChB,OAA2B,EAC3B,MAAc;IAEd,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,GAAwB,EAAE,EAAE;QACvD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,GAAG,CAAC,WAAW,CACnB,MAAM,EACN,6CAA6C;YAC7C,wCAAwC;YACxC,aAAa;YACb,8BAA8B;YAC9B,8BAA8B;YAC9B,yCAAyC;YACzC,mCAAmC;YACnC,oCAAoC;YACpC,sCAAsC;YACtC,uBAAuB;YACvB,6CAA6C,CAC9C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * /status command - Check API status
3
+ */
4
+ import TelegramBot from 'node-telegram-bot-api';
5
+ import { ConversationMemory } from '../conversation-memory';
6
+ import type { Tool } from '../types';
7
+ export declare function registerStatusCommand(bot: TelegramBot, _memory: ConversationMemory, _tools: Tool[]): void;
8
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGrC,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,IAAI,EAAE,GACb,IAAI,CAYN"}