@llblab/pi-telegram 0.54.4 → 0.55.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 (80) hide show
  1. package/AGENTS.md +4 -2
  2. package/BACKLOG.md +1 -1
  3. package/CHANGELOG.md +16 -0
  4. package/README.md +5 -3
  5. package/dist/lib/activity.d.ts +5 -1
  6. package/dist/lib/activity.js +31 -2
  7. package/dist/lib/bindings.d.ts +3 -1
  8. package/dist/lib/bindings.js +8 -2
  9. package/dist/lib/bus-api.d.ts +2 -2
  10. package/dist/lib/bus-api.js +7 -2
  11. package/dist/lib/bus-follower.d.ts +50 -3
  12. package/dist/lib/bus-follower.js +313 -146
  13. package/dist/lib/bus-leader.d.ts +3 -0
  14. package/dist/lib/bus-leader.js +99 -18
  15. package/dist/lib/bus.d.ts +7 -3
  16. package/dist/lib/bus.js +24 -16
  17. package/dist/lib/delivery.d.ts +4 -0
  18. package/dist/lib/delivery.js +48 -15
  19. package/dist/lib/extension.js +48 -6
  20. package/dist/lib/lifecycle.d.ts +68 -0
  21. package/dist/lib/lifecycle.js +178 -58
  22. package/dist/lib/machine.d.ts +23 -0
  23. package/dist/lib/machine.js +37 -0
  24. package/dist/lib/media.d.ts +114 -28
  25. package/dist/lib/media.js +292 -119
  26. package/dist/lib/model.d.ts +54 -15
  27. package/dist/lib/model.js +98 -53
  28. package/dist/lib/polling.js +2 -0
  29. package/dist/lib/preview.d.ts +128 -113
  30. package/dist/lib/preview.js +448 -366
  31. package/dist/lib/queue.d.ts +2 -2
  32. package/dist/lib/queue.js +3 -3
  33. package/dist/lib/routing.d.ts +7 -2
  34. package/dist/lib/routing.js +585 -229
  35. package/dist/lib/runtime.d.ts +77 -11
  36. package/dist/lib/runtime.js +174 -92
  37. package/dist/lib/sections.js +0 -1
  38. package/dist/lib/telegram-api.d.ts +11 -9
  39. package/dist/lib/telegram-api.js +53 -4
  40. package/dist/lib/text-groups.d.ts +0 -26
  41. package/dist/lib/text-groups.js +51 -98
  42. package/dist/lib/thread-display.js +14 -6
  43. package/dist/lib/threads.d.ts +18 -5
  44. package/dist/lib/threads.js +107 -30
  45. package/dist/lib/turns.d.ts +6 -0
  46. package/dist/lib/turns.js +12 -1
  47. package/dist/lib/updates.d.ts +13 -4
  48. package/dist/lib/updates.js +54 -19
  49. package/dist/package.json +1 -1
  50. package/docs/activity.md +1 -1
  51. package/docs/architecture.md +14 -11
  52. package/docs/delivery.md +7 -5
  53. package/docs/multi-instance-bus.md +20 -8
  54. package/docs/public-api.md +2 -2
  55. package/docs/ui-style.md +2 -2
  56. package/lib/activity.ts +29 -5
  57. package/lib/bindings.ts +9 -1
  58. package/lib/bus-api.ts +11 -3
  59. package/lib/bus-follower.ts +417 -203
  60. package/lib/bus-leader.ts +88 -14
  61. package/lib/bus.ts +30 -18
  62. package/lib/delivery.ts +47 -19
  63. package/lib/extension.ts +51 -9
  64. package/lib/lifecycle.ts +229 -55
  65. package/lib/machine.ts +60 -0
  66. package/lib/media.ts +438 -172
  67. package/lib/model.ts +169 -74
  68. package/lib/polling.ts +2 -0
  69. package/lib/preview.ts +715 -566
  70. package/lib/queue.ts +5 -5
  71. package/lib/routing.ts +614 -257
  72. package/lib/runtime.ts +260 -104
  73. package/lib/sections.ts +0 -2
  74. package/lib/telegram-api.ts +61 -8
  75. package/lib/text-groups.ts +75 -136
  76. package/lib/thread-display.ts +15 -4
  77. package/lib/threads.ts +120 -36
  78. package/lib/turns.ts +15 -1
  79. package/lib/updates.ts +60 -21
  80. package/package.json +1 -1
@@ -726,7 +726,7 @@ export interface TelegramDispatchRuntimeDeps<TContext = unknown> {
726
726
  executeControlItem: (item: Extract<TelegramQueueDispatchAction<TContext>, {
727
727
  kind: "control";
728
728
  }>["item"]) => void;
729
- onPromptDispatchStart: (chatId: number) => void;
729
+ onPromptDispatchStart: (chatId: number, target?: TelegramQueueTarget) => void;
730
730
  commitPromptDispatch?: (item: Extract<TelegramQueueDispatchAction<TContext>, {
731
731
  kind: "prompt";
732
732
  }>["item"]) => boolean;
@@ -745,7 +745,7 @@ export interface TelegramQueueDispatchControllerDeps<TContext = unknown> extends
745
745
  isDispatchGenerationActive?: (generation: number) => boolean;
746
746
  updateStatus: (ctx: TContext, error?: string) => void;
747
747
  sendTextReply: TelegramControlRuntimeDeps<TContext>["sendTextReply"];
748
- onPromptDispatchStart: (ctx: TContext, chatId: number) => void;
748
+ onPromptDispatchStart: (ctx: TContext, chatId: number, target?: TelegramQueueTarget) => void;
749
749
  commitPromptDispatch?: (item: Extract<TelegramQueueDispatchAction<TContext>, {
750
750
  kind: "prompt";
751
751
  }>["item"], ctx: TContext) => boolean;
package/dist/lib/queue.js CHANGED
@@ -1957,7 +1957,7 @@ export function executeTelegramQueueDispatchPlan(plan, deps) {
1957
1957
  deps.executeControlItem(plan.item);
1958
1958
  return;
1959
1959
  }
1960
- deps.onPromptDispatchStart(plan.item.chatId);
1960
+ deps.onPromptDispatchStart(plan.item.chatId, plan.item.target);
1961
1961
  try {
1962
1962
  if (deps.commitPromptDispatch && !deps.commitPromptDispatch(plan.item)) {
1963
1963
  throw new Error("Telegram prompt dispatch could not be committed durably.");
@@ -2188,8 +2188,8 @@ export function createTelegramQueueDispatchController(deps) {
2188
2188
  },
2189
2189
  });
2190
2190
  },
2191
- onPromptDispatchStart: (chatId) => {
2192
- deps.onPromptDispatchStart(ctx, chatId);
2191
+ onPromptDispatchStart: (chatId, target) => {
2192
+ deps.onPromptDispatchStart(ctx, chatId, target);
2193
2193
  },
2194
2194
  commitPromptDispatch: deps.commitPromptDispatch
2195
2195
  ? (item) => deps.commitPromptDispatch(item, ctx)
@@ -72,7 +72,7 @@ type TelegramLiveRebindSelectedCommandReference = {
72
72
  preparedSource: Bus.TelegramBusPreparedCommandSource;
73
73
  selectedCommand: Bus.TelegramBusSelectedCommandInput;
74
74
  };
75
- /** One warm live attempt with exact post-release peer donor settlement; no startup recovery, Restore ACK or cleanup. */
75
+ /** One warm live attempt with independent leader input/cleanup grants and exact peer donor settlement; no startup recovery or legacy Restore ACK. */
76
76
  export declare function createTelegramLiveRebindCoordinator(input: {
77
77
  request: Threads.TelegramWorkspaceRestoreRequest;
78
78
  /** Captures caller source/reference, admission, profile, transport and Pi lifetime. */
@@ -103,6 +103,8 @@ export declare function createTelegramLiveRebindCoordinator(input: {
103
103
  /** Explicit staged singleton command branch; absence preserves ordinary live input behavior. */
104
104
  selectedCommand?: Bus.TelegramBusSelectedCommandInput;
105
105
  };
106
+ /** Existing profile admission spans the applied recipient, fresh cleanup decision and one native input grant. */
107
+ cleanupBeforeRelease?(intent: Threads.TelegramWorkspaceLiveRebindIntent, isCurrent: () => boolean): Promise<boolean>;
106
108
  /** Restore moves the tab to its new owner: once applied, show that owner's title (best-effort, never blocking). */
107
109
  retitle?: (isCurrent: () => boolean) => Promise<void>;
108
110
  recordRuntimeEvent?: (category: string, error: unknown, details: Record<string, unknown>) => void;
@@ -204,9 +206,10 @@ export interface TelegramInboundRouteRuntimeDeps<TMessage extends TelegramRouted
204
206
  hasWorkspaceRestoreAuthority?: () => boolean;
205
207
  /** Exact live root authority; capability advertisement alone cannot replace owned profile/session/recipient fences. */
206
208
  hasWorkspaceLiveRebindAuthority?: () => boolean;
209
+ canUsePreDispatchRebind?: (recipient?: Threads.TelegramWorkspaceRestoreRecipient) => boolean;
207
210
  /** Strict complete namespace plus exact current/historical references; only an empty result clears journal protection. */
208
211
  inspectTemporaryThreadSources?: (target: Queue.TelegramQueueTarget, requiredJournalBindingKeys: readonly string[], ownInputs?: readonly Threads.TelegramTemporaryThreadInput[]) => readonly number[] | undefined;
209
- /** Quiet period after the last cancelled input before one cleanup attempt; defaults to 1000 ms. */
212
+ /** Quiet period after the last cancelled input before one cleanup attempt; defaults to 0 ms. */
210
213
  temporaryThreadCleanupDelayMs?: number;
211
214
  /** Live-rebind cleanup attempt pacing; the bounded window ends in `not-issued`, never a time-based deletion. */
212
215
  liveRebindCleanupSchedule?: {
@@ -353,6 +356,8 @@ export declare function createTelegramInboundRouteRuntime<TUpdate extends Update
353
356
  canPrepareHeldCommand: ReturnType<typeof Commands.createTelegramCommandHandlerTargetRuntime<TMessage, TContext>>["canPrepareHeldCommand"];
354
357
  /** Agent-settled hint: wakes waiting leader cleanup retries early; every readiness gate is still sampled fresh. */
355
358
  onSessionSettled(ctx: TContext): void;
359
+ /** Lifetime-fenced hint from drained publication/activity/delivery/API owners; never a cleanup grant. */
360
+ onDeliverySettled(ctx: TContext): void;
356
361
  /** Fresh body-free recipient observation only; never reconstructs an attempt or grants cleanup. */
357
362
  observeLiveRebindLeaderWork(intent: Threads.TelegramWorkspaceLiveRebindIntent, ctx: TContext): Promise<Bus.TelegramBusLiveRebindWorkObservation | undefined>;
358
363
  /** Fresh non-destructive candidate only; no retained idle, cleanup action or deletion grant. */