@deadragdoll/tellymcp 0.0.10 → 0.0.11

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.
Files changed (153) hide show
  1. package/.env.example.client +42 -52
  2. package/.env.example.gateway +48 -62
  3. package/CHANGELOG.md +3 -3
  4. package/README-ru.md +205 -384
  5. package/README.md +195 -1194
  6. package/TOOLS.md +294 -377
  7. package/VERSION.md +11 -11
  8. package/config/codex/plugins/telly-workflows/.codex-plugin/plugin.json +18 -0
  9. package/config/codex/plugins/telly-workflows/references/invariants.md +10 -0
  10. package/config/codex/plugins/telly-workflows/skills/telly-browser-screenshot/SKILL.md +27 -0
  11. package/config/codex/plugins/telly-workflows/skills/telly-collab-artifact/SKILL.md +22 -0
  12. package/config/codex/plugins/telly-workflows/skills/telly-human-telegram/SKILL.md +31 -0
  13. package/config/codex/plugins/telly-workflows/skills/telly-partner-note/SKILL.md +36 -0
  14. package/config/templates/env.both.template +39 -20
  15. package/config/templates/env.client.template +34 -19
  16. package/config/templates/env.gateway.template +37 -22
  17. package/dist/cli.js +322 -75
  18. package/dist/codexPluginInstaller.js +215 -0
  19. package/dist/lib/mixins/session.errors.js +34 -1
  20. package/dist/lib/pinoTargets.js +2 -2
  21. package/dist/moleculer.config.js +7 -5
  22. package/dist/services/features/telegram-mcp/browser.service.js +94 -1
  23. package/dist/services/features/telegram-mcp/collaboration.service.js +40 -3
  24. package/dist/services/features/telegram-mcp/ensuredb.service.js +145 -26
  25. package/dist/services/features/telegram-mcp/gateway-delivery.service.js +285 -103
  26. package/dist/services/features/telegram-mcp/gateway-socket.service.js +897 -85
  27. package/dist/services/features/telegram-mcp/gateway.service.js +876 -81
  28. package/dist/services/features/telegram-mcp/mcp-http.service.js +8 -0
  29. package/dist/services/features/telegram-mcp/mcp-server.service.js +17 -26
  30. package/dist/services/features/telegram-mcp/notify.service.js +127 -1
  31. package/dist/services/features/telegram-mcp/session-context.service.js +28 -1
  32. package/dist/services/features/telegram-mcp/src/app/bootstrap/runtime.js +132 -10
  33. package/dist/services/features/telegram-mcp/src/app/config/env.js +158 -52
  34. package/dist/services/features/telegram-mcp/src/app/http.js +375 -42
  35. package/dist/services/features/telegram-mcp/src/app/webapp/assets.js +386 -58
  36. package/dist/services/features/telegram-mcp/src/app/webapp/auth.js +3 -0
  37. package/dist/services/features/telegram-mcp/src/app/webapp/terminal.js +12 -0
  38. package/dist/services/features/telegram-mcp/src/entities/request/model/schema.js +116 -104
  39. package/dist/services/features/telegram-mcp/src/entities/xchange/model/types.js +2 -0
  40. package/dist/services/features/telegram-mcp/src/features/ask-user/model/askUserTelegram.js +1 -1
  41. package/dist/services/features/telegram-mcp/src/features/browser/model/browserScreenshotTool.js +1 -1
  42. package/dist/services/features/telegram-mcp/src/features/browser/model/browserService.js +249 -19
  43. package/dist/services/features/telegram-mcp/src/features/collaboration/model/gatewaySessionsService.js +71 -0
  44. package/dist/services/features/telegram-mcp/src/features/collaboration/model/listGatewaySessionsTool.js +33 -0
  45. package/dist/services/features/telegram-mcp/src/features/collaboration/model/localCollaborationBackend.js +93 -82
  46. package/dist/services/features/telegram-mcp/src/features/collaboration/model/sendPartnerFileService.js +47 -5
  47. package/dist/services/features/telegram-mcp/src/features/collaboration/model/sendPartnerFileTool.js +1 -1
  48. package/dist/services/features/telegram-mcp/src/features/collaboration/model/sendPartnerNoteTool.js +1 -1
  49. package/dist/services/features/telegram-mcp/src/features/distributed-client/model/gatewayClientAccess.js +82 -0
  50. package/dist/services/features/telegram-mcp/src/features/distributed-client/model/gatewayCollaborationBackend.js +22 -14
  51. package/dist/services/features/telegram-mcp/src/features/distributed-gateway/model/gatewayHttpService.js +649 -75
  52. package/dist/services/features/telegram-mcp/src/features/distributed-gateway/model/remoteConsoleActionClient.js +76 -0
  53. package/dist/services/features/telegram-mcp/src/features/embedded-runtime/model/embeddedRuntimeBroker.js +92 -0
  54. package/dist/services/features/telegram-mcp/src/features/foreground-terminal/model/foregroundTerminalRuntime.js +192 -0
  55. package/dist/services/features/telegram-mcp/src/features/notify/model/notifyService.js +382 -3
  56. package/dist/services/features/telegram-mcp/src/features/notify/model/notifyTelegramTool.js +1 -1
  57. package/dist/services/features/telegram-mcp/src/features/notify/model/sendFileToTelegramTool.js +33 -0
  58. package/dist/services/features/telegram-mcp/src/features/session-context/model/clearSessionContextTool.js +1 -1
  59. package/dist/services/features/telegram-mcp/src/features/session-context/model/getSessionContextTool.js +1 -1
  60. package/dist/services/features/telegram-mcp/src/features/session-context/model/renameSessionTool.js +1 -1
  61. package/dist/services/features/telegram-mcp/src/features/session-context/model/sessionContextService.js +42 -200
  62. package/dist/services/features/telegram-mcp/src/features/session-context/model/setSessionContextTool.js +1 -1
  63. package/dist/services/features/telegram-mcp/src/features/terminal-buffer/model/terminalBufferService.js +96 -0
  64. package/dist/services/features/telegram-mcp/src/features/terminal-input/model/terminalInputService.js +97 -0
  65. package/dist/services/features/telegram-mcp/src/features/tools-sync/model/refreshToolsMarkdownService.js +107 -58
  66. package/dist/services/features/telegram-mcp/src/features/tools-sync/model/refreshToolsMarkdownTool.js +1 -1
  67. package/dist/services/features/telegram-mcp/src/features/xchange/model/getXchangeRecordTool.js +28 -0
  68. package/dist/services/features/telegram-mcp/src/features/xchange/model/listXchangeRecordsTool.js +28 -0
  69. package/dist/services/features/telegram-mcp/src/features/xchange/model/markXchangeRecordReadTool.js +28 -0
  70. package/dist/services/features/telegram-mcp/src/features/xchange/model/xchangeService.js +169 -0
  71. package/dist/services/features/telegram-mcp/src/processes/human-approval/model/orchestrator.js +5 -4
  72. package/dist/services/features/telegram-mcp/src/shared/i18n/resources/en.js +139 -42
  73. package/dist/services/features/telegram-mcp/src/shared/i18n/resources/ru.js +135 -38
  74. package/dist/services/features/telegram-mcp/src/shared/integrations/memory/processLocalSessionStore.js +27 -0
  75. package/dist/services/features/telegram-mcp/src/shared/integrations/object-storage/minioExchangeStore.js +11 -8
  76. package/dist/services/features/telegram-mcp/src/shared/integrations/redis/stateStore.js +42 -71
  77. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/proxyFetch.js +21 -22
  78. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transport.js +415 -7101
  79. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportAttachmentStore.js +93 -0
  80. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportBroadcastActions.js +385 -0
  81. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportConsoleRegistry.js +143 -0
  82. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportConstructorWiring.js +633 -0
  83. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportContent.js +84 -0
  84. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportContext.js +78 -0
  85. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportDocumentActions.js +36 -0
  86. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportEventActions.js +292 -0
  87. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportFileHandoffActions.js +352 -0
  88. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportFormatting.js +75 -0
  89. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportGatewayActions.js +44 -0
  90. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportLifecycleActions.js +161 -0
  91. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportLive.js +56 -0
  92. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportLiveActions.js +77 -0
  93. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuCallbacks.js +254 -0
  94. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuFactories.js +538 -0
  95. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuFingerprints.js +93 -0
  96. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuFlow.js +344 -0
  97. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuShell.js +62 -0
  98. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuState.js +408 -0
  99. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMenuText.js +216 -0
  100. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportMessageFlow.js +452 -0
  101. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportOutputActions.js +189 -0
  102. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportPartnerActions.js +286 -0
  103. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportPayloadState.js +101 -0
  104. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectActions.js +463 -0
  105. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectEntryActions.js +202 -0
  106. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectEvents.js +99 -0
  107. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectMenus.js +138 -0
  108. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectState.js +308 -0
  109. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportProjectView.js +426 -0
  110. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportRequestFlow.js +278 -0
  111. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportSessionActions.js +143 -0
  112. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportTerminalActions.js +468 -0
  113. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportTerminalRuntime.js +171 -0
  114. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportTypes.js +2 -0
  115. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportUtils.js +330 -0
  116. package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportXchangeState.js +107 -0
  117. package/dist/services/features/telegram-mcp/src/shared/integrations/terminal/client.js +255 -0
  118. package/dist/services/features/telegram-mcp/src/shared/integrations/terminal/ptyRegistry.js +543 -0
  119. package/dist/services/features/telegram-mcp/src/shared/integrations/xchange/sqliteRecordStore.js +223 -0
  120. package/dist/services/features/telegram-mcp/src/shared/lib/gatewayScope.js +24 -0
  121. package/dist/services/features/telegram-mcp/src/shared/lib/logger/logger.js +6 -0
  122. package/dist/services/features/telegram-mcp/src/shared/lib/project-identity/projectIdentity.js +147 -76
  123. package/dist/services/features/telegram-mcp/src/shared/lib/telegramXchangeRecords.js +72 -0
  124. package/dist/services/features/telegram-mcp/src/shared/lib/terminalPromptDetection.js +237 -0
  125. package/dist/services/features/telegram-mcp/src/shared/lib/version/versionHandshake.js +129 -1
  126. package/dist/services/features/telegram-mcp/src/shared/lib/xchangeRecordHints.js +98 -0
  127. package/dist/services/features/telegram-mcp/standalone-http.service.js +12 -0
  128. package/dist/services/features/telegram-mcp/terminal-buffer.service.js +42 -0
  129. package/dist/services/features/telegram-mcp/terminal-input.service.js +41 -0
  130. package/dist/services/features/telegram-mcp/tools-sync.service.js +15 -1
  131. package/dist/services/features/telegram-mcp/xchange.service.js +123 -0
  132. package/docs/STANDALONE-ru.md +172 -0
  133. package/docs/STANDALONE.md +172 -0
  134. package/package.json +10 -5
  135. package/scripts/build-package-artifact.sh +27 -0
  136. package/scripts/deploy-gateway.sh +64 -0
  137. package/scripts/deploy-onebot-branch.sh +27 -0
  138. package/scripts/postinstall.js +11 -36
  139. package/STANDALONE-ru.md +0 -274
  140. package/STANDALONE.md +0 -274
  141. package/dist/services/features/telegram-mcp/inbox.service.js +0 -33
  142. package/dist/services/features/telegram-mcp/pair.service.js +0 -33
  143. package/dist/services/features/telegram-mcp/src/app/webapp/tmux.js +0 -10
  144. package/dist/services/features/telegram-mcp/src/features/inbox/model/deleteTelegramInboxMessageTool.js +0 -33
  145. package/dist/services/features/telegram-mcp/src/features/inbox/model/getTelegramInboxCountTool.js +0 -33
  146. package/dist/services/features/telegram-mcp/src/features/inbox/model/getTelegramInboxTool.js +0 -33
  147. package/dist/services/features/telegram-mcp/src/features/inbox/model/inboxService.js +0 -77
  148. package/dist/services/features/telegram-mcp/src/features/pair-session/model/clearSessionPairingTool.js +0 -33
  149. package/dist/services/features/telegram-mcp/src/features/pair-session/model/createSessionPairCodeTool.js +0 -33
  150. package/dist/services/features/telegram-mcp/src/features/pair-session/model/generatePairCode.js +0 -202
  151. package/dist/services/features/telegram-mcp/src/features/session-context/model/getTmuxTargetTool.js +0 -33
  152. package/dist/services/features/telegram-mcp/src/features/session-context/model/setTmuxTargetTool.js +0 -33
  153. package/dist/services/features/telegram-mcp/src/shared/integrations/tmux/client.js +0 -363
@@ -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;
@@ -0,0 +1,62 @@
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(/^project-detail:(.+)$/u, async (ctx) => {
45
+ await this.host.handleProjectDetailCallback(ctx);
46
+ });
47
+ bot.callbackQuery(/^project-delete:(.+)$/u, async (ctx) => {
48
+ await this.host.handleProjectDeleteCallback(ctx);
49
+ });
50
+ bot.callbackQuery(/^project-leave:(.+)$/u, async (ctx) => {
51
+ await this.host.handleProjectLeaveCallback(ctx);
52
+ });
53
+ bot.callbackQuery("project-back", async (ctx) => {
54
+ await ctx.answerCallbackQuery({ text: "Back to projects." });
55
+ await this.host.showProjectsMenu(ctx);
56
+ });
57
+ bot.on("message", async (ctx) => {
58
+ await this.host.handleMessage(ctx);
59
+ });
60
+ }
61
+ }
62
+ exports.TransportMenuShell = TransportMenuShell;