@llblab/pi-kit 0.29.2 → 0.30.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 (208) hide show
  1. package/BACKLOG.md +2 -1
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +2 -2
  4. package/node_modules/@llblab/pi-telegram/AGENTS.md +9 -7
  5. package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -18
  6. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +11 -0
  7. package/node_modules/@llblab/pi-telegram/README.md +7 -11
  8. package/node_modules/@llblab/pi-telegram/api/commands.ts +3 -0
  9. package/node_modules/@llblab/pi-telegram/dist/api/commands.d.ts +1 -1
  10. package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.d.ts +1 -5
  11. package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.js +15 -42
  12. package/node_modules/@llblab/pi-telegram/dist/lib/activity.d.ts +9 -0
  13. package/node_modules/@llblab/pi-telegram/dist/lib/activity.js +39 -10
  14. package/node_modules/@llblab/pi-telegram/dist/lib/agent-messages.js +7 -3
  15. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +43 -5
  16. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +163 -20
  17. package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.d.ts +12 -0
  18. package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.js +182 -79
  19. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +111 -31
  20. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +1324 -359
  21. package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.d.ts +41 -91
  22. package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.js +969 -637
  23. package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.js +16 -9
  24. package/node_modules/@llblab/pi-telegram/dist/lib/bus.d.ts +215 -18
  25. package/node_modules/@llblab/pi-telegram/dist/lib/bus.js +1048 -327
  26. package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.d.ts +5 -0
  27. package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.js +434 -261
  28. package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.d.ts +26 -5
  29. package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.js +92 -176
  30. package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +168 -82
  31. package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +1409 -291
  32. package/node_modules/@llblab/pi-telegram/dist/lib/config.d.ts +1 -8
  33. package/node_modules/@llblab/pi-telegram/dist/lib/config.js +34 -76
  34. package/node_modules/@llblab/pi-telegram/dist/lib/delivery.d.ts +2 -2
  35. package/node_modules/@llblab/pi-telegram/dist/lib/delivery.js +16 -16
  36. package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +639 -171
  37. package/node_modules/@llblab/pi-telegram/dist/lib/generative-app-worker.mjs +19 -7
  38. package/node_modules/@llblab/pi-telegram/dist/lib/generative-apps.d.ts +0 -5
  39. package/node_modules/@llblab/pi-telegram/dist/lib/generative-apps.js +61 -49
  40. package/node_modules/@llblab/pi-telegram/dist/lib/inbound.d.ts +5 -0
  41. package/node_modules/@llblab/pi-telegram/dist/lib/inbound.js +35 -59
  42. package/node_modules/@llblab/pi-telegram/dist/lib/journal.d.ts +33 -3
  43. package/node_modules/@llblab/pi-telegram/dist/lib/journal.js +2063 -782
  44. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.d.ts +2 -6
  45. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +75 -58
  46. package/node_modules/@llblab/pi-telegram/dist/lib/locks.d.ts +29 -3
  47. package/node_modules/@llblab/pi-telegram/dist/lib/locks.js +289 -108
  48. package/node_modules/@llblab/pi-telegram/dist/lib/logging.js +50 -14
  49. package/node_modules/@llblab/pi-telegram/dist/lib/media.d.ts +22 -1
  50. package/node_modules/@llblab/pi-telegram/dist/lib/media.js +46 -28
  51. package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.d.ts +19 -5
  52. package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.js +53 -11
  53. package/node_modules/@llblab/pi-telegram/dist/lib/menu-queue.d.ts +5 -4
  54. package/node_modules/@llblab/pi-telegram/dist/lib/menu-queue.js +45 -63
  55. package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.d.ts +5 -4
  56. package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.js +114 -78
  57. package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.d.ts +1 -1
  58. package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.js +8 -25
  59. package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.d.ts +6 -1
  60. package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.js +14 -21
  61. package/node_modules/@llblab/pi-telegram/dist/lib/menu.d.ts +8 -61
  62. package/node_modules/@llblab/pi-telegram/dist/lib/menu.js +92 -164
  63. package/node_modules/@llblab/pi-telegram/dist/lib/model.d.ts +1 -1
  64. package/node_modules/@llblab/pi-telegram/dist/lib/model.js +2 -16
  65. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.d.ts +6 -27
  66. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.js +45 -38
  67. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-buttons.js +22 -16
  68. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.d.ts +0 -2
  69. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.js +51 -64
  70. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-voice.js +6 -3
  71. package/node_modules/@llblab/pi-telegram/dist/lib/outbound.d.ts +6 -6
  72. package/node_modules/@llblab/pi-telegram/dist/lib/outbound.js +61 -51
  73. package/node_modules/@llblab/pi-telegram/dist/lib/ownership.js +6 -2
  74. package/node_modules/@llblab/pi-telegram/dist/lib/paths.d.ts +5 -0
  75. package/node_modules/@llblab/pi-telegram/dist/lib/paths.js +37 -21
  76. package/node_modules/@llblab/pi-telegram/dist/lib/pi.d.ts +2 -0
  77. package/node_modules/@llblab/pi-telegram/dist/lib/pi.js +8 -1
  78. package/node_modules/@llblab/pi-telegram/dist/lib/polling.d.ts +21 -37
  79. package/node_modules/@llblab/pi-telegram/dist/lib/polling.js +59 -50
  80. package/node_modules/@llblab/pi-telegram/dist/lib/preview.js +39 -19
  81. package/node_modules/@llblab/pi-telegram/dist/lib/process-identity.d.ts +24 -0
  82. package/node_modules/@llblab/pi-telegram/dist/lib/process-identity.js +133 -0
  83. package/node_modules/@llblab/pi-telegram/dist/lib/prompts.js +2 -7
  84. package/node_modules/@llblab/pi-telegram/dist/lib/queue.d.ts +14 -16
  85. package/node_modules/@llblab/pi-telegram/dist/lib/queue.js +249 -126
  86. package/node_modules/@llblab/pi-telegram/dist/lib/recovery.d.ts +2 -83
  87. package/node_modules/@llblab/pi-telegram/dist/lib/recovery.js +20 -274
  88. package/node_modules/@llblab/pi-telegram/dist/lib/replies.d.ts +16 -24
  89. package/node_modules/@llblab/pi-telegram/dist/lib/replies.js +99 -116
  90. package/node_modules/@llblab/pi-telegram/dist/lib/routing.d.ts +120 -7
  91. package/node_modules/@llblab/pi-telegram/dist/lib/routing.js +4667 -1152
  92. package/node_modules/@llblab/pi-telegram/dist/lib/runtime.d.ts +1 -11
  93. package/node_modules/@llblab/pi-telegram/dist/lib/sections.d.ts +4 -29
  94. package/node_modules/@llblab/pi-telegram/dist/lib/sections.js +7 -20
  95. package/node_modules/@llblab/pi-telegram/dist/lib/skills.js +4 -3
  96. package/node_modules/@llblab/pi-telegram/dist/lib/status.js +86 -57
  97. package/node_modules/@llblab/pi-telegram/dist/lib/sync.d.ts +1 -3
  98. package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +67 -43
  99. package/node_modules/@llblab/pi-telegram/dist/lib/target.d.ts +4 -0
  100. package/node_modules/@llblab/pi-telegram/dist/lib/target.js +18 -0
  101. package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.d.ts +18 -13
  102. package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.js +148 -53
  103. package/node_modules/@llblab/pi-telegram/dist/lib/text-groups.js +4 -39
  104. package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.d.ts +6 -27
  105. package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.js +369 -186
  106. package/node_modules/@llblab/pi-telegram/dist/lib/thread-display.d.ts +1 -2
  107. package/node_modules/@llblab/pi-telegram/dist/lib/thread-display.js +58 -38
  108. package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.d.ts +28 -8
  109. package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.js +175 -66
  110. package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.d.ts +42 -16
  111. package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.js +90 -50
  112. package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +82 -20
  113. package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +2247 -855
  114. package/node_modules/@llblab/pi-telegram/dist/lib/time-injection.js +1 -2
  115. package/node_modules/@llblab/pi-telegram/dist/lib/turns.js +1 -19
  116. package/node_modules/@llblab/pi-telegram/dist/lib/updates.d.ts +169 -80
  117. package/node_modules/@llblab/pi-telegram/dist/lib/updates.js +2418 -641
  118. package/node_modules/@llblab/pi-telegram/dist/lib/voice.d.ts +7 -22
  119. package/node_modules/@llblab/pi-telegram/dist/lib/voice.js +7 -22
  120. package/node_modules/@llblab/pi-telegram/dist/lib/wire.js +1 -1
  121. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.d.ts +3 -1
  122. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.js +425 -211
  123. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-identity.js +8 -13
  124. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +1 -1
  125. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +328 -140
  126. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-slots.js +8 -4
  127. package/node_modules/@llblab/pi-telegram/dist/package.json +1 -1
  128. package/node_modules/@llblab/pi-telegram/docs/architecture.md +31 -29
  129. package/node_modules/@llblab/pi-telegram/docs/inbound.md +1 -1
  130. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +15 -3
  131. package/node_modules/@llblab/pi-telegram/docs/outbound.md +1 -1
  132. package/node_modules/@llblab/pi-telegram/docs/public-api.md +29 -1
  133. package/node_modules/@llblab/pi-telegram/docs/ui-style.md +25 -8
  134. package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +59 -82
  135. package/node_modules/@llblab/pi-telegram/lib/activity.ts +146 -102
  136. package/node_modules/@llblab/pi-telegram/lib/agent-messages.ts +12 -5
  137. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +389 -82
  138. package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +263 -102
  139. package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +2440 -601
  140. package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +2209 -1290
  141. package/node_modules/@llblab/pi-telegram/lib/bus-transport.ts +46 -12
  142. package/node_modules/@llblab/pi-telegram/lib/bus.ts +1673 -444
  143. package/node_modules/@llblab/pi-telegram/lib/channel-posts.ts +848 -327
  144. package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +152 -265
  145. package/node_modules/@llblab/pi-telegram/lib/commands.ts +2398 -555
  146. package/node_modules/@llblab/pi-telegram/lib/config.ts +177 -170
  147. package/node_modules/@llblab/pi-telegram/lib/delivery.ts +41 -29
  148. package/node_modules/@llblab/pi-telegram/lib/extension.ts +1206 -433
  149. package/node_modules/@llblab/pi-telegram/lib/generative-app-worker.mjs +19 -7
  150. package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +324 -211
  151. package/node_modules/@llblab/pi-telegram/lib/inbound.ts +95 -97
  152. package/node_modules/@llblab/pi-telegram/lib/journal.ts +5311 -1763
  153. package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +1 -3
  154. package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +128 -78
  155. package/node_modules/@llblab/pi-telegram/lib/locks.ts +677 -203
  156. package/node_modules/@llblab/pi-telegram/lib/logging.ts +147 -58
  157. package/node_modules/@llblab/pi-telegram/lib/media.ts +82 -43
  158. package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +85 -18
  159. package/node_modules/@llblab/pi-telegram/lib/menu-queue.ts +88 -129
  160. package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +260 -155
  161. package/node_modules/@llblab/pi-telegram/lib/menu-status.ts +20 -60
  162. package/node_modules/@llblab/pi-telegram/lib/menu-thinking.ts +41 -56
  163. package/node_modules/@llblab/pi-telegram/lib/menu.ts +112 -285
  164. package/node_modules/@llblab/pi-telegram/lib/model.ts +8 -22
  165. package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +156 -125
  166. package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +76 -49
  167. package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +96 -94
  168. package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +33 -27
  169. package/node_modules/@llblab/pi-telegram/lib/outbound.ts +125 -125
  170. package/node_modules/@llblab/pi-telegram/lib/ownership.ts +19 -10
  171. package/node_modules/@llblab/pi-telegram/lib/paths.ts +148 -49
  172. package/node_modules/@llblab/pi-telegram/lib/pi.ts +35 -15
  173. package/node_modules/@llblab/pi-telegram/lib/polling.ts +144 -147
  174. package/node_modules/@llblab/pi-telegram/lib/preview.ts +93 -40
  175. package/node_modules/@llblab/pi-telegram/lib/process-identity.ts +164 -0
  176. package/node_modules/@llblab/pi-telegram/lib/prompts.ts +4 -11
  177. package/node_modules/@llblab/pi-telegram/lib/queue.ts +511 -300
  178. package/node_modules/@llblab/pi-telegram/lib/recovery.ts +50 -454
  179. package/node_modules/@llblab/pi-telegram/lib/rendering.ts +1 -3
  180. package/node_modules/@llblab/pi-telegram/lib/replies.ts +248 -209
  181. package/node_modules/@llblab/pi-telegram/lib/routing.ts +8509 -2186
  182. package/node_modules/@llblab/pi-telegram/lib/runtime.ts +1 -12
  183. package/node_modules/@llblab/pi-telegram/lib/sections.ts +24 -89
  184. package/node_modules/@llblab/pi-telegram/lib/setup.ts +1 -3
  185. package/node_modules/@llblab/pi-telegram/lib/skills.ts +9 -4
  186. package/node_modules/@llblab/pi-telegram/lib/status.ts +215 -110
  187. package/node_modules/@llblab/pi-telegram/lib/sync.ts +448 -361
  188. package/node_modules/@llblab/pi-telegram/lib/target.ts +22 -3
  189. package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +302 -127
  190. package/node_modules/@llblab/pi-telegram/lib/text-groups.ts +5 -39
  191. package/node_modules/@llblab/pi-telegram/lib/thread-cleanup-manager.ts +833 -331
  192. package/node_modules/@llblab/pi-telegram/lib/thread-display.ts +213 -97
  193. package/node_modules/@llblab/pi-telegram/lib/thread-naming.ts +232 -87
  194. package/node_modules/@llblab/pi-telegram/lib/thread-reconciler.ts +155 -72
  195. package/node_modules/@llblab/pi-telegram/lib/threads.ts +5318 -1845
  196. package/node_modules/@llblab/pi-telegram/lib/time-injection.ts +1 -4
  197. package/node_modules/@llblab/pi-telegram/lib/turns.ts +15 -28
  198. package/node_modules/@llblab/pi-telegram/lib/updates.ts +5184 -1612
  199. package/node_modules/@llblab/pi-telegram/lib/voice.ts +7 -35
  200. package/node_modules/@llblab/pi-telegram/lib/wire.ts +1 -1
  201. package/node_modules/@llblab/pi-telegram/lib/workspace-admission.ts +996 -416
  202. package/node_modules/@llblab/pi-telegram/lib/workspace-identity.ts +14 -17
  203. package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +878 -376
  204. package/node_modules/@llblab/pi-telegram/lib/workspace-slots.ts +22 -13
  205. package/node_modules/@llblab/pi-telegram/package.json +1 -1
  206. package/package.json +2 -2
  207. package/node_modules/@llblab/pi-telegram/scripts/check-downgrade.mjs +0 -472
  208. package/node_modules/@llblab/pi-telegram/scripts/measure-workspace.mjs +0 -108
@@ -4,17 +4,16 @@
4
4
  * Owns leader-only runtime orchestration: follower registration envelopes, follower API proxying,
5
5
  * leader activation hot-switching, local bus server startup, and stale follower pruning.
6
6
  */
7
- import * as Sync from "./sync.ts";
7
+ import { type TelegramBusEnvelope, type TelegramBusLeaderQueueHandoffOffer, type TelegramBusFollowerRegistry, type TelegramBusFollowerView, type TelegramBusInstanceRegistration, type TelegramBusProtocolIdentity, type TelegramBusSelectedMenuDelivery, type TelegramBusSocketPathSource } from "./bus.ts";
8
8
  import type { TelegramThreadDisplayMode } from "./config.ts";
9
- import * as ThreadReconciler from "./thread-reconciler.ts";
10
- import { type TelegramApiCallOptions } from "./telegram-api.ts";
11
- import type { TelegramTarget } from "./target.ts";
12
9
  import type { TelegramAttachmentSource } from "./media.ts";
10
+ import * as Sync from "./sync.ts";
11
+ import { type TelegramTarget } from "./target.ts";
12
+ import { type TelegramApiCallOptions, type TelegramBridgeApiRuntime } from "./telegram-api.ts";
13
+ import * as ThreadReconciler from "./thread-reconciler.ts";
13
14
  import * as Threads from "./threads.ts";
14
- import { type TelegramBusEnvelope, type TelegramBusFollowerRegistry, type TelegramBusFollowerView, type TelegramBusInstanceRegistration, type TelegramBusProtocolIdentity, type TelegramBusSocketPathSource } from "./bus.ts";
15
- import type { TelegramQueueHandoffPayload } from "./queue.ts";
16
- import { type TelegramWorkspaceCapacityRunner, type TelegramWorkspaceSlotRotationPorts, type TelegramWorkspaceOperationRunner } from "./workspace-retirement.ts";
17
15
  import { type TelegramWorkspaceAdmissionLedger } from "./workspace-admission.ts";
16
+ import { type TelegramWorkspaceCapacityRunner, type TelegramWorkspaceOperationRunner, type TelegramWorkspaceSlotRotationPorts } from "./workspace-retirement.ts";
18
17
  export declare const TELEGRAM_BUS_FOLLOWER_STALE_AFTER_MS = 15000;
19
18
  export type TelegramBusWorkspaceAdmissionRunner = TelegramWorkspaceOperationRunner;
20
19
  export interface TelegramBusLeaderRuntime<TContext> {
@@ -27,21 +26,7 @@ export interface TelegramBusLeaderRuntime<TContext> {
27
26
  renameLeaderThread?: (threadName: string) => Promise<Threads.TelegramTopicTargetRecord>;
28
27
  startPolling: (ctx: TContext) => Promise<void>;
29
28
  stopPolling: () => Promise<void>;
30
- routeQueueHandoff: (input: {
31
- requestId: string;
32
- auth?: string;
33
- recipientInstanceId: string;
34
- recipientRegistrationGeneration: string;
35
- donorInstanceId: string;
36
- donorProcessId: number;
37
- donorProcessBirthId: string;
38
- donorSessionGeneration: number;
39
- donorAcquisitionId: string;
40
- donorAcquiredAtMs: number;
41
- handoffToken: string;
42
- payload: TelegramQueueHandoffPayload;
43
- sentAtMs: number;
44
- }) => Promise<TelegramBusEnvelope>;
29
+ routeQueueHandoff: (input: TelegramBusLeaderQueueHandoffOffer) => Promise<TelegramBusEnvelope>;
45
30
  }
46
31
  export interface TelegramBusFollowerLifecycleAnnouncement {
47
32
  target: TelegramTarget & {
@@ -154,8 +139,8 @@ export declare function createTelegramBusFollowerSessionReplacementAuthority(dep
154
139
  settle: TelegramBusFollowerSessionReplacementOperation;
155
140
  };
156
141
  export declare function createTelegramBusLeaderRuntimeAssembly<TContext>(deps: TelegramBusLeaderRuntimeAssemblyDeps<TContext>): TelegramBusLeaderRuntime<TContext> & {
157
- renameLeaderThreadAdmitted: (threadName: string, expectedTarget?: Threads.TelegramTopicTargetRecord["target"]) => Promise<Threads.TelegramTopicTargetRecord>;
158
- resetLeaderThreadName: (expectedTarget: Threads.TelegramTopicTargetRecord["target"]) => Promise<{
142
+ renameLeaderThreadAdmitted: (threadName: string, expectedTarget?: Threads.TelegramTopicTargetRecord["target"], assertRecipientAuthority?: () => void) => Promise<Threads.TelegramTopicTargetRecord>;
143
+ resetLeaderThreadName: (expectedTarget: Threads.TelegramTopicTargetRecord["target"], assertRecipientAuthority?: () => void) => Promise<{
159
144
  threadName: string;
160
145
  }>;
161
146
  resetThreadNameAdmitted: (target: Threads.TelegramTopicTargetRecord["target"]) => Promise<{
@@ -174,72 +159,21 @@ export type TelegramBusFollowerRegistrationCommitter = (input: {
174
159
  target?: TelegramTarget;
175
160
  slot?: string;
176
161
  }, publish: () => void) => Promise<void> | void;
177
- export interface TelegramBusLeaderRuntimeDeps<TContext> {
162
+ export interface TelegramBusLeaderRuntimeDeps<TContext> extends Omit<TelegramBusLeaderEnvelopeHandlerDeps, "runFollowerMutation" | "getWorkspaceRestoreObservationGeneration"> {
178
163
  socketPath: TelegramBusSocketPathSource;
179
164
  commitEndpointPublication?: (commit: () => void) => boolean;
180
- followerRegistry: TelegramBusFollowerRegistry;
181
- authSecret?: string;
182
- protocolIdentity: TelegramBusProtocolIdentity;
183
165
  startPolling: (ctx: TContext) => void | Promise<void>;
184
166
  stopPolling: () => void | Promise<void>;
185
- callApi?: (method: string, args: unknown[]) => Promise<unknown> | unknown;
186
- authorizeFollowerApiCall?: (input: {
187
- follower: TelegramBusFollowerView;
188
- method: string;
189
- args: unknown[];
190
- }) => boolean;
191
- recordFollowerMessageOwnership?: TelegramBusFollowerMessageOwnershipRecorder;
192
- resolveAgentTarget?: (follower: TelegramBusFollowerView, selector: Extract<TelegramBusEnvelope, {
193
- kind: "follower.resolveAgentTarget";
194
- }>["selector"]) => Promise<TelegramTarget | undefined> | TelegramTarget | undefined;
195
- routeAgentMessage?: (follower: TelegramBusFollowerView, message: Extract<TelegramBusEnvelope, {
196
- kind: "follower.routeAgentMessage";
197
- }>["message"]) => Promise<void> | void;
198
- routeQueueHandoff?: (follower: TelegramBusFollowerView, envelope: Extract<TelegramBusEnvelope, {
199
- kind: "follower.offerQueueHandoff";
200
- }>) => Promise<unknown> | unknown;
201
- provisionFollowerTarget?: (registration: TelegramBusInstanceRegistration, options?: {
202
- existingWorkspaceBindingOnly?: boolean;
203
- }) => Promise<TelegramTarget | undefined> | TelegramTarget | undefined;
204
- commitFollowerRegistration?: TelegramBusFollowerRegistrationCommitter;
205
- renameFollowerThread?: (follower: TelegramBusFollowerView, threadName: string) => Promise<{
206
- threadName: string;
207
- }> | {
208
- threadName: string;
209
- };
210
- resetFollowerThreadName?: (follower: TelegramBusFollowerView) => Promise<{
211
- threadName: string;
212
- }> | {
213
- threadName: string;
214
- };
215
- publishFollowerSessionReplacement?: TelegramBusFollowerSessionReplacementOperation;
216
- settleFollowerSessionReplacement?: TelegramBusFollowerSessionReplacementOperation;
217
- getFollowerDisplayTitle?: (follower: TelegramBusFollowerView) => string | undefined;
218
- onFollowerRegistered?: () => void;
219
- /** Observation only: reacquire admission and inspect work, never infer completion.
220
- * Listener settlement ends its currentness fence; return asynchronous work to retain that fence. */
221
- onWorkspaceRestoreRecipientObserved?: (follower: TelegramBusFollowerView, isCurrent: () => boolean) => Promise<void> | void;
222
- applyThreadDisplayMode?: (mode: TelegramThreadDisplayMode, isCurrent: () => boolean) => Promise<void>;
223
- getThreadDisplayMode?: () => TelegramThreadDisplayMode;
224
- getCurrentLeaderEpoch?: () => number | string | undefined;
225
- getTelegramProfile?: () => string | undefined;
226
- getAllowedUserId?: () => number | undefined;
227
167
  provisionLeaderTarget?: (ctx: TContext) => Promise<void> | void;
228
- runWorkspaceAdmission?: TelegramBusWorkspaceAdmissionRunner;
229
- runWithWorkspaceCapacity?: TelegramWorkspaceCapacityRunner;
230
- getNowMs?: () => number;
231
- timeoutMs?: number;
232
168
  followerPruneIntervalMs?: number;
233
169
  /** Leader housekeeping after each current prune pass; throttling is the callee's concern. */
234
170
  afterFollowerPrune?: () => void;
235
171
  followerStaleAfterMs?: number;
236
172
  isFollowerProcessAlive?: (pid: number) => boolean;
237
173
  shouldCleanupConfirmedDeadFollower?: () => Promise<boolean> | boolean;
238
- onFollowerDisconnected?: (follower: TelegramBusFollowerView) => Promise<void> | void;
239
174
  onFollowerConfirmedDead?: (follower: TelegramBusFollowerView) => Promise<void> | void;
240
175
  /** True settles this observation; false needs fresh proof before another attempt. */
241
176
  onFollowerConfirmedDeadPreserved?: (follower: TelegramBusFollowerView, isDetached: () => boolean, operationId: string) => Promise<boolean> | boolean;
242
- recordRuntimeEvent?: (category: string, error: unknown, details?: Record<string, unknown>) => void;
243
177
  }
244
178
  export declare function createTelegramBusInstanceLifecycleAnnouncement(input: {
245
179
  target: TelegramTarget & {
@@ -263,12 +197,37 @@ type TelegramBusFollowerMutationRunner = <T>(follower: {
263
197
  instanceId: string;
264
198
  profileKey?: string;
265
199
  }, operation: () => Promise<T>) => Promise<T>;
266
- export declare function createTelegramBusLeaderEnvelopeHandler(deps: {
200
+ /** One delegated text effect through existing Workspace/API owners; no closure transport, ordinary proxy or replay loop. */
201
+ export declare function createTelegramBusSelectedMenuDeliveryHandler(deps: {
202
+ followerRegistry: TelegramBusFollowerRegistry;
203
+ protocolIdentity: TelegramBusProtocolIdentity;
204
+ workspace: {
205
+ /** Exact active bot/profile namespace, independently captured by the leader; never follower-supplied. */
206
+ getScopeKey(): string | undefined;
207
+ captureAuthority(): Threads.TelegramWorkspaceRestoreAuthority | undefined;
208
+ getStore(): Threads.TelegramWorkspaceRestore | undefined;
209
+ threadStore: Pick<Threads.TelegramTopicTargetStore, "withWorkspaceLiveRebindSnapshot">;
210
+ getJournalBindingKey(follower: TelegramBusFollowerView): string | undefined;
211
+ run: TelegramBusWorkspaceAdmissionRunner;
212
+ };
213
+ api: {
214
+ runtime: Pick<TelegramBridgeApiRuntime, "call">;
215
+ authorize(input: {
216
+ follower: TelegramBusFollowerView;
217
+ method: string;
218
+ args: unknown[];
219
+ }): boolean;
220
+ /** Synchronous publication acceptance through the existing ownership owner, never delivery/cleanup permission. */
221
+ record(record: TelegramBusFollowerMessageOwnershipRecord, assertCurrent: () => void): boolean;
222
+ };
223
+ }): (input: TelegramBusSelectedMenuDelivery, isCallerCurrent: () => boolean) => Promise<TelegramBusEnvelope>;
224
+ export interface TelegramBusLeaderEnvelopeHandlerDeps {
267
225
  followerRegistry: TelegramBusFollowerRegistry;
268
226
  authSecret?: string;
269
227
  protocolIdentity: TelegramBusProtocolIdentity;
270
228
  getNowMs?: () => number;
271
229
  timeoutMs?: number;
230
+ selectedMenuDelivery?: ReturnType<typeof createTelegramBusSelectedMenuDeliveryHandler>;
272
231
  callApi?: (method: string, args: unknown[]) => Promise<unknown> | unknown;
273
232
  authorizeFollowerApiCall?: (input: {
274
233
  follower: TelegramBusFollowerView;
@@ -310,9 +269,11 @@ export declare function createTelegramBusLeaderEnvelopeHandler(deps: {
310
269
  settleFollowerSessionReplacement?: TelegramBusFollowerSessionReplacementOperation;
311
270
  getFollowerDisplayTitle?: (follower: TelegramBusFollowerView) => string | undefined;
312
271
  onFollowerRegistered?: () => void;
313
- onWorkspaceRestoreRecipientObserved?: TelegramBusLeaderRuntimeDeps<unknown>["onWorkspaceRestoreRecipientObserved"];
272
+ /** Observation only: reacquire admission and inspect work, never infer completion.
273
+ * Listener settlement ends its currentness fence; return asynchronous work to retain that fence. */
274
+ onWorkspaceRestoreRecipientObserved?: (follower: TelegramBusFollowerView, isCurrent: () => boolean) => Promise<void> | void;
314
275
  getWorkspaceRestoreObservationGeneration?: () => number | undefined;
315
- recordRuntimeEvent?: TelegramBusLeaderRuntimeDeps<unknown>["recordRuntimeEvent"];
276
+ recordRuntimeEvent?: (category: string, error: unknown, details?: Record<string, unknown>) => void;
316
277
  applyThreadDisplayMode?: (mode: TelegramThreadDisplayMode, isCurrent: () => boolean) => Promise<void>;
317
278
  getThreadDisplayMode?: () => TelegramThreadDisplayMode;
318
279
  getCurrentLeaderEpoch?: () => number | string | undefined;
@@ -321,18 +282,7 @@ export declare function createTelegramBusLeaderEnvelopeHandler(deps: {
321
282
  runFollowerMutation?: TelegramBusFollowerMutationRunner;
322
283
  runWorkspaceAdmission?: TelegramBusWorkspaceAdmissionRunner;
323
284
  runWithWorkspaceCapacity?: TelegramWorkspaceCapacityRunner;
324
- }): (envelope: TelegramBusEnvelope) => Promise<TelegramBusEnvelope> | TelegramBusEnvelope;
325
- export interface TelegramBusLeaderActivationSchedulerDeps<TContext> {
326
- isBusEnabled: () => boolean;
327
- ownsPolling: (ctx: TContext) => boolean;
328
- isBusPollingStarted: () => boolean;
329
- setBusPollingStarted: (started: boolean) => void;
330
- stopClassicPolling: () => Promise<void>;
331
- startClassicPolling: (ctx: TContext) => void | Promise<void>;
332
- startBusLeaderPolling: (ctx: TContext) => Promise<void>;
333
- updateStatus: (ctx: TContext) => void;
334
- recordRuntimeEvent?: (category: string, error: unknown, details?: Record<string, unknown>) => void;
335
285
  }
336
- export declare function createTelegramBusLeaderActivationScheduler<TContext>(deps: TelegramBusLeaderActivationSchedulerDeps<TContext>): (ctx: TContext) => void;
286
+ export declare function createTelegramBusLeaderEnvelopeHandler(deps: TelegramBusLeaderEnvelopeHandlerDeps): (envelope: TelegramBusEnvelope) => Promise<TelegramBusEnvelope> | TelegramBusEnvelope;
337
287
  export declare function createTelegramBusLeaderRuntime<TContext>(deps: TelegramBusLeaderRuntimeDeps<TContext>): TelegramBusLeaderRuntime<TContext>;
338
288
  export {};