opencode-telegram-bot 1.0.8 → 1.0.10
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 +24 -1
- package/dist/app.d.ts +21 -13
- package/dist/index.js +2207 -614
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,7 +115,21 @@ These are handled directly by the Telegram bot:
|
|
|
115
115
|
| `/usage` | Show token and cost usage for this session |
|
|
116
116
|
| `/help` | Show available commands |
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
### Interactive Questions
|
|
119
|
+
|
|
120
|
+
When the OpenCode agent asks a question (e.g. to clarify intent or pick from options), the bot forwards it to Telegram as **inline keyboard buttons**. Tap an option to answer, or tap **Dismiss** to reject the question.
|
|
121
|
+
|
|
122
|
+
If the bot restarts while a question is pending, it automatically re-sends the question buttons on startup so the session is not left stuck.
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Agent: Which area do you want to focus on?
|
|
126
|
+
[Code review] [Bug fix] [New feature] [Dismiss]
|
|
127
|
+
|
|
128
|
+
You: [tap "Bug fix"]
|
|
129
|
+
Bot: Answered: Bug fix
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The bot also registers these commands in Telegram's command menu (the `/` button), plus any OpenCode server commands discovered at startup.
|
|
119
133
|
|
|
120
134
|
### Verbose Mode
|
|
121
135
|
|
|
@@ -250,6 +264,15 @@ Sessions survive bot restarts. The bot saves the chat-to-session mapping to `ses
|
|
|
250
264
|
|
|
251
265
|
This means you can restart the bot (or even delete `sessions.json`) and it will reconnect to existing sessions automatically.
|
|
252
266
|
|
|
267
|
+
## Resilience
|
|
268
|
+
|
|
269
|
+
The bot is designed to survive restarts and failures:
|
|
270
|
+
|
|
271
|
+
- **Drop pending updates** -- On startup, stale Telegram updates are discarded so old button clicks and messages from a previous run are not replayed.
|
|
272
|
+
- **Pending question recovery** -- If the bot restarts while the agent is waiting for a question answer, the question is re-sent to Telegram on startup so the session can be unblocked.
|
|
273
|
+
- **Global error handler** -- Unhandled errors in Telegram update handlers are logged instead of crashing the process.
|
|
274
|
+
- **Handler timeout** -- Telegraf's handler timeout is set to 10 minutes (up from 90 seconds) to accommodate long-running LLM responses.
|
|
275
|
+
|
|
253
276
|
## Environment Variables
|
|
254
277
|
|
|
255
278
|
| Variable | Required | Description |
|
package/dist/app.d.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
interface OpencodeClientLike {
|
|
2
2
|
session: {
|
|
3
|
-
list: (options?: any) => Promise<any>;
|
|
4
|
-
create: (
|
|
5
|
-
update: (
|
|
6
|
-
delete: (
|
|
7
|
-
get: (
|
|
8
|
-
messages: (
|
|
9
|
-
command: (
|
|
10
|
-
promptAsync: (
|
|
3
|
+
list: (params?: any, options?: any) => Promise<any>;
|
|
4
|
+
create: (params: any, options?: any) => Promise<any>;
|
|
5
|
+
update: (params: any, options?: any) => Promise<any>;
|
|
6
|
+
delete: (params: any, options?: any) => Promise<any>;
|
|
7
|
+
get: (params: any, options?: any) => Promise<any>;
|
|
8
|
+
messages: (params: any, options?: any) => Promise<any>;
|
|
9
|
+
command: (params: any, options?: any) => Promise<any>;
|
|
10
|
+
promptAsync: (params: any, options?: any) => Promise<any>;
|
|
11
11
|
};
|
|
12
12
|
command: {
|
|
13
|
-
list: (options?: any) => Promise<any>;
|
|
13
|
+
list: (params?: any, options?: any) => Promise<any>;
|
|
14
14
|
};
|
|
15
15
|
provider: {
|
|
16
|
-
list: (options?: any) => Promise<any>;
|
|
16
|
+
list: (params?: any, options?: any) => Promise<any>;
|
|
17
17
|
};
|
|
18
18
|
path: {
|
|
19
|
-
get: (options?: any) => Promise<any>;
|
|
19
|
+
get: (params?: any, options?: any) => Promise<any>;
|
|
20
20
|
};
|
|
21
21
|
event: {
|
|
22
|
-
subscribe: (options?: any) => Promise<any>;
|
|
22
|
+
subscribe: (params?: any, options?: any) => Promise<any>;
|
|
23
|
+
};
|
|
24
|
+
question: {
|
|
25
|
+
list: (params?: any, options?: any) => Promise<any>;
|
|
26
|
+
reply: (params: any, options?: any) => Promise<any>;
|
|
27
|
+
reject: (params: any, options?: any) => Promise<any>;
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
30
|
interface StartOptions {
|
|
@@ -32,12 +37,15 @@ interface StartOptions {
|
|
|
32
37
|
}
|
|
33
38
|
interface TelegramBot {
|
|
34
39
|
use: (fn: (ctx: any, next: () => Promise<void>) => Promise<void> | void) => void;
|
|
40
|
+
catch: (fn: (err: unknown, ctx: any) => void) => void;
|
|
35
41
|
start: (fn: (ctx: any) => void | Promise<void>) => void;
|
|
36
42
|
help: (fn: (ctx: any) => void | Promise<void>) => void;
|
|
37
43
|
command: (command: string, fn: (ctx: any) => void | Promise<void>) => void;
|
|
38
44
|
on: (event: string, fn: (ctx: any) => void | Promise<void>) => void;
|
|
39
45
|
action: (trigger: string | RegExp, fn: (ctx: any) => void | Promise<void>) => void;
|
|
40
|
-
launch: (
|
|
46
|
+
launch: (options?: {
|
|
47
|
+
dropPendingUpdates?: boolean;
|
|
48
|
+
}) => Promise<void>;
|
|
41
49
|
stop: (reason?: string) => void;
|
|
42
50
|
telegram: {
|
|
43
51
|
sendMessage: (chatId: number, text: string, options?: Record<string, unknown>) => Promise<void>;
|