@deadragdoll/tellymcp 0.0.12 → 0.0.14
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/.env.example.client +5 -1
- package/.env.example.gateway +16 -1
- package/CHANGELOG.md +30 -0
- package/README-ru.md +33 -0
- package/README.md +33 -0
- package/TOOLS.md +384 -9
- package/config/templates/env.both.template +15 -2
- package/config/templates/env.client.template +5 -2
- package/config/templates/env.gateway.template +15 -2
- package/dist/cli.js +137 -2
- package/dist/services/features/telegram-mcp/browser.service.js +56 -1
- package/dist/services/features/telegram-mcp/file-content.service.js +94 -0
- package/dist/services/features/telegram-mcp/gateway-delivery.service.js +5 -1
- package/dist/services/features/telegram-mcp/gateway-socket.service.js +43 -11
- package/dist/services/features/telegram-mcp/mcp-http.service.js +1 -0
- package/dist/services/features/telegram-mcp/mcp-server.service.js +30 -0
- package/dist/services/features/telegram-mcp/src/app/bootstrap/runtime.js +23 -1
- package/dist/services/features/telegram-mcp/src/app/config/env.js +132 -2
- package/dist/services/features/telegram-mcp/src/app/http.js +139 -99
- package/dist/services/features/telegram-mcp/src/app/oauthFacade.js +642 -0
- package/dist/services/features/telegram-mcp/src/app/webapp/assets.js +151 -170
- package/dist/services/features/telegram-mcp/src/app/webapp/auth.js +96 -99
- package/dist/services/features/telegram-mcp/src/entities/request/model/schema.js +205 -17
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserAttachActiveTabTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserAttachTabTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserClickTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserDetachTabTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserDomTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserFillTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserInjectScriptTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserListAttachedInstancesTool.js +33 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserListTabsTool.js +33 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserPressTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserRecordingStartTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserRecordingStatusTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserRecordingStopTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserScreenshotTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserService.js +890 -23
- package/dist/services/features/telegram-mcp/src/features/browser-attach/model/browserRecordingBundle.js +536 -0
- package/dist/services/features/telegram-mcp/src/features/browser-attach/model/firefoxAttachRegistry.js +80 -0
- package/dist/services/features/telegram-mcp/src/features/browser-attach/model/firefoxAttachServer.js +736 -0
- package/dist/services/features/telegram-mcp/src/features/browser-attach/model/types.js +188 -0
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/collaborationService.js +2 -0
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/sendPartnerFileService.js +6 -3
- package/dist/services/features/telegram-mcp/src/features/distributed-client/model/gatewayClientAccess.js +4 -1
- package/dist/services/features/telegram-mcp/src/features/distributed-gateway/model/gatewayHttpService.js +33 -35
- package/dist/services/features/telegram-mcp/src/features/file-content/model/getFileListTool.js +33 -0
- package/dist/services/features/telegram-mcp/src/features/file-content/model/getFileService.js +327 -0
- package/dist/services/features/telegram-mcp/src/features/file-content/model/getFileTool.js +81 -0
- package/dist/services/features/telegram-mcp/src/features/file-content/model/temporaryFileLinkStore.js +307 -0
- package/dist/services/features/telegram-mcp/src/features/file-content/model/workspaceFilePolicy.js +115 -0
- package/dist/services/features/telegram-mcp/src/features/notify/model/notifyService.js +5 -1
- package/dist/services/features/telegram-mcp/src/shared/integrations/redis/stateStore.js +28 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transport.js +3 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportFileHandoffActions.js +6 -3
- package/dist/services/features/telegram-mcp/src/shared/integrations/terminal/client.js +29 -6
- package/dist/services/features/telegram-mcp/src/shared/integrations/terminal/ptyRegistry.js +100 -2
- package/dist/services/features/telegram-mcp/src/shared/lib/bodyLimits.js +63 -0
- package/dist/services/features/telegram-mcp/src/shared/lib/gatewayAuth.js +13 -0
- package/dist/services/features/telegram-mcp/src/shared/lib/time/localTimestamp.js +21 -0
- package/docs/CHAT_CONNECTOR.md +134 -0
- package/docs/STANDALONE-ru.md +55 -6
- package/docs/STANDALONE.md +55 -6
- package/package.json +10 -5
- package/packages/chrome-attach-extension/dist/background.js +1735 -0
- package/packages/chrome-attach-extension/dist/icon.svg +6 -0
- package/packages/chrome-attach-extension/dist/manifest.json +37 -0
- package/packages/chrome-attach-extension/dist/options.html +312 -0
- package/packages/chrome-attach-extension/dist/options.js +606 -0
- package/packages/chrome-attach-extension/dist/popup.html +93 -0
- package/packages/chrome-attach-extension/dist/popup.js +79 -0
- package/packages/chrome-attach-extension/dist/recorder-content.js +96 -0
- package/packages/chrome-attach-extension/dist/recorder-page.js +282 -0
- package/packages/firefox-attach-extension/README.md +13 -0
- package/packages/firefox-attach-extension/dist/background.js +1622 -0
- package/packages/firefox-attach-extension/dist/icon.svg +6 -0
- package/packages/firefox-attach-extension/dist/manifest.json +44 -0
- package/packages/firefox-attach-extension/dist/options.html +312 -0
- package/packages/firefox-attach-extension/dist/options.js +540 -0
- package/packages/firefox-attach-extension/dist/popup.html +93 -0
- package/packages/firefox-attach-extension/dist/popup.js +64 -0
- package/packages/firefox-attach-extension/dist/recorder-content.js +90 -0
- package/packages/firefox-attach-extension/dist/recorder-page.js +318 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.firefoxAttachInboundMessageSchema = exports.firefoxAttachTabRecordSchema = void 0;
|
|
37
|
+
const z = __importStar(require("zod/v4"));
|
|
38
|
+
const bodyLimits_1 = require("../../../shared/lib/bodyLimits");
|
|
39
|
+
const MAX_ID_LENGTH = 256;
|
|
40
|
+
const MAX_TEXT_LENGTH = 16 * 1024;
|
|
41
|
+
const MAX_GENERIC_STRING_LENGTH = bodyLimits_1.MAX_BODY_SIZE_BYTES;
|
|
42
|
+
const MAX_GENERIC_ARRAY_ITEMS = 4096;
|
|
43
|
+
const MAX_GENERIC_OBJECT_KEYS = 512;
|
|
44
|
+
const MAX_GENERIC_DEPTH = 24;
|
|
45
|
+
const MAX_TABS = 4096;
|
|
46
|
+
const boundedString = z.string().max(MAX_TEXT_LENGTH);
|
|
47
|
+
const identifier = z.string().trim().min(1).max(MAX_ID_LENGTH);
|
|
48
|
+
const tabId = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
49
|
+
const validateBoundedJson = (value, context) => {
|
|
50
|
+
const queue = [{ value, depth: 0 }];
|
|
51
|
+
while (queue.length > 0) {
|
|
52
|
+
const current = queue.pop();
|
|
53
|
+
if (!current) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (current.depth > MAX_GENERIC_DEPTH) {
|
|
57
|
+
context.addIssue({
|
|
58
|
+
code: "custom",
|
|
59
|
+
message: `JSON nesting exceeds ${MAX_GENERIC_DEPTH} levels`,
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (typeof current.value === "string") {
|
|
64
|
+
if (current.value.length > MAX_GENERIC_STRING_LENGTH) {
|
|
65
|
+
context.addIssue({
|
|
66
|
+
code: "too_big",
|
|
67
|
+
origin: "string",
|
|
68
|
+
maximum: MAX_GENERIC_STRING_LENGTH,
|
|
69
|
+
inclusive: true,
|
|
70
|
+
message: `String exceeds ${MAX_GENERIC_STRING_LENGTH} characters`,
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(current.value)) {
|
|
77
|
+
if (current.value.length > MAX_GENERIC_ARRAY_ITEMS) {
|
|
78
|
+
context.addIssue({
|
|
79
|
+
code: "too_big",
|
|
80
|
+
origin: "array",
|
|
81
|
+
maximum: MAX_GENERIC_ARRAY_ITEMS,
|
|
82
|
+
inclusive: true,
|
|
83
|
+
message: `Array exceeds ${MAX_GENERIC_ARRAY_ITEMS} items`,
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
for (const item of current.value) {
|
|
88
|
+
queue.push({ value: item, depth: current.depth + 1 });
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (current.value && typeof current.value === "object") {
|
|
93
|
+
const entries = Object.entries(current.value);
|
|
94
|
+
if (entries.length > MAX_GENERIC_OBJECT_KEYS) {
|
|
95
|
+
context.addIssue({
|
|
96
|
+
code: "custom",
|
|
97
|
+
message: `Object exceeds ${MAX_GENERIC_OBJECT_KEYS} keys`,
|
|
98
|
+
});
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
for (const [, item] of entries) {
|
|
102
|
+
queue.push({ value: item, depth: current.depth + 1 });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const boundedRecord = z
|
|
108
|
+
.record(z.string().max(MAX_ID_LENGTH), z.unknown())
|
|
109
|
+
.superRefine(validateBoundedJson);
|
|
110
|
+
exports.firefoxAttachTabRecordSchema = z.strictObject({
|
|
111
|
+
tab_id: tabId,
|
|
112
|
+
window_id: tabId.optional(),
|
|
113
|
+
active: z.boolean(),
|
|
114
|
+
title: boundedString,
|
|
115
|
+
url: boundedString,
|
|
116
|
+
status: z.string().max(64).optional(),
|
|
117
|
+
});
|
|
118
|
+
const requestId = identifier;
|
|
119
|
+
exports.firefoxAttachInboundMessageSchema = z.discriminatedUnion("type", [
|
|
120
|
+
z.strictObject({
|
|
121
|
+
type: z.literal("hello"),
|
|
122
|
+
extension_version: z.string().trim().min(1).max(64),
|
|
123
|
+
browser: z.enum(["firefox", "chrome"]),
|
|
124
|
+
instance_id: identifier,
|
|
125
|
+
profile_name: z.string().max(MAX_ID_LENGTH).optional(),
|
|
126
|
+
}),
|
|
127
|
+
z.strictObject({
|
|
128
|
+
type: z.literal("heartbeat"),
|
|
129
|
+
sent_at: z.string().min(1).max(64),
|
|
130
|
+
}),
|
|
131
|
+
z.strictObject({
|
|
132
|
+
type: z.literal("list_tabs_result"),
|
|
133
|
+
request_id: requestId,
|
|
134
|
+
tabs: z.array(exports.firefoxAttachTabRecordSchema).max(MAX_TABS),
|
|
135
|
+
}),
|
|
136
|
+
z.strictObject({
|
|
137
|
+
type: z.literal("get_active_tab_result"),
|
|
138
|
+
request_id: requestId,
|
|
139
|
+
tab: exports.firefoxAttachTabRecordSchema.nullable(),
|
|
140
|
+
}),
|
|
141
|
+
z.strictObject({
|
|
142
|
+
type: z.literal("active_tab_changed"),
|
|
143
|
+
tab: exports.firefoxAttachTabRecordSchema,
|
|
144
|
+
}),
|
|
145
|
+
z.strictObject({
|
|
146
|
+
type: z.literal("tab_updated"),
|
|
147
|
+
tab: exports.firefoxAttachTabRecordSchema,
|
|
148
|
+
}),
|
|
149
|
+
z.strictObject({
|
|
150
|
+
type: z.literal("attach_tab_selected"),
|
|
151
|
+
tab: exports.firefoxAttachTabRecordSchema,
|
|
152
|
+
}),
|
|
153
|
+
z.strictObject({
|
|
154
|
+
type: z.literal("tab_action_result"),
|
|
155
|
+
request_id: requestId,
|
|
156
|
+
ok: z.boolean(),
|
|
157
|
+
result: boundedRecord.optional(),
|
|
158
|
+
error: boundedString.optional(),
|
|
159
|
+
}),
|
|
160
|
+
z.strictObject({
|
|
161
|
+
type: z.literal("recording_control_result"),
|
|
162
|
+
request_id: requestId,
|
|
163
|
+
ok: z.boolean(),
|
|
164
|
+
active: z.boolean(),
|
|
165
|
+
error: boundedString.optional(),
|
|
166
|
+
}),
|
|
167
|
+
z.strictObject({
|
|
168
|
+
type: z.literal("recording_event"),
|
|
169
|
+
recording_id: identifier,
|
|
170
|
+
tab_id: tabId,
|
|
171
|
+
event: boundedRecord,
|
|
172
|
+
}),
|
|
173
|
+
z.strictObject({
|
|
174
|
+
type: z.literal("recording_manual_start"),
|
|
175
|
+
request_id: requestId,
|
|
176
|
+
tab: exports.firefoxAttachTabRecordSchema.optional(),
|
|
177
|
+
}),
|
|
178
|
+
z.strictObject({
|
|
179
|
+
type: z.literal("recording_manual_stop"),
|
|
180
|
+
request_id: requestId,
|
|
181
|
+
tab: exports.firefoxAttachTabRecordSchema.optional(),
|
|
182
|
+
}),
|
|
183
|
+
z.strictObject({
|
|
184
|
+
type: z.literal("recording_manual_status"),
|
|
185
|
+
request_id: requestId,
|
|
186
|
+
tab: exports.firefoxAttachTabRecordSchema.optional(),
|
|
187
|
+
}),
|
|
188
|
+
]);
|
package/dist/services/features/telegram-mcp/src/features/collaboration/model/collaborationService.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CollaborationService = void 0;
|
|
4
|
+
const bodyLimits_1 = require("../../../shared/lib/bodyLimits");
|
|
4
5
|
class CollaborationService {
|
|
5
6
|
backend;
|
|
6
7
|
logger;
|
|
@@ -11,6 +12,7 @@ class CollaborationService {
|
|
|
11
12
|
this.projectIdentityResolver = projectIdentityResolver;
|
|
12
13
|
}
|
|
13
14
|
async sendPartnerNote(input) {
|
|
15
|
+
(0, bodyLimits_1.assertSerializedBodySize)(input);
|
|
14
16
|
const resolved = this.projectIdentityResolver.resolveSessionDefaults(input);
|
|
15
17
|
const output = await this.backend.sendPartnerNote(input, resolved);
|
|
16
18
|
this.logger.info("Partner note processed by collaboration service", {
|
|
@@ -7,6 +7,7 @@ exports.SendPartnerFileService = void 0;
|
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const mime_types_1 = require("mime-types");
|
|
9
9
|
const client_1 = require("../../../shared/integrations/terminal/client");
|
|
10
|
+
const bodyLimits_1 = require("../../../shared/lib/bodyLimits");
|
|
10
11
|
function resolveWorkspaceDir(input) {
|
|
11
12
|
if (input.inputCwd?.trim()) {
|
|
12
13
|
return node_path_1.default.resolve(input.inputCwd.trim());
|
|
@@ -69,10 +70,10 @@ class SendPartnerFileService {
|
|
|
69
70
|
resolvedCwd: resolved.cwd,
|
|
70
71
|
});
|
|
71
72
|
const relativeFilePath = normalizeWorkspaceRelativePath(workspaceDir, input.file_path);
|
|
72
|
-
const fileContent = await (0, client_1.readWorkspaceFile)(this.config.terminal, workspaceDir, relativeFilePath);
|
|
73
|
+
const fileContent = await (0, client_1.readWorkspaceFile)(this.config.terminal, workspaceDir, relativeFilePath, bodyLimits_1.MAX_BASE64_SOURCE_SIZE_BYTES);
|
|
73
74
|
const originalName = node_path_1.default.basename(relativeFilePath);
|
|
74
75
|
const mimeType = (0, mime_types_1.lookup)(originalName) || "application/octet-stream";
|
|
75
|
-
const
|
|
76
|
+
const note = {
|
|
76
77
|
session_id: sessionId,
|
|
77
78
|
...(input.target_session_id?.trim()
|
|
78
79
|
? { target_session_id: input.target_session_id.trim() }
|
|
@@ -108,7 +109,9 @@ class SendPartnerFileService {
|
|
|
108
109
|
content_base64: Buffer.from(fileContent).toString("base64"),
|
|
109
110
|
},
|
|
110
111
|
],
|
|
111
|
-
}
|
|
112
|
+
};
|
|
113
|
+
(0, bodyLimits_1.assertSerializedBodySize)(note);
|
|
114
|
+
const output = await this.collaborationService.sendPartnerNote(note);
|
|
112
115
|
this.logger.info("Partner file sent through send_partner_file", {
|
|
113
116
|
sessionId: output.session_id,
|
|
114
117
|
partnerSessionId: output.partner_session_id,
|
|
@@ -7,6 +7,7 @@ exports.normalizeGatewayBaseUrl = normalizeGatewayBaseUrl;
|
|
|
7
7
|
exports.callGatewayJson = callGatewayJson;
|
|
8
8
|
exports.ensureGatewayClientUuid = ensureGatewayClientUuid;
|
|
9
9
|
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
+
const bodyLimits_1 = require("../../../shared/lib/bodyLimits");
|
|
10
11
|
function normalizeGatewayBaseUrl(value) {
|
|
11
12
|
const url = new URL(value);
|
|
12
13
|
url.pathname = url.pathname.replace(/\/+$/u, "");
|
|
@@ -18,6 +19,8 @@ function normalizeGatewayBaseUrl(value) {
|
|
|
18
19
|
async function callGatewayJson(input) {
|
|
19
20
|
const url = normalizeGatewayBaseUrl(input.gatewayPublicUrl);
|
|
20
21
|
url.pathname = `${url.pathname}${input.endpointPath}`.replace(/\/{2,}/gu, "/");
|
|
22
|
+
const serializedBody = JSON.stringify(input.body);
|
|
23
|
+
(0, bodyLimits_1.assertStringBodySize)(serializedBody);
|
|
21
24
|
const response = await fetch(url, {
|
|
22
25
|
method: "POST",
|
|
23
26
|
headers: {
|
|
@@ -26,7 +29,7 @@ async function callGatewayJson(input) {
|
|
|
26
29
|
? { authorization: `Bearer ${input.gatewayAuthToken}` }
|
|
27
30
|
: {}),
|
|
28
31
|
},
|
|
29
|
-
body:
|
|
32
|
+
body: serializedBody,
|
|
30
33
|
});
|
|
31
34
|
if (!response.ok) {
|
|
32
35
|
const message = await response.text();
|
|
@@ -5,6 +5,8 @@ const node_fs_1 = require("node:fs");
|
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const schema_1 = require("../../../entities/request/model/schema");
|
|
7
7
|
const relay_1 = require("../../../app/webapp/relay");
|
|
8
|
+
const gatewayAuth_1 = require("../../../shared/lib/gatewayAuth");
|
|
9
|
+
const bodyLimits_1 = require("../../../shared/lib/bodyLimits");
|
|
8
10
|
const versionHandshake_1 = require("../../../shared/lib/version/versionHandshake");
|
|
9
11
|
function readHeader(req, headerName) {
|
|
10
12
|
const value = req.headers[headerName];
|
|
@@ -73,9 +75,6 @@ function normalizeLiveRelayBootstrapResult(response) {
|
|
|
73
75
|
session_id: sessionId,
|
|
74
76
|
session_label: typeof record.session_label === "string" ? record.session_label : null,
|
|
75
77
|
terminal_target: record.terminal_target === true,
|
|
76
|
-
poll_interval_ms: typeof record.poll_interval_ms === "number" && record.poll_interval_ms > 0
|
|
77
|
-
? record.poll_interval_ms
|
|
78
|
-
: 2000,
|
|
79
78
|
telegram_user_id: telegramUserId,
|
|
80
79
|
};
|
|
81
80
|
}
|
|
@@ -145,21 +144,6 @@ class GatewayHttpService {
|
|
|
145
144
|
}
|
|
146
145
|
return response;
|
|
147
146
|
}
|
|
148
|
-
async requestLiveRelayView(input) {
|
|
149
|
-
const rawResponse = await this.callBroker("telegramMcp.gatewaySocket.requestLiveRelay", {
|
|
150
|
-
clientUuid: input.clientUuid,
|
|
151
|
-
localSessionId: input.localSessionId,
|
|
152
|
-
requestType: "view",
|
|
153
|
-
payload: {},
|
|
154
|
-
}, { meta: { internal_call: true } });
|
|
155
|
-
const response = unwrapLiveRelayResult(rawResponse);
|
|
156
|
-
if (!response ||
|
|
157
|
-
typeof response !== "object" ||
|
|
158
|
-
typeof response.content !== "string") {
|
|
159
|
-
throw new Error("Invalid live relay view response");
|
|
160
|
-
}
|
|
161
|
-
return response;
|
|
162
|
-
}
|
|
163
147
|
async requestLiveRelayAction(input) {
|
|
164
148
|
const rawResponse = await this.callBroker("telegramMcp.gatewaySocket.requestLiveRelay", {
|
|
165
149
|
clientUuid: input.clientUuid,
|
|
@@ -179,11 +163,8 @@ class GatewayHttpService {
|
|
|
179
163
|
return response;
|
|
180
164
|
}
|
|
181
165
|
isAuthorized(req) {
|
|
182
|
-
if (!this.config.distributed.gatewayAuthToken) {
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
166
|
const authorization = readHeader(req, "authorization");
|
|
186
|
-
return authorization
|
|
167
|
+
return (0, gatewayAuth_1.isGatewayAuthorizationValid)(authorization, this.config.distributed.gatewayAuthToken);
|
|
187
168
|
}
|
|
188
169
|
extractActionErrorMessage(value, fallback) {
|
|
189
170
|
if (value && typeof value === "object") {
|
|
@@ -223,8 +204,14 @@ class GatewayHttpService {
|
|
|
223
204
|
};
|
|
224
205
|
}
|
|
225
206
|
async readJsonBody(req) {
|
|
226
|
-
const
|
|
207
|
+
const cachedRequest = req;
|
|
208
|
+
if (cachedRequest.limitedJsonBodyRead) {
|
|
209
|
+
return cachedRequest.body;
|
|
210
|
+
}
|
|
211
|
+
const knownBody = cachedRequest.body;
|
|
227
212
|
if (knownBody !== undefined) {
|
|
213
|
+
(0, bodyLimits_1.assertSerializedBodySize)(knownBody);
|
|
214
|
+
cachedRequest.limitedJsonBodyRead = true;
|
|
228
215
|
return knownBody;
|
|
229
216
|
}
|
|
230
217
|
const knownParams = req.$params;
|
|
@@ -234,20 +221,15 @@ class GatewayHttpService {
|
|
|
234
221
|
"summary" in knownParams ||
|
|
235
222
|
"message" in knownParams ||
|
|
236
223
|
"session_id" in knownParams)) {
|
|
224
|
+
(0, bodyLimits_1.assertSerializedBodySize)(knownParams);
|
|
225
|
+
cachedRequest.body = knownParams;
|
|
226
|
+
cachedRequest.limitedJsonBodyRead = true;
|
|
237
227
|
return knownParams;
|
|
238
228
|
}
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (chunks.length === 0) {
|
|
244
|
-
return undefined;
|
|
245
|
-
}
|
|
246
|
-
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
247
|
-
if (!raw) {
|
|
248
|
-
return undefined;
|
|
249
|
-
}
|
|
250
|
-
return JSON.parse(raw);
|
|
229
|
+
const parsedBody = await (0, bodyLimits_1.readLimitedJsonBody)(req);
|
|
230
|
+
cachedRequest.body = parsedBody;
|
|
231
|
+
cachedRequest.limitedJsonBodyRead = true;
|
|
232
|
+
return parsedBody;
|
|
251
233
|
}
|
|
252
234
|
async handleRequest(req, res, pathname) {
|
|
253
235
|
if (!this.isEnabled() || !this.matches(pathname)) {
|
|
@@ -290,6 +272,22 @@ class GatewayHttpService {
|
|
|
290
272
|
return true;
|
|
291
273
|
}
|
|
292
274
|
}
|
|
275
|
+
if (["POST", "PUT", "PATCH", "DELETE"].includes(req.method ?? "")) {
|
|
276
|
+
try {
|
|
277
|
+
await this.readJsonBody(req);
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
if ((0, bodyLimits_1.isBodySizeLimitError)(error)) {
|
|
281
|
+
writeJson(res, 413, {
|
|
282
|
+
error: `Request body exceeds the ${bodyLimits_1.MAX_BODY_SIZE} MiB limit`,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
writeJson(res, 400, { error: "Invalid JSON request body" });
|
|
287
|
+
}
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
293
291
|
if (pathname === "/gateway/partner-note") {
|
|
294
292
|
if (req.method !== "POST") {
|
|
295
293
|
writeText(res, 405, "Method not allowed");
|
package/dist/services/features/telegram-mcp/src/features/file-content/model/getFileListTool.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetFileListTool = void 0;
|
|
4
|
+
const schema_1 = require("../../../entities/request/model/schema");
|
|
5
|
+
function createContent(output) {
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
type: "text",
|
|
9
|
+
text: JSON.stringify(output, null, 2),
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
class GetFileListTool {
|
|
14
|
+
getFileService;
|
|
15
|
+
constructor(getFileService) {
|
|
16
|
+
this.getFileService = getFileService;
|
|
17
|
+
}
|
|
18
|
+
register(server) {
|
|
19
|
+
server.registerTool("get_file_list", {
|
|
20
|
+
title: "Get File List",
|
|
21
|
+
description: "List managed files available in the workspace of a selected live console before calling get_file. Returns exact file_path values for Telegram uploads, browser screenshots, and partner artifacts, newest first. In gateway mode, pass session_id exactly as returned by list_gateway_sessions. Optionally filter by source and limit the result count.",
|
|
22
|
+
inputSchema: schema_1.getFileListInputSchema,
|
|
23
|
+
outputSchema: schema_1.getFileListOutputSchema,
|
|
24
|
+
}, async (args) => {
|
|
25
|
+
const output = await this.getFileService.list(args);
|
|
26
|
+
return {
|
|
27
|
+
content: createContent(output),
|
|
28
|
+
structuredContent: output,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.GetFileListTool = GetFileListTool;
|