@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
|
@@ -77,19 +77,9 @@ export interface TelegramSettingsMenuRuntimeDeps<TContext, TModel extends MenuMo
|
|
|
77
77
|
sendInteractiveMessage: (chatId: number, text: string, mode: "markdown" | "html" | "plain", replyMarkup: TelegramSettingsMenuReplyMarkup) => Promise<number | undefined>;
|
|
78
78
|
answerCallbackQuery: (callbackQueryId: string, text?: string) => Promise<void>;
|
|
79
79
|
}
|
|
80
|
-
export declare const SETTINGS_MENU_TITLE = "<b>\u2699\uFE0F Settings:</b>";
|
|
81
|
-
export declare const AUTOMATIC_THREAD_CLEANUP_SETTINGS_TITLE = "<b>\uD83E\uDDF9 Thread cleanup:</b>";
|
|
82
|
-
export declare const INACTIVE_THREAD_REVIEW_TITLE = "<b>\uD83D\uDD0E Inactive tabs review:</b>";
|
|
83
|
-
export declare const DRAFT_PREVIEWS_SETTINGS_TITLE = "<b>\uD83D\uDCDD Draft previews:</b>";
|
|
84
|
-
export declare const ASSISTANT_RENDERING_SETTINGS_TITLE = "<b>\uD83E\uDDFE Assistant rendering:</b>";
|
|
85
|
-
export declare const ACTIVITY_VERBOSITY_SETTINGS_TITLE = "<b>\uD83D\uDD2C Activity:</b>";
|
|
86
|
-
export declare const TIME_INJECTION_MODE_SETTINGS_TITLE = "<b>\uD83D\uDD52 Time injection mode:</b>";
|
|
87
|
-
export declare const VOICE_REPLY_MODE_SETTINGS_TITLE = "<b>\uD83D\uDC44 Voice reply mode:</b>";
|
|
88
|
-
export declare const THREAD_DISPLAY_SETTINGS_TITLE = "<b>\uD83E\uDDF5 Thread display:</b>";
|
|
89
80
|
export declare function buildTelegramSettingsMenuText(): string;
|
|
90
81
|
export declare function buildThreadDisplaySettingsText(mode: TelegramThreadDisplayMode, custom?: boolean): string;
|
|
91
82
|
export declare function buildAutomaticThreadCleanupSettingsText(enabled: boolean): string;
|
|
92
|
-
export declare function buildInactiveThreadReviewText(count: number): string;
|
|
93
83
|
export declare function buildInactiveThreadReviewReplyMarkup(operationId?: string, canCleanInactiveThreads?: boolean): TelegramSettingsMenuReplyMarkup;
|
|
94
84
|
export declare function buildDraftPreviewsSettingsText(enabled: boolean): string;
|
|
95
85
|
export declare function buildAssistantRenderingSettingsText(mode: TelegramAssistantRenderingMode): string;
|
|
@@ -97,7 +87,6 @@ export declare function buildActivityVerbositySettingsText(verbosity: TelegramAc
|
|
|
97
87
|
export declare function buildVoiceReplyModeSettingsText(mode: TelegramVoiceReplyMode, configured?: boolean): string;
|
|
98
88
|
export declare function buildTimeInjectionModeSettingsText(mode: TelegramTimeMode): string;
|
|
99
89
|
export declare function buildTelegramSettingsMenuReplyMarkup(draftPreviewsEnabled: boolean, assistantRenderingModeOrVoiceReplyMode: TelegramAssistantRenderingMode | TelegramVoiceReplyMode, voiceReplyModeOrTimeInjectionMode: TelegramVoiceReplyMode | TelegramTimeMode, timeInjectionModeOrSectionRegistry?: TelegramTimeMode | TelegramSectionRegistry, sectionRegistryOrVoiceReplyModeConfigured?: TelegramSectionRegistry | boolean, voiceReplyModeConfigured?: boolean, automaticThreadCleanupEnabled?: boolean, activityVerbosity?: TelegramActivityVerbosity, threadDisplayMode?: TelegramThreadDisplayMode, threadDisplayCustom?: boolean): TelegramSettingsMenuReplyMarkup;
|
|
100
|
-
export declare function openTelegramSettingsMenu<TModel extends MenuModel = MenuModel>(deps: TelegramSettingsMenuOpenDeps<TModel>, sectionRegistry?: TelegramSectionRegistry): Promise<void>;
|
|
101
90
|
export declare function buildThreadDisplaySettingsReplyMarkup(mode: TelegramThreadDisplayMode, custom?: boolean): TelegramSettingsMenuReplyMarkup;
|
|
102
91
|
export declare function buildAutomaticThreadCleanupSettingsReplyMarkup(enabled: boolean, canReviewInactiveThreads?: boolean): TelegramSettingsMenuReplyMarkup;
|
|
103
92
|
export declare function buildDraftPreviewsSettingsReplyMarkup(enabled: boolean): TelegramSettingsMenuReplyMarkup;
|
|
@@ -105,12 +94,5 @@ export declare function buildAssistantRenderingSettingsReplyMarkup(mode: Telegra
|
|
|
105
94
|
export declare function buildActivityVerbositySettingsReplyMarkup(verbosity: TelegramActivityVerbosity): TelegramSettingsMenuReplyMarkup;
|
|
106
95
|
export declare function buildTimeInjectionModeSettingsReplyMarkup(mode: TelegramTimeMode): TelegramSettingsMenuReplyMarkup;
|
|
107
96
|
export declare function buildVoiceReplyModeSettingsReplyMarkup(mode: TelegramVoiceReplyMode, configured?: boolean): TelegramSettingsMenuReplyMarkup;
|
|
108
|
-
export declare function updateTelegramSettingsMenuMessage(deps: TelegramSettingsMenuMessageUpdateDeps, sectionRegistry?: TelegramSectionRegistry): Promise<void>;
|
|
109
|
-
export declare function updateAutomaticThreadCleanupSettingsMessage(deps: TelegramSettingsMenuCallbackDeps): Promise<void>;
|
|
110
|
-
export declare function updateDraftPreviewsSettingsMessage(deps: TelegramSettingsMenuCallbackDeps): Promise<void>;
|
|
111
|
-
export declare function updateAssistantRenderingSettingsMessage(deps: TelegramSettingsMenuCallbackDeps): Promise<void>;
|
|
112
|
-
export declare function updateActivityVerbositySettingsMessage(deps: TelegramSettingsMenuCallbackDeps): Promise<void>;
|
|
113
|
-
export declare function updateTimeInjectionModeSettingsMessage(deps: TelegramSettingsMenuCallbackDeps): Promise<void>;
|
|
114
|
-
export declare function updateVoiceReplyModeSettingsMessage(deps: TelegramSettingsMenuCallbackDeps): Promise<void>;
|
|
115
97
|
export declare function handleTelegramSettingsMenuCallbackAction(callbackQueryId: string, data: string | undefined, deps: TelegramSettingsMenuCallbackDeps): Promise<boolean>;
|
|
116
98
|
export declare function createTelegramSettingsMenuRuntime<TContext, TModel extends MenuModel = MenuModel>(deps: TelegramSettingsMenuRuntimeDeps<TContext, TModel>, sectionRegistry?: TelegramSectionRegistry): TelegramSettingsMenuRuntime<TContext>;
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* Owns hidden settings-menu rendering, settings callbacks, and persisted toggle wiring
|
|
5
5
|
*/
|
|
6
6
|
import { getTelegramExtensionSettingsRows, } from "./sections.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const SETTINGS_MENU_TITLE = "<b>⚙️ Settings:</b>";
|
|
8
|
+
const AUTOMATIC_THREAD_CLEANUP_SETTINGS_TITLE = "<b>🧹 Thread cleanup:</b>";
|
|
9
|
+
const INACTIVE_THREAD_REVIEW_TITLE = "<b>🔎 Inactive tabs review:</b>";
|
|
10
|
+
const DRAFT_PREVIEWS_SETTINGS_TITLE = "<b>📝 Draft previews:</b>";
|
|
11
|
+
const ASSISTANT_RENDERING_SETTINGS_TITLE = "<b>🧾 Assistant rendering:</b>";
|
|
12
|
+
const ACTIVITY_VERBOSITY_SETTINGS_TITLE = "<b>🔬 Activity:</b>";
|
|
13
|
+
const TIME_INJECTION_MODE_SETTINGS_TITLE = "<b>🕒 Time injection mode:</b>";
|
|
14
|
+
const VOICE_REPLY_MODE_SETTINGS_TITLE = "<b>👄 Voice reply mode:</b>";
|
|
15
|
+
const THREAD_DISPLAY_SETTINGS_TITLE = "<b>🧵 Thread display:</b>";
|
|
16
16
|
function getVoiceReplyModeLabel(mode) {
|
|
17
17
|
return mode;
|
|
18
18
|
}
|
|
@@ -51,7 +51,7 @@ export function buildAutomaticThreadCleanupSettingsText(enabled) {
|
|
|
51
51
|
"Review inactive tabs checks current owner and work evidence. Review never deletes tabs.",
|
|
52
52
|
].join("\n");
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
function buildInactiveThreadReviewText(count) {
|
|
55
55
|
return [INACTIVE_THREAD_REVIEW_TITLE, "",
|
|
56
56
|
`${count} proven inactive tab${count === 1 ? "" : "s"}.`,
|
|
57
57
|
"No tabs were deleted.",
|
|
@@ -185,7 +185,7 @@ export function buildTelegramSettingsMenuReplyMarkup(draftPreviewsEnabled, assis
|
|
|
185
185
|
rows.push(...settingsButtons.map((button) => [button]));
|
|
186
186
|
return { inline_keyboard: rows };
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
async function openTelegramSettingsMenu(deps, sectionRegistry) {
|
|
189
189
|
const state = await deps.getModelMenuState();
|
|
190
190
|
const messageId = await deps.sendSettingsMenu(state, buildTelegramSettingsMenuText(), buildTelegramSettingsMenuReplyMarkup(deps.areDraftPreviewsEnabled(), deps.getAssistantRenderingMode(), deps.getVoiceReplyMode(), deps.getTimeInjectionMode(), sectionRegistry, deps.isVoiceReplyModeConfigured(), deps.isAutomaticThreadCleanupEnabled(), deps.getActivityVerbosity(), deps.getThreadDisplayMode?.(), deps.isThreadDisplayCustom?.() ?? false));
|
|
191
191
|
if (messageId === undefined)
|
|
@@ -307,30 +307,30 @@ export function buildVoiceReplyModeSettingsReplyMarkup(mode, configured = true)
|
|
|
307
307
|
],
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
async function updateTelegramSettingsMenuMessage(deps, sectionRegistry) {
|
|
311
311
|
await deps.updateSettingsMessage(buildTelegramSettingsMenuText(), buildTelegramSettingsMenuReplyMarkup(deps.areDraftPreviewsEnabled(), deps.getAssistantRenderingMode(), deps.getVoiceReplyMode(), deps.getTimeInjectionMode(), sectionRegistry, deps.isVoiceReplyModeConfigured(), deps.isAutomaticThreadCleanupEnabled(), deps.getActivityVerbosity(), deps.getThreadDisplayMode?.(), deps.isThreadDisplayCustom?.() ?? false));
|
|
312
312
|
}
|
|
313
|
-
|
|
313
|
+
async function updateAutomaticThreadCleanupSettingsMessage(deps) {
|
|
314
314
|
const enabled = deps.isAutomaticThreadCleanupEnabled();
|
|
315
315
|
await deps.updateSettingsMessage(buildAutomaticThreadCleanupSettingsText(enabled), buildAutomaticThreadCleanupSettingsReplyMarkup(enabled, !!deps.reviewInactiveThreads));
|
|
316
316
|
}
|
|
317
|
-
|
|
317
|
+
async function updateDraftPreviewsSettingsMessage(deps) {
|
|
318
318
|
const enabled = deps.areDraftPreviewsEnabled();
|
|
319
319
|
await deps.updateSettingsMessage(buildDraftPreviewsSettingsText(enabled), buildDraftPreviewsSettingsReplyMarkup(enabled));
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
async function updateAssistantRenderingSettingsMessage(deps) {
|
|
322
322
|
const mode = deps.getAssistantRenderingMode();
|
|
323
323
|
await deps.updateSettingsMessage(buildAssistantRenderingSettingsText(mode), buildAssistantRenderingSettingsReplyMarkup(mode));
|
|
324
324
|
}
|
|
325
|
-
|
|
325
|
+
async function updateActivityVerbositySettingsMessage(deps) {
|
|
326
326
|
const verbosity = deps.getActivityVerbosity();
|
|
327
327
|
await deps.updateSettingsMessage(buildActivityVerbositySettingsText(verbosity), buildActivityVerbositySettingsReplyMarkup(verbosity));
|
|
328
328
|
}
|
|
329
|
-
|
|
329
|
+
async function updateTimeInjectionModeSettingsMessage(deps) {
|
|
330
330
|
const mode = deps.getTimeInjectionMode();
|
|
331
331
|
await deps.updateSettingsMessage(buildTimeInjectionModeSettingsText(mode), buildTimeInjectionModeSettingsReplyMarkup(mode));
|
|
332
332
|
}
|
|
333
|
-
|
|
333
|
+
async function updateVoiceReplyModeSettingsMessage(deps) {
|
|
334
334
|
const mode = deps.getVoiceReplyMode();
|
|
335
335
|
const configured = deps.isVoiceReplyModeConfigured();
|
|
336
336
|
await deps.updateSettingsMessage(buildVoiceReplyModeSettingsText(mode, configured), buildVoiceReplyModeSettingsReplyMarkup(mode, configured));
|
|
@@ -26,7 +26,7 @@ export interface TelegramStatusMenuOpenDeps<TModel extends MenuModel = MenuModel
|
|
|
26
26
|
}
|
|
27
27
|
export declare function openTelegramStatusMenu<TModel extends MenuModel = MenuModel>(deps: TelegramStatusMenuOpenDeps<TModel>): Promise<void>;
|
|
28
28
|
export declare function handleTelegramStatusMenuCallbackAction(callbackQueryId: string, data: string | undefined, activeModel: MenuModel | undefined, deps: TelegramStatusMenuCallbackDeps): Promise<boolean>;
|
|
29
|
-
export declare function buildStatusReplyMarkup(activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean): TelegramReplyMarkup;
|
|
30
|
-
export declare function buildTelegramStatusMenuRenderPayload(statusText: string, activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean): TelegramMenuRenderPayload;
|
|
31
|
-
export declare function updateTelegramStatusMessage(state: TelegramModelMenuState, statusText: string, activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, deps: TelegramMenuMessageRuntimeDeps, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean): Promise<void>;
|
|
32
|
-
export declare function sendTelegramStatusMessage(state: TelegramModelMenuState, statusText: string, activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, deps: TelegramMenuMessageRuntimeDeps, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean): Promise<number | undefined>;
|
|
29
|
+
export declare function buildStatusReplyMarkup(activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean, pendingCancellationCount?: number): TelegramReplyMarkup;
|
|
30
|
+
export declare function buildTelegramStatusMenuRenderPayload(statusText: string, activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean, pendingCancellationCount?: number): TelegramMenuRenderPayload;
|
|
31
|
+
export declare function updateTelegramStatusMessage(state: TelegramModelMenuState, statusText: string, activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, deps: TelegramMenuMessageRuntimeDeps, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean, pendingCancellationCount?: number): Promise<void>;
|
|
32
|
+
export declare function sendTelegramStatusMessage(state: TelegramModelMenuState, statusText: string, activeModel: MenuModel | undefined, currentThinkingLevel: ThinkingLevel, deps: TelegramMenuMessageRuntimeDeps, queueItemCount?: number, sectionRegistry?: TelegramSectionRegistry, isVoiceReplyActive?: boolean, pendingCancellationCount?: number): Promise<number | undefined>;
|
|
@@ -60,7 +60,7 @@ export async function handleTelegramStatusMenuCallbackAction(callbackQueryId, da
|
|
|
60
60
|
await deps.answerCallbackQuery(callbackQueryId);
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
|
-
export function buildStatusReplyMarkup(activeModel, currentThinkingLevel, queueItemCount = 0, sectionRegistry, isVoiceReplyActive) {
|
|
63
|
+
export function buildStatusReplyMarkup(activeModel, currentThinkingLevel, queueItemCount = 0, sectionRegistry, isVoiceReplyActive, pendingCancellationCount = 0) {
|
|
64
64
|
const rows = [];
|
|
65
65
|
rows.push([
|
|
66
66
|
{
|
|
@@ -82,6 +82,11 @@ export function buildStatusReplyMarkup(activeModel, currentThinkingLevel, queueI
|
|
|
82
82
|
callback_data: "menu:queue",
|
|
83
83
|
},
|
|
84
84
|
]);
|
|
85
|
+
if (pendingCancellationCount > 0)
|
|
86
|
+
rows.push([{
|
|
87
|
+
text: `❌ Pending cancellations: ${pendingCancellationCount}`,
|
|
88
|
+
callback_data: "reroutecancel:review:open",
|
|
89
|
+
}]);
|
|
85
90
|
if (sectionRegistry) {
|
|
86
91
|
const sectionRows = getTelegramSectionMainMenuRows(sectionRegistry);
|
|
87
92
|
for (const row of sectionRows) {
|
|
@@ -96,17 +101,17 @@ export function buildStatusReplyMarkup(activeModel, currentThinkingLevel, queueI
|
|
|
96
101
|
]);
|
|
97
102
|
return { inline_keyboard: rows };
|
|
98
103
|
}
|
|
99
|
-
export function buildTelegramStatusMenuRenderPayload(statusText, activeModel, currentThinkingLevel, queueItemCount = 0, sectionRegistry, isVoiceReplyActive) {
|
|
104
|
+
export function buildTelegramStatusMenuRenderPayload(statusText, activeModel, currentThinkingLevel, queueItemCount = 0, sectionRegistry, isVoiceReplyActive, pendingCancellationCount = 0) {
|
|
100
105
|
return {
|
|
101
106
|
nextMode: "status",
|
|
102
107
|
text: statusText,
|
|
103
108
|
mode: "html",
|
|
104
|
-
replyMarkup: buildStatusReplyMarkup(activeModel, currentThinkingLevel, queueItemCount, sectionRegistry, isVoiceReplyActive),
|
|
109
|
+
replyMarkup: buildStatusReplyMarkup(activeModel, currentThinkingLevel, queueItemCount, sectionRegistry, isVoiceReplyActive, pendingCancellationCount),
|
|
105
110
|
};
|
|
106
111
|
}
|
|
107
|
-
export async function updateTelegramStatusMessage(state, statusText, activeModel, currentThinkingLevel, deps, queueItemCount = 0, sectionRegistry, isVoiceReplyActive) {
|
|
108
|
-
await editTelegramMenuMessage(state, buildTelegramStatusMenuRenderPayload(statusText, activeModel, currentThinkingLevel, queueItemCount, sectionRegistry, isVoiceReplyActive), deps);
|
|
112
|
+
export async function updateTelegramStatusMessage(state, statusText, activeModel, currentThinkingLevel, deps, queueItemCount = 0, sectionRegistry, isVoiceReplyActive, pendingCancellationCount = 0) {
|
|
113
|
+
await editTelegramMenuMessage(state, buildTelegramStatusMenuRenderPayload(statusText, activeModel, currentThinkingLevel, queueItemCount, sectionRegistry, isVoiceReplyActive, pendingCancellationCount), deps);
|
|
109
114
|
}
|
|
110
|
-
export function sendTelegramStatusMessage(state, statusText, activeModel, currentThinkingLevel, deps, queueItemCount = 0, sectionRegistry, isVoiceReplyActive) {
|
|
111
|
-
return sendTelegramMenuMessage(state, buildTelegramStatusMenuRenderPayload(statusText, activeModel, currentThinkingLevel, queueItemCount, sectionRegistry, isVoiceReplyActive), deps);
|
|
115
|
+
export function sendTelegramStatusMessage(state, statusText, activeModel, currentThinkingLevel, deps, queueItemCount = 0, sectionRegistry, isVoiceReplyActive, pendingCancellationCount = 0) {
|
|
116
|
+
return sendTelegramMenuMessage(state, buildTelegramStatusMenuRenderPayload(statusText, activeModel, currentThinkingLevel, queueItemCount, sectionRegistry, isVoiceReplyActive, pendingCancellationCount), deps);
|
|
112
117
|
}
|
|
@@ -8,7 +8,7 @@ import { type MenuModel, type ThinkingLevel } from "./model.ts";
|
|
|
8
8
|
export interface TelegramThinkingMenuCallbackDeps {
|
|
9
9
|
setThinkingLevel: (level: ThinkingLevel) => void;
|
|
10
10
|
getCurrentThinkingLevel: () => ThinkingLevel;
|
|
11
|
-
|
|
11
|
+
updateThinkingMenuMessage: () => Promise<void>;
|
|
12
12
|
answerCallbackQuery: (callbackQueryId: string, text?: string) => Promise<void>;
|
|
13
13
|
isVoiceReplyActive?: () => boolean;
|
|
14
14
|
}
|
|
@@ -40,7 +40,7 @@ export async function handleTelegramThinkingMenuCallbackAction(callbackQueryId,
|
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
42
|
deps.setThinkingLevel(action.level);
|
|
43
|
-
await deps.
|
|
43
|
+
await deps.updateThinkingMenuMessage();
|
|
44
44
|
await deps.answerCallbackQuery(callbackQueryId, `Thinking: ${deps.getCurrentThinkingLevel()}`);
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
@@ -82,6 +82,7 @@ export interface TelegramMenuActionRuntimeDeps<TContext, TModel extends MenuMode
|
|
|
82
82
|
getActiveModel: (ctx: TContext) => TModel | undefined;
|
|
83
83
|
getThinkingLevel: () => ThinkingLevel;
|
|
84
84
|
getQueueItemCount?: () => number;
|
|
85
|
+
getPendingCancellationCount?: () => number;
|
|
85
86
|
buildStatusHtml: (ctx: TContext) => string;
|
|
86
87
|
storeModelMenuState: (state: TelegramModelMenuState<TModel>) => void;
|
|
87
88
|
isIdle: (ctx: TContext) => boolean;
|
|
@@ -215,7 +215,7 @@ export async function handleTelegramMenuCallbackRuntime(query, ctx, deps) {
|
|
|
215
215
|
deps.updateStatus(ctx);
|
|
216
216
|
},
|
|
217
217
|
getCurrentThinkingLevel: deps.getThinkingLevel,
|
|
218
|
-
|
|
218
|
+
updateThinkingMenuMessage: () => deps.updateThinkingMenuMessage(state, ctx),
|
|
219
219
|
answerCallbackQuery: deps.answerCallbackQuery,
|
|
220
220
|
isVoiceReplyActive: deps.isVoiceReplyActive,
|
|
221
221
|
}),
|
|
@@ -267,6 +267,7 @@ export function createTelegramMenuActionRuntimeWithStateBuilder(deps) {
|
|
|
267
267
|
getActiveModel: deps.getActiveModel,
|
|
268
268
|
getThinkingLevel: deps.getThinkingLevel,
|
|
269
269
|
getQueueItemCount: deps.getQueueItemCount,
|
|
270
|
+
getPendingCancellationCount: deps.getPendingCancellationCount,
|
|
270
271
|
buildStatusHtml: deps.buildStatusHtml,
|
|
271
272
|
storeModelMenuState: deps.storeModelMenuState,
|
|
272
273
|
isIdle: deps.isIdle,
|
|
@@ -281,7 +282,7 @@ export function createTelegramMenuActionRuntime(deps) {
|
|
|
281
282
|
return {
|
|
282
283
|
updateModelMenuMessage: (state, ctx) => updateTelegramModelMenuMessage(state, deps.getActiveModel(ctx), deps),
|
|
283
284
|
updateThinkingMenuMessage: (state, ctx) => updateTelegramThinkingMenuMessage(state, deps.getActiveModel(ctx), deps.getThinkingLevel(), deps),
|
|
284
|
-
updateStatusMessage: (state, ctx) => updateTelegramStatusMessage(state, deps.buildStatusHtml(ctx), deps.getActiveModel(ctx), deps.getThinkingLevel(), deps, deps.getQueueItemCount?.() ?? 0, deps.sectionRegistry, deps.isVoiceReplyActive?.()),
|
|
285
|
+
updateStatusMessage: (state, ctx) => updateTelegramStatusMessage(state, deps.buildStatusHtml(ctx), deps.getActiveModel(ctx), deps.getThinkingLevel(), deps, deps.getQueueItemCount?.() ?? 0, deps.sectionRegistry, deps.isVoiceReplyActive?.(), deps.getPendingCancellationCount?.() ?? 0),
|
|
285
286
|
sendStatusMessage: (chatId, replyToMessageId, ctx, threadId) => openTelegramStatusMenu({
|
|
286
287
|
isIdle: () => deps.isIdle(ctx),
|
|
287
288
|
sendBusyMessage: async () => {
|
|
@@ -292,7 +293,7 @@ export function createTelegramMenuActionRuntime(deps) {
|
|
|
292
293
|
getActiveModel: () => deps.getActiveModel(ctx),
|
|
293
294
|
getThinkingLevel: deps.getThinkingLevel,
|
|
294
295
|
getQueueItemCount: deps.getQueueItemCount,
|
|
295
|
-
sendStatusMenu: (state, statusHtml, activeModel, thinkingLevel, queueItemCount) => sendTelegramStatusMessage(state, statusHtml, activeModel, thinkingLevel, deps, queueItemCount, deps.sectionRegistry, deps.isVoiceReplyActive?.()),
|
|
296
|
+
sendStatusMenu: (state, statusHtml, activeModel, thinkingLevel, queueItemCount) => sendTelegramStatusMessage(state, statusHtml, activeModel, thinkingLevel, deps, queueItemCount, deps.sectionRegistry, deps.isVoiceReplyActive?.(), deps.getPendingCancellationCount?.() ?? 0),
|
|
296
297
|
storeModelMenuState: deps.storeModelMenuState,
|
|
297
298
|
}),
|
|
298
299
|
openModelMenu: (chatId, replyToMessageId, ctx, threadId) => openTelegramModelMenu({
|
|
@@ -8,7 +8,6 @@ import type { ExtensionAPI } from "./pi.ts";
|
|
|
8
8
|
import { type TelegramTarget } from "./target.ts";
|
|
9
9
|
export declare const TELEGRAM_OUTBOUND_ATTACHMENT_DEFAULT_MAX_BYTES: number;
|
|
10
10
|
export declare function getTelegramOutboundAttachmentByteLimitFromEnv(env: NodeJS.ProcessEnv, names: string[], defaultValue?: number): number;
|
|
11
|
-
export declare const TELEGRAM_OUTBOUND_ATTACHMENT_MAX_BYTES: number;
|
|
12
11
|
export interface TelegramOutboundAttachmentToolResult {
|
|
13
12
|
content: Array<{
|
|
14
13
|
type: "text";
|
|
@@ -23,7 +23,7 @@ export function getTelegramOutboundAttachmentByteLimitFromEnv(env, names, defaul
|
|
|
23
23
|
}
|
|
24
24
|
return defaultValue;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
const TELEGRAM_OUTBOUND_ATTACHMENT_MAX_BYTES = getTelegramOutboundAttachmentByteLimitFromEnv(process.env, [
|
|
27
27
|
"PI_TELEGRAM_OUTBOUND_ATTACHMENT_MAX_BYTES",
|
|
28
28
|
"TELEGRAM_MAX_ATTACHMENT_SIZE_BYTES",
|
|
29
29
|
]);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Owns assistant-authored telegram_button extraction, button action storage, callback handling, and prompt-turn construction
|
|
5
5
|
*/
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
|
-
import { parseTelegramActionPayloadRows, parseTelegramButtonPayloadRows, replaceTelegramButtonFences, replaceTopLevelHtmlComments, } from "./outbound-markup.js";
|
|
7
|
+
import { getTelegramActionString as getTelegramButtonString, parseTelegramActionPayloadRows, parseTelegramButtonPayloadRows, replaceTelegramButtonFences, replaceTopLevelHtmlComments, } from "./outbound-markup.js";
|
|
8
8
|
import { truncateTelegramQueueSummary, } from "./queue.js";
|
|
9
9
|
const TELEGRAM_BUTTON_CALLBACK_PREFIX = "tgbtn";
|
|
10
10
|
const TELEGRAM_BUTTON_ACTION_TTL_MS = 24 * 60 * 60 * 1000;
|
|
@@ -14,13 +14,6 @@ function nowMs() {
|
|
|
14
14
|
function normalizeMarkdownAfterButtonExtraction(markdown) {
|
|
15
15
|
return markdown.replace(/\n{3,}/g, "\n\n").trim();
|
|
16
16
|
}
|
|
17
|
-
function getTelegramButtonString(payload, key) {
|
|
18
|
-
const value = payload[key];
|
|
19
|
-
if (typeof value !== "string")
|
|
20
|
-
return undefined;
|
|
21
|
-
const trimmed = value.trim();
|
|
22
|
-
return trimmed || undefined;
|
|
23
|
-
}
|
|
24
17
|
function parseTelegramButtonAction(payload) {
|
|
25
18
|
const value = getTelegramButtonString(payload, "value");
|
|
26
19
|
const explicitLabel = getTelegramButtonString(payload, "label");
|
|
@@ -15,12 +15,6 @@ export declare function collectTopLevelHtmlComments(markdown: string): {
|
|
|
15
15
|
};
|
|
16
16
|
export declare function replaceTelegramButtonFences(markdown: string, replace: (payload: string, closed: boolean) => string): string;
|
|
17
17
|
export declare function replaceTopLevelHtmlComments(markdown: string, replacer: (comment: TelegramTopLevelHtmlComment) => string): string;
|
|
18
|
-
export declare function findTopLevelOpenOrPartialHtmlCommentIndex(markdown: string): number;
|
|
19
|
-
export declare function parseTopLevelTelegramComment(comment: TelegramTopLevelHtmlComment, command: string): {
|
|
20
|
-
head: string;
|
|
21
|
-
body?: string;
|
|
22
|
-
} | undefined;
|
|
23
|
-
export declare function parseTelegramActionPayload(comment: TelegramTopLevelHtmlComment, command: string): Record<string, unknown> | undefined;
|
|
24
18
|
export declare function parseTelegramButtonPayloadRows(source: string): Record<string, unknown>[][] | undefined;
|
|
25
19
|
export declare function parseTelegramActionPayloadRows(comment: TelegramTopLevelHtmlComment, command: string): Record<string, unknown>[][] | undefined;
|
|
26
20
|
export declare function normalizeMarkdownAfterVoiceExtraction(markdown: string): string;
|
|
@@ -39,4 +33,5 @@ export interface TelegramVoiceReplyPlan {
|
|
|
39
33
|
lang?: string;
|
|
40
34
|
rate?: string;
|
|
41
35
|
}
|
|
36
|
+
export declare function getTelegramActionString(payload: Record<string, unknown>, key: string): string | undefined;
|
|
42
37
|
export declare function planTelegramVoiceReply(markdown: string): TelegramVoiceReplyPlan;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Zones: telegram outbound, assistant markup
|
|
4
4
|
* Owns top-level assistant action comment extraction, attribute parsing, and markup stripping shared by voice and outbound delivery
|
|
5
5
|
*/
|
|
6
|
+
import { isWireRecord as isTelegramActionPayload } from "./wire.js";
|
|
6
7
|
function getMarkdownLineEnd(markdown, offset) {
|
|
7
8
|
const newlineIndex = markdown.indexOf("\n", offset);
|
|
8
9
|
return newlineIndex === -1 ? markdown.length : newlineIndex + 1;
|
|
@@ -117,7 +118,7 @@ export function replaceTopLevelHtmlComments(markdown, replacer) {
|
|
|
117
118
|
}
|
|
118
119
|
return result + markdown.slice(offset);
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
+
function findTopLevelOpenOrPartialHtmlCommentIndex(markdown) {
|
|
121
122
|
const { openCommentStart } = collectTopLevelHtmlComments(markdown);
|
|
122
123
|
if (openCommentStart !== undefined)
|
|
123
124
|
return openCommentStart;
|
|
@@ -146,21 +147,6 @@ export function findTopLevelOpenOrPartialHtmlCommentIndex(markdown) {
|
|
|
146
147
|
}
|
|
147
148
|
return -1;
|
|
148
149
|
}
|
|
149
|
-
export function parseTopLevelTelegramComment(comment, command) {
|
|
150
|
-
let normalizedContent = comment.content.replace(/^\s+/, "");
|
|
151
|
-
normalizedContent = normalizedContent.replace(/^!/, "");
|
|
152
|
-
const [rawHead = "", ...bodyLines] = normalizedContent.split(/\r?\n/);
|
|
153
|
-
let head = rawHead.trimStart();
|
|
154
|
-
if (!head.startsWith(command))
|
|
155
|
-
return undefined;
|
|
156
|
-
const nextChar = head[command.length];
|
|
157
|
-
if (nextChar !== undefined && !/\s|:/.test(nextChar))
|
|
158
|
-
return undefined;
|
|
159
|
-
return {
|
|
160
|
-
head: head.slice(command.length),
|
|
161
|
-
...(bodyLines.length > 0 ? { body: bodyLines.join("\n") } : {}),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
150
|
function parseTolerantTelegramAttributes(source, names) {
|
|
165
151
|
const attributes = {};
|
|
166
152
|
const namePattern = names.join("|");
|
|
@@ -172,9 +158,6 @@ function parseTolerantTelegramAttributes(source, names) {
|
|
|
172
158
|
}
|
|
173
159
|
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
|
174
160
|
}
|
|
175
|
-
function isTelegramActionPayload(value) {
|
|
176
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
177
|
-
}
|
|
178
161
|
function removeTelegramJsonTrailingCommas(source) {
|
|
179
162
|
let normalized = "";
|
|
180
163
|
let inString = false;
|
|
@@ -224,7 +207,7 @@ function parseTelegramJsonObjectCandidate(source) {
|
|
|
224
207
|
function looksLikeTelegramNamedJsonObject(source, offset) {
|
|
225
208
|
return /^\{\s*"(?:[^"\\]|\\.)*"\s*:/u.test(source.slice(offset));
|
|
226
209
|
}
|
|
227
|
-
|
|
210
|
+
function parseTelegramActionPayload(comment, command) {
|
|
228
211
|
let content = comment.content.replace(/^\s+/, "").replace(/^!/, "");
|
|
229
212
|
if (!content.startsWith(command))
|
|
230
213
|
return undefined;
|
|
@@ -628,7 +611,7 @@ export function stripTelegramCommentMarkupForDelivery(markdown) {
|
|
|
628
611
|
export function stripTelegramVoiceMarkupForPreview(markdown) {
|
|
629
612
|
return stripTelegramCommentMarkupForPreview(markdown);
|
|
630
613
|
}
|
|
631
|
-
function getTelegramActionString(payload, key) {
|
|
614
|
+
export function getTelegramActionString(payload, key) {
|
|
632
615
|
const value = payload[key];
|
|
633
616
|
if (typeof value !== "string")
|
|
634
617
|
return undefined;
|
|
@@ -68,7 +68,6 @@ export interface TelegramOutboundHandlerRegistry {
|
|
|
68
68
|
handlers: Map<string, TelegramOutboundProgrammaticHandler[]>;
|
|
69
69
|
}
|
|
70
70
|
export declare function registerTelegramOutboundHandler(kind: string, handler: TelegramOutboundProgrammaticHandler): () => void;
|
|
71
|
-
export declare function getTelegramOutboundProgrammaticHandlers(kind: string): TelegramOutboundProgrammaticHandler[];
|
|
72
71
|
export interface TelegramOutboundTextReplyRuntimeDeps<TReplyMarkup = unknown> {
|
|
73
72
|
execCommand: TelegramVoiceReplySenderDeps["execCommand"];
|
|
74
73
|
getHandlers?: () => TelegramOutboundHandlerConfig[] | undefined;
|
|
@@ -117,13 +116,6 @@ export declare function generateTelegramVoiceReplyFile(text: string, options: {
|
|
|
117
116
|
cwd?: string;
|
|
118
117
|
execCommand: TelegramVoiceReplySenderDeps["execCommand"];
|
|
119
118
|
}): Promise<string | undefined>;
|
|
120
|
-
export declare function transformTelegramOutboundText(text: string, options: {
|
|
121
|
-
handlers?: TelegramOutboundHandlerConfig[];
|
|
122
|
-
cwd?: string;
|
|
123
|
-
execCommand: TelegramVoiceReplySenderDeps["execCommand"];
|
|
124
|
-
recordRuntimeEvent?: TelegramVoiceReplySenderDeps["recordRuntimeEvent"];
|
|
125
|
-
}): Promise<string>;
|
|
126
|
-
export declare function transformTelegramOutboundTextReply<TReplyMarkup = unknown>(text: string, options: TelegramOutboundTextTransformOptions<TReplyMarkup>): Promise<TelegramOutboundTextTransformResult<TReplyMarkup>>;
|
|
127
119
|
export declare function createTelegramOutboundTextReplyRuntime<TReplyMarkup = unknown>(deps: TelegramOutboundTextReplyRuntimeDeps<TReplyMarkup>): Pick<TelegramOutboundTextReplyRuntimeDeps<TReplyMarkup>, "sendTextReply" | "sendMarkdownReply">;
|
|
128
120
|
export declare function createTelegramOutboundTextPreviewRuntime<TReplyMarkup = unknown>(deps: TelegramOutboundTextPreviewRuntimeDeps<TReplyMarkup>): {
|
|
129
121
|
finalizeMarkdownPreview: TelegramPreparedPreviewDelivery<TReplyMarkup>["finalizeMarkdownPreview"];
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { mkdir } from "node:fs/promises";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
-
import {
|
|
9
|
+
import { resolveTelegramAttachmentsDir } from "./paths.js";
|
|
10
10
|
import * as Replies from "./replies.js";
|
|
11
11
|
import { isTelegramApiCommitUnknownError } from "./telegram-api.js";
|
|
12
12
|
import { planTelegramButtonReply, } from "./outbound-buttons.js";
|
|
@@ -57,7 +57,7 @@ export function registerTelegramOutboundHandler(kind, handler) {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
function getTelegramOutboundProgrammaticHandlers(kind) {
|
|
61
61
|
const registry = getOrCreateOutboundHandlerRegistry();
|
|
62
62
|
return [...(registry.handlers.get(kind) ?? [])];
|
|
63
63
|
}
|
|
@@ -183,7 +183,7 @@ function getVoiceReplyTemplateValues(text, options) {
|
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
function getDefaultTelegramVoiceTempDir() {
|
|
186
|
-
return
|
|
186
|
+
return resolveTelegramAttachmentsDir();
|
|
187
187
|
}
|
|
188
188
|
async function generateTelegramVoiceReplyFileWithHandler(text, options) {
|
|
189
189
|
await mkdir(options.tempDir, { recursive: true });
|
|
@@ -275,7 +275,7 @@ async function transformTelegramOutboundTextWithHandler(text, options) {
|
|
|
275
275
|
});
|
|
276
276
|
return result.stdout.trim() || text;
|
|
277
277
|
}
|
|
278
|
-
|
|
278
|
+
async function transformTelegramOutboundText(text, options) {
|
|
279
279
|
let transformed = text;
|
|
280
280
|
for (const handler of findTelegramOutboundHandlers(options.handlers, "text")) {
|
|
281
281
|
try {
|
|
@@ -316,7 +316,7 @@ async function transformTelegramOutboundReplyMarkup(replyMarkup, options) {
|
|
|
316
316
|
}
|
|
317
317
|
return { ...replyMarkup, inline_keyboard: translatedRows };
|
|
318
318
|
}
|
|
319
|
-
|
|
319
|
+
async function transformTelegramOutboundTextReply(text, options) {
|
|
320
320
|
const transformOptions = {
|
|
321
321
|
handlers: options.handlers,
|
|
322
322
|
cwd: options.cwd,
|
|
@@ -22,29 +22,72 @@ export declare function resolveAgentDir(input?: TelegramAgentDirResolutionInput)
|
|
|
22
22
|
export declare function requireTelegramStoragePathReference(path: string, expectedPath: string): string;
|
|
23
23
|
/** Telegram bridge configuration file (<agentDir>/telegram.json). */
|
|
24
24
|
export declare function resolveTelegramConfigPath(): string;
|
|
25
|
-
/** Telegram bridge temporary directory (<agentDir>/tmp/telegram). */
|
|
25
|
+
/** Telegram bridge temporary directory (<agentDir>/tmp/pi-telegram); releases before 0.52.0 used `tmp/telegram`. */
|
|
26
26
|
export declare function resolveTelegramTempDir(agentDir?: string): string;
|
|
27
|
-
/**
|
|
27
|
+
/** Consolidated-root service artifacts (transaction guards, staging and IPC), never session custody. */
|
|
28
|
+
export declare function resolveTelegramRuntimeDir(agentDir?: string): string;
|
|
29
|
+
/** Rotated shared runtime event segments, outside the persistent root-file census. */
|
|
30
|
+
export declare function resolveTelegramRuntimeLogsDir(agentDir?: string): string;
|
|
31
|
+
/** Consolidated runtime state for every logical profile (`tmp/pi-telegram/state.json`). */
|
|
32
|
+
export declare function resolveTelegramStatePath(agentDir?: string): string;
|
|
33
|
+
/** Flat attachment scratch directory (<agentDir>/tmp/pi-telegram/attachments). */
|
|
34
|
+
export declare function resolveTelegramAttachmentsDir(agentDir?: string): string;
|
|
35
|
+
/** Read-only pre-0.52.0 ownership file, consulted only to refuse a second poller beside a live older leader. */
|
|
36
|
+
export declare function resolveLegacyTelegramOwnersPath(agentDir?: string): string;
|
|
37
|
+
/** Telegram transport ownership store (<agentDir>/tmp/pi-telegram/owners.json). */
|
|
28
38
|
export declare function resolveTelegramOwnersPath(): string;
|
|
29
39
|
export declare function getTelegramProfilePathSuffix(profileName?: string): string;
|
|
30
40
|
export declare function resolveTelegramProfileTempFilePath(baseName: string, extension: string, agentDir?: string, profileName?: string): string;
|
|
31
|
-
export declare function getTelegramDiagnosticsDisplayPaths(
|
|
41
|
+
export declare function getTelegramDiagnosticsDisplayPaths(_profileName?: string): {
|
|
32
42
|
state: string;
|
|
33
43
|
logs: string;
|
|
34
44
|
};
|
|
35
|
-
/** Durable Workspace admission ledger (<agentDir>/tmp/telegram/workspace-admission[.<profile>].json). */
|
|
45
|
+
/** Durable Workspace admission ledger (<agentDir>/tmp/pi-telegram/workspace-admission[.<profile>].json). */
|
|
36
46
|
export declare function resolveTelegramWorkspaceAdmissionPath(agentDir?: string, profileName?: string): string;
|
|
37
47
|
/** Profile-only callback shape; binds storage to the configured agent directory. */
|
|
38
48
|
export declare function resolveTelegramWorkspaceAdmissionPathForProfile(profileName?: string): string;
|
|
49
|
+
/** Consolidated non-session service journal (`journals/<kind>.<profile sha256>.json`) and its runtime namespace. */
|
|
50
|
+
export declare function resolveTelegramServiceJournalStorage(kind: "thread-cleanup" | "channel-posts", agentDir?: string, profileName?: string): {
|
|
51
|
+
path: string;
|
|
52
|
+
runtimeDir: string;
|
|
53
|
+
};
|
|
54
|
+
/** Bind one non-session journal to its exact colocated-root service namespace, never a format fallback. */
|
|
55
|
+
export declare function getTelegramJournalPublicationPaths(path: string, runtimeDir?: string): {
|
|
56
|
+
transactionPath: string;
|
|
57
|
+
temporaryBasePath: string;
|
|
58
|
+
};
|
|
39
59
|
/** Durable inactive Thread cleanup work-set journal. */
|
|
40
60
|
export declare function resolveTelegramThreadCleanupWorkPath(agentDir?: string, profileName?: string): string;
|
|
41
61
|
/** Durable agent-authored channel post journal. */
|
|
42
62
|
export declare function resolveTelegramChannelPostJournalPath(agentDir?: string, profileName?: string): string;
|
|
43
|
-
/** Durable inbound update journal (<agentDir>/tmp/telegram/inbox[.<profile>].json). */
|
|
63
|
+
/** Durable inbound update journal (<agentDir>/tmp/pi-telegram/inbox[.<profile>].json). */
|
|
44
64
|
export declare function resolveTelegramUpdateJournalPath(agentDir?: string, profileName?: string): string;
|
|
45
65
|
/** Profile-only callback shape; binds storage to the configured agent directory. */
|
|
46
66
|
export declare function resolveTelegramUpdateJournalPathForProfile(profileName?: string): string;
|
|
47
67
|
/** Durable follower delivery journal, isolated by stable recipient binding. */
|
|
48
68
|
export declare function resolveTelegramFollowerJournalPath(recipientBindingKey: string, agentDir?: string, profileName?: string): string;
|
|
49
|
-
/**
|
|
50
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Directory name for a session id. Lowercase letters, digits, `_`, `-` and inner `.` stay verbatim, so every real
|
|
71
|
+
* (UUID-shaped) id is unchanged; any other UTF-8 byte is percent-encoded. Uppercase is encoded so case-insensitive
|
|
72
|
+
* filesystems never merge two sessions; a leading or trailing dot and Windows reserved names are encoded so the name
|
|
73
|
+
* can never be `.`/`..`, hidden, or a device. The encoding is reversible; an empty or over-long result is refused.
|
|
74
|
+
*/
|
|
75
|
+
export declare function encodeTelegramSessionDirectoryName(sessionId: string): string | undefined;
|
|
76
|
+
/** Inverse of `encodeTelegramSessionDirectoryName`; undefined unless the name is exactly canonical. */
|
|
77
|
+
export declare function decodeTelegramSessionDirectoryName(name: string): string | undefined;
|
|
78
|
+
/** Root of every session folder (<agentDir>/tmp/pi-telegram/sessions). */
|
|
79
|
+
export declare function resolveTelegramSessionsDir(agentDir?: string): string;
|
|
80
|
+
/** One session's folder (<agentDir>/tmp/pi-telegram/sessions/<session id>). */
|
|
81
|
+
export declare function resolveTelegramSessionDir(sessionId: string, agentDir?: string): string;
|
|
82
|
+
/** Hash naming one recipient incarnation inside its session folder; unchanged from the former follower inbox. */
|
|
83
|
+
export declare function getTelegramRecipientJournalHash(recipientBindingKey: string): string;
|
|
84
|
+
/** Durable per-session journal (`sessions/<session id>/journal.<hash>[.<profile>].json`); the name never reveals a role. */
|
|
85
|
+
export declare function resolveTelegramSessionJournalPath(sessionId: string, recipientBindingKey: string, agentDir?: string, profileName?: string): string;
|
|
86
|
+
/** Leader polling journal hosted by the session that first led (`sessions/<id>/inbox[.<profile>].json`); owners.json names it. */
|
|
87
|
+
export declare function resolveTelegramSessionPollingJournalPath(sessionId: string, agentDir?: string, profileName?: string): string;
|
|
88
|
+
/** Accept only a canonical `sessions/<id>/inbox[.<profile>].json` beneath this agent's runtime. */
|
|
89
|
+
export declare function isTelegramSessionPollingJournalPath(path: string, agentDir?: string): boolean;
|
|
90
|
+
/** Runtime event log (<agentDir>/tmp/pi-telegram/logs.jsonl). */
|
|
91
|
+
export declare function resolveTelegramRuntimeLogPath(agentDir?: string): string;
|
|
92
|
+
/** Bounded previous shared log segment below `logs/`. */
|
|
93
|
+
export declare function resolveTelegramPreviousSharedRuntimeLogPath(agentDir?: string): string;
|