@llblab/pi-kit 0.5.1 → 0.5.2
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/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -0
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +16 -0
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +2 -2
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +4 -0
- package/node_modules/@llblab/pi-telegram/docs/outbound.md +19 -3
- package/node_modules/@llblab/pi-telegram/index.ts +2 -0
- package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +43 -25
- package/node_modules/@llblab/pi-telegram/lib/activity.ts +60 -1
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +101 -90
- package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +7 -2
- package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +18 -7
- package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +11 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound.ts +10 -3
- package/node_modules/@llblab/pi-telegram/lib/preview.ts +19 -3
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +97 -66
- package/node_modules/@llblab/pi-telegram/lib/routing.ts +192 -58
- package/node_modules/@llblab/pi-telegram/lib/updates.ts +27 -35
- package/node_modules/@llblab/pi-telegram/package.json +1 -1
- package/package.json +2 -2
|
@@ -481,12 +481,7 @@ const TELEGRAM_UPDATE_ADMISSION_BINDING = Symbol(
|
|
|
481
481
|
|
|
482
482
|
interface TelegramUpdateAdmissionBinding {
|
|
483
483
|
sourceUpdateId: number;
|
|
484
|
-
report: (
|
|
485
|
-
outcome: Extract<
|
|
486
|
-
TelegramUpdateAdmissionOutcome,
|
|
487
|
-
{ kind: "deferred" | "queued" }
|
|
488
|
-
>,
|
|
489
|
-
) => void;
|
|
484
|
+
report: (outcome: TelegramUpdateAdmissionOutcome) => void;
|
|
490
485
|
}
|
|
491
486
|
|
|
492
487
|
export type TelegramQueueAdmissionReceiptLike = TelegramQueueAdmissionReceipt;
|
|
@@ -589,6 +584,16 @@ export function collectTelegramAdmissionSourceUpdateIds(
|
|
|
589
584
|
return [...sourceUpdateIds].sort((left, right) => left - right);
|
|
590
585
|
}
|
|
591
586
|
|
|
587
|
+
/** Report source completion; true means reported, not a durable settlement acknowledgement. */
|
|
588
|
+
export function reportTelegramUpdateCompleted(value: unknown): boolean {
|
|
589
|
+
const binding = getTelegramUpdateAdmissionBinding(value);
|
|
590
|
+
if (!binding) return false;
|
|
591
|
+
const execution = getTelegramUpdateExecutionFence(value);
|
|
592
|
+
if (execution && !execution.isCurrent()) return false;
|
|
593
|
+
binding.report({ kind: "complete" });
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
|
|
592
597
|
export function reportTelegramUpdateDeferred(value: unknown): boolean {
|
|
593
598
|
const binding = getTelegramUpdateAdmissionBinding(value);
|
|
594
599
|
if (!binding) return false;
|
|
@@ -1810,10 +1815,7 @@ export interface TelegramUpdateWorkerRuntime<TContext> {
|
|
|
1810
1815
|
signal: () => void;
|
|
1811
1816
|
settleDeferred: (input: {
|
|
1812
1817
|
updateId: number;
|
|
1813
|
-
outcome:
|
|
1814
|
-
TelegramUpdateAdmissionOutcome,
|
|
1815
|
-
{ kind: "deferred" | "queued" }
|
|
1816
|
-
>;
|
|
1818
|
+
outcome: TelegramUpdateAdmissionOutcome;
|
|
1817
1819
|
signal: AbortSignal;
|
|
1818
1820
|
}) => void;
|
|
1819
1821
|
isQueueReceiptCommitted: (
|
|
@@ -3018,6 +3020,13 @@ export function createTelegramUpdateWorkerRuntime<TContext>(
|
|
|
3018
3020
|
return;
|
|
3019
3021
|
}
|
|
3020
3022
|
const claim = claims.get(input.updateId);
|
|
3023
|
+
if (input.outcome.kind === "complete") {
|
|
3024
|
+
// Expiry may retire only a still-deferred source, never accepted queue work.
|
|
3025
|
+
if (claim !== "deferred") return;
|
|
3026
|
+
const result = commitCompletedBatch(expectedOwner, [input.updateId]);
|
|
3027
|
+
if (!result) transition("idle", input.updateId);
|
|
3028
|
+
return;
|
|
3029
|
+
}
|
|
3021
3030
|
if (input.outcome.kind === "deferred") {
|
|
3022
3031
|
if (claim === "queued") return;
|
|
3023
3032
|
if (claim !== "deferred") {
|
|
@@ -3453,10 +3462,7 @@ export interface TelegramUpdateAdmissionHandleDeps<
|
|
|
3453
3462
|
) => Promise<void>;
|
|
3454
3463
|
registry?: TelegramUpdateHandlerRegistry;
|
|
3455
3464
|
onLateOutcome?: (
|
|
3456
|
-
outcome:
|
|
3457
|
-
TelegramUpdateAdmissionOutcome,
|
|
3458
|
-
{ kind: "deferred" | "queued" }
|
|
3459
|
-
>,
|
|
3465
|
+
outcome: TelegramUpdateAdmissionOutcome,
|
|
3460
3466
|
details: {
|
|
3461
3467
|
updateId: number;
|
|
3462
3468
|
ctx: TContext;
|
|
@@ -3467,24 +3473,15 @@ export interface TelegramUpdateAdmissionHandleDeps<
|
|
|
3467
3473
|
}
|
|
3468
3474
|
|
|
3469
3475
|
function mergeTelegramReportedAdmissionOutcome(
|
|
3470
|
-
current:
|
|
3471
|
-
|
|
3472
|
-
TelegramUpdateAdmissionOutcome,
|
|
3473
|
-
{ kind: "deferred" | "queued" }
|
|
3474
|
-
>
|
|
3475
|
-
| undefined,
|
|
3476
|
-
next: Extract<
|
|
3477
|
-
TelegramUpdateAdmissionOutcome,
|
|
3478
|
-
{ kind: "deferred" | "queued" }
|
|
3479
|
-
>,
|
|
3476
|
+
current: TelegramUpdateAdmissionOutcome | undefined,
|
|
3477
|
+
next: TelegramUpdateAdmissionOutcome,
|
|
3480
3478
|
updateId: number,
|
|
3481
|
-
):
|
|
3482
|
-
TelegramUpdateAdmissionOutcome,
|
|
3483
|
-
{ kind: "deferred" | "queued" }
|
|
3484
|
-
> {
|
|
3479
|
+
): TelegramUpdateAdmissionOutcome {
|
|
3485
3480
|
if (!current || current.kind === "deferred") return next;
|
|
3486
3481
|
if (next.kind === "deferred") return current;
|
|
3487
|
-
if (
|
|
3482
|
+
if (current.kind === "complete" && next.kind === "complete") return current;
|
|
3483
|
+
if (current.kind === "queued" && next.kind === "queued" &&
|
|
3484
|
+
areTelegramQueueAdmissionReceiptsEqual(current, next)) return current;
|
|
3488
3485
|
throw new TelegramUpdateAdmissionOutcomeError(
|
|
3489
3486
|
`Telegram update ${updateId} reported conflicting queue outcomes.`,
|
|
3490
3487
|
);
|
|
@@ -3529,12 +3526,7 @@ export function createTelegramUpdateAdmissionHandle<
|
|
|
3529
3526
|
execution.assertCurrent();
|
|
3530
3527
|
if (verdict === "consume") return { kind: "complete" };
|
|
3531
3528
|
let immediate = true;
|
|
3532
|
-
let outcome:
|
|
3533
|
-
| Extract<
|
|
3534
|
-
TelegramUpdateAdmissionOutcome,
|
|
3535
|
-
{ kind: "deferred" | "queued" }
|
|
3536
|
-
>
|
|
3537
|
-
| undefined;
|
|
3529
|
+
let outcome: TelegramUpdateAdmissionOutcome | undefined;
|
|
3538
3530
|
const boundUpdate = bindTelegramUpdateExecutionFence(
|
|
3539
3531
|
bindTelegramUpdateAdmissionSource(update, (next) => {
|
|
3540
3532
|
if (immediate) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llblab/pi-kit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@llblab/pi-codex-usage": "0.9.4",
|
|
46
46
|
"@llblab/pi-grow-loop": "0.7.4",
|
|
47
47
|
"@llblab/pi-state-flow": "0.3.0",
|
|
48
|
-
"@llblab/pi-telegram": "0.43.
|
|
48
|
+
"@llblab/pi-telegram": "0.43.2",
|
|
49
49
|
"@llblab/skills": "1.14.0"
|
|
50
50
|
},
|
|
51
51
|
"bundledDependencies": [
|