@llblab/pi-kit 0.1.8 → 0.1.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/node_modules/@llblab/pi-grow-loop/AGENTS.md +1 -1
  4. package/node_modules/@llblab/pi-grow-loop/CHANGELOG.md +6 -0
  5. package/node_modules/@llblab/pi-grow-loop/README.md +2 -1
  6. package/node_modules/@llblab/pi-grow-loop/index.ts +11 -2
  7. package/node_modules/@llblab/pi-grow-loop/package.json +1 -1
  8. package/node_modules/@llblab/pi-telegram/AGENTS.md +4 -4
  9. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +34 -0
  10. package/node_modules/@llblab/pi-telegram/README.md +3 -3
  11. package/node_modules/@llblab/pi-telegram/api/voice.ts +0 -1
  12. package/node_modules/@llblab/pi-telegram/docs/architecture.md +5 -5
  13. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +2 -2
  14. package/node_modules/@llblab/pi-telegram/docs/outbound.md +2 -3
  15. package/node_modules/@llblab/pi-telegram/docs/public-api.md +4 -13
  16. package/node_modules/@llblab/pi-telegram/docs/ui-style.md +22 -8
  17. package/node_modules/@llblab/pi-telegram/docs/voice.md +9 -37
  18. package/node_modules/@llblab/pi-telegram/index.ts +20 -7
  19. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +49 -13
  20. package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +127 -25
  21. package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +17 -4
  22. package/node_modules/@llblab/pi-telegram/lib/bus.ts +56 -2
  23. package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +65 -4
  24. package/node_modules/@llblab/pi-telegram/lib/commands.ts +122 -28
  25. package/node_modules/@llblab/pi-telegram/lib/config.ts +10 -7
  26. package/node_modules/@llblab/pi-telegram/lib/journal.ts +2 -9
  27. package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +20 -18
  28. package/node_modules/@llblab/pi-telegram/lib/locks.ts +6 -1
  29. package/node_modules/@llblab/pi-telegram/lib/menu-queue.ts +15 -4
  30. package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +15 -11
  31. package/node_modules/@llblab/pi-telegram/lib/menu.ts +10 -7
  32. package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +3 -18
  33. package/node_modules/@llblab/pi-telegram/lib/prompts.ts +2 -2
  34. package/node_modules/@llblab/pi-telegram/lib/queue.ts +49 -12
  35. package/node_modules/@llblab/pi-telegram/lib/routing.ts +5 -2
  36. package/node_modules/@llblab/pi-telegram/lib/status.ts +4 -2
  37. package/node_modules/@llblab/pi-telegram/lib/sync.ts +17 -0
  38. package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +91 -45
  39. package/node_modules/@llblab/pi-telegram/lib/threads.ts +5 -0
  40. package/node_modules/@llblab/pi-telegram/lib/updates.ts +17 -9
  41. package/node_modules/@llblab/pi-telegram/lib/voice.ts +7 -31
  42. package/node_modules/@llblab/pi-telegram/package.json +1 -1
  43. package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/SKILL.md +1 -1
  44. package/package.json +3 -3
@@ -1782,6 +1782,7 @@ export interface TelegramUpdateWorkerRuntimeDeps<TContext> {
1782
1782
  classifyExecutionFailure?: (
1783
1783
  error: unknown,
1784
1784
  ) => TelegramUpdateExecutionFailureClassification;
1785
+ settleTerminalExecutionFailure?: (error: unknown) => Promise<boolean>;
1785
1786
  scheduleRetry?: (callback: () => void, delayMs: number) => unknown;
1786
1787
  cancelRetry?: (handle: unknown) => void;
1787
1788
  batchSize?: number;
@@ -4583,11 +4584,11 @@ export function createTelegramUpdateAdmissionLifecycleRuntime<TContext>(
4583
4584
  try {
4584
4585
  deps.recordRuntimeEvent?.(
4585
4586
  "inbound-worker",
4586
- "Recovered queued authority from a confirmed-dead process.",
4587
+ "Discarded session-owned queue authority from a confirmed-dead process.",
4587
4588
  {
4588
- phase: "dead-queue-owner-recovery",
4589
+ phase: "dead-queue-owner-cleanup",
4589
4590
  receiptId,
4590
- recoveredUpdateCount: result.recoveredUpdateIds.length,
4591
+ removedUpdateCount: result.recoveredUpdateIds.length,
4591
4592
  },
4592
4593
  );
4593
4594
  } catch {
@@ -4833,13 +4834,20 @@ export function createTelegramUpdateAdmissionWorkerRuntime<
4833
4834
  });
4834
4835
  worker = createTelegramUpdateWorkerRuntime({
4835
4836
  ...deps,
4836
- executeUpdate: (update, ctx, signal) => {
4837
+ async executeUpdate(update, ctx, signal) {
4837
4838
  const typedUpdate = update as TUpdate;
4838
- return executeUpdate(
4839
- deps.prepareUpdateForExecution?.(typedUpdate) ?? typedUpdate,
4840
- ctx,
4841
- signal,
4842
- );
4839
+ try {
4840
+ return await executeUpdate(
4841
+ deps.prepareUpdateForExecution?.(typedUpdate) ?? typedUpdate,
4842
+ ctx,
4843
+ signal,
4844
+ );
4845
+ } catch (error) {
4846
+ if (await deps.settleTerminalExecutionFailure?.(error)) {
4847
+ return { kind: "complete" };
4848
+ }
4849
+ throw error;
4850
+ }
4843
4851
  },
4844
4852
  });
4845
4853
  return worker;
@@ -38,15 +38,9 @@ function getNextAvailableProviderId<T>(
38
38
  return id;
39
39
  }
40
40
 
41
- export type TelegramVoiceReplyMode = "hidden" | "mirror" | "always";
41
+ export type TelegramVoiceReplyMode = "manual" | "mirror" | "always";
42
42
 
43
- export type TelegramVoiceSynthesisProviderResult =
44
- | string
45
- | {
46
- audioPath: string;
47
- transcriptText?: string;
48
- }
49
- | undefined;
43
+ export type TelegramVoiceSynthesisProviderResult = string | undefined;
50
44
 
51
45
  export interface TelegramVoiceTurnView {
52
46
  voiceReplyPreferred?: boolean;
@@ -215,7 +209,7 @@ export function clearTelegramVoiceTranscriptionProviders(): void {
215
209
  // --- Voice Reply Modes ---
216
210
 
217
211
  export const TELEGRAM_VOICE_REPLY_MODES = [
218
- "hidden",
212
+ "manual",
219
213
  "mirror",
220
214
  "always",
221
215
  ] as const;
@@ -224,33 +218,15 @@ export const TELEGRAM_VOICE_REPLY_MODES = [
224
218
  * Returns the active voice reply mode for the current session.
225
219
  *
226
220
  * Pi-telegram owns reply-mode policy through telegram.json. If
227
- * config.voice.replyMode is missing, invalid, or legacy `manual`, the effective
228
- * mode is hidden.
221
+ * config.voice.replyMode is missing, invalid, or legacy `hidden`, the effective
222
+ * mode is manual.
229
223
  */
230
224
  export function getTelegramVoiceReplyMode(config?: {
231
225
  voice?: { replyMode?: string };
232
226
  }): TelegramVoiceReplyMode {
233
227
  const configMode = config?.voice?.replyMode;
234
- if (
235
- configMode &&
236
- (TELEGRAM_VOICE_REPLY_MODES as readonly string[]).includes(configMode)
237
- ) {
238
- return configMode as TelegramVoiceReplyMode;
239
- }
240
- return "hidden";
241
- }
242
-
243
- /**
244
- * Returns whether the user wants the voice synthesis provider's transcript attached
245
- * as a caption on the voice message.
246
- *
247
- * Reads from `config.voice.sendTranscript`.
248
- * Default: false (no transcript text sent at all).
249
- */
250
- export function getTelegramVoiceSendTranscript(config?: {
251
- voice?: { sendTranscript?: boolean };
252
- }): boolean {
253
- return !!config?.voice?.sendTranscript;
228
+ if (configMode === "mirror" || configMode === "always") return configMode;
229
+ return "manual";
254
230
  }
255
231
 
256
232
  // --- Voice Turn Helpers ---
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-telegram",
3
- "version": "0.37.1",
3
+ "version": "0.39.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -122,7 +122,7 @@ Prefer no-code command-template configuration in `telegram.json` before adding a
122
122
  - `outboundHandlers` transforms final replies.
123
123
  - Voice transcription handlers can match `type: "voice"` or `mime: "audio/*"`; stdout becomes `[outputs]`.
124
124
 
125
- When asked to configure voice rather than merely operate it, follow the provider-neutral contracts in `docs/voice.md`, `docs/inbound.md`, `docs/outbound.md`, and `docs/command-templates.md` from the pi-telegram package or repository. Inspect the available Skill catalog and trusted local executables for STT, TTS, and media conversion capabilities; check only whether required environment variables exist, never reveal their values. Preserve unrelated `telegram.json` fields, order multiple matching inbound handlers as fallbacks, require OGG/Opus output for native voice delivery, and validate each stage before a live Telegram smoke test. Keep `voice.replyMode` at its existing value unless the user requests a policy change: the default `hidden` mode is fully functional because explicit top-level `telegram_voice` actions still use the configured synthesis pipeline.
125
+ When asked to configure voice rather than merely operate it, follow the provider-neutral contracts in `docs/voice.md`, `docs/inbound.md`, `docs/outbound.md`, and `docs/command-templates.md` from the pi-telegram package or repository. Inspect the available Skill catalog and trusted local executables for STT, TTS, and media conversion capabilities; check only whether required environment variables exist, never reveal their values. Preserve unrelated `telegram.json` fields, order multiple matching inbound handlers as fallbacks, require OGG/Opus output for native voice delivery, and validate each stage before a live Telegram smoke test. Keep `voice.replyMode` at its existing value unless the user requests a policy change: the default `manual` mode is fully functional because explicit top-level `telegram_voice` actions still use the configured synthesis pipeline.
126
126
 
127
127
  When configuration is insufficient, use documented `@llblab/pi-telegram/*` public API subpaths. Never import package-private `lib/*`, start another polling loop, or bypass bridge ownership with raw Bot API access.
128
128
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-kit",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "@llblab/pi-actors": "0.50.0",
44
44
  "@llblab/pi-codex-usage": "0.9.3",
45
- "@llblab/pi-grow-loop": "0.7.2",
46
- "@llblab/pi-telegram": "0.37.1"
45
+ "@llblab/pi-grow-loop": "0.7.3",
46
+ "@llblab/pi-telegram": "0.39.3"
47
47
  },
48
48
  "bundledDependencies": [
49
49
  "@llblab/pi-actors",