@llblab/pi-kit 0.12.1 → 0.13.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/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/node_modules/@llblab/pi-telegram/AGENTS.md +5 -3
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +0 -6
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +22 -0
- package/node_modules/@llblab/pi-telegram/README.md +6 -3
- package/node_modules/@llblab/pi-telegram/dist/api/activity.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/activity.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/commands.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/commands.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/delivery.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/delivery.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/inbound.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/inbound.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/keyboard.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/keyboard.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/outbound.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/outbound.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/sections.d.ts +7 -0
- package/node_modules/@llblab/pi-telegram/dist/api/sections.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/status.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/status.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/updates.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/updates.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/voice.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/api/voice.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/index.d.ts +6 -0
- package/node_modules/@llblab/pi-telegram/dist/index.js +6 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.d.ts +52 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/activity-verbosity.js +596 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/activity.d.ts +220 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/activity.js +574 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/agent-messages.d.ts +28 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/agent-messages.js +86 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +250 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +936 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.d.ts +18 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-api.js +254 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +464 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +1689 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.d.ts +292 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.js +2242 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.d.ts +64 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-transport.js +140 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus.d.ts +518 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus.js +2055 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.d.ts +170 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/channel-posts.js +611 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.d.ts +70 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/command-templates.js +744 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +541 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +1155 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/config.d.ts +252 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/config.js +889 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/delivery.d.ts +163 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/delivery.js +542 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/extension.d.ts +7 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +1604 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/generative-app-worker.mjs +104 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/generative-apps.d.ts +212 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/generative-apps.js +1006 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/inbound.d.ts +91 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/inbound.js +502 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/journal.d.ts +665 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/journal.js +3701 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.d.ts +23 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/keyboard.js +37 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.d.ts +157 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +395 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/locks.d.ts +164 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/locks.js +1208 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/logging.d.ts +50 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/logging.js +274 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/media.d.ts +181 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/media.js +602 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.d.ts +217 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-model.js +663 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-queue.d.ts +37 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-queue.js +408 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.d.ts +115 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-settings.js +595 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.d.ts +32 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-status.js +112 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.d.ts +29 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu-thinking.js +82 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu.d.ts +171 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/menu.js +323 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/model.d.ts +127 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/model.js +409 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.d.ts +241 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-attachments.js +639 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-buttons.d.ts +69 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-buttons.js +248 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.d.ts +42 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-markup.js +678 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-voice.d.ts +55 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound-voice.js +152 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound.d.ts +185 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/outbound.js +516 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/ownership.d.ts +77 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/ownership.js +174 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/paths.d.ts +40 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/paths.js +94 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/pi.d.ts +72 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/pi.js +121 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/polling.d.ts +351 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/polling.js +1196 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/preview.d.ts +192 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/preview.js +614 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.d.ts +24 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/prompt-templates.js +118 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/prompts.d.ts +57 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/prompts.js +167 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.d.ts +766 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/queue.js +1965 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/recovery.d.ts +86 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/recovery.js +285 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/rendering.d.ts +20 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/rendering.js +983 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/replies.d.ts +214 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/replies.js +737 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/routing.d.ts +207 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/routing.js +2282 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/runtime.d.ts +172 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/runtime.js +402 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/sections.d.ts +165 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/sections.js +327 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/setup.d.ts +82 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/setup.js +150 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/skills.d.ts +8 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/skills.js +12 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/status.d.ts +442 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/status.js +1000 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/sync.d.ts +179 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +782 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/target.d.ts +20 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/target.js +27 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.d.ts +541 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/telegram-api.js +1159 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/text-groups.d.ts +89 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/text-groups.js +317 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.d.ts +288 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-cleanup-manager.js +560 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-display.d.ts +46 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-display.js +257 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.d.ts +46 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-naming.js +78 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.d.ts +239 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/thread-reconciler.js +644 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +621 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +3679 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/time-injection.d.ts +15 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/time-injection.js +56 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/turns.d.ts +109 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/turns.js +500 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/updates.d.ts +1290 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/updates.js +3634 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/voice.d.ts +117 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/voice.js +174 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.d.ts +264 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-admission.js +1136 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +219 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +587 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-slots.d.ts +30 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/workspace-slots.js +54 -0
- package/node_modules/@llblab/pi-telegram/dist/package.json +126 -0
- package/node_modules/@llblab/pi-telegram/dist/pi-telegram/index.js +1 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/generated-control-surface/SKILL.md +107 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/generated-control-surface/references/capability-adapters.md +27 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/generated-control-surface/references/layout-and-state.md +37 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/generative-apps/SKILL.md +115 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/show-me/SKILL.md +166 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/show-me/references/telegram-surfaces.md +43 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/telegram-bridge/SKILL.md +129 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/telegram-bridge/references/configuration.md +15 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/telegram-bridge/references/delivery-and-threads.md +27 -0
- package/node_modules/@llblab/pi-telegram/dist/skills/telegram-bridge/references/diagnosis.md +18 -0
- package/node_modules/@llblab/pi-telegram/docs/README.md +2 -0
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +4 -2
- package/node_modules/@llblab/pi-telegram/docs/compact-matrix-literal.md +10 -3
- package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +15 -13
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +6 -4
- package/node_modules/@llblab/pi-telegram/docs/outbound.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +3 -3
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +89 -6
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +12 -5
- package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +44 -19
- package/node_modules/@llblab/pi-telegram/lib/bus.ts +4 -1
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +2 -2
- package/node_modules/@llblab/pi-telegram/lib/config.ts +14 -7
- package/node_modules/@llblab/pi-telegram/lib/delivery.ts +38 -6
- package/node_modules/@llblab/pi-telegram/lib/extension.ts +7 -0
- package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +379 -13
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +20 -6
- package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +16 -7
- package/node_modules/@llblab/pi-telegram/lib/status.ts +9 -15
- package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +12 -1
- package/node_modules/@llblab/pi-telegram/lib/thread-display.ts +96 -18
- package/node_modules/@llblab/pi-telegram/package.json +56 -13
- package/node_modules/@llblab/pi-telegram/scripts/build-dist.mjs +44 -0
- package/node_modules/@llblab/pi-telegram/scripts/measure-bus.mjs +8 -1
- package/node_modules/@llblab/pi-telegram/scripts/measure-workspace.mjs +8 -1
- package/node_modules/@llblab/pi-telegram/skills/generative-apps/SKILL.md +1 -1
- package/node_modules/@llblab/pi-telegram/skills/show-me/SKILL.md +1 -1
- package/node_modules/@llblab/pi-telegram/skills/show-me/references/telegram-surfaces.md +1 -1
- package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/SKILL.md +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram activity lifecycle normalization and extension dispatch
|
|
3
|
+
* Zones: pi agent lifecycle, extension API, operational delivery
|
|
4
|
+
* Owns stable handler registration, evidence-based activity/source identity, assistant segment and reasoning normalization, ordered public-output projection, executed-tool and compaction events, isolated non-blocking queues, shutdown fencing, diagnostics, and fresh delivery contexts; excludes Pi hook wiring, Telegram rendering implementation, raw transport clients, and consumer-extension behavior
|
|
5
|
+
*/
|
|
6
|
+
import { type TelegramDeliveryChatAction, type TelegramDeliveryHandle, type TelegramDeliveryResult, type TelegramDeliveryScope, type TelegramDeliveryTarget, type TelegramDeliveryView } from "./delivery.ts";
|
|
7
|
+
export type TelegramActivitySource = "telegram" | "local" | "autonomous" | "unknown";
|
|
8
|
+
export type TelegramActivityTarget = Readonly<TelegramDeliveryTarget>;
|
|
9
|
+
export interface TelegramActivityEnvelope {
|
|
10
|
+
activityId: string;
|
|
11
|
+
sequence: number;
|
|
12
|
+
source: TelegramActivitySource;
|
|
13
|
+
target?: TelegramActivityTarget;
|
|
14
|
+
replyToMessageId?: number;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
}
|
|
17
|
+
export type TelegramActivityPayload = {
|
|
18
|
+
type: "agent-start";
|
|
19
|
+
} | {
|
|
20
|
+
type: "assistant-text-delta";
|
|
21
|
+
contentIndex: number;
|
|
22
|
+
delta: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "assistant-segment";
|
|
25
|
+
contentIndex: number;
|
|
26
|
+
text: string;
|
|
27
|
+
placement: "intermediate" | "final" | "terminal-partial";
|
|
28
|
+
} | {
|
|
29
|
+
type: "reasoning-delta";
|
|
30
|
+
contentIndex: number;
|
|
31
|
+
delta: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "reasoning-end";
|
|
34
|
+
contentIndex: number;
|
|
35
|
+
text: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "tool-start";
|
|
38
|
+
toolCallId: string;
|
|
39
|
+
toolName: string;
|
|
40
|
+
args: unknown;
|
|
41
|
+
} | {
|
|
42
|
+
type: "tool-update";
|
|
43
|
+
toolCallId: string;
|
|
44
|
+
toolName: string;
|
|
45
|
+
update: unknown;
|
|
46
|
+
} | {
|
|
47
|
+
type: "tool-end";
|
|
48
|
+
toolCallId: string;
|
|
49
|
+
toolName: string;
|
|
50
|
+
result: unknown;
|
|
51
|
+
isError: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
type: "compaction-start";
|
|
54
|
+
reason: "manual" | "threshold" | "overflow" | "unknown";
|
|
55
|
+
} | {
|
|
56
|
+
type: "compaction-end";
|
|
57
|
+
reason: "manual" | "threshold" | "overflow" | "unknown";
|
|
58
|
+
} | {
|
|
59
|
+
type: "ui-prompt-start";
|
|
60
|
+
kind: "select" | "confirm" | "input" | "editor" | "custom";
|
|
61
|
+
title?: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "ui-prompt-end";
|
|
64
|
+
} | {
|
|
65
|
+
type: "agent-end";
|
|
66
|
+
} | {
|
|
67
|
+
type: "agent-settled";
|
|
68
|
+
};
|
|
69
|
+
export type TelegramActivityEvent = TelegramActivityEnvelope & TelegramActivityPayload;
|
|
70
|
+
export type TelegramAssistantSegmentEvent = TelegramActivityEnvelope & Extract<TelegramActivityPayload, {
|
|
71
|
+
type: "assistant-segment";
|
|
72
|
+
}>;
|
|
73
|
+
export interface TelegramActivityContext {
|
|
74
|
+
activityId: string;
|
|
75
|
+
sequence: number;
|
|
76
|
+
source: TelegramActivitySource;
|
|
77
|
+
defaultScope: TelegramDeliveryScope;
|
|
78
|
+
send: (view: TelegramDeliveryView, options?: {
|
|
79
|
+
scope?: TelegramDeliveryScope;
|
|
80
|
+
replyToMessageId?: number;
|
|
81
|
+
}) => Promise<TelegramDeliveryResult<TelegramDeliveryHandle>>;
|
|
82
|
+
edit: (handle: TelegramDeliveryHandle, view: TelegramDeliveryView) => Promise<TelegramDeliveryResult<TelegramDeliveryHandle>>;
|
|
83
|
+
delete: (handle: TelegramDeliveryHandle) => Promise<TelegramDeliveryResult<void>>;
|
|
84
|
+
chatAction: (action: TelegramDeliveryChatAction, options?: {
|
|
85
|
+
scope?: TelegramDeliveryScope;
|
|
86
|
+
}) => Promise<TelegramDeliveryResult<void>>;
|
|
87
|
+
}
|
|
88
|
+
export interface TelegramActivityHandlerRegistration {
|
|
89
|
+
id: string;
|
|
90
|
+
order?: number;
|
|
91
|
+
handle: (event: TelegramActivityEvent, ctx: TelegramActivityContext) => void | Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
export declare function registerTelegramActivityHandler(registration: TelegramActivityHandlerRegistration): () => void;
|
|
94
|
+
/** @internal */
|
|
95
|
+
export declare function clearTelegramActivityHandlers(): void;
|
|
96
|
+
/** @internal */
|
|
97
|
+
export interface TelegramActivityDispatcher {
|
|
98
|
+
dispatch: (event: TelegramActivityEvent) => void;
|
|
99
|
+
stop: () => void;
|
|
100
|
+
}
|
|
101
|
+
/** @internal */
|
|
102
|
+
export declare function createTelegramActivityDispatcher(deps?: {
|
|
103
|
+
recordFailure?: (handlerId: string, event: TelegramActivityEvent, error: unknown) => void;
|
|
104
|
+
}): TelegramActivityDispatcher;
|
|
105
|
+
/** @internal */
|
|
106
|
+
export declare function createTelegramActivityBridgeRuntime(deps: {
|
|
107
|
+
generation: string;
|
|
108
|
+
observeEvent?: (event: TelegramActivityEvent) => void;
|
|
109
|
+
recordFailure?: (handlerId: string, event: TelegramActivityEvent, error: unknown) => void;
|
|
110
|
+
now?: () => number;
|
|
111
|
+
}): TelegramActivityRuntime;
|
|
112
|
+
export type TelegramActivityInputSource = "interactive" | "rpc" | "extension" | "unknown";
|
|
113
|
+
export type TelegramAssistantStreamEvent = {
|
|
114
|
+
type: "start";
|
|
115
|
+
} | {
|
|
116
|
+
type: "text_start";
|
|
117
|
+
contentIndex: number;
|
|
118
|
+
} | {
|
|
119
|
+
type: "text_delta";
|
|
120
|
+
contentIndex: number;
|
|
121
|
+
delta: string;
|
|
122
|
+
} | {
|
|
123
|
+
type: "text_end";
|
|
124
|
+
contentIndex: number;
|
|
125
|
+
content: string;
|
|
126
|
+
} | {
|
|
127
|
+
type: "thinking_delta";
|
|
128
|
+
contentIndex: number;
|
|
129
|
+
delta: string;
|
|
130
|
+
} | {
|
|
131
|
+
type: "thinking_end";
|
|
132
|
+
contentIndex: number;
|
|
133
|
+
content: string;
|
|
134
|
+
} | {
|
|
135
|
+
type: "thinking_start";
|
|
136
|
+
contentIndex: number;
|
|
137
|
+
} | {
|
|
138
|
+
type: "toolcall_start";
|
|
139
|
+
contentIndex: number;
|
|
140
|
+
} | {
|
|
141
|
+
type: "toolcall_delta";
|
|
142
|
+
contentIndex: number;
|
|
143
|
+
delta: string;
|
|
144
|
+
} | {
|
|
145
|
+
type: "toolcall_end";
|
|
146
|
+
contentIndex: number;
|
|
147
|
+
} | {
|
|
148
|
+
type: "done";
|
|
149
|
+
} | {
|
|
150
|
+
type: "error";
|
|
151
|
+
};
|
|
152
|
+
/** @internal */
|
|
153
|
+
export interface TelegramActivityRuntime {
|
|
154
|
+
onSessionStart?: () => void;
|
|
155
|
+
recordInputSource: (source: TelegramActivityInputSource) => void;
|
|
156
|
+
onAgentStart: (activeTelegramTarget?: TelegramActivityTarget, replyToMessageId?: number) => void;
|
|
157
|
+
onAssistantEvent: (event: TelegramAssistantStreamEvent) => void;
|
|
158
|
+
onAssistantMessageEnd: (stopReason?: string) => void;
|
|
159
|
+
onToolStart: (event: {
|
|
160
|
+
toolCallId: string;
|
|
161
|
+
toolName: string;
|
|
162
|
+
args: unknown;
|
|
163
|
+
}) => void;
|
|
164
|
+
onToolUpdate: (event: {
|
|
165
|
+
toolCallId: string;
|
|
166
|
+
toolName: string;
|
|
167
|
+
update: unknown;
|
|
168
|
+
}) => void;
|
|
169
|
+
onToolEnd: (event: {
|
|
170
|
+
toolCallId: string;
|
|
171
|
+
toolName: string;
|
|
172
|
+
result: unknown;
|
|
173
|
+
isError: boolean;
|
|
174
|
+
}) => void;
|
|
175
|
+
onCompactionStart: (reason: "manual" | "threshold" | "overflow" | "unknown") => void;
|
|
176
|
+
onCompactionEnd: (reason: "manual" | "threshold" | "overflow" | "unknown") => void;
|
|
177
|
+
onCompactionAbandoned: () => void;
|
|
178
|
+
onUiPromptStart: (kind: "select" | "confirm" | "input" | "editor" | "custom", title?: string) => void;
|
|
179
|
+
onUiPromptEnd: () => void;
|
|
180
|
+
onAgentEnd: () => void;
|
|
181
|
+
onAgentSettled: () => void;
|
|
182
|
+
onSessionShutdown: () => void;
|
|
183
|
+
}
|
|
184
|
+
/** @internal */
|
|
185
|
+
export declare function createTelegramActivityRuntime(deps: {
|
|
186
|
+
generation: string;
|
|
187
|
+
dispatcher: TelegramActivityDispatcher;
|
|
188
|
+
observeEvent?: (event: TelegramActivityEvent) => void;
|
|
189
|
+
recordObserverFailure?: (event: TelegramActivityEvent, error: unknown) => void;
|
|
190
|
+
now?: () => number;
|
|
191
|
+
}): TelegramActivityRuntime;
|
|
192
|
+
export interface TelegramActivityPublicationReservation {
|
|
193
|
+
publish: (task: () => Promise<void>) => Promise<void>;
|
|
194
|
+
cancel: () => void;
|
|
195
|
+
}
|
|
196
|
+
export interface TelegramActivityPublicationRuntime {
|
|
197
|
+
enqueue: (task: () => Promise<void>) => Promise<void>;
|
|
198
|
+
reserve: () => TelegramActivityPublicationReservation;
|
|
199
|
+
reset: () => void;
|
|
200
|
+
}
|
|
201
|
+
export declare function createTelegramActivityPublicationRuntime(): TelegramActivityPublicationRuntime;
|
|
202
|
+
export interface TelegramAssistantOutputRuntime {
|
|
203
|
+
start: () => void;
|
|
204
|
+
accept: (event: TelegramAssistantSegmentEvent) => void;
|
|
205
|
+
waitForIdle: () => Promise<void>;
|
|
206
|
+
stop: () => void;
|
|
207
|
+
}
|
|
208
|
+
export interface TelegramAssistantOutputPreparation {
|
|
209
|
+
wait: () => Promise<void>;
|
|
210
|
+
settle: () => void;
|
|
211
|
+
}
|
|
212
|
+
export declare function createTelegramAssistantOutputRuntime<TAuthority = undefined>(deps: {
|
|
213
|
+
prepareSend?: (event: TelegramAssistantSegmentEvent) => TelegramAssistantOutputPreparation | undefined;
|
|
214
|
+
enqueue?: TelegramActivityPublicationRuntime["enqueue"];
|
|
215
|
+
captureAuthority?: () => TAuthority;
|
|
216
|
+
isAuthorityActive?: (authority: TAuthority) => boolean;
|
|
217
|
+
canDeliver: (event: TelegramAssistantSegmentEvent) => boolean;
|
|
218
|
+
send: (event: TelegramAssistantSegmentEvent, authority: TAuthority, isAuthorityActive: () => boolean) => Promise<void>;
|
|
219
|
+
recordFailure?: (event: TelegramAssistantSegmentEvent, error: unknown) => void;
|
|
220
|
+
}): TelegramAssistantOutputRuntime;
|