@diegoaltoworks/chatter 0.54.2 → 0.55.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/README.md +2 -1
- package/dist/channels/telegram/api.d.ts +122 -0
- package/dist/channels/telegram/api.d.ts.map +1 -0
- package/dist/channels/telegram/channel.d.ts +80 -0
- package/dist/channels/telegram/channel.d.ts.map +1 -0
- package/dist/channels/telegram/index.d.ts +26 -0
- package/dist/channels/telegram/index.d.ts.map +1 -0
- package/dist/channels/telegram/index.js +690 -0
- package/dist/channels/telegram/index.mjs +647 -0
- package/dist/channels/telegram/poll.d.ts +47 -0
- package/dist/channels/telegram/poll.d.ts.map +1 -0
- package/dist/channels/telegram/updates.d.ts +63 -0
- package/dist/channels/telegram/updates.d.ts.map +1 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
- ⚡ **High Performance**: Built on Hono with streaming support
|
|
27
27
|
- 🛡️ **Security First**: Rate limiting, CORS, referrer checking, and input guardrails
|
|
28
28
|
- 💸 **Usage Metering**: Per-caller and global daily caps for paid features, multi-instance safe, via `@diegoaltoworks/chatter/usage` ([guide](./docs/usage.md))
|
|
29
|
-
- 💬 **Channels**: Built-in WhatsApp
|
|
29
|
+
- 💬 **Channels**: Built-in WhatsApp and Telegram transports plus a Channel SPI for plugging in any other one — allowlist/mute gates, reply rate-limiting, and a shared inbound pipeline every channel reuses ([WhatsApp](./docs/channels.md), [Telegram](./docs/telegram.md), [build your own](./docs/build-a-channel.md))
|
|
30
30
|
- 🧩 **Flows**: Multi-turn, schema-driven slot-filling for structured conversations, with hybrid keyword + LLM intent matching ([guide](./docs/flows.md))
|
|
31
31
|
- 🖼️ **Images**: On-demand generation and editing with cache-before-spend ordering and optional Cloudinary upload ([guide](./docs/images.md))
|
|
32
32
|
- 🎭 **Personas**: Windowed, per-contact prompt layers and named greetings from a JSON registry ([guide](./docs/personas.md))
|
|
@@ -102,6 +102,7 @@ Complete guides for setup, deployment, and integration — see
|
|
|
102
102
|
- **[Personas](./docs/personas.md)** - Dynamic prompt layers and named greetings
|
|
103
103
|
- **[WhatsApp Channel](./docs/channels.md)** - Link a WhatsApp number as a transport
|
|
104
104
|
- **[Building a Channel](./docs/build-a-channel.md)** - Plug in a new transport
|
|
105
|
+
- **[Telegram Channel](./docs/telegram.md)** - Run a bot on the official Bot API, no extra dependency
|
|
105
106
|
- **[Flows](./docs/flows.md)** - Multi-turn, schema-driven slot-filling flows
|
|
106
107
|
- **[Images](./docs/images.md)** - Generate and cache images on demand
|
|
107
108
|
- **[Conversation History](./docs/history.md)** - Structural, host-replaceable multi-turn context
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Bot API client — the whole transport layer of the Telegram
|
|
3
|
+
* channel, over plain `fetch`. No SDK, no optional peer dependency: the Bot
|
|
4
|
+
* API is JSON over HTTPS, so `./telegram` costs a consumer nothing beyond the
|
|
5
|
+
* package itself.
|
|
6
|
+
*
|
|
7
|
+
* Everything here is about the wire: envelopes, error mapping, the 4096-char
|
|
8
|
+
* message limit. Interpretation of a message (mentions, gates, replies) lives
|
|
9
|
+
* in `./updates` and `./channel`.
|
|
10
|
+
*
|
|
11
|
+
* The bot token is a credential that appears in every request URL, so it is
|
|
12
|
+
* never allowed into an error message or a log line — see {@link redactToken}.
|
|
13
|
+
*/
|
|
14
|
+
/** Default Bot API origin. A self-hosted Bot API server sets its own via `baseUrl`. */
|
|
15
|
+
export declare const TELEGRAM_API_BASE = "https://api.telegram.org";
|
|
16
|
+
/** Bot API `sendMessage` hard limit, in UTF-16 code units. A longer text is rejected with HTTP 400. */
|
|
17
|
+
export declare const TELEGRAM_TEXT_LIMIT = 4096;
|
|
18
|
+
export interface TelegramUser {
|
|
19
|
+
id: number;
|
|
20
|
+
is_bot?: boolean;
|
|
21
|
+
username?: string;
|
|
22
|
+
first_name?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TelegramChat {
|
|
25
|
+
id: number;
|
|
26
|
+
type: "private" | "group" | "supergroup" | "channel";
|
|
27
|
+
}
|
|
28
|
+
/** Offsets/lengths are UTF-16 code units — the same units JS string indexing uses, so `text.slice(offset, offset + length)` is exact. */
|
|
29
|
+
export interface TelegramMessageEntity {
|
|
30
|
+
type: string;
|
|
31
|
+
offset: number;
|
|
32
|
+
length: number;
|
|
33
|
+
/** Present on `text_mention` entities: a mention of a user who has no username. */
|
|
34
|
+
user?: TelegramUser;
|
|
35
|
+
}
|
|
36
|
+
export interface TelegramMessage {
|
|
37
|
+
message_id: number;
|
|
38
|
+
from?: TelegramUser;
|
|
39
|
+
chat: TelegramChat;
|
|
40
|
+
text?: string;
|
|
41
|
+
/** Photos/videos/documents carry their text here, with entities on `caption_entities`. */
|
|
42
|
+
caption?: string;
|
|
43
|
+
entities?: TelegramMessageEntity[];
|
|
44
|
+
caption_entities?: TelegramMessageEntity[];
|
|
45
|
+
reply_to_message?: {
|
|
46
|
+
message_id?: number;
|
|
47
|
+
from?: TelegramUser;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface TelegramUpdate {
|
|
51
|
+
update_id: number;
|
|
52
|
+
message?: TelegramMessage;
|
|
53
|
+
}
|
|
54
|
+
/** A Bot API call that did not return `ok: true`, or never completed. `retryAfterMs` carries Telegram's own flood-wait instruction when it sent one. */
|
|
55
|
+
export declare class TelegramApiError extends Error {
|
|
56
|
+
readonly errorCode?: number;
|
|
57
|
+
readonly retryAfterMs?: number;
|
|
58
|
+
constructor(message: string, options?: {
|
|
59
|
+
errorCode?: number;
|
|
60
|
+
retryAfterMs?: number;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Replaces every occurrence of the bot token with `***`. The token is part of
|
|
65
|
+
* the request URL, and a fetch failure (or a proxy's error body) can echo that
|
|
66
|
+
* URL back — logging it verbatim would leak full control of the bot into the
|
|
67
|
+
* host's logs. An empty token is left alone: replacing "" would corrupt the
|
|
68
|
+
* message rather than protect anything.
|
|
69
|
+
*/
|
|
70
|
+
export declare function redactToken(text: string, token: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Splits `text` into chunks no longer than `limit`, preferring paragraph, then
|
|
73
|
+
* line, then word boundaries — a model's answer regularly runs past Telegram's
|
|
74
|
+
* 4096-char cap, and the Bot API's response to that is to reject the whole
|
|
75
|
+
* message, so an unsplit send loses the answer entirely rather than truncating
|
|
76
|
+
* it. Empty/blank input yields no chunks (nothing to send).
|
|
77
|
+
*/
|
|
78
|
+
export declare function splitTelegramText(text: string, limit?: number): string[];
|
|
79
|
+
/** What `ChannelSender.sendMedia` accepts for this channel. A bare string is shorthand for a photo URL. */
|
|
80
|
+
export interface TelegramMediaPayload {
|
|
81
|
+
/** @default "photo" */
|
|
82
|
+
kind?: "photo" | "document" | "video" | "audio";
|
|
83
|
+
/** An https URL or a Telegram `file_id` — the two forms the Bot API accepts without a multipart upload. */
|
|
84
|
+
url: string;
|
|
85
|
+
caption?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Turns the registry's opaque `sendMedia` payload into a Bot API call.
|
|
89
|
+
* `ChannelSender.sendMedia` types its payload as `unknown` (payload shapes are
|
|
90
|
+
* transport-defined), so this is where that unknown is checked — a malformed
|
|
91
|
+
* payload throws here, which the sender registry reports as `false` rather
|
|
92
|
+
* than letting a caller's bad send crash it.
|
|
93
|
+
*/
|
|
94
|
+
export declare function toTelegramMediaRequest(chatId: string, payload: unknown): {
|
|
95
|
+
method: string;
|
|
96
|
+
body: Record<string, unknown>;
|
|
97
|
+
};
|
|
98
|
+
export interface TelegramApiConfig {
|
|
99
|
+
botToken: string;
|
|
100
|
+
/** Overridable for tests and for hosts routing through a proxy; defaults to `globalThis.fetch`. */
|
|
101
|
+
fetch?: typeof fetch;
|
|
102
|
+
/** @default {@link TELEGRAM_API_BASE} */
|
|
103
|
+
baseUrl?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface TelegramApi {
|
|
106
|
+
/** Raw call, for a method this interface does not wrap. Rejects with {@link TelegramApiError} on any non-`ok` result. */
|
|
107
|
+
call<T>(method: string, body?: Record<string, unknown>, signal?: AbortSignal): Promise<T>;
|
|
108
|
+
getMe(): Promise<TelegramUser>;
|
|
109
|
+
getUpdates(options: {
|
|
110
|
+
offset?: number;
|
|
111
|
+
timeoutSeconds: number;
|
|
112
|
+
signal?: AbortSignal;
|
|
113
|
+
}): Promise<TelegramUpdate[]>;
|
|
114
|
+
/** Splits at {@link TELEGRAM_TEXT_LIMIT}; only the first chunk threads onto `replyToMessageId`. */
|
|
115
|
+
sendMessage(chatId: string, text: string, options?: {
|
|
116
|
+
replyToMessageId?: number;
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
sendMedia(chatId: string, payload: unknown): Promise<void>;
|
|
119
|
+
setMessageReaction(chatId: string, messageId: number, emoji: string): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
export declare function createTelegramApi(config: TelegramApiConfig): TelegramApi;
|
|
122
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/channels/telegram/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,uFAAuF;AACvF,eAAO,MAAM,iBAAiB,6BAA6B,CAAC;AAE5D,uGAAuG;AACvG,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;CACtD;AAED,yIAAyI;AACzI,MAAM,WAAW,qBAA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,CAAC,CAAC;IAC3D,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrF;AAMD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CAiGxE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Bot API transport: a {@link Channel} that long-polls `getUpdates`,
|
|
3
|
+
* maps each update into a `ChannelMessage`, and answers through the shared
|
|
4
|
+
* `createInboundPipeline` — the same gates, persona, buckets, history and
|
|
5
|
+
* `answerFn` seams every other channel uses.
|
|
6
|
+
*
|
|
7
|
+
* This is the second transport on the channel SPI, and unlike WhatsApp it
|
|
8
|
+
* needs no optional peer dependency, no session persistence, and no deploy
|
|
9
|
+
* lease: the Bot API is JSON over HTTPS and Telegram itself queues updates
|
|
10
|
+
* per bot token. It is deliberately self-contained — `start(deps)` has
|
|
11
|
+
* everything it needs, so there is no `customRoutes` wiring step (contrast
|
|
12
|
+
* `./channels/whatsapp/inbound.ts`, whose transport and interpretation are
|
|
13
|
+
* separate modules).
|
|
14
|
+
*
|
|
15
|
+
* One caveat worth knowing before choosing this over a user-mode client: a bot
|
|
16
|
+
* cannot start a conversation (the user must message it first), and in groups
|
|
17
|
+
* Telegram's privacy mode means it only receives messages that address it —
|
|
18
|
+
* which is the same policy `decideChannelAction` applies anyway.
|
|
19
|
+
*/
|
|
20
|
+
import type { AnswerFn } from "../../core/answer";
|
|
21
|
+
import type { BucketsFor } from "../../core/buckets";
|
|
22
|
+
import { type Logger } from "../../core/logger";
|
|
23
|
+
import type { HistoryStore } from "../../history/types";
|
|
24
|
+
import type { Channel } from "../index";
|
|
25
|
+
import { type TelegramApi } from "./api";
|
|
26
|
+
export interface TelegramChannelConfig {
|
|
27
|
+
/** From @BotFather. A credential — pass it from the environment, never commit it. */
|
|
28
|
+
botToken: string;
|
|
29
|
+
/** Channel and sender-registry name. Override to run more than one bot in one process. @default "telegram" */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** Group chats eligible for a reply. Empty (default) = every group. Has no effect on DMs, which always reply. */
|
|
32
|
+
allowedChats?: string[];
|
|
33
|
+
answerFn?: AnswerFn;
|
|
34
|
+
bucketsFor?: BucketsFor;
|
|
35
|
+
model?: string;
|
|
36
|
+
/** Extra system-prompt section describing the delivery channel; passed through to `prepareChat`. @default "Channel: Telegram." */
|
|
37
|
+
channelHint?: string;
|
|
38
|
+
/** A throw/rejection is treated as "no persona" for that turn. `sender` is the namespaced `tg:<id>` key. */
|
|
39
|
+
personaResolver?: (ctx: {
|
|
40
|
+
sender: string;
|
|
41
|
+
text: string;
|
|
42
|
+
}) => string | undefined | Promise<string | undefined>;
|
|
43
|
+
/** Off by default — the channel stays single-turn until a store is configured. */
|
|
44
|
+
history?: {
|
|
45
|
+
store: HistoryStore;
|
|
46
|
+
limit?: number;
|
|
47
|
+
};
|
|
48
|
+
muteRegex?: RegExp;
|
|
49
|
+
unmuteRegex?: RegExp;
|
|
50
|
+
/** Neutral, overridable acknowledgements — this module ships no bot personality; unset = silent mute/unmute. */
|
|
51
|
+
muteReply?: string;
|
|
52
|
+
unmuteReply?: string;
|
|
53
|
+
dmRateLimit?: {
|
|
54
|
+
max: number;
|
|
55
|
+
windowMs: number;
|
|
56
|
+
};
|
|
57
|
+
groupRateLimit?: {
|
|
58
|
+
max: number;
|
|
59
|
+
windowMs: number;
|
|
60
|
+
};
|
|
61
|
+
/** @default 30 */
|
|
62
|
+
pollTimeoutSeconds?: number;
|
|
63
|
+
/** Resume point for `getUpdates`. Omitted = whatever Telegram still has queued (see docs/telegram.md). */
|
|
64
|
+
initialOffset?: number;
|
|
65
|
+
/** Called with each acknowledged offset, for a host that wants to persist it across restarts. */
|
|
66
|
+
onOffset?: (offset: number) => void;
|
|
67
|
+
/** Overridable for tests and for hosts routing through a proxy; defaults to `globalThis.fetch`. */
|
|
68
|
+
fetch?: typeof fetch;
|
|
69
|
+
/** Self-hosted Bot API server origin. */
|
|
70
|
+
apiBaseUrl?: string;
|
|
71
|
+
/** Overridable for tests, which fake the Bot API instead of calling it; defaults to a `fetch` client over {@link TelegramChannelConfig.botToken}. */
|
|
72
|
+
api?: TelegramApi;
|
|
73
|
+
/** Overridable for tests; defaults to a `setTimeout`-based sleep. */
|
|
74
|
+
sleep?: (ms: number) => Promise<void>;
|
|
75
|
+
now?: () => number;
|
|
76
|
+
/** Logger for poll/gate diagnostics. Falls back to the host's `deps.logger`, then a console logger. */
|
|
77
|
+
logger?: Logger;
|
|
78
|
+
}
|
|
79
|
+
export declare function createTelegramChannel(config: TelegramChannelConfig): Channel;
|
|
80
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/channels/telegram/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,EAAqB,KAAK,WAAW,EAAuB,MAAM,OAAO,CAAC;AAOjF,MAAM,WAAW,qBAAqB;IACpC,qFAAqF;IACrF,QAAQ,EAAE,MAAM,CAAC;IACjB,8GAA8G;IAC9G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iHAAiH;IACjH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,KAAK,CAAC,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G;IACvG,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AASD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CA+H5E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Bot API transport — a {@link Channel} with NO optional peer
|
|
3
|
+
* dependency: the Bot API is JSON over HTTPS, reached with plain `fetch`, so
|
|
4
|
+
* this subpath costs a consumer nothing beyond the package itself.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { createTelegramChannel } from "@diegoaltoworks/chatter/telegram";
|
|
8
|
+
*
|
|
9
|
+
* await createServer({
|
|
10
|
+
* ...,
|
|
11
|
+
* channels: [createTelegramChannel({ botToken: process.env.TELEGRAM_BOT_TOKEN as string })],
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Everything past turning an update into a `ChannelMessage` runs through
|
|
16
|
+
* `./channels`' `createInboundPipeline`, shared with every other channel — see
|
|
17
|
+
* docs/telegram.md for configuration and docs/build-a-channel.md for the SPI
|
|
18
|
+
* this implements.
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
export { createTelegramApi, redactToken, splitTelegramText, TELEGRAM_API_BASE, TELEGRAM_TEXT_LIMIT, type TelegramApi, type TelegramApiConfig, TelegramApiError, type TelegramChat, type TelegramMediaPayload, type TelegramMessage, type TelegramMessageEntity, type TelegramUpdate, type TelegramUser, toTelegramMediaRequest, } from "./api";
|
|
23
|
+
export { createTelegramChannel, type TelegramChannelConfig } from "./channel";
|
|
24
|
+
export { type LongPollDeps, pollBackoffMs, retryDelayMs, runLongPoll } from "./poll";
|
|
25
|
+
export { mentionsBot, messageEntities, messageText, nextOffset, type TelegramBotIdentity, telegramSenderKey, toChannelMessage, } from "./updates";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channels/telegram/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,sBAAsB,GACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrF,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACV,KAAK,mBAAmB,EACxB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC"}
|