@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.
- package/BACKLOG.md +3 -1
- package/CHANGELOG.md +9 -0
- package/README.md +4 -4
- package/node_modules/@llblab/pi-state-flow/AGENTS.md +1 -1
- package/node_modules/@llblab/pi-state-flow/BACKLOG.md +6 -2
- package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +4 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.js +4 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/extension.js +26 -13
- package/node_modules/@llblab/pi-state-flow/dist/package.json +1 -1
- package/node_modules/@llblab/pi-state-flow/docs/architecture.md +3 -1
- package/node_modules/@llblab/pi-state-flow/docs/compatibility.md +2 -2
- package/node_modules/@llblab/pi-state-flow/docs/usage.md +2 -1
- package/node_modules/@llblab/pi-state-flow/lib/compaction.ts +4 -3
- package/node_modules/@llblab/pi-state-flow/lib/extension.ts +25 -12
- package/node_modules/@llblab/pi-state-flow/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/AGENTS.md +10 -8
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -9
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +13 -0
- package/node_modules/@llblab/pi-telegram/LICENSE +21 -0
- package/node_modules/@llblab/pi-telegram/README.md +15 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.d.ts +1 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.js +5 -7
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +5 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +6 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.js +4 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +54 -56
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +206 -139
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.d.ts +21 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.js +181 -25
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.d.ts +4 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.js +28 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/bus.d.ts +52 -56
- package/node_modules/@llblab/pi-telegram/dist/lib/bus.js +78 -246
- package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.d.ts +1 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.js +23 -26
- package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.d.ts +0 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.js +5 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +0 -23
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +15 -15
- package/node_modules/@llblab/pi-telegram/dist/lib/config.d.ts +0 -17
- package/node_modules/@llblab/pi-telegram/dist/lib/config.js +12 -14
- package/node_modules/@llblab/pi-telegram/dist/lib/delivery.d.ts +0 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/delivery.js +2 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +255 -61
- package/node_modules/@llblab/pi-telegram/dist/lib/generative-apps.d.ts +0 -19
- package/node_modules/@llblab/pi-telegram/dist/lib/inbound.d.ts +0 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/inbound.js +2 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/journal.d.ts +177 -16
- package/node_modules/@llblab/pi-telegram/dist/lib/journal.js +1115 -249
- package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.d.ts +0 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.js +2 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/locks.d.ts +100 -12
- package/node_modules/@llblab/pi-telegram/dist/lib/locks.js +380 -14
- package/node_modules/@llblab/pi-telegram/dist/lib/logging.d.ts +30 -12
- package/node_modules/@llblab/pi-telegram/dist/lib/logging.js +129 -72
- package/node_modules/@llblab/pi-telegram/dist/lib/media.d.ts +28 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/media.js +26 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.d.ts +0 -11
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.js +8 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.d.ts +0 -18
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.js +18 -18
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.d.ts +4 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.js +12 -7
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.d.ts +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/menu.d.ts +1 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu.js +4 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.d.ts +0 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-buttons.js +1 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.d.ts +1 -6
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.js +4 -21
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound.d.ts +0 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound.js +5 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/paths.d.ts +50 -7
- package/node_modules/@llblab/pi-telegram/dist/lib/paths.js +155 -17
- package/node_modules/@llblab/pi-telegram/dist/lib/pi.d.ts +1 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/pi.js +2 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/polling.d.ts +0 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/polling.js +5 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/preview.d.ts +0 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/preview.js +3 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.d.ts +0 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.d.ts +3 -15
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.js +69 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/recovery.d.ts +29 -9
- package/node_modules/@llblab/pi-telegram/dist/lib/recovery.js +104 -33
- package/node_modules/@llblab/pi-telegram/dist/lib/replies.d.ts +0 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/replies.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/routing.d.ts +73 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/routing.js +2206 -307
- package/node_modules/@llblab/pi-telegram/dist/lib/sections.d.ts +0 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/sections.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/status.d.ts +44 -9
- package/node_modules/@llblab/pi-telegram/dist/lib/status.js +149 -27
- package/node_modules/@llblab/pi-telegram/dist/lib/sync.d.ts +0 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +5 -4
- package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.d.ts +11 -3
- package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.js +34 -23
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.d.ts +1 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.js +18 -21
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.d.ts +32 -5
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.js +191 -7
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.d.ts +2 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +291 -59
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +1647 -369
- package/node_modules/@llblab/pi-telegram/dist/lib/turns.d.ts +0 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/turns.js +1 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/updates.d.ts +184 -28
- package/node_modules/@llblab/pi-telegram/dist/lib/updates.js +1032 -114
- package/node_modules/@llblab/pi-telegram/dist/lib/wire.d.ts +12 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/wire.js +21 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.d.ts +25 -17
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.js +95 -20
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-identity.d.ts +20 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-identity.js +103 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +43 -8
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +148 -52
- package/node_modules/@llblab/pi-telegram/dist/package.json +6 -6
- package/node_modules/@llblab/pi-telegram/dist/skills/generated-control-surface/SKILL.md +3 -3
- package/node_modules/@llblab/pi-telegram/dist/skills/telegram-bridge/references/diagnosis.md +3 -3
- package/node_modules/@llblab/pi-telegram/docs/README.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/activity.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +152 -34
- package/node_modules/@llblab/pi-telegram/docs/callback-namespaces.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/delivery.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +2 -2
- package/node_modules/@llblab/pi-telegram/docs/inbound.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +125 -19
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +3 -1
- package/node_modules/@llblab/pi-telegram/docs/ui-style.md +22 -8
- package/node_modules/@llblab/pi-telegram/docs/updates.md +1 -1
- package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +5 -9
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +6 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +5 -2
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +243 -224
- package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +178 -31
- package/node_modules/@llblab/pi-telegram/lib/bus-transport.ts +30 -8
- package/node_modules/@llblab/pi-telegram/lib/bus.ts +110 -334
- package/node_modules/@llblab/pi-telegram/lib/channel-posts.ts +29 -29
- package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +5 -5
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +15 -15
- package/node_modules/@llblab/pi-telegram/lib/config.ts +12 -17
- package/node_modules/@llblab/pi-telegram/lib/delivery.ts +2 -8
- package/node_modules/@llblab/pi-telegram/lib/extension.ts +257 -72
- package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +0 -22
- package/node_modules/@llblab/pi-telegram/lib/inbound.ts +2 -2
- package/node_modules/@llblab/pi-telegram/lib/journal.ts +1182 -326
- package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +2 -2
- package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/locks.ts +402 -23
- package/node_modules/@llblab/pi-telegram/lib/logging.ts +151 -101
- package/node_modules/@llblab/pi-telegram/lib/media.ts +51 -9
- package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +8 -8
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +18 -18
- package/node_modules/@llblab/pi-telegram/lib/menu-status.ts +11 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-thinking.ts +2 -2
- package/node_modules/@llblab/pi-telegram/lib/menu.ts +5 -1
- package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +1 -10
- package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +5 -24
- package/node_modules/@llblab/pi-telegram/lib/outbound.ts +5 -5
- package/node_modules/@llblab/pi-telegram/lib/paths.ts +177 -17
- package/node_modules/@llblab/pi-telegram/lib/pi.ts +5 -2
- package/node_modules/@llblab/pi-telegram/lib/polling.ts +5 -5
- package/node_modules/@llblab/pi-telegram/lib/preview.ts +3 -3
- package/node_modules/@llblab/pi-telegram/lib/prompt-templates.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +67 -9
- package/node_modules/@llblab/pi-telegram/lib/recovery.ts +104 -44
- package/node_modules/@llblab/pi-telegram/lib/replies.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/routing.ts +1955 -375
- package/node_modules/@llblab/pi-telegram/lib/sections.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/status.ts +156 -36
- package/node_modules/@llblab/pi-telegram/lib/sync.ts +4 -4
- package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +48 -33
- package/node_modules/@llblab/pi-telegram/lib/thread-cleanup-manager.ts +24 -21
- package/node_modules/@llblab/pi-telegram/lib/thread-naming.ts +267 -9
- package/node_modules/@llblab/pi-telegram/lib/thread-reconciler.ts +3 -1
- package/node_modules/@llblab/pi-telegram/lib/threads.ts +1697 -488
- package/node_modules/@llblab/pi-telegram/lib/turns.ts +1 -1
- package/node_modules/@llblab/pi-telegram/lib/updates.ts +1072 -151
- package/node_modules/@llblab/pi-telegram/lib/wire.ts +28 -0
- package/node_modules/@llblab/pi-telegram/lib/workspace-admission.ts +97 -47
- package/node_modules/@llblab/pi-telegram/lib/workspace-identity.ts +147 -0
- package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +188 -89
- package/node_modules/@llblab/pi-telegram/package.json +6 -6
- package/node_modules/@llblab/pi-telegram/scripts/audit-exports.mjs +100 -0
- package/node_modules/@llblab/pi-telegram/scripts/check-downgrade.mjs +80 -43
- package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +3 -3
- package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/references/diagnosis.md +3 -3
- package/package.json +3 -3
|
@@ -17,7 +17,5 @@ export type TelegramInlineKeyboardButton = {
|
|
|
17
17
|
export interface TelegramInlineKeyboardMarkup {
|
|
18
18
|
inline_keyboard: TelegramInlineKeyboardButton[][];
|
|
19
19
|
}
|
|
20
|
-
export declare const TELEGRAM_CALLBACK_DATA_MAX_BYTES = 64;
|
|
21
|
-
export declare function getTelegramCallbackDataByteLength(value: string): number;
|
|
22
20
|
export declare function assertTelegramCallbackData(callbackData: string, context?: string): string;
|
|
23
21
|
export declare function assertTelegramInlineKeyboardCallbackData(replyMarkup: unknown, context?: string): void;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Zones: telegram ui, shared structure
|
|
4
4
|
* Owns the shared Bot API reply-markup shape while feature domains own their button semantics
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const TELEGRAM_CALLBACK_DATA_MAX_BYTES = 64;
|
|
7
|
+
function getTelegramCallbackDataByteLength(value) {
|
|
8
8
|
return new TextEncoder().encode(value).byteLength;
|
|
9
9
|
}
|
|
10
10
|
export function assertTelegramCallbackData(callbackData, context = "Telegram callback_data") {
|
|
@@ -343,7 +343,7 @@ export function createTelegramCompactionObserverRuntime(deps) {
|
|
|
343
343
|
typingStartedByObserver = false;
|
|
344
344
|
deps.updateStatus(ctx);
|
|
345
345
|
deps.recordRuntimeEvent?.("compact", new Error("Compaction observer timed out"));
|
|
346
|
-
|
|
346
|
+
// Observer expiry releases local presence, not Pi's eventual terminal result.
|
|
347
347
|
requestDispatch();
|
|
348
348
|
}, timeoutMs);
|
|
349
349
|
unrefTelegramLifecycleTimer(fallbackTimer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Telegram singleton lock helpers
|
|
3
3
|
* Zones: telegram ownership, filesystem, transport authority
|
|
4
|
-
* Owns
|
|
4
|
+
* Owns filesystem authority, atomic runtime-section publication and Telegram bridge ownership semantics
|
|
5
5
|
*/
|
|
6
6
|
import { renameSync } from "node:fs";
|
|
7
7
|
export declare const TELEGRAM_LOCK_KEY = "default";
|
|
@@ -14,10 +14,21 @@ export declare const TELEGRAM_OWNERSHIP_REFRESH_MS = 2000;
|
|
|
14
14
|
* Named profile → the validated profile name
|
|
15
15
|
*/
|
|
16
16
|
export declare function resolveTelegramLockKey(activeProfile?: string): string;
|
|
17
|
-
|
|
17
|
+
interface TelegramActiveProfileGetter {
|
|
18
18
|
getActiveProfileName: () => string | undefined;
|
|
19
19
|
}
|
|
20
20
|
export declare function createTelegramLockKeyResolver(activeProfile: TelegramActiveProfileGetter): () => string;
|
|
21
|
+
/** Structural session view; Locks never imports the lifecycle owner. */
|
|
22
|
+
interface TelegramOwnedStateSessionPort<TContext extends TelegramLockContext> {
|
|
23
|
+
get: () => TContext | undefined;
|
|
24
|
+
getGeneration: () => number;
|
|
25
|
+
isCurrent: (ctx: TContext, generation?: number) => boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Captures exact context, session generation and owned leader epoch before awaits.
|
|
29
|
+
* Session replacement, release or re-election revokes the grant; a successor never renews it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createTelegramOwnedStateAuthorityCapture<TContext extends TelegramLockContext>(lock: Pick<TelegramLockRuntime<TContext>, "owns" | "getOwnedLeaderEpoch">, session: TelegramOwnedStateSessionPort<TContext>): () => (() => boolean) | undefined;
|
|
21
32
|
export interface TelegramLockEntry {
|
|
22
33
|
pid: number;
|
|
23
34
|
cwd?: string;
|
|
@@ -27,6 +38,8 @@ export interface TelegramLockEntry {
|
|
|
27
38
|
runtimeGeneration?: number;
|
|
28
39
|
busSocketPath?: string;
|
|
29
40
|
busSecret?: string;
|
|
41
|
+
/** Polling journal custody; inherited by every successor and kept after release. */
|
|
42
|
+
journalPath?: string;
|
|
30
43
|
}
|
|
31
44
|
export interface TelegramLockContext {
|
|
32
45
|
cwd: string;
|
|
@@ -43,12 +56,12 @@ export type TelegramLockState = {
|
|
|
43
56
|
kind: "stale";
|
|
44
57
|
lock: TelegramLockEntry;
|
|
45
58
|
};
|
|
46
|
-
|
|
59
|
+
interface TelegramLockAcquireOptions {
|
|
47
60
|
force?: boolean;
|
|
48
61
|
expectedOwner?: TelegramLockEntry;
|
|
49
62
|
election?: boolean;
|
|
50
63
|
}
|
|
51
|
-
|
|
64
|
+
type TelegramLockAcquireResult = {
|
|
52
65
|
ok: true;
|
|
53
66
|
lock: TelegramLockEntry;
|
|
54
67
|
replacedStale: boolean;
|
|
@@ -56,6 +69,12 @@ export type TelegramLockAcquireResult = {
|
|
|
56
69
|
ok: false;
|
|
57
70
|
lock: TelegramLockEntry;
|
|
58
71
|
};
|
|
72
|
+
export type TelegramOwnedStatePublicationResult<T> = {
|
|
73
|
+
committed: false;
|
|
74
|
+
} | {
|
|
75
|
+
committed: true;
|
|
76
|
+
result: T;
|
|
77
|
+
};
|
|
59
78
|
export interface TelegramLockRuntime<TContext extends TelegramLockContext> {
|
|
60
79
|
acquire: (ctx: TContext, options?: TelegramLockAcquireOptions) => TelegramLockAcquireResult;
|
|
61
80
|
release: () => TelegramLockState;
|
|
@@ -64,17 +83,26 @@ export interface TelegramLockRuntime<TContext extends TelegramLockContext> {
|
|
|
64
83
|
getOwnedLeaderEpoch: () => number | string | undefined;
|
|
65
84
|
owns: (ctx?: TelegramLockContext) => boolean;
|
|
66
85
|
commitIfOwned: (commit: () => void) => boolean;
|
|
86
|
+
/** Consolidated-store publication; domain reducers retain their own exact payload/CAS rules. */
|
|
87
|
+
publishStateSectionIfOwned?: <T>(section: "workspace" | "runtime", mutate: (current: unknown, observed: Readonly<TelegramRuntimeStateProfile>) => TelegramRuntimeStateMutation<T>, options: TelegramOwnedStatePublicationOptions) => TelegramOwnedStatePublicationResult<T>;
|
|
67
88
|
refresh: (ctx?: TelegramLockContext) => boolean;
|
|
89
|
+
/** The polling journal named by owners.json for this key, owned or not. */
|
|
90
|
+
getJournalPath: () => string | undefined;
|
|
68
91
|
}
|
|
69
|
-
|
|
92
|
+
interface TelegramLockOwnershipGuard<TContext extends TelegramLockContext> {
|
|
70
93
|
ownsContext: (ctx: TContext) => boolean;
|
|
71
94
|
}
|
|
72
|
-
|
|
95
|
+
interface TelegramLockContextStore<TContext extends TelegramLockContext> {
|
|
73
96
|
get: () => TContext | undefined;
|
|
74
97
|
}
|
|
75
|
-
|
|
98
|
+
interface TelegramLockRuntimeOptions {
|
|
76
99
|
key?: string | (() => string | undefined);
|
|
77
100
|
locksPath?: string;
|
|
101
|
+
/** Consolidated version-2 state envelope; exclusive with `locksPath`. */
|
|
102
|
+
statePath?: string;
|
|
103
|
+
statePublication?: Pick<TelegramRuntimeStatePublicationOptions, "onPublicationBoundary" | "publishRename">;
|
|
104
|
+
/** Read-only ownership file of releases that used another directory; a live fresh owner there blocks acquisition. */
|
|
105
|
+
legacyLocksPath?: string;
|
|
78
106
|
pid?: number;
|
|
79
107
|
isProcessAlive?: (pid: number) => boolean;
|
|
80
108
|
instanceId?: string;
|
|
@@ -84,9 +112,25 @@ export interface TelegramLockRuntimeOptions {
|
|
|
84
112
|
mintLeaderEpoch?: () => number | string;
|
|
85
113
|
runtimeGeneration?: number;
|
|
86
114
|
staleHeartbeatMs?: number;
|
|
115
|
+
/** First leader without an inherited pointer names the polling journal it creates. */
|
|
116
|
+
createJournalPath?: (ctx: TelegramLockContext) => string | undefined;
|
|
87
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Leader polling journal: the path owners.json names, else the session that would host it on acquisition.
|
|
120
|
+
* Without a session identity, the flat root `inbox` remains the compatibility fallback.
|
|
121
|
+
*/
|
|
122
|
+
export declare function createTelegramLeaderJournalPathResolver(deps: {
|
|
123
|
+
getNamedJournalPath: () => string | undefined;
|
|
124
|
+
getSessionId: () => string | undefined;
|
|
125
|
+
getProfileName: () => string | undefined;
|
|
126
|
+
}): {
|
|
127
|
+
createJournalPath: () => string | undefined;
|
|
128
|
+
resolve(profileName?: string): string;
|
|
129
|
+
};
|
|
130
|
+
/** A released key keeps only `{ journalPath }`: no owner, but the successor's polling custody. */
|
|
131
|
+
export declare function readTelegramLockJournalPath(value: unknown): string | undefined;
|
|
88
132
|
export declare function readLocks(path?: string): Record<string, unknown>;
|
|
89
|
-
|
|
133
|
+
interface TelegramRenameRetryOptions {
|
|
90
134
|
rename?: typeof renameSync;
|
|
91
135
|
attempts?: number;
|
|
92
136
|
retryDelayMs?: number;
|
|
@@ -100,17 +144,56 @@ export interface TelegramFileTransactionOptions {
|
|
|
100
144
|
retryDelayMs?: number;
|
|
101
145
|
}
|
|
102
146
|
export declare function withTelegramFileTransaction<T>(transactionPath: string, operation: () => T, options?: TelegramFileTransactionOptions): T;
|
|
147
|
+
export type TelegramRuntimeStateSection = "transport" | "workspace" | "admission" | "runtime";
|
|
148
|
+
type TelegramRuntimeStateProfile = Partial<Record<TelegramRuntimeStateSection, unknown>>;
|
|
149
|
+
interface TelegramRuntimeStateFile {
|
|
150
|
+
version: 2;
|
|
151
|
+
profiles: Record<string, TelegramRuntimeStateProfile>;
|
|
152
|
+
}
|
|
153
|
+
export declare class TelegramRuntimeStateError extends Error {
|
|
154
|
+
readonly code: "invalid" | "authority-changed" | "publication-unknown";
|
|
155
|
+
constructor(code: TelegramRuntimeStateError["code"], message: string, options?: ErrorOptions);
|
|
156
|
+
}
|
|
157
|
+
/** Strict, observational envelope read; section owners validate their own payloads. Legacy state is never adopted here. */
|
|
158
|
+
export declare function readTelegramRuntimeState(path: string): TelegramRuntimeStateFile;
|
|
159
|
+
/**
|
|
160
|
+
* Operator-approved optimistic recovery before leader acquisition: when the shared envelope, any transport section or a
|
|
161
|
+
* caller-validated section is damaged, publish a fresh empty envelope instead of refusing. All profiles lose runtime
|
|
162
|
+
* continuity. Filesystem access errors are not damage and still throw. Returns whether a reset was published.
|
|
163
|
+
*/
|
|
164
|
+
export declare function resetDamagedTelegramRuntimeState(path: string, validateProfile?: (profile: string, sections: Readonly<TelegramRuntimeStateProfile>) => void): boolean;
|
|
165
|
+
export interface TelegramRuntimeStateMutation<T> {
|
|
166
|
+
value: unknown;
|
|
167
|
+
result: T;
|
|
168
|
+
}
|
|
169
|
+
interface TelegramRuntimeStatePublicationOptions {
|
|
170
|
+
/** Exact domain authority, recaptured by the caller before invoking this synchronous transaction. */
|
|
171
|
+
isCurrent: () => boolean;
|
|
172
|
+
onPublicationBoundary?: (boundary: "before-write" | "after-write-before-rename" | "after-rename") => void;
|
|
173
|
+
publishRename?: typeof renameSync;
|
|
174
|
+
}
|
|
175
|
+
export interface TelegramOwnedStatePublicationOptions extends TelegramRuntimeStatePublicationOptions {
|
|
176
|
+
/** Optional caller-bound physical/logical identity; a mismatch cannot redirect an owner grant. */
|
|
177
|
+
expectedScope?: {
|
|
178
|
+
path: string;
|
|
179
|
+
profile: string;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* One physical read/check/write transaction for one named section. The caller supplies domain policy; copies expose
|
|
184
|
+
* current sibling facts without granting writes to them. No await, nested transaction, repair or legacy import.
|
|
185
|
+
*/
|
|
186
|
+
export declare function mutateTelegramRuntimeStateSection<T>(path: string, profile: string, section: TelegramRuntimeStateSection, mutate: (current: unknown, observed: Readonly<TelegramRuntimeStateProfile>) => TelegramRuntimeStateMutation<T>, options: TelegramRuntimeStatePublicationOptions): T;
|
|
103
187
|
export declare function writeLocks(path: string, locks: Record<string, unknown>): void;
|
|
104
188
|
export declare function parseTelegramLockEntry(value: unknown): TelegramLockEntry | undefined;
|
|
105
189
|
export declare function isProcessAlive(pid: number): boolean;
|
|
106
|
-
export declare function formatTelegramLockEntry(lock: TelegramLockEntry): string;
|
|
107
190
|
export declare function createTelegramLockRuntime<TContext extends TelegramLockContext>(options?: TelegramLockRuntimeOptions): TelegramLockRuntime<TContext>;
|
|
108
191
|
export declare function createTelegramLockOwnershipGuard<TContext extends TelegramLockContext>(lock: TelegramLockRuntime<TContext>): TelegramLockOwnershipGuard<TContext>;
|
|
109
192
|
export declare function createTelegramDirectDeliveryOwnershipChecker<TContext extends TelegramLockContext>(deps: {
|
|
110
193
|
lock: TelegramLockRuntime<TContext>;
|
|
111
194
|
contextStore: TelegramLockContextStore<TContext>;
|
|
112
195
|
}): () => boolean;
|
|
113
|
-
|
|
196
|
+
interface TelegramLockedPollingStartOptions {
|
|
114
197
|
force?: boolean;
|
|
115
198
|
forceFreshLeaderThread?: boolean;
|
|
116
199
|
requestedThreadName?: string;
|
|
@@ -119,7 +202,7 @@ export interface TelegramLockedPollingStartOptions {
|
|
|
119
202
|
};
|
|
120
203
|
onAcquired?: () => Promise<void> | void;
|
|
121
204
|
}
|
|
122
|
-
|
|
205
|
+
type TelegramLockedPollingStartResult = {
|
|
123
206
|
ok: true;
|
|
124
207
|
message?: string;
|
|
125
208
|
canTakeover?: false;
|
|
@@ -134,14 +217,18 @@ export interface TelegramLockedPollingRuntime<TContext extends TelegramLockConte
|
|
|
134
217
|
stop: () => Promise<string>;
|
|
135
218
|
suspend: () => Promise<void>;
|
|
136
219
|
isSuspended: () => boolean;
|
|
220
|
+
/** Fence one owned polling generation; suspension, restart, conflict or lock loss revokes it. */
|
|
221
|
+
captureTransportAuthority: (ctx: TContext) => (() => boolean) | undefined;
|
|
137
222
|
onPersistentConflict: (ctx: TContext, count: number) => Promise<void>;
|
|
138
223
|
onSessionStart: (_event: unknown, ctx: TContext) => Promise<void>;
|
|
139
224
|
registerFollowerWithOwner?: (ctx: TContext, owner: TelegramLockEntry) => boolean | undefined | Promise<boolean | undefined>;
|
|
140
225
|
restoreFollowerWithOwner?: (ctx: TContext, owner: TelegramLockEntry) => boolean | undefined | Promise<boolean | undefined>;
|
|
141
226
|
stopFollowerRegistration?: () => void;
|
|
142
227
|
}
|
|
143
|
-
|
|
228
|
+
interface TelegramLockedPollingRuntimeDeps<TContext extends TelegramLockContext> {
|
|
144
229
|
lock: TelegramLockRuntime<TContext>;
|
|
230
|
+
/** Optimistically replaces a damaged shared runtime state before a non-election acquisition. */
|
|
231
|
+
resetDamagedState?: () => boolean;
|
|
145
232
|
hasBotToken: () => boolean;
|
|
146
233
|
getBotTokenDiagnostic?: () => string | undefined;
|
|
147
234
|
canStartPolling?: (ctx: TContext) => boolean;
|
|
@@ -163,3 +250,4 @@ export interface TelegramLockedPollingRuntimeDeps<TContext extends TelegramLockC
|
|
|
163
250
|
ownershipRefreshMs?: number;
|
|
164
251
|
}
|
|
165
252
|
export declare function createTelegramLockedPollingRuntime<TContext extends TelegramLockContext>(deps: TelegramLockedPollingRuntimeDeps<TContext>): TelegramLockedPollingRuntime<TContext>;
|
|
253
|
+
export {};
|