@llblab/pi-telegram 0.51.5 → 0.52.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/AGENTS.md +10 -8
- package/BACKLOG.md +1 -8
- package/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +16 -6
- package/dist/lib/activity-verbosity.d.ts +1 -5
- package/dist/lib/activity-verbosity.js +5 -7
- package/dist/lib/bindings.d.ts +9 -2
- package/dist/lib/bindings.js +22 -13
- package/dist/lib/bus-api.js +4 -2
- package/dist/lib/bus-follower.d.ts +55 -57
- package/dist/lib/bus-follower.js +213 -140
- package/dist/lib/bus-leader.d.ts +21 -2
- package/dist/lib/bus-leader.js +181 -25
- package/dist/lib/bus-transport.d.ts +4 -1
- package/dist/lib/bus-transport.js +28 -4
- package/dist/lib/bus.d.ts +52 -56
- package/dist/lib/bus.js +78 -246
- package/dist/lib/channel-posts.d.ts +1 -3
- package/dist/lib/channel-posts.js +23 -26
- package/dist/lib/command-templates.d.ts +0 -5
- package/dist/lib/command-templates.js +5 -5
- package/dist/lib/commands.d.ts +12 -26
- package/dist/lib/commands.js +152 -98
- package/dist/lib/config.d.ts +0 -17
- package/dist/lib/config.js +12 -14
- package/dist/lib/delivery.d.ts +0 -4
- package/dist/lib/delivery.js +2 -5
- package/dist/lib/extension.js +281 -61
- package/dist/lib/generative-apps.d.ts +0 -19
- package/dist/lib/inbound.d.ts +0 -2
- package/dist/lib/inbound.js +2 -2
- package/dist/lib/journal.d.ts +177 -16
- package/dist/lib/journal.js +1115 -249
- package/dist/lib/keyboard.d.ts +0 -2
- package/dist/lib/keyboard.js +2 -2
- package/dist/lib/lifecycle.d.ts +57 -2
- package/dist/lib/lifecycle.js +110 -5
- package/dist/lib/locks.d.ts +100 -12
- package/dist/lib/locks.js +380 -14
- package/dist/lib/logging.d.ts +30 -12
- package/dist/lib/logging.js +129 -72
- package/dist/lib/media.d.ts +28 -5
- package/dist/lib/media.js +26 -8
- package/dist/lib/menu-model.d.ts +0 -11
- package/dist/lib/menu-model.js +8 -8
- package/dist/lib/menu-settings.d.ts +0 -18
- package/dist/lib/menu-settings.js +18 -18
- package/dist/lib/menu-status.d.ts +4 -4
- package/dist/lib/menu-status.js +12 -7
- package/dist/lib/menu-thinking.d.ts +1 -1
- package/dist/lib/menu-thinking.js +1 -1
- package/dist/lib/menu.d.ts +1 -0
- package/dist/lib/menu.js +4 -3
- package/dist/lib/model.js +2 -4
- package/dist/lib/outbound-attachments.d.ts +0 -1
- package/dist/lib/outbound-attachments.js +1 -1
- package/dist/lib/outbound-buttons.js +1 -8
- package/dist/lib/outbound-markup.d.ts +1 -6
- package/dist/lib/outbound-markup.js +4 -21
- package/dist/lib/outbound.d.ts +0 -8
- package/dist/lib/outbound.js +5 -5
- package/dist/lib/paths.d.ts +50 -7
- package/dist/lib/paths.js +155 -17
- package/dist/lib/pi.d.ts +1 -0
- package/dist/lib/pi.js +2 -1
- package/dist/lib/polling.d.ts +0 -5
- package/dist/lib/polling.js +5 -5
- package/dist/lib/preview.d.ts +0 -3
- package/dist/lib/preview.js +3 -3
- package/dist/lib/prompt-templates.d.ts +0 -1
- package/dist/lib/prompt-templates.js +1 -1
- package/dist/lib/queue.d.ts +3 -15
- package/dist/lib/queue.js +69 -8
- package/dist/lib/recovery.d.ts +29 -9
- package/dist/lib/recovery.js +104 -33
- package/dist/lib/replies.d.ts +0 -4
- package/dist/lib/replies.js +1 -1
- package/dist/lib/routing.d.ts +73 -8
- package/dist/lib/routing.js +2206 -307
- package/dist/lib/sections.d.ts +0 -2
- package/dist/lib/sections.js +1 -1
- package/dist/lib/status.d.ts +46 -9
- package/dist/lib/status.js +179 -27
- package/dist/lib/sync.d.ts +0 -5
- package/dist/lib/sync.js +9 -8
- package/dist/lib/telegram-api.d.ts +11 -3
- package/dist/lib/telegram-api.js +34 -23
- package/dist/lib/thread-cleanup-manager.d.ts +1 -0
- package/dist/lib/thread-cleanup-manager.js +18 -21
- package/dist/lib/thread-naming.d.ts +32 -5
- package/dist/lib/thread-naming.js +191 -7
- package/dist/lib/thread-reconciler.d.ts +2 -0
- package/dist/lib/thread-reconciler.js +1 -1
- package/dist/lib/threads.d.ts +292 -59
- package/dist/lib/threads.js +1664 -373
- package/dist/lib/turns.d.ts +0 -1
- package/dist/lib/turns.js +1 -1
- package/dist/lib/updates.d.ts +184 -28
- package/dist/lib/updates.js +1032 -114
- package/dist/lib/wire.d.ts +12 -0
- package/dist/lib/wire.js +21 -0
- package/dist/lib/workspace-admission.d.ts +25 -17
- package/dist/lib/workspace-admission.js +95 -20
- package/dist/lib/workspace-identity.d.ts +20 -0
- package/dist/lib/workspace-identity.js +103 -0
- package/dist/lib/workspace-retirement.d.ts +45 -10
- package/dist/lib/workspace-retirement.js +196 -64
- package/dist/package.json +6 -6
- package/dist/skills/generated-control-surface/SKILL.md +3 -3
- package/dist/skills/telegram-bridge/references/diagnosis.md +3 -3
- package/docs/README.md +1 -1
- package/docs/activity.md +1 -1
- package/docs/architecture.md +158 -39
- package/docs/callback-namespaces.md +1 -1
- package/docs/delivery.md +1 -1
- package/docs/generative-apps.md +2 -2
- package/docs/inbound.md +1 -1
- package/docs/multi-instance-bus.md +127 -19
- package/docs/public-api.md +5 -3
- package/docs/ui-style.md +26 -8
- package/docs/updates.md +1 -1
- package/lib/activity-verbosity.ts +5 -9
- package/lib/bindings.ts +23 -10
- package/lib/bus-api.ts +5 -2
- package/lib/bus-follower.ts +251 -226
- package/lib/bus-leader.ts +178 -31
- package/lib/bus-transport.ts +30 -8
- package/lib/bus.ts +110 -334
- package/lib/channel-posts.ts +29 -29
- package/lib/command-templates.ts +5 -5
- package/lib/commands.ts +150 -112
- package/lib/config.ts +12 -17
- package/lib/delivery.ts +2 -8
- package/lib/extension.ts +282 -72
- package/lib/generative-apps.ts +0 -22
- package/lib/inbound.ts +2 -2
- package/lib/journal.ts +1182 -326
- package/lib/keyboard.ts +2 -2
- package/lib/lifecycle.ts +141 -5
- package/lib/locks.ts +402 -23
- package/lib/logging.ts +151 -101
- package/lib/media.ts +51 -9
- package/lib/menu-model.ts +8 -8
- package/lib/menu-settings.ts +18 -18
- package/lib/menu-status.ts +11 -0
- package/lib/menu-thinking.ts +2 -2
- package/lib/menu.ts +5 -1
- package/lib/model.ts +2 -4
- package/lib/outbound-attachments.ts +1 -1
- package/lib/outbound-buttons.ts +1 -10
- package/lib/outbound-markup.ts +5 -24
- package/lib/outbound.ts +5 -5
- package/lib/paths.ts +177 -17
- package/lib/pi.ts +5 -2
- package/lib/polling.ts +5 -5
- package/lib/preview.ts +3 -3
- package/lib/prompt-templates.ts +1 -1
- package/lib/queue.ts +67 -9
- package/lib/recovery.ts +104 -44
- package/lib/replies.ts +1 -1
- package/lib/routing.ts +1955 -375
- package/lib/sections.ts +1 -1
- package/lib/status.ts +185 -36
- package/lib/sync.ts +8 -8
- package/lib/telegram-api.ts +48 -33
- package/lib/thread-cleanup-manager.ts +24 -21
- package/lib/thread-naming.ts +267 -9
- package/lib/thread-reconciler.ts +3 -1
- package/lib/threads.ts +1718 -491
- package/lib/turns.ts +1 -1
- package/lib/updates.ts +1072 -151
- package/lib/wire.ts +28 -0
- package/lib/workspace-admission.ts +97 -47
- package/lib/workspace-identity.ts +147 -0
- package/lib/workspace-retirement.ts +234 -102
- package/package.json +6 -6
- package/scripts/audit-exports.mjs +100 -0
- package/scripts/check-downgrade.mjs +80 -43
- package/skills/generated-control-surface/SKILL.md +3 -3
- package/skills/telegram-bridge/references/diagnosis.md +3 -3
package/lib/config.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
export { TELEGRAM_DEFAULT_PROFILE_NAME } from "./paths.ts";
|
|
25
25
|
|
|
26
26
|
import type { CommandTemplateObjectConfig } from "./command-templates.ts";
|
|
27
|
+
import { isWireRecord as isPlainConfigRecord } from "./wire.ts";
|
|
27
28
|
import type { TelegramInboundHandlerConfig } from "./inbound.ts";
|
|
28
29
|
import { withTelegramFileTransaction } from "./locks.ts";
|
|
29
30
|
|
|
@@ -75,7 +76,7 @@ export type TelegramBotTokenReference =
|
|
|
75
76
|
* environment-variable references. Any other `$`-prefixed value is malformed
|
|
76
77
|
* rather than a literal secret so a broken reference fails closed.
|
|
77
78
|
*/
|
|
78
|
-
|
|
79
|
+
function getTelegramBotTokenReference(
|
|
79
80
|
value: string | undefined,
|
|
80
81
|
): TelegramBotTokenReference | undefined {
|
|
81
82
|
const trimmed = value?.trim();
|
|
@@ -115,8 +116,6 @@ export function getTelegramBotTokenDiagnostic(
|
|
|
115
116
|
return `Telegram bot token environment variable ${reference.variable} is not set.`;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
export type TelegramOutboundCommandTemplateConfig =
|
|
119
|
-
string | CommandTemplateObjectConfig;
|
|
120
119
|
export interface TelegramOutboundHandlerConfig extends CommandTemplateObjectConfig {
|
|
121
120
|
type?: string;
|
|
122
121
|
match?: string | string[];
|
|
@@ -465,10 +464,6 @@ export async function writeTelegramConfig(
|
|
|
465
464
|
await chmod(configPath, 0o600);
|
|
466
465
|
}
|
|
467
466
|
|
|
468
|
-
function isPlainConfigRecord(value: unknown): value is Record<string, unknown> {
|
|
469
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
467
|
function cloneTelegramConfig<T>(value: T): T {
|
|
473
468
|
return structuredClone(value);
|
|
474
469
|
}
|
|
@@ -963,7 +958,7 @@ export function createTelegramConfigStore(
|
|
|
963
958
|
};
|
|
964
959
|
}
|
|
965
960
|
|
|
966
|
-
|
|
961
|
+
function createTelegramDraftPreviewsChecker(
|
|
967
962
|
configStore: Pick<TelegramConfigStore, "get">,
|
|
968
963
|
): () => boolean {
|
|
969
964
|
return () => {
|
|
@@ -977,7 +972,7 @@ export function createTelegramDraftPreviewsChecker(
|
|
|
977
972
|
};
|
|
978
973
|
}
|
|
979
974
|
|
|
980
|
-
|
|
975
|
+
function createTelegramDraftPreviewsSetter(
|
|
981
976
|
configStore: TelegramMutableConfigStore,
|
|
982
977
|
): (enabled: boolean) => Promise<void> {
|
|
983
978
|
return async (enabled) => {
|
|
@@ -996,7 +991,7 @@ export function createTelegramDraftPreviewsSetter(
|
|
|
996
991
|
};
|
|
997
992
|
}
|
|
998
993
|
|
|
999
|
-
|
|
994
|
+
function createTelegramAssistantRenderingModeGetter(
|
|
1000
995
|
configStore: Pick<TelegramConfigStore, "get">,
|
|
1001
996
|
): () => TelegramAssistantRenderingMode {
|
|
1002
997
|
return () => {
|
|
@@ -1006,7 +1001,7 @@ export function createTelegramAssistantRenderingModeGetter(
|
|
|
1006
1001
|
};
|
|
1007
1002
|
}
|
|
1008
1003
|
|
|
1009
|
-
|
|
1004
|
+
function createTelegramAssistantRenderingModeSetter(
|
|
1010
1005
|
configStore: TelegramMutableConfigStore,
|
|
1011
1006
|
): (mode: TelegramAssistantRenderingMode) => Promise<void> {
|
|
1012
1007
|
return async (mode) => {
|
|
@@ -1022,7 +1017,7 @@ export function createTelegramAssistantRenderingModeSetter(
|
|
|
1022
1017
|
};
|
|
1023
1018
|
}
|
|
1024
1019
|
|
|
1025
|
-
|
|
1020
|
+
function createTelegramActivityVerbosityGetter(
|
|
1026
1021
|
configStore: Pick<TelegramConfigStore, "get">,
|
|
1027
1022
|
): () => TelegramActivityVerbosity {
|
|
1028
1023
|
return () => {
|
|
@@ -1044,13 +1039,13 @@ export function createTelegramActivityVerbosityGetter(
|
|
|
1044
1039
|
};
|
|
1045
1040
|
}
|
|
1046
1041
|
|
|
1047
|
-
|
|
1042
|
+
function createTelegramActivityVerbosityRefresher(
|
|
1048
1043
|
configStore: TelegramMutableConfigStore,
|
|
1049
1044
|
): () => Promise<void> {
|
|
1050
1045
|
return () => loadLatestTelegramConfig(configStore);
|
|
1051
1046
|
}
|
|
1052
1047
|
|
|
1053
|
-
|
|
1048
|
+
function createTelegramActivityVerbositySetter(
|
|
1054
1049
|
configStore: TelegramMutableConfigStore,
|
|
1055
1050
|
): (verbosity: TelegramActivityVerbosity) => Promise<void> {
|
|
1056
1051
|
return async (verbosity) => {
|
|
@@ -1210,13 +1205,13 @@ export function createTelegramProactivePushTargetGetter(deps: {
|
|
|
1210
1205
|
};
|
|
1211
1206
|
}
|
|
1212
1207
|
|
|
1213
|
-
|
|
1208
|
+
function createTelegramAutomaticThreadCleanupChecker(
|
|
1214
1209
|
configStore: Pick<TelegramConfigStore, "get">,
|
|
1215
1210
|
): () => boolean {
|
|
1216
1211
|
return () => configStore.get().threads?.automaticCleanup ?? true;
|
|
1217
1212
|
}
|
|
1218
1213
|
|
|
1219
|
-
|
|
1214
|
+
function createTelegramAutomaticThreadCleanupResolver(
|
|
1220
1215
|
configStore: TelegramMutableConfigStore,
|
|
1221
1216
|
): () => Promise<boolean> {
|
|
1222
1217
|
return async () => {
|
|
@@ -1230,7 +1225,7 @@ export function createTelegramAutomaticThreadCleanupResolver(
|
|
|
1230
1225
|
};
|
|
1231
1226
|
}
|
|
1232
1227
|
|
|
1233
|
-
|
|
1228
|
+
function createTelegramAutomaticThreadCleanupSetter(
|
|
1234
1229
|
configStore: TelegramMutableConfigStore,
|
|
1235
1230
|
): (enabled: boolean) => Promise<void> {
|
|
1236
1231
|
return async (enabled) => {
|
package/lib/delivery.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
renderTelegramMessage,
|
|
15
15
|
} from "./replies.ts";
|
|
16
16
|
import {
|
|
17
|
+
areTelegramTargetsEqual as areDeliveryTargetsEqual,
|
|
17
18
|
getTelegramTargetThreadParams,
|
|
18
19
|
type TelegramTarget,
|
|
19
20
|
} from "./target.ts";
|
|
@@ -262,7 +263,7 @@ function failure<T>(
|
|
|
262
263
|
: { ok: false, reason, message, partial, ...retry };
|
|
263
264
|
}
|
|
264
265
|
|
|
265
|
-
|
|
266
|
+
function classifyTelegramDeliveryTransportError(error: unknown): {
|
|
266
267
|
reason: Extract<TelegramDeliveryFailureReason,
|
|
267
268
|
"commit-unknown" | "message-unavailable" | "rate-limited" |
|
|
268
269
|
"transport-retryable" | "transport-failed">;
|
|
@@ -374,13 +375,6 @@ export function isTelegramDeliveryExplicitTargetAuthorized(
|
|
|
374
375
|
});
|
|
375
376
|
}
|
|
376
377
|
|
|
377
|
-
function areDeliveryTargetsEqual(
|
|
378
|
-
left: TelegramDeliveryTarget,
|
|
379
|
-
right: TelegramDeliveryTarget,
|
|
380
|
-
): boolean {
|
|
381
|
-
return left.chatId === right.chatId && left.threadId === right.threadId;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
378
|
function cloneTarget(target: TelegramDeliveryTarget): TelegramDeliveryTarget {
|
|
385
379
|
return target.threadId === undefined
|
|
386
380
|
? { chatId: target.chatId }
|