@bytesbrains/pi-telegram-bridge 1.1.1 → 1.1.3
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/package.json +5 -1
- package/skills/telegram-first/SKILL.md +57 -0
- package/src/helpers.ts +2 -1
- package/src/index.ts +1 -1
- package/src/templates.ts +555 -652
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytesbrains/pi-telegram-bridge",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Telegram bot bridge for pi agents — send messages, ask questions, and listen for human replies via Telegram.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"src/",
|
|
30
|
+
"skills/",
|
|
30
31
|
"README.md",
|
|
31
32
|
"AGENTS.md",
|
|
32
33
|
"LICENSE"
|
|
@@ -38,6 +39,9 @@
|
|
|
38
39
|
"pi": {
|
|
39
40
|
"extensions": [
|
|
40
41
|
"./src/index.ts"
|
|
42
|
+
],
|
|
43
|
+
"skills": [
|
|
44
|
+
"./skills"
|
|
41
45
|
]
|
|
42
46
|
},
|
|
43
47
|
"scripts": {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: telegram-first
|
|
3
|
+
description: Route ALL interactive communication through Telegram instead of terminal prompts. The human is reachable on Telegram — use telegram_ask for questions, telegram_notify for status, telegram_send for updates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Telegram-First Communication
|
|
7
|
+
|
|
8
|
+
When telegram-bridge is active, route ALL interactive communication through Telegram instead of the terminal. The human is primarily reachable on Telegram — terminal prompts go unanswered.
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
|
|
12
|
+
### Questions & Confirmations
|
|
13
|
+
|
|
14
|
+
Use `telegram_ask` for ANY decision, confirmation, or question:
|
|
15
|
+
|
|
16
|
+
- Approval requests (force push, destructive ops, deployments)
|
|
17
|
+
- Clarification questions (ambiguous instructions, multiple approaches)
|
|
18
|
+
- Dependency decisions (which library, which approach)
|
|
19
|
+
- Priority calls (order of work, tradeoffs)
|
|
20
|
+
|
|
21
|
+
Do NOT use terminal dialogs (`ctx.ui.confirm`, `ctx.ui.select`, `ctx.ui.input`) — the human won't see them.
|
|
22
|
+
|
|
23
|
+
### Status Updates
|
|
24
|
+
|
|
25
|
+
Use `telegram_notify` for structured status updates:
|
|
26
|
+
|
|
27
|
+
- Issue created/updated → kind: `issue`
|
|
28
|
+
- PR created/status change → kind: `pr`
|
|
29
|
+
- Work started/progress/complete → kind: `task`
|
|
30
|
+
- CI pipeline results → kind: `pipeline`
|
|
31
|
+
- Session started/ended → kind: `session`
|
|
32
|
+
- Factory job dispatched/completed → kind: `factory-job`
|
|
33
|
+
- Errors or warnings → kind: `alert`
|
|
34
|
+
- Commits or diffs → kind: `diff`
|
|
35
|
+
- End-of-session roundup → kind: `standup`
|
|
36
|
+
|
|
37
|
+
### One-Way Messages
|
|
38
|
+
|
|
39
|
+
Use `telegram_send` for:
|
|
40
|
+
|
|
41
|
+
- Quick acknowledgments ("Got it, working on it")
|
|
42
|
+
- Simple progress notes not needing structured format
|
|
43
|
+
- Links or references
|
|
44
|
+
|
|
45
|
+
### Fallback
|
|
46
|
+
|
|
47
|
+
Only use terminal UI if:
|
|
48
|
+
|
|
49
|
+
- `telegram_status` reports Telegram is not configured or unreachable
|
|
50
|
+
- A `telegram_ask` times out with no reply (then proceed autonomously and notify via `telegram_send`)
|
|
51
|
+
|
|
52
|
+
## Session Flow
|
|
53
|
+
|
|
54
|
+
1. **Start:** Send `session` notification via `telegram_notify`
|
|
55
|
+
2. **During:** Route all questions through `telegram_ask`, progress through `telegram_notify(kind="task")`
|
|
56
|
+
3. **Significant events:** CI results, PRs, issues, commits → `telegram_notify` with appropriate kind
|
|
57
|
+
4. **End:** Send `standup` roundup summarizing completed, next, and blockers
|
package/src/helpers.ts
CHANGED
|
@@ -40,11 +40,12 @@ export async function telegramApi(
|
|
|
40
40
|
export async function sendMsg(
|
|
41
41
|
text: string,
|
|
42
42
|
replyMarkup?: object,
|
|
43
|
+
parseMode: "Markdown" | "HTML" = "Markdown",
|
|
43
44
|
): Promise<number> {
|
|
44
45
|
const body: Record<string, unknown> = {
|
|
45
46
|
chat_id: getChatId(),
|
|
46
47
|
text,
|
|
47
|
-
parse_mode:
|
|
48
|
+
parse_mode: parseMode,
|
|
48
49
|
};
|
|
49
50
|
if (replyMarkup) body.reply_markup = JSON.stringify(replyMarkup);
|
|
50
51
|
const r = (await telegramApi("sendMessage", body)) as {
|
package/src/index.ts
CHANGED
|
@@ -381,7 +381,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
|
|
|
381
381
|
const message = buildNotification(
|
|
382
382
|
params as unknown as import("./templates").NotifyInput,
|
|
383
383
|
);
|
|
384
|
-
const mid = await sendMsg(message);
|
|
384
|
+
const mid = await sendMsg(message, undefined, "HTML");
|
|
385
385
|
return {
|
|
386
386
|
content: [{ type: "text", text: `Notification sent (id:${mid})` }],
|
|
387
387
|
details: {},
|