@llblab/pi-telegram 0.10.0 → 0.10.1
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/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/docs/extension-sections.md +36 -0
- package/lib/extension-sections.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.1: Navigation Abstraction Hotfix
|
|
4
|
+
|
|
5
|
+
- `[ctx.open()]` Removed automatic Back-row prepend from `ctx.open()`. `ctx.open()` sends a new message into the chat — a Back button makes no sense outside the menu. `ctx.edit()` still auto-prepends the correct navigation row for in-menu views.
|
|
6
|
+
- `[Platform Docs]` Extended `docs/extension-sections.md` with a dedicated section on sending interactive messages into chat via `ctx.open()`: confirmation dialogs, approve/deny gates, and extension-driven button flows that live outside the menu hierarchy.
|
|
7
|
+
|
|
3
8
|
## 0.10.0: Extension Sections Platform
|
|
4
9
|
|
|
5
10
|
- `[Extension Sections]` Implemented the Telegram Extension Sections platform: extensions can register structured UI sections that appear in the main Telegram application menu and Settings submenu without owning a second bot poller.
|
package/README.md
CHANGED
|
@@ -209,7 +209,7 @@ Unknown inline-button callbacks are forwarded to π as `[callback] <data>` when
|
|
|
209
209
|
|
|
210
210
|
Ordinary pi extensions can register structured UI sections that appear in the main Telegram menu and Settings submenu without owning a second poller. Each section gets a narrow typed context with `edit`, `open`, `enqueuePrompt`, `answerCallback`, and `callbackData()` — enough to build interactive Telegram-native surfaces while `pi-telegram` owns transport, callback routing, navigation hierarchy, and diagnostics.
|
|
211
211
|
|
|
212
|
-
Import from `@llblab/pi-telegram`, call `registerTelegramSection()`, and return a disposer on shutdown. See [`@llblab/pi-telegram-extension-demo`](https://github.com/llblab/pi-telegram-extension-demo) for a working reference and the [Extension Sections Standard](./docs/extension-sections.md) for the full contract.
|
|
212
|
+
Import from `@llblab/pi-telegram`, call `registerTelegramSection()`, and return a disposer on shutdown. Sections can send interactive messages directly into the chat via `ctx.open()` — confirmation dialogs, approve/deny gates, and multi-step forms live outside the menu hierarchy while callbacks route through the same typed handler. See [`@llblab/pi-telegram-extension-demo`](https://github.com/llblab/pi-telegram-extension-demo) for a working reference and the [Extension Sections Standard](./docs/extension-sections.md) for the full contract.
|
|
213
213
|
|
|
214
214
|
### Proactive push
|
|
215
215
|
|
|
@@ -298,6 +298,42 @@ Context ports are intentionally narrow. Sections **cannot**:
|
|
|
298
298
|
|
|
299
299
|
Add capability-specific ports only when the first real extension proves the need.
|
|
300
300
|
|
|
301
|
+
### Interactive messages in chat (`ctx.open`)
|
|
302
|
+
|
|
303
|
+
`ctx.open()` sends a new message directly into the Telegram chat — outside the menu hierarchy. No Back row is prepended. Use it for extension-driven interactions that live in the conversation:
|
|
304
|
+
|
|
305
|
+
- Confirmation dialogs ("Delete file.txt?")
|
|
306
|
+
- Approve/deny gates ("Allow tool execution?")
|
|
307
|
+
- Multi-step forms that should not be menu-bound
|
|
308
|
+
- Status reports with action buttons
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
handleCallback: async (ctx) => {
|
|
312
|
+
if (ctx.action === "delete-file") {
|
|
313
|
+
await ctx.open({
|
|
314
|
+
text: `<b>Delete ${ctx.payload}?</b>\n\nThis cannot be undone.`,
|
|
315
|
+
parseMode: "html",
|
|
316
|
+
replyMarkup: {
|
|
317
|
+
inline_keyboard: [[
|
|
318
|
+
{ text: "✅ Yes, delete",
|
|
319
|
+
callback_data: ctx.callbackData("confirm-delete", ctx.payload) },
|
|
320
|
+
{ text: "❌ Cancel",
|
|
321
|
+
callback_data: ctx.callbackData("cancel") },
|
|
322
|
+
]],
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
return "handled";
|
|
326
|
+
}
|
|
327
|
+
if (ctx.action === "confirm-delete") {
|
|
328
|
+
// actual deletion logic
|
|
329
|
+
await ctx.answerCallback(`Deleted: ${ctx.payload}`);
|
|
330
|
+
return "handled";
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Callbacks from chat buttons route through the same `handleCallback` — the same `ctx.callbackData()` works regardless of where the button lives. The extension owns its callback namespace; the bridge owns transport.
|
|
336
|
+
|
|
301
337
|
## 10. Telegram Bot API Integration
|
|
302
338
|
|
|
303
339
|
### `callback_data` contract
|
|
@@ -157,7 +157,7 @@ function buildTelegramSectionContext(
|
|
|
157
157
|
chatId,
|
|
158
158
|
view.text,
|
|
159
159
|
view.parseMode ?? "html",
|
|
160
|
-
|
|
160
|
+
view.replyMarkup ?? { inline_keyboard: [] },
|
|
161
161
|
)
|
|
162
162
|
.then(() => {}),
|
|
163
163
|
enqueuePrompt: deps.enqueuePrompt,
|
|
@@ -203,7 +203,7 @@ function buildTelegramSectionCallbackContext(
|
|
|
203
203
|
chatId,
|
|
204
204
|
view.text,
|
|
205
205
|
view.parseMode ?? "html",
|
|
206
|
-
|
|
206
|
+
view.replyMarkup ?? { inline_keyboard: [] },
|
|
207
207
|
)
|
|
208
208
|
.then(() => {}),
|
|
209
209
|
enqueuePrompt: deps.enqueuePrompt,
|