@llblab/pi-kit 0.27.6 → 0.28.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 (182) hide show
  1. package/BACKLOG.md +2 -5
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +2 -2
  4. package/node_modules/@llblab/pi-telegram/AGENTS.md +10 -8
  5. package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -9
  6. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +13 -0
  7. package/node_modules/@llblab/pi-telegram/LICENSE +21 -0
  8. package/node_modules/@llblab/pi-telegram/README.md +15 -5
  9. package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.d.ts +1 -5
  10. package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.js +5 -7
  11. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +5 -1
  12. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +6 -1
  13. package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.js +4 -2
  14. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +54 -56
  15. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +206 -139
  16. package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.d.ts +21 -2
  17. package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.js +181 -25
  18. package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.d.ts +4 -1
  19. package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.js +28 -4
  20. package/node_modules/@llblab/pi-telegram/dist/lib/bus.d.ts +52 -56
  21. package/node_modules/@llblab/pi-telegram/dist/lib/bus.js +78 -246
  22. package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.d.ts +1 -3
  23. package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.js +23 -26
  24. package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.d.ts +0 -5
  25. package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.js +5 -5
  26. package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +0 -23
  27. package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +15 -15
  28. package/node_modules/@llblab/pi-telegram/dist/lib/config.d.ts +0 -17
  29. package/node_modules/@llblab/pi-telegram/dist/lib/config.js +12 -14
  30. package/node_modules/@llblab/pi-telegram/dist/lib/delivery.d.ts +0 -4
  31. package/node_modules/@llblab/pi-telegram/dist/lib/delivery.js +2 -5
  32. package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +255 -61
  33. package/node_modules/@llblab/pi-telegram/dist/lib/generative-apps.d.ts +0 -19
  34. package/node_modules/@llblab/pi-telegram/dist/lib/inbound.d.ts +0 -2
  35. package/node_modules/@llblab/pi-telegram/dist/lib/inbound.js +2 -2
  36. package/node_modules/@llblab/pi-telegram/dist/lib/journal.d.ts +177 -16
  37. package/node_modules/@llblab/pi-telegram/dist/lib/journal.js +1115 -249
  38. package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.d.ts +0 -2
  39. package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.js +2 -2
  40. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +1 -1
  41. package/node_modules/@llblab/pi-telegram/dist/lib/locks.d.ts +100 -12
  42. package/node_modules/@llblab/pi-telegram/dist/lib/locks.js +380 -14
  43. package/node_modules/@llblab/pi-telegram/dist/lib/logging.d.ts +30 -12
  44. package/node_modules/@llblab/pi-telegram/dist/lib/logging.js +129 -72
  45. package/node_modules/@llblab/pi-telegram/dist/lib/media.d.ts +28 -5
  46. package/node_modules/@llblab/pi-telegram/dist/lib/media.js +26 -8
  47. package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.d.ts +0 -11
  48. package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.js +8 -8
  49. package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.d.ts +0 -18
  50. package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.js +18 -18
  51. package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.d.ts +4 -4
  52. package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.js +12 -7
  53. package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.d.ts +1 -1
  54. package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.js +1 -1
  55. package/node_modules/@llblab/pi-telegram/dist/lib/menu.d.ts +1 -0
  56. package/node_modules/@llblab/pi-telegram/dist/lib/menu.js +4 -3
  57. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.d.ts +0 -1
  58. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.js +1 -1
  59. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-buttons.js +1 -8
  60. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.d.ts +1 -6
  61. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.js +4 -21
  62. package/node_modules/@llblab/pi-telegram/dist/lib/outbound.d.ts +0 -8
  63. package/node_modules/@llblab/pi-telegram/dist/lib/outbound.js +5 -5
  64. package/node_modules/@llblab/pi-telegram/dist/lib/paths.d.ts +50 -7
  65. package/node_modules/@llblab/pi-telegram/dist/lib/paths.js +155 -17
  66. package/node_modules/@llblab/pi-telegram/dist/lib/pi.d.ts +1 -0
  67. package/node_modules/@llblab/pi-telegram/dist/lib/pi.js +2 -1
  68. package/node_modules/@llblab/pi-telegram/dist/lib/polling.d.ts +0 -5
  69. package/node_modules/@llblab/pi-telegram/dist/lib/polling.js +5 -5
  70. package/node_modules/@llblab/pi-telegram/dist/lib/preview.d.ts +0 -3
  71. package/node_modules/@llblab/pi-telegram/dist/lib/preview.js +3 -3
  72. package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.d.ts +0 -1
  73. package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.js +1 -1
  74. package/node_modules/@llblab/pi-telegram/dist/lib/queue.d.ts +3 -15
  75. package/node_modules/@llblab/pi-telegram/dist/lib/queue.js +69 -8
  76. package/node_modules/@llblab/pi-telegram/dist/lib/recovery.d.ts +29 -9
  77. package/node_modules/@llblab/pi-telegram/dist/lib/recovery.js +104 -33
  78. package/node_modules/@llblab/pi-telegram/dist/lib/replies.d.ts +0 -4
  79. package/node_modules/@llblab/pi-telegram/dist/lib/replies.js +1 -1
  80. package/node_modules/@llblab/pi-telegram/dist/lib/routing.d.ts +73 -8
  81. package/node_modules/@llblab/pi-telegram/dist/lib/routing.js +2206 -307
  82. package/node_modules/@llblab/pi-telegram/dist/lib/sections.d.ts +0 -2
  83. package/node_modules/@llblab/pi-telegram/dist/lib/sections.js +1 -1
  84. package/node_modules/@llblab/pi-telegram/dist/lib/status.d.ts +44 -9
  85. package/node_modules/@llblab/pi-telegram/dist/lib/status.js +149 -27
  86. package/node_modules/@llblab/pi-telegram/dist/lib/sync.d.ts +0 -5
  87. package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +5 -4
  88. package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.d.ts +11 -3
  89. package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.js +34 -23
  90. package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.d.ts +1 -0
  91. package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.js +18 -21
  92. package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.d.ts +32 -5
  93. package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.js +191 -7
  94. package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.d.ts +2 -0
  95. package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.js +1 -1
  96. package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +291 -59
  97. package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +1647 -369
  98. package/node_modules/@llblab/pi-telegram/dist/lib/turns.d.ts +0 -1
  99. package/node_modules/@llblab/pi-telegram/dist/lib/turns.js +1 -1
  100. package/node_modules/@llblab/pi-telegram/dist/lib/updates.d.ts +184 -28
  101. package/node_modules/@llblab/pi-telegram/dist/lib/updates.js +1032 -114
  102. package/node_modules/@llblab/pi-telegram/dist/lib/wire.d.ts +12 -0
  103. package/node_modules/@llblab/pi-telegram/dist/lib/wire.js +21 -0
  104. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.d.ts +25 -17
  105. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.js +95 -20
  106. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-identity.d.ts +20 -0
  107. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-identity.js +103 -0
  108. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +43 -8
  109. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +148 -52
  110. package/node_modules/@llblab/pi-telegram/dist/package.json +6 -6
  111. package/node_modules/@llblab/pi-telegram/dist/skills/generated-control-surface/SKILL.md +3 -3
  112. package/node_modules/@llblab/pi-telegram/dist/skills/telegram-bridge/references/diagnosis.md +3 -3
  113. package/node_modules/@llblab/pi-telegram/docs/README.md +1 -1
  114. package/node_modules/@llblab/pi-telegram/docs/activity.md +1 -1
  115. package/node_modules/@llblab/pi-telegram/docs/architecture.md +152 -34
  116. package/node_modules/@llblab/pi-telegram/docs/callback-namespaces.md +1 -1
  117. package/node_modules/@llblab/pi-telegram/docs/delivery.md +1 -1
  118. package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +2 -2
  119. package/node_modules/@llblab/pi-telegram/docs/inbound.md +1 -1
  120. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +125 -19
  121. package/node_modules/@llblab/pi-telegram/docs/public-api.md +3 -1
  122. package/node_modules/@llblab/pi-telegram/docs/ui-style.md +22 -8
  123. package/node_modules/@llblab/pi-telegram/docs/updates.md +1 -1
  124. package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +5 -9
  125. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +6 -0
  126. package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +5 -2
  127. package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +243 -224
  128. package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +178 -31
  129. package/node_modules/@llblab/pi-telegram/lib/bus-transport.ts +30 -8
  130. package/node_modules/@llblab/pi-telegram/lib/bus.ts +110 -334
  131. package/node_modules/@llblab/pi-telegram/lib/channel-posts.ts +29 -29
  132. package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +5 -5
  133. package/node_modules/@llblab/pi-telegram/lib/commands.ts +15 -15
  134. package/node_modules/@llblab/pi-telegram/lib/config.ts +12 -17
  135. package/node_modules/@llblab/pi-telegram/lib/delivery.ts +2 -8
  136. package/node_modules/@llblab/pi-telegram/lib/extension.ts +257 -72
  137. package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +0 -22
  138. package/node_modules/@llblab/pi-telegram/lib/inbound.ts +2 -2
  139. package/node_modules/@llblab/pi-telegram/lib/journal.ts +1182 -326
  140. package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +2 -2
  141. package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +1 -1
  142. package/node_modules/@llblab/pi-telegram/lib/locks.ts +402 -23
  143. package/node_modules/@llblab/pi-telegram/lib/logging.ts +151 -101
  144. package/node_modules/@llblab/pi-telegram/lib/media.ts +51 -9
  145. package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +8 -8
  146. package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +18 -18
  147. package/node_modules/@llblab/pi-telegram/lib/menu-status.ts +11 -0
  148. package/node_modules/@llblab/pi-telegram/lib/menu-thinking.ts +2 -2
  149. package/node_modules/@llblab/pi-telegram/lib/menu.ts +5 -1
  150. package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +1 -1
  151. package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +1 -10
  152. package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +5 -24
  153. package/node_modules/@llblab/pi-telegram/lib/outbound.ts +5 -5
  154. package/node_modules/@llblab/pi-telegram/lib/paths.ts +177 -17
  155. package/node_modules/@llblab/pi-telegram/lib/pi.ts +5 -2
  156. package/node_modules/@llblab/pi-telegram/lib/polling.ts +5 -5
  157. package/node_modules/@llblab/pi-telegram/lib/preview.ts +3 -3
  158. package/node_modules/@llblab/pi-telegram/lib/prompt-templates.ts +1 -1
  159. package/node_modules/@llblab/pi-telegram/lib/queue.ts +67 -9
  160. package/node_modules/@llblab/pi-telegram/lib/recovery.ts +104 -44
  161. package/node_modules/@llblab/pi-telegram/lib/replies.ts +1 -1
  162. package/node_modules/@llblab/pi-telegram/lib/routing.ts +1955 -375
  163. package/node_modules/@llblab/pi-telegram/lib/sections.ts +1 -1
  164. package/node_modules/@llblab/pi-telegram/lib/status.ts +156 -36
  165. package/node_modules/@llblab/pi-telegram/lib/sync.ts +4 -4
  166. package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +48 -33
  167. package/node_modules/@llblab/pi-telegram/lib/thread-cleanup-manager.ts +24 -21
  168. package/node_modules/@llblab/pi-telegram/lib/thread-naming.ts +267 -9
  169. package/node_modules/@llblab/pi-telegram/lib/thread-reconciler.ts +3 -1
  170. package/node_modules/@llblab/pi-telegram/lib/threads.ts +1697 -488
  171. package/node_modules/@llblab/pi-telegram/lib/turns.ts +1 -1
  172. package/node_modules/@llblab/pi-telegram/lib/updates.ts +1072 -151
  173. package/node_modules/@llblab/pi-telegram/lib/wire.ts +28 -0
  174. package/node_modules/@llblab/pi-telegram/lib/workspace-admission.ts +97 -47
  175. package/node_modules/@llblab/pi-telegram/lib/workspace-identity.ts +147 -0
  176. package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +188 -89
  177. package/node_modules/@llblab/pi-telegram/package.json +6 -6
  178. package/node_modules/@llblab/pi-telegram/scripts/audit-exports.mjs +100 -0
  179. package/node_modules/@llblab/pi-telegram/scripts/check-downgrade.mjs +80 -43
  180. package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +3 -3
  181. package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/references/diagnosis.md +3 -3
  182. package/package.json +2 -2
@@ -10,14 +10,7 @@ import { type TelegramWorkspaceAdmissionLedger, type TelegramWorkspaceAdmissionS
10
10
  export declare const TELEGRAM_UPDATE_JOURNAL_VERSION: 1;
11
11
  export declare const TELEGRAM_UPDATE_JOURNAL_EXCLUSION_VERSION: 2;
12
12
  export declare const TELEGRAM_UPDATE_JOURNAL_CUSTODY_VERSION: 3;
13
- export declare const TELEGRAM_UPDATE_JOURNAL_MAX_ENTRIES = 10000;
14
- export declare const TELEGRAM_UPDATE_JOURNAL_MAX_BYTES: number;
15
- export declare const TELEGRAM_UPDATE_JOURNAL_FAILURE_ID_MAX_LENGTH = 128;
16
13
  export declare const TELEGRAM_UPDATE_JOURNAL_QUEUE_OWNER_ID_MAX_LENGTH = 256;
17
- export declare const TELEGRAM_UPDATE_JOURNAL_INPUT_BINDING_MAX_LENGTH = 256;
18
- export declare const TELEGRAM_UPDATE_JOURNAL_QUEUE_HANDOFF_ID_MAX_LENGTH = 128;
19
- export declare const TELEGRAM_UPDATE_JOURNAL_QUEUE_HANDOFF_TOKEN_MIN_LENGTH = 32;
20
- export declare const TELEGRAM_UPDATE_JOURNAL_QUEUE_HANDOFF_TOKEN_MAX_LENGTH = 256;
21
14
  export declare const TELEGRAM_UPDATE_JOURNAL_FAILURE_CLASS_MAX_LENGTH = 128;
22
15
  export declare const TELEGRAM_UPDATE_JOURNAL_FAILURE_SUMMARY_MAX_LENGTH = 512;
23
16
  export interface TelegramFollowerJournalDiscovery {
@@ -29,7 +22,17 @@ export declare function discoverTelegramFollowerJournalPaths(input: {
29
22
  directory: string;
30
23
  profileName?: string;
31
24
  }): TelegramFollowerJournalDiscovery;
32
- export declare const TELEGRAM_UPDATE_JOURNAL_TERMINAL_REASON_MAX_LENGTH = 256;
25
+ /** Bounded read-only session-family discovery, not writer closure or deletion authority. */
26
+ export declare function discoverTelegramSessionJournalPaths(input: {
27
+ directory: string;
28
+ profileName?: string;
29
+ maxDirectoryEntries?: number;
30
+ }): TelegramFollowerJournalDiscovery;
31
+ /** Transitional discovery covers both retained flat recipients and session-owned families. */
32
+ export declare function discoverTelegramRecipientJournalPaths(input: {
33
+ directory: string;
34
+ profileName?: string;
35
+ }): TelegramFollowerJournalDiscovery;
33
36
  export declare const TELEGRAM_UPDATE_JOURNAL_COMPACTION_SEGMENT_COUNT = 256;
34
37
  export declare const TELEGRAM_UPDATE_JOURNAL_COMPACTION_SEGMENT_BYTES: number;
35
38
  export type TelegramUpdateJournalErrorCode = "capacity" | "conflict" | "identity-mismatch" | "invalid" | "io" | "unsupported-version" | "pairing-evidence" | "sender-denied";
@@ -113,7 +116,6 @@ export interface TelegramUpdateJournalLegacyCustodyCandidate {
113
116
  failureClass: string;
114
117
  evidenceSha256: string;
115
118
  }
116
- export declare function listTelegramUpdateJournalLegacyCustodyCandidates(snapshot: Pick<TelegramUpdateJournalSnapshot, "entries">): TelegramUpdateJournalLegacyCustodyCandidate[];
117
119
  export interface TelegramUpdateJournalLegacyCustodyDispositionAuthority {
118
120
  version: 1;
119
121
  dispositionId: string;
@@ -146,12 +148,21 @@ export interface TelegramUpdateJournalLegacyCustodyDisposition {
146
148
  authorizedAtMs: number;
147
149
  }
148
150
  export type TelegramUpdateJournalOperatorDisposition = TelegramUpdateJournalTerminalOperatorDisposition | TelegramUpdateJournalLegacyCustodyDisposition;
151
+ export declare const TELEGRAM_ROUTING_INPUT_TTL_MS: number;
152
+ /** A source-only choice deadline, never a queue lease or a Thread deletion grant. */
153
+ export interface TelegramUpdateJournalRoutingInput {
154
+ operatorUserId: number;
155
+ publishedAtMs: number;
156
+ expiresAtMs: number;
157
+ phase: "waiting" | "selected";
158
+ }
149
159
  export interface TelegramUpdateJournalEntry {
150
160
  updateId: number;
151
161
  update: TelegramJournaledUpdate;
152
162
  /** Mandatory in v2/v3; immutable veto, never sender authorization. Absent only in legacy v1. */
153
163
  preApprovalExcluded?: boolean;
154
164
  admittedAtMs: number;
165
+ routingInput?: TelegramUpdateJournalRoutingInput;
155
166
  state: TelegramUpdateJournalEntryState;
156
167
  queueKind?: TelegramUpdateJournalQueueKind;
157
168
  queueReceiptId?: string;
@@ -165,6 +176,16 @@ export interface TelegramUpdateJournalEntry {
165
176
  terminalReason?: string;
166
177
  terminalFailureId?: string;
167
178
  }
179
+ /** Exact parsed journal entry identity, checked inside the source owner's mutation transaction. */
180
+ export interface TelegramUpdateJournalEntryDigest {
181
+ updateId: number;
182
+ sourceSha256: string;
183
+ }
184
+ /** Journal-owned removal ACK bound to an opaque, immutable caller acceptance scope. */
185
+ export interface TelegramUpdateJournalSourceCompletion extends TelegramUpdateJournalEntryDigest {
186
+ completionSha256: string;
187
+ }
188
+ export declare function createTelegramUpdateJournalEntryDigest(entry: TelegramUpdateJournalEntry): TelegramUpdateJournalEntryDigest;
168
189
  export interface TelegramUpdateJournalFile {
169
190
  version: typeof TELEGRAM_UPDATE_JOURNAL_VERSION | typeof TELEGRAM_UPDATE_JOURNAL_EXCLUSION_VERSION | typeof TELEGRAM_UPDATE_JOURNAL_CUSTODY_VERSION;
170
191
  revision?: number;
@@ -173,6 +194,7 @@ export interface TelegramUpdateJournalFile {
173
194
  botIdentity: TelegramUpdateJournalBotIdentity;
174
195
  entries: TelegramUpdateJournalEntry[];
175
196
  operatorDispositions?: TelegramUpdateJournalOperatorDisposition[];
197
+ sourceCompletions?: TelegramUpdateJournalSourceCompletion[];
176
198
  }
177
199
  export interface TelegramUpdateJournalSnapshot extends TelegramUpdateJournalFile {
178
200
  exists: boolean;
@@ -187,6 +209,7 @@ export interface TelegramUpdateJournalAppendResult {
187
209
  serializedBytes: number;
188
210
  }
189
211
  export interface TelegramUpdateJournalRemoveResult {
212
+ sourceCompletions?: TelegramUpdateJournalSourceCompletion[];
190
213
  removedUpdateIds: number[];
191
214
  entryCount: number;
192
215
  serializedBytes: number;
@@ -204,6 +227,11 @@ export interface TelegramUpdateJournalQueueResult {
204
227
  entryCount: number;
205
228
  serializedBytes: number;
206
229
  }
230
+ export interface TelegramUpdateJournalQueuedReceiptEvidence {
231
+ receipt: TelegramUpdateJournalQueuedCompletion;
232
+ sources: TelegramUpdateJournalEntryDigest[];
233
+ queueOwnerSha256: string;
234
+ }
207
235
  export interface TelegramUpdateJournalQueuedCompletion {
208
236
  queueKind: TelegramUpdateJournalQueueKind;
209
237
  receiptId: string;
@@ -306,8 +334,67 @@ export interface TelegramUpdateJournalOperatorDispositionResult {
306
334
  entryCount: number;
307
335
  serializedBytes: number;
308
336
  }
337
+ export interface TelegramUpdateJournalPendingAbandonmentInput {
338
+ journalBindingKey: string;
339
+ entry: TelegramUpdateJournalEntry;
340
+ operatorAuthorityId: string;
341
+ /** Caller proves owner authorization and excludes live chooser/worker dispatch through publication. */
342
+ isCurrent: () => boolean;
343
+ }
344
+ export interface TelegramUpdateJournalPendingAbandonmentResult {
345
+ disposition: TelegramUpdateJournalLegacyCustodyDisposition;
346
+ retainedPath: string;
347
+ duplicate: boolean;
348
+ entryCount: number;
349
+ serializedBytes: number;
350
+ }
351
+ /** Private evidence copy, not execution authority or proof that abandonment committed. */
352
+ export interface TelegramUpdateJournalRetainedInput {
353
+ version: 1;
354
+ kind: "pending-input-retention";
355
+ journalBindingKey: string;
356
+ entry: TelegramUpdateJournalEntry;
357
+ requestedDisposition: TelegramUpdateJournalLegacyCustodyDisposition;
358
+ }
359
+ export interface TelegramUpdateJournalPendingRetentionEvidence {
360
+ journalBindingKey: string;
361
+ retainedPath: string;
362
+ requestedDisposition: TelegramUpdateJournalLegacyCustodyDisposition;
363
+ }
364
+ /** Durable proof that an owner abandoned this exact pending source; never delivery or completion proof. */
365
+ export interface TelegramUpdateJournalAbandonedPendingEvidence {
366
+ journalBindingKey: string;
367
+ updateId: number;
368
+ retainedPath: string;
369
+ operatorAuthorityId: string;
370
+ }
371
+ export interface TelegramRoutingInputAuthority {
372
+ journalBindingKey: string;
373
+ entries: readonly TelegramUpdateJournalEntry[];
374
+ operatorUserId: number;
375
+ isCurrent(): boolean;
376
+ }
377
+ /** Package-private v1 capability; raw input custody does not expose it. */
378
+ export interface TelegramRoutingInputJournal {
379
+ arm(input: TelegramRoutingInputAuthority & {
380
+ publishedAtMs: number;
381
+ }): TelegramUpdateJournalEntry[];
382
+ select(input: TelegramRoutingInputAuthority): {
383
+ issued: boolean;
384
+ entries: TelegramUpdateJournalEntry[];
385
+ };
386
+ expire(input: Omit<TelegramRoutingInputAuthority, "entries"> & {
387
+ entry: TelegramUpdateJournalEntry;
388
+ }): TelegramUpdateJournalPendingAbandonmentResult;
389
+ }
309
390
  export interface TelegramUpdateJournalStore {
391
+ routingInputs?: TelegramRoutingInputJournal;
310
392
  read(): TelegramUpdateJournalSnapshot;
393
+ /** Read-only: the committed abandonment tombstone plus its matching private retention, or undefined. */
394
+ inspectAbandonedPending(updateId: number): TelegramUpdateJournalAbandonedPendingEvidence | undefined;
395
+ /** Read-only protection evidence for this snapshot entry, never commit/execution authority. */
396
+ inspectPendingRetention(entry: TelegramUpdateJournalEntry): TelegramUpdateJournalPendingRetentionEvidence | undefined;
397
+ abandonPending(input: TelegramUpdateJournalPendingAbandonmentInput): TelegramUpdateJournalPendingAbandonmentResult;
311
398
  appendBatch<TUpdate extends TelegramUpdateJournalInput>(updates: readonly TUpdate[], acceptedThroughUpdateId?: number): TelegramUpdateJournalAppendResult;
312
399
  markQueued(receipt: TelegramUpdateJournalQueueReceipt): TelegramUpdateJournalQueueResult;
313
400
  markExecutionFailure(input: TelegramUpdateJournalFailureInput): TelegramUpdateJournalFailureResult;
@@ -317,16 +404,28 @@ export interface TelegramUpdateJournalStore {
317
404
  acceptQueuedHandoff(input: TelegramUpdateJournalQueueHandoffInput): TelegramUpdateJournalQueueHandoffAcceptResult;
318
405
  cancelQueuedHandoff(input: TelegramUpdateJournalQueueHandoffInput): TelegramUpdateJournalQueueHandoffCancelResult;
319
406
  completeQueued(receipts: readonly TelegramUpdateJournalQueuedCompletion[]): TelegramUpdateJournalRemoveResult;
407
+ /** Strict v1 whole-receipt disposal co-publishes caller-scoped ACKs; never a readiness grant. */
408
+ completeQueuedExact(receipts: readonly TelegramUpdateJournalQueuedCompletion[], completions: readonly TelegramUpdateJournalSourceCompletion[]): TelegramUpdateJournalRemoveResult;
320
409
  discardQueued(input: TelegramUpdateJournalQueueDiscardInput): TelegramUpdateJournalQueueDiscardResult;
321
410
  recoverDeadQueueOwner(input: TelegramUpdateJournalDeadQueueOwnerRecoveryInput): TelegramUpdateJournalDeadQueueOwnerRecoveryResult;
322
411
  removeCompleted(updateIds: readonly number[]): TelegramUpdateJournalRemoveResult;
412
+ /** Guarded completion; every supplied source must still match, and absence is a conflict, not an ACK. */
413
+ removeCompletedExact(updateIds: readonly number[], expectedSources: readonly TelegramUpdateJournalEntryDigest[], completions?: readonly TelegramUpdateJournalSourceCompletion[]): TelegramUpdateJournalRemoveResult;
414
+ /** Strict read-only observation; neither source absence nor a different scope is completion evidence. */
415
+ inspectSourceCompletion(expected: TelegramUpdateJournalSourceCompletion): TelegramUpdateJournalSourceCompletion | undefined;
416
+ /** Complete strict observation of a retained, unoffered v1 queue receipt; never acquires readiness. */
417
+ inspectQueuedReceipt(expected: TelegramUpdateJournalQueuedCompletion): TelegramUpdateJournalQueuedReceiptEvidence | undefined;
418
+ isQueueReceiptCurrent?: (receipt: Pick<TelegramUpdateJournalQueuedCompletion, "queueKind" | "receiptId" | "sourceUpdateIds"> & {
419
+ journalBindingKey?: string;
420
+ }, owner: TelegramUpdateJournalQueueOwner) => boolean;
323
421
  }
324
422
  export type TelegramUpdateJournalPublicationBoundary = "before-write" | "after-write-before-rename";
325
423
  export interface TelegramUpdateJournalRecoveryEvent {
326
424
  kind: "repaired" | "reset";
327
425
  path: string;
328
426
  revision?: number;
329
- quarantinePath?: string;
427
+ /** Damaged snapshot/segment paths deleted or atomically replaced; nothing is retained for recovery. */
428
+ deletedPaths?: string[];
330
429
  reason: string;
331
430
  }
332
431
  export interface TelegramUpdateJournalStoreOptions {
@@ -498,6 +597,7 @@ export interface TelegramUpdateJournalSegment {
498
597
  upsertedEntries: TelegramUpdateJournalEntry[];
499
598
  removedUpdateIds: number[];
500
599
  operatorDispositions?: TelegramUpdateJournalOperatorDisposition[];
600
+ sourceCompletions?: TelegramUpdateJournalSourceCompletion[];
501
601
  }
502
602
  export interface TelegramUpdateJournalSegmentPublicationResult {
503
603
  path: string;
@@ -507,6 +607,8 @@ export interface TelegramUpdateJournalSegmentPublicationResult {
507
607
  export declare function parseTelegramUpdateJournalQueueOwner(value: unknown): TelegramUpdateJournalQueueOwner | undefined;
508
608
  export declare function isTelegramUpdateJournalQueueOwnerProcess(owner: TelegramUpdateJournalQueueOwner, identity: TelegramUpdateJournalQueueOwnerIdentity): boolean;
509
609
  export declare function areTelegramUpdateJournalQueueOwnersEqual(left: TelegramUpdateJournalQueueOwner, right: TelegramUpdateJournalQueueOwner): boolean;
610
+ /** Only legacy v1 carries routing-lifetime, scoped-ACK and pairing-free queue-receipt semantics. */
611
+ export declare function isTelegramUpdateJournalLegacyFamilyVersion(version: unknown): boolean;
510
612
  /**
511
613
  * Isolated evidence only: caller must serialize/quiesce writers before inspection
512
614
  * and consumption. Metadata checks detect observable changes, not hostile same-user
@@ -541,6 +643,18 @@ export declare function inspectTelegramUpdateJournalFamily(input: {
541
643
  work: number;
542
644
  };
543
645
  };
646
+ export interface TelegramUpdateJournalRetentionInspection {
647
+ evidence: ReturnType<typeof inspectTelegramUpdateJournalFamily>;
648
+ retainedInputs: {
649
+ path: string;
650
+ journalBindingKey: string;
651
+ failureId: string;
652
+ updateId: number;
653
+ state: "committed" | "uncommitted";
654
+ }[];
655
+ }
656
+ /** Classifies private originals against exact discard tombstones; never replay or deletion authority. */
657
+ export declare function inspectTelegramUpdateJournalRetention(input: Parameters<typeof inspectTelegramUpdateJournalFamily>[0]): TelegramUpdateJournalRetentionInspection;
544
658
  /**
545
659
  * Read-only source evidence for cooperating writers serialized by the caller through
546
660
  * consumption; never readiness, recovery, or permission to publish. Ancestors retain
@@ -560,7 +674,7 @@ export declare function readTelegramUpdateJournalSource(input: Parameters<typeof
560
674
  * Recensus detects observable changes, not hostile same-user path swaps; arbitrary
561
675
  * consumer references and archive consumption require separate audits.
562
676
  */
563
- export declare function inspectTelegramProfileJournalNamespace(input: {
677
+ export interface TelegramJournalNamespaceInspectionInput {
564
678
  directory: string;
565
679
  profile: string;
566
680
  botIdentity: TelegramUpdateJournalBotIdentity;
@@ -571,9 +685,18 @@ export declare function inspectTelegramProfileJournalNamespace(input: {
571
685
  maxEntries: number;
572
686
  maxWork: number;
573
687
  };
574
- }): {
688
+ /** Leader polling journal named by owners.json; defaults to the flat root `inbox`. */
689
+ pollingPath?: string;
690
+ /** Hold a participating consumer reference during each physical family read. */
691
+ withSourceReference?: <T>(path: string, operation: () => T) => T;
692
+ }
693
+ export interface TelegramJournalNamespaceInspection {
694
+ /** Original preservation facts only, never replay/deletion grants. */
695
+ retainedInputs?: (TelegramUpdateJournalRetentionInspection["retainedInputs"][number] & {
696
+ journalPath: string;
697
+ })[];
575
698
  sources: {
576
- role: "polling" | "follower";
699
+ role: "polling" | "follower" | "session";
577
700
  path: string;
578
701
  evidence: ReturnType<typeof inspectTelegramUpdateJournalFamily>;
579
702
  }[];
@@ -584,7 +707,15 @@ export declare function inspectTelegramProfileJournalNamespace(input: {
584
707
  work: number;
585
708
  };
586
709
  knownBotId?: number;
587
- };
710
+ }
711
+ export declare function inspectTelegramProfileJournalNamespace(input: TelegramJournalNamespaceInspectionInput): TelegramJournalNamespaceInspection;
712
+ /** Read-only evidence over polling, retained flat recipients and role-neutral session journals. */
713
+ export declare function inspectTelegramSessionJournalNamespace(input: TelegramJournalNamespaceInspectionInput): TelegramJournalNamespaceInspection;
714
+ /** Complete-empty protection only; caller holds source serialization through consumption. Never deletion authority. */
715
+ export declare function isTelegramThreadCleanupJournalNamespaceClear(input: TelegramJournalNamespaceInspectionInput & {
716
+ requiredJournalBindingKeys: readonly string[];
717
+ withSourceReference: NonNullable<TelegramJournalNamespaceInspectionInput["withSourceReference"]>;
718
+ }): boolean;
588
719
  export declare function publishTelegramUpdateJournalSegment(path: string, segment: TelegramUpdateJournalSegment): TelegramUpdateJournalSegmentPublicationResult;
589
720
  export declare function createTelegramUpdateQueueHandoffToken(): string;
590
721
  export declare function createTelegramUpdateJournalBotIdentity(input: {
@@ -612,6 +743,7 @@ export interface TelegramUpdateJournalRuntimeBinding {
612
743
  journal: TelegramUpdateJournalStore;
613
744
  readForProtection?: () => {
614
745
  entries: readonly TelegramUpdateJournalEntry[];
746
+ exists: boolean;
615
747
  };
616
748
  }
617
749
  export interface TelegramUpdateJournalRuntimeBindingResolverDeps {
@@ -621,8 +753,11 @@ export interface TelegramUpdateJournalRuntimeBindingResolverDeps {
621
753
  getJournalPath: (profileName?: string) => string;
622
754
  getQueueRuntimeIdentity?: () => TelegramUpdateJournalQueueRuntimeIdentity;
623
755
  withWriterAdmission?: <T>(operation: () => T) => T;
756
+ withSourceSerialization?: TelegramUpdateJournalStoreOptions["withSourceSerialization"];
624
757
  getWorkspaceAdmission?: () => Pick<TelegramWorkspaceAdmissionLedger, "acquireAdmission" | "releaseAdmission"> | undefined;
625
758
  onRecovery?: (event: TelegramUpdateJournalRecoveryEvent) => void;
759
+ /** Strict no-follow source handles; defaults to platform support (absent on Windows). */
760
+ strictSourceAccess?: boolean;
626
761
  }
627
762
  export declare function createTelegramUpdateJournalRuntimeBindingResolver(deps: TelegramUpdateJournalRuntimeBindingResolverDeps): () => TelegramUpdateJournalRuntimeBinding | undefined;
628
763
  export type TelegramUpdateJournalReferenceClass = "leader-lifecycle" | "follower-lifecycle" | "polling-cursor" | "polling-bootstrap" | "workspace-retirement" | "operator-disposition";
@@ -648,19 +783,45 @@ export declare function withTelegramResolvedUpdateJournalReference<T>(input: {
648
783
  referenceClass: TelegramUpdateJournalReferenceClass;
649
784
  operation(binding: TelegramUpdateJournalRuntimeBinding): T;
650
785
  }): T | undefined;
786
+ /** Operator-distinct authority: routing never treats it as an owner cancellation. */
787
+ export declare const TELEGRAM_SESSION_ADOPTION_AUTHORITY_PREFIX = "session-successor:";
788
+ export interface TelegramSessionPendingAdoptionInput {
789
+ recipientBindingKey: string;
790
+ predecessorSessionId: string;
791
+ successorSessionId: string;
792
+ /** Caller proves the successor registration is current and no predecessor worker runs. */
793
+ isCurrent: () => boolean;
794
+ }
795
+ export interface TelegramSessionPendingAdoptionResult {
796
+ adoptedUpdateIds: number[];
797
+ /** Already committed away by an earlier attempt; never re-appended, the private original remains. */
798
+ retainedUpdateIds: number[];
799
+ }
651
800
  export interface TelegramUpdateJournalBindingRuntime {
652
801
  resolveLeader: () => TelegramUpdateJournalRuntimeBinding | undefined;
653
802
  resolveFollower: () => TelegramUpdateJournalRuntimeBinding | undefined;
654
803
  resolveActive: () => TelegramUpdateJournalRuntimeBinding | undefined;
655
804
  getActiveRecoveryKey: () => string | undefined;
656
- createRecipientResolver: (recipientBindingKey: string) => () => TelegramUpdateJournalRuntimeBinding | undefined;
805
+ /** Exact historical proof lookup; no store, admission, execution, recovery or mutation port. */
806
+ inspectSourceAbandonment: (journalBindingKey: string, updateId: number) => TelegramUpdateJournalAbandonedPendingEvidence | undefined;
807
+ inspectSourceCompletion: (journalBindingKey: string, expected: TelegramUpdateJournalSourceCompletion) => TelegramUpdateJournalSourceCompletion | undefined;
808
+ inspectQueuedReceipt: (journalBindingKey: string, expected: TelegramUpdateJournalQueuedCompletion) => TelegramUpdateJournalQueuedReceiptEvidence | undefined;
809
+ /** In-process `/new` succession: move unclaimed predecessor pending inputs into the successor session journal. */
810
+ adoptPredecessorPending: (input: TelegramSessionPendingAdoptionInput) => TelegramSessionPendingAdoptionResult;
811
+ /** Process-local: adopts from the previously prepared session of the same recipient key, then records the active one. */
812
+ prepareActiveFollowerSuccession: (isCurrent: () => boolean) => TelegramSessionPendingAdoptionResult | undefined;
813
+ createRecipientResolver: (recipientBindingKey: string, sessionId?: string) => () => TelegramUpdateJournalRuntimeBinding | undefined;
814
+ createLegacyRecipientResolver: (recipientBindingKey: string) => () => TelegramUpdateJournalRuntimeBinding | undefined;
657
815
  createPathResolver: (path: string) => () => TelegramUpdateJournalRuntimeBinding | undefined;
658
816
  }
659
817
  export declare function createTelegramUpdateJournalBindingRuntime(deps: {
660
818
  base: Omit<TelegramUpdateJournalRuntimeBindingResolverDeps, "getJournalPath">;
661
819
  getLeaderJournalPath: (profileName?: string) => string;
662
- getFollowerJournalPath: (bindingKey: string, profileName?: string) => string;
820
+ /** Runtime root; defaults to the leader journal's directory for flat layouts. */
821
+ getRuntimeDir?: () => string;
822
+ getFollowerJournalPath: (bindingKey: string, profileName?: string, sessionId?: string) => string;
663
823
  getActiveFollowerBindingKey: () => string;
824
+ getActiveFollowerSessionId?: () => string | undefined;
664
825
  isFollowerRegistered: () => boolean;
665
826
  }): TelegramUpdateJournalBindingRuntime;
666
827
  export declare function createTelegramUpdateJournalStore(options: TelegramUpdateJournalStoreOptions): TelegramUpdateJournalStore;