@llblab/pi-telegram 0.6.3 → 0.7.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 +153 -0
- package/BACKLOG.md +5 -0
- package/CHANGELOG.md +148 -0
- package/README.md +40 -39
- package/docs/README.md +1 -0
- package/docs/architecture.md +36 -27
- package/docs/attachment-handlers.md +4 -6
- package/docs/callback-namespaces.md +36 -0
- package/docs/command-templates.md +53 -9
- package/docs/locks.md +4 -0
- package/docs/outbound-handlers.md +6 -5
- package/index.ts +60 -7
- package/lib/api.ts +1 -0
- package/lib/attachment-handlers.ts +21 -10
- package/lib/attachments.ts +1 -0
- package/lib/command-templates.ts +37 -3
- package/lib/commands.ts +363 -88
- package/lib/config.ts +6 -2
- package/lib/keyboard.ts +14 -0
- package/lib/lifecycle.ts +26 -0
- package/lib/locks.ts +3 -2
- package/lib/media.ts +1 -0
- package/lib/menu-model.ts +881 -0
- package/lib/menu-queue.ts +610 -0
- package/lib/menu-status.ts +226 -0
- package/lib/menu-thinking.ts +171 -0
- package/lib/menu.ts +143 -1019
- package/lib/model.ts +1 -0
- package/lib/outbound-handlers.ts +28 -19
- package/lib/pi.ts +8 -0
- package/lib/polling.ts +1 -0
- package/lib/preview.ts +97 -50
- package/lib/prompt-templates.ts +150 -0
- package/lib/prompts.ts +2 -0
- package/lib/queue.ts +60 -15
- package/lib/rendering.ts +1 -0
- package/lib/replies.ts +90 -2
- package/lib/routing.ts +106 -14
- package/lib/runtime.ts +2 -0
- package/lib/setup.ts +1 -0
- package/lib/status.ts +18 -6
- package/lib/turns.ts +1 -0
- package/lib/updates.ts +55 -6
- package/package.json +5 -2
package/lib/lifecycle.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Telegram lifecycle hook registration helpers
|
|
3
|
+
* Zones: pi agent lifecycle, telegram session
|
|
3
4
|
* Owns binding prepared Telegram lifecycle runtimes to pi extension lifecycle events
|
|
4
5
|
*/
|
|
5
6
|
|
|
@@ -13,6 +14,21 @@ import type {
|
|
|
13
14
|
SessionStartEvent,
|
|
14
15
|
} from "./pi.ts";
|
|
15
16
|
|
|
17
|
+
let resetTransportReplyDedupFn: (() => void) | undefined;
|
|
18
|
+
|
|
19
|
+
export function setResetTransportReplyDedup(fn: () => void): void {
|
|
20
|
+
resetTransportReplyDedupFn = fn;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createAgentStartDedupHook(
|
|
24
|
+
inner: (event: AgentStartEvent, ctx: ExtensionContext) => Promise<void>,
|
|
25
|
+
): (event: AgentStartEvent, ctx: ExtensionContext) => Promise<void> {
|
|
26
|
+
return async function onAgentStartDedup(event, ctx) {
|
|
27
|
+
if (resetTransportReplyDedupFn) resetTransportReplyDedupFn();
|
|
28
|
+
return inner(event, ctx);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
export interface TelegramBeforeAgentStartResult {
|
|
17
33
|
systemPrompt?: string;
|
|
18
34
|
}
|
|
@@ -76,6 +92,16 @@ export interface TelegramSessionLifecycleHooks {
|
|
|
76
92
|
) => Promise<void>;
|
|
77
93
|
}
|
|
78
94
|
|
|
95
|
+
export function createDedupAgentStartHook(
|
|
96
|
+
dedup: { reset(): void },
|
|
97
|
+
inner: (event: AgentStartEvent, ctx: ExtensionContext) => Promise<void>,
|
|
98
|
+
): (event: AgentStartEvent, ctx: ExtensionContext) => Promise<void> {
|
|
99
|
+
return async (event, ctx) => {
|
|
100
|
+
dedup.reset();
|
|
101
|
+
await inner(event, ctx);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
79
105
|
export interface TelegramExtraLifecycleHooks {
|
|
80
106
|
onSessionStart?: (
|
|
81
107
|
event: SessionStartEvent,
|
package/lib/locks.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Telegram singleton lock helpers
|
|
3
|
+
* Zones: shared singleton, filesystem, telegram runtime ownership
|
|
3
4
|
* Owns shared locks.json access and Telegram bridge ownership semantics
|
|
4
5
|
*/
|
|
5
6
|
|
|
@@ -285,7 +286,7 @@ export function createTelegramLockedPollingRuntime<
|
|
|
285
286
|
ok: false,
|
|
286
287
|
canTakeover: true,
|
|
287
288
|
owner: formatLock(acquired.lock),
|
|
288
|
-
message: `Telegram bridge is active in another
|
|
289
|
+
message: `Telegram bridge is active in another π instance (${formatLock(acquired.lock)}).`,
|
|
289
290
|
};
|
|
290
291
|
}
|
|
291
292
|
await deps.startPolling(ctx);
|
|
@@ -298,7 +299,7 @@ export function createTelegramLockedPollingRuntime<
|
|
|
298
299
|
await suspendPolling();
|
|
299
300
|
const state = deps.lock.release();
|
|
300
301
|
if (state.kind === "active-elsewhere") {
|
|
301
|
-
return `Telegram bridge is active in another
|
|
302
|
+
return `Telegram bridge is active in another π instance (${formatLock(state.lock)}).`;
|
|
302
303
|
}
|
|
303
304
|
if (state.kind === "stale")
|
|
304
305
|
return `Removed stale Telegram bridge lock (${formatLock(state.lock)}).`;
|