@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
|
@@ -43,10 +43,7 @@ interface RegisteredTelegramExtensionCommand {
|
|
|
43
43
|
emoji?: string;
|
|
44
44
|
handler: TelegramExtensionCommandRegistration["handler"];
|
|
45
45
|
}
|
|
46
|
-
export declare function normalizeTelegramExtensionCommandName(name: string): string;
|
|
47
|
-
export declare function isTelegramExtensionCommandName(name: string): boolean;
|
|
48
46
|
export declare function registerTelegramCommand(registration: TelegramExtensionCommandRegistration): () => void;
|
|
49
|
-
export declare function getTelegramExtensionCommands(): RegisteredTelegramExtensionCommand[];
|
|
50
47
|
export declare function findTelegramExtensionCommand(name: string | undefined): RegisteredTelegramExtensionCommand | undefined;
|
|
51
48
|
export declare function clearTelegramExtensionCommands(): void;
|
|
52
49
|
export declare const TELEGRAM_COMMAND_EMOJI: {
|
|
@@ -65,18 +62,14 @@ export declare const TELEGRAM_COMMAND_EMOJI: {
|
|
|
65
62
|
readonly new: "🆕";
|
|
66
63
|
};
|
|
67
64
|
export type TelegramCommandEmojiName = keyof typeof TELEGRAM_COMMAND_EMOJI;
|
|
68
|
-
export declare function getTelegramCommandEmoji(command: TelegramCommandEmojiName): string;
|
|
69
65
|
export declare function formatTelegramCommandEmojiPrefix(command: TelegramCommandEmojiName): string;
|
|
70
66
|
export declare function formatTelegramPiCommandHtml(command: string): string;
|
|
71
67
|
export declare function formatTelegramInformationHeading(emoji: string, text: string): string;
|
|
72
68
|
export declare function formatTelegramInvalidInstanceName(validationError: string): string;
|
|
73
69
|
export declare function formatTelegramThreadDisplayNameSavedHeading(name: string): string;
|
|
74
70
|
export declare function formatTelegramAutomaticThreadDisplayNameRestoredHeading(name: string): string;
|
|
75
|
-
export declare const TELEGRAM_COMPACTION_STARTED_TEXT: string;
|
|
76
|
-
export declare const TELEGRAM_COMPACTION_COMPLETED_TEXT: string;
|
|
77
71
|
export declare const TELEGRAM_COMPACTION_STARTED_MARKDOWN: string;
|
|
78
72
|
export declare const TELEGRAM_COMPACTION_COMPLETED_MARKDOWN = "**\u2705 Compaction completed.**";
|
|
79
|
-
export declare const TELEGRAM_BUILTIN_BOT_COMMANDS: readonly TelegramBotCommandDefinition[];
|
|
80
73
|
export declare const TELEGRAM_BOT_COMMANDS: readonly TelegramBotCommandDefinition[];
|
|
81
74
|
export declare function getTelegramReservedCommandNames(): string[];
|
|
82
75
|
export interface TelegramBotCommandRegistrationDeps {
|
|
@@ -542,16 +535,8 @@ export declare function handleTelegramNextCommand(deps: {
|
|
|
542
535
|
parseMode?: "HTML";
|
|
543
536
|
}) => Promise<void>) | undefined;
|
|
544
537
|
}): Promise<void>;
|
|
545
|
-
export declare function handleTelegramContinueCommand<TMessage, TContext>(message: TMessage, ctx: TContext, deps: {
|
|
546
|
-
enqueueContinueTurn: (message: TMessage, ctx: TContext) => Promise<void>;
|
|
547
|
-
}): Promise<void>;
|
|
548
|
-
export declare function buildTelegramNewConfirmationReplyMarkup(): TelegramCompactConfirmationReplyMarkup;
|
|
549
|
-
export declare function getTelegramNewConfirmationHtml(): string;
|
|
550
538
|
export declare function openTelegramNewConfirmation(target: TelegramCommandMessageTarget, deps: TelegramCompactConfirmationDeps): Promise<void>;
|
|
551
539
|
export declare function handleTelegramNewConfirmationCallback<TContext>(query: TelegramCompactConfirmationCallbackQuery, deps: TelegramNewConfirmationCallbackDeps<TContext>): Promise<boolean>;
|
|
552
|
-
export declare function buildTelegramCompactConfirmationReplyMarkup(): TelegramCompactConfirmationReplyMarkup;
|
|
553
|
-
export declare function getTelegramCompactConfirmationHtml(): string;
|
|
554
|
-
export declare function openTelegramCompactConfirmation(target: TelegramCommandMessageTarget, deps: TelegramCompactConfirmationDeps): Promise<void>;
|
|
555
540
|
export declare function handleTelegramCompactConfirmationCallback<TContext>(query: TelegramCompactConfirmationCallbackQuery, deps: TelegramCompactConfirmationCallbackDeps<TContext>): Promise<boolean>;
|
|
556
541
|
export interface TelegramNewCommandDeps extends TelegramRuntimeEventRecorderPort {
|
|
557
542
|
isIdle: () => boolean;
|
|
@@ -588,7 +573,6 @@ export declare function createTelegramCommandOrPromptRuntime<TMessage, TContext>
|
|
|
588
573
|
export declare const TELEGRAM_INTERNAL_COMMAND_NAME = "telegram-internal";
|
|
589
574
|
export declare const TELEGRAM_INTERNAL_COMMAND_DESCRIPTION = "Internal Telegram command cannot be run manually";
|
|
590
575
|
export declare const TELEGRAM_INTERNAL_MANUAL_USE_MESSAGE = "This internal Telegram command cannot be run manually.";
|
|
591
|
-
export declare function delayTelegramSessionAction(delayMs: number): Promise<void>;
|
|
592
576
|
export interface TelegramSessionActionRuntimeDeps {
|
|
593
577
|
registerCommand: Pi.ExtensionAPI["registerCommand"];
|
|
594
578
|
sendUserMessage: Pi.ExtensionAPI["sendUserMessage"];
|
|
@@ -621,13 +605,6 @@ export interface TelegramSessionReplacementSettlementDeps {
|
|
|
621
605
|
isCurrent?: () => boolean;
|
|
622
606
|
}
|
|
623
607
|
export declare function settleTelegramSessionReplacement(deps: TelegramSessionReplacementSettlementDeps): Promise<"none" | "settled" | "expired" | "failed" | "stale">;
|
|
624
|
-
export declare function createTelegramSessionReplacementSettlementRuntime<TContext>(deps: {
|
|
625
|
-
resolve: (ctx: TContext) => TelegramSessionReplacementSettlementDeps | undefined;
|
|
626
|
-
onResult?: (result: "none" | "settled" | "expired" | "failed" | "stale") => void;
|
|
627
|
-
onError?: (error: unknown) => void;
|
|
628
|
-
}): {
|
|
629
|
-
onSessionStart: (ctx: TContext) => void;
|
|
630
|
-
};
|
|
631
608
|
export interface TelegramSessionActionAssemblyDeps {
|
|
632
609
|
registerCommand: Pi.ExtensionAPI["registerCommand"];
|
|
633
610
|
sendUserMessage: Pi.ExtensionAPI["sendUserMessage"];
|
|
@@ -23,10 +23,10 @@ function getOrCreateTelegramCommandRegistry() {
|
|
|
23
23
|
globalThis[TELEGRAM_EXTENSION_COMMAND_REGISTRY_KEY] = registry;
|
|
24
24
|
return registry;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
function normalizeTelegramExtensionCommandName(name) {
|
|
27
27
|
return name.trim().replace(/^\/+/, "").toLowerCase();
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
function isTelegramExtensionCommandName(name) {
|
|
30
30
|
return TELEGRAM_BOT_COMMAND_NAME_PATTERN.test(name);
|
|
31
31
|
}
|
|
32
32
|
function normalizeTelegramExtensionCommandEmoji(emoji) {
|
|
@@ -67,7 +67,7 @@ export function registerTelegramCommand(registration) {
|
|
|
67
67
|
registry.commands.delete(name);
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
function getTelegramExtensionCommands() {
|
|
71
71
|
return Array.from(getOrCreateTelegramCommandRegistry().commands.values()).sort((a, b) => a.order - b.order || a.name.localeCompare(b.name));
|
|
72
72
|
}
|
|
73
73
|
export function findTelegramExtensionCommand(name) {
|
|
@@ -93,7 +93,7 @@ export const TELEGRAM_COMMAND_EMOJI = {
|
|
|
93
93
|
name: "🏷️",
|
|
94
94
|
new: "🆕",
|
|
95
95
|
};
|
|
96
|
-
|
|
96
|
+
function getTelegramCommandEmoji(command) {
|
|
97
97
|
return TELEGRAM_COMMAND_EMOJI[command];
|
|
98
98
|
}
|
|
99
99
|
export function formatTelegramCommandEmojiPrefix(command) {
|
|
@@ -124,14 +124,14 @@ export function formatTelegramThreadDisplayNameSavedHeading(name) {
|
|
|
124
124
|
export function formatTelegramAutomaticThreadDisplayNameRestoredHeading(name) {
|
|
125
125
|
return `<b>✅ Automatic Thread display name restored as <i>${escapeHtml(name)}</i>.</b>`;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
const TELEGRAM_COMPACTION_STARTED_TEXT = formatTelegramInformationHeading(getTelegramCommandEmoji("compact"), "Compaction started.");
|
|
128
|
+
const TELEGRAM_COMPACTION_COMPLETED_TEXT = formatTelegramInformationHeading("✅", "Compaction completed.");
|
|
129
129
|
export const TELEGRAM_COMPACTION_STARTED_MARKDOWN = `**${formatTelegramCommandEmojiPrefix("compact")}Compaction started.**`;
|
|
130
130
|
export const TELEGRAM_COMPACTION_COMPLETED_MARKDOWN = "**✅ Compaction completed.**";
|
|
131
131
|
function formatTelegramBotCommandDescription(command, description) {
|
|
132
132
|
return `${formatTelegramCommandEmojiPrefix(command)}${description}`;
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
const TELEGRAM_BUILTIN_BOT_COMMANDS = [
|
|
135
135
|
{
|
|
136
136
|
command: "start",
|
|
137
137
|
description: formatTelegramBotCommandDescription("start", "Open menu / Pair bridge"),
|
|
@@ -738,7 +738,7 @@ export async function handleTelegramNextCommand(deps) {
|
|
|
738
738
|
deps.dispatchNextQueuedTurn();
|
|
739
739
|
deps.updateStatus();
|
|
740
740
|
}
|
|
741
|
-
|
|
741
|
+
async function handleTelegramContinueCommand(message, ctx, deps) {
|
|
742
742
|
await deps.enqueueContinueTurn(message, ctx);
|
|
743
743
|
}
|
|
744
744
|
function dispatchNextQueuedTelegramTurnAfterCompact(deps) {
|
|
@@ -748,7 +748,7 @@ function dispatchNextQueuedTelegramTurnAfterCompact(deps) {
|
|
|
748
748
|
}
|
|
749
749
|
deps.dispatchNextQueuedTelegramTurn();
|
|
750
750
|
}
|
|
751
|
-
|
|
751
|
+
function buildTelegramNewConfirmationReplyMarkup() {
|
|
752
752
|
return {
|
|
753
753
|
inline_keyboard: [
|
|
754
754
|
[
|
|
@@ -758,7 +758,7 @@ export function buildTelegramNewConfirmationReplyMarkup() {
|
|
|
758
758
|
],
|
|
759
759
|
};
|
|
760
760
|
}
|
|
761
|
-
|
|
761
|
+
function getTelegramNewConfirmationHtml() {
|
|
762
762
|
return "<b>Start a new session?</b>";
|
|
763
763
|
}
|
|
764
764
|
export async function openTelegramNewConfirmation(target, deps) {
|
|
@@ -785,7 +785,7 @@ export async function handleTelegramNewConfirmationCallback(query, deps) {
|
|
|
785
785
|
await deps.runNew(deps.ctx);
|
|
786
786
|
return true;
|
|
787
787
|
}
|
|
788
|
-
|
|
788
|
+
function buildTelegramCompactConfirmationReplyMarkup() {
|
|
789
789
|
return {
|
|
790
790
|
inline_keyboard: [
|
|
791
791
|
[
|
|
@@ -795,10 +795,10 @@ export function buildTelegramCompactConfirmationReplyMarkup() {
|
|
|
795
795
|
],
|
|
796
796
|
};
|
|
797
797
|
}
|
|
798
|
-
|
|
798
|
+
function getTelegramCompactConfirmationHtml() {
|
|
799
799
|
return "<b>Compact session?</b>";
|
|
800
800
|
}
|
|
801
|
-
|
|
801
|
+
async function openTelegramCompactConfirmation(target, deps) {
|
|
802
802
|
await deps.sendInteractiveMessage(target.chatId, getTelegramCompactConfirmationHtml(), "html", buildTelegramCompactConfirmationReplyMarkup(), target.threadId !== undefined
|
|
803
803
|
? { target: { chatId: target.chatId, threadId: target.threadId } }
|
|
804
804
|
: undefined);
|
|
@@ -1277,7 +1277,7 @@ async function handleTelegramCommandRuntime(commandName, message, ctx, deps, com
|
|
|
1277
1277
|
export const TELEGRAM_INTERNAL_COMMAND_NAME = "telegram-internal";
|
|
1278
1278
|
export const TELEGRAM_INTERNAL_COMMAND_DESCRIPTION = "Internal Telegram command cannot be run manually";
|
|
1279
1279
|
export const TELEGRAM_INTERNAL_MANUAL_USE_MESSAGE = "This internal Telegram command cannot be run manually.";
|
|
1280
|
-
|
|
1280
|
+
function delayTelegramSessionAction(delayMs) {
|
|
1281
1281
|
return new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
1282
1282
|
}
|
|
1283
1283
|
export async function settleTelegramSessionReplacement(deps) {
|
|
@@ -1309,7 +1309,7 @@ export async function settleTelegramSessionReplacement(deps) {
|
|
|
1309
1309
|
}
|
|
1310
1310
|
return "stale";
|
|
1311
1311
|
}
|
|
1312
|
-
|
|
1312
|
+
function createTelegramSessionReplacementSettlementRuntime(deps) {
|
|
1313
1313
|
let generation = 0;
|
|
1314
1314
|
return {
|
|
1315
1315
|
onSessionStart(ctx) {
|
|
@@ -16,17 +16,10 @@ export type TelegramBotTokenReference = {
|
|
|
16
16
|
} | {
|
|
17
17
|
kind: "malformed";
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
* Parse a persisted bot-token value. `$NAME` and `${NAME}` are exact
|
|
21
|
-
* environment-variable references. Any other `$`-prefixed value is malformed
|
|
22
|
-
* rather than a literal secret so a broken reference fails closed.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getTelegramBotTokenReference(value: string | undefined): TelegramBotTokenReference | undefined;
|
|
25
19
|
/** Resolve a persisted token at a validation/activation boundary. */
|
|
26
20
|
export declare function resolveTelegramBotToken(value: string | undefined, env?: NodeJS.ProcessEnv): string | undefined;
|
|
27
21
|
/** Redacted diagnostic for an unresolved or malformed token reference. */
|
|
28
22
|
export declare function getTelegramBotTokenDiagnostic(value: string | undefined, env?: NodeJS.ProcessEnv): string | undefined;
|
|
29
|
-
export type TelegramOutboundCommandTemplateConfig = string | CommandTemplateObjectConfig;
|
|
30
23
|
export interface TelegramOutboundHandlerConfig extends CommandTemplateObjectConfig {
|
|
31
24
|
type?: string;
|
|
32
25
|
match?: string | string[];
|
|
@@ -179,13 +172,6 @@ export declare function normalizeTelegramDefaultProfileConfig(config: TelegramCo
|
|
|
179
172
|
changed: boolean;
|
|
180
173
|
};
|
|
181
174
|
export declare function createTelegramConfigStore(options?: TelegramConfigStoreOptions): TelegramConfigStore;
|
|
182
|
-
export declare function createTelegramDraftPreviewsChecker(configStore: Pick<TelegramConfigStore, "get">): () => boolean;
|
|
183
|
-
export declare function createTelegramDraftPreviewsSetter(configStore: TelegramMutableConfigStore): (enabled: boolean) => Promise<void>;
|
|
184
|
-
export declare function createTelegramAssistantRenderingModeGetter(configStore: Pick<TelegramConfigStore, "get">): () => TelegramAssistantRenderingMode;
|
|
185
|
-
export declare function createTelegramAssistantRenderingModeSetter(configStore: TelegramMutableConfigStore): (mode: TelegramAssistantRenderingMode) => Promise<void>;
|
|
186
|
-
export declare function createTelegramActivityVerbosityGetter(configStore: Pick<TelegramConfigStore, "get">): () => TelegramActivityVerbosity;
|
|
187
|
-
export declare function createTelegramActivityVerbosityRefresher(configStore: TelegramMutableConfigStore): () => Promise<void>;
|
|
188
|
-
export declare function createTelegramActivityVerbositySetter(configStore: TelegramMutableConfigStore): (verbosity: TelegramActivityVerbosity) => Promise<void>;
|
|
189
175
|
export declare function createTelegramVoiceReplyModeGetter(configStore: Pick<TelegramConfigStore, "get">): () => "manual" | "mirror" | "always";
|
|
190
176
|
export declare function createTelegramVoiceReplyModeConfiguredChecker(configStore: Pick<TelegramConfigStore, "get">): () => boolean;
|
|
191
177
|
export declare function createTelegramVoiceReplyModeSetter(configStore: TelegramMutableConfigStore): (replyMode: "manual" | "hidden" | "mirror" | "always" | undefined) => Promise<void>;
|
|
@@ -203,9 +189,6 @@ export declare function createTelegramProactivePushTargetGetter(deps: {
|
|
|
203
189
|
getAssignedTarget: () => TelegramProactivePushTarget | undefined;
|
|
204
190
|
getAllowedUserId: () => number | undefined;
|
|
205
191
|
}): () => TelegramProactivePushTarget | undefined;
|
|
206
|
-
export declare function createTelegramAutomaticThreadCleanupChecker(configStore: Pick<TelegramConfigStore, "get">): () => boolean;
|
|
207
|
-
export declare function createTelegramAutomaticThreadCleanupResolver(configStore: TelegramMutableConfigStore): () => Promise<boolean>;
|
|
208
|
-
export declare function createTelegramAutomaticThreadCleanupSetter(configStore: TelegramMutableConfigStore): (enabled: boolean) => Promise<void>;
|
|
209
192
|
export declare function createTelegramConfigControls(configStore: TelegramMutableConfigStore): {
|
|
210
193
|
areDraftPreviewsEnabled: () => boolean;
|
|
211
194
|
setDraftPreviewsEnabled: (enabled: boolean) => Promise<void>;
|
|
@@ -8,6 +8,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, u
|
|
|
8
8
|
import { chmod, mkdir, rename, writeFile } from "node:fs/promises";
|
|
9
9
|
import { resolveAgentDir, resolveTelegramConfigPath, TELEGRAM_DEFAULT_PROFILE_NAME, } from "./paths.js";
|
|
10
10
|
export { TELEGRAM_DEFAULT_PROFILE_NAME } from "./paths.js";
|
|
11
|
+
import { isWireRecord as isPlainConfigRecord } from "./wire.js";
|
|
11
12
|
import { withTelegramFileTransaction } from "./locks.js";
|
|
12
13
|
const CONFIG_RUNTIME_KEY = "__piTelegramConfigRuntime__";
|
|
13
14
|
const CONFIG_REPLACE_RETRY_ATTEMPTS = 5;
|
|
@@ -45,7 +46,7 @@ const TELEGRAM_BOT_TOKEN_ENV_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
|
45
46
|
* environment-variable references. Any other `$`-prefixed value is malformed
|
|
46
47
|
* rather than a literal secret so a broken reference fails closed.
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
+
function getTelegramBotTokenReference(value) {
|
|
49
50
|
const trimmed = value?.trim();
|
|
50
51
|
if (!trimmed)
|
|
51
52
|
return undefined;
|
|
@@ -211,9 +212,6 @@ export async function writeTelegramConfig(agentDir, configPath, config) {
|
|
|
211
212
|
await rename(tempConfigPath, configPath);
|
|
212
213
|
await chmod(configPath, 0o600);
|
|
213
214
|
}
|
|
214
|
-
function isPlainConfigRecord(value) {
|
|
215
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
216
|
-
}
|
|
217
215
|
function cloneTelegramConfig(value) {
|
|
218
216
|
return structuredClone(value);
|
|
219
217
|
}
|
|
@@ -628,7 +626,7 @@ export function createTelegramConfigStore(options = {}) {
|
|
|
628
626
|
},
|
|
629
627
|
};
|
|
630
628
|
}
|
|
631
|
-
|
|
629
|
+
function createTelegramDraftPreviewsChecker(configStore) {
|
|
632
630
|
return () => {
|
|
633
631
|
const config = configStore.get();
|
|
634
632
|
return (config.assistant?.draftPreviews ??
|
|
@@ -637,7 +635,7 @@ export function createTelegramDraftPreviewsChecker(configStore) {
|
|
|
637
635
|
true);
|
|
638
636
|
};
|
|
639
637
|
}
|
|
640
|
-
|
|
638
|
+
function createTelegramDraftPreviewsSetter(configStore) {
|
|
641
639
|
return async (enabled) => {
|
|
642
640
|
await loadLatestTelegramConfig(configStore);
|
|
643
641
|
const { draftPreviews: _legacyDraftPreviews, richDraftPreviews: _legacyRichDraftPreviews, ...current } = configStore.get();
|
|
@@ -649,14 +647,14 @@ export function createTelegramDraftPreviewsSetter(configStore) {
|
|
|
649
647
|
await configStore.persist(config);
|
|
650
648
|
};
|
|
651
649
|
}
|
|
652
|
-
|
|
650
|
+
function createTelegramAssistantRenderingModeGetter(configStore) {
|
|
653
651
|
return () => {
|
|
654
652
|
const config = configStore.get();
|
|
655
653
|
const mode = config.assistant?.rendering ?? config.assistantRendering;
|
|
656
654
|
return mode === "html" ? "html" : "rich";
|
|
657
655
|
};
|
|
658
656
|
}
|
|
659
|
-
|
|
657
|
+
function createTelegramAssistantRenderingModeSetter(configStore) {
|
|
660
658
|
return async (mode) => {
|
|
661
659
|
await loadLatestTelegramConfig(configStore);
|
|
662
660
|
const { assistantRendering: _legacyAssistantRendering, ...current } = configStore.get();
|
|
@@ -668,7 +666,7 @@ export function createTelegramAssistantRenderingModeSetter(configStore) {
|
|
|
668
666
|
await configStore.persist(config);
|
|
669
667
|
};
|
|
670
668
|
}
|
|
671
|
-
|
|
669
|
+
function createTelegramActivityVerbosityGetter(configStore) {
|
|
672
670
|
return () => {
|
|
673
671
|
const assistant = configStore.get().assistant;
|
|
674
672
|
if (assistant?.activity !== undefined) {
|
|
@@ -685,10 +683,10 @@ export function createTelegramActivityVerbosityGetter(configStore) {
|
|
|
685
683
|
return "verbose";
|
|
686
684
|
};
|
|
687
685
|
}
|
|
688
|
-
|
|
686
|
+
function createTelegramActivityVerbosityRefresher(configStore) {
|
|
689
687
|
return () => loadLatestTelegramConfig(configStore);
|
|
690
688
|
}
|
|
691
|
-
|
|
689
|
+
function createTelegramActivityVerbositySetter(configStore) {
|
|
692
690
|
return async (verbosity) => {
|
|
693
691
|
await loadLatestTelegramConfig(configStore);
|
|
694
692
|
const current = configStore.get();
|
|
@@ -801,10 +799,10 @@ export function createTelegramProactivePushTargetGetter(deps) {
|
|
|
801
799
|
return typeof chatId === "number" ? { chatId } : undefined;
|
|
802
800
|
};
|
|
803
801
|
}
|
|
804
|
-
|
|
802
|
+
function createTelegramAutomaticThreadCleanupChecker(configStore) {
|
|
805
803
|
return () => configStore.get().threads?.automaticCleanup ?? true;
|
|
806
804
|
}
|
|
807
|
-
|
|
805
|
+
function createTelegramAutomaticThreadCleanupResolver(configStore) {
|
|
808
806
|
return async () => {
|
|
809
807
|
await loadLatestTelegramConfig(configStore);
|
|
810
808
|
if (configStore.didLastLoadRecoverInvalidConfig?.()) {
|
|
@@ -813,7 +811,7 @@ export function createTelegramAutomaticThreadCleanupResolver(configStore) {
|
|
|
813
811
|
return createTelegramAutomaticThreadCleanupChecker(configStore)();
|
|
814
812
|
};
|
|
815
813
|
}
|
|
816
|
-
|
|
814
|
+
function createTelegramAutomaticThreadCleanupSetter(configStore) {
|
|
817
815
|
return async (enabled) => {
|
|
818
816
|
await loadLatestTelegramConfig(configStore);
|
|
819
817
|
const current = configStore.get();
|
|
@@ -108,10 +108,6 @@ export declare function createTelegramBridgeDeliveryLifecycleHooks<TTransportSta
|
|
|
108
108
|
getTransportStamp?: () => TTransportStamp;
|
|
109
109
|
isTransportStampActive?: (stamp: TTransportStamp) => boolean;
|
|
110
110
|
}): ReturnType<typeof createTelegramDeliveryLifecycleHooks>;
|
|
111
|
-
export declare function classifyTelegramDeliveryTransportError(error: unknown): {
|
|
112
|
-
reason: Extract<TelegramDeliveryFailureReason, "commit-unknown" | "message-unavailable" | "rate-limited" | "transport-retryable" | "transport-failed">;
|
|
113
|
-
retryAfterMs?: number;
|
|
114
|
-
};
|
|
115
111
|
/** @internal */
|
|
116
112
|
export interface TelegramDeliveryTargetPolicyView {
|
|
117
113
|
canDeliver: boolean;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { markTelegramBusAggregateDelivery } from "./bus.js";
|
|
7
7
|
import { assertTelegramInlineKeyboardCallbackData, } from "./keyboard.js";
|
|
8
8
|
import { withTelegramReplyParameters, renderTelegramMessage, } from "./replies.js";
|
|
9
|
-
import { getTelegramTargetThreadParams, } from "./target.js";
|
|
9
|
+
import { areTelegramTargetsEqual as areDeliveryTargetsEqual, getTelegramTargetThreadParams, } from "./target.js";
|
|
10
10
|
import { getTelegramApiRetryAfterMs, isRetryableTelegramApiError, isTelegramApiCommitUnknownError, isTelegramMessageUnavailableError, } from "./telegram-api.js";
|
|
11
11
|
const TELEGRAM_DELIVERY_RUNTIME_KEY = "__piTelegramDeliveryRuntime__";
|
|
12
12
|
class TelegramDeliveryTransportGenerationError extends Error {
|
|
@@ -69,7 +69,7 @@ function failure(reason, message, partial, retryAfterMs) {
|
|
|
69
69
|
? { ok: false, reason, message, ...retry }
|
|
70
70
|
: { ok: false, reason, message, partial, ...retry };
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
function classifyTelegramDeliveryTransportError(error) {
|
|
73
73
|
if (isTelegramApiCommitUnknownError(error))
|
|
74
74
|
return { reason: "commit-unknown" };
|
|
75
75
|
if (isTelegramMessageUnavailableError(error))
|
|
@@ -140,9 +140,6 @@ export function isTelegramDeliveryExplicitTargetAuthorized(candidate, view) {
|
|
|
140
140
|
return areDeliveryTargetsEqual(candidate, target);
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
function areDeliveryTargetsEqual(left, right) {
|
|
144
|
-
return left.chatId === right.chatId && left.threadId === right.threadId;
|
|
145
|
-
}
|
|
146
143
|
function cloneTarget(target) {
|
|
147
144
|
return target.threadId === undefined
|
|
148
145
|
? { chatId: target.chatId }
|