@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.
- package/README.md +58 -0
- package/dist/api/fetch-retry.d.ts +5 -0
- package/dist/api/fetch-retry.d.ts.map +1 -0
- package/dist/api/fetch-retry.js +35 -0
- package/dist/api/fetch-retry.js.map +1 -0
- package/dist/api/keys.d.ts +9 -0
- package/dist/api/keys.d.ts.map +1 -0
- package/dist/api/keys.js +23 -0
- package/dist/api/keys.js.map +1 -0
- package/dist/commands/clear.d.ts +6 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +11 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/doppler.d.ts +8 -0
- package/dist/commands/doppler.d.ts.map +1 -0
- package/dist/commands/doppler.js +64 -0
- package/dist/commands/doppler.js.map +1 -0
- package/dist/commands/git.d.ts +8 -0
- package/dist/commands/git.d.ts.map +1 -0
- package/dist/commands/git.js +70 -0
- package/dist/commands/git.js.map +1 -0
- package/dist/commands/help.d.ts +8 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +26 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/index.d.ts +19 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +36 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/logs.d.ts +8 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +28 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/resources.d.ts +6 -0
- package/dist/commands/resources.d.ts.map +1 -0
- package/dist/commands/resources.js +34 -0
- package/dist/commands/resources.js.map +1 -0
- package/dist/commands/start.d.ts +8 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +20 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +14 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/tools.d.ts +6 -0
- package/dist/commands/tools.d.ts.map +1 -0
- package/dist/commands/tools.js +18 -0
- package/dist/commands/tools.js.map +1 -0
- package/dist/commands/toolsoutput.d.ts +11 -0
- package/dist/commands/toolsoutput.d.ts.map +1 -0
- package/dist/commands/toolsoutput.js +35 -0
- package/dist/commands/toolsoutput.js.map +1 -0
- package/dist/commands/types.d.ts +18 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +5 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/conversation-memory.d.ts +21 -0
- package/dist/conversation-memory.d.ts.map +1 -0
- package/dist/conversation-memory.js +51 -0
- package/dist/conversation-memory.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +530 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
- package/src/api/fetch-retry.ts +46 -0
- package/src/api/keys.ts +21 -0
- package/src/commands/clear.ts +13 -0
- package/src/commands/doppler.ts +74 -0
- package/src/commands/git.ts +77 -0
- package/src/commands/help.ts +38 -0
- package/src/commands/index.ts +46 -0
- package/src/commands/logs.ts +38 -0
- package/src/commands/resources.ts +44 -0
- package/src/commands/start.ts +31 -0
- package/src/commands/status.ts +26 -0
- package/src/commands/tools.ts +23 -0
- package/src/commands/toolsoutput.ts +50 -0
- package/src/commands/types.ts +24 -0
- package/src/conversation-memory.ts +57 -0
- package/src/index.ts +614 -0
- package/src/todo +11 -0
- package/src/types.ts +21 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /status command - Check API status
|
|
3
|
+
*/
|
|
4
|
+
import { getZAIKey } from '../api/keys';
|
|
5
|
+
export function registerStatusCommand(bot, _memory, _tools) {
|
|
6
|
+
bot.onText(/\/status/, async (msg) => {
|
|
7
|
+
const chatId = msg.chat.id;
|
|
8
|
+
const apiKey = getZAIKey();
|
|
9
|
+
await bot.sendMessage(chatId, `*Bot Status*\n\n` +
|
|
10
|
+
`*AI:* GLM-4.7 via Z.AI\n` +
|
|
11
|
+
`*API:* ${apiKey ? 'Connected' : 'Disconnected'}`, { parse_mode: 'Markdown' });
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,UAAU,qBAAqB,CACnC,GAAgB,EAChB,OAA2B,EAC3B,MAAc;IAEd,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,GAAwB,EAAE,EAAE;QACxD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,GAAG,CAAC,WAAW,CACnB,MAAM,EACN,kBAAkB;YAClB,0BAA0B;YAC1B,UAAU,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,EAAE,EACjD,EAAE,UAAU,EAAE,UAAU,EAAE,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/commands/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,oBAAoB,EAAE,gBAgBlC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /tools command - Show available LLM tools
|
|
3
|
+
*/
|
|
4
|
+
export const registerToolsCommand = (bot, _memory, tools) => {
|
|
5
|
+
bot.onText(/\/tools/, async (msg) => {
|
|
6
|
+
const chatId = msg.chat.id;
|
|
7
|
+
let toolsMsg = '*🛠️ Available Tools*\n\n';
|
|
8
|
+
toolsMsg += 'The AI can use these tools:\n\n';
|
|
9
|
+
for (const tool of tools) {
|
|
10
|
+
toolsMsg += `*${tool.name}*\n`;
|
|
11
|
+
toolsMsg += `${tool.description}\n\n`;
|
|
12
|
+
}
|
|
13
|
+
toolsMsg += '_Just ask the AI to use them!_';
|
|
14
|
+
toolsMsg += '\nExample: "Show me system info" or "List files in /root"';
|
|
15
|
+
await bot.sendMessage(chatId, toolsMsg, { parse_mode: 'Markdown' });
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/commands/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,CAAC,MAAM,oBAAoB,GAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;IAC5E,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,IAAI,QAAQ,GAAG,2BAA2B,CAAC;QAC3C,QAAQ,IAAI,iCAAiC,CAAC;QAE9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,QAAQ,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;YAC/B,QAAQ,IAAI,GAAG,IAAI,CAAC,WAAW,MAAM,CAAC;QACxC,CAAC;QAED,QAAQ,IAAI,gCAAgC,CAAC;QAC7C,QAAQ,IAAI,2DAA2D,CAAC;QAExE,MAAM,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /toolsoutput command - Toggle tool output messages
|
|
3
|
+
*
|
|
4
|
+
* When disabled, tools still execute but their output isn't sent to Telegram
|
|
5
|
+
*/
|
|
6
|
+
import TelegramBot from 'node-telegram-bot-api';
|
|
7
|
+
import { ConversationMemory } from '../conversation-memory';
|
|
8
|
+
import type { Tool } from '../types';
|
|
9
|
+
export declare function isToolOutputEnabled(): boolean;
|
|
10
|
+
export declare function registerToolsOutputCommand(bot: TelegramBot, _memory: ConversationMemory, _tools: Tool[]): void;
|
|
11
|
+
//# sourceMappingURL=toolsoutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolsoutput.d.ts","sourceRoot":"","sources":["../../src/commands/toolsoutput.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKrC,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,IAAI,EAAE,GACb,IAAI,CA4BN"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /toolsoutput command - Toggle tool output messages
|
|
3
|
+
*
|
|
4
|
+
* When disabled, tools still execute but their output isn't sent to Telegram
|
|
5
|
+
*/
|
|
6
|
+
// Global state for tool output visibility
|
|
7
|
+
let toolOutputEnabled = true;
|
|
8
|
+
export function isToolOutputEnabled() {
|
|
9
|
+
return toolOutputEnabled;
|
|
10
|
+
}
|
|
11
|
+
export function registerToolsOutputCommand(bot, _memory, _tools) {
|
|
12
|
+
bot.onText(/\/toolsoutput(?:\s+(on|off|toggle))?/, async (msg, match) => {
|
|
13
|
+
const chatId = msg.chat.id;
|
|
14
|
+
const subCommand = match?.[1]?.toLowerCase();
|
|
15
|
+
if (subCommand === 'on') {
|
|
16
|
+
toolOutputEnabled = true;
|
|
17
|
+
}
|
|
18
|
+
else if (subCommand === 'off') {
|
|
19
|
+
toolOutputEnabled = false;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// toggle or no arg = toggle
|
|
23
|
+
toolOutputEnabled = !toolOutputEnabled;
|
|
24
|
+
}
|
|
25
|
+
const status = toolOutputEnabled ? 'ON' : 'OFF';
|
|
26
|
+
const emoji = toolOutputEnabled ? '🔊' : '🔇';
|
|
27
|
+
await bot.sendMessage(chatId, `${emoji} *Tool Output: ${status}*\n\n` +
|
|
28
|
+
`Tool execution messages are now ${toolOutputEnabled ? 'visible' : 'hidden'}.\n\n` +
|
|
29
|
+
`Commands:\n` +
|
|
30
|
+
`/toolsoutput on - Enable tool messages\n` +
|
|
31
|
+
`/toolsoutput off - Disable tool messages\n` +
|
|
32
|
+
`/toolsoutput toggle - Toggle`, { parse_mode: 'Markdown' });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=toolsoutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolsoutput.js","sourceRoot":"","sources":["../../src/commands/toolsoutput.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,0CAA0C;AAC1C,IAAI,iBAAiB,GAAG,IAAI,CAAC;AAE7B,MAAM,UAAU,mBAAmB;IACjC,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,GAAgB,EAChB,OAA2B,EAC3B,MAAc;IAEd,GAAG,CAAC,MAAM,CAAC,sCAAsC,EAAE,KAAK,EAAE,GAAwB,EAAE,KAA6B,EAAE,EAAE;QACnH,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;QAE7C,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACxB,iBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;aAAM,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YAChC,iBAAiB,GAAG,KAAK,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,4BAA4B;YAC5B,iBAAiB,GAAG,CAAC,iBAAiB,CAAC;QACzC,CAAC;QAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAChD,MAAM,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAE9C,MAAM,GAAG,CAAC,WAAW,CACnB,MAAM,EACN,GAAG,KAAK,kBAAkB,MAAM,OAAO;YACvC,mCAAmC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,OAAO;YAClF,aAAa;YACb,0CAA0C;YAC1C,4CAA4C;YAC5C,8BAA8B,EAC9B,EAAE,UAAU,EAAE,UAAU,EAAE,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Telegram command handlers
|
|
3
|
+
*/
|
|
4
|
+
import TelegramBot from 'node-telegram-bot-api';
|
|
5
|
+
import { ConversationMemory } from '../conversation-memory';
|
|
6
|
+
/**
|
|
7
|
+
* Command registration function signature
|
|
8
|
+
*/
|
|
9
|
+
export type CommandRegistrar = (bot: TelegramBot, memory: ConversationMemory, tools: import('../index').Tool[]) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Context passed to command handlers
|
|
12
|
+
*/
|
|
13
|
+
export interface CommandContext {
|
|
14
|
+
bot: TelegramBot;
|
|
15
|
+
memory: ConversationMemory;
|
|
16
|
+
tools: import('../index').Tool[];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,OAAO,UAAU,EAAE,IAAI,EAAE,KAC7B,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,OAAO,UAAU,EAAE,IAAI,EAAE,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation Memory - tracks chat history per user
|
|
3
|
+
*/
|
|
4
|
+
interface Message {
|
|
5
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
6
|
+
content: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class ConversationMemory {
|
|
10
|
+
private conversations;
|
|
11
|
+
private maxMessages;
|
|
12
|
+
private file;
|
|
13
|
+
constructor(file?: string);
|
|
14
|
+
private load;
|
|
15
|
+
private save;
|
|
16
|
+
add(chatId: number, role: 'user' | 'assistant' | 'system' | 'tool', content: string, name?: string): void;
|
|
17
|
+
get(chatId: number): Message[];
|
|
18
|
+
clear(chatId: number): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=conversation-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-memory.d.ts","sourceRoot":"","sources":["../src/conversation-memory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,UAAU,OAAO;IAAG,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;AAEpG,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,IAAI,CAAS;gBAET,IAAI,CAAC,EAAE,MAAM;IAKzB,OAAO,CAAC,IAAI;IAUZ,OAAO,CAAC,IAAI;IAKZ,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAelG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE;IAI9B,KAAK,CAAC,MAAM,EAAE,MAAM;CAIrB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation Memory - tracks chat history per user
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
5
|
+
export class ConversationMemory {
|
|
6
|
+
conversations = new Map();
|
|
7
|
+
maxMessages = 10; // Keep last N messages
|
|
8
|
+
file;
|
|
9
|
+
constructor(file) {
|
|
10
|
+
this.file = file || '/root/conversations.json';
|
|
11
|
+
this.load();
|
|
12
|
+
}
|
|
13
|
+
load() {
|
|
14
|
+
if (!existsSync(this.file))
|
|
15
|
+
return;
|
|
16
|
+
try {
|
|
17
|
+
const data = JSON.parse(readFileSync(this.file, 'utf-8'));
|
|
18
|
+
for (const [chatId, messages] of Object.entries(data)) {
|
|
19
|
+
this.conversations.set(Number(chatId), messages);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch { }
|
|
23
|
+
}
|
|
24
|
+
save() {
|
|
25
|
+
const data = Object.fromEntries(this.conversations);
|
|
26
|
+
writeFileSync(this.file, JSON.stringify(data, null, 2));
|
|
27
|
+
}
|
|
28
|
+
add(chatId, role, content, name) {
|
|
29
|
+
if (!this.conversations.has(chatId)) {
|
|
30
|
+
this.conversations.set(chatId, []);
|
|
31
|
+
}
|
|
32
|
+
const history = this.conversations.get(chatId);
|
|
33
|
+
const msg = { role, content };
|
|
34
|
+
if (name)
|
|
35
|
+
msg.name = name;
|
|
36
|
+
history.push(msg);
|
|
37
|
+
// Keep only last N messages
|
|
38
|
+
if (history.length > this.maxMessages) {
|
|
39
|
+
history.splice(0, history.length - this.maxMessages);
|
|
40
|
+
}
|
|
41
|
+
this.save();
|
|
42
|
+
}
|
|
43
|
+
get(chatId) {
|
|
44
|
+
return this.conversations.get(chatId) || [];
|
|
45
|
+
}
|
|
46
|
+
clear(chatId) {
|
|
47
|
+
this.conversations.delete(chatId);
|
|
48
|
+
this.save();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=conversation-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-memory.js","sourceRoot":"","sources":["../src/conversation-memory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAI7D,MAAM,OAAO,kBAAkB;IACrB,aAAa,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC7C,WAAW,GAAG,EAAE,CAAC,CAAC,uBAAuB;IACzC,IAAI,CAAS;IAErB,YAAY,IAAa;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,0BAA0B,CAAC;QAC/C,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO;QACnC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1D,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAqB,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;IAEO,IAAI;QACV,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACpD,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,GAAG,CAAC,MAAc,EAAE,IAA8C,EAAE,OAAe,EAAE,IAAa;QAChG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACrC,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QAChD,MAAM,GAAG,GAAY,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACvC,IAAI,IAAI;YAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,4BAA4B;QAC5B,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACtC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,MAAc;QAClB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GLM Daemon Telegram Bot
|
|
3
|
+
*
|
|
4
|
+
* Full-featured Telegram bot with GLM-4.7 AI, git status, Doppler integration
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - GLM-4.7 AI responses via Z.AI API
|
|
8
|
+
* - 429 rate limit handling with exponential backoff
|
|
9
|
+
* - /git command for git status + GitHub auth
|
|
10
|
+
* - /doppler command for Doppler secrets status
|
|
11
|
+
* - Rolling API key support
|
|
12
|
+
*/
|
|
13
|
+
export interface Tool {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: Record<string, unknown>;
|
|
17
|
+
handler: (args: Record<string, unknown>) => Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
export declare class TelegramGLMBot {
|
|
20
|
+
private bot;
|
|
21
|
+
private memory;
|
|
22
|
+
constructor(token: string);
|
|
23
|
+
/**
|
|
24
|
+
* Send message, splitting if too long for Telegram (4096 char limit)
|
|
25
|
+
*/
|
|
26
|
+
private sendLongMessage;
|
|
27
|
+
start(): Promise<void>;
|
|
28
|
+
getGLMResponse(chatId: number, userMessage: string, userName: string): Promise<string>;
|
|
29
|
+
sendTestMessage(chatId: number): Promise<void>;
|
|
30
|
+
stop(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Check for crash recovery - analyze previous session and report
|
|
33
|
+
* Always sends a startup message (crash or normal)
|
|
34
|
+
*/
|
|
35
|
+
checkCrashAndReport(chatId: number): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmBH,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7D;AAmOD,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,MAAM,CAAqB;gBAEvB,KAAK,EAAE,MAAM;IAKzB;;OAEG;YACW,eAAe;IAsCvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2CtB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA2ItF,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B;;;OAGG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAyDzD"}
|