@llblab/pi-telegram 0.52.2 → 0.53.0

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 (204) hide show
  1. package/AGENTS.md +9 -7
  2. package/BACKLOG.md +1 -18
  3. package/CHANGELOG.md +11 -0
  4. package/README.md +7 -11
  5. package/api/commands.ts +3 -0
  6. package/dist/api/commands.d.ts +1 -1
  7. package/dist/lib/activity-verbosity.d.ts +1 -5
  8. package/dist/lib/activity-verbosity.js +15 -42
  9. package/dist/lib/activity.d.ts +9 -0
  10. package/dist/lib/activity.js +39 -10
  11. package/dist/lib/agent-messages.js +7 -3
  12. package/dist/lib/bindings.d.ts +43 -5
  13. package/dist/lib/bindings.js +163 -20
  14. package/dist/lib/bus-api.d.ts +12 -0
  15. package/dist/lib/bus-api.js +182 -79
  16. package/dist/lib/bus-follower.d.ts +111 -31
  17. package/dist/lib/bus-follower.js +1324 -359
  18. package/dist/lib/bus-leader.d.ts +41 -91
  19. package/dist/lib/bus-leader.js +969 -637
  20. package/dist/lib/bus-transport.js +16 -9
  21. package/dist/lib/bus.d.ts +215 -18
  22. package/dist/lib/bus.js +1048 -327
  23. package/dist/lib/channel-posts.d.ts +5 -0
  24. package/dist/lib/channel-posts.js +434 -261
  25. package/dist/lib/command-templates.d.ts +26 -5
  26. package/dist/lib/command-templates.js +92 -176
  27. package/dist/lib/commands.d.ts +168 -82
  28. package/dist/lib/commands.js +1409 -291
  29. package/dist/lib/config.d.ts +1 -8
  30. package/dist/lib/config.js +34 -76
  31. package/dist/lib/delivery.d.ts +2 -2
  32. package/dist/lib/delivery.js +16 -16
  33. package/dist/lib/extension.js +639 -171
  34. package/dist/lib/generative-app-worker.mjs +19 -7
  35. package/dist/lib/generative-apps.d.ts +0 -5
  36. package/dist/lib/generative-apps.js +61 -49
  37. package/dist/lib/inbound.d.ts +5 -0
  38. package/dist/lib/inbound.js +35 -59
  39. package/dist/lib/journal.d.ts +33 -3
  40. package/dist/lib/journal.js +2063 -782
  41. package/dist/lib/lifecycle.d.ts +2 -6
  42. package/dist/lib/lifecycle.js +75 -58
  43. package/dist/lib/locks.d.ts +29 -3
  44. package/dist/lib/locks.js +289 -108
  45. package/dist/lib/logging.js +50 -14
  46. package/dist/lib/media.d.ts +22 -1
  47. package/dist/lib/media.js +46 -28
  48. package/dist/lib/menu-model.d.ts +19 -5
  49. package/dist/lib/menu-model.js +53 -11
  50. package/dist/lib/menu-queue.d.ts +5 -4
  51. package/dist/lib/menu-queue.js +45 -63
  52. package/dist/lib/menu-settings.d.ts +5 -4
  53. package/dist/lib/menu-settings.js +114 -78
  54. package/dist/lib/menu-status.d.ts +1 -1
  55. package/dist/lib/menu-status.js +8 -25
  56. package/dist/lib/menu-thinking.d.ts +6 -1
  57. package/dist/lib/menu-thinking.js +14 -21
  58. package/dist/lib/menu.d.ts +8 -61
  59. package/dist/lib/menu.js +92 -164
  60. package/dist/lib/model.d.ts +1 -1
  61. package/dist/lib/model.js +2 -16
  62. package/dist/lib/outbound-attachments.d.ts +6 -27
  63. package/dist/lib/outbound-attachments.js +45 -38
  64. package/dist/lib/outbound-buttons.js +22 -16
  65. package/dist/lib/outbound-markup.d.ts +0 -2
  66. package/dist/lib/outbound-markup.js +51 -64
  67. package/dist/lib/outbound-voice.js +6 -3
  68. package/dist/lib/outbound.d.ts +6 -6
  69. package/dist/lib/outbound.js +61 -51
  70. package/dist/lib/ownership.js +6 -2
  71. package/dist/lib/paths.d.ts +5 -0
  72. package/dist/lib/paths.js +37 -21
  73. package/dist/lib/pi.d.ts +2 -0
  74. package/dist/lib/pi.js +8 -1
  75. package/dist/lib/polling.d.ts +21 -37
  76. package/dist/lib/polling.js +59 -50
  77. package/dist/lib/preview.js +39 -19
  78. package/dist/lib/process-identity.d.ts +24 -0
  79. package/dist/lib/process-identity.js +133 -0
  80. package/dist/lib/prompts.js +2 -7
  81. package/dist/lib/queue.d.ts +14 -16
  82. package/dist/lib/queue.js +249 -126
  83. package/dist/lib/recovery.d.ts +2 -83
  84. package/dist/lib/recovery.js +20 -274
  85. package/dist/lib/replies.d.ts +16 -24
  86. package/dist/lib/replies.js +99 -116
  87. package/dist/lib/routing.d.ts +120 -7
  88. package/dist/lib/routing.js +4667 -1152
  89. package/dist/lib/runtime.d.ts +1 -11
  90. package/dist/lib/sections.d.ts +4 -29
  91. package/dist/lib/sections.js +7 -20
  92. package/dist/lib/skills.js +4 -3
  93. package/dist/lib/status.js +86 -57
  94. package/dist/lib/sync.d.ts +1 -3
  95. package/dist/lib/sync.js +67 -43
  96. package/dist/lib/target.d.ts +4 -0
  97. package/dist/lib/target.js +18 -0
  98. package/dist/lib/telegram-api.d.ts +18 -13
  99. package/dist/lib/telegram-api.js +148 -53
  100. package/dist/lib/text-groups.js +4 -39
  101. package/dist/lib/thread-cleanup-manager.d.ts +6 -27
  102. package/dist/lib/thread-cleanup-manager.js +369 -186
  103. package/dist/lib/thread-display.d.ts +1 -2
  104. package/dist/lib/thread-display.js +58 -38
  105. package/dist/lib/thread-naming.d.ts +28 -8
  106. package/dist/lib/thread-naming.js +175 -66
  107. package/dist/lib/thread-reconciler.d.ts +42 -16
  108. package/dist/lib/thread-reconciler.js +90 -50
  109. package/dist/lib/threads.d.ts +82 -20
  110. package/dist/lib/threads.js +2247 -855
  111. package/dist/lib/time-injection.js +1 -2
  112. package/dist/lib/turns.js +1 -19
  113. package/dist/lib/updates.d.ts +169 -80
  114. package/dist/lib/updates.js +2418 -641
  115. package/dist/lib/voice.d.ts +7 -22
  116. package/dist/lib/voice.js +7 -22
  117. package/dist/lib/wire.js +1 -1
  118. package/dist/lib/workspace-admission.d.ts +3 -1
  119. package/dist/lib/workspace-admission.js +425 -211
  120. package/dist/lib/workspace-identity.js +8 -13
  121. package/dist/lib/workspace-retirement.d.ts +1 -1
  122. package/dist/lib/workspace-retirement.js +328 -140
  123. package/dist/lib/workspace-slots.js +8 -4
  124. package/dist/package.json +1 -1
  125. package/docs/architecture.md +31 -29
  126. package/docs/inbound.md +1 -1
  127. package/docs/multi-instance-bus.md +15 -3
  128. package/docs/outbound.md +1 -1
  129. package/docs/public-api.md +29 -1
  130. package/docs/ui-style.md +25 -8
  131. package/lib/activity-verbosity.ts +59 -82
  132. package/lib/activity.ts +146 -102
  133. package/lib/agent-messages.ts +12 -5
  134. package/lib/bindings.ts +389 -82
  135. package/lib/bus-api.ts +263 -102
  136. package/lib/bus-follower.ts +2440 -601
  137. package/lib/bus-leader.ts +2209 -1290
  138. package/lib/bus-transport.ts +46 -12
  139. package/lib/bus.ts +1673 -444
  140. package/lib/channel-posts.ts +848 -327
  141. package/lib/command-templates.ts +152 -265
  142. package/lib/commands.ts +2398 -555
  143. package/lib/config.ts +177 -170
  144. package/lib/delivery.ts +41 -29
  145. package/lib/extension.ts +1206 -433
  146. package/lib/generative-app-worker.mjs +19 -7
  147. package/lib/generative-apps.ts +324 -211
  148. package/lib/inbound.ts +95 -97
  149. package/lib/journal.ts +5311 -1763
  150. package/lib/keyboard.ts +1 -3
  151. package/lib/lifecycle.ts +128 -78
  152. package/lib/locks.ts +677 -203
  153. package/lib/logging.ts +147 -58
  154. package/lib/media.ts +82 -43
  155. package/lib/menu-model.ts +85 -18
  156. package/lib/menu-queue.ts +88 -129
  157. package/lib/menu-settings.ts +260 -155
  158. package/lib/menu-status.ts +20 -60
  159. package/lib/menu-thinking.ts +41 -56
  160. package/lib/menu.ts +112 -285
  161. package/lib/model.ts +8 -22
  162. package/lib/outbound-attachments.ts +156 -125
  163. package/lib/outbound-buttons.ts +76 -49
  164. package/lib/outbound-markup.ts +96 -94
  165. package/lib/outbound-voice.ts +33 -27
  166. package/lib/outbound.ts +125 -125
  167. package/lib/ownership.ts +19 -10
  168. package/lib/paths.ts +148 -49
  169. package/lib/pi.ts +35 -15
  170. package/lib/polling.ts +144 -147
  171. package/lib/preview.ts +93 -40
  172. package/lib/process-identity.ts +164 -0
  173. package/lib/prompts.ts +4 -11
  174. package/lib/queue.ts +511 -300
  175. package/lib/recovery.ts +50 -454
  176. package/lib/rendering.ts +1 -3
  177. package/lib/replies.ts +248 -209
  178. package/lib/routing.ts +8509 -2186
  179. package/lib/runtime.ts +1 -12
  180. package/lib/sections.ts +24 -89
  181. package/lib/setup.ts +1 -3
  182. package/lib/skills.ts +9 -4
  183. package/lib/status.ts +215 -110
  184. package/lib/sync.ts +448 -361
  185. package/lib/target.ts +22 -3
  186. package/lib/telegram-api.ts +302 -127
  187. package/lib/text-groups.ts +5 -39
  188. package/lib/thread-cleanup-manager.ts +833 -331
  189. package/lib/thread-display.ts +213 -97
  190. package/lib/thread-naming.ts +232 -87
  191. package/lib/thread-reconciler.ts +155 -72
  192. package/lib/threads.ts +5318 -1845
  193. package/lib/time-injection.ts +1 -4
  194. package/lib/turns.ts +15 -28
  195. package/lib/updates.ts +5184 -1612
  196. package/lib/voice.ts +7 -35
  197. package/lib/wire.ts +1 -1
  198. package/lib/workspace-admission.ts +996 -416
  199. package/lib/workspace-identity.ts +14 -17
  200. package/lib/workspace-retirement.ts +878 -376
  201. package/lib/workspace-slots.ts +22 -13
  202. package/package.json +1 -1
  203. package/scripts/check-downgrade.mjs +0 -472
  204. package/scripts/measure-workspace.mjs +0 -108
@@ -1,21 +1,10 @@
1
1
  /**
2
- * Voice Domain
3
- * Zones: telegram, voice
4
- *
5
- * This module is the single owner of all Voice-specific coordination logic:
6
- * - Voice reply policy (mirror / voice / manual) via getTelegramVoiceReplyMode()
7
- * - Voice turn tagging (voiceReplyPreferred / voiceReplyRequired)
8
- * - Voice-specific prompt contributions for the LLM
9
- * - Voice synthesis provider registry (registration + policy/prompt hooks)
10
- * - Voice markup parsing (planTelegramVoiceReply + helpers)
11
- * - Voice suppression helpers (isVoiceTurn, shouldSuppressPreviewForVoice)
12
- *
13
- * Separation of concerns:
14
- * - All decision logic and domain rules live here.
15
- * - Actual delivery (sending the audio via Telegram) stays in outbound.ts.
16
- *
17
- * Keeps voice policy, turn tagging, prompt contributions, and markup helpers
18
- * out of the queue, preview, turn-building, and delivery domains.
2
+ * Telegram voice reply policy and provider registries
3
+ * Zones: telegram, voice, pi agent prompts
4
+ * Owns: voice reply modes (manual / mirror / always), voice turn flags and preview suppression,
5
+ * voice prompt contributions, and the process-global synthesis/transcription provider registries.
6
+ * Excludes: voice markup parsing (outbound-markup), audio generation and Telegram delivery
7
+ * (outbound, outbound-voice), queue, preview lifecycle and turn building.
19
8
  */
20
9
  export type TelegramVoiceReplyMode = "manual" | "mirror" | "always";
21
10
  export type TelegramVoiceSynthesisProviderResult = string | undefined;
@@ -110,8 +99,4 @@ export declare function computeVoicePromptContribution(voiceReplyMode: TelegramV
110
99
  * Returns true if the current turn should not show a text preview
111
100
  * (e.g. because it's a voice reply).
112
101
  */
113
- export declare function shouldSuppressPreviewForVoice(turn: {
114
- voiceReplyPreferred?: boolean;
115
- voiceReplyRequired?: boolean;
116
- } | null | undefined): boolean;
117
- export { normalizeMarkdownAfterVoiceExtraction, planTelegramVoiceReply, stripTelegramCommentMarkupForDelivery, stripTelegramCommentMarkupForPreview, stripTelegramVoiceMarkupForPreview, } from "./outbound-markup.ts";
102
+ export declare const shouldSuppressPreviewForVoice: typeof isVoiceTurn;
package/dist/lib/voice.js CHANGED
@@ -1,21 +1,10 @@
1
1
  /**
2
- * Voice Domain
3
- * Zones: telegram, voice
4
- *
5
- * This module is the single owner of all Voice-specific coordination logic:
6
- * - Voice reply policy (mirror / voice / manual) via getTelegramVoiceReplyMode()
7
- * - Voice turn tagging (voiceReplyPreferred / voiceReplyRequired)
8
- * - Voice-specific prompt contributions for the LLM
9
- * - Voice synthesis provider registry (registration + policy/prompt hooks)
10
- * - Voice markup parsing (planTelegramVoiceReply + helpers)
11
- * - Voice suppression helpers (isVoiceTurn, shouldSuppressPreviewForVoice)
12
- *
13
- * Separation of concerns:
14
- * - All decision logic and domain rules live here.
15
- * - Actual delivery (sending the audio via Telegram) stays in outbound.ts.
16
- *
17
- * Keeps voice policy, turn tagging, prompt contributions, and markup helpers
18
- * out of the queue, preview, turn-building, and delivery domains.
2
+ * Telegram voice reply policy and provider registries
3
+ * Zones: telegram, voice, pi agent prompts
4
+ * Owns: voice reply modes (manual / mirror / always), voice turn flags and preview suppression,
5
+ * voice prompt contributions, and the process-global synthesis/transcription provider registries.
6
+ * Excludes: voice markup parsing (outbound-markup), audio generation and Telegram delivery
7
+ * (outbound, outbound-voice), queue, preview lifecycle and turn building.
19
8
  */
20
9
  const VOICE_SYNTHESIS_PROVIDER_REGISTRY_KEY = "__piTelegramVoiceSynthesisProviders__";
21
10
  const VOICE_TRANSCRIPTION_PROVIDER_REGISTRY_KEY = "__piTelegramVoiceTranscriptionProviders__";
@@ -167,8 +156,4 @@ export function computeVoicePromptContribution(voiceReplyMode, files, rawText) {
167
156
  * Returns true if the current turn should not show a text preview
168
157
  * (e.g. because it's a voice reply).
169
158
  */
170
- export function shouldSuppressPreviewForVoice(turn) {
171
- return !!(turn?.voiceReplyPreferred || turn?.voiceReplyRequired);
172
- }
173
- // --- Outbound Markup Re-Exports ---
174
- export { normalizeMarkdownAfterVoiceExtraction, planTelegramVoiceReply, stripTelegramCommentMarkupForDelivery, stripTelegramCommentMarkupForPreview, stripTelegramVoiceMarkupForPreview, } from "./outbound-markup.js";
159
+ export const shouldSuppressPreviewForVoice = isVoiceTurn;
package/dist/lib/wire.js CHANGED
@@ -11,7 +11,7 @@ export function isWireRecord(value) {
11
11
  /** Checks only own enumerable string keys, not required, inherited or symbol fields. */
12
12
  export function hasOnlyWireKeys(value, allowedKeys) {
13
13
  const allowed = new Set(allowedKeys);
14
- return Object.keys(value).every(key => allowed.has(key));
14
+ return Object.keys(value).every((key) => allowed.has(key));
15
15
  }
16
16
  export function isNonEmptyWireString(value) {
17
17
  return typeof value === "string" && value.length > 0;
@@ -5,7 +5,7 @@
5
5
  * Excludes journal/API operations, retirement policy, and binding persistence
6
6
  */
7
7
  import { type PathLike } from "node:fs";
8
- import { type TelegramProcessLiveness } from "./bus.ts";
8
+ import { type TelegramProcessLiveness } from "./process-identity.ts";
9
9
  import { type TelegramTarget } from "./target.ts";
10
10
  export interface TelegramWorkspaceAdmissionOwner {
11
11
  processId: number;
@@ -256,6 +256,8 @@ export declare function createTelegramWorkspaceAdmissionRuntimeBinding(input: {
256
256
  getStatePath: () => string;
257
257
  getPath?: never;
258
258
  })): TelegramWorkspaceAdmissionRuntimeBinding;
259
+ /** Stable admission-scope identity used by leases and admission-gated journal operations. */
260
+ export declare function getTelegramWorkspaceAdmissionScopeKey(scope: TelegramWorkspaceAdmissionScope): string;
259
261
  export declare function runWithTelegramWorkspaceAdmissions<T>(input: {
260
262
  ledger: Pick<TelegramWorkspaceAdmissionLedger, "acquireAdmission" | "releaseAdmission">;
261
263
  operationId: string;