@llblab/pi-telegram 0.56.0 → 0.56.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.
- package/AGENTS.md +2 -2
- package/BACKLOG.md +2 -0
- package/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/dist/lib/bus-follower.d.ts +1 -0
- package/dist/lib/bus-follower.js +6 -5
- package/dist/lib/bus-leader.d.ts +2 -0
- package/dist/lib/bus-leader.js +26 -20
- package/dist/lib/bus.d.ts +5 -0
- package/dist/lib/bus.js +15 -7
- package/dist/lib/commands.d.ts +1 -1
- package/dist/lib/commands.js +33 -28
- package/dist/lib/extension.js +4 -1
- package/dist/lib/locks.d.ts +6 -2
- package/dist/lib/locks.js +3 -3
- package/dist/lib/polling.d.ts +6 -2
- package/dist/lib/polling.js +2 -2
- package/dist/lib/routing.d.ts +4 -0
- package/dist/lib/routing.js +62 -1
- package/dist/lib/sync.js +11 -1
- package/dist/lib/threads.d.ts +11 -0
- package/dist/lib/threads.js +57 -6
- package/dist/lib/updates.d.ts +4 -1
- package/dist/lib/updates.js +24 -5
- package/dist/package.json +1 -1
- package/docs/architecture.md +10 -0
- package/docs/multi-instance-bus.md +4 -2
- package/lib/bus-follower.ts +8 -5
- package/lib/bus-leader.ts +28 -23
- package/lib/bus.ts +16 -7
- package/lib/commands.ts +52 -47
- package/lib/extension.ts +4 -1
- package/lib/locks.ts +5 -2
- package/lib/polling.ts +4 -1
- package/lib/routing.ts +51 -1
- package/lib/sync.ts +11 -0
- package/lib/threads.ts +57 -5
- package/lib/updates.ts +22 -5
- package/package.json +1 -1
package/lib/updates.ts
CHANGED
|
@@ -547,6 +547,7 @@ interface TelegramUpdateAdmissionBinding {
|
|
|
547
547
|
inspectSource?: () => TelegramDeferredSourceEvidence | undefined;
|
|
548
548
|
inspectSourceSnapshot?: () => TelegramDeferredSourceSnapshot | undefined;
|
|
549
549
|
inspectCompletion?: () => TelegramDeferredSourceEvidence | undefined;
|
|
550
|
+
subscribeCompletion?: (notify: () => void) => () => void;
|
|
550
551
|
isSourceUnsettled?: () => boolean;
|
|
551
552
|
prepareLiveInput?: (
|
|
552
553
|
sourceUpdateIds: readonly number[],
|
|
@@ -615,6 +616,7 @@ export function bindTelegramUpdateAdmissionSource<
|
|
|
615
616
|
| "inspectSource"
|
|
616
617
|
| "inspectSourceSnapshot"
|
|
617
618
|
| "inspectCompletion"
|
|
619
|
+
| "subscribeCompletion"
|
|
618
620
|
| "isSourceUnsettled"
|
|
619
621
|
| "acknowledgeTransferred"
|
|
620
622
|
| "prepareLiveInput"
|
|
@@ -743,6 +745,15 @@ export function inspectTelegramDeferredSourceCompletion(
|
|
|
743
745
|
return execution.isCurrent() && source ? { ...source } : undefined;
|
|
744
746
|
}
|
|
745
747
|
|
|
748
|
+
/** Warm ACK notification only; subscribers must independently recheck exact completion and recipient authority. */
|
|
749
|
+
export function subscribeTelegramDeferredSourceCompletion(value: unknown, notify: () => void): (() => void) | undefined {
|
|
750
|
+
const execution = getTelegramUpdateExecutionFence(value);
|
|
751
|
+
if (execution?.isCurrent() !== true) return undefined;
|
|
752
|
+
return getTelegramUpdateAdmissionBinding(value)?.subscribeCompletion?.(() => {
|
|
753
|
+
if (execution.isCurrent()) notify();
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
746
757
|
/** Reuse only live bound deferred originals; raw IDs or cold/adopted input cannot mint this carrier. */
|
|
747
758
|
export function prepareTelegramLiveDeferredInput(
|
|
748
759
|
values: readonly unknown[],
|
|
@@ -8721,6 +8732,7 @@ function createTelegramUpdateSourceAdmissionHandle<
|
|
|
8721
8732
|
let outcome: TelegramUpdateAdmissionOutcome | undefined;
|
|
8722
8733
|
let completionAttempted = false;
|
|
8723
8734
|
let completedSource: TelegramDeferredSourceCompletion | undefined;
|
|
8735
|
+
const completionObservers = new Set<() => void>();
|
|
8724
8736
|
const boundUpdate = bindTelegramUpdateExecutionFence(
|
|
8725
8737
|
bindTelegramUpdateAdmissionSource(
|
|
8726
8738
|
update,
|
|
@@ -8777,11 +8789,12 @@ function createTelegramUpdateSourceAdmissionHandle<
|
|
|
8777
8789
|
execution.isCurrent() &&
|
|
8778
8790
|
completion.isCurrent() &&
|
|
8779
8791
|
isDeepStrictEqual(completion.source, expectedSource)
|
|
8780
|
-
)
|
|
8781
|
-
completedSource = {
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
}
|
|
8792
|
+
) {
|
|
8793
|
+
completedSource = { ...completion, source: { ...expectedSource } };
|
|
8794
|
+
for (const notify of completionObservers) {
|
|
8795
|
+
try { notify(); } catch { /* Observation cannot invalidate an exact removal ACK. */ }
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8785
8798
|
})
|
|
8786
8799
|
.catch((error) => {
|
|
8787
8800
|
try {
|
|
@@ -8842,6 +8855,10 @@ function createTelegramUpdateSourceAdmissionHandle<
|
|
|
8842
8855
|
signal,
|
|
8843
8856
|
})
|
|
8844
8857
|
: undefined,
|
|
8858
|
+
subscribeCompletion: (notify) => {
|
|
8859
|
+
completionObservers.add(notify);
|
|
8860
|
+
return () => { completionObservers.delete(notify); };
|
|
8861
|
+
},
|
|
8845
8862
|
inspectCompletion: () =>
|
|
8846
8863
|
execution.isCurrent() && completedSource?.isCurrent()
|
|
8847
8864
|
? { ...completedSource.source }
|