@llblab/pi-kit 0.1.7 → 0.1.9
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/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -0
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +17 -0
- package/node_modules/@llblab/pi-telegram/README.md +3 -3
- package/node_modules/@llblab/pi-telegram/api/voice.ts +0 -1
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +5 -5
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +2 -2
- package/node_modules/@llblab/pi-telegram/docs/outbound.md +2 -3
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +5 -15
- package/node_modules/@llblab/pi-telegram/docs/voice.md +9 -37
- package/node_modules/@llblab/pi-telegram/index.ts +30 -7
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +112 -25
- package/node_modules/@llblab/pi-telegram/lib/config.ts +38 -46
- package/node_modules/@llblab/pi-telegram/lib/journal.ts +107 -2
- package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +4 -2
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +15 -11
- package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +3 -18
- package/node_modules/@llblab/pi-telegram/lib/polling.ts +66 -24
- package/node_modules/@llblab/pi-telegram/lib/setup.ts +0 -1
- package/node_modules/@llblab/pi-telegram/lib/status.ts +2 -2
- package/node_modules/@llblab/pi-telegram/lib/updates.ts +11 -4
- package/node_modules/@llblab/pi-telegram/lib/voice.ts +7 -31
- package/node_modules/@llblab/pi-telegram/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/SKILL.md +1 -1
- package/package.json +2 -2
|
@@ -1685,6 +1685,7 @@ export interface TelegramUpdateWorkerStateSnapshot {
|
|
|
1685
1685
|
}
|
|
1686
1686
|
|
|
1687
1687
|
export interface TelegramUpdateWorkerJournalSnapshot {
|
|
1688
|
+
acceptedThroughUpdateId?: number;
|
|
1688
1689
|
entries: readonly {
|
|
1689
1690
|
updateId: number;
|
|
1690
1691
|
update: TelegramJournaledUpdate;
|
|
@@ -3669,7 +3670,10 @@ export interface TelegramUpdateAdmissionLifecycleJournalBinding {
|
|
|
3669
3670
|
runtimeKey: string;
|
|
3670
3671
|
recoveryKey: string;
|
|
3671
3672
|
journal: TelegramUpdateWorkerJournalPort & {
|
|
3672
|
-
appendBatch: (
|
|
3673
|
+
appendBatch: (
|
|
3674
|
+
updates: readonly TelegramJournaledUpdate[],
|
|
3675
|
+
acceptedThroughUpdateId?: number,
|
|
3676
|
+
) => unknown;
|
|
3673
3677
|
applyOperatorDisposition?: (
|
|
3674
3678
|
input: TelegramUpdateJournalOperatorDispositionInput,
|
|
3675
3679
|
) => TelegramUpdateJournalOperatorDispositionResult;
|
|
@@ -4303,7 +4307,10 @@ export interface TelegramUpdateAdmissionLifecycleRuntime<TContext>
|
|
|
4303
4307
|
onSessionStart: (ctx: TContext) => Promise<void>;
|
|
4304
4308
|
onSessionShutdown: () => Promise<void>;
|
|
4305
4309
|
onTransportChanged: (ctx?: TContext) => Promise<void>;
|
|
4306
|
-
appendBatch: (
|
|
4310
|
+
appendBatch: (
|
|
4311
|
+
updates: readonly TelegramJournaledUpdate[],
|
|
4312
|
+
acceptedThroughUpdateId?: number,
|
|
4313
|
+
) => unknown;
|
|
4307
4314
|
discardQueueReceipt: (input: {
|
|
4308
4315
|
queueKind: "prompt" | "control";
|
|
4309
4316
|
receiptId: string;
|
|
@@ -4603,11 +4610,11 @@ export function createTelegramUpdateAdmissionLifecycleRuntime<TContext>(
|
|
|
4603
4610
|
await stopCurrent(true);
|
|
4604
4611
|
if (ctx !== undefined) await bind(ctx);
|
|
4605
4612
|
}),
|
|
4606
|
-
appendBatch(updates) {
|
|
4613
|
+
appendBatch(updates, acceptedThroughUpdateId) {
|
|
4607
4614
|
if (!journal || !worker) {
|
|
4608
4615
|
throw new Error("Telegram update admission worker is not active.");
|
|
4609
4616
|
}
|
|
4610
|
-
return journal.appendBatch(updates);
|
|
4617
|
+
return journal.appendBatch(updates, acceptedThroughUpdateId);
|
|
4611
4618
|
},
|
|
4612
4619
|
discardQueueReceipt(input) {
|
|
4613
4620
|
if (!journal || !worker || !journal.discardQueued) {
|
|
@@ -38,15 +38,9 @@ function getNextAvailableProviderId<T>(
|
|
|
38
38
|
return id;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export type TelegramVoiceReplyMode = "
|
|
41
|
+
export type TelegramVoiceReplyMode = "manual" | "mirror" | "always";
|
|
42
42
|
|
|
43
|
-
export type TelegramVoiceSynthesisProviderResult =
|
|
44
|
-
| string
|
|
45
|
-
| {
|
|
46
|
-
audioPath: string;
|
|
47
|
-
transcriptText?: string;
|
|
48
|
-
}
|
|
49
|
-
| undefined;
|
|
43
|
+
export type TelegramVoiceSynthesisProviderResult = string | undefined;
|
|
50
44
|
|
|
51
45
|
export interface TelegramVoiceTurnView {
|
|
52
46
|
voiceReplyPreferred?: boolean;
|
|
@@ -215,7 +209,7 @@ export function clearTelegramVoiceTranscriptionProviders(): void {
|
|
|
215
209
|
// --- Voice Reply Modes ---
|
|
216
210
|
|
|
217
211
|
export const TELEGRAM_VOICE_REPLY_MODES = [
|
|
218
|
-
"
|
|
212
|
+
"manual",
|
|
219
213
|
"mirror",
|
|
220
214
|
"always",
|
|
221
215
|
] as const;
|
|
@@ -224,33 +218,15 @@ export const TELEGRAM_VOICE_REPLY_MODES = [
|
|
|
224
218
|
* Returns the active voice reply mode for the current session.
|
|
225
219
|
*
|
|
226
220
|
* Pi-telegram owns reply-mode policy through telegram.json. If
|
|
227
|
-
* config.voice.replyMode is missing, invalid, or legacy `
|
|
228
|
-
* mode is
|
|
221
|
+
* config.voice.replyMode is missing, invalid, or legacy `hidden`, the effective
|
|
222
|
+
* mode is manual.
|
|
229
223
|
*/
|
|
230
224
|
export function getTelegramVoiceReplyMode(config?: {
|
|
231
225
|
voice?: { replyMode?: string };
|
|
232
226
|
}): TelegramVoiceReplyMode {
|
|
233
227
|
const configMode = config?.voice?.replyMode;
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
(TELEGRAM_VOICE_REPLY_MODES as readonly string[]).includes(configMode)
|
|
237
|
-
) {
|
|
238
|
-
return configMode as TelegramVoiceReplyMode;
|
|
239
|
-
}
|
|
240
|
-
return "hidden";
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Returns whether the user wants the voice synthesis provider's transcript attached
|
|
245
|
-
* as a caption on the voice message.
|
|
246
|
-
*
|
|
247
|
-
* Reads from `config.voice.sendTranscript`.
|
|
248
|
-
* Default: false (no transcript text sent at all).
|
|
249
|
-
*/
|
|
250
|
-
export function getTelegramVoiceSendTranscript(config?: {
|
|
251
|
-
voice?: { sendTranscript?: boolean };
|
|
252
|
-
}): boolean {
|
|
253
|
-
return !!config?.voice?.sendTranscript;
|
|
228
|
+
if (configMode === "mirror" || configMode === "always") return configMode;
|
|
229
|
+
return "manual";
|
|
254
230
|
}
|
|
255
231
|
|
|
256
232
|
// --- Voice Turn Helpers ---
|
|
@@ -122,7 +122,7 @@ Prefer no-code command-template configuration in `telegram.json` before adding a
|
|
|
122
122
|
- `outboundHandlers` transforms final replies.
|
|
123
123
|
- Voice transcription handlers can match `type: "voice"` or `mime: "audio/*"`; stdout becomes `[outputs]`.
|
|
124
124
|
|
|
125
|
-
When asked to configure voice rather than merely operate it, follow the provider-neutral contracts in `docs/voice.md`, `docs/inbound.md`, `docs/outbound.md`, and `docs/command-templates.md` from the pi-telegram package or repository. Inspect the available Skill catalog and trusted local executables for STT, TTS, and media conversion capabilities; check only whether required environment variables exist, never reveal their values. Preserve unrelated `telegram.json` fields, order multiple matching inbound handlers as fallbacks, require OGG/Opus output for native voice delivery, and validate each stage before a live Telegram smoke test. Keep `voice.replyMode` at its existing value unless the user requests a policy change: the default `
|
|
125
|
+
When asked to configure voice rather than merely operate it, follow the provider-neutral contracts in `docs/voice.md`, `docs/inbound.md`, `docs/outbound.md`, and `docs/command-templates.md` from the pi-telegram package or repository. Inspect the available Skill catalog and trusted local executables for STT, TTS, and media conversion capabilities; check only whether required environment variables exist, never reveal their values. Preserve unrelated `telegram.json` fields, order multiple matching inbound handlers as fallbacks, require OGG/Opus output for native voice delivery, and validate each stage before a live Telegram smoke test. Keep `voice.replyMode` at its existing value unless the user requests a policy change: the default `manual` mode is fully functional because explicit top-level `telegram_voice` actions still use the configured synthesis pipeline.
|
|
126
126
|
|
|
127
127
|
When configuration is insufficient, use documented `@llblab/pi-telegram/*` public API subpaths. Never import package-private `lib/*`, start another polling loop, or bypass bridge ownership with raw Bot API access.
|
|
128
128
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llblab/pi-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@llblab/pi-actors": "0.50.0",
|
|
44
44
|
"@llblab/pi-codex-usage": "0.9.3",
|
|
45
45
|
"@llblab/pi-grow-loop": "0.7.2",
|
|
46
|
-
"@llblab/pi-telegram": "0.
|
|
46
|
+
"@llblab/pi-telegram": "0.38.0"
|
|
47
47
|
},
|
|
48
48
|
"bundledDependencies": [
|
|
49
49
|
"@llblab/pi-actors",
|