@llblab/pi-telegram 0.46.0 → 0.47.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/BACKLOG.md +0 -1
- package/CHANGELOG.md +8 -0
- package/README.md +2 -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 +1608 -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 +116 -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 +1006 -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/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 +4 -2
- package/docs/outbound.md +1 -1
- package/docs/public-api.md +2 -2
- 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 +19 -0
- package/lib/generative-apps.ts +379 -13
- package/lib/menu-settings.ts +21 -5
- package/lib/outbound-markup.ts +16 -7
- 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/telegram-bridge/SKILL.md +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram bus local transport boundary
|
|
3
|
+
* Zones: multi-instance bus, IPC transport, Windows named pipes, Unix sockets
|
|
4
|
+
* Owns endpoint derivation, transport-kind detection, retry/error classification, and small timing policy.
|
|
5
|
+
*/
|
|
6
|
+
export type TelegramBusTransportKind = "pipe" | "socket";
|
|
7
|
+
export type TelegramBusTransportEventRecorder = (phase: string, details: Record<string, unknown>) => void;
|
|
8
|
+
export type TelegramBusTransportEndpointDiagnostics = Record<string, unknown> & {
|
|
9
|
+
endpoint: string;
|
|
10
|
+
transport: TelegramBusTransportKind;
|
|
11
|
+
};
|
|
12
|
+
export interface TelegramBusTransportRetryPolicy {
|
|
13
|
+
attempts: number;
|
|
14
|
+
delayMs: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TelegramBusTransportRetryPolicyOverrides {
|
|
17
|
+
attempts?: number;
|
|
18
|
+
delayMs?: number;
|
|
19
|
+
}
|
|
20
|
+
export type TelegramBusTransportOperation = "registration" | "operation";
|
|
21
|
+
export declare const TELEGRAM_BUS_REGISTRATION_RETRY: TelegramBusTransportRetryPolicy;
|
|
22
|
+
export declare const TELEGRAM_BUS_OPERATION_RETRY: TelegramBusTransportRetryPolicy;
|
|
23
|
+
export declare function getTelegramBusPipePath(input: {
|
|
24
|
+
agentDir: string;
|
|
25
|
+
scope: string;
|
|
26
|
+
}): string;
|
|
27
|
+
export declare function isTelegramBusPipePath(endpoint: string): boolean;
|
|
28
|
+
export declare function getTelegramBusTransportKind(endpoint: string): TelegramBusTransportKind;
|
|
29
|
+
export declare function getTelegramBusEndpointDiagnostics(endpoint: string): TelegramBusTransportEndpointDiagnostics;
|
|
30
|
+
export declare function getTelegramBusTransportRetryPolicy(input: {
|
|
31
|
+
endpoint: string;
|
|
32
|
+
operation: TelegramBusTransportOperation;
|
|
33
|
+
overrides?: TelegramBusTransportRetryPolicyOverrides;
|
|
34
|
+
}): TelegramBusTransportRetryPolicy | undefined;
|
|
35
|
+
export declare function getTelegramBusLeaderEndpoint(input: {
|
|
36
|
+
agentDir: string;
|
|
37
|
+
platform: NodeJS.Platform | string;
|
|
38
|
+
profileName?: string;
|
|
39
|
+
}): string;
|
|
40
|
+
export declare function getTelegramBusFollowerEndpoint(input: {
|
|
41
|
+
agentDir: string;
|
|
42
|
+
platform: NodeJS.Platform | string;
|
|
43
|
+
instanceId: string;
|
|
44
|
+
profileName?: string;
|
|
45
|
+
}): string;
|
|
46
|
+
export interface TelegramBusTransportErrorInfo {
|
|
47
|
+
message: string;
|
|
48
|
+
code?: string;
|
|
49
|
+
syscall?: string;
|
|
50
|
+
kind: "connect" | "timeout" | "auth" | "protocol" | "unknown";
|
|
51
|
+
retryable: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare function classifyTelegramBusTransportError(error: unknown): TelegramBusTransportErrorInfo;
|
|
54
|
+
export declare function isRetryableTelegramBusTransportError(error: unknown): boolean;
|
|
55
|
+
export declare function createTelegramBusTransportTimeoutError(message: string): NodeJS.ErrnoException;
|
|
56
|
+
export declare function delayTelegramBusTransportRetry(ms: number): Promise<void>;
|
|
57
|
+
export interface TelegramBusTransportProbeResult extends TelegramBusTransportEndpointDiagnostics {
|
|
58
|
+
reachable: boolean;
|
|
59
|
+
error?: TelegramBusTransportErrorInfo;
|
|
60
|
+
}
|
|
61
|
+
export declare function probeTelegramBusEndpoint(input: {
|
|
62
|
+
endpoint: string;
|
|
63
|
+
timeoutMs?: number;
|
|
64
|
+
}): Promise<TelegramBusTransportProbeResult>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram bus local transport boundary
|
|
3
|
+
* Zones: multi-instance bus, IPC transport, Windows named pipes, Unix sockets
|
|
4
|
+
* Owns endpoint derivation, transport-kind detection, retry/error classification, and small timing policy.
|
|
5
|
+
*/
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { createConnection } from "node:net";
|
|
8
|
+
import { join, resolve } from "node:path";
|
|
9
|
+
export const TELEGRAM_BUS_REGISTRATION_RETRY = {
|
|
10
|
+
attempts: 10,
|
|
11
|
+
delayMs: 150,
|
|
12
|
+
};
|
|
13
|
+
export const TELEGRAM_BUS_OPERATION_RETRY = {
|
|
14
|
+
attempts: 3,
|
|
15
|
+
delayMs: 100,
|
|
16
|
+
};
|
|
17
|
+
export function getTelegramBusPipePath(input) {
|
|
18
|
+
const digest = createHash("sha256")
|
|
19
|
+
.update(resolve(input.agentDir))
|
|
20
|
+
.digest("base64url")
|
|
21
|
+
.slice(0, 16);
|
|
22
|
+
const scope = input.scope.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 80);
|
|
23
|
+
return `\\\\.\\pipe\\pi-telegram-${digest}-${scope}`;
|
|
24
|
+
}
|
|
25
|
+
export function isTelegramBusPipePath(endpoint) {
|
|
26
|
+
return /^\\\\[.?]\\pipe\\/i.test(endpoint);
|
|
27
|
+
}
|
|
28
|
+
export function getTelegramBusTransportKind(endpoint) {
|
|
29
|
+
return isTelegramBusPipePath(endpoint) ? "pipe" : "socket";
|
|
30
|
+
}
|
|
31
|
+
export function getTelegramBusEndpointDiagnostics(endpoint) {
|
|
32
|
+
return {
|
|
33
|
+
endpoint,
|
|
34
|
+
transport: getTelegramBusTransportKind(endpoint),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function getTelegramBusTransportRetryPolicy(input) {
|
|
38
|
+
const base = input.operation === "registration"
|
|
39
|
+
? TELEGRAM_BUS_REGISTRATION_RETRY
|
|
40
|
+
: isTelegramBusPipePath(input.endpoint)
|
|
41
|
+
? TELEGRAM_BUS_OPERATION_RETRY
|
|
42
|
+
: undefined;
|
|
43
|
+
if (!base && !input.overrides)
|
|
44
|
+
return undefined;
|
|
45
|
+
return {
|
|
46
|
+
attempts: Math.max(1, input.overrides?.attempts ?? base?.attempts ?? 1),
|
|
47
|
+
delayMs: Math.max(0, input.overrides?.delayMs ?? base?.delayMs ?? 0),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function normalizeTelegramBusEndpointScope(value) {
|
|
51
|
+
return value.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 80);
|
|
52
|
+
}
|
|
53
|
+
export function getTelegramBusLeaderEndpoint(input) {
|
|
54
|
+
const profileScope = input.profileName
|
|
55
|
+
? normalizeTelegramBusEndpointScope(input.profileName)
|
|
56
|
+
: undefined;
|
|
57
|
+
return input.platform === "win32"
|
|
58
|
+
? getTelegramBusPipePath({
|
|
59
|
+
agentDir: input.agentDir,
|
|
60
|
+
scope: profileScope ? `bus-${profileScope}` : "bus",
|
|
61
|
+
})
|
|
62
|
+
: join(input.agentDir, "tmp", "telegram", profileScope ? `bus.${profileScope}.sock` : "bus.sock");
|
|
63
|
+
}
|
|
64
|
+
export function getTelegramBusFollowerEndpoint(input) {
|
|
65
|
+
const instanceScope = normalizeTelegramBusEndpointScope(input.instanceId);
|
|
66
|
+
const profileScope = input.profileName
|
|
67
|
+
? normalizeTelegramBusEndpointScope(input.profileName)
|
|
68
|
+
: undefined;
|
|
69
|
+
return input.platform === "win32"
|
|
70
|
+
? getTelegramBusPipePath({
|
|
71
|
+
agentDir: input.agentDir,
|
|
72
|
+
scope: profileScope
|
|
73
|
+
? `follower-${profileScope}-${instanceScope}`
|
|
74
|
+
: `follower-${instanceScope}`,
|
|
75
|
+
})
|
|
76
|
+
: join(input.agentDir, "tmp", "telegram", "followers", ...(profileScope ? [profileScope] : []), `${instanceScope}.sock`);
|
|
77
|
+
}
|
|
78
|
+
export function classifyTelegramBusTransportError(error) {
|
|
79
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
80
|
+
const maybeNodeError = error;
|
|
81
|
+
const code = typeof maybeNodeError?.code === "string" ? maybeNodeError.code : undefined;
|
|
82
|
+
const syscall = typeof maybeNodeError?.syscall === "string"
|
|
83
|
+
? maybeNodeError.syscall
|
|
84
|
+
: undefined;
|
|
85
|
+
const timeout = code === "ETIMEDOUT" || /timed out/i.test(message);
|
|
86
|
+
const retryable = code === "ENOENT" ||
|
|
87
|
+
code === "ECONNREFUSED" ||
|
|
88
|
+
code === "EPIPE" ||
|
|
89
|
+
code === "ECONNRESET" ||
|
|
90
|
+
code === "EBUSY" ||
|
|
91
|
+
timeout;
|
|
92
|
+
const kind = timeout
|
|
93
|
+
? "timeout"
|
|
94
|
+
: code === "ENOENT" || code === "ECONNREFUSED"
|
|
95
|
+
? "connect"
|
|
96
|
+
: "unknown";
|
|
97
|
+
return { message, code, syscall, kind, retryable };
|
|
98
|
+
}
|
|
99
|
+
export function isRetryableTelegramBusTransportError(error) {
|
|
100
|
+
return classifyTelegramBusTransportError(error).retryable;
|
|
101
|
+
}
|
|
102
|
+
export function createTelegramBusTransportTimeoutError(message) {
|
|
103
|
+
const error = new Error(message);
|
|
104
|
+
error.code = "ETIMEDOUT";
|
|
105
|
+
return error;
|
|
106
|
+
}
|
|
107
|
+
export function delayTelegramBusTransportRetry(ms) {
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
setTimeout(resolve, ms);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export function probeTelegramBusEndpoint(input) {
|
|
113
|
+
const timeoutMs = input.timeoutMs ?? 250;
|
|
114
|
+
const diagnostics = getTelegramBusEndpointDiagnostics(input.endpoint);
|
|
115
|
+
return new Promise((resolve) => {
|
|
116
|
+
const socket = createConnection(input.endpoint);
|
|
117
|
+
let settled = false;
|
|
118
|
+
const settle = (result) => {
|
|
119
|
+
if (settled)
|
|
120
|
+
return;
|
|
121
|
+
settled = true;
|
|
122
|
+
clearTimeout(timeout);
|
|
123
|
+
socket.destroy();
|
|
124
|
+
resolve(result);
|
|
125
|
+
};
|
|
126
|
+
const timeout = setTimeout(() => {
|
|
127
|
+
settle({
|
|
128
|
+
...diagnostics,
|
|
129
|
+
reachable: false,
|
|
130
|
+
error: classifyTelegramBusTransportError(createTelegramBusTransportTimeoutError("Timed out probing Telegram bus endpoint")),
|
|
131
|
+
});
|
|
132
|
+
}, timeoutMs);
|
|
133
|
+
socket.once("connect", () => settle({ ...diagnostics, reachable: true }));
|
|
134
|
+
socket.once("error", (error) => settle({
|
|
135
|
+
...diagnostics,
|
|
136
|
+
reachable: false,
|
|
137
|
+
error: classifyTelegramBusTransportError(error),
|
|
138
|
+
}));
|
|
139
|
+
});
|
|
140
|
+
}
|