@llblab/pi-telegram 0.11.0 → 0.11.2
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 +4 -2
- package/CHANGELOG.md +22 -2
- package/README.md +38 -10
- package/docs/architecture.md +137 -30
- package/docs/command-templates.md +81 -24
- package/index.ts +33 -42
- package/lib/command-templates.ts +163 -32
- package/lib/config.ts +64 -0
- package/lib/lifecycle.ts +86 -0
- package/lib/menu-settings.ts +139 -21
- package/lib/pi.ts +4 -0
- package/lib/prompts.ts +1 -0
- package/lib/routing.ts +3 -10
- package/lib/time-injection.ts +78 -0
- package/lib/turns.ts +13 -0
- package/package.json +1 -1
package/lib/turns.ts
CHANGED
|
@@ -127,6 +127,7 @@ export function buildTelegramTurnPrompt(options: {
|
|
|
127
127
|
promptFiles?: DownloadedTelegramTurnFile[];
|
|
128
128
|
handlerOutputs?: string[];
|
|
129
129
|
historyTurns?: Pick<PendingTelegramTurn, "historyText">[];
|
|
130
|
+
timeLine?: string | null;
|
|
130
131
|
voiceContext?: Record<string, string>;
|
|
131
132
|
}): string {
|
|
132
133
|
let prompt = options.telegramPrefix;
|
|
@@ -154,6 +155,9 @@ export function buildTelegramTurnPrompt(options: {
|
|
|
154
155
|
if (options.voiceContext) {
|
|
155
156
|
prompt = appendTelegramVoiceContext(prompt, options.voiceContext);
|
|
156
157
|
}
|
|
158
|
+
if (options.timeLine) {
|
|
159
|
+
prompt = `${prompt}\n\n[time] ${options.timeLine}`;
|
|
160
|
+
}
|
|
157
161
|
return prompt;
|
|
158
162
|
}
|
|
159
163
|
|
|
@@ -330,6 +334,7 @@ export interface BuildTelegramPromptTurnOptions {
|
|
|
330
334
|
files: DownloadedTelegramTurnFile[];
|
|
331
335
|
promptFiles?: DownloadedTelegramTurnFile[];
|
|
332
336
|
handlerOutputs?: string[];
|
|
337
|
+
timeLine?: string | null;
|
|
333
338
|
readBinaryFile: (path: string) => Promise<Uint8Array>;
|
|
334
339
|
inferImageMimeType: (path: string) => string | undefined;
|
|
335
340
|
voiceReplyMode?: TelegramVoiceReplyMode;
|
|
@@ -355,6 +360,7 @@ export interface TelegramPromptTurnRuntimeBuilderDeps<
|
|
|
355
360
|
promptFiles?: DownloadedTelegramTurnFile[];
|
|
356
361
|
handlerOutputs?: string[];
|
|
357
362
|
}>;
|
|
363
|
+
resolveTimeLine?: (chatId: number) => string | null;
|
|
358
364
|
getVoiceReplyMode?: () => TelegramVoiceReplyMode;
|
|
359
365
|
isVoiceReplyModeConfigured?: () => boolean;
|
|
360
366
|
}
|
|
@@ -386,6 +392,11 @@ export function createTelegramPromptTurnRuntimeBuilder<
|
|
|
386
392
|
);
|
|
387
393
|
// Compute voice mode once and pass it to both the turn builder and the prompt contribution helper
|
|
388
394
|
const voiceReplyMode = deps.getVoiceReplyMode?.();
|
|
395
|
+
const chatId = messages[0]?.chat.id;
|
|
396
|
+
const timeLine =
|
|
397
|
+
deps.resolveTimeLine && chatId !== undefined
|
|
398
|
+
? deps.resolveTimeLine(chatId)
|
|
399
|
+
: null;
|
|
389
400
|
return buildTelegramPromptTurnRuntime({
|
|
390
401
|
telegramPrefix: TELEGRAM_PREFIX,
|
|
391
402
|
messages,
|
|
@@ -396,6 +407,7 @@ export function createTelegramPromptTurnRuntimeBuilder<
|
|
|
396
407
|
files,
|
|
397
408
|
promptFiles: processed.promptFiles,
|
|
398
409
|
handlerOutputs: processed.handlerOutputs,
|
|
410
|
+
timeLine,
|
|
399
411
|
inferImageMimeType: guessMediaType,
|
|
400
412
|
voiceReplyMode,
|
|
401
413
|
voiceReplyModeConfigured: deps.isVoiceReplyModeConfigured?.(),
|
|
@@ -440,6 +452,7 @@ export async function buildTelegramPromptTurn(
|
|
|
440
452
|
promptFiles: options.promptFiles,
|
|
441
453
|
handlerOutputs: options.handlerOutputs,
|
|
442
454
|
historyTurns: options.historyTurns,
|
|
455
|
+
timeLine: options.timeLine,
|
|
443
456
|
voiceContext: showVoiceContext
|
|
444
457
|
? getTelegramVoicePromptContext(voiceReplyMode, hasVoiceFile)
|
|
445
458
|
: undefined,
|