@llblab/pi-telegram 0.27.8 → 0.27.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 +5 -0
- package/docs/multi-instance-bus.md +1 -1
- package/lib/agent-messages.ts +2 -1
- package/lib/turns.ts +5 -1
- package/lib/updates.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.27.9: Symmetric Agent-Turn Metadata Hotfix
|
|
4
|
+
|
|
5
|
+
- `Agent-Turn Prompt Shape`: Cross-instance turns now fold trusted source-thread attribution into the canonical Telegram prefix as `[telegram|thread:<destination>|from-thread:<source>] <message>` instead of emitting a separate `[agent|from-thread:<source>]` block. Impact: inter-thread prompts match the existing compact metadata grammar without allowing ordinary Telegram text to impersonate transport attribution.
|
|
6
|
+
- `Transport Preservation`: Source-thread metadata travels as an internal serialized message field so leader-to-follower bus forwarding preserves it across the local IPC boundary. Focused regressions prove synthetic construction and final prompt formatting.
|
|
7
|
+
|
|
3
8
|
## 0.27.8: Bidirectional Thread Routing Hotfix
|
|
4
9
|
|
|
5
10
|
- `Directional Ownership`: Internal cross-instance turns now bypass only ownership of the already-sent Telegram message id while preserving ownership of the destination thread. Impact: follower-to-leader turns avoid bouncing back to their sender, while leader-to-follower and follower-to-follower turns still forward through the destination follower's live registration.
|
|
@@ -281,7 +281,7 @@ Follower instances receive normalized events, not raw Telegram transport interna
|
|
|
281
281
|
|
|
282
282
|
Followers do not call Telegram Bot API directly for routed Telegram work. Instead, they call a leader-owned transport port:
|
|
283
283
|
|
|
284
|
-
Explicit `telegram_message(..., thread)` delivery also uses the bus as an agent-message plane. The leader resolves the case-insensitive name or numeric id against live leader/follower registrations, rejects ambiguous, stale, same-instance, cross-chat, and replayed requests, then coordinates visible Bot API delivery with one source-attributed synthetic turn routed through the destination instance's ordinary queue. The destination sees `[
|
|
284
|
+
Explicit `telegram_message(..., thread)` delivery also uses the bus as an agent-message plane. The leader resolves the case-insensitive name or numeric id against live leader/follower registrations, rejects ambiguous, stale, same-instance, cross-chat, and replayed requests, then coordinates visible Bot API delivery with one source-attributed synthetic turn routed through the destination instance's ordinary queue. The destination sees `[telegram|thread:<destination>|from-thread:<source>]`, not an impersonated user message. Generation fencing and request-ledger deduplication apply to both resolution and routing.
|
|
285
285
|
|
|
286
286
|
```text
|
|
287
287
|
follower reply/preview/upload/chat-action/download/callback-answer -> leader IPC -> Telegram API
|
package/lib/agent-messages.ts
CHANGED
|
@@ -109,7 +109,8 @@ export function createTelegramAgentMessageRuntime<TContext, TUpdate>(
|
|
|
109
109
|
chat: { id: target.chatId, type: "private" as const },
|
|
110
110
|
from: { id: allowedChatId, is_bot: false, first_name: "Pi Agent" },
|
|
111
111
|
message_thread_id: target.threadId,
|
|
112
|
-
|
|
112
|
+
pi_telegram_agent_source_thread: sourceLabel,
|
|
113
|
+
text: input.message.text,
|
|
113
114
|
} as TelegramRoutedMessage;
|
|
114
115
|
await deps.handleUpdate(
|
|
115
116
|
{ message, [TELEGRAM_INTERNAL_AGENT_MESSAGE]: true } as TUpdate,
|
package/lib/turns.ts
CHANGED
|
@@ -54,6 +54,7 @@ export interface TelegramTurnTarget {
|
|
|
54
54
|
export interface TelegramTurnMessage {
|
|
55
55
|
message_id: number;
|
|
56
56
|
message_thread_id?: number;
|
|
57
|
+
pi_telegram_agent_source_thread?: string;
|
|
57
58
|
chat: { id: number; type?: string };
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -552,7 +553,10 @@ export function createTelegramPromptTurnRuntimeBuilder<
|
|
|
552
553
|
const threadLabel = firstMessage
|
|
553
554
|
? deps.getTelegramThreadLabel?.(firstMessage)
|
|
554
555
|
: undefined;
|
|
555
|
-
const telegramPrefix = createTelegramTurnPrefix({
|
|
556
|
+
const telegramPrefix = createTelegramTurnPrefix({
|
|
557
|
+
thread: threadLabel,
|
|
558
|
+
"from-thread": firstMessage?.pi_telegram_agent_source_thread,
|
|
559
|
+
});
|
|
556
560
|
return buildTelegramPromptTurnRuntime({
|
|
557
561
|
telegramPrefix,
|
|
558
562
|
messages,
|
package/lib/updates.ts
CHANGED
|
@@ -129,6 +129,7 @@ export interface TelegramUpdateMessage {
|
|
|
129
129
|
from?: TelegramUser;
|
|
130
130
|
message_id?: number;
|
|
131
131
|
message_thread_id?: number;
|
|
132
|
+
pi_telegram_agent_source_thread?: string;
|
|
132
133
|
forum_topic_created?: unknown;
|
|
133
134
|
forum_topic_closed?: unknown;
|
|
134
135
|
forum_topic_reopened?: unknown;
|