@adminforth/chat-surface-adapter-telegram 1.0.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/.woodpecker/buildRelease.sh +9 -0
- package/.woodpecker/buildSlackNotify.sh +44 -0
- package/.woodpecker/release.yml +56 -0
- package/LICENSE +21 -0
- package/build.log +4 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +263 -0
- package/dist/types.d.ts +31 -0
- package/dist/types.js +1 -0
- package/index.ts +346 -0
- package/package.json +61 -0
- package/tsconfig.json +14 -0
- package/types.ts +37 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -x
|
|
4
|
+
|
|
5
|
+
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
|
|
6
|
+
|
|
7
|
+
STATUS=${1}
|
|
8
|
+
|
|
9
|
+
if [ "$STATUS" = "success" ]; then
|
|
10
|
+
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
11
|
+
|
|
12
|
+
curl -s -X POST -H "Content-Type: application/json" -d '{
|
|
13
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
14
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
15
|
+
"attachments": [
|
|
16
|
+
{
|
|
17
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
18
|
+
"color": "#36a64f",
|
|
19
|
+
"text": "'"$MESSAGE"'"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK"
|
|
23
|
+
exit 0
|
|
24
|
+
fi
|
|
25
|
+
export BUILD_LOG=$(cat ./build.log)
|
|
26
|
+
|
|
27
|
+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
|
|
28
|
+
|
|
29
|
+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
30
|
+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
|
|
31
|
+
|
|
32
|
+
echo "Sending slack message to developers $MESSAGE"
|
|
33
|
+
curl -sS -X POST -H "Content-Type: application/json" -d '{
|
|
34
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
35
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
36
|
+
"attachments": [
|
|
37
|
+
{
|
|
38
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
39
|
+
"color": "#8A1C12",
|
|
40
|
+
"text": "'"$CODE_BLOCK"'",
|
|
41
|
+
"pretext": "'"$MESSAGE"'"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
clone:
|
|
2
|
+
git:
|
|
3
|
+
image: woodpeckerci/plugin-git
|
|
4
|
+
settings:
|
|
5
|
+
partial: false
|
|
6
|
+
depth: 5
|
|
7
|
+
|
|
8
|
+
steps:
|
|
9
|
+
init-secrets:
|
|
10
|
+
when:
|
|
11
|
+
- event: push
|
|
12
|
+
image: infisical/cli
|
|
13
|
+
environment:
|
|
14
|
+
INFISICAL_TOKEN:
|
|
15
|
+
from_secret: VAULT_TOKEN
|
|
16
|
+
commands:
|
|
17
|
+
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
|
|
18
|
+
|
|
19
|
+
build:
|
|
20
|
+
image: devforth/node20-pnpm:latest
|
|
21
|
+
when:
|
|
22
|
+
- event: push
|
|
23
|
+
commands:
|
|
24
|
+
- . /woodpecker/deploy.vault.env
|
|
25
|
+
- pnpm install
|
|
26
|
+
- /bin/bash ./.woodpecker/buildRelease.sh
|
|
27
|
+
- npm audit signatures
|
|
28
|
+
|
|
29
|
+
release:
|
|
30
|
+
image: devforth/node20-pnpm:latest
|
|
31
|
+
when:
|
|
32
|
+
- event:
|
|
33
|
+
- push
|
|
34
|
+
branch:
|
|
35
|
+
- main
|
|
36
|
+
commands:
|
|
37
|
+
- . /woodpecker/deploy.vault.env
|
|
38
|
+
- pnpm exec semantic-release
|
|
39
|
+
|
|
40
|
+
slack-on-failure:
|
|
41
|
+
image: curlimages/curl
|
|
42
|
+
when:
|
|
43
|
+
- event: push
|
|
44
|
+
status: [failure]
|
|
45
|
+
commands:
|
|
46
|
+
- . /woodpecker/deploy.vault.env
|
|
47
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh failure
|
|
48
|
+
|
|
49
|
+
slack-on-success:
|
|
50
|
+
image: curlimages/curl
|
|
51
|
+
when:
|
|
52
|
+
- event: push
|
|
53
|
+
status: [success]
|
|
54
|
+
commands:
|
|
55
|
+
- . /woodpecker/deploy.vault.env
|
|
56
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh success
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Devforth.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/build.log
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AdminUser, type ChatSurfaceAdapter, type ChatSurfaceEventSink, type ChatSurfaceIncomingMessage, type ChatSurfaceRequestContext, type IAdminForth } from "adminforth";
|
|
2
|
+
import { AdapterOptions } from "./types.js";
|
|
3
|
+
export type { AdapterOptions, TelegramStreamingMode } from "./types.js";
|
|
4
|
+
type TelegramUpdate = {
|
|
5
|
+
message?: {
|
|
6
|
+
text?: string;
|
|
7
|
+
chat?: {
|
|
8
|
+
id?: number | string;
|
|
9
|
+
};
|
|
10
|
+
from?: {
|
|
11
|
+
id?: number | string;
|
|
12
|
+
username?: string;
|
|
13
|
+
first_name?: string;
|
|
14
|
+
last_name?: string;
|
|
15
|
+
language_code?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare class TelegramChatSurfaceAdapter implements ChatSurfaceAdapter {
|
|
20
|
+
private options;
|
|
21
|
+
name: string;
|
|
22
|
+
constructor(options: AdapterOptions);
|
|
23
|
+
validate(): void;
|
|
24
|
+
parseIncomingMessage(ctx: ChatSurfaceRequestContext): Promise<{
|
|
25
|
+
surface: string;
|
|
26
|
+
prompt: string;
|
|
27
|
+
externalConversationId: string;
|
|
28
|
+
externalUserId: string;
|
|
29
|
+
userTimeZone: string;
|
|
30
|
+
metadata: {
|
|
31
|
+
telegramUpdate: TelegramUpdate;
|
|
32
|
+
};
|
|
33
|
+
} | null>;
|
|
34
|
+
createEventSink(ctx: ChatSurfaceRequestContext, incoming: ChatSurfaceIncomingMessage): ChatSurfaceEventSink;
|
|
35
|
+
resolveAdminUser(input: {
|
|
36
|
+
adminforth: IAdminForth;
|
|
37
|
+
incoming: ChatSurfaceIncomingMessage;
|
|
38
|
+
}): Promise<AdminUser | null>;
|
|
39
|
+
private sendMessage;
|
|
40
|
+
private sendChatAction;
|
|
41
|
+
private sendMessageDraft;
|
|
42
|
+
}
|
|
43
|
+
export default TelegramChatSurfaceAdapter;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { AdminForthFilterOperators, } from "adminforth";
|
|
11
|
+
import { randomInt } from "node:crypto";
|
|
12
|
+
const TELEGRAM_API_BASE_URL = "https://api.telegram.org";
|
|
13
|
+
const TELEGRAM_SECRET_HEADER = "x-telegram-bot-api-secret-token";
|
|
14
|
+
const TELEGRAM_MESSAGE_MAX_LENGTH = 4096;
|
|
15
|
+
const TELEGRAM_DRAFT_MAX_LENGTH = 4096;
|
|
16
|
+
const DEFAULT_DRAFT_UPDATE_INTERVAL_MS = 650;
|
|
17
|
+
const DEFAULT_TYPING_INTERVAL_MS = 4000;
|
|
18
|
+
const DEFAULT_ADMIN_USER_RESOURCE_ID = "adminuser";
|
|
19
|
+
const DEFAULT_ADMIN_USER_TELEGRAM_ID_FIELD = "telegramId";
|
|
20
|
+
function createTelegramDraftId() {
|
|
21
|
+
return randomInt(1, 2147483647);
|
|
22
|
+
}
|
|
23
|
+
function truncateTelegramDraft(text) {
|
|
24
|
+
if (text.length <= TELEGRAM_DRAFT_MAX_LENGTH) {
|
|
25
|
+
return text;
|
|
26
|
+
}
|
|
27
|
+
return `${text.slice(0, TELEGRAM_DRAFT_MAX_LENGTH - 1)}…`;
|
|
28
|
+
}
|
|
29
|
+
function isPrivateChatId(chatId) {
|
|
30
|
+
const numericChatId = Number(chatId);
|
|
31
|
+
return Number.isInteger(numericChatId) && numericChatId > 0;
|
|
32
|
+
}
|
|
33
|
+
function getHeaderValue(headers, name) {
|
|
34
|
+
const value = headers[name.toLowerCase()];
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
return String(value[0]);
|
|
37
|
+
}
|
|
38
|
+
return typeof value === "undefined" ? undefined : String(value);
|
|
39
|
+
}
|
|
40
|
+
function splitTelegramMessage(text) {
|
|
41
|
+
const chunks = [];
|
|
42
|
+
for (let index = 0; index < text.length; index += TELEGRAM_MESSAGE_MAX_LENGTH) {
|
|
43
|
+
chunks.push(text.slice(index, index + TELEGRAM_MESSAGE_MAX_LENGTH));
|
|
44
|
+
}
|
|
45
|
+
return chunks;
|
|
46
|
+
}
|
|
47
|
+
export class TelegramChatSurfaceAdapter {
|
|
48
|
+
constructor(options) {
|
|
49
|
+
this.options = options;
|
|
50
|
+
this.name = "telegram";
|
|
51
|
+
}
|
|
52
|
+
validate() {
|
|
53
|
+
if (!this.options.botToken) {
|
|
54
|
+
throw new Error("Telegram botToken is required");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
parseIncomingMessage(ctx) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
60
|
+
if (this.options.webhookSecret
|
|
61
|
+
&& getHeaderValue(ctx.headers, TELEGRAM_SECRET_HEADER) !== this.options.webhookSecret) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const update = ctx.body;
|
|
65
|
+
const text = (_a = update.message) === null || _a === void 0 ? void 0 : _a.text;
|
|
66
|
+
const chatId = (_c = (_b = update.message) === null || _b === void 0 ? void 0 : _b.chat) === null || _c === void 0 ? void 0 : _c.id;
|
|
67
|
+
const userId = (_e = (_d = update.message) === null || _d === void 0 ? void 0 : _d.from) === null || _e === void 0 ? void 0 : _e.id;
|
|
68
|
+
if (!text || chatId === undefined || userId === undefined) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
surface: this.name,
|
|
73
|
+
prompt: text,
|
|
74
|
+
externalConversationId: String(chatId),
|
|
75
|
+
externalUserId: String(userId),
|
|
76
|
+
userTimeZone: "UTC",
|
|
77
|
+
metadata: {
|
|
78
|
+
telegramUpdate: update,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
createEventSink(ctx, incoming) {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
let text = "";
|
|
86
|
+
let lastDraftText = "";
|
|
87
|
+
let draftTimer;
|
|
88
|
+
let typingTimer;
|
|
89
|
+
let closed = false;
|
|
90
|
+
let done = false;
|
|
91
|
+
const chatId = incoming.externalConversationId;
|
|
92
|
+
const configuredStreamingMode = (_a = this.options.streamingMode) !== null && _a !== void 0 ? _a : "draft";
|
|
93
|
+
const streamingMode = configuredStreamingMode === "draft" && !isPrivateChatId(chatId)
|
|
94
|
+
? "typing"
|
|
95
|
+
: configuredStreamingMode;
|
|
96
|
+
const draftUpdateIntervalMs = (_b = this.options.draftUpdateIntervalMs) !== null && _b !== void 0 ? _b : DEFAULT_DRAFT_UPDATE_INTERVAL_MS;
|
|
97
|
+
const draftId = createTelegramDraftId();
|
|
98
|
+
const stopTyping = () => {
|
|
99
|
+
if (typingTimer) {
|
|
100
|
+
clearInterval(typingTimer);
|
|
101
|
+
typingTimer = undefined;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const startTyping = () => {
|
|
105
|
+
if (typingTimer || streamingMode === "off") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
void this.sendChatAction(chatId, "typing").catch(() => undefined);
|
|
109
|
+
typingTimer = setInterval(() => {
|
|
110
|
+
void this.sendChatAction(chatId, "typing").catch(() => undefined);
|
|
111
|
+
}, DEFAULT_TYPING_INTERVAL_MS);
|
|
112
|
+
};
|
|
113
|
+
const clearDraftTimer = () => {
|
|
114
|
+
if (draftTimer) {
|
|
115
|
+
clearTimeout(draftTimer);
|
|
116
|
+
draftTimer = undefined;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const flushDraft = () => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
if (closed ||
|
|
121
|
+
done ||
|
|
122
|
+
streamingMode !== "draft" ||
|
|
123
|
+
!text) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const draftText = truncateTelegramDraft(text);
|
|
127
|
+
if (draftText === lastDraftText) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
lastDraftText = draftText;
|
|
131
|
+
yield this.sendMessageDraft({
|
|
132
|
+
chatId,
|
|
133
|
+
draftId,
|
|
134
|
+
text: draftText,
|
|
135
|
+
parseMode: "Markdown",
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
const scheduleDraftFlush = () => {
|
|
139
|
+
if (streamingMode !== "draft" || draftTimer) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
draftTimer = setTimeout(() => {
|
|
143
|
+
draftTimer = undefined;
|
|
144
|
+
void flushDraft().catch(() => undefined);
|
|
145
|
+
}, draftUpdateIntervalMs);
|
|
146
|
+
};
|
|
147
|
+
startTyping();
|
|
148
|
+
return {
|
|
149
|
+
emit: (event) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
if (closed) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (event.type === "text_delta") {
|
|
154
|
+
text += event.delta;
|
|
155
|
+
if (streamingMode === "draft") {
|
|
156
|
+
scheduleDraftFlush();
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (event.type === "done") {
|
|
161
|
+
done = true;
|
|
162
|
+
stopTyping();
|
|
163
|
+
clearDraftTimer();
|
|
164
|
+
yield this.sendMessage(chatId, text || event.text);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (event.type === "error") {
|
|
168
|
+
done = true;
|
|
169
|
+
stopTyping();
|
|
170
|
+
clearDraftTimer();
|
|
171
|
+
yield this.sendMessage(chatId, event.message);
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
close: () => __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
closed = true;
|
|
176
|
+
stopTyping();
|
|
177
|
+
clearDraftTimer();
|
|
178
|
+
}),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
resolveAdminUser(input) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
var _a, _b;
|
|
184
|
+
const adminUserResourceId = (_a = this.options.adminUserResourceId) !== null && _a !== void 0 ? _a : DEFAULT_ADMIN_USER_RESOURCE_ID;
|
|
185
|
+
const telegramIdField = (_b = this.options.adminUserTelegramIdField) !== null && _b !== void 0 ? _b : DEFAULT_ADMIN_USER_TELEGRAM_ID_FIELD;
|
|
186
|
+
const adminUser = yield input.adminforth.resource(adminUserResourceId).get([
|
|
187
|
+
{
|
|
188
|
+
field: telegramIdField,
|
|
189
|
+
operator: AdminForthFilterOperators.EQ,
|
|
190
|
+
value: input.incoming.externalUserId,
|
|
191
|
+
},
|
|
192
|
+
]);
|
|
193
|
+
if (!adminUser) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
pk: adminUser.id,
|
|
198
|
+
username: adminUser[input.adminforth.config.auth.usernameField],
|
|
199
|
+
dbUser: adminUser,
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
sendMessage(chatId, text) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
if (!text) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
for (const chunk of splitTelegramMessage(text)) {
|
|
209
|
+
const response = yield fetch(`${TELEGRAM_API_BASE_URL}/bot${this.options.botToken}/sendMessage`, {
|
|
210
|
+
method: "POST",
|
|
211
|
+
headers: {
|
|
212
|
+
"Content-Type": "application/json",
|
|
213
|
+
},
|
|
214
|
+
body: JSON.stringify({
|
|
215
|
+
chat_id: chatId,
|
|
216
|
+
text: chunk,
|
|
217
|
+
parse_mode: "Markdown",
|
|
218
|
+
}),
|
|
219
|
+
});
|
|
220
|
+
if (!response.ok) {
|
|
221
|
+
throw new Error(`Telegram sendMessage failed: ${response.status} ${yield response.text()}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
sendChatAction(chatId, action) {
|
|
227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
const response = yield fetch(`${TELEGRAM_API_BASE_URL}/bot${this.options.botToken}/sendChatAction`, {
|
|
229
|
+
method: "POST",
|
|
230
|
+
headers: {
|
|
231
|
+
"Content-Type": "application/json",
|
|
232
|
+
},
|
|
233
|
+
body: JSON.stringify({
|
|
234
|
+
chat_id: chatId,
|
|
235
|
+
action,
|
|
236
|
+
}),
|
|
237
|
+
});
|
|
238
|
+
if (!response.ok) {
|
|
239
|
+
throw new Error(`Telegram sendChatAction failed: ${response.status} ${yield response.text()}`);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
sendMessageDraft(input) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
const response = yield fetch(`${TELEGRAM_API_BASE_URL}/bot${this.options.botToken}/sendMessageDraft`, {
|
|
246
|
+
method: "POST",
|
|
247
|
+
headers: {
|
|
248
|
+
"Content-Type": "application/json",
|
|
249
|
+
},
|
|
250
|
+
body: JSON.stringify({
|
|
251
|
+
chat_id: Number(input.chatId),
|
|
252
|
+
draft_id: input.draftId,
|
|
253
|
+
text: input.text,
|
|
254
|
+
parse_mode: input.parseMode,
|
|
255
|
+
}),
|
|
256
|
+
});
|
|
257
|
+
if (!response.ok) {
|
|
258
|
+
throw new Error(`Telegram sendMessageDraft failed: ${response.status} ${yield response.text()}`);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
export default TelegramChatSurfaceAdapter;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type TelegramStreamingMode = "draft" | "typing" | "off";
|
|
2
|
+
export type AdapterOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Telegram bot token from BotFather.
|
|
5
|
+
*/
|
|
6
|
+
botToken: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional secret token configured in Telegram setWebhook.
|
|
9
|
+
*/
|
|
10
|
+
webhookSecret?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Streaming behavior for Telegram responses.
|
|
13
|
+
* Default is `draft`.
|
|
14
|
+
*/
|
|
15
|
+
streamingMode?: TelegramStreamingMode;
|
|
16
|
+
/**
|
|
17
|
+
* Draft preview update throttle interval.
|
|
18
|
+
* Default is 650ms.
|
|
19
|
+
*/
|
|
20
|
+
draftUpdateIntervalMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* AdminForth admin user field that stores Telegram user id.
|
|
23
|
+
* Default is `telegramId`.
|
|
24
|
+
*/
|
|
25
|
+
adminUserTelegramIdField?: string;
|
|
26
|
+
/**
|
|
27
|
+
* AdminForth admin users resource id.
|
|
28
|
+
* Default is `adminuser`.
|
|
29
|
+
*/
|
|
30
|
+
adminUserResourceId?: string;
|
|
31
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.ts
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AdminForthFilterOperators,
|
|
3
|
+
type AdminUser,
|
|
4
|
+
type ChatSurfaceAdapter,
|
|
5
|
+
type ChatSurfaceEventSink,
|
|
6
|
+
type ChatSurfaceIncomingMessage,
|
|
7
|
+
type ChatSurfaceRequestContext,
|
|
8
|
+
type IAdminForth,
|
|
9
|
+
} from "adminforth";
|
|
10
|
+
import { AdapterOptions } from "./types.js";
|
|
11
|
+
import { randomInt } from "node:crypto";
|
|
12
|
+
export type { AdapterOptions, TelegramStreamingMode } from "./types.js";
|
|
13
|
+
|
|
14
|
+
type TelegramUpdate = {
|
|
15
|
+
message?: {
|
|
16
|
+
text?: string;
|
|
17
|
+
chat?: {
|
|
18
|
+
id?: number | string;
|
|
19
|
+
};
|
|
20
|
+
from?: {
|
|
21
|
+
id?: number | string;
|
|
22
|
+
username?: string;
|
|
23
|
+
first_name?: string;
|
|
24
|
+
last_name?: string;
|
|
25
|
+
language_code?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const TELEGRAM_API_BASE_URL = "https://api.telegram.org";
|
|
31
|
+
const TELEGRAM_SECRET_HEADER = "x-telegram-bot-api-secret-token";
|
|
32
|
+
const TELEGRAM_MESSAGE_MAX_LENGTH = 4096;
|
|
33
|
+
const TELEGRAM_DRAFT_MAX_LENGTH = 4096;
|
|
34
|
+
const DEFAULT_DRAFT_UPDATE_INTERVAL_MS = 650;
|
|
35
|
+
const DEFAULT_TYPING_INTERVAL_MS = 4000;
|
|
36
|
+
const DEFAULT_ADMIN_USER_RESOURCE_ID = "adminuser";
|
|
37
|
+
const DEFAULT_ADMIN_USER_TELEGRAM_ID_FIELD = "telegramId";
|
|
38
|
+
|
|
39
|
+
function createTelegramDraftId() {
|
|
40
|
+
return randomInt(1, 2147483647);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function truncateTelegramDraft(text: string) {
|
|
44
|
+
if (text.length <= TELEGRAM_DRAFT_MAX_LENGTH) {
|
|
45
|
+
return text;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return `${text.slice(0, TELEGRAM_DRAFT_MAX_LENGTH - 1)}…`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isPrivateChatId(chatId: string) {
|
|
52
|
+
const numericChatId = Number(chatId);
|
|
53
|
+
|
|
54
|
+
return Number.isInteger(numericChatId) && numericChatId > 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getHeaderValue(
|
|
58
|
+
headers: ChatSurfaceRequestContext["headers"],
|
|
59
|
+
name: string,
|
|
60
|
+
) {
|
|
61
|
+
const value = headers[name.toLowerCase()];
|
|
62
|
+
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
return String(value[0]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return typeof value === "undefined" ? undefined : String(value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function splitTelegramMessage(text: string) {
|
|
71
|
+
const chunks: string[] = [];
|
|
72
|
+
|
|
73
|
+
for (let index = 0; index < text.length; index += TELEGRAM_MESSAGE_MAX_LENGTH) {
|
|
74
|
+
chunks.push(text.slice(index, index + TELEGRAM_MESSAGE_MAX_LENGTH));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return chunks;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class TelegramChatSurfaceAdapter implements ChatSurfaceAdapter {
|
|
81
|
+
name = "telegram";
|
|
82
|
+
|
|
83
|
+
constructor(private options: AdapterOptions) {}
|
|
84
|
+
|
|
85
|
+
validate() {
|
|
86
|
+
if (!this.options.botToken) {
|
|
87
|
+
throw new Error("Telegram botToken is required");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async parseIncomingMessage(ctx: ChatSurfaceRequestContext) {
|
|
92
|
+
if (
|
|
93
|
+
this.options.webhookSecret
|
|
94
|
+
&& getHeaderValue(ctx.headers, TELEGRAM_SECRET_HEADER) !== this.options.webhookSecret
|
|
95
|
+
) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const update = ctx.body as TelegramUpdate;
|
|
100
|
+
const text = update.message?.text;
|
|
101
|
+
const chatId = update.message?.chat?.id;
|
|
102
|
+
const userId = update.message?.from?.id;
|
|
103
|
+
|
|
104
|
+
if (!text || chatId === undefined || userId === undefined) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
surface: this.name,
|
|
110
|
+
prompt: text,
|
|
111
|
+
externalConversationId: String(chatId),
|
|
112
|
+
externalUserId: String(userId),
|
|
113
|
+
userTimeZone: "UTC",
|
|
114
|
+
metadata: {
|
|
115
|
+
telegramUpdate: update,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
createEventSink(
|
|
121
|
+
ctx: ChatSurfaceRequestContext,
|
|
122
|
+
incoming: ChatSurfaceIncomingMessage,
|
|
123
|
+
): ChatSurfaceEventSink {
|
|
124
|
+
let text = "";
|
|
125
|
+
let lastDraftText = "";
|
|
126
|
+
let draftTimer: ReturnType<typeof setTimeout> | undefined;
|
|
127
|
+
let typingTimer: ReturnType<typeof setInterval> | undefined;
|
|
128
|
+
let closed = false;
|
|
129
|
+
let done = false;
|
|
130
|
+
|
|
131
|
+
const chatId = incoming.externalConversationId;
|
|
132
|
+
const configuredStreamingMode = this.options.streamingMode ?? "draft";
|
|
133
|
+
const streamingMode =
|
|
134
|
+
configuredStreamingMode === "draft" && !isPrivateChatId(chatId)
|
|
135
|
+
? "typing"
|
|
136
|
+
: configuredStreamingMode;
|
|
137
|
+
const draftUpdateIntervalMs =
|
|
138
|
+
this.options.draftUpdateIntervalMs ?? DEFAULT_DRAFT_UPDATE_INTERVAL_MS;
|
|
139
|
+
const draftId = createTelegramDraftId();
|
|
140
|
+
|
|
141
|
+
const stopTyping = () => {
|
|
142
|
+
if (typingTimer) {
|
|
143
|
+
clearInterval(typingTimer);
|
|
144
|
+
typingTimer = undefined;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const startTyping = () => {
|
|
149
|
+
if (typingTimer || streamingMode === "off") {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
void this.sendChatAction(chatId, "typing").catch(() => undefined);
|
|
154
|
+
|
|
155
|
+
typingTimer = setInterval(() => {
|
|
156
|
+
void this.sendChatAction(chatId, "typing").catch(() => undefined);
|
|
157
|
+
}, DEFAULT_TYPING_INTERVAL_MS);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const clearDraftTimer = () => {
|
|
161
|
+
if (draftTimer) {
|
|
162
|
+
clearTimeout(draftTimer);
|
|
163
|
+
draftTimer = undefined;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const flushDraft = async () => {
|
|
168
|
+
if (
|
|
169
|
+
closed ||
|
|
170
|
+
done ||
|
|
171
|
+
streamingMode !== "draft" ||
|
|
172
|
+
!text
|
|
173
|
+
) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const draftText = truncateTelegramDraft(text);
|
|
178
|
+
|
|
179
|
+
if (draftText === lastDraftText) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
lastDraftText = draftText;
|
|
184
|
+
|
|
185
|
+
await this.sendMessageDraft({
|
|
186
|
+
chatId,
|
|
187
|
+
draftId,
|
|
188
|
+
text: draftText,
|
|
189
|
+
parseMode: "Markdown",
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const scheduleDraftFlush = () => {
|
|
194
|
+
if (streamingMode !== "draft" || draftTimer) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
draftTimer = setTimeout(() => {
|
|
199
|
+
draftTimer = undefined;
|
|
200
|
+
|
|
201
|
+
void flushDraft().catch(() => undefined);
|
|
202
|
+
}, draftUpdateIntervalMs);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
startTyping();
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
emit: async (event) => {
|
|
209
|
+
if (closed) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (event.type === "text_delta") {
|
|
214
|
+
text += event.delta;
|
|
215
|
+
|
|
216
|
+
if (streamingMode === "draft") {
|
|
217
|
+
scheduleDraftFlush();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (event.type === "done") {
|
|
224
|
+
done = true;
|
|
225
|
+
stopTyping();
|
|
226
|
+
clearDraftTimer();
|
|
227
|
+
|
|
228
|
+
await this.sendMessage(
|
|
229
|
+
chatId,
|
|
230
|
+
text || event.text,
|
|
231
|
+
);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (event.type === "error") {
|
|
236
|
+
done = true;
|
|
237
|
+
stopTyping();
|
|
238
|
+
clearDraftTimer();
|
|
239
|
+
|
|
240
|
+
await this.sendMessage(
|
|
241
|
+
chatId,
|
|
242
|
+
event.message,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
close: async () => {
|
|
248
|
+
closed = true;
|
|
249
|
+
stopTyping();
|
|
250
|
+
clearDraftTimer();
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async resolveAdminUser(input: {
|
|
256
|
+
adminforth: IAdminForth;
|
|
257
|
+
incoming: ChatSurfaceIncomingMessage;
|
|
258
|
+
}): Promise<AdminUser | null> {
|
|
259
|
+
const adminUserResourceId = this.options.adminUserResourceId ?? DEFAULT_ADMIN_USER_RESOURCE_ID;
|
|
260
|
+
const telegramIdField = this.options.adminUserTelegramIdField ?? DEFAULT_ADMIN_USER_TELEGRAM_ID_FIELD;
|
|
261
|
+
const adminUser = await input.adminforth.resource(adminUserResourceId).get([
|
|
262
|
+
{
|
|
263
|
+
field: telegramIdField,
|
|
264
|
+
operator: AdminForthFilterOperators.EQ,
|
|
265
|
+
value: input.incoming.externalUserId,
|
|
266
|
+
},
|
|
267
|
+
]);
|
|
268
|
+
|
|
269
|
+
if (!adminUser) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return {
|
|
274
|
+
pk: adminUser.id,
|
|
275
|
+
username: adminUser[input.adminforth.config.auth!.usernameField],
|
|
276
|
+
dbUser: adminUser,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private async sendMessage(chatId: string, text: string) {
|
|
281
|
+
if (!text) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
for (const chunk of splitTelegramMessage(text)) {
|
|
286
|
+
const response = await fetch(`${TELEGRAM_API_BASE_URL}/bot${this.options.botToken}/sendMessage`, {
|
|
287
|
+
method: "POST",
|
|
288
|
+
headers: {
|
|
289
|
+
"Content-Type": "application/json",
|
|
290
|
+
},
|
|
291
|
+
body: JSON.stringify({
|
|
292
|
+
chat_id: chatId,
|
|
293
|
+
text: chunk,
|
|
294
|
+
parse_mode: "Markdown",
|
|
295
|
+
}),
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
if (!response.ok) {
|
|
299
|
+
throw new Error(`Telegram sendMessage failed: ${response.status} ${await response.text()}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
private async sendChatAction(chatId: string, action: "typing") {
|
|
305
|
+
const response = await fetch(`${TELEGRAM_API_BASE_URL}/bot${this.options.botToken}/sendChatAction`, {
|
|
306
|
+
method: "POST",
|
|
307
|
+
headers: {
|
|
308
|
+
"Content-Type": "application/json",
|
|
309
|
+
},
|
|
310
|
+
body: JSON.stringify({
|
|
311
|
+
chat_id: chatId,
|
|
312
|
+
action,
|
|
313
|
+
}),
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
if (!response.ok) {
|
|
317
|
+
throw new Error(`Telegram sendChatAction failed: ${response.status} ${await response.text()}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private async sendMessageDraft(input: {
|
|
322
|
+
chatId: string;
|
|
323
|
+
draftId: number;
|
|
324
|
+
text: string;
|
|
325
|
+
parseMode?: "Markdown" | "MarkdownV2" | "HTML";
|
|
326
|
+
}) {
|
|
327
|
+
const response = await fetch(`${TELEGRAM_API_BASE_URL}/bot${this.options.botToken}/sendMessageDraft`, {
|
|
328
|
+
method: "POST",
|
|
329
|
+
headers: {
|
|
330
|
+
"Content-Type": "application/json",
|
|
331
|
+
},
|
|
332
|
+
body: JSON.stringify({
|
|
333
|
+
chat_id: Number(input.chatId),
|
|
334
|
+
draft_id: input.draftId,
|
|
335
|
+
text: input.text,
|
|
336
|
+
parse_mode: input.parseMode,
|
|
337
|
+
}),
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
if (!response.ok) {
|
|
341
|
+
throw new Error(`Telegram sendMessageDraft failed: ${response.status} ${await response.text()}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export default TelegramChatSurfaceAdapter;
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adminforth/chat-surface-adapter-telegram",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"homepage": "https://adminforth.dev/docs/tutorial/Adapters/chat-surface-adapter-telegram/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/devforth/adminforth-chat-surface-adapter-telegram.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"adminforth",
|
|
20
|
+
"telegram",
|
|
21
|
+
"chat-surface",
|
|
22
|
+
"ai-agent"
|
|
23
|
+
],
|
|
24
|
+
"author": "DevForth (https://devforth.io)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"description": "AdminForth Agent chat surface adapter for Telegram bots.",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"semantic-release": "^24.2.9",
|
|
29
|
+
"semantic-release-slack-bot": "^4.0.2",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@adminforth/agent": ">=1.0.2",
|
|
34
|
+
"adminforth": ">=2.59.0"
|
|
35
|
+
},
|
|
36
|
+
"release": {
|
|
37
|
+
"plugins": [
|
|
38
|
+
"@semantic-release/commit-analyzer",
|
|
39
|
+
"@semantic-release/release-notes-generator",
|
|
40
|
+
"@semantic-release/npm",
|
|
41
|
+
"@semantic-release/github",
|
|
42
|
+
[
|
|
43
|
+
"semantic-release-slack-bot",
|
|
44
|
+
{
|
|
45
|
+
"packageName": "@adminforth/chat-surface-adapter-telegram",
|
|
46
|
+
"notifyOnSuccess": true,
|
|
47
|
+
"notifyOnFail": true,
|
|
48
|
+
"slackIcon": ":package:",
|
|
49
|
+
"markdownReleaseNotes": true
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
],
|
|
53
|
+
"branches": [
|
|
54
|
+
"main",
|
|
55
|
+
{
|
|
56
|
+
"name": "next",
|
|
57
|
+
"prerelease": true
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2016",
|
|
4
|
+
"module": "node16",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"strict": false,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strictNullChecks": true
|
|
12
|
+
},
|
|
13
|
+
"exclude": ["node_modules", "dist", "custom"]
|
|
14
|
+
}
|
package/types.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type TelegramStreamingMode = "draft" | "typing" | "off";
|
|
2
|
+
|
|
3
|
+
export type AdapterOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Telegram bot token from BotFather.
|
|
6
|
+
*/
|
|
7
|
+
botToken: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Optional secret token configured in Telegram setWebhook.
|
|
11
|
+
*/
|
|
12
|
+
webhookSecret?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Streaming behavior for Telegram responses.
|
|
16
|
+
* Default is `draft`.
|
|
17
|
+
*/
|
|
18
|
+
streamingMode?: TelegramStreamingMode;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Draft preview update throttle interval.
|
|
22
|
+
* Default is 650ms.
|
|
23
|
+
*/
|
|
24
|
+
draftUpdateIntervalMs?: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* AdminForth admin user field that stores Telegram user id.
|
|
28
|
+
* Default is `telegramId`.
|
|
29
|
+
*/
|
|
30
|
+
adminUserTelegramIdField?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* AdminForth admin users resource id.
|
|
34
|
+
* Default is `adminuser`.
|
|
35
|
+
*/
|
|
36
|
+
adminUserResourceId?: string;
|
|
37
|
+
};
|