agents
Version:
A home for your AI agents
117 lines (115 loc) • 3.76 kB
TypeScript
import {
D as ChannelIngress,
c as ChannelRoute,
n as Channel,
o as ChannelMessage,
s as ChannelParticipant
} from "../../../channel-Bak_6zDP.js";
import { b as ChannelMessageSurface } from "../../../protocol-CukuI73M.js";
//#region src/experimental/channels/telegram/index.d.ts
type TelegramUser = {
id: number;
is_bot: boolean;
first_name: string;
last_name?: string;
username?: string;
[key: string]: unknown;
};
type TelegramChat = {
id: number;
type: "private" | "group" | "supergroup" | "channel";
title?: string;
username?: string;
first_name?: string;
last_name?: string;
[key: string]: unknown;
};
type TelegramMessage = {
message_id: number;
date: number;
chat: TelegramChat;
message_thread_id?: number;
from?: TelegramUser;
sender_chat?: TelegramChat;
text?: string;
edit_date?: number;
reply_to_message?: TelegramMessage;
[key: string]: unknown;
};
/** Authenticated JSON body delivered by a Telegram webhook. */
type TelegramUpdate = {
update_id: number;
message?: TelegramMessage;
edited_message?: TelegramMessage;
[key: string]: unknown;
};
type TelegramMessageSurface = ChannelMessageSurface<
string,
{
chatId: string;
botUserId?: number;
messageThreadId?: number;
replyToMessageId?: number;
}
>;
/** Configuration for a Telegram Channel. */
type TelegramChannelOptions = {
/** Bot token issued by BotFather. */ botToken: string /** Telegram Bot API origin. @default "https://api.telegram.org" */;
apiBaseUrl?: string /** Maximum text length accepted by this route. @default 4096 */;
maxLength?: number /** Project the canonical message into Telegram text. */;
toText?: (
message: ChannelMessage
) => string /** Parse mode for caller-formatted delivery text. */;
parseMode?: "HTML" | "MarkdownV2";
/**
* Smallest gap between `sendMessageDraft` previews. Snapshots produced
* inside one interval are replaced rather than sent. @default 500
*/
streamIntervalMs?: number;
/**
* Who sent a verified Telegram update, such as your user linked to
* `event.actor`. Return null to drop the update. Required with `webhook`.
*/
participant?: ChannelParticipant<TelegramUpdate>;
/**
* Pick the agent object an update reaches. Default: a room of the
* participant's own, so a group chat is not shared by accident.
*/
route?: ChannelRoute<TelegramUpdate> /** Add secret-verified Telegram webhook ingress to the returned Channel. */;
webhook?: {
secretToken: string /** Exact webhook pathname accepted by this ingress. @default "/webhooks/telegram" */;
path?: string;
} /** Override fetch for testing or custom network routing. */;
fetch?: typeof globalThis.fetch;
};
type TelegramWebhookOptions = {
/** Telegram webhook secret configured through setWebhook. */ secretToken: string /** Exact webhook pathname accepted by this ingress. @default "/webhooks/telegram" */;
path?: string;
/**
* Numeric user id of this bot, used to prove that an approval reply answers
* a message this bot sent. Without it, marker replies stay ordinary
* messages because their provenance cannot be established.
*/
botUserId?: number;
};
/** Create dependency-free Telegram webhook ingress for a destination chat. */
declare function telegramWebhook(
options: TelegramWebhookOptions
): ChannelIngress<TelegramUpdate>;
/** Create a configured Telegram ingress Channel. */
declare function telegram(
options: TelegramChannelOptions
): Channel<TelegramUpdate>;
//#endregion
export {
TelegramChannelOptions,
TelegramChat,
TelegramMessage,
TelegramMessageSurface,
TelegramUpdate,
TelegramUser,
TelegramWebhookOptions,
telegram,
telegramWebhook
};
//# sourceMappingURL=index.d.ts.map