@llblab/pi-kit 0.27.5 → 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 (194) hide show
  1. package/BACKLOG.md +3 -1
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +4 -4
  4. package/node_modules/@llblab/pi-state-flow/AGENTS.md +1 -1
  5. package/node_modules/@llblab/pi-state-flow/BACKLOG.md +6 -2
  6. package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +4 -1
  7. package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.js +4 -3
  8. package/node_modules/@llblab/pi-state-flow/dist/lib/extension.js +26 -13
  9. package/node_modules/@llblab/pi-state-flow/dist/package.json +1 -1
  10. package/node_modules/@llblab/pi-state-flow/docs/architecture.md +3 -1
  11. package/node_modules/@llblab/pi-state-flow/docs/compatibility.md +2 -2
  12. package/node_modules/@llblab/pi-state-flow/docs/usage.md +2 -1
  13. package/node_modules/@llblab/pi-state-flow/lib/compaction.ts +4 -3
  14. package/node_modules/@llblab/pi-state-flow/lib/extension.ts +25 -12
  15. package/node_modules/@llblab/pi-state-flow/package.json +1 -1
  16. package/node_modules/@llblab/pi-telegram/AGENTS.md +10 -8
  17. package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -9
  18. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +13 -0
  19. package/node_modules/@llblab/pi-telegram/LICENSE +21 -0
  20. package/node_modules/@llblab/pi-telegram/README.md +15 -5
  21. package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.d.ts +1 -5
  22. package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.js +5 -7
  23. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +5 -1
  24. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +6 -1
  25. package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.js +4 -2
  26. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +54 -56
  27. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +206 -139
  28. package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.d.ts +21 -2
  29. package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.js +181 -25
  30. package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.d.ts +4 -1
  31. package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.js +28 -4
  32. package/node_modules/@llblab/pi-telegram/dist/lib/bus.d.ts +52 -56
  33. package/node_modules/@llblab/pi-telegram/dist/lib/bus.js +78 -246
  34. package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.d.ts +1 -3
  35. package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.js +23 -26
  36. package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.d.ts +0 -5
  37. package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.js +5 -5
  38. package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +0 -23
  39. package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +15 -15
  40. package/node_modules/@llblab/pi-telegram/dist/lib/config.d.ts +0 -17
  41. package/node_modules/@llblab/pi-telegram/dist/lib/config.js +12 -14
  42. package/node_modules/@llblab/pi-telegram/dist/lib/delivery.d.ts +0 -4
  43. package/node_modules/@llblab/pi-telegram/dist/lib/delivery.js +2 -5
  44. package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +255 -61
  45. package/node_modules/@llblab/pi-telegram/dist/lib/generative-apps.d.ts +0 -19
  46. package/node_modules/@llblab/pi-telegram/dist/lib/inbound.d.ts +0 -2
  47. package/node_modules/@llblab/pi-telegram/dist/lib/inbound.js +2 -2
  48. package/node_modules/@llblab/pi-telegram/dist/lib/journal.d.ts +177 -16
  49. package/node_modules/@llblab/pi-telegram/dist/lib/journal.js +1115 -249
  50. package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.d.ts +0 -2
  51. package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.js +2 -2
  52. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +1 -1
  53. package/node_modules/@llblab/pi-telegram/dist/lib/locks.d.ts +100 -12
  54. package/node_modules/@llblab/pi-telegram/dist/lib/locks.js +380 -14
  55. package/node_modules/@llblab/pi-telegram/dist/lib/logging.d.ts +30 -12
  56. package/node_modules/@llblab/pi-telegram/dist/lib/logging.js +129 -72
  57. package/node_modules/@llblab/pi-telegram/dist/lib/media.d.ts +28 -5
  58. package/node_modules/@llblab/pi-telegram/dist/lib/media.js +26 -8
  59. package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.d.ts +0 -11
  60. package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.js +8 -8
  61. package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.d.ts +0 -18
  62. package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.js +18 -18
  63. package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.d.ts +4 -4
  64. package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.js +12 -7
  65. package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.d.ts +1 -1
  66. package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.js +1 -1
  67. package/node_modules/@llblab/pi-telegram/dist/lib/menu.d.ts +1 -0
  68. package/node_modules/@llblab/pi-telegram/dist/lib/menu.js +4 -3
  69. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.d.ts +0 -1
  70. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.js +1 -1
  71. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-buttons.js +1 -8
  72. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.d.ts +1 -6
  73. package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.js +4 -21
  74. package/node_modules/@llblab/pi-telegram/dist/lib/outbound.d.ts +0 -8
  75. package/node_modules/@llblab/pi-telegram/dist/lib/outbound.js +5 -5
  76. package/node_modules/@llblab/pi-telegram/dist/lib/paths.d.ts +50 -7
  77. package/node_modules/@llblab/pi-telegram/dist/lib/paths.js +155 -17
  78. package/node_modules/@llblab/pi-telegram/dist/lib/pi.d.ts +1 -0
  79. package/node_modules/@llblab/pi-telegram/dist/lib/pi.js +2 -1
  80. package/node_modules/@llblab/pi-telegram/dist/lib/polling.d.ts +0 -5
  81. package/node_modules/@llblab/pi-telegram/dist/lib/polling.js +5 -5
  82. package/node_modules/@llblab/pi-telegram/dist/lib/preview.d.ts +0 -3
  83. package/node_modules/@llblab/pi-telegram/dist/lib/preview.js +3 -3
  84. package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.d.ts +0 -1
  85. package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.js +1 -1
  86. package/node_modules/@llblab/pi-telegram/dist/lib/queue.d.ts +3 -15
  87. package/node_modules/@llblab/pi-telegram/dist/lib/queue.js +69 -8
  88. package/node_modules/@llblab/pi-telegram/dist/lib/recovery.d.ts +29 -9
  89. package/node_modules/@llblab/pi-telegram/dist/lib/recovery.js +104 -33
  90. package/node_modules/@llblab/pi-telegram/dist/lib/replies.d.ts +0 -4
  91. package/node_modules/@llblab/pi-telegram/dist/lib/replies.js +1 -1
  92. package/node_modules/@llblab/pi-telegram/dist/lib/routing.d.ts +73 -8
  93. package/node_modules/@llblab/pi-telegram/dist/lib/routing.js +2206 -307
  94. package/node_modules/@llblab/pi-telegram/dist/lib/sections.d.ts +0 -2
  95. package/node_modules/@llblab/pi-telegram/dist/lib/sections.js +1 -1
  96. package/node_modules/@llblab/pi-telegram/dist/lib/status.d.ts +44 -9
  97. package/node_modules/@llblab/pi-telegram/dist/lib/status.js +149 -27
  98. package/node_modules/@llblab/pi-telegram/dist/lib/sync.d.ts +0 -5
  99. package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +5 -4
  100. package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.d.ts +11 -3
  101. package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.js +34 -23
  102. package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.d.ts +1 -0
  103. package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.js +18 -21
  104. package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.d.ts +32 -5
  105. package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.js +191 -7
  106. package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.d.ts +2 -0
  107. package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.js +1 -1
  108. package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +291 -59
  109. package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +1647 -369
  110. package/node_modules/@llblab/pi-telegram/dist/lib/turns.d.ts +0 -1
  111. package/node_modules/@llblab/pi-telegram/dist/lib/turns.js +1 -1
  112. package/node_modules/@llblab/pi-telegram/dist/lib/updates.d.ts +184 -28
  113. package/node_modules/@llblab/pi-telegram/dist/lib/updates.js +1032 -114
  114. package/node_modules/@llblab/pi-telegram/dist/lib/wire.d.ts +12 -0
  115. package/node_modules/@llblab/pi-telegram/dist/lib/wire.js +21 -0
  116. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.d.ts +25 -17
  117. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.js +95 -20
  118. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-identity.d.ts +20 -0
  119. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-identity.js +103 -0
  120. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +43 -8
  121. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +148 -52
  122. package/node_modules/@llblab/pi-telegram/dist/package.json +6 -6
  123. package/node_modules/@llblab/pi-telegram/dist/skills/generated-control-surface/SKILL.md +3 -3
  124. package/node_modules/@llblab/pi-telegram/dist/skills/telegram-bridge/references/diagnosis.md +3 -3
  125. package/node_modules/@llblab/pi-telegram/docs/README.md +1 -1
  126. package/node_modules/@llblab/pi-telegram/docs/activity.md +1 -1
  127. package/node_modules/@llblab/pi-telegram/docs/architecture.md +152 -34
  128. package/node_modules/@llblab/pi-telegram/docs/callback-namespaces.md +1 -1
  129. package/node_modules/@llblab/pi-telegram/docs/delivery.md +1 -1
  130. package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +2 -2
  131. package/node_modules/@llblab/pi-telegram/docs/inbound.md +1 -1
  132. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +125 -19
  133. package/node_modules/@llblab/pi-telegram/docs/public-api.md +3 -1
  134. package/node_modules/@llblab/pi-telegram/docs/ui-style.md +22 -8
  135. package/node_modules/@llblab/pi-telegram/docs/updates.md +1 -1
  136. package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +5 -9
  137. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +6 -0
  138. package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +5 -2
  139. package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +243 -224
  140. package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +178 -31
  141. package/node_modules/@llblab/pi-telegram/lib/bus-transport.ts +30 -8
  142. package/node_modules/@llblab/pi-telegram/lib/bus.ts +110 -334
  143. package/node_modules/@llblab/pi-telegram/lib/channel-posts.ts +29 -29
  144. package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +5 -5
  145. package/node_modules/@llblab/pi-telegram/lib/commands.ts +15 -15
  146. package/node_modules/@llblab/pi-telegram/lib/config.ts +12 -17
  147. package/node_modules/@llblab/pi-telegram/lib/delivery.ts +2 -8
  148. package/node_modules/@llblab/pi-telegram/lib/extension.ts +257 -72
  149. package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +0 -22
  150. package/node_modules/@llblab/pi-telegram/lib/inbound.ts +2 -2
  151. package/node_modules/@llblab/pi-telegram/lib/journal.ts +1182 -326
  152. package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +2 -2
  153. package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +1 -1
  154. package/node_modules/@llblab/pi-telegram/lib/locks.ts +402 -23
  155. package/node_modules/@llblab/pi-telegram/lib/logging.ts +151 -101
  156. package/node_modules/@llblab/pi-telegram/lib/media.ts +51 -9
  157. package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +8 -8
  158. package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +18 -18
  159. package/node_modules/@llblab/pi-telegram/lib/menu-status.ts +11 -0
  160. package/node_modules/@llblab/pi-telegram/lib/menu-thinking.ts +2 -2
  161. package/node_modules/@llblab/pi-telegram/lib/menu.ts +5 -1
  162. package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +1 -1
  163. package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +1 -10
  164. package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +5 -24
  165. package/node_modules/@llblab/pi-telegram/lib/outbound.ts +5 -5
  166. package/node_modules/@llblab/pi-telegram/lib/paths.ts +177 -17
  167. package/node_modules/@llblab/pi-telegram/lib/pi.ts +5 -2
  168. package/node_modules/@llblab/pi-telegram/lib/polling.ts +5 -5
  169. package/node_modules/@llblab/pi-telegram/lib/preview.ts +3 -3
  170. package/node_modules/@llblab/pi-telegram/lib/prompt-templates.ts +1 -1
  171. package/node_modules/@llblab/pi-telegram/lib/queue.ts +67 -9
  172. package/node_modules/@llblab/pi-telegram/lib/recovery.ts +104 -44
  173. package/node_modules/@llblab/pi-telegram/lib/replies.ts +1 -1
  174. package/node_modules/@llblab/pi-telegram/lib/routing.ts +1955 -375
  175. package/node_modules/@llblab/pi-telegram/lib/sections.ts +1 -1
  176. package/node_modules/@llblab/pi-telegram/lib/status.ts +156 -36
  177. package/node_modules/@llblab/pi-telegram/lib/sync.ts +4 -4
  178. package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +48 -33
  179. package/node_modules/@llblab/pi-telegram/lib/thread-cleanup-manager.ts +24 -21
  180. package/node_modules/@llblab/pi-telegram/lib/thread-naming.ts +267 -9
  181. package/node_modules/@llblab/pi-telegram/lib/thread-reconciler.ts +3 -1
  182. package/node_modules/@llblab/pi-telegram/lib/threads.ts +1697 -488
  183. package/node_modules/@llblab/pi-telegram/lib/turns.ts +1 -1
  184. package/node_modules/@llblab/pi-telegram/lib/updates.ts +1072 -151
  185. package/node_modules/@llblab/pi-telegram/lib/wire.ts +28 -0
  186. package/node_modules/@llblab/pi-telegram/lib/workspace-admission.ts +97 -47
  187. package/node_modules/@llblab/pi-telegram/lib/workspace-identity.ts +147 -0
  188. package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +188 -89
  189. package/node_modules/@llblab/pi-telegram/package.json +6 -6
  190. package/node_modules/@llblab/pi-telegram/scripts/audit-exports.mjs +100 -0
  191. package/node_modules/@llblab/pi-telegram/scripts/check-downgrade.mjs +80 -43
  192. package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +3 -3
  193. package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/references/diagnosis.md +3 -3
  194. package/package.json +3 -3
@@ -4,12 +4,12 @@
4
4
  * Owns serializable bus envelopes, socket/auth helpers, local IPC client/server primitives,
5
5
  * cross-instance forwarding helpers, and the live follower registry model.
6
6
  */
7
- import { type TelegramBusTransportEventRecorder, type TelegramBusTransportRetryPolicy } from "./bus-transport.ts";
7
+ import { type TelegramBusEndpointLayout, type TelegramBusTransportEventRecorder, type TelegramBusTransportRetryPolicy } from "./bus-transport.ts";
8
8
  import { type TelegramQueueHandoffPayload } from "./queue.ts";
9
9
  import type { TelegramTarget } from "./target.ts";
10
10
  import type { TelegramThreadDisplayMode } from "./config.ts";
11
11
  import { type TelegramSessionReplacementIntent } from "./threads.ts";
12
- export interface TelegramBusProcessRuntime {
12
+ interface TelegramBusProcessRuntime {
13
13
  instanceId: string;
14
14
  processId: number;
15
15
  processBirthId: string;
@@ -17,22 +17,15 @@ export interface TelegramBusProcessRuntime {
17
17
  getLeaderSocketPath: () => string;
18
18
  getFollowerSocketPath: () => string;
19
19
  }
20
- export interface TelegramProcessBirthIdentityOptions {
20
+ interface TelegramProcessBirthIdentityOptions {
21
21
  platform?: NodeJS.Platform;
22
22
  readProcStat?: (pid: number) => string;
23
23
  readDarwinProcessStart?: (pid: number) => string;
24
24
  }
25
- export type TelegramProcessBirthProof = {
26
- status: "proven";
27
- identity: string;
28
- } | {
29
- status: "unverifiable";
30
- };
31
25
  export type TelegramProcessLiveness = "alive" | "dead" | "unverifiable";
32
- export interface TelegramProcessLivenessOptions extends TelegramProcessBirthIdentityOptions {
26
+ interface TelegramProcessLivenessOptions extends TelegramProcessBirthIdentityOptions {
33
27
  isProcessAlive?: (pid: number) => boolean;
34
28
  }
35
- export declare function getTelegramProcessBirthProof(pid: number, options?: TelegramProcessBirthIdentityOptions): TelegramProcessBirthProof;
36
29
  export declare function getTelegramProcessBirthIdentity(pid: number, fallbackGeneration: number | string, options?: TelegramProcessBirthIdentityOptions): string;
37
30
  export declare function getTelegramProcessLiveness(owner: {
38
31
  processId: number;
@@ -41,19 +34,20 @@ export declare function getTelegramProcessLiveness(owner: {
41
34
  export declare function getTelegramProcessBirthIdentityLiveness(processBirthId: string, options?: TelegramProcessLivenessOptions): TelegramProcessLiveness;
42
35
  export declare function createCurrentTelegramBusProcessRuntime(input: {
43
36
  getActiveProfileName: () => string | undefined;
37
+ endpointLayout?: TelegramBusEndpointLayout;
44
38
  pid?: number;
45
39
  parentPid?: number;
46
40
  createdAtMs?: number;
47
41
  }): TelegramBusProcessRuntime;
48
42
  export declare function createTelegramBusProcessRuntime(input: {
49
43
  getActiveProfileName: () => string | undefined;
44
+ endpointLayout?: TelegramBusEndpointLayout;
50
45
  pid: number;
51
46
  parentPid: number;
52
47
  parentProcessIdentity?: string;
53
48
  createdAtMs: number;
54
49
  }): TelegramBusProcessRuntime;
55
50
  export declare function createTelegramBusAuthSecret(): string;
56
- export declare const TELEGRAM_BUS_PROTOCOL_VERSION: 2;
57
51
  export declare const TELEGRAM_BUS_CAPABILITY_DURABLE_FOLLOWER_ADMISSION: "durable-follower-admission-v1";
58
52
  export declare const TELEGRAM_BUS_CAPABILITY_QUEUE_HANDOFF: "queue-handoff-v1";
59
53
  export declare const TELEGRAM_BUS_CAPABILITY_INPUT_CUSTODY_REFERENCE: "input-custody-reference-v1";
@@ -62,12 +56,27 @@ export declare const TELEGRAM_BUS_CAPABILITY_THREAD_DISPLAY_MODE: "thread-displa
62
56
  export declare const TELEGRAM_BUS_CAPABILITY_DIRECTORY_DISPLAY_FORMAT: "directory-display-format-v1";
63
57
  export declare const TELEGRAM_BUS_CAPABILITY_WORKSPACE_FOLLOWER_AUTO_CONNECT: "workspace-follower-auto-connect-v1";
64
58
  export declare const TELEGRAM_BUS_CAPABILITY_SESSION_REPLACEMENT_INTENT: "session-replacement-intent-v1";
59
+ export declare const TELEGRAM_BUS_CAPABILITY_WORKSPACE_RESTORE: "workspace-restore-v1";
60
+ export interface TelegramBusWorkspaceRestoreObservation {
61
+ operationId: string;
62
+ recipient: {
63
+ kind: "follower";
64
+ instanceId: string;
65
+ sessionId: string;
66
+ generation: string;
67
+ };
68
+ target: TelegramTarget & {
69
+ threadId: number;
70
+ };
71
+ slot: string;
72
+ ready: boolean;
73
+ }
65
74
  export interface TelegramBusProtocolIdentity {
66
75
  protocolVersion: number;
67
76
  runtimeBuild: string;
68
77
  capabilities: string[];
69
78
  }
70
- export interface TelegramBusProtocolCompatibility {
79
+ interface TelegramBusProtocolCompatibility {
71
80
  compatible: boolean;
72
81
  reason?: "missing-identity" | "version-mismatch" | "missing-capability";
73
82
  missingCapabilities: string[];
@@ -83,8 +92,8 @@ export declare function getTelegramBusProtocolCompatibility(input: {
83
92
  local: TelegramBusProtocolIdentity;
84
93
  remote?: TelegramBusProtocolIdentity;
85
94
  }): TelegramBusProtocolCompatibility;
86
- export declare function getTelegramBusSocketPath(agentDir?: string, platform?: NodeJS.Platform, profileName?: string): string;
87
- export declare function getTelegramBusFollowerSocketPath(instanceId: string, agentDir?: string, platform?: NodeJS.Platform, profileName?: string): string;
95
+ export declare function getTelegramBusSocketPath(agentDir?: string, platform?: NodeJS.Platform, profileName?: string, layout?: TelegramBusEndpointLayout): string;
96
+ export declare function getTelegramBusFollowerSocketPath(instanceId: string, agentDir?: string, platform?: NodeJS.Platform, profileName?: string, layout?: TelegramBusEndpointLayout): string;
88
97
  export interface TelegramBusInstanceRegistration {
89
98
  instanceId: string;
90
99
  previousInstanceId?: string;
@@ -125,9 +134,7 @@ export declare function getTelegramFollowerTargetOwnership(input: {
125
134
  protocolIdentity: TelegramBusProtocolIdentity;
126
135
  } | undefined;
127
136
  export declare function markTelegramBusAggregateDelivery<T extends Record<string, unknown>>(body: T): T;
128
- export declare function isTelegramBusAggregateDelivery(body: unknown): boolean;
129
137
  export declare function markTelegramBusCrossTargetDelivery<T extends Record<string, unknown>>(body: T): T;
130
- export declare function isTelegramBusCrossTargetDelivery(body: unknown): boolean;
131
138
  export declare function stripTelegramBusApiMetadata<T extends Record<string, unknown>>(body: T): T;
132
139
  export declare function isTelegramFollowerApiCallAllowed(input: {
133
140
  follower: TelegramBusFollowerView;
@@ -135,7 +142,7 @@ export declare function isTelegramFollowerApiCallAllowed(input: {
135
142
  args: unknown[];
136
143
  isMessageOwned?: (chatId: number, messageId: number) => boolean;
137
144
  }): boolean;
138
- export interface TelegramFollowerApiCallAuthorizationInput {
145
+ interface TelegramFollowerApiCallAuthorizationInput {
139
146
  follower: TelegramBusFollowerView;
140
147
  method: string;
141
148
  args: unknown[];
@@ -169,7 +176,7 @@ export interface TelegramBusFollowerDeliveryIdentity {
169
176
  handoffId: string;
170
177
  };
171
178
  }
172
- export type TelegramBusForeignUpdateFailureClass = "source-update-identity-missing" | "recipient-binding-missing" | "recipient-generation-missing" | "source-reference-missing" | "recipient-ownership-stale" | "transport-failed" | "acknowledgement-missing" | "acknowledgement-rejected" | "acknowledgement-mismatched" | "durable-receipt-missing" | "durable-receipt-mismatched";
179
+ type TelegramBusForeignUpdateFailureClass = "source-update-identity-missing" | "recipient-binding-missing" | "recipient-generation-missing" | "source-reference-missing" | "recipient-ownership-stale" | "transport-failed" | "acknowledgement-missing" | "acknowledgement-rejected" | "acknowledgement-mismatched" | "durable-receipt-missing" | "durable-receipt-mismatched";
173
180
  export type TelegramBusForeignUpdateSettlement = {
174
181
  status: "accepted";
175
182
  delivery: TelegramBusFollowerDeliveryIdentity;
@@ -313,17 +320,12 @@ export type TelegramBusEnvelope = ({
313
320
  delivery: TelegramBusFollowerDeliveryIdentity;
314
321
  sentAtMs: number;
315
322
  } | {
316
- kind: "leader.replaceFollowerTarget";
323
+ kind: "leader.workspaceRestore";
317
324
  requestId: string;
318
325
  recipientInstanceId: string;
319
- recipientRegistrationGeneration?: string;
320
- target: TelegramTarget & {
321
- threadId: number;
322
- };
323
- oldTarget?: TelegramTarget & {
324
- threadId: number;
325
- };
326
- reason: "thread-restore";
326
+ recipientRegistrationGeneration: string;
327
+ operationId: string;
328
+ mode: "apply" | "inspect";
327
329
  sentAtMs: number;
328
330
  } | {
329
331
  kind: "leader.offerQueueHandoff";
@@ -392,7 +394,7 @@ export type TelegramBusEnvelope = ({
392
394
  }) & {
393
395
  auth?: string;
394
396
  };
395
- export type TelegramBusEnvelopeTrafficClass = "bootstrap" | "generation-fenced" | "response";
397
+ type TelegramBusEnvelopeTrafficClass = "bootstrap" | "generation-fenced" | "response";
396
398
  export declare function getTelegramBusEnvelopeTrafficClass(envelope: TelegramBusEnvelope): TelegramBusEnvelopeTrafficClass;
397
399
  export declare function createTelegramBusRequestId(input: {
398
400
  instanceId: string;
@@ -401,14 +403,14 @@ export declare function createTelegramBusRequestId(input: {
401
403
  export declare function createTelegramBusRequestIdFactory(instanceId: string): () => string;
402
404
  export declare function encodeTelegramBusEnvelope(envelope: TelegramBusEnvelope): string;
403
405
  export declare function parseTelegramBusEnvelope(line: string): TelegramBusEnvelope | undefined;
404
- export interface TelegramBusLocalServer {
406
+ interface TelegramBusLocalServer {
405
407
  start: () => Promise<void>;
406
408
  stop: () => Promise<void>;
407
409
  ensureEndpoint: () => Promise<boolean>;
408
410
  }
409
411
  export type TelegramBusSocketPathSource = string | (() => string);
410
412
  export declare function resolveTelegramBusSocketPath(source: TelegramBusSocketPathSource, platform?: NodeJS.Platform | string): string;
411
- export interface TelegramBusLocalServerDeps {
413
+ interface TelegramBusLocalServerDeps {
412
414
  socketPath: TelegramBusSocketPathSource;
413
415
  handleEnvelope: (envelope: TelegramBusEnvelope) => Promise<TelegramBusEnvelope | undefined> | TelegramBusEnvelope | undefined;
414
416
  recordTransportEvent?: TelegramBusTransportEventRecorder;
@@ -417,14 +419,14 @@ export interface TelegramBusLocalServerDeps {
417
419
  requestLedgerMaxEntries?: number;
418
420
  shouldDropResponse?: (request: TelegramBusEnvelope, response: TelegramBusEnvelope) => boolean;
419
421
  }
420
- export interface TelegramBusLocalClientOptions {
422
+ interface TelegramBusLocalClientOptions {
421
423
  socketPath: string;
422
424
  envelope: TelegramBusEnvelope;
423
425
  timeoutMs?: number;
424
426
  retry?: TelegramBusTransportRetryPolicy;
425
427
  recordTransportEvent?: TelegramBusTransportEventRecorder;
426
428
  }
427
- export interface TelegramBusForeignOwnedForwarderDeps<TMessage = unknown> {
429
+ interface TelegramBusForeignOwnedForwarderDeps<TMessage = unknown> {
428
430
  socketPath: TelegramBusSocketPathSource;
429
431
  createRequestId: () => string;
430
432
  getNowMs?: () => number;
@@ -477,38 +479,31 @@ export declare function createTelegramBusForeignOwnedUpdateForwarder<TContext, T
477
479
  ctx: TContext;
478
480
  }) => Promise<TelegramBusForeignUpdateSettlement>;
479
481
  };
480
- export interface TelegramBusFollowerThreadRestoreHandlerDeps {
481
- followerRegistry: Pick<TelegramBusFollowerRegistry, "get" | "register">;
482
- followerTargetController: ReturnType<typeof createTelegramBusFollowerTargetController>;
483
- onRestored?: () => void;
484
- }
485
482
  export declare function listTelegramBusLiveThreadTargets(input: {
486
483
  leaderTarget?: TelegramTarget;
487
484
  followers: readonly TelegramBusFollowerView[];
488
485
  }): TelegramTarget[];
489
- export declare function createTelegramBusFollowerTargetController(deps: TelegramBusForeignOwnedForwarderDeps): {
490
- replaceTarget: (input: {
491
- follower: TelegramBusFollowerView;
492
- target: TelegramTarget & {
493
- threadId: number;
494
- };
495
- oldTarget?: TelegramTarget & {
496
- threadId: number;
497
- };
498
- reason: "thread-restore";
499
- }) => Promise<boolean>;
500
- };
501
- export declare function createTelegramBusFollowerThreadRestoreHandler(deps: TelegramBusFollowerThreadRestoreHandlerDeps): (input: {
502
- record: {
503
- instanceId?: string;
504
- };
486
+ /** Caller owns the durable one-shot apply grant. Inspections never grant another apply. */
487
+ export declare function createTelegramBusWorkspaceRestoreController(deps: {
488
+ getFollower: (instanceId: string) => TelegramBusFollowerView | undefined;
489
+ localProtocolIdentity: TelegramBusProtocolIdentity;
490
+ createRequestId: () => string;
491
+ getAuthSecret: () => string | undefined;
492
+ timeoutMs?: number;
493
+ }): (input: {
494
+ operationId: string;
495
+ instanceId: string;
496
+ sessionId: string;
497
+ slot: string;
505
498
  target: TelegramTarget & {
506
499
  threadId: number;
507
500
  };
508
- oldTarget?: TelegramTarget & {
501
+ oldTarget: TelegramTarget & {
509
502
  threadId: number;
510
503
  };
511
- }) => Promise<boolean>;
504
+ mode: "apply" | "inspect";
505
+ isCurrent: () => boolean;
506
+ }) => Promise<TelegramBusWorkspaceRestoreObservation | undefined>;
512
507
  export declare function isTelegramBusEnvelopeAuthorized(envelope: TelegramBusEnvelope, secret: string | undefined): boolean;
513
508
  export declare function createUnauthorizedBusAck(requestId: string): TelegramBusEnvelope;
514
509
  export declare function createTelegramBusLocalServer(deps: TelegramBusLocalServerDeps): TelegramBusLocalServer;
@@ -529,3 +524,4 @@ export interface TelegramBusFollowerRegistry {
529
524
  }
530
525
  export declare function createTelegramBusForwardOwnershipValidator(registry: Pick<TelegramBusFollowerRegistry, "get">): (ownership: TelegramBusForwardOwnership) => boolean;
531
526
  export declare function createTelegramBusFollowerRegistry(): TelegramBusFollowerRegistry;
527
+ export {};