@elizaos/plugin-telegram 2.0.0-alpha.6 → 2.0.0-alpha.8
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/dist/accounts.d.ts +139 -0
- package/dist/accounts.d.ts.map +1 -0
- package/dist/actions/deleteMessage.d.ts +4 -0
- package/dist/actions/deleteMessage.d.ts.map +1 -0
- package/dist/actions/deleteMessage.test.d.ts +2 -0
- package/dist/actions/deleteMessage.test.d.ts.map +1 -0
- package/dist/actions/editMessage.d.ts +4 -0
- package/dist/actions/editMessage.d.ts.map +1 -0
- package/dist/actions/editMessage.test.d.ts +2 -0
- package/dist/actions/editMessage.test.d.ts.map +1 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/sendMessage.d.ts +4 -0
- package/dist/actions/sendMessage.d.ts.map +1 -0
- package/dist/actions/sendReaction.d.ts +4 -0
- package/dist/actions/sendReaction.d.ts.map +1 -0
- package/dist/actions/sendSticker.d.ts +4 -0
- package/dist/actions/sendSticker.d.ts.map +1 -0
- package/dist/config.d.ts +153 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/environment.d.ts +49 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/formatting.d.ts +114 -0
- package/dist/formatting.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11645 -0
- package/dist/index.js.map +80 -0
- package/dist/messageManager.d.ts +61 -0
- package/dist/messageManager.d.ts.map +1 -0
- package/dist/providers/chatState.d.ts +4 -0
- package/dist/providers/chatState.d.ts.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/service.d.ts +137 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/tests.d.ts +19 -0
- package/dist/tests.d.ts.map +1 -0
- package/dist/types.d.ts +238 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +15 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Default account identifier used when no specific account is configured
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_ACCOUNT_ID = "default";
|
|
6
|
+
/**
|
|
7
|
+
* Source of the Telegram token
|
|
8
|
+
*/
|
|
9
|
+
export type TelegramTokenSource = "env" | "config" | "character" | "none";
|
|
10
|
+
/**
|
|
11
|
+
* Result of token resolution
|
|
12
|
+
*/
|
|
13
|
+
export interface TelegramTokenResolution {
|
|
14
|
+
token: string;
|
|
15
|
+
source: TelegramTokenSource;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* DM-specific configuration
|
|
19
|
+
*/
|
|
20
|
+
export interface TelegramDmConfig {
|
|
21
|
+
/** If false, ignore all incoming Telegram DMs */
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/** Direct message access policy */
|
|
24
|
+
policy?: "open" | "disabled" | "allowlist" | "pairing";
|
|
25
|
+
/** Allowlist for DM senders (ids or usernames) */
|
|
26
|
+
allowFrom?: Array<string | number>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Group-specific runtime configuration (for account resolution)
|
|
30
|
+
*/
|
|
31
|
+
export interface TelegramGroupRuntimeConfig {
|
|
32
|
+
/** If false, ignore all group messages */
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
/** Group message access policy */
|
|
35
|
+
policy?: "open" | "disabled" | "allowlist";
|
|
36
|
+
/** Require bot mention to respond in groups */
|
|
37
|
+
requireMention?: boolean;
|
|
38
|
+
/** Allowlist for groups (ids or usernames) */
|
|
39
|
+
allowFrom?: Array<string | number>;
|
|
40
|
+
/** User allowlist within groups */
|
|
41
|
+
users?: Array<string | number>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Configuration for a single Telegram account (runtime resolution)
|
|
45
|
+
*/
|
|
46
|
+
export interface TelegramAccountRuntimeConfig {
|
|
47
|
+
/** Optional display name for this account */
|
|
48
|
+
name?: string;
|
|
49
|
+
/** If false, do not start this Telegram account */
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
/** Telegram bot token for this account */
|
|
52
|
+
token?: string;
|
|
53
|
+
/** Update mode: polling or webhook */
|
|
54
|
+
updateMode?: "polling" | "webhook";
|
|
55
|
+
/** Webhook URL for webhook mode */
|
|
56
|
+
webhookUrl?: string;
|
|
57
|
+
/** Webhook port */
|
|
58
|
+
webhookPort?: number;
|
|
59
|
+
/** Webhook path */
|
|
60
|
+
webhookPath?: string;
|
|
61
|
+
/** Webhook secret */
|
|
62
|
+
webhookSecret?: string;
|
|
63
|
+
/** Custom API root URL */
|
|
64
|
+
apiRoot?: string;
|
|
65
|
+
/** Outbound text chunk size (chars) */
|
|
66
|
+
textChunkLimit?: number;
|
|
67
|
+
/** Max media size in MB */
|
|
68
|
+
mediaMaxMb?: number;
|
|
69
|
+
/** History limit for context */
|
|
70
|
+
historyLimit?: number;
|
|
71
|
+
/** DM configuration */
|
|
72
|
+
dm?: TelegramDmConfig;
|
|
73
|
+
/** Group configuration */
|
|
74
|
+
group?: TelegramGroupRuntimeConfig;
|
|
75
|
+
/** Allowed chat IDs */
|
|
76
|
+
allowedChatIds?: Array<string | number>;
|
|
77
|
+
/** Whether to ignore bot messages */
|
|
78
|
+
shouldIgnoreBotMessages?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Multi-account Telegram configuration structure
|
|
82
|
+
*/
|
|
83
|
+
export interface TelegramMultiAccountConfig {
|
|
84
|
+
/** Default/base configuration applied to all accounts */
|
|
85
|
+
enabled?: boolean;
|
|
86
|
+
token?: string;
|
|
87
|
+
/** Per-account configuration overrides */
|
|
88
|
+
accounts?: Record<string, TelegramAccountRuntimeConfig>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolved Telegram account with all configuration merged
|
|
92
|
+
*/
|
|
93
|
+
export interface ResolvedTelegramAccount {
|
|
94
|
+
accountId: string;
|
|
95
|
+
enabled: boolean;
|
|
96
|
+
name?: string;
|
|
97
|
+
token: string;
|
|
98
|
+
tokenSource: TelegramTokenSource;
|
|
99
|
+
config: TelegramAccountRuntimeConfig;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Normalizes an account ID, returning the default if not provided
|
|
103
|
+
*/
|
|
104
|
+
export declare function normalizeAccountId(accountId?: string | null): string;
|
|
105
|
+
/**
|
|
106
|
+
* Normalizes a Telegram token by trimming whitespace
|
|
107
|
+
*/
|
|
108
|
+
export declare function normalizeTelegramToken(raw?: string | null): string | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Gets the multi-account configuration from runtime settings
|
|
111
|
+
*/
|
|
112
|
+
export declare function getMultiAccountConfig(runtime: IAgentRuntime): TelegramMultiAccountConfig;
|
|
113
|
+
/**
|
|
114
|
+
* Lists all configured account IDs
|
|
115
|
+
*/
|
|
116
|
+
export declare function listTelegramAccountIds(runtime: IAgentRuntime): string[];
|
|
117
|
+
/**
|
|
118
|
+
* Resolves the default account ID to use
|
|
119
|
+
*/
|
|
120
|
+
export declare function resolveDefaultTelegramAccountId(runtime: IAgentRuntime): string;
|
|
121
|
+
/**
|
|
122
|
+
* Resolves the Telegram token for a specific account
|
|
123
|
+
*/
|
|
124
|
+
export declare function resolveTelegramToken(runtime: IAgentRuntime, opts?: {
|
|
125
|
+
accountId?: string | null;
|
|
126
|
+
}): TelegramTokenResolution;
|
|
127
|
+
/**
|
|
128
|
+
* Resolves a complete Telegram account configuration
|
|
129
|
+
*/
|
|
130
|
+
export declare function resolveTelegramAccount(runtime: IAgentRuntime, accountId?: string | null): ResolvedTelegramAccount;
|
|
131
|
+
/**
|
|
132
|
+
* Lists all enabled Telegram accounts
|
|
133
|
+
*/
|
|
134
|
+
export declare function listEnabledTelegramAccounts(runtime: IAgentRuntime): ResolvedTelegramAccount[];
|
|
135
|
+
/**
|
|
136
|
+
* Checks if multi-account mode is enabled
|
|
137
|
+
*/
|
|
138
|
+
export declare function isMultiAccountEnabled(runtime: IAgentRuntime): boolean;
|
|
139
|
+
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;IACvD,kDAAkD;IAClD,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;IAC3C,+CAA+C;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACnC,mCAAmC;IACnC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM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AAsB/D,eAAO,MAAM,mBAAmB,EAAE,MAwLjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteMessage.test.d.ts","sourceRoot":"","sources":["../../src/actions/deleteMessage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editMessage.d.ts","sourceRoot":"","sources":["../../src/actions/editMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAyB3D,eAAO,MAAM,iBAAiB,EAAE,MA6K/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editMessage.test.d.ts","sourceRoot":"","sources":["../../src/actions/editMessage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DELETE_MESSAGE_ACTION, deleteMessageAction } from "./deleteMessage";
|
|
2
|
+
export { EDIT_MESSAGE_ACTION, editMessageAction } from "./editMessage";
|
|
3
|
+
export { SEND_MESSAGE_ACTION, sendMessageAction } from "./sendMessage";
|
|
4
|
+
export { SEND_REACTION_ACTION, sendReactionAction } from "./sendReaction";
|
|
5
|
+
export { SEND_STICKER_ACTION, sendStickerAction } from "./sendSticker";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D,eAAO,MAAM,iBAAiB,EAAE,MAgH/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendReaction.d.ts","sourceRoot":"","sources":["../../src/actions/sendReaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAMvB,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAmC7D,eAAO,MAAM,kBAAkB,EAAE,MAwMhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendSticker.d.ts","sourceRoot":"","sources":["../../src/actions/sendSticker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AA2B3D,eAAO,MAAM,iBAAiB,EAAE,MA0L/B,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram plugin configuration types.
|
|
3
|
+
*
|
|
4
|
+
* These types define the configuration schema for the Telegram plugin.
|
|
5
|
+
* Shared base types are imported from @elizaos/core.
|
|
6
|
+
*/
|
|
7
|
+
import type { BlockStreamingChunkConfig, BlockStreamingCoalesceConfig, ChannelHeartbeatVisibilityConfig, DmConfig, DmPolicy, GroupPolicy, GroupToolPolicyBySenderConfig, GroupToolPolicyConfig, MarkdownConfig, OutboundRetryConfig, ProviderCommandsConfig, ReplyToMode } from "@elizaos/core";
|
|
8
|
+
export type TelegramActionConfig = {
|
|
9
|
+
reactions?: boolean;
|
|
10
|
+
sendMessage?: boolean;
|
|
11
|
+
deleteMessage?: boolean;
|
|
12
|
+
editMessage?: boolean;
|
|
13
|
+
/** Enable sticker actions (send and search). */
|
|
14
|
+
sticker?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type TelegramNetworkConfig = {
|
|
17
|
+
/** Override Node's autoSelectFamily behavior (true = enable, false = disable). */
|
|
18
|
+
autoSelectFamily?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type TelegramInlineButtonsScope = "off" | "dm" | "group" | "all" | "allowlist";
|
|
21
|
+
export type TelegramCapabilitiesConfig = string[] | {
|
|
22
|
+
inlineButtons?: TelegramInlineButtonsScope;
|
|
23
|
+
};
|
|
24
|
+
/** Custom command definition for Telegram bot menu. */
|
|
25
|
+
export type TelegramCustomCommand = {
|
|
26
|
+
/** Command name (without leading /). */
|
|
27
|
+
command: string;
|
|
28
|
+
/** Description shown in Telegram command menu. */
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
export type TelegramTopicConfig = {
|
|
32
|
+
requireMention?: boolean;
|
|
33
|
+
/** If specified, only load these skills for this topic. Omit = all skills; empty = no skills. */
|
|
34
|
+
skills?: string[];
|
|
35
|
+
/** If false, disable the bot for this topic. */
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
/** Optional allowlist for topic senders (ids or usernames). */
|
|
38
|
+
allowFrom?: Array<string | number>;
|
|
39
|
+
/** Optional system prompt snippet for this topic. */
|
|
40
|
+
systemPrompt?: string;
|
|
41
|
+
};
|
|
42
|
+
export type TelegramGroupConfig = {
|
|
43
|
+
requireMention?: boolean;
|
|
44
|
+
/** Optional tool policy overrides for this group. */
|
|
45
|
+
tools?: GroupToolPolicyConfig;
|
|
46
|
+
toolsBySender?: GroupToolPolicyBySenderConfig;
|
|
47
|
+
/** If specified, only load these skills for this group (when no topic). Omit = all skills; empty = no skills. */
|
|
48
|
+
skills?: string[];
|
|
49
|
+
/** Per-topic configuration (key is message_thread_id as string) */
|
|
50
|
+
topics?: Record<string, TelegramTopicConfig>;
|
|
51
|
+
/** If false, disable the bot for this group (and its topics). */
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
/** Optional allowlist for group senders (ids or usernames). */
|
|
54
|
+
allowFrom?: Array<string | number>;
|
|
55
|
+
/** Optional system prompt snippet for this group. */
|
|
56
|
+
systemPrompt?: string;
|
|
57
|
+
};
|
|
58
|
+
export type TelegramAccountConfig = {
|
|
59
|
+
/** Optional display name for this account (used in CLI/UI lists). */
|
|
60
|
+
name?: string;
|
|
61
|
+
/** Optional provider capability tags used for agent/runtime guidance. */
|
|
62
|
+
capabilities?: TelegramCapabilitiesConfig;
|
|
63
|
+
/** Markdown formatting overrides (tables). */
|
|
64
|
+
markdown?: MarkdownConfig;
|
|
65
|
+
/** Override native command registration for Telegram (bool or "auto"). */
|
|
66
|
+
commands?: ProviderCommandsConfig;
|
|
67
|
+
/** Custom commands to register in Telegram's command menu (merged with native). */
|
|
68
|
+
customCommands?: TelegramCustomCommand[];
|
|
69
|
+
/** Allow channel-initiated config writes (default: true). */
|
|
70
|
+
configWrites?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Controls how Telegram direct chats (DMs) are handled:
|
|
73
|
+
* - "pairing" (default): unknown senders get a pairing code; owner must approve
|
|
74
|
+
* - "allowlist": only allow senders in allowFrom (or paired allow store)
|
|
75
|
+
* - "open": allow all inbound DMs (requires allowFrom to include "*")
|
|
76
|
+
* - "disabled": ignore all inbound DMs
|
|
77
|
+
*/
|
|
78
|
+
dmPolicy?: DmPolicy;
|
|
79
|
+
/** If false, do not start this Telegram account. Default: true. */
|
|
80
|
+
enabled?: boolean;
|
|
81
|
+
botToken?: string;
|
|
82
|
+
/** Path to file containing bot token (for secret managers like agenix). */
|
|
83
|
+
tokenFile?: string;
|
|
84
|
+
/** Control reply threading when reply tags are present (off|first|all). */
|
|
85
|
+
replyToMode?: ReplyToMode;
|
|
86
|
+
groups?: Record<string, TelegramGroupConfig>;
|
|
87
|
+
allowFrom?: Array<string | number>;
|
|
88
|
+
/** Optional allowlist for Telegram group senders (user ids or usernames). */
|
|
89
|
+
groupAllowFrom?: Array<string | number>;
|
|
90
|
+
/**
|
|
91
|
+
* Controls how group messages are handled:
|
|
92
|
+
* - "open": groups bypass allowFrom, only mention-gating applies
|
|
93
|
+
* - "disabled": block all group messages entirely
|
|
94
|
+
* - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
|
95
|
+
*/
|
|
96
|
+
groupPolicy?: GroupPolicy;
|
|
97
|
+
/** Max group messages to keep as history context (0 disables). */
|
|
98
|
+
historyLimit?: number;
|
|
99
|
+
/** Max DM turns to keep as history context. */
|
|
100
|
+
dmHistoryLimit?: number;
|
|
101
|
+
/** Per-DM config overrides keyed by user ID. */
|
|
102
|
+
dms?: Record<string, DmConfig>;
|
|
103
|
+
/** Outbound text chunk size (chars). Default: 4000. */
|
|
104
|
+
textChunkLimit?: number;
|
|
105
|
+
/** Chunking mode: "length" (default) splits by size; "newline" splits on every newline. */
|
|
106
|
+
chunkMode?: "length" | "newline";
|
|
107
|
+
/** Disable block streaming for this account. */
|
|
108
|
+
blockStreaming?: boolean;
|
|
109
|
+
/** Chunking config for draft streaming in `streamMode: "block"`. */
|
|
110
|
+
draftChunk?: BlockStreamingChunkConfig;
|
|
111
|
+
/** Merge streamed block replies before sending. */
|
|
112
|
+
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
|
113
|
+
/** Draft streaming mode for Telegram (off|partial|block). Default: partial. */
|
|
114
|
+
streamMode?: "off" | "partial" | "block";
|
|
115
|
+
mediaMaxMb?: number;
|
|
116
|
+
/** Telegram API client timeout in seconds (grammY ApiClientOptions). */
|
|
117
|
+
timeoutSeconds?: number;
|
|
118
|
+
/** Retry policy for outbound Telegram API calls. */
|
|
119
|
+
retry?: OutboundRetryConfig;
|
|
120
|
+
/** Network transport overrides for Telegram. */
|
|
121
|
+
network?: TelegramNetworkConfig;
|
|
122
|
+
proxy?: string;
|
|
123
|
+
webhookUrl?: string;
|
|
124
|
+
webhookSecret?: string;
|
|
125
|
+
webhookPath?: string;
|
|
126
|
+
/** Per-action tool gating (default: true for all). */
|
|
127
|
+
actions?: TelegramActionConfig;
|
|
128
|
+
/**
|
|
129
|
+
* Controls which user reactions trigger notifications:
|
|
130
|
+
* - "off" (default): ignore all reactions
|
|
131
|
+
* - "own": notify when users react to bot messages
|
|
132
|
+
* - "all": notify agent of all reactions
|
|
133
|
+
*/
|
|
134
|
+
reactionNotifications?: "off" | "own" | "all";
|
|
135
|
+
/**
|
|
136
|
+
* Controls agent's reaction capability:
|
|
137
|
+
* - "off": agent cannot react
|
|
138
|
+
* - "ack" (default): bot sends acknowledgment reactions (👀 while processing)
|
|
139
|
+
* - "minimal": agent can react sparingly (guideline: 1 per 5-10 exchanges)
|
|
140
|
+
* - "extensive": agent can react liberally when appropriate
|
|
141
|
+
*/
|
|
142
|
+
reactionLevel?: "off" | "ack" | "minimal" | "extensive";
|
|
143
|
+
/** Heartbeat visibility settings for this channel. */
|
|
144
|
+
heartbeat?: ChannelHeartbeatVisibilityConfig;
|
|
145
|
+
/** Controls whether link previews are shown in outbound messages. Default: true. */
|
|
146
|
+
linkPreview?: boolean;
|
|
147
|
+
};
|
|
148
|
+
export type TelegramChannelConfig = {
|
|
149
|
+
/** Optional per-account Telegram configuration (multi-account). */
|
|
150
|
+
accounts?: Record<string, TelegramAccountConfig>;
|
|
151
|
+
} & TelegramAccountConfig;
|
|
152
|
+
export type { TelegramChannelConfig as TelegramConfig };
|
|
153
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAC5B,gCAAgC,EAChC,QAAQ,EACR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;CACvB,CAAC;AAMF,MAAM,MAAM,qBAAqB,GAAG;IAClC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAClD,GAAG,qBAAqB,CAAC;AAG1B,YAAY,EAAE,qBAAqB,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const MESSAGE_CONSTANTS: {
|
|
2
|
+
readonly MAX_MESSAGES: 50;
|
|
3
|
+
readonly RECENT_MESSAGE_COUNT: 5;
|
|
4
|
+
readonly CHAT_HISTORY_COUNT: 10;
|
|
5
|
+
readonly DEFAULT_SIMILARITY_THRESHOLD: 0.6;
|
|
6
|
+
readonly DEFAULT_SIMILARITY_THRESHOLD_FOLLOW_UPS: 0.4;
|
|
7
|
+
readonly INTEREST_DECAY_TIME: number;
|
|
8
|
+
readonly PARTIAL_INTEREST_DECAY: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const TELEGRAM_SERVICE_NAME = "telegram";
|
|
11
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;;;;;;CAQpB,CAAC;AAEX,eAAO,MAAM,qBAAqB,aAAa,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Update mode for receiving Telegram updates.
|
|
5
|
+
* - polling: Long-polling (default, suitable for development)
|
|
6
|
+
* - webhook: Webhook-based (recommended for production)
|
|
7
|
+
*/
|
|
8
|
+
export type TelegramUpdateMode = "polling" | "webhook";
|
|
9
|
+
export declare const telegramEnvSchema: z.ZodObject<{
|
|
10
|
+
TELEGRAM_BOT_TOKEN: z.ZodString;
|
|
11
|
+
TELEGRAM_API_ROOT: z.ZodOptional<z.ZodString>;
|
|
12
|
+
TELEGRAM_UPDATE_MODE: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
polling: "polling";
|
|
14
|
+
webhook: "webhook";
|
|
15
|
+
}>>>;
|
|
16
|
+
TELEGRAM_WEBHOOK_URL: z.ZodOptional<z.ZodString>;
|
|
17
|
+
TELEGRAM_WEBHOOK_PATH: z.ZodOptional<z.ZodString>;
|
|
18
|
+
TELEGRAM_WEBHOOK_PORT: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
19
|
+
TELEGRAM_WEBHOOK_SECRET: z.ZodOptional<z.ZodString>;
|
|
20
|
+
TELEGRAM_ALLOWED_CHATS: z.ZodOptional<z.ZodString>;
|
|
21
|
+
TELEGRAM_PROXY_URL: z.ZodOptional<z.ZodString>;
|
|
22
|
+
TELEGRAM_DROP_PENDING_UPDATES: z.ZodDefault<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
23
|
+
TELEGRAM_SHOULD_IGNORE_BOT_MESSAGES: z.ZodDefault<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
24
|
+
TELEGRAM_SHOULD_RESPOND_ONLY_TO_MENTIONS: z.ZodDefault<z.ZodOptional<z.ZodCoercedBoolean<unknown>>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type TelegramConfig = z.infer<typeof telegramEnvSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* Extended configuration with parsed values.
|
|
29
|
+
*/
|
|
30
|
+
export interface TelegramSettings {
|
|
31
|
+
botToken: string;
|
|
32
|
+
apiRoot: string;
|
|
33
|
+
updateMode: TelegramUpdateMode;
|
|
34
|
+
webhookUrl?: string;
|
|
35
|
+
webhookPath?: string;
|
|
36
|
+
webhookPort?: number;
|
|
37
|
+
webhookSecret?: string;
|
|
38
|
+
allowedChatIds: number[];
|
|
39
|
+
proxyUrl?: string;
|
|
40
|
+
dropPendingUpdates: boolean;
|
|
41
|
+
shouldIgnoreBotMessages: boolean;
|
|
42
|
+
shouldRespondOnlyToMentions: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare function validateTelegramConfig(runtime: IAgentRuntime): Promise<TelegramConfig | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Build TelegramSettings from validated config.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildTelegramSettings(config: TelegramConfig): TelegramSettings;
|
|
49
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEvD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;iBAa5B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,uBAAuB,EAAE,OAAO,CAAC;IACjC,2BAA2B,EAAE,OAAO,CAAC;CACtC;AA+BD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAyChC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAe9E"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Chat, User } from "telegraf/types";
|
|
2
|
+
/**
|
|
3
|
+
* Options for markdown to Telegram HTML conversion
|
|
4
|
+
*/
|
|
5
|
+
export interface MarkdownToTelegramOptions {
|
|
6
|
+
/** How to handle tables: 'code' wraps in code block, 'text' converts to plain text */
|
|
7
|
+
tableMode?: "code" | "text" | "preserve";
|
|
8
|
+
/** Whether to linkify URLs */
|
|
9
|
+
linkify?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Formatted chunk with both HTML and plain text versions
|
|
13
|
+
*/
|
|
14
|
+
export interface TelegramFormattedChunk {
|
|
15
|
+
html: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Escapes HTML special characters
|
|
20
|
+
*/
|
|
21
|
+
export declare function escapeHtml(text: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Escapes HTML attribute special characters
|
|
24
|
+
*/
|
|
25
|
+
export declare function escapeHtmlAttr(text: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Escapes Telegram MarkdownV2 special characters
|
|
28
|
+
*/
|
|
29
|
+
export declare function escapeMarkdownV2(text: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Converts markdown to Telegram HTML format
|
|
32
|
+
*/
|
|
33
|
+
export declare function markdownToTelegramHtml(markdown: string, options?: MarkdownToTelegramOptions): string;
|
|
34
|
+
/**
|
|
35
|
+
* Converts markdown to Telegram HTML and splits into chunks
|
|
36
|
+
*/
|
|
37
|
+
export declare function markdownToTelegramChunks(markdown: string, limit: number, options?: MarkdownToTelegramOptions): TelegramFormattedChunk[];
|
|
38
|
+
/**
|
|
39
|
+
* Converts markdown to Telegram HTML chunks (HTML only)
|
|
40
|
+
*/
|
|
41
|
+
export declare function markdownToTelegramHtmlChunks(markdown: string, limit: number): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Strips HTML tags from text
|
|
44
|
+
*/
|
|
45
|
+
export declare function stripHtmlTags(html: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Options for chunking Telegram text
|
|
48
|
+
*/
|
|
49
|
+
export interface ChunkTelegramTextOpts {
|
|
50
|
+
/** Max characters per message. Default: 4096 */
|
|
51
|
+
maxChars?: number;
|
|
52
|
+
/** Preserve HTML tag boundaries when chunking */
|
|
53
|
+
preserveHtml?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Chunks Telegram text while preserving HTML tag boundaries
|
|
57
|
+
*/
|
|
58
|
+
export declare function chunkTelegramText(text: string, maxChars?: number): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Formats a Telegram user for display
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatTelegramUser(user: User): string;
|
|
63
|
+
/**
|
|
64
|
+
* Formats a Telegram user mention (HTML)
|
|
65
|
+
*/
|
|
66
|
+
export declare function formatTelegramUserMention(user: User): string;
|
|
67
|
+
/**
|
|
68
|
+
* Formats a Telegram chat for display
|
|
69
|
+
*/
|
|
70
|
+
export declare function formatTelegramChat(chat: Chat): string;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the chat type as a human-readable string
|
|
73
|
+
*/
|
|
74
|
+
export declare function getChatTypeString(chat: Chat): string;
|
|
75
|
+
/**
|
|
76
|
+
* Resolves the system location string for logging/display
|
|
77
|
+
*/
|
|
78
|
+
export declare function resolveTelegramSystemLocation(chat: Chat): string;
|
|
79
|
+
/**
|
|
80
|
+
* Checks if a chat is a private chat (DM)
|
|
81
|
+
*/
|
|
82
|
+
export declare function isPrivateChat(chat: Chat): chat is Chat.PrivateChat;
|
|
83
|
+
/**
|
|
84
|
+
* Checks if a chat is a group chat
|
|
85
|
+
*/
|
|
86
|
+
export declare function isGroupChat(chat: Chat): chat is Chat.GroupChat | Chat.SupergroupChat;
|
|
87
|
+
/**
|
|
88
|
+
* Checks if a chat is a channel
|
|
89
|
+
*/
|
|
90
|
+
export declare function isChannelChat(chat: Chat): chat is Chat.ChannelChat;
|
|
91
|
+
/**
|
|
92
|
+
* Truncates text to a maximum length with an ellipsis
|
|
93
|
+
*/
|
|
94
|
+
export declare function truncateText(text: string, maxLength: number, ellipsis?: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Builds a Telegram deep link URL
|
|
97
|
+
*/
|
|
98
|
+
export declare function buildTelegramDeepLink(botUsername: string, startParam?: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Builds a Telegram message link URL
|
|
101
|
+
*/
|
|
102
|
+
export declare function buildTelegramMessageLink(chatUsername: string, messageId: number): string;
|
|
103
|
+
/**
|
|
104
|
+
* Parses a Telegram message link URL
|
|
105
|
+
*/
|
|
106
|
+
export declare function parseTelegramMessageLink(url: string): {
|
|
107
|
+
chatUsername: string;
|
|
108
|
+
messageId: number;
|
|
109
|
+
} | null;
|
|
110
|
+
/**
|
|
111
|
+
* Formats a caption for media messages
|
|
112
|
+
*/
|
|
113
|
+
export declare function formatMediaCaption(text: string, maxLength?: number): string;
|
|
114
|
+
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IACzC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,w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AAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAIhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,WAAW,CAElE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAEpF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,WAAW,CAElE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,MAAM,CAKpF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAMtF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAExF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,GACV;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,GAAG,MAAM,CAsBjF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Plugin } from "@elizaos/core";
|
|
2
|
+
import { DELETE_MESSAGE_ACTION, deleteMessageAction, EDIT_MESSAGE_ACTION, editMessageAction, SEND_MESSAGE_ACTION, SEND_REACTION_ACTION, SEND_STICKER_ACTION, sendMessageAction, sendReactionAction, sendStickerAction } from "./actions";
|
|
3
|
+
import { buildTelegramSettings, type TelegramSettings, type TelegramUpdateMode, validateTelegramConfig } from "./environment";
|
|
4
|
+
import { MessageManager } from "./messageManager";
|
|
5
|
+
import { CHAT_STATE_PROVIDER, chatStateProvider } from "./providers";
|
|
6
|
+
import { TelegramService } from "./service";
|
|
7
|
+
import { type SendReactionParams, type SendReactionResult, TELEGRAM_REACTIONS, type TelegramBotInfo, type TelegramBotProbe, type TelegramContent, TelegramEventTypes, type TelegramReactionEmoji } from "./types";
|
|
8
|
+
declare const telegramPlugin: Plugin;
|
|
9
|
+
export { TelegramService, MessageManager, sendMessageAction, SEND_MESSAGE_ACTION, sendReactionAction, SEND_REACTION_ACTION, editMessageAction, EDIT_MESSAGE_ACTION, deleteMessageAction, DELETE_MESSAGE_ACTION, sendStickerAction, SEND_STICKER_ACTION, chatStateProvider, CHAT_STATE_PROVIDER, TelegramEventTypes, TELEGRAM_REACTIONS, type TelegramContent, type TelegramBotProbe, type SendReactionParams, type SendReactionResult, type TelegramBotInfo, type TelegramReactionEmoji, type TelegramSettings, type TelegramUpdateMode, buildTelegramSettings, validateTelegramConfig, };
|
|
10
|
+
export { DEFAULT_ACCOUNT_ID, isMultiAccountEnabled, listEnabledTelegramAccounts, listTelegramAccountIds, normalizeAccountId, normalizeTelegramToken, type ResolvedTelegramAccount, resolveDefaultTelegramAccountId, resolveTelegramAccount, resolveTelegramToken, type TelegramAccountRuntimeConfig, type TelegramDmConfig, type TelegramGroupRuntimeConfig, type TelegramMultiAccountConfig, type TelegramTokenResolution, type TelegramTokenSource, } from "./accounts";
|
|
11
|
+
export { buildTelegramDeepLink, buildTelegramMessageLink, type ChunkTelegramTextOpts, chunkTelegramText, escapeHtml, escapeHtmlAttr, escapeMarkdownV2, formatMediaCaption, formatTelegramChat, formatTelegramUser, formatTelegramUserMention, getChatTypeString, isChannelChat, isGroupChat, isPrivateChat, type MarkdownToTelegramOptions, markdownToTelegramChunks, markdownToTelegramHtml, markdownToTelegramHtmlChunks, parseTelegramMessageLink, resolveTelegramSystemLocation, stripHtmlTags, type TelegramFormattedChunk, truncateText, } from "./formatting";
|
|
12
|
+
export default telegramPlugin;
|
|
13
|
+
export type { TelegramAccountConfig, TelegramActionConfig, TelegramCapabilitiesConfig, TelegramChannelConfig, TelegramConfig, TelegramCustomCommand, TelegramGroupConfig, TelegramInlineButtonsScope, TelegramNetworkConfig, TelegramTopicConfig, } from "./config";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,kBAAkB,EAClB,KAAK,qBAAqB,EAC3B,MAAM,SAAS,CAAC;AAEjB,QAAA,MAAM,cAAc,EAAE,MAarB,CAAC;AAEF,OAAO,EAEL,eAAe,EACf,cAAc,EAEd,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,iB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