@deadragdoll/tellymcp 0.0.10 → 0.0.12
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 +42 -52
- package/.env.example.gateway +48 -62
- package/CHANGELOG.md +3 -3
- package/README-ru.md +226 -376
- package/README.md +213 -1184
- package/TOOLS.md +320 -377
- package/VERSION.md +13 -13
- package/config/codex/plugins/telly-workflows/.codex-plugin/plugin.json +18 -0
- package/config/codex/plugins/telly-workflows/references/invariants.md +10 -0
- package/config/codex/plugins/telly-workflows/skills/telly-browser-screenshot/SKILL.md +27 -0
- package/config/codex/plugins/telly-workflows/skills/telly-collab-artifact/SKILL.md +22 -0
- package/config/codex/plugins/telly-workflows/skills/telly-human-telegram/SKILL.md +31 -0
- package/config/codex/plugins/telly-workflows/skills/telly-partner-note/SKILL.md +36 -0
- package/config/templates/env.both.template +39 -20
- package/config/templates/env.client.template +34 -19
- package/config/templates/env.gateway.template +37 -22
- package/dist/cli.js +322 -75
- package/dist/codexPluginInstaller.js +215 -0
- package/dist/lib/mixins/session.errors.js +34 -1
- package/dist/lib/pinoTargets.js +2 -2
- package/dist/moleculer.config.js +7 -5
- package/dist/services/features/telegram-mcp/browser.service.js +94 -1
- package/dist/services/features/telegram-mcp/collaboration.service.js +40 -3
- package/dist/services/features/telegram-mcp/ensuredb.service.js +145 -26
- package/dist/services/features/telegram-mcp/gateway-delivery.service.js +285 -103
- package/dist/services/features/telegram-mcp/gateway-socket.service.js +907 -85
- package/dist/services/features/telegram-mcp/gateway.service.js +876 -81
- package/dist/services/features/telegram-mcp/mcp-http.service.js +8 -0
- package/dist/services/features/telegram-mcp/mcp-server.service.js +17 -26
- package/dist/services/features/telegram-mcp/notify.service.js +127 -1
- package/dist/services/features/telegram-mcp/session-context.service.js +28 -1
- package/dist/services/features/telegram-mcp/src/app/bootstrap/runtime.js +132 -10
- package/dist/services/features/telegram-mcp/src/app/config/env.js +158 -52
- package/dist/services/features/telegram-mcp/src/app/http.js +375 -42
- package/dist/services/features/telegram-mcp/src/app/webapp/assets.js +386 -58
- package/dist/services/features/telegram-mcp/src/app/webapp/auth.js +3 -0
- package/dist/services/features/telegram-mcp/src/app/webapp/terminal.js +12 -0
- package/dist/services/features/telegram-mcp/src/entities/request/model/schema.js +120 -104
- package/dist/services/features/telegram-mcp/src/entities/xchange/model/types.js +2 -0
- package/dist/services/features/telegram-mcp/src/features/ask-user/model/askUserTelegram.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserOpenTool.js +1 -1
- 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 +306 -26
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/gatewaySessionsService.js +71 -0
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/listGatewaySessionsTool.js +33 -0
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/localCollaborationBackend.js +93 -82
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/sendPartnerFileService.js +47 -5
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/sendPartnerFileTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/collaboration/model/sendPartnerNoteTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/distributed-client/model/gatewayClientAccess.js +82 -0
- package/dist/services/features/telegram-mcp/src/features/distributed-client/model/gatewayCollaborationBackend.js +22 -14
- package/dist/services/features/telegram-mcp/src/features/distributed-gateway/model/gatewayHttpService.js +697 -75
- package/dist/services/features/telegram-mcp/src/features/distributed-gateway/model/remoteConsoleActionClient.js +76 -0
- package/dist/services/features/telegram-mcp/src/features/embedded-runtime/model/embeddedRuntimeBroker.js +92 -0
- package/dist/services/features/telegram-mcp/src/features/foreground-terminal/model/foregroundTerminalRuntime.js +192 -0
- package/dist/services/features/telegram-mcp/src/features/notify/model/notifyService.js +382 -3
- package/dist/services/features/telegram-mcp/src/features/notify/model/notifyTelegramTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/notify/model/sendFileToTelegramTool.js +33 -0
- package/dist/services/features/telegram-mcp/src/features/session-context/model/clearSessionContextTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/session-context/model/getSessionContextTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/session-context/model/renameSessionTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/session-context/model/sessionContextService.js +42 -200
- package/dist/services/features/telegram-mcp/src/features/session-context/model/setSessionContextTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/terminal-buffer/model/terminalBufferService.js +96 -0
- package/dist/services/features/telegram-mcp/src/features/terminal-input/model/terminalInputService.js +97 -0
- package/dist/services/features/telegram-mcp/src/features/tools-sync/model/refreshToolsMarkdownService.js +107 -58
- package/dist/services/features/telegram-mcp/src/features/tools-sync/model/refreshToolsMarkdownTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/xchange/model/getXchangeRecordTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/xchange/model/listXchangeRecordsTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/xchange/model/markXchangeRecordReadTool.js +28 -0
- package/dist/services/features/telegram-mcp/src/features/xchange/model/xchangeService.js +169 -0
- package/dist/services/features/telegram-mcp/src/processes/human-approval/model/orchestrator.js +5 -4
- package/dist/services/features/telegram-mcp/src/shared/i18n/resources/en.js +143 -42
- package/dist/services/features/telegram-mcp/src/shared/i18n/resources/ru.js +139 -38
- package/dist/services/features/telegram-mcp/src/shared/integrations/memory/processLocalSessionStore.js +27 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/object-storage/minioExchangeStore.js +11 -8
- package/dist/services/features/telegram-mcp/src/shared/integrations/redis/stateStore.js +69 -70
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/proxyFetch.js +21 -22
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transport.js +444 -7093
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportAttachmentStore.js +93 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportBroadcastActions.js +385 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportConsoleRegistry.js +149 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportConstructorWiring.js +642 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportContent.js +84 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportContext.js +78 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportDocumentActions.js +36 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportEventActions.js +292 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportFileHandoffActions.js +352 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportFormatting.js +75 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportGatewayActions.js +44 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportLifecycleActions.js +161 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportLive.js +56 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportLiveActions.js +77 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuCallbacks.js +254 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuFactories.js +538 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuFingerprints.js +93 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuFlow.js +344 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuShell.js +65 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuState.js +408 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuText.js +216 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMessageFlow.js +452 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportOutputActions.js +189 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportPartnerActions.js +286 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportPayloadState.js +108 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectActions.js +463 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectEntryActions.js +202 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectEvents.js +99 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectMenus.js +138 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectState.js +308 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectView.js +426 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportRequestFlow.js +278 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportSessionActions.js +143 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportTerminalActions.js +665 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportTerminalRuntime.js +226 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportTypes.js +2 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportUtils.js +330 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportXchangeState.js +107 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/terminal/client.js +255 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/terminal/ptyRegistry.js +543 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/xchange/sqliteRecordStore.js +223 -0
- package/dist/services/features/telegram-mcp/src/shared/lib/gatewayScope.js +24 -0
- package/dist/services/features/telegram-mcp/src/shared/lib/logger/logger.js +6 -0
- package/dist/services/features/telegram-mcp/src/shared/lib/project-identity/projectIdentity.js +147 -76
- package/dist/services/features/telegram-mcp/src/shared/lib/telegramXchangeRecords.js +72 -0
- package/dist/services/features/telegram-mcp/src/shared/lib/terminalPromptDetection.js +409 -0
- package/dist/services/features/telegram-mcp/src/shared/lib/version/versionHandshake.js +129 -1
- package/dist/services/features/telegram-mcp/src/shared/lib/xchangeRecordHints.js +98 -0
- package/dist/services/features/telegram-mcp/standalone-http.service.js +12 -0
- package/dist/services/features/telegram-mcp/terminal-buffer.service.js +42 -0
- package/dist/services/features/telegram-mcp/terminal-input.service.js +41 -0
- package/dist/services/features/telegram-mcp/tools-sync.service.js +15 -1
- package/dist/services/features/telegram-mcp/xchange.service.js +123 -0
- package/docs/STANDALONE-ru.md +172 -0
- package/docs/STANDALONE.md +172 -0
- package/package.json +10 -5
- package/scripts/build-package-artifact.sh +27 -0
- package/scripts/deploy-gateway.sh +64 -0
- package/scripts/deploy-onebot-branch.sh +27 -0
- package/scripts/postinstall.js +11 -36
- package/STANDALONE-ru.md +0 -274
- package/STANDALONE.md +0 -274
- package/dist/services/features/telegram-mcp/inbox.service.js +0 -33
- package/dist/services/features/telegram-mcp/pair.service.js +0 -33
- package/dist/services/features/telegram-mcp/src/app/webapp/tmux.js +0 -10
- package/dist/services/features/telegram-mcp/src/features/inbox/model/deleteTelegramInboxMessageTool.js +0 -33
- package/dist/services/features/telegram-mcp/src/features/inbox/model/getTelegramInboxCountTool.js +0 -33
- package/dist/services/features/telegram-mcp/src/features/inbox/model/getTelegramInboxTool.js +0 -33
- package/dist/services/features/telegram-mcp/src/features/inbox/model/inboxService.js +0 -77
- package/dist/services/features/telegram-mcp/src/features/pair-session/model/clearSessionPairingTool.js +0 -33
- package/dist/services/features/telegram-mcp/src/features/pair-session/model/createSessionPairCodeTool.js +0 -33
- package/dist/services/features/telegram-mcp/src/features/pair-session/model/generatePairCode.js +0 -202
- package/dist/services/features/telegram-mcp/src/features/session-context/model/getTmuxTargetTool.js +0 -33
- package/dist/services/features/telegram-mcp/src/features/session-context/model/setTmuxTargetTool.js +0 -33
- package/dist/services/features/telegram-mcp/src/shared/integrations/tmux/client.js +0 -363
package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuFlow.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransportMenuFlow = void 0;
|
|
4
|
+
const grammy_1 = require("grammy");
|
|
5
|
+
const relay_1 = require("../../../app/webapp/relay");
|
|
6
|
+
const transportUtils_1 = require("./transportUtils");
|
|
7
|
+
const client_1 = require("../terminal/client");
|
|
8
|
+
class TransportMenuFlow {
|
|
9
|
+
host;
|
|
10
|
+
constructor(host) {
|
|
11
|
+
this.host = host;
|
|
12
|
+
}
|
|
13
|
+
async showSessionsMenu(ctx, introText) {
|
|
14
|
+
const principal = this.host.getPrincipalFromContext(ctx);
|
|
15
|
+
if (principal && this.host.ensureGatewayScopeConsolesBound) {
|
|
16
|
+
await this.host.ensureGatewayScopeConsolesBound({ principal, ctx });
|
|
17
|
+
}
|
|
18
|
+
await this.host.menuState.showSessionsMenu(ctx, introText);
|
|
19
|
+
}
|
|
20
|
+
async showStorageMenu(ctx, introText) {
|
|
21
|
+
await this.host.menuState.showStorageMenu(ctx, introText);
|
|
22
|
+
}
|
|
23
|
+
async showBrowserMenu(ctx, introText) {
|
|
24
|
+
await this.host.menuState.showBrowserMenu(ctx, introText);
|
|
25
|
+
}
|
|
26
|
+
async showScreenshotsMenu(ctx, introText) {
|
|
27
|
+
await this.host.menuState.showScreenshotsMenu(ctx, introText);
|
|
28
|
+
}
|
|
29
|
+
async showProjectsMenu(ctx, introText) {
|
|
30
|
+
await this.host.projectView.showProjectsMenu(ctx, introText);
|
|
31
|
+
}
|
|
32
|
+
async showCollabToolsMenu(ctx, introText) {
|
|
33
|
+
await this.host.projectView.showCollabToolsMenu(ctx, introText);
|
|
34
|
+
}
|
|
35
|
+
async handleCollabHistoryExport(ctx) {
|
|
36
|
+
await this.host.projectView.handleCollabHistoryExport(ctx);
|
|
37
|
+
}
|
|
38
|
+
async showCollabDeleteMenu(ctx, introText) {
|
|
39
|
+
await this.host.projectView.showCollabDeleteMenu(ctx, introText);
|
|
40
|
+
}
|
|
41
|
+
async showSettingsMenu(ctx, introText) {
|
|
42
|
+
await this.host.menuState.showSettingsMenu(ctx, introText);
|
|
43
|
+
}
|
|
44
|
+
async showBufferMenu(ctx, introText) {
|
|
45
|
+
await this.host.menuState.showBufferMenu(ctx, introText);
|
|
46
|
+
}
|
|
47
|
+
async showDeveloperMenu(ctx, introText) {
|
|
48
|
+
await this.host.menuState.showDeveloperMenu(ctx, introText);
|
|
49
|
+
}
|
|
50
|
+
async showDeveloperInfo(ctx, introText) {
|
|
51
|
+
await this.host.menuState.showDeveloperInfo(ctx, introText);
|
|
52
|
+
}
|
|
53
|
+
async showUnpairConfirmMenu(ctx, introText) {
|
|
54
|
+
await this.host.menuState.showUnpairConfirmMenu(ctx, introText);
|
|
55
|
+
}
|
|
56
|
+
async showPruneConfirmMenu(ctx, introText) {
|
|
57
|
+
await this.host.menuState.showPruneConfirmMenu(ctx, introText);
|
|
58
|
+
}
|
|
59
|
+
async renderMenuScreen(ctx, text, meta, menu) {
|
|
60
|
+
if (ctx.callbackQuery?.message) {
|
|
61
|
+
await this.host.editText(ctx, text, meta, {
|
|
62
|
+
reply_markup: menu,
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
await this.host.replyText(ctx, text, meta, {
|
|
67
|
+
reply_markup: menu,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async renderMenuMarkdownScreen(ctx, text, meta, menu) {
|
|
71
|
+
if (ctx.callbackQuery?.message) {
|
|
72
|
+
await this.host.editText(ctx, text, meta, {
|
|
73
|
+
parse_mode: "MarkdownV2",
|
|
74
|
+
reply_markup: menu,
|
|
75
|
+
});
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
await this.host.replyText(ctx, text, meta, {
|
|
79
|
+
parse_mode: "MarkdownV2",
|
|
80
|
+
reply_markup: menu,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async renderMenuHtmlScreen(ctx, text, meta, menu) {
|
|
84
|
+
if (ctx.callbackQuery?.message) {
|
|
85
|
+
await this.host.editText(ctx, text, meta, {
|
|
86
|
+
parse_mode: "HTML",
|
|
87
|
+
reply_markup: menu,
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await this.host.replyText(ctx, text, meta, {
|
|
92
|
+
parse_mode: "HTML",
|
|
93
|
+
reply_markup: menu,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async showHelp(ctx) {
|
|
97
|
+
const locale = await this.host.resolveLocaleForContext(ctx);
|
|
98
|
+
await this.host.replyText(ctx, [
|
|
99
|
+
this.host.t(locale, "menu:help.title"),
|
|
100
|
+
"",
|
|
101
|
+
this.host.t(locale, "menu:help.menu"),
|
|
102
|
+
this.host.t(locale, "menu:help.help"),
|
|
103
|
+
"",
|
|
104
|
+
this.host.t(locale, "menu:help.how_it_works"),
|
|
105
|
+
this.host.t(locale, "menu:help.step_choose"),
|
|
106
|
+
this.host.t(locale, "menu:help.step_nudge"),
|
|
107
|
+
this.host.t(locale, "menu:help.step_tools"),
|
|
108
|
+
].join("\n"), { kind: "menu" });
|
|
109
|
+
}
|
|
110
|
+
async showLiveViewLauncher(ctx) {
|
|
111
|
+
const locale = await this.host.resolveLocaleForContext(ctx);
|
|
112
|
+
const principal = this.host.getPrincipalFromContext(ctx);
|
|
113
|
+
if (!principal) {
|
|
114
|
+
await ctx.answerCallbackQuery({
|
|
115
|
+
text: this.host.t(locale, "menu:live.errors.identity_unavailable"),
|
|
116
|
+
show_alert: true,
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const activeSessionId = await this.host.bindingStore.getActiveSessionIdForPrincipal(principal);
|
|
121
|
+
if (!activeSessionId) {
|
|
122
|
+
await ctx.answerCallbackQuery({
|
|
123
|
+
text: this.host.t(locale, "menu:live.errors.no_active_session"),
|
|
124
|
+
show_alert: true,
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (!this.host.liveActions.canRender()) {
|
|
129
|
+
await ctx.answerCallbackQuery({
|
|
130
|
+
text: this.host.t(locale, "menu:live.errors.webapp_disabled"),
|
|
131
|
+
show_alert: true,
|
|
132
|
+
});
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const session = await this.host.sessionStore.getSession(activeSessionId);
|
|
136
|
+
const actor = this.host.getGatewayActorFromContext(ctx);
|
|
137
|
+
const sent = await this.host.liveActions.sendLauncherMessage({
|
|
138
|
+
principal,
|
|
139
|
+
sessionId: activeSessionId,
|
|
140
|
+
sessionName: session?.label ?? activeSessionId,
|
|
141
|
+
locale,
|
|
142
|
+
...(actor ? { actor } : {}),
|
|
143
|
+
});
|
|
144
|
+
if (!sent) {
|
|
145
|
+
await ctx.answerCallbackQuery({
|
|
146
|
+
text: this.host.t(locale, "menu:live.errors.public_url_missing"),
|
|
147
|
+
show_alert: true,
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
await ctx.answerCallbackQuery({
|
|
152
|
+
text: this.host.t(locale, "menu:live.actions.opening"),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
clearPendingInteractionsForContext(ctx) {
|
|
156
|
+
const principal = this.host.getPrincipalFromContext(ctx);
|
|
157
|
+
if (!principal) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const key = (0, transportUtils_1.buildPrincipalKey)(principal);
|
|
161
|
+
this.host.pendingRenames.delete(key);
|
|
162
|
+
this.host.pendingBroadcasts.delete(key);
|
|
163
|
+
this.host.pendingPartnerNotes.delete(key);
|
|
164
|
+
this.host.pendingFileHandoffs.delete(key);
|
|
165
|
+
this.host.pendingProjects.delete(key);
|
|
166
|
+
}
|
|
167
|
+
setCurrentAttachmentTargetForContext(ctx, target) {
|
|
168
|
+
const principal = this.host.getPrincipalFromContext(ctx);
|
|
169
|
+
if (!principal) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const key = (0, transportUtils_1.buildPrincipalKey)(principal);
|
|
173
|
+
if (target) {
|
|
174
|
+
this.host.currentAttachmentTargets.set(key, target);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this.host.currentAttachmentTargets.delete(key);
|
|
178
|
+
}
|
|
179
|
+
async sendActiveSessionBuffer(ctx, scope) {
|
|
180
|
+
const locale = await this.host.resolveLocaleForContext(ctx);
|
|
181
|
+
const principal = this.host.getPrincipalFromContext(ctx);
|
|
182
|
+
if (!principal) {
|
|
183
|
+
await ctx.answerCallbackQuery({
|
|
184
|
+
text: this.host.t(locale, "common:errors.no_telegram_identity"),
|
|
185
|
+
show_alert: true,
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const sessionId = await this.host.bindingStore.getActiveSessionIdForPrincipal(principal);
|
|
190
|
+
if (!sessionId) {
|
|
191
|
+
await ctx.answerCallbackQuery({
|
|
192
|
+
text: this.host.t(locale, "common:errors.no_active_session"),
|
|
193
|
+
show_alert: true,
|
|
194
|
+
});
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const relayTarget = (0, relay_1.parseLiveRelaySessionId)(sessionId);
|
|
198
|
+
const session = await this.host.sessionStore.getSession(sessionId);
|
|
199
|
+
if (!relayTarget && !session?.terminalTarget) {
|
|
200
|
+
await ctx.answerCallbackQuery({
|
|
201
|
+
text: "terminal target is not configured for this session.",
|
|
202
|
+
show_alert: true,
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
await ctx.answerCallbackQuery({
|
|
207
|
+
text: `Capturing ${this.host.terminalActions.describeCaptureScope(scope)}...`,
|
|
208
|
+
});
|
|
209
|
+
try {
|
|
210
|
+
const capture = relayTarget
|
|
211
|
+
? await this.host.captureRelaySessionBuffer(sessionId, scope)
|
|
212
|
+
: await this.host.terminalActions.captureBuffer(session, scope);
|
|
213
|
+
const relayMarkdownContent = relayTarget && "markdown_content" in capture
|
|
214
|
+
? capture.markdown_content
|
|
215
|
+
: relayTarget &&
|
|
216
|
+
"markdownContent" in capture &&
|
|
217
|
+
typeof capture.markdownContent === "string"
|
|
218
|
+
? capture.markdownContent
|
|
219
|
+
: null;
|
|
220
|
+
const relayFilename = relayTarget && "filename" in capture && typeof capture.filename === "string"
|
|
221
|
+
? capture.filename
|
|
222
|
+
: relayTarget &&
|
|
223
|
+
"fileName" in capture &&
|
|
224
|
+
typeof capture.fileName === "string"
|
|
225
|
+
? capture.fileName
|
|
226
|
+
: null;
|
|
227
|
+
if (relayTarget && typeof relayMarkdownContent !== "string") {
|
|
228
|
+
throw new Error(`Invalid relay terminal buffer response: ${JSON.stringify(capture)}`);
|
|
229
|
+
}
|
|
230
|
+
const finalRelayMarkdownContent = relayMarkdownContent ?? "";
|
|
231
|
+
const finalRelayFilename = relayFilename ?? capture.filename;
|
|
232
|
+
await this.host.replyDocumentWithRetry(ctx, new grammy_1.InputFile("buffer" in capture
|
|
233
|
+
? capture.buffer
|
|
234
|
+
: Buffer.from(finalRelayMarkdownContent, "utf8"), finalRelayFilename), {
|
|
235
|
+
caption: `📄 Buffer: ${session?.label ?? sessionId}`,
|
|
236
|
+
}, {
|
|
237
|
+
kind: "menu",
|
|
238
|
+
sessionId,
|
|
239
|
+
});
|
|
240
|
+
this.host.logger.info("Telegram terminal buffer sent", {
|
|
241
|
+
sessionId,
|
|
242
|
+
terminalTarget: "terminal_target" in capture ? capture.terminal_target : session?.terminalTarget,
|
|
243
|
+
filename: capture.filename,
|
|
244
|
+
bytes: "buffer" in capture
|
|
245
|
+
? capture.buffer.length
|
|
246
|
+
: Buffer.byteLength(finalRelayMarkdownContent, "utf8"),
|
|
247
|
+
captureMode: "captureMode" in capture ? capture.captureMode : capture.capture_mode,
|
|
248
|
+
captureScope: "scopeDescription" in capture
|
|
249
|
+
? capture.scopeDescription
|
|
250
|
+
: capture.scope_description,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
const payload = {
|
|
255
|
+
sessionId,
|
|
256
|
+
terminalTarget: session?.terminalTarget,
|
|
257
|
+
error: error instanceof Error ? (error.stack ?? error.message) : String(error),
|
|
258
|
+
};
|
|
259
|
+
if ((0, client_1.isTerminalUnavailableError)(error)) {
|
|
260
|
+
this.host.logger.warn("terminal buffer capture skipped because terminal is unavailable", payload);
|
|
261
|
+
await this.host.replyText(ctx, (0, transportUtils_1.formatTerminalBridgeError)(this.host.config, error, "Unable to capture the terminal buffer right now."), { kind: "menu", sessionId });
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
this.host.logger.error("terminal buffer capture failed", payload);
|
|
265
|
+
await this.host.replyText(ctx, (0, transportUtils_1.formatTerminalBridgeError)(this.host.config, error, "Failed to capture the terminal buffer for this session."), { kind: "menu", sessionId });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async buildSessionsMenuText(ctx) {
|
|
269
|
+
return this.host.menuState.buildSessionsMenuText(ctx);
|
|
270
|
+
}
|
|
271
|
+
async buildBufferMenuText(ctx) {
|
|
272
|
+
return this.host.menuState.buildBufferMenuText(ctx);
|
|
273
|
+
}
|
|
274
|
+
async buildBrowserMenuText(ctx) {
|
|
275
|
+
return this.host.menuState.buildBrowserMenuText(ctx);
|
|
276
|
+
}
|
|
277
|
+
async buildSettingsMenuText(ctx) {
|
|
278
|
+
return this.host.menuState.buildSettingsMenuText(ctx);
|
|
279
|
+
}
|
|
280
|
+
async buildScreenshotsMenuText(ctx) {
|
|
281
|
+
return this.host.menuState.buildScreenshotsMenuText(ctx);
|
|
282
|
+
}
|
|
283
|
+
async buildStorageMenuText(ctx) {
|
|
284
|
+
return this.host.menuState.buildStorageMenuText(ctx);
|
|
285
|
+
}
|
|
286
|
+
async buildProjectsMenuText(ctx) {
|
|
287
|
+
return this.host.projectView.buildProjectsMenuText(ctx);
|
|
288
|
+
}
|
|
289
|
+
async buildCollabToolsMenuText(ctx) {
|
|
290
|
+
return this.host.projectView.buildCollabToolsMenuText(ctx);
|
|
291
|
+
}
|
|
292
|
+
async buildCollabDeleteMenuText(ctx) {
|
|
293
|
+
return this.host.projectView.buildCollabDeleteMenuText(ctx);
|
|
294
|
+
}
|
|
295
|
+
async buildDeveloperMenuText(ctx) {
|
|
296
|
+
return this.host.menuState.buildDeveloperMenuText(ctx);
|
|
297
|
+
}
|
|
298
|
+
async buildUnpairConfirmText(ctx) {
|
|
299
|
+
return this.host.menuState.buildUnpairConfirmText(ctx);
|
|
300
|
+
}
|
|
301
|
+
async buildPruneConfirmText(ctx) {
|
|
302
|
+
return this.host.menuState.buildPruneConfirmText(ctx);
|
|
303
|
+
}
|
|
304
|
+
async showActiveSessionInfo(ctx) {
|
|
305
|
+
const locale = await this.host.resolveLocaleForContext(ctx);
|
|
306
|
+
const principal = this.host.getPrincipalFromContext(ctx);
|
|
307
|
+
if (!principal) {
|
|
308
|
+
await ctx.answerCallbackQuery({
|
|
309
|
+
text: this.host.t(locale, "common:errors.no_telegram_identity"),
|
|
310
|
+
show_alert: true,
|
|
311
|
+
});
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const sessionId = await this.host.bindingStore.getActiveSessionIdForPrincipal(principal);
|
|
315
|
+
if (!sessionId) {
|
|
316
|
+
await ctx.answerCallbackQuery({
|
|
317
|
+
text: this.host.t(locale, "common:errors.no_active_session"),
|
|
318
|
+
show_alert: true,
|
|
319
|
+
});
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const session = await this.host.sessionStore.getSession(sessionId);
|
|
323
|
+
const binding = await this.host.bindingStore.getBinding(sessionId);
|
|
324
|
+
await ctx.answerCallbackQuery({
|
|
325
|
+
text: this.host.t(locale, "menu:session_info.opened"),
|
|
326
|
+
});
|
|
327
|
+
await this.host.replyText(ctx, [
|
|
328
|
+
this.host.t(locale, "menu:session_info.title"),
|
|
329
|
+
"",
|
|
330
|
+
this.host.t(locale, "menu:session_info.label", {
|
|
331
|
+
value: session?.label ?? sessionId,
|
|
332
|
+
}),
|
|
333
|
+
this.host.t(locale, "menu:session_info.session_id", {
|
|
334
|
+
value: sessionId,
|
|
335
|
+
}),
|
|
336
|
+
this.host.t(locale, "menu:session_info.route", {
|
|
337
|
+
value: binding
|
|
338
|
+
? this.host.t(locale, "menu:session_info.yes")
|
|
339
|
+
: this.host.t(locale, "menu:session_info.no"),
|
|
340
|
+
}),
|
|
341
|
+
].join("\n"), { kind: "menu", sessionId });
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
exports.TransportMenuFlow = TransportMenuFlow;
|
package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuShell.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransportMenuShell = void 0;
|
|
4
|
+
class TransportMenuShell {
|
|
5
|
+
host;
|
|
6
|
+
constructor(host) {
|
|
7
|
+
this.host = host;
|
|
8
|
+
}
|
|
9
|
+
register(bot) {
|
|
10
|
+
bot.catch((error) => {
|
|
11
|
+
this.host.logger.error("Telegram polling error", {
|
|
12
|
+
error: error.error instanceof Error
|
|
13
|
+
? error.error.message
|
|
14
|
+
: String(error.error),
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
bot.callbackQuery("broadcast-cancel", async (ctx) => {
|
|
18
|
+
await this.host.cancelPendingBroadcast(ctx);
|
|
19
|
+
});
|
|
20
|
+
bot.callbackQuery("partner-note-cancel", async (ctx) => {
|
|
21
|
+
await this.host.cancelPendingPartnerNote(ctx);
|
|
22
|
+
});
|
|
23
|
+
bot.callbackQuery("file-handoff-cancel", async (ctx) => {
|
|
24
|
+
await this.host.cancelPendingFileHandoff(ctx);
|
|
25
|
+
});
|
|
26
|
+
bot.callbackQuery(/^project-set:(.+)$/u, async (ctx) => {
|
|
27
|
+
await this.host.handleProjectSetCallback(ctx);
|
|
28
|
+
});
|
|
29
|
+
bot.callbackQuery(/^project-members:(.+)$/u, async (ctx) => {
|
|
30
|
+
await this.host.handleProjectMembersCallback(ctx);
|
|
31
|
+
});
|
|
32
|
+
bot.callbackQuery(/^project-member-open:(.+)$/u, async (ctx) => {
|
|
33
|
+
await this.host.handleProjectMemberOpenCallback(ctx);
|
|
34
|
+
});
|
|
35
|
+
bot.callbackQuery(/^project-member-note:(question|share):(.+)$/u, async (ctx) => {
|
|
36
|
+
await this.host.handleProjectMemberNoteCallback(ctx);
|
|
37
|
+
});
|
|
38
|
+
bot.callbackQuery(/^project-member-live:(.+)$/u, async (ctx) => {
|
|
39
|
+
await this.host.handleProjectMemberLiveCallback(ctx);
|
|
40
|
+
});
|
|
41
|
+
bot.callbackQuery(/^live-approval:(approve|deny):(.+)$/u, async (ctx) => {
|
|
42
|
+
await this.host.handleLiveApprovalCallback(ctx);
|
|
43
|
+
});
|
|
44
|
+
bot.callbackQuery(/^terminal-prompt-action:(\d+|enter|escape):(.+)$/u, async (ctx) => {
|
|
45
|
+
await this.host.handleTerminalPromptActionCallback(ctx);
|
|
46
|
+
});
|
|
47
|
+
bot.callbackQuery(/^project-detail:(.+)$/u, async (ctx) => {
|
|
48
|
+
await this.host.handleProjectDetailCallback(ctx);
|
|
49
|
+
});
|
|
50
|
+
bot.callbackQuery(/^project-delete:(.+)$/u, async (ctx) => {
|
|
51
|
+
await this.host.handleProjectDeleteCallback(ctx);
|
|
52
|
+
});
|
|
53
|
+
bot.callbackQuery(/^project-leave:(.+)$/u, async (ctx) => {
|
|
54
|
+
await this.host.handleProjectLeaveCallback(ctx);
|
|
55
|
+
});
|
|
56
|
+
bot.callbackQuery("project-back", async (ctx) => {
|
|
57
|
+
await ctx.answerCallbackQuery({ text: "Back to projects." });
|
|
58
|
+
await this.host.showProjectsMenu(ctx);
|
|
59
|
+
});
|
|
60
|
+
bot.on("message", async (ctx) => {
|
|
61
|
+
await this.host.handleMessage(ctx);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.TransportMenuShell = TransportMenuShell;
|