@llblab/pi-telegram 0.10.2 → 0.10.4

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.4: Polling Status Resilience Hotfix
4
+
5
+ - `[Polling]` Status-bar updates from the polling loop are now best-effort and no longer crash the extension when a captured session context becomes stale after session reload. Failures are recorded as structured polling runtime events with `phase: "status-update"`. Impact: polling cleanup and retry status updates stay resilient without changing the Telegram API, config, or operator workflow.
6
+ - `[Tests]` Added stale-context polling regressions for startup, cleanup, and retry status updates. Impact: the external PR #43 fix is now covered by maintainer-side tests and kept aligned with local style.
7
+
8
+ ## 0.10.3: Dependency Audit Hotfix
9
+
10
+ - `[Dependencies]` Refreshed the lockfile transitive dependency set to resolve current `protobufjs` / `@protobufjs/utf8` npm audit advisories inherited through development peer installs. Impact: `npm run validate` is green again without changing runtime API or bridge behavior.
11
+
3
12
  ## 0.10.2: Delete Message Port Hotfix
4
13
 
5
14
  - `[ctx.deleteMessage()]` Added `deleteMessage()` to `TelegramSectionContext` and `TelegramSectionCallbackContext`. Extensions can now delete the message that triggered a callback — useful for cleaning up confirmation dialogs after the user makes a choice.
package/README.md CHANGED
@@ -236,6 +236,16 @@ Import from `@llblab/pi-telegram`, call `registerTelegramSection()`, and return
236
236
  - Replies to Telegram prompts are sent as Telegram replies to the source message when possible; if the source message is unavailable, delivery falls back to a normal message.
237
237
  - Temporary inbound Telegram files are cleaned up on later session starts.
238
238
 
239
+ ## Companion Extensions
240
+
241
+ Third-party extensions that integrate with `pi-telegram`:
242
+
243
+ - [`pi-telegram-tool-status`](https://github.com/Timur00Kh/pi-telegram-tool-status) — Live-updating service messages that list tools used by the agent. It keeps one message per Telegram prompt and edits it in place as tools execute.
244
+
245
+ ```bash
246
+ pi install npm:pi-telegram-tool-status
247
+ ```
248
+
239
249
  ## License
240
250
 
241
251
  MIT
package/lib/polling.ts CHANGED
@@ -91,7 +91,8 @@ export function createTelegramPollingActivityReader(
91
91
  return () => isTelegramPollingControllerActive(state);
92
92
  }
93
93
 
94
- export interface TelegramPollingRuntimeDeps<TContext> {
94
+ export interface TelegramPollingRuntimeDeps<TContext>
95
+ extends TelegramRuntimeEventRecorderPort {
95
96
  hasBotToken: () => boolean;
96
97
  getPollingPromise: () => Promise<void> | undefined;
97
98
  setPollingPromise: (promise: Promise<void> | undefined) => void;
@@ -150,6 +151,7 @@ export function createTelegramPollingControllerRuntime<
150
151
  }),
151
152
  updateStatus: deps.updateStatus,
152
153
  createAbortController: deps.createAbortController,
154
+ recordRuntimeEvent: deps.recordRuntimeEvent,
153
155
  });
154
156
  }
155
157
 
@@ -191,6 +193,22 @@ export async function stopTelegramPollingRuntime<TContext>(
191
193
  deps.setPollingPromise(undefined);
192
194
  }
193
195
 
196
+ function updateTelegramPollingStatusSafely<TContext>(
197
+ updateStatus: (ctx: TContext, message?: string) => void,
198
+ ctx: TContext,
199
+ options: {
200
+ message?: string;
201
+ recordRuntimeEvent?: TelegramRuntimeEventRecorderPort["recordRuntimeEvent"];
202
+ } = {},
203
+ ): void {
204
+ try {
205
+ updateStatus(ctx, options.message);
206
+ } catch (error) {
207
+ // The polling loop can outlive the session context it captured.
208
+ options.recordRuntimeEvent?.("polling", error, { phase: "status-update" });
209
+ }
210
+ }
211
+
194
212
  export function startTelegramPollingRuntime<TContext>(
195
213
  ctx: TContext,
196
214
  deps: TelegramPollingRuntimeDeps<TContext>,
@@ -208,10 +226,14 @@ export function startTelegramPollingRuntime<TContext>(
208
226
  const promise = deps.runPollLoop(ctx, controller.signal).finally(() => {
209
227
  deps.setPollingPromise(undefined);
210
228
  deps.setPollingController(undefined);
211
- deps.updateStatus(ctx);
229
+ updateTelegramPollingStatusSafely(deps.updateStatus, ctx, {
230
+ recordRuntimeEvent: deps.recordRuntimeEvent,
231
+ });
212
232
  });
213
233
  deps.setPollingPromise(promise);
214
- deps.updateStatus(ctx);
234
+ updateTelegramPollingStatusSafely(deps.updateStatus, ctx, {
235
+ recordRuntimeEvent: deps.recordRuntimeEvent,
236
+ });
215
237
  }
216
238
 
217
239
  export interface TelegramRuntimeEventRecorderPort {
@@ -281,10 +303,15 @@ export function createTelegramPollLoopRunner<
281
303
  persistConfig: deps.persistConfig,
282
304
  handleUpdate: deps.handleUpdate,
283
305
  onErrorStatus: (message) => {
284
- deps.updateStatus(ctx, message);
306
+ updateTelegramPollingStatusSafely(deps.updateStatus, ctx, {
307
+ message,
308
+ recordRuntimeEvent: deps.recordRuntimeEvent,
309
+ });
285
310
  },
286
311
  onStatusReset: () => {
287
- deps.updateStatus(ctx);
312
+ updateTelegramPollingStatusSafely(deps.updateStatus, ctx, {
313
+ recordRuntimeEvent: deps.recordRuntimeEvent,
314
+ });
288
315
  },
289
316
  sleep,
290
317
  maxUpdateFailures: deps.maxUpdateFailures,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-telegram",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"