@bytesbrains/pi-telegram-bridge 1.1.0 → 1.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytesbrains/pi-telegram-bridge",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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/index.ts CHANGED
@@ -113,6 +113,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
113
113
  if (!res.ok)
114
114
  return {
115
115
  content: [{ type: "text", text: "Could not reach Telegram." }],
116
+ details: { message: "" },
116
117
  isError: true,
117
118
  };
118
119
 
@@ -132,6 +133,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
132
133
  if (!data.ok)
133
134
  return {
134
135
  content: [{ type: "text", text: "Telegram API error." }],
136
+ details: { message: "" },
135
137
  isError: true,
136
138
  };
137
139
 
@@ -157,7 +159,10 @@ export default function telegramBridge(pi: ExtensionAPI) {
157
159
  };
158
160
  }
159
161
  }
160
- return { content: [{ type: "text", text: "No new messages." }] };
162
+ return {
163
+ content: [{ type: "text", text: "No new messages." }],
164
+ details: { message: "" },
165
+ };
161
166
  } catch (e: unknown) {
162
167
  return {
163
168
  content: [
@@ -166,6 +171,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
166
171
  text: `Failed: ${e instanceof Error ? e.message : e}`,
167
172
  },
168
173
  ],
174
+ details: { message: "" },
169
175
  isError: true,
170
176
  };
171
177
  }
@@ -181,7 +187,10 @@ export default function telegramBridge(pi: ExtensionAPI) {
181
187
  async execute(_id: string, params: { message: string }) {
182
188
  try {
183
189
  const mid = await sendMsg(params.message);
184
- return { content: [{ type: "text", text: `Sent (id:${mid})` }] };
190
+ return {
191
+ content: [{ type: "text", text: `Sent (id:${mid})` }],
192
+ details: {},
193
+ };
185
194
  } catch (e: unknown) {
186
195
  return {
187
196
  content: [
@@ -190,6 +199,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
190
199
  text: `Failed: ${e instanceof Error ? e.message : e}`,
191
200
  },
192
201
  ],
202
+ details: {},
193
203
  isError: true,
194
204
  };
195
205
  }
@@ -226,12 +236,12 @@ export default function telegramBridge(pi: ExtensionAPI) {
226
236
  content: [
227
237
  { type: "text", text: "Timeout — proceeding autonomously" },
228
238
  ],
229
- details: { timedOut: true },
239
+ details: { timedOut: true, answer: "" },
230
240
  };
231
241
  }
232
242
  return {
233
243
  content: [{ type: "text", text: `Reply: "${reply}"` }],
234
- details: { answer: reply },
244
+ details: { timedOut: false, answer: reply },
235
245
  };
236
246
  } catch (e: unknown) {
237
247
  return {
@@ -241,6 +251,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
241
251
  text: `Failed: ${e instanceof Error ? e.message : e}`,
242
252
  },
243
253
  ],
254
+ details: { timedOut: false, answer: "" },
244
255
  isError: true,
245
256
  };
246
257
  }
@@ -301,6 +312,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
301
312
  timedOut: true,
302
313
  action: "abort",
303
314
  command: params.command,
315
+ choice: "",
304
316
  },
305
317
  };
306
318
  }
@@ -340,6 +352,12 @@ export default function telegramBridge(pi: ExtensionAPI) {
340
352
  text: `Failed: ${e instanceof Error ? e.message : e}`,
341
353
  },
342
354
  ],
355
+ details: {
356
+ timedOut: false,
357
+ action: "",
358
+ command: "",
359
+ choice: "",
360
+ },
343
361
  isError: true,
344
362
  };
345
363
  }
@@ -398,6 +416,7 @@ export default function telegramBridge(pi: ExtensionAPI) {
398
416
  text: "Not configured. Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID.",
399
417
  },
400
418
  ],
419
+ details: {},
401
420
  };
402
421
  }
403
422
  try {
@@ -411,10 +430,12 @@ export default function telegramBridge(pi: ExtensionAPI) {
411
430
  text: `Active. Bot: @${r.result.username} (listener: ${listenerAbort ? "🟢 running" : "🔴 stopped"})`,
412
431
  },
413
432
  ],
433
+ details: {},
414
434
  };
415
435
  } catch {
416
436
  return {
417
437
  content: [{ type: "text", text: "Token set but unreachable." }],
438
+ details: {},
418
439
  };
419
440
  }
420
441
  },