@llblab/pi-kit 0.29.2 → 0.30.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.
Files changed (208) hide show
  1. package/BACKLOG.md +2 -1
  2. package/CHANGELOG.md +9 -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 +15 -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 +65 -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 +252 -127
  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 +128 -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 +516 -301
  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
@@ -6,7 +6,7 @@
6
6
  import { createHash } from "node:crypto";
7
7
  import { createConnection } from "node:net";
8
8
  import { isAbsolute, join, resolve } from "node:path";
9
- import { resolveTelegramTempDir, resolveTelegramRuntimeDir } from "./paths.js";
9
+ import { resolveTelegramRuntimeDir, resolveTelegramTempDir } from "./paths.js";
10
10
  export const TELEGRAM_BUS_MAX_DIRECT_UNIX_ENDPOINT_BYTES = 80;
11
11
  function requireConsolidatedUnixEndpoint(path) {
12
12
  if (!isAbsolute(path) || resolve(path) !== path)
@@ -58,14 +58,24 @@ export function getTelegramBusTransportRetryPolicy(input) {
58
58
  function normalizeTelegramBusEndpointScope(value) {
59
59
  return value.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 80);
60
60
  }
61
+ /** Consolidated endpoints hash their identity so profile/instance names never reach the path. */
62
+ function getConsolidatedTelegramBusEndpoint(input, identity, pipePrefix, socketPrefix) {
63
+ const scope = createHash("sha256")
64
+ .update(JSON.stringify(identity))
65
+ .digest("hex")
66
+ .slice(0, 16);
67
+ return input.platform === "win32"
68
+ ? getTelegramBusPipePath({
69
+ agentDir: input.agentDir,
70
+ scope: `${pipePrefix}-${scope}`,
71
+ })
72
+ : requireConsolidatedUnixEndpoint(join(resolveTelegramRuntimeDir(input.agentDir), `${socketPrefix}.${scope}.sock`));
73
+ }
61
74
  export function getTelegramBusLeaderEndpoint(input) {
62
75
  if (input.layout !== undefined && input.layout !== "consolidated")
63
76
  throw new Error("Telegram IPC layout is invalid.");
64
77
  if (input.layout === "consolidated") {
65
- const scope = createHash("sha256").update(JSON.stringify([input.profileName ?? "default"])).digest("hex").slice(0, 16);
66
- return input.platform === "win32"
67
- ? getTelegramBusPipePath({ agentDir: input.agentDir, scope: `bus-${scope}` })
68
- : requireConsolidatedUnixEndpoint(join(resolveTelegramRuntimeDir(input.agentDir), `bus.${scope}.sock`));
78
+ return getConsolidatedTelegramBusEndpoint(input, [input.profileName ?? "default"], "bus", "bus");
69
79
  }
70
80
  const profileScope = input.profileName
71
81
  ? normalizeTelegramBusEndpointScope(input.profileName)
@@ -81,10 +91,7 @@ export function getTelegramBusFollowerEndpoint(input) {
81
91
  if (input.layout !== undefined && input.layout !== "consolidated")
82
92
  throw new Error("Telegram IPC layout is invalid.");
83
93
  if (input.layout === "consolidated") {
84
- const scope = createHash("sha256").update(JSON.stringify([input.profileName ?? "default", input.instanceId])).digest("hex").slice(0, 16);
85
- return input.platform === "win32"
86
- ? getTelegramBusPipePath({ agentDir: input.agentDir, scope: `follower-${scope}` })
87
- : requireConsolidatedUnixEndpoint(join(resolveTelegramRuntimeDir(input.agentDir), `f.${scope}.sock`));
94
+ return getConsolidatedTelegramBusEndpoint(input, [input.profileName ?? "default", input.instanceId], "follower", "f");
88
95
  }
89
96
  const instanceScope = normalizeTelegramBusEndpointScope(input.instanceId);
90
97
  const profileScope = input.profileName
@@ -5,9 +5,9 @@
5
5
  * cross-instance forwarding helpers, and the live follower registry model.
6
6
  */
7
7
  import { type TelegramBusEndpointLayout, type TelegramBusTransportEventRecorder, type TelegramBusTransportRetryPolicy } from "./bus-transport.ts";
8
- import { type TelegramQueueHandoffPayload } from "./queue.ts";
9
- import type { TelegramTarget } from "./target.ts";
10
8
  import type { TelegramThreadDisplayMode } from "./config.ts";
9
+ import { type TelegramQueueHandoffPayload } from "./queue.ts";
10
+ import { type TelegramTarget } from "./target.ts";
11
11
  import { type TelegramSessionReplacementIntent } from "./threads.ts";
12
12
  interface TelegramBusProcessRuntime {
13
13
  instanceId: string;
@@ -17,21 +17,6 @@ interface TelegramBusProcessRuntime {
17
17
  getLeaderSocketPath: () => string;
18
18
  getFollowerSocketPath: () => string;
19
19
  }
20
- interface TelegramProcessBirthIdentityOptions {
21
- platform?: NodeJS.Platform;
22
- readProcStat?: (pid: number) => string;
23
- readDarwinProcessStart?: (pid: number) => string;
24
- }
25
- export type TelegramProcessLiveness = "alive" | "dead" | "unverifiable";
26
- interface TelegramProcessLivenessOptions extends TelegramProcessBirthIdentityOptions {
27
- isProcessAlive?: (pid: number) => boolean;
28
- }
29
- export declare function getTelegramProcessBirthIdentity(pid: number, fallbackGeneration: number | string, options?: TelegramProcessBirthIdentityOptions): string;
30
- export declare function getTelegramProcessLiveness(owner: {
31
- processId: number;
32
- processBirthId: string;
33
- }, options?: TelegramProcessLivenessOptions): TelegramProcessLiveness;
34
- export declare function getTelegramProcessBirthIdentityLiveness(processBirthId: string, options?: TelegramProcessLivenessOptions): TelegramProcessLiveness;
35
20
  export declare function createCurrentTelegramBusProcessRuntime(input: {
36
21
  getActiveProfileName: () => string | undefined;
37
22
  endpointLayout?: TelegramBusEndpointLayout;
@@ -57,6 +42,122 @@ export declare const TELEGRAM_BUS_CAPABILITY_DIRECTORY_DISPLAY_FORMAT: "director
57
42
  export declare const TELEGRAM_BUS_CAPABILITY_WORKSPACE_FOLLOWER_AUTO_CONNECT: "workspace-follower-auto-connect-v1";
58
43
  export declare const TELEGRAM_BUS_CAPABILITY_SESSION_REPLACEMENT_INTENT: "session-replacement-intent-v1";
59
44
  export declare const TELEGRAM_BUS_CAPABILITY_WORKSPACE_RESTORE: "workspace-restore-v1";
45
+ export declare const TELEGRAM_BUS_CAPABILITY_LIVE_REBIND_SAVE: "live-thread-rebind-save-v1";
46
+ export declare const TELEGRAM_BUS_CAPABILITY_LIVE_REBIND_APPLY: "live-thread-rebind-apply-v1";
47
+ export declare const TELEGRAM_BUS_CAPABILITY_LIVE_REBIND_SETTLE: "live-thread-rebind-settle-v1";
48
+ /** Restricted recipient text/menu delivery; negotiated identity and captured effect authority remain required. */
49
+ export declare const TELEGRAM_BUS_CAPABILITY_SELECTED_MENU_DELIVERY: "selected-menu-delivery-v1";
50
+ /** Versioned held-command set; syntax is shared, while the captured recipient Commands registry owns supported plans. */
51
+ export declare const TELEGRAM_BUS_CAPABILITY_LIVE_REBIND_COMMAND_SET: "live-thread-rebind-command-set-v1";
52
+ /** Every live rebinding needs the save/apply/settle trio; held command selections additionally need these two. */
53
+ export declare const TELEGRAM_BUS_LIVE_REBIND_CAPABILITIES: readonly ["live-thread-rebind-save-v1", "live-thread-rebind-apply-v1", "live-thread-rebind-settle-v1"];
54
+ export declare const TELEGRAM_BUS_HELD_COMMAND_CAPABILITIES: readonly ["live-thread-rebind-command-set-v1", "selected-menu-delivery-v1"];
55
+ export interface TelegramBusSelectedCommandInput {
56
+ name: string;
57
+ target: TelegramTarget & {
58
+ threadId: number;
59
+ };
60
+ }
61
+ export type TelegramBusSelectedMenuTextEffect = {
62
+ text: string;
63
+ parseMode?: "HTML";
64
+ replyMarkup?: {
65
+ inline_keyboard: {
66
+ text: string;
67
+ callback_data: string;
68
+ }[][];
69
+ };
70
+ } & ({
71
+ kind: "send-text";
72
+ replyToMessageId?: number;
73
+ } | {
74
+ kind: "edit-text";
75
+ messageId: number;
76
+ });
77
+ /** Serializable identity/effect description, never a process-local callback or standalone delivery grant. */
78
+ export interface TelegramBusSelectedMenuDelivery {
79
+ kind: "follower.deliverSelectedMenu";
80
+ requestId: string;
81
+ instanceId: string;
82
+ registrationGeneration: string;
83
+ operationId: string;
84
+ recipient: {
85
+ sessionId: string;
86
+ sessionGeneration: number;
87
+ processId: number;
88
+ processBirthId: string;
89
+ profileKey: string;
90
+ journalBindingKey: string;
91
+ target: TelegramTarget & {
92
+ threadId: number;
93
+ };
94
+ };
95
+ executor: {
96
+ instanceId: string;
97
+ leaderEpoch: string;
98
+ };
99
+ operatorUserId: number;
100
+ effect: TelegramBusSelectedMenuTextEffect;
101
+ sentAtMs: number;
102
+ }
103
+ export interface TelegramBusSelectedMenuDeliveryObservation {
104
+ operationId: string;
105
+ recipient: TelegramBusSelectedMenuDelivery["recipient"];
106
+ registrationGeneration: string;
107
+ effect: TelegramBusSelectedMenuTextEffect["kind"];
108
+ messageId: number;
109
+ }
110
+ /** Closed wire projection of prepared recipient source; independent of journal implementation and never a removal grant. */
111
+ export interface TelegramBusPreparedCommandSource {
112
+ journalBindingKey: string;
113
+ updateId: number;
114
+ sourceSha256: string;
115
+ }
116
+ export interface TelegramBusLiveRebindSaveObservation {
117
+ operationId: string;
118
+ recipient: {
119
+ instanceId: string;
120
+ sessionId: string;
121
+ generation: string;
122
+ bindingKey: string;
123
+ };
124
+ sourceUpdateIds: number[];
125
+ selectedCommand?: TelegramBusSelectedCommandInput;
126
+ preparedSource?: TelegramBusPreparedCommandSource;
127
+ status: "saved";
128
+ }
129
+ /** Read-only warm observation; semantic completion and exact source ACK are distinct from detached delivery. */
130
+ export interface TelegramBusLiveRebindCommandObservation extends Omit<TelegramBusLiveRebindSaveObservation, "status" | "preparedSource" | "selectedCommand"> {
131
+ status: "command-observed";
132
+ selectedCommand: TelegramBusSelectedCommandInput;
133
+ preparedSource: TelegramBusPreparedCommandSource;
134
+ command: "completed" | "unknown" | "not-issued";
135
+ sourceAck?: TelegramBusPreparedCommandSource;
136
+ }
137
+ export interface TelegramBusLiveRebindWorkState {
138
+ sessionBusy: boolean;
139
+ targetWork: boolean;
140
+ deliveryPending: boolean;
141
+ unknown: boolean;
142
+ }
143
+ export interface TelegramBusLiveRebindWorkObservation extends Omit<TelegramBusLiveRebindSaveObservation, "status"> {
144
+ status: "observed";
145
+ oldTarget: TelegramTarget & {
146
+ threadId: number;
147
+ };
148
+ work: TelegramBusLiveRebindWorkState;
149
+ }
150
+ export interface TelegramBusLiveRebindSettlementObservation extends Omit<TelegramBusLiveRebindSaveObservation, "status"> {
151
+ action: "release" | "discard";
152
+ status: "released" | "discarded" | "protected" | "unknown";
153
+ }
154
+ export interface TelegramBusLiveRebindApplyObservation extends Omit<TelegramBusLiveRebindSaveObservation, "status"> {
155
+ status: "saved" | "applied";
156
+ target: TelegramTarget & {
157
+ threadId: number;
158
+ };
159
+ slot: string;
160
+ }
60
161
  export interface TelegramBusWorkspaceRestoreObservation {
61
162
  operationId: string;
62
163
  recipient: {
@@ -88,6 +189,8 @@ export declare function createTelegramBusProtocolIdentity(input: {
88
189
  export declare function createTelegramCurrentBusProtocolIdentity(capabilities?: readonly string[]): TelegramBusProtocolIdentity;
89
190
  export declare function hasTelegramBusCapability(identity: TelegramBusProtocolIdentity | undefined, capability: string): boolean;
90
191
  export declare function getTelegramInputCustodyPeerReadiness(followers: readonly Pick<TelegramBusFollowerView, "registrationGeneration" | "protocol">[]): ("ready" | "legacy" | "unknown")[];
192
+ /** Both peers advertise every required capability over a compatible protocol; reads only the two identities. */
193
+ export declare function hasTelegramBusSharedCapabilities(local: TelegramBusProtocolIdentity, remote: TelegramBusProtocolIdentity | undefined, required: readonly string[]): boolean;
91
194
  export declare function getTelegramBusProtocolCompatibility(input: {
92
195
  local: TelegramBusProtocolIdentity;
93
196
  remote?: TelegramBusProtocolIdentity;
@@ -114,6 +217,8 @@ export interface TelegramBusInstanceRegistration {
114
217
  export interface TelegramBusFollowerView extends TelegramBusInstanceRegistration {
115
218
  lastHeartbeatMs: number;
116
219
  }
220
+ /** Whether a live follower is still exactly the captured registration: identity, process, session, endpoint and negotiated protocol. */
221
+ export declare function isSameTelegramBusFollowerRegistration(live: TelegramBusInstanceRegistration, captured: TelegramBusInstanceRegistration): boolean;
117
222
  export declare function getTelegramFollowerTargetOwnership(input: {
118
223
  target: TelegramTarget;
119
224
  followers: readonly TelegramBusFollowerView[];
@@ -319,6 +424,48 @@ export type TelegramBusEnvelope = ({
319
424
  recipientRegistrationGeneration: string;
320
425
  delivery: TelegramBusFollowerDeliveryIdentity;
321
426
  sentAtMs: number;
427
+ } | {
428
+ kind: "leader.prepareLiveRebind";
429
+ requestId: string;
430
+ recipientInstanceId: string;
431
+ recipientRegistrationGeneration: string;
432
+ recipientSessionId: string;
433
+ recipientBindingKey: string;
434
+ operationId: string;
435
+ updates: ({
436
+ update_id: number;
437
+ } & Record<string, unknown>)[];
438
+ selectedCommand?: TelegramBusSelectedCommandInput;
439
+ sentAtMs: number;
440
+ } | {
441
+ kind: "leader.applyLiveRebind";
442
+ requestId: string;
443
+ recipientInstanceId: string;
444
+ recipientRegistrationGeneration: string;
445
+ recipientSessionId: string;
446
+ recipientBindingKey: string;
447
+ operationId: string;
448
+ sourceUpdateIds: number[];
449
+ mode: "apply" | "inspect";
450
+ preparedSource?: TelegramBusPreparedCommandSource;
451
+ selectedCommand?: TelegramBusSelectedCommandInput;
452
+ sentAtMs: number;
453
+ } | {
454
+ kind: "leader.settleLiveRebind";
455
+ requestId: string;
456
+ recipientInstanceId: string;
457
+ recipientRegistrationGeneration: string;
458
+ recipientSessionId: string;
459
+ recipientBindingKey: string;
460
+ operationId: string;
461
+ sourceUpdateIds: number[];
462
+ mode: "release" | "discard" | "observe" | "observe-command";
463
+ oldTarget?: TelegramTarget & {
464
+ threadId: number;
465
+ };
466
+ preparedSource?: TelegramBusPreparedCommandSource;
467
+ selectedCommand?: TelegramBusSelectedCommandInput;
468
+ sentAtMs: number;
322
469
  } | {
323
470
  kind: "leader.workspaceRestore";
324
471
  requestId: string;
@@ -370,7 +517,7 @@ export type TelegramBusEnvelope = ({
370
517
  registrationGeneration?: string;
371
518
  message: TelegramBusAgentMessage;
372
519
  sentAtMs: number;
373
- } | {
520
+ } | TelegramBusSelectedMenuDelivery | {
374
521
  kind: "follower.callApi";
375
522
  requestId: string;
376
523
  instanceId: string;
@@ -394,6 +541,14 @@ export type TelegramBusEnvelope = ({
394
541
  }) & {
395
542
  auth?: string;
396
543
  };
544
+ /** Follower-staged queue handoff offer before the follower adds its own request and registration framing. */
545
+ export type TelegramBusFollowerQueueHandoffOffer = Omit<Extract<TelegramBusEnvelope, {
546
+ kind: "follower.offerQueueHandoff";
547
+ }>, "kind" | "requestId" | "instanceId" | "registrationGeneration" | "sentAtMs" | "auth">;
548
+ /** Leader-routed queue handoff offer as donors and leaders exchange it before envelope framing. */
549
+ export type TelegramBusLeaderQueueHandoffOffer = Omit<Extract<TelegramBusEnvelope, {
550
+ kind: "leader.offerQueueHandoff";
551
+ }>, "kind">;
397
552
  type TelegramBusEnvelopeTrafficClass = "bootstrap" | "generation-fenced" | "response";
398
553
  export declare function getTelegramBusEnvelopeTrafficClass(envelope: TelegramBusEnvelope): TelegramBusEnvelopeTrafficClass;
399
554
  export declare function createTelegramBusRequestId(input: {
@@ -419,7 +574,13 @@ interface TelegramBusLocalServerDeps {
419
574
  requestLedgerMaxEntries?: number;
420
575
  shouldDropResponse?: (request: TelegramBusEnvelope, response: TelegramBusEnvelope) => boolean;
421
576
  }
577
+ /** Local IPC issuance proof only: this callback/error never enters the envelope or certifies a remote API effect. */
578
+ export declare class TelegramBusLocalAuthorityError extends Error {
579
+ readonly requestIssued: boolean;
580
+ constructor(requestIssued: boolean, reason?: string);
581
+ }
422
582
  interface TelegramBusLocalClientOptions {
583
+ assertAuthority?: () => void;
423
584
  socketPath: string;
424
585
  envelope: TelegramBusEnvelope;
425
586
  timeoutMs?: number;
@@ -504,7 +665,41 @@ export declare function createTelegramBusWorkspaceRestoreController(deps: {
504
665
  mode: "apply" | "inspect";
505
666
  isCurrent: () => boolean;
506
667
  }) => Promise<TelegramBusWorkspaceRestoreObservation | undefined>;
668
+ /** Each capability has its own effect boundary; transport retries never replay save/dispatch/disposal. */
669
+ export declare function createTelegramBusLiveRebindController(deps: {
670
+ getFollower(instanceId: string): TelegramBusFollowerView | undefined;
671
+ localProtocolIdentity: TelegramBusProtocolIdentity;
672
+ createRequestId(): string;
673
+ getAuthSecret(): string | undefined;
674
+ timeoutMs?: number;
675
+ }): (input: {
676
+ operationId: string;
677
+ instanceId: string;
678
+ sessionId: string;
679
+ recipientBindingKey: string;
680
+ isCurrent(): boolean;
681
+ selectedCommand?: TelegramBusSelectedCommandInput;
682
+ preparedSource?: TelegramBusPreparedCommandSource;
683
+ } & ({
684
+ updates: ({
685
+ update_id: number;
686
+ } & Record<string, unknown>)[];
687
+ } | {
688
+ mode: "apply" | "inspect" | "release" | "discard" | "observe" | "observe-command";
689
+ sourceUpdateIds: number[];
690
+ slot: string;
691
+ target: TelegramTarget & {
692
+ threadId: number;
693
+ };
694
+ oldTarget: TelegramTarget & {
695
+ threadId: number;
696
+ };
697
+ })) => Promise<TelegramBusLiveRebindSaveObservation | TelegramBusLiveRebindApplyObservation | TelegramBusLiveRebindSettlementObservation | TelegramBusLiveRebindWorkObservation | TelegramBusLiveRebindCommandObservation | undefined>;
507
698
  export declare function isTelegramBusEnvelopeAuthorized(envelope: TelegramBusEnvelope, secret: string | undefined): boolean;
699
+ /** Negative acknowledgement carrying only a diagnostic message. */
700
+ export declare function rejectTelegramBusRequest(requestId: string, message: string): Extract<TelegramBusEnvelope, {
701
+ kind: "bus.ack";
702
+ }>;
508
703
  export declare function createUnauthorizedBusAck(requestId: string): TelegramBusEnvelope;
509
704
  export declare function createTelegramBusLocalServer(deps: TelegramBusLocalServerDeps): TelegramBusLocalServer;
510
705
  export declare function sendTelegramBusLocalEnvelope(options: TelegramBusLocalClientOptions): Promise<TelegramBusEnvelope | undefined>;
@@ -524,4 +719,6 @@ export interface TelegramBusFollowerRegistry {
524
719
  }
525
720
  export declare function createTelegramBusForwardOwnershipValidator(registry: Pick<TelegramBusFollowerRegistry, "get">): (ownership: TelegramBusForwardOwnership) => boolean;
526
721
  export declare function createTelegramBusFollowerRegistry(): TelegramBusFollowerRegistry;
722
+ /** Shared closed text-effect codec; parsing alone supplies no recipient or issuance authority. */
723
+ export declare function parseTelegramBusSelectedMenuTextEffect(effect: unknown): TelegramBusSelectedMenuTextEffect | undefined;
527
724
  export {};