@llblab/pi-telegram 0.24.11 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -2
- package/BACKLOG.md +15 -1
- package/CHANGELOG.md +9 -1
- package/README.md +5 -4
- package/docs/activity.md +9 -7
- package/docs/architecture.md +3 -1
- package/docs/multi-instance-bus.md +11 -8
- package/docs/outbound.md +23 -1
- package/docs/public-api.md +4 -2
- package/docs/sections.md +4 -3
- package/docs/ui-style.md +2 -0
- package/index.ts +35 -1
- package/lib/activity-verbosity.ts +494 -0
- package/lib/bindings.ts +13 -2
- package/lib/config.ts +65 -17
- package/lib/menu-settings.ts +111 -45
- package/lib/queue.ts +4 -0
- package/lib/telegram-api.ts +32 -1
- package/package.json +1 -1
package/lib/config.ts
CHANGED
|
@@ -44,7 +44,6 @@ export interface TelegramOutboundHandlerConfig extends CommandTemplateObjectConf
|
|
|
44
44
|
export type TelegramTimeMode = "hidden" | "always" | "interval";
|
|
45
45
|
|
|
46
46
|
export interface TelegramTimeConfig {
|
|
47
|
-
injectionMode?: TelegramTimeMode;
|
|
48
47
|
interval?: number;
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -55,6 +54,7 @@ export interface ResolvedTelegramTimeConfig {
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
export type TelegramAssistantRenderingMode = "rich" | "html";
|
|
57
|
+
export type TelegramActivityVerbosity = "quiet" | "verbose";
|
|
58
58
|
|
|
59
59
|
export interface TelegramConfig {
|
|
60
60
|
/** @deprecated persisted identity belongs in profiles.default; retained for effective/legacy views */
|
|
@@ -74,6 +74,10 @@ export interface TelegramConfig {
|
|
|
74
74
|
draftPreviews?: boolean;
|
|
75
75
|
rendering?: TelegramAssistantRenderingMode;
|
|
76
76
|
proactivePush?: boolean;
|
|
77
|
+
activity?: TelegramActivityVerbosity;
|
|
78
|
+
timeInjection?: TelegramTimeMode;
|
|
79
|
+
/** @deprecated use activity */
|
|
80
|
+
activityVerbosity?: TelegramActivityVerbosity;
|
|
77
81
|
};
|
|
78
82
|
/** @deprecated use assistant.draftPreviews */
|
|
79
83
|
draftPreviews?: boolean;
|
|
@@ -678,7 +682,7 @@ export function createTelegramProactivePushSetter(
|
|
|
678
682
|
return async (enabled) => {
|
|
679
683
|
await loadLatestTelegramConfig(configStore);
|
|
680
684
|
const current = configStore.get();
|
|
681
|
-
const config = {
|
|
685
|
+
const config: TelegramConfig = {
|
|
682
686
|
...current,
|
|
683
687
|
assistant: { ...current.assistant, proactivePush: enabled },
|
|
684
688
|
};
|
|
@@ -746,6 +750,40 @@ export function createTelegramAssistantRenderingModeSetter(
|
|
|
746
750
|
};
|
|
747
751
|
}
|
|
748
752
|
|
|
753
|
+
export function createTelegramActivityVerbosityGetter(
|
|
754
|
+
configStore: Pick<TelegramConfigStore, "get">,
|
|
755
|
+
): () => TelegramActivityVerbosity {
|
|
756
|
+
return () => {
|
|
757
|
+
const assistant = configStore.get().assistant;
|
|
758
|
+
if (assistant?.activity !== undefined) {
|
|
759
|
+
return assistant.activity === "verbose" ? "verbose" : "quiet";
|
|
760
|
+
}
|
|
761
|
+
return assistant?.activityVerbosity === "verbose" ? "verbose" : "quiet";
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export function createTelegramActivityVerbositySetter(
|
|
766
|
+
configStore: TelegramMutableConfigStore,
|
|
767
|
+
): (verbosity: TelegramActivityVerbosity) => Promise<void> {
|
|
768
|
+
return async (verbosity) => {
|
|
769
|
+
await loadLatestTelegramConfig(configStore);
|
|
770
|
+
const current = configStore.get();
|
|
771
|
+
const {
|
|
772
|
+
activityVerbosity: _legacyActivityVerbosity,
|
|
773
|
+
...assistant
|
|
774
|
+
} = current.assistant ?? {};
|
|
775
|
+
const config = {
|
|
776
|
+
...current,
|
|
777
|
+
assistant: {
|
|
778
|
+
...assistant,
|
|
779
|
+
activity: verbosity,
|
|
780
|
+
},
|
|
781
|
+
};
|
|
782
|
+
configStore.set(config);
|
|
783
|
+
await configStore.persist(config);
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
|
|
749
787
|
export function createTelegramVoiceReplyModeGetter(
|
|
750
788
|
configStore: Pick<TelegramConfigStore, "get">,
|
|
751
789
|
): () => "hidden" | "mirror" | "always" {
|
|
@@ -796,10 +834,11 @@ function getSystemTimezone(): string {
|
|
|
796
834
|
|
|
797
835
|
export function resolveTelegramTimeConfig(
|
|
798
836
|
raw: TelegramTimeConfig | undefined,
|
|
837
|
+
timeInjection: TelegramTimeMode | undefined = undefined,
|
|
799
838
|
): ResolvedTelegramTimeConfig {
|
|
800
839
|
const injectionMode: TelegramTimeMode =
|
|
801
|
-
|
|
802
|
-
?
|
|
840
|
+
timeInjection === "always" || timeInjection === "interval"
|
|
841
|
+
? timeInjection
|
|
803
842
|
: "hidden";
|
|
804
843
|
const interval =
|
|
805
844
|
typeof raw?.interval === "number" && raw.interval > 0
|
|
@@ -812,13 +851,25 @@ export function resolveTelegramTimeConfig(
|
|
|
812
851
|
export function createTelegramTimeConfigGetter(
|
|
813
852
|
configStore: Pick<TelegramConfigStore, "get">,
|
|
814
853
|
): () => ResolvedTelegramTimeConfig {
|
|
815
|
-
return () =>
|
|
854
|
+
return () => {
|
|
855
|
+
const config = configStore.get();
|
|
856
|
+
return resolveTelegramTimeConfig(
|
|
857
|
+
config.time,
|
|
858
|
+
config.assistant?.timeInjection,
|
|
859
|
+
);
|
|
860
|
+
};
|
|
816
861
|
}
|
|
817
862
|
|
|
818
863
|
export function createTelegramTimeInjectionModeGetter(
|
|
819
864
|
configStore: Pick<TelegramConfigStore, "get">,
|
|
820
865
|
): () => TelegramTimeMode {
|
|
821
|
-
return () =>
|
|
866
|
+
return () => {
|
|
867
|
+
const config = configStore.get();
|
|
868
|
+
return resolveTelegramTimeConfig(
|
|
869
|
+
config.time,
|
|
870
|
+
config.assistant?.timeInjection,
|
|
871
|
+
).injectionMode;
|
|
872
|
+
};
|
|
822
873
|
}
|
|
823
874
|
|
|
824
875
|
export function createTelegramTimeInjectionModeSetter(
|
|
@@ -827,19 +878,12 @@ export function createTelegramTimeInjectionModeSetter(
|
|
|
827
878
|
return async (injectionMode) => {
|
|
828
879
|
await loadLatestTelegramConfig(configStore);
|
|
829
880
|
const current = configStore.get();
|
|
830
|
-
if (injectionMode === "hidden") {
|
|
831
|
-
const { injectionMode: _injectionMode, ...remainingTime } =
|
|
832
|
-
current.time ?? {};
|
|
833
|
-
const next = { ...current };
|
|
834
|
-
if (Object.keys(remainingTime).length > 0) next.time = remainingTime;
|
|
835
|
-
else delete next.time;
|
|
836
|
-
configStore.set(next);
|
|
837
|
-
await configStore.persist(next);
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
881
|
const next = {
|
|
841
882
|
...current,
|
|
842
|
-
|
|
883
|
+
assistant: {
|
|
884
|
+
...(current.assistant ?? {}),
|
|
885
|
+
timeInjection: injectionMode,
|
|
886
|
+
},
|
|
843
887
|
};
|
|
844
888
|
configStore.set(next);
|
|
845
889
|
await configStore.persist(next);
|
|
@@ -919,6 +963,10 @@ export function createTelegramConfigControls(
|
|
|
919
963
|
createTelegramAssistantRenderingModeGetter(configStore),
|
|
920
964
|
setAssistantRenderingMode:
|
|
921
965
|
createTelegramAssistantRenderingModeSetter(configStore),
|
|
966
|
+
getActivityVerbosity:
|
|
967
|
+
createTelegramActivityVerbosityGetter(configStore),
|
|
968
|
+
setActivityVerbosity:
|
|
969
|
+
createTelegramActivityVerbositySetter(configStore),
|
|
922
970
|
getVoiceReplyMode: createTelegramVoiceReplyModeGetter(configStore),
|
|
923
971
|
isVoiceReplyModeConfigured:
|
|
924
972
|
createTelegramVoiceReplyModeConfiguredChecker(configStore),
|
package/lib/menu-settings.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
|
+
TelegramActivityVerbosity,
|
|
8
9
|
TelegramAssistantRenderingMode,
|
|
9
10
|
TelegramTimeMode,
|
|
10
11
|
} from "./config.ts";
|
|
@@ -23,6 +24,7 @@ export interface TelegramSettingsStateDeps {
|
|
|
23
24
|
isProactivePushEnabled: () => boolean;
|
|
24
25
|
areDraftPreviewsEnabled: () => boolean;
|
|
25
26
|
getAssistantRenderingMode: () => TelegramAssistantRenderingMode;
|
|
27
|
+
getActivityVerbosity: () => TelegramActivityVerbosity;
|
|
26
28
|
getTimeInjectionMode: () => TelegramTimeMode;
|
|
27
29
|
getVoiceReplyMode: () => TelegramVoiceReplyMode;
|
|
28
30
|
isVoiceReplyModeConfigured: () => boolean;
|
|
@@ -35,6 +37,9 @@ export interface TelegramSettingsMutationDeps extends TelegramSettingsStateDeps
|
|
|
35
37
|
setAssistantRenderingMode: (
|
|
36
38
|
mode: TelegramAssistantRenderingMode,
|
|
37
39
|
) => Promise<void>;
|
|
40
|
+
setActivityVerbosity: (
|
|
41
|
+
verbosity: TelegramActivityVerbosity,
|
|
42
|
+
) => Promise<void>;
|
|
38
43
|
setVoiceReplyMode: (
|
|
39
44
|
mode: TelegramVoiceReplyMode | undefined,
|
|
40
45
|
) => Promise<void>;
|
|
@@ -138,6 +143,8 @@ export const PROACTIVE_PUSH_SETTINGS_TITLE = "<b>📌 Proactive push:</b>";
|
|
|
138
143
|
export const DRAFT_PREVIEWS_SETTINGS_TITLE = "<b>📝 Draft previews:</b>";
|
|
139
144
|
export const ASSISTANT_RENDERING_SETTINGS_TITLE =
|
|
140
145
|
"<b>🧾 Assistant rendering:</b>";
|
|
146
|
+
export const ACTIVITY_VERBOSITY_SETTINGS_TITLE =
|
|
147
|
+
"<b>🔬 Activity:</b>";
|
|
141
148
|
export const TIME_INJECTION_MODE_SETTINGS_TITLE =
|
|
142
149
|
"<b>🕒 Time injection mode:</b>";
|
|
143
150
|
export const VOICE_REPLY_MODE_SETTINGS_TITLE = "<b>👄 Voice reply mode:</b>";
|
|
@@ -213,6 +220,19 @@ export function buildAssistantRenderingSettingsText(
|
|
|
213
220
|
].join("\n");
|
|
214
221
|
}
|
|
215
222
|
|
|
223
|
+
export function buildActivityVerbositySettingsText(
|
|
224
|
+
verbosity: TelegramActivityVerbosity,
|
|
225
|
+
): string {
|
|
226
|
+
return [
|
|
227
|
+
`${ACTIVITY_VERBOSITY_SETTINGS_TITLE} <code>${verbosity}</code>`,
|
|
228
|
+
"",
|
|
229
|
+
"Choose how much technical model activity Telegram shows.",
|
|
230
|
+
"",
|
|
231
|
+
"<code>-</code> <code>quiet</code> (default): show public assistant output without reasoning or tool traffic.",
|
|
232
|
+
"<code>-</code> <code>verbose</code>: add ephemeral available reasoning and durable collapsed tool details.",
|
|
233
|
+
].join("\n");
|
|
234
|
+
}
|
|
235
|
+
|
|
216
236
|
export function buildVoiceReplyModeSettingsText(
|
|
217
237
|
mode: TelegramVoiceReplyMode,
|
|
218
238
|
configured = true,
|
|
@@ -255,6 +275,7 @@ export function buildTelegramSettingsMenuReplyMarkup(
|
|
|
255
275
|
sectionRegistryOrVoiceReplyModeConfigured?: TelegramSectionRegistry | boolean,
|
|
256
276
|
voiceReplyModeConfigured = true,
|
|
257
277
|
automaticThreadCleanupEnabled = true,
|
|
278
|
+
activityVerbosity: TelegramActivityVerbosity = "quiet",
|
|
258
279
|
): TelegramSettingsMenuReplyMarkup {
|
|
259
280
|
const hasRenderingMode =
|
|
260
281
|
assistantRenderingModeOrVoiceReplyMode === "rich" ||
|
|
@@ -280,23 +301,17 @@ export function buildTelegramSettingsMenuReplyMarkup(
|
|
|
280
301
|
const rows: Array<Array<{ text: string; callback_data: string }>> = [
|
|
281
302
|
[{ text: "⬆️ Main menu", callback_data: "menu:back" }],
|
|
282
303
|
];
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
callback_data: "settings:open:automatic-thread-cleanup",
|
|
295
|
-
},
|
|
296
|
-
],
|
|
297
|
-
[
|
|
298
|
-
{
|
|
299
|
-
text: `👄 Voice reply: ${getTelegramSettingsStateValueLabel(
|
|
304
|
+
const settingsButtons: Array<{ text: string; callback_data: string }> = [
|
|
305
|
+
{
|
|
306
|
+
text: `📝 Draft previews: ${draftPreviewsEnabled ? "on" : "off"}`,
|
|
307
|
+
callback_data: "settings:open:draft-previews",
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
text: `🧾 Rendering: ${assistantRenderingMode}`,
|
|
311
|
+
callback_data: "settings:open:assistant-rendering",
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
text: `👄 Voice reply: ${getTelegramSettingsStateValueLabel(
|
|
300
315
|
getVoiceReplyModeLabel(
|
|
301
316
|
getVoiceReplyModeSetting(
|
|
302
317
|
voiceReplyMode,
|
|
@@ -304,34 +319,35 @@ export function buildTelegramSettingsMenuReplyMarkup(
|
|
|
304
319
|
),
|
|
305
320
|
),
|
|
306
321
|
)}`,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
{
|
|
330
|
-
text:
|
|
331
|
-
callback_data:
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
|
|
322
|
+
callback_data: "settings:open:voice-reply",
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
text: `🔬 Activity: ${activityVerbosity}`,
|
|
326
|
+
callback_data: "settings:open:activity-verbosity",
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
text: `📌 Proactive push: ${proactivePushEnabled ? "on" : "off"}`,
|
|
330
|
+
callback_data: "settings:open:proactive",
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
text: `🕒 Time injection: ${getTelegramSettingsStateValueLabel(timeInjectionMode)}`,
|
|
334
|
+
callback_data: "settings:open:time-injection",
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
text: `🧹 Thread cleanup: ${automaticThreadCleanupEnabled ? "on" : "off"}`,
|
|
338
|
+
callback_data: "settings:open:automatic-thread-cleanup",
|
|
339
|
+
},
|
|
340
|
+
];
|
|
341
|
+
if (sectionRegistry) {
|
|
342
|
+
const extensionRows = getTelegramExtensionSettingsRows(sectionRegistry);
|
|
343
|
+
settingsButtons.push(
|
|
344
|
+
...extensionRows.map((row) => ({
|
|
345
|
+
text: row.label,
|
|
346
|
+
callback_data: row.callback_data,
|
|
347
|
+
})),
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
rows.push(...settingsButtons.map((button) => [button]));
|
|
335
351
|
return { inline_keyboard: rows };
|
|
336
352
|
}
|
|
337
353
|
|
|
@@ -354,6 +370,7 @@ export async function openTelegramSettingsMenu<
|
|
|
354
370
|
sectionRegistry,
|
|
355
371
|
deps.isVoiceReplyModeConfigured(),
|
|
356
372
|
deps.isAutomaticThreadCleanupEnabled(),
|
|
373
|
+
deps.getActivityVerbosity(),
|
|
357
374
|
),
|
|
358
375
|
);
|
|
359
376
|
if (messageId === undefined) return;
|
|
@@ -439,6 +456,23 @@ export function buildAssistantRenderingSettingsReplyMarkup(
|
|
|
439
456
|
};
|
|
440
457
|
}
|
|
441
458
|
|
|
459
|
+
export function buildActivityVerbositySettingsReplyMarkup(
|
|
460
|
+
verbosity: TelegramActivityVerbosity,
|
|
461
|
+
): TelegramSettingsMenuReplyMarkup {
|
|
462
|
+
const values: TelegramActivityVerbosity[] = ["quiet", "verbose"];
|
|
463
|
+
return {
|
|
464
|
+
inline_keyboard: [
|
|
465
|
+
[{ text: "⬆️ Back", callback_data: "settings:list" }],
|
|
466
|
+
...values.map((value) => [
|
|
467
|
+
{
|
|
468
|
+
text: `${value === verbosity ? "🟢 " : ""}${value}`,
|
|
469
|
+
callback_data: `settings:set:activity-verbosity:${value}`,
|
|
470
|
+
},
|
|
471
|
+
]),
|
|
472
|
+
],
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
|
|
442
476
|
export function buildTimeInjectionModeSettingsReplyMarkup(
|
|
443
477
|
mode: TelegramTimeMode,
|
|
444
478
|
): TelegramSettingsMenuReplyMarkup {
|
|
@@ -490,6 +524,7 @@ export async function updateTelegramSettingsMenuMessage(
|
|
|
490
524
|
sectionRegistry,
|
|
491
525
|
deps.isVoiceReplyModeConfigured(),
|
|
492
526
|
deps.isAutomaticThreadCleanupEnabled(),
|
|
527
|
+
deps.getActivityVerbosity(),
|
|
493
528
|
),
|
|
494
529
|
);
|
|
495
530
|
}
|
|
@@ -534,6 +569,16 @@ export async function updateAssistantRenderingSettingsMessage(
|
|
|
534
569
|
);
|
|
535
570
|
}
|
|
536
571
|
|
|
572
|
+
export async function updateActivityVerbositySettingsMessage(
|
|
573
|
+
deps: TelegramSettingsMenuCallbackDeps,
|
|
574
|
+
): Promise<void> {
|
|
575
|
+
const verbosity = deps.getActivityVerbosity();
|
|
576
|
+
await deps.updateSettingsMessage(
|
|
577
|
+
buildActivityVerbositySettingsText(verbosity),
|
|
578
|
+
buildActivityVerbositySettingsReplyMarkup(verbosity),
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
|
|
537
582
|
export async function updateTimeInjectionModeSettingsMessage(
|
|
538
583
|
deps: TelegramSettingsMenuCallbackDeps,
|
|
539
584
|
): Promise<void> {
|
|
@@ -589,6 +634,11 @@ export async function handleTelegramSettingsMenuCallbackAction(
|
|
|
589
634
|
await deps.answerCallbackQuery(callbackQueryId);
|
|
590
635
|
return true;
|
|
591
636
|
}
|
|
637
|
+
if (data === "settings:open:activity-verbosity") {
|
|
638
|
+
await updateActivityVerbositySettingsMessage(deps);
|
|
639
|
+
await deps.answerCallbackQuery(callbackQueryId);
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
592
642
|
if (data === "settings:open:voice-reply") {
|
|
593
643
|
await updateVoiceReplyModeSettingsMessage(deps);
|
|
594
644
|
await deps.answerCallbackQuery(callbackQueryId);
|
|
@@ -660,6 +710,18 @@ export async function handleTelegramSettingsMenuCallbackAction(
|
|
|
660
710
|
return true;
|
|
661
711
|
}
|
|
662
712
|
}
|
|
713
|
+
if (data.startsWith("settings:set:activity-verbosity:")) {
|
|
714
|
+
const verbosity = data.slice("settings:set:activity-verbosity:".length);
|
|
715
|
+
if (verbosity === "quiet" || verbosity === "verbose") {
|
|
716
|
+
await deps.setActivityVerbosity(verbosity);
|
|
717
|
+
await updateActivityVerbositySettingsMessage(deps);
|
|
718
|
+
await deps.answerCallbackQuery(
|
|
719
|
+
callbackQueryId,
|
|
720
|
+
`Activity: ${verbosity}`,
|
|
721
|
+
);
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
663
725
|
if (
|
|
664
726
|
data === "settings:set:automatic-thread-cleanup:on" ||
|
|
665
727
|
data === "settings:set:automatic-thread-cleanup:off"
|
|
@@ -706,6 +768,7 @@ export function createTelegramSettingsMenuRuntime<
|
|
|
706
768
|
isProactivePushEnabled: deps.isProactivePushEnabled,
|
|
707
769
|
areDraftPreviewsEnabled: deps.areDraftPreviewsEnabled,
|
|
708
770
|
getAssistantRenderingMode: deps.getAssistantRenderingMode,
|
|
771
|
+
getActivityVerbosity: deps.getActivityVerbosity,
|
|
709
772
|
getVoiceReplyMode: deps.getVoiceReplyMode,
|
|
710
773
|
isVoiceReplyModeConfigured: deps.isVoiceReplyModeConfigured,
|
|
711
774
|
getTimeInjectionMode: deps.getTimeInjectionMode,
|
|
@@ -729,6 +792,7 @@ export function createTelegramSettingsMenuRuntime<
|
|
|
729
792
|
isProactivePushEnabled: deps.isProactivePushEnabled,
|
|
730
793
|
areDraftPreviewsEnabled: deps.areDraftPreviewsEnabled,
|
|
731
794
|
getAssistantRenderingMode: deps.getAssistantRenderingMode,
|
|
795
|
+
getActivityVerbosity: deps.getActivityVerbosity,
|
|
732
796
|
getVoiceReplyMode: deps.getVoiceReplyMode,
|
|
733
797
|
isVoiceReplyModeConfigured: deps.isVoiceReplyModeConfigured,
|
|
734
798
|
getTimeInjectionMode: deps.getTimeInjectionMode,
|
|
@@ -772,6 +836,7 @@ export function createTelegramSettingsMenuRuntime<
|
|
|
772
836
|
isProactivePushEnabled: deps.isProactivePushEnabled,
|
|
773
837
|
areDraftPreviewsEnabled: deps.areDraftPreviewsEnabled,
|
|
774
838
|
getAssistantRenderingMode: deps.getAssistantRenderingMode,
|
|
839
|
+
getActivityVerbosity: deps.getActivityVerbosity,
|
|
775
840
|
getVoiceReplyMode: deps.getVoiceReplyMode,
|
|
776
841
|
isVoiceReplyModeConfigured: deps.isVoiceReplyModeConfigured,
|
|
777
842
|
getTimeInjectionMode: deps.getTimeInjectionMode,
|
|
@@ -779,6 +844,7 @@ export function createTelegramSettingsMenuRuntime<
|
|
|
779
844
|
setProactivePushEnabled: deps.setProactivePushEnabled,
|
|
780
845
|
setDraftPreviewsEnabled: deps.setDraftPreviewsEnabled,
|
|
781
846
|
setAssistantRenderingMode: deps.setAssistantRenderingMode,
|
|
847
|
+
setActivityVerbosity: deps.setActivityVerbosity,
|
|
782
848
|
setVoiceReplyMode: deps.setVoiceReplyMode,
|
|
783
849
|
setTimeInjectionMode: deps.setTimeInjectionMode,
|
|
784
850
|
setAutomaticThreadCleanupEnabled: deps.setAutomaticThreadCleanupEnabled,
|
package/lib/queue.ts
CHANGED
|
@@ -968,6 +968,7 @@ export interface TelegramAgentEndRuntimeDeps<
|
|
|
968
968
|
isSessionActive?: () => boolean;
|
|
969
969
|
isTurnTransportActive?: (turn: TTurn) => boolean;
|
|
970
970
|
waitForTypingIdle?: () => Promise<void>;
|
|
971
|
+
waitForActivityIdle?: () => Promise<void>;
|
|
971
972
|
updateStatus: () => void;
|
|
972
973
|
dispatchNextQueuedTelegramTurn: () => void;
|
|
973
974
|
scheduleActiveTurnDelivery?: (task: () => Promise<void>) => void;
|
|
@@ -1047,6 +1048,7 @@ export interface TelegramAgentEndHookRuntimeDeps<
|
|
|
1047
1048
|
isSessionActive?: (ctx: TContext) => boolean;
|
|
1048
1049
|
isTurnTransportActive?: (turn: TTurn) => boolean;
|
|
1049
1050
|
waitForTypingIdle?: () => Promise<void>;
|
|
1051
|
+
waitForActivityIdle?: () => Promise<void>;
|
|
1050
1052
|
updateStatus: (ctx: TContext) => void;
|
|
1051
1053
|
dispatchNextQueuedTelegramTurn: (ctx: TContext) => void;
|
|
1052
1054
|
requestDeferredDispatchNextQueuedTelegramTurn: (
|
|
@@ -1188,6 +1190,7 @@ export function createTelegramAgentEndHook<
|
|
|
1188
1190
|
isSessionActive: () => deps.isSessionActive?.(ctx) ?? true,
|
|
1189
1191
|
isTurnTransportActive: deps.isTurnTransportActive,
|
|
1190
1192
|
waitForTypingIdle: deps.waitForTypingIdle,
|
|
1193
|
+
waitForActivityIdle: deps.waitForActivityIdle,
|
|
1191
1194
|
updateStatus: () => deps.updateStatus(ctx),
|
|
1192
1195
|
dispatchNextQueuedTelegramTurn: () => {
|
|
1193
1196
|
deps.requestDeferredDispatchNextQueuedTelegramTurn(
|
|
@@ -1358,6 +1361,7 @@ export async function handleTelegramAgentEndRuntime<
|
|
|
1358
1361
|
return;
|
|
1359
1362
|
}
|
|
1360
1363
|
const deliverActiveTurn = async () => {
|
|
1364
|
+
await deps.waitForActivityIdle?.();
|
|
1361
1365
|
if (!isDeliveryActive()) return;
|
|
1362
1366
|
if (finalText) deps.setPreviewPendingText(finalText);
|
|
1363
1367
|
if (!finalText && hasOutboundArtifacts)
|
package/lib/telegram-api.ts
CHANGED
|
@@ -274,6 +274,24 @@ type TelegramInputRichMessageCommon = {
|
|
|
274
274
|
skip_entity_detection?: boolean;
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
+
export type TelegramRichText =
|
|
278
|
+
| string
|
|
279
|
+
| TelegramRichText[]
|
|
280
|
+
| { type: "bold" | "code"; text: TelegramRichText };
|
|
281
|
+
|
|
282
|
+
export type TelegramInputRichBlock =
|
|
283
|
+
| { type: "pre"; text: TelegramRichText; language?: string }
|
|
284
|
+
| {
|
|
285
|
+
type: "details";
|
|
286
|
+
summary: TelegramRichText;
|
|
287
|
+
blocks: TelegramInputRichBlock[];
|
|
288
|
+
is_open?: true;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export type TelegramInputRichDraftBlock =
|
|
292
|
+
| TelegramInputRichBlock
|
|
293
|
+
| { type: "thinking"; text: TelegramRichText };
|
|
294
|
+
|
|
277
295
|
export type TelegramInputRichMessage = TelegramInputRichMessageCommon &
|
|
278
296
|
(
|
|
279
297
|
| {
|
|
@@ -288,6 +306,12 @@ export type TelegramInputRichMessage = TelegramInputRichMessageCommon &
|
|
|
288
306
|
blocks?: never;
|
|
289
307
|
media?: TelegramInputRichMessageMedia[];
|
|
290
308
|
}
|
|
309
|
+
| {
|
|
310
|
+
blocks: TelegramInputRichBlock[];
|
|
311
|
+
markdown?: never;
|
|
312
|
+
html?: never;
|
|
313
|
+
media?: never;
|
|
314
|
+
}
|
|
291
315
|
);
|
|
292
316
|
|
|
293
317
|
export type TelegramSendRichMessageBody = Record<string, unknown> & {
|
|
@@ -318,7 +342,14 @@ export type TelegramSendMessageDraftBody = Record<string, unknown> & {
|
|
|
318
342
|
export type TelegramSendRichMessageDraftBody = Record<string, unknown> & {
|
|
319
343
|
chat_id: number;
|
|
320
344
|
draft_id: number;
|
|
321
|
-
rich_message:
|
|
345
|
+
rich_message:
|
|
346
|
+
| TelegramInputRichMessage
|
|
347
|
+
| (TelegramInputRichMessageCommon & {
|
|
348
|
+
blocks: TelegramInputRichDraftBlock[];
|
|
349
|
+
markdown?: never;
|
|
350
|
+
html?: never;
|
|
351
|
+
media?: never;
|
|
352
|
+
});
|
|
322
353
|
message_thread_id?: number;
|
|
323
354
|
};
|
|
324
355
|
|