@llblab/pi-telegram 0.46.0 → 0.48.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/AGENTS.md +4 -2
- package/BACKLOG.md +0 -6
- package/CHANGELOG.md +14 -0
- package/README.md +5 -2
- package/dist/api/activity.d.ts +6 -0
- package/dist/api/activity.js +6 -0
- package/dist/api/commands.d.ts +6 -0
- package/dist/api/commands.js +6 -0
- package/dist/api/delivery.d.ts +6 -0
- package/dist/api/delivery.js +6 -0
- package/dist/api/inbound.d.ts +6 -0
- package/dist/api/inbound.js +6 -0
- package/dist/api/keyboard.d.ts +6 -0
- package/dist/api/keyboard.js +6 -0
- package/dist/api/outbound.d.ts +6 -0
- package/dist/api/outbound.js +6 -0
- package/dist/api/sections.d.ts +7 -0
- package/dist/api/sections.js +6 -0
- package/dist/api/status.d.ts +6 -0
- package/dist/api/status.js +6 -0
- package/dist/api/updates.d.ts +6 -0
- package/dist/api/updates.js +6 -0
- package/dist/api/voice.d.ts +6 -0
- package/dist/api/voice.js +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/lib/activity-verbosity.d.ts +52 -0
- package/dist/lib/activity-verbosity.js +596 -0
- package/dist/lib/activity.d.ts +220 -0
- package/dist/lib/activity.js +574 -0
- package/dist/lib/agent-messages.d.ts +28 -0
- package/dist/lib/agent-messages.js +86 -0
- package/dist/lib/bindings.d.ts +250 -0
- package/dist/lib/bindings.js +936 -0
- package/dist/lib/bus-api.d.ts +18 -0
- package/dist/lib/bus-api.js +254 -0
- package/dist/lib/bus-follower.d.ts +464 -0
- package/dist/lib/bus-follower.js +1686 -0
- package/dist/lib/bus-leader.d.ts +292 -0
- package/dist/lib/bus-leader.js +2242 -0
- package/dist/lib/bus-transport.d.ts +64 -0
- package/dist/lib/bus-transport.js +140 -0
- package/dist/lib/bus.d.ts +518 -0
- package/dist/lib/bus.js +2055 -0
- package/dist/lib/channel-posts.d.ts +170 -0
- package/dist/lib/channel-posts.js +611 -0
- package/dist/lib/command-templates.d.ts +70 -0
- package/dist/lib/command-templates.js +744 -0
- package/dist/lib/commands.d.ts +541 -0
- package/dist/lib/commands.js +1155 -0
- package/dist/lib/config.d.ts +252 -0
- package/dist/lib/config.js +889 -0
- package/dist/lib/delivery.d.ts +163 -0
- package/dist/lib/delivery.js +542 -0
- package/dist/lib/extension.d.ts +7 -0
- package/dist/lib/extension.js +1604 -0
- package/dist/lib/generative-app-worker.mjs +104 -0
- package/dist/lib/generative-apps.d.ts +212 -0
- package/dist/lib/generative-apps.js +1006 -0
- package/dist/lib/inbound.d.ts +91 -0
- package/dist/lib/inbound.js +502 -0
- package/dist/lib/journal.d.ts +665 -0
- package/dist/lib/journal.js +3701 -0
- package/dist/lib/keyboard.d.ts +23 -0
- package/dist/lib/keyboard.js +37 -0
- package/dist/lib/lifecycle.d.ts +157 -0
- package/dist/lib/lifecycle.js +395 -0
- package/dist/lib/locks.d.ts +164 -0
- package/dist/lib/locks.js +1208 -0
- package/dist/lib/logging.d.ts +50 -0
- package/dist/lib/logging.js +274 -0
- package/dist/lib/media.d.ts +181 -0
- package/dist/lib/media.js +602 -0
- package/dist/lib/menu-model.d.ts +217 -0
- package/dist/lib/menu-model.js +663 -0
- package/dist/lib/menu-queue.d.ts +37 -0
- package/dist/lib/menu-queue.js +408 -0
- package/dist/lib/menu-settings.d.ts +115 -0
- package/dist/lib/menu-settings.js +595 -0
- package/dist/lib/menu-status.d.ts +32 -0
- package/dist/lib/menu-status.js +112 -0
- package/dist/lib/menu-thinking.d.ts +29 -0
- package/dist/lib/menu-thinking.js +82 -0
- package/dist/lib/menu.d.ts +171 -0
- package/dist/lib/menu.js +323 -0
- package/dist/lib/model.d.ts +127 -0
- package/dist/lib/model.js +409 -0
- package/dist/lib/outbound-attachments.d.ts +241 -0
- package/dist/lib/outbound-attachments.js +639 -0
- package/dist/lib/outbound-buttons.d.ts +69 -0
- package/dist/lib/outbound-buttons.js +248 -0
- package/dist/lib/outbound-markup.d.ts +42 -0
- package/dist/lib/outbound-markup.js +678 -0
- package/dist/lib/outbound-voice.d.ts +55 -0
- package/dist/lib/outbound-voice.js +152 -0
- package/dist/lib/outbound.d.ts +185 -0
- package/dist/lib/outbound.js +516 -0
- package/dist/lib/ownership.d.ts +77 -0
- package/dist/lib/ownership.js +174 -0
- package/dist/lib/paths.d.ts +40 -0
- package/dist/lib/paths.js +94 -0
- package/dist/lib/pi.d.ts +72 -0
- package/dist/lib/pi.js +121 -0
- package/dist/lib/polling.d.ts +351 -0
- package/dist/lib/polling.js +1196 -0
- package/dist/lib/preview.d.ts +192 -0
- package/dist/lib/preview.js +614 -0
- package/dist/lib/prompt-templates.d.ts +24 -0
- package/dist/lib/prompt-templates.js +118 -0
- package/dist/lib/prompts.d.ts +57 -0
- package/dist/lib/prompts.js +167 -0
- package/dist/lib/queue.d.ts +766 -0
- package/dist/lib/queue.js +1965 -0
- package/dist/lib/recovery.d.ts +86 -0
- package/dist/lib/recovery.js +285 -0
- package/dist/lib/rendering.d.ts +20 -0
- package/dist/lib/rendering.js +983 -0
- package/dist/lib/replies.d.ts +214 -0
- package/dist/lib/replies.js +737 -0
- package/dist/lib/routing.d.ts +207 -0
- package/dist/lib/routing.js +2282 -0
- package/dist/lib/runtime.d.ts +172 -0
- package/dist/lib/runtime.js +402 -0
- package/dist/lib/sections.d.ts +165 -0
- package/dist/lib/sections.js +327 -0
- package/dist/lib/setup.d.ts +82 -0
- package/dist/lib/setup.js +150 -0
- package/dist/lib/skills.d.ts +8 -0
- package/dist/lib/skills.js +12 -0
- package/dist/lib/status.d.ts +442 -0
- package/dist/lib/status.js +1008 -0
- package/dist/lib/sync.d.ts +179 -0
- package/dist/lib/sync.js +782 -0
- package/dist/lib/target.d.ts +20 -0
- package/dist/lib/target.js +27 -0
- package/dist/lib/telegram-api.d.ts +541 -0
- package/dist/lib/telegram-api.js +1159 -0
- package/dist/lib/text-groups.d.ts +89 -0
- package/dist/lib/text-groups.js +317 -0
- package/dist/lib/thread-cleanup-manager.d.ts +288 -0
- package/dist/lib/thread-cleanup-manager.js +560 -0
- package/dist/lib/thread-display.d.ts +46 -0
- package/dist/lib/thread-display.js +257 -0
- package/dist/lib/thread-naming.d.ts +46 -0
- package/dist/lib/thread-naming.js +78 -0
- package/dist/lib/thread-reconciler.d.ts +239 -0
- package/dist/lib/thread-reconciler.js +644 -0
- package/dist/lib/threads.d.ts +621 -0
- package/dist/lib/threads.js +3679 -0
- package/dist/lib/time-injection.d.ts +15 -0
- package/dist/lib/time-injection.js +56 -0
- package/dist/lib/turns.d.ts +109 -0
- package/dist/lib/turns.js +500 -0
- package/dist/lib/updates.d.ts +1290 -0
- package/dist/lib/updates.js +3634 -0
- package/dist/lib/voice.d.ts +117 -0
- package/dist/lib/voice.js +174 -0
- package/dist/lib/workspace-admission.d.ts +264 -0
- package/dist/lib/workspace-admission.js +1136 -0
- package/dist/lib/workspace-retirement.d.ts +219 -0
- package/dist/lib/workspace-retirement.js +587 -0
- package/dist/lib/workspace-slots.d.ts +30 -0
- package/dist/lib/workspace-slots.js +54 -0
- package/dist/package.json +126 -0
- package/dist/pi-telegram/index.js +1 -0
- package/dist/skills/generated-control-surface/SKILL.md +107 -0
- package/dist/skills/generated-control-surface/references/capability-adapters.md +27 -0
- package/dist/skills/generated-control-surface/references/layout-and-state.md +37 -0
- package/dist/skills/generative-apps/SKILL.md +115 -0
- package/dist/skills/show-me/SKILL.md +166 -0
- package/dist/skills/show-me/references/telegram-surfaces.md +43 -0
- package/dist/skills/telegram-bridge/SKILL.md +129 -0
- package/dist/skills/telegram-bridge/references/configuration.md +15 -0
- package/dist/skills/telegram-bridge/references/delivery-and-threads.md +27 -0
- package/dist/skills/telegram-bridge/references/diagnosis.md +18 -0
- package/docs/README.md +2 -0
- package/docs/architecture.md +1 -1
- package/docs/compact-matrix-literal.md +10 -3
- package/docs/generative-apps.md +15 -13
- package/docs/multi-instance-bus.md +6 -4
- package/docs/outbound.md +1 -1
- package/docs/public-api.md +3 -3
- package/lib/bindings.ts +89 -6
- package/lib/bus-follower.ts +7 -3
- package/lib/bus-leader.ts +44 -19
- package/lib/bus.ts +4 -1
- package/lib/commands.ts +2 -2
- package/lib/config.ts +14 -7
- package/lib/delivery.ts +38 -6
- package/lib/extension.ts +7 -0
- package/lib/generative-apps.ts +379 -13
- package/lib/menu-settings.ts +20 -6
- package/lib/outbound-markup.ts +16 -7
- package/lib/status.ts +15 -12
- package/lib/telegram-api.ts +12 -1
- package/lib/thread-display.ts +96 -18
- package/package.json +56 -13
- package/scripts/build-dist.mjs +44 -0
- package/scripts/measure-bus.mjs +8 -1
- package/scripts/measure-workspace.mjs +8 -1
- package/skills/generative-apps/SKILL.md +1 -1
- package/skills/show-me/SKILL.md +1 -1
- package/skills/show-me/references/telegram-surfaces.md +1 -1
- package/skills/telegram-bridge/SKILL.md +1 -1
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram multi-instance bus protocol and IPC helpers
|
|
3
|
+
* Zones: multi-instance bus, local IPC contract, live instance routing
|
|
4
|
+
* Owns serializable bus envelopes, socket/auth helpers, local IPC client/server primitives,
|
|
5
|
+
* cross-instance forwarding helpers, and the live follower registry model.
|
|
6
|
+
*/
|
|
7
|
+
import { type TelegramBusTransportEventRecorder, type TelegramBusTransportRetryPolicy } from "./bus-transport.ts";
|
|
8
|
+
import { type TelegramQueueHandoffPayload } from "./queue.ts";
|
|
9
|
+
import type { TelegramTarget } from "./target.ts";
|
|
10
|
+
import type { TelegramThreadDisplayMode } from "./config.ts";
|
|
11
|
+
export interface TelegramBusProcessRuntime {
|
|
12
|
+
instanceId: string;
|
|
13
|
+
processId: number;
|
|
14
|
+
processBirthId: string;
|
|
15
|
+
manualFollowerOwnerId: string;
|
|
16
|
+
getLeaderSocketPath: () => string;
|
|
17
|
+
getFollowerSocketPath: () => string;
|
|
18
|
+
}
|
|
19
|
+
export interface TelegramProcessBirthIdentityOptions {
|
|
20
|
+
platform?: NodeJS.Platform;
|
|
21
|
+
readProcStat?: (pid: number) => string;
|
|
22
|
+
readDarwinProcessStart?: (pid: number) => string;
|
|
23
|
+
}
|
|
24
|
+
export type TelegramProcessBirthProof = {
|
|
25
|
+
status: "proven";
|
|
26
|
+
identity: string;
|
|
27
|
+
} | {
|
|
28
|
+
status: "unverifiable";
|
|
29
|
+
};
|
|
30
|
+
export type TelegramProcessLiveness = "alive" | "dead" | "unverifiable";
|
|
31
|
+
export interface TelegramProcessLivenessOptions extends TelegramProcessBirthIdentityOptions {
|
|
32
|
+
isProcessAlive?: (pid: number) => boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function getTelegramProcessBirthProof(pid: number, options?: TelegramProcessBirthIdentityOptions): TelegramProcessBirthProof;
|
|
35
|
+
export declare function getTelegramProcessBirthIdentity(pid: number, fallbackGeneration: number | string, options?: TelegramProcessBirthIdentityOptions): string;
|
|
36
|
+
export declare function getTelegramProcessLiveness(owner: {
|
|
37
|
+
processId: number;
|
|
38
|
+
processBirthId: string;
|
|
39
|
+
}, options?: TelegramProcessLivenessOptions): TelegramProcessLiveness;
|
|
40
|
+
export declare function getTelegramProcessBirthIdentityLiveness(processBirthId: string, options?: TelegramProcessLivenessOptions): TelegramProcessLiveness;
|
|
41
|
+
export declare function createCurrentTelegramBusProcessRuntime(input: {
|
|
42
|
+
getActiveProfileName: () => string | undefined;
|
|
43
|
+
pid?: number;
|
|
44
|
+
parentPid?: number;
|
|
45
|
+
createdAtMs?: number;
|
|
46
|
+
}): TelegramBusProcessRuntime;
|
|
47
|
+
export declare function createTelegramBusProcessRuntime(input: {
|
|
48
|
+
getActiveProfileName: () => string | undefined;
|
|
49
|
+
pid: number;
|
|
50
|
+
parentPid: number;
|
|
51
|
+
parentProcessIdentity?: string;
|
|
52
|
+
createdAtMs: number;
|
|
53
|
+
}): TelegramBusProcessRuntime;
|
|
54
|
+
export declare function createTelegramBusAuthSecret(): string;
|
|
55
|
+
export declare const TELEGRAM_BUS_PROTOCOL_VERSION: 2;
|
|
56
|
+
export declare const TELEGRAM_BUS_CAPABILITY_DURABLE_FOLLOWER_ADMISSION: "durable-follower-admission-v1";
|
|
57
|
+
export declare const TELEGRAM_BUS_CAPABILITY_QUEUE_HANDOFF: "queue-handoff-v1";
|
|
58
|
+
export declare const TELEGRAM_BUS_CAPABILITY_INPUT_CUSTODY_REFERENCE: "input-custody-reference-v1";
|
|
59
|
+
export declare const TELEGRAM_BUS_CAPABILITY_WORKSPACE_THREAD_RENAME: "workspace-thread-rename-v1";
|
|
60
|
+
export declare const TELEGRAM_BUS_CAPABILITY_THREAD_DISPLAY_MODE: "thread-display-mode-v1";
|
|
61
|
+
export declare const TELEGRAM_BUS_CAPABILITY_DIRECTORY_DISPLAY_FORMAT: "directory-display-format-v1";
|
|
62
|
+
export declare const TELEGRAM_BUS_CAPABILITY_WORKSPACE_FOLLOWER_AUTO_CONNECT: "workspace-follower-auto-connect-v1";
|
|
63
|
+
export interface TelegramBusProtocolIdentity {
|
|
64
|
+
protocolVersion: number;
|
|
65
|
+
runtimeBuild: string;
|
|
66
|
+
capabilities: string[];
|
|
67
|
+
}
|
|
68
|
+
export interface TelegramBusProtocolCompatibility {
|
|
69
|
+
compatible: boolean;
|
|
70
|
+
reason?: "missing-identity" | "version-mismatch" | "missing-capability";
|
|
71
|
+
missingCapabilities: string[];
|
|
72
|
+
}
|
|
73
|
+
export declare function createTelegramBusProtocolIdentity(input: {
|
|
74
|
+
runtimeBuild: string;
|
|
75
|
+
capabilities?: readonly string[];
|
|
76
|
+
}): TelegramBusProtocolIdentity;
|
|
77
|
+
export declare function createTelegramCurrentBusProtocolIdentity(capabilities?: readonly string[]): TelegramBusProtocolIdentity;
|
|
78
|
+
export declare function hasTelegramBusCapability(identity: TelegramBusProtocolIdentity | undefined, capability: string): boolean;
|
|
79
|
+
export declare function getTelegramInputCustodyPeerReadiness(followers: readonly Pick<TelegramBusFollowerView, "registrationGeneration" | "protocol">[]): ("ready" | "legacy" | "unknown")[];
|
|
80
|
+
export declare function getTelegramBusProtocolCompatibility(input: {
|
|
81
|
+
local: TelegramBusProtocolIdentity;
|
|
82
|
+
remote?: TelegramBusProtocolIdentity;
|
|
83
|
+
}): TelegramBusProtocolCompatibility;
|
|
84
|
+
export declare function getTelegramBusSocketPath(agentDir?: string, platform?: NodeJS.Platform, profileName?: string): string;
|
|
85
|
+
export declare function getTelegramBusFollowerSocketPath(instanceId: string, agentDir?: string, platform?: NodeJS.Platform, profileName?: string): string;
|
|
86
|
+
export interface TelegramBusInstanceRegistration {
|
|
87
|
+
instanceId: string;
|
|
88
|
+
previousInstanceId?: string;
|
|
89
|
+
profileKey?: string;
|
|
90
|
+
threadName?: string;
|
|
91
|
+
slot?: string;
|
|
92
|
+
cwd?: string;
|
|
93
|
+
sessionId?: string;
|
|
94
|
+
pid?: number;
|
|
95
|
+
target?: TelegramTarget;
|
|
96
|
+
busSocketPath?: string;
|
|
97
|
+
registrationGeneration?: string;
|
|
98
|
+
protocol?: TelegramBusProtocolIdentity;
|
|
99
|
+
sessionGeneration?: number;
|
|
100
|
+
processBirthId?: string;
|
|
101
|
+
connectedAtMs: number;
|
|
102
|
+
}
|
|
103
|
+
export interface TelegramBusFollowerView extends TelegramBusInstanceRegistration {
|
|
104
|
+
lastHeartbeatMs: number;
|
|
105
|
+
}
|
|
106
|
+
export declare function getTelegramFollowerTargetOwnership(input: {
|
|
107
|
+
target: TelegramTarget;
|
|
108
|
+
followers: readonly TelegramBusFollowerView[];
|
|
109
|
+
activeThreadRecords?: readonly {
|
|
110
|
+
status?: string;
|
|
111
|
+
instanceId?: string;
|
|
112
|
+
profileKey?: string;
|
|
113
|
+
owner?: {
|
|
114
|
+
kind?: string;
|
|
115
|
+
};
|
|
116
|
+
target: TelegramTarget;
|
|
117
|
+
}[];
|
|
118
|
+
currentInstanceId?: string;
|
|
119
|
+
}): {
|
|
120
|
+
instanceId: string;
|
|
121
|
+
ownerGeneration: string;
|
|
122
|
+
recipientBindingKey: string;
|
|
123
|
+
protocolIdentity: TelegramBusProtocolIdentity;
|
|
124
|
+
} | undefined;
|
|
125
|
+
export declare function markTelegramBusAggregateDelivery<T extends Record<string, unknown>>(body: T): T;
|
|
126
|
+
export declare function isTelegramBusAggregateDelivery(body: unknown): boolean;
|
|
127
|
+
export declare function markTelegramBusCrossTargetDelivery<T extends Record<string, unknown>>(body: T): T;
|
|
128
|
+
export declare function isTelegramBusCrossTargetDelivery(body: unknown): boolean;
|
|
129
|
+
export declare function stripTelegramBusApiMetadata<T extends Record<string, unknown>>(body: T): T;
|
|
130
|
+
export declare function isTelegramFollowerApiCallAllowed(input: {
|
|
131
|
+
follower: TelegramBusFollowerView;
|
|
132
|
+
method: string;
|
|
133
|
+
args: unknown[];
|
|
134
|
+
isMessageOwned?: (chatId: number, messageId: number) => boolean;
|
|
135
|
+
}): boolean;
|
|
136
|
+
export interface TelegramFollowerApiCallAuthorizationInput {
|
|
137
|
+
follower: TelegramBusFollowerView;
|
|
138
|
+
method: string;
|
|
139
|
+
args: unknown[];
|
|
140
|
+
}
|
|
141
|
+
export declare function createTelegramFollowerApiCallAuthorizer(deps: {
|
|
142
|
+
isMessageOwned(input: {
|
|
143
|
+
chatId: number;
|
|
144
|
+
messageId: number;
|
|
145
|
+
follower: TelegramBusFollowerView;
|
|
146
|
+
}): boolean;
|
|
147
|
+
}): (input: TelegramFollowerApiCallAuthorizationInput) => boolean;
|
|
148
|
+
export interface TelegramBusAgentTargetSelector {
|
|
149
|
+
chatId?: number;
|
|
150
|
+
threadId?: number;
|
|
151
|
+
threadName?: string;
|
|
152
|
+
}
|
|
153
|
+
export interface TelegramBusAgentMessage {
|
|
154
|
+
target: TelegramTarget & {
|
|
155
|
+
threadId: number;
|
|
156
|
+
};
|
|
157
|
+
messageId: number;
|
|
158
|
+
text: string;
|
|
159
|
+
}
|
|
160
|
+
export interface TelegramBusFollowerDeliveryIdentity {
|
|
161
|
+
deliveryId: string;
|
|
162
|
+
sourceUpdateId: number;
|
|
163
|
+
recipientBindingKey: string;
|
|
164
|
+
sourceRecoveryKey?: string;
|
|
165
|
+
sourceClaim?: {
|
|
166
|
+
acquisitionId: string;
|
|
167
|
+
handoffId: string;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
export type TelegramBusForeignUpdateFailureClass = "source-update-identity-missing" | "recipient-binding-missing" | "recipient-generation-missing" | "source-reference-missing" | "recipient-ownership-stale" | "transport-failed" | "acknowledgement-missing" | "acknowledgement-rejected" | "acknowledgement-mismatched" | "durable-receipt-missing" | "durable-receipt-mismatched";
|
|
171
|
+
export type TelegramBusForeignUpdateSettlement = {
|
|
172
|
+
status: "accepted";
|
|
173
|
+
delivery: TelegramBusFollowerDeliveryIdentity;
|
|
174
|
+
} | {
|
|
175
|
+
status: "retryable" | "terminal-rejected";
|
|
176
|
+
failureClass: TelegramBusForeignUpdateFailureClass;
|
|
177
|
+
message: string;
|
|
178
|
+
delivery?: TelegramBusFollowerDeliveryIdentity;
|
|
179
|
+
sourceUpdateId?: number;
|
|
180
|
+
};
|
|
181
|
+
export declare function createTelegramBusFollowerDeliveryIdentity(input: {
|
|
182
|
+
kind: "leader.forwardCallback" | "leader.forwardReaction" | "leader.forwardMessage" | "leader.forwardEditedMessage" | "leader.wakeInputCustody";
|
|
183
|
+
recipientBindingKey: string;
|
|
184
|
+
sourceUpdateId: number;
|
|
185
|
+
sourceRecoveryKey?: string;
|
|
186
|
+
sourceClaim?: {
|
|
187
|
+
acquisitionId: string;
|
|
188
|
+
handoffId: string;
|
|
189
|
+
};
|
|
190
|
+
}): TelegramBusFollowerDeliveryIdentity;
|
|
191
|
+
export declare function canUseTelegramBusInputCustodyReference(input: {
|
|
192
|
+
local?: TelegramBusProtocolIdentity;
|
|
193
|
+
remote?: TelegramBusProtocolIdentity;
|
|
194
|
+
}): boolean;
|
|
195
|
+
export declare function createTelegramBusFollowerSourceReferenceDeliveryIdentity(input: {
|
|
196
|
+
kind: "leader.forwardCallback" | "leader.forwardReaction" | "leader.forwardMessage" | "leader.forwardEditedMessage" | "leader.wakeInputCustody";
|
|
197
|
+
recipientBindingKey: string;
|
|
198
|
+
sourceRecoveryKey: string;
|
|
199
|
+
source: {
|
|
200
|
+
updateId: number;
|
|
201
|
+
owner: {
|
|
202
|
+
acquisitionId: string;
|
|
203
|
+
handoffId?: string;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
}): TelegramBusFollowerDeliveryIdentity;
|
|
207
|
+
export type TelegramBusEnvelope = ({
|
|
208
|
+
kind: "follower.register";
|
|
209
|
+
requestId: string;
|
|
210
|
+
registration: TelegramBusInstanceRegistration;
|
|
211
|
+
} | {
|
|
212
|
+
kind: "follower.restoreWorkspace";
|
|
213
|
+
requestId: string;
|
|
214
|
+
registration: TelegramBusInstanceRegistration;
|
|
215
|
+
} | {
|
|
216
|
+
kind: "follower.heartbeat";
|
|
217
|
+
requestId: string;
|
|
218
|
+
instanceId: string;
|
|
219
|
+
registrationGeneration?: string;
|
|
220
|
+
sentAtMs: number;
|
|
221
|
+
} | {
|
|
222
|
+
kind: "follower.disconnect";
|
|
223
|
+
requestId: string;
|
|
224
|
+
instanceId: string;
|
|
225
|
+
registrationGeneration?: string;
|
|
226
|
+
sentAtMs: number;
|
|
227
|
+
} | {
|
|
228
|
+
kind: "follower.setThreadDisplayMode";
|
|
229
|
+
requestId: string;
|
|
230
|
+
instanceId: string;
|
|
231
|
+
registrationGeneration: string;
|
|
232
|
+
mode: TelegramThreadDisplayMode;
|
|
233
|
+
} | {
|
|
234
|
+
kind: "follower.renameThread";
|
|
235
|
+
requestId: string;
|
|
236
|
+
instanceId: string;
|
|
237
|
+
registrationGeneration: string;
|
|
238
|
+
target: TelegramTarget & {
|
|
239
|
+
threadId: number;
|
|
240
|
+
};
|
|
241
|
+
threadName: string;
|
|
242
|
+
sentAtMs: number;
|
|
243
|
+
} | {
|
|
244
|
+
kind: "follower.resetThreadName";
|
|
245
|
+
requestId: string;
|
|
246
|
+
instanceId: string;
|
|
247
|
+
registrationGeneration: string;
|
|
248
|
+
target: TelegramTarget & {
|
|
249
|
+
threadId: number;
|
|
250
|
+
};
|
|
251
|
+
sentAtMs: number;
|
|
252
|
+
} | {
|
|
253
|
+
kind: "leader.forwardCallback";
|
|
254
|
+
requestId: string;
|
|
255
|
+
recipientInstanceId: string;
|
|
256
|
+
recipientRegistrationGeneration: string;
|
|
257
|
+
delivery: TelegramBusFollowerDeliveryIdentity;
|
|
258
|
+
query: unknown;
|
|
259
|
+
sentAtMs: number;
|
|
260
|
+
} | {
|
|
261
|
+
kind: "leader.forwardReaction";
|
|
262
|
+
requestId: string;
|
|
263
|
+
recipientInstanceId: string;
|
|
264
|
+
recipientRegistrationGeneration: string;
|
|
265
|
+
delivery: TelegramBusFollowerDeliveryIdentity;
|
|
266
|
+
reactionUpdate: unknown;
|
|
267
|
+
sentAtMs: number;
|
|
268
|
+
} | {
|
|
269
|
+
kind: "leader.forwardMessage";
|
|
270
|
+
requestId: string;
|
|
271
|
+
recipientInstanceId: string;
|
|
272
|
+
recipientRegistrationGeneration: string;
|
|
273
|
+
delivery: TelegramBusFollowerDeliveryIdentity;
|
|
274
|
+
message: unknown;
|
|
275
|
+
forwardCommentBatchPosition?: "comment" | "forward";
|
|
276
|
+
sentAtMs: number;
|
|
277
|
+
} | {
|
|
278
|
+
kind: "leader.forwardEditedMessage";
|
|
279
|
+
requestId: string;
|
|
280
|
+
recipientInstanceId: string;
|
|
281
|
+
recipientRegistrationGeneration: string;
|
|
282
|
+
delivery: TelegramBusFollowerDeliveryIdentity;
|
|
283
|
+
message: unknown;
|
|
284
|
+
sentAtMs: number;
|
|
285
|
+
} | {
|
|
286
|
+
kind: "leader.offerInputCustodyHandoff";
|
|
287
|
+
requestId: string;
|
|
288
|
+
recipientInstanceId: string;
|
|
289
|
+
recipientRegistrationGeneration: string;
|
|
290
|
+
recipientBindingKey: string;
|
|
291
|
+
sourceRecoveryKey: string;
|
|
292
|
+
source: {
|
|
293
|
+
journalBindingKey: string;
|
|
294
|
+
tokenSha256: string;
|
|
295
|
+
updateId: number;
|
|
296
|
+
};
|
|
297
|
+
handoffId: string;
|
|
298
|
+
sentAtMs: number;
|
|
299
|
+
} | {
|
|
300
|
+
kind: "leader.wakeInputCustody";
|
|
301
|
+
requestId: string;
|
|
302
|
+
recipientInstanceId: string;
|
|
303
|
+
recipientRegistrationGeneration: string;
|
|
304
|
+
delivery: TelegramBusFollowerDeliveryIdentity;
|
|
305
|
+
sentAtMs: number;
|
|
306
|
+
} | {
|
|
307
|
+
kind: "leader.replaceFollowerTarget";
|
|
308
|
+
requestId: string;
|
|
309
|
+
recipientInstanceId: string;
|
|
310
|
+
recipientRegistrationGeneration?: string;
|
|
311
|
+
target: TelegramTarget & {
|
|
312
|
+
threadId: number;
|
|
313
|
+
};
|
|
314
|
+
oldTarget?: TelegramTarget & {
|
|
315
|
+
threadId: number;
|
|
316
|
+
};
|
|
317
|
+
reason: "thread-restore";
|
|
318
|
+
sentAtMs: number;
|
|
319
|
+
} | {
|
|
320
|
+
kind: "leader.offerQueueHandoff";
|
|
321
|
+
requestId: string;
|
|
322
|
+
recipientInstanceId: string;
|
|
323
|
+
recipientRegistrationGeneration: string;
|
|
324
|
+
donorInstanceId: string;
|
|
325
|
+
donorProcessId: number;
|
|
326
|
+
donorProcessBirthId: string;
|
|
327
|
+
donorSessionGeneration: number;
|
|
328
|
+
donorAcquisitionId: string;
|
|
329
|
+
donorAcquiredAtMs: number;
|
|
330
|
+
handoffToken: string;
|
|
331
|
+
payload: TelegramQueueHandoffPayload;
|
|
332
|
+
sentAtMs: number;
|
|
333
|
+
} | {
|
|
334
|
+
kind: "follower.offerQueueHandoff";
|
|
335
|
+
requestId: string;
|
|
336
|
+
instanceId: string;
|
|
337
|
+
registrationGeneration: string;
|
|
338
|
+
recipientInstanceId: string;
|
|
339
|
+
recipientRegistrationGeneration: string;
|
|
340
|
+
donorProcessId: number;
|
|
341
|
+
donorProcessBirthId: string;
|
|
342
|
+
donorSessionGeneration: number;
|
|
343
|
+
donorAcquisitionId: string;
|
|
344
|
+
donorAcquiredAtMs: number;
|
|
345
|
+
handoffToken: string;
|
|
346
|
+
payload: TelegramQueueHandoffPayload;
|
|
347
|
+
sentAtMs: number;
|
|
348
|
+
} | {
|
|
349
|
+
kind: "follower.resolveAgentTarget";
|
|
350
|
+
requestId: string;
|
|
351
|
+
instanceId: string;
|
|
352
|
+
registrationGeneration?: string;
|
|
353
|
+
selector: TelegramBusAgentTargetSelector;
|
|
354
|
+
sentAtMs: number;
|
|
355
|
+
} | {
|
|
356
|
+
kind: "follower.routeAgentMessage";
|
|
357
|
+
requestId: string;
|
|
358
|
+
instanceId: string;
|
|
359
|
+
registrationGeneration?: string;
|
|
360
|
+
message: TelegramBusAgentMessage;
|
|
361
|
+
sentAtMs: number;
|
|
362
|
+
} | {
|
|
363
|
+
kind: "follower.callApi";
|
|
364
|
+
requestId: string;
|
|
365
|
+
instanceId: string;
|
|
366
|
+
registrationGeneration?: string;
|
|
367
|
+
method: string;
|
|
368
|
+
args: unknown[];
|
|
369
|
+
sentAtMs: number;
|
|
370
|
+
} | {
|
|
371
|
+
kind: "bus.ack";
|
|
372
|
+
requestId: string;
|
|
373
|
+
ok: boolean;
|
|
374
|
+
message?: string;
|
|
375
|
+
result?: unknown;
|
|
376
|
+
protocol?: TelegramBusProtocolIdentity;
|
|
377
|
+
error?: {
|
|
378
|
+
code: "commit-unknown" | "request-id-collision" | "ledger-overloaded" | "incompatible-protocol" | "stale-target" | "workspace-binding-unavailable";
|
|
379
|
+
method?: string;
|
|
380
|
+
chatId?: number;
|
|
381
|
+
threadId?: number;
|
|
382
|
+
};
|
|
383
|
+
}) & {
|
|
384
|
+
auth?: string;
|
|
385
|
+
};
|
|
386
|
+
export type TelegramBusEnvelopeTrafficClass = "bootstrap" | "generation-fenced" | "response";
|
|
387
|
+
export declare function getTelegramBusEnvelopeTrafficClass(envelope: TelegramBusEnvelope): TelegramBusEnvelopeTrafficClass;
|
|
388
|
+
export declare function createTelegramBusRequestId(input: {
|
|
389
|
+
instanceId: string;
|
|
390
|
+
sequence: number;
|
|
391
|
+
}): string;
|
|
392
|
+
export declare function createTelegramBusRequestIdFactory(instanceId: string): () => string;
|
|
393
|
+
export declare function encodeTelegramBusEnvelope(envelope: TelegramBusEnvelope): string;
|
|
394
|
+
export declare function parseTelegramBusEnvelope(line: string): TelegramBusEnvelope | undefined;
|
|
395
|
+
export interface TelegramBusLocalServer {
|
|
396
|
+
start: () => Promise<void>;
|
|
397
|
+
stop: () => Promise<void>;
|
|
398
|
+
ensureEndpoint: () => Promise<boolean>;
|
|
399
|
+
}
|
|
400
|
+
export type TelegramBusSocketPathSource = string | (() => string);
|
|
401
|
+
export declare function resolveTelegramBusSocketPath(source: TelegramBusSocketPathSource, platform?: NodeJS.Platform | string): string;
|
|
402
|
+
export interface TelegramBusLocalServerDeps {
|
|
403
|
+
socketPath: TelegramBusSocketPathSource;
|
|
404
|
+
handleEnvelope: (envelope: TelegramBusEnvelope) => Promise<TelegramBusEnvelope | undefined> | TelegramBusEnvelope | undefined;
|
|
405
|
+
recordTransportEvent?: TelegramBusTransportEventRecorder;
|
|
406
|
+
beforeEndpointPublication?: () => Promise<void> | void;
|
|
407
|
+
commitEndpointPublication?: (commit: () => void) => boolean;
|
|
408
|
+
requestLedgerMaxEntries?: number;
|
|
409
|
+
shouldDropResponse?: (request: TelegramBusEnvelope, response: TelegramBusEnvelope) => boolean;
|
|
410
|
+
}
|
|
411
|
+
export interface TelegramBusLocalClientOptions {
|
|
412
|
+
socketPath: string;
|
|
413
|
+
envelope: TelegramBusEnvelope;
|
|
414
|
+
timeoutMs?: number;
|
|
415
|
+
retry?: TelegramBusTransportRetryPolicy;
|
|
416
|
+
recordTransportEvent?: TelegramBusTransportEventRecorder;
|
|
417
|
+
}
|
|
418
|
+
export interface TelegramBusForeignOwnedForwarderDeps<TMessage = unknown> {
|
|
419
|
+
socketPath: TelegramBusSocketPathSource;
|
|
420
|
+
createRequestId: () => string;
|
|
421
|
+
getNowMs?: () => number;
|
|
422
|
+
timeoutMs?: number;
|
|
423
|
+
getAuthSecret?: () => string | undefined;
|
|
424
|
+
getForwardCommentBatchPosition?: (message: TMessage) => "comment" | "forward" | undefined;
|
|
425
|
+
localProtocolIdentity?: TelegramBusProtocolIdentity;
|
|
426
|
+
validateForwardOwnership?: (ownership: TelegramBusForwardOwnership) => boolean;
|
|
427
|
+
resolveInputCustodyReference?: (input: {
|
|
428
|
+
sourceUpdateId: number;
|
|
429
|
+
recipientBindingKey: string;
|
|
430
|
+
}) => {
|
|
431
|
+
sourceRecoveryKey: string;
|
|
432
|
+
source: {
|
|
433
|
+
updateId: number;
|
|
434
|
+
owner: {
|
|
435
|
+
acquisitionId: string;
|
|
436
|
+
handoffId?: string;
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
} | undefined;
|
|
440
|
+
recordRuntimeEvent?: (category: string, error: unknown, details?: Record<string, unknown>) => void;
|
|
441
|
+
}
|
|
442
|
+
export interface TelegramBusForwardOwnership {
|
|
443
|
+
instanceId: string;
|
|
444
|
+
ownerGeneration?: string;
|
|
445
|
+
recipientBindingKey?: string;
|
|
446
|
+
protocolIdentity?: TelegramBusProtocolIdentity;
|
|
447
|
+
}
|
|
448
|
+
export declare function isTelegramBusForwardOwnershipCurrent(expected: TelegramBusForwardOwnership, current: TelegramBusForwardOwnership | undefined): boolean;
|
|
449
|
+
export declare function createTelegramBusForeignOwnedUpdateForwarder<TContext, TReactionUpdate, TCallbackQuery, TMessage = unknown>(deps: TelegramBusForeignOwnedForwarderDeps<TMessage>): {
|
|
450
|
+
forwardCallback: (input: {
|
|
451
|
+
query: TCallbackQuery;
|
|
452
|
+
ownership: TelegramBusForwardOwnership;
|
|
453
|
+
ctx: TContext;
|
|
454
|
+
}) => Promise<TelegramBusForeignUpdateSettlement>;
|
|
455
|
+
forwardReaction: (input: {
|
|
456
|
+
reactionUpdate: TReactionUpdate;
|
|
457
|
+
ownership: TelegramBusForwardOwnership;
|
|
458
|
+
ctx: TContext;
|
|
459
|
+
}) => Promise<TelegramBusForeignUpdateSettlement>;
|
|
460
|
+
forwardMessage: (input: {
|
|
461
|
+
message: TMessage;
|
|
462
|
+
ownership: TelegramBusForwardOwnership;
|
|
463
|
+
ctx: TContext;
|
|
464
|
+
}) => Promise<TelegramBusForeignUpdateSettlement>;
|
|
465
|
+
forwardEditedMessage: (input: {
|
|
466
|
+
message: TMessage;
|
|
467
|
+
ownership: TelegramBusForwardOwnership;
|
|
468
|
+
ctx: TContext;
|
|
469
|
+
}) => Promise<TelegramBusForeignUpdateSettlement>;
|
|
470
|
+
};
|
|
471
|
+
export interface TelegramBusFollowerThreadRestoreHandlerDeps {
|
|
472
|
+
followerRegistry: Pick<TelegramBusFollowerRegistry, "get" | "register">;
|
|
473
|
+
followerTargetController: ReturnType<typeof createTelegramBusFollowerTargetController>;
|
|
474
|
+
onRestored?: () => void;
|
|
475
|
+
}
|
|
476
|
+
export declare function listTelegramBusLiveThreadTargets(input: {
|
|
477
|
+
leaderTarget?: TelegramTarget;
|
|
478
|
+
followers: readonly TelegramBusFollowerView[];
|
|
479
|
+
}): TelegramTarget[];
|
|
480
|
+
export declare function createTelegramBusFollowerTargetController(deps: TelegramBusForeignOwnedForwarderDeps): {
|
|
481
|
+
replaceTarget: (input: {
|
|
482
|
+
follower: TelegramBusFollowerView;
|
|
483
|
+
target: TelegramTarget & {
|
|
484
|
+
threadId: number;
|
|
485
|
+
};
|
|
486
|
+
oldTarget?: TelegramTarget & {
|
|
487
|
+
threadId: number;
|
|
488
|
+
};
|
|
489
|
+
reason: "thread-restore";
|
|
490
|
+
}) => Promise<boolean>;
|
|
491
|
+
};
|
|
492
|
+
export declare function createTelegramBusFollowerThreadRestoreHandler(deps: TelegramBusFollowerThreadRestoreHandlerDeps): (input: {
|
|
493
|
+
record: {
|
|
494
|
+
instanceId?: string;
|
|
495
|
+
};
|
|
496
|
+
target: TelegramTarget & {
|
|
497
|
+
threadId: number;
|
|
498
|
+
};
|
|
499
|
+
oldTarget?: TelegramTarget & {
|
|
500
|
+
threadId: number;
|
|
501
|
+
};
|
|
502
|
+
}) => Promise<boolean>;
|
|
503
|
+
export declare function isTelegramBusEnvelopeAuthorized(envelope: TelegramBusEnvelope, secret: string | undefined): boolean;
|
|
504
|
+
export declare function createUnauthorizedBusAck(requestId: string): TelegramBusEnvelope;
|
|
505
|
+
export declare function createTelegramBusLocalServer(deps: TelegramBusLocalServerDeps): TelegramBusLocalServer;
|
|
506
|
+
export declare function sendTelegramBusLocalEnvelope(options: TelegramBusLocalClientOptions): Promise<TelegramBusEnvelope | undefined>;
|
|
507
|
+
export interface TelegramBusFollowerRegistry {
|
|
508
|
+
register: (registration: TelegramBusInstanceRegistration) => TelegramBusFollowerView;
|
|
509
|
+
heartbeat: (instanceId: string, nowMs: number) => TelegramBusFollowerView | undefined;
|
|
510
|
+
get: (instanceId: string) => TelegramBusFollowerView | undefined;
|
|
511
|
+
getByTarget: (target: TelegramTarget) => TelegramBusFollowerView | undefined;
|
|
512
|
+
list: () => TelegramBusFollowerView[];
|
|
513
|
+
remove: (instanceId: string) => boolean;
|
|
514
|
+
clear: () => void;
|
|
515
|
+
pruneStale: (nowMs: number, staleAfterMs: number) => TelegramBusFollowerView[];
|
|
516
|
+
}
|
|
517
|
+
export declare function createTelegramBusForwardOwnershipValidator(registry: Pick<TelegramBusFollowerRegistry, "get">): (ownership: TelegramBusForwardOwnership) => boolean;
|
|
518
|
+
export declare function createTelegramBusFollowerRegistry(): TelegramBusFollowerRegistry;
|