@deadragdoll/tellymcp 0.0.9 → 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.
- package/.env.example.client +42 -50
- package/.env.example.gateway +49 -61
- package/CHANGELOG.md +3 -3
- package/README-ru.md +205 -384
- package/README.md +195 -1194
- package/TOOLS.md +294 -377
- package/VERSION.md +36 -10
- 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 +40 -20
- package/config/templates/env.client.template +34 -18
- package/config/templates/env.gateway.template +38 -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/approval.service.js +1 -1
- package/dist/services/features/telegram-mcp/browser.service.js +95 -2
- package/dist/services/features/telegram-mcp/collaboration.service.js +41 -4
- 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-rmq.service.js +3 -2
- package/dist/services/features/telegram-mcp/gateway-socket.service.js +905 -87
- package/dist/services/features/telegram-mcp/gateway.service.js +876 -81
- package/dist/services/features/telegram-mcp/mcp-http.service.js +9 -1
- package/dist/services/features/telegram-mcp/mcp-server.service.js +17 -26
- package/dist/services/features/telegram-mcp/notify.service.js +128 -2
- package/dist/services/features/telegram-mcp/runtime.service.js +27 -7
- package/dist/services/features/telegram-mcp/session-context.service.js +29 -2
- package/dist/services/features/telegram-mcp/src/app/bootstrap/runtime.js +133 -10
- package/dist/services/features/telegram-mcp/src/app/config/env.js +161 -51
- 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 +116 -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/browserScreenshotTool.js +1 -1
- package/dist/services/features/telegram-mcp/src/features/browser/model/browserService.js +249 -19
- 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 +649 -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/index.js +46 -0
- package/dist/services/features/telegram-mcp/src/shared/i18n/resources/en.js +652 -0
- package/dist/services/features/telegram-mcp/src/shared/i18n/resources/ru.js +652 -0
- 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 +51 -71
- 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 +411 -6524
- 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 +143 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportConstructorWiring.js +633 -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 +62 -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 +101 -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 +468 -0
- package/dist/services/features/telegram-mcp/src/shared/integrations/telegram/transportTerminalRuntime.js +171 -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 +237 -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 +13 -1
- 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 +16 -2
- 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 +11 -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
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectTerminalInteractivePrompt = detectTerminalInteractivePrompt;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const ANSI_ESCAPE_SEQUENCE_PATTERN =
|
|
6
|
+
// eslint-disable-next-line no-control-regex
|
|
7
|
+
/\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/gu;
|
|
8
|
+
const STRONG_PATTERNS = [
|
|
9
|
+
{
|
|
10
|
+
pattern: /\[(?:[Yy]\/[Nn]|[Nn]\/[Yy])\]|\((?:[Yy]\/[Nn]|[Nn]\/[Yy])\)/u,
|
|
11
|
+
score: 5,
|
|
12
|
+
reason: "yes_no_prompt",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
pattern: /press\s+enter\s+to\s+continue|hit\s+enter\s+to\s+continue/iu,
|
|
16
|
+
score: 5,
|
|
17
|
+
reason: "press_enter_prompt",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
pattern: /waiting\s+for\s+(?:user\s+)?input|awaiting\s+(?:user\s+)?(?:input|confirmation)|requires?\s+approval|need\s+your\s+(?:input|permission|approval)|cannot\s+continue\s+without/iu,
|
|
21
|
+
score: 4,
|
|
22
|
+
reason: "waiting_for_input",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
pattern: /\b(do\s+you\s+want|are\s+you\s+sure|would\s+you\s+like|should\s+i|can\s+i\s+go\s+ahead|may\s+i\s+proceed)\b/iu,
|
|
26
|
+
score: 4,
|
|
27
|
+
reason: "direct_question_phrase",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
pattern: /\[\s*!\s*\]\s*action\s+required\b/iu,
|
|
31
|
+
score: 5,
|
|
32
|
+
reason: "action_required_banner",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
pattern: /\bfield\s+\d+\/\d+\s+\(\d+\s+required\s+unanswered\)/iu,
|
|
36
|
+
score: 5,
|
|
37
|
+
reason: "required_unanswered_field",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
pattern: /\ballow\s+the\s+.+\?\s*$/iu,
|
|
41
|
+
score: 4,
|
|
42
|
+
reason: "allow_question",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
pattern: /\brun\s+the\s+tool\s+and\s+continue\b/iu,
|
|
46
|
+
score: 4,
|
|
47
|
+
reason: "tool_continue_prompt",
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
const MEDIUM_PATTERNS = [
|
|
51
|
+
{
|
|
52
|
+
pattern: /\b(confirm|approve|allow|continue|proceed|select|choose)\b/iu,
|
|
53
|
+
score: 1,
|
|
54
|
+
reason: "action_keyword",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
pattern: /\?\s*$/u,
|
|
58
|
+
score: 1,
|
|
59
|
+
reason: "question_mark",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
pattern: /\b(?:always\s+allow|allow\s+for\s+this\s+session|cancel\s+this\s+tool\s+call)\b/iu,
|
|
63
|
+
score: 1,
|
|
64
|
+
reason: "tool_choice_keyword",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
function normalizeLine(line) {
|
|
68
|
+
return line
|
|
69
|
+
.replaceAll("\r", "")
|
|
70
|
+
.replace(ANSI_ESCAPE_SEQUENCE_PATTERN, "")
|
|
71
|
+
.replace(/\s+/gu, " ")
|
|
72
|
+
.trim();
|
|
73
|
+
}
|
|
74
|
+
function isNoiseLine(line) {
|
|
75
|
+
if (!line) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (line.length > 260) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return (/^\[[0-9]{4}-[0-9]{2}-[0-9]{2}\b/u.test(line) ||
|
|
82
|
+
/^at\s+.+\(.+\)$/u.test(line) ||
|
|
83
|
+
/^diff --git\b/u.test(line) ||
|
|
84
|
+
/^(---|\+\+\+|@@)\b/u.test(line) ||
|
|
85
|
+
/^[~/.\w-]+:\d+:\d+/u.test(line) ||
|
|
86
|
+
/^https?:\/\/\S+$/u.test(line));
|
|
87
|
+
}
|
|
88
|
+
function scoreStrongLine(line) {
|
|
89
|
+
const contributions = [];
|
|
90
|
+
for (const candidate of STRONG_PATTERNS) {
|
|
91
|
+
if (candidate.pattern.test(line)) {
|
|
92
|
+
contributions.push({
|
|
93
|
+
score: candidate.score,
|
|
94
|
+
reason: candidate.reason,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return contributions;
|
|
99
|
+
}
|
|
100
|
+
function scoreMediumLine(line, strategy) {
|
|
101
|
+
const contributions = [];
|
|
102
|
+
for (const candidate of MEDIUM_PATTERNS) {
|
|
103
|
+
if (candidate.pattern.test(line)) {
|
|
104
|
+
contributions.push({
|
|
105
|
+
score: candidate.score,
|
|
106
|
+
reason: candidate.reason,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (strategy === "balanced" &&
|
|
111
|
+
/\b(input|reply|answer|decision|permission|approval)\b/iu.test(line)) {
|
|
112
|
+
contributions.push({
|
|
113
|
+
score: 1,
|
|
114
|
+
reason: "balanced_context_keyword",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return contributions;
|
|
118
|
+
}
|
|
119
|
+
function isStrongReason(reason) {
|
|
120
|
+
return STRONG_PATTERNS.some((candidate) => candidate.reason === reason);
|
|
121
|
+
}
|
|
122
|
+
function detectGroupedSignals(candidateLines, strategy) {
|
|
123
|
+
const signals = [];
|
|
124
|
+
const hasPrimaryAllowChoice = candidateLines.some((line) => /^>?[\s\d.]*allow\b/iu.test(line));
|
|
125
|
+
const hasSecondaryApprovalChoice = candidateLines.some((line) => /\b(?:allow\s+once|allow\s+for\s+this\s+session|always\s+allow|cancel)\b/iu.test(line));
|
|
126
|
+
const hasSubmitCancelHint = candidateLines.some((line) => /\benter\s+to\s+submit\b.*\besc\s+to\s+cancel\b/iu.test(line));
|
|
127
|
+
if (hasPrimaryAllowChoice && hasSecondaryApprovalChoice) {
|
|
128
|
+
signals.push({
|
|
129
|
+
score: 5,
|
|
130
|
+
reason: "approval_choice_group",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (hasSubmitCancelHint) {
|
|
134
|
+
signals.push({
|
|
135
|
+
score: strategy === "balanced" ? 2 : 3,
|
|
136
|
+
reason: "submit_cancel_hint",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return signals;
|
|
140
|
+
}
|
|
141
|
+
function collectCandidateLines(rawText, maxLines) {
|
|
142
|
+
const normalized = rawText
|
|
143
|
+
.split("\n")
|
|
144
|
+
.map(normalizeLine)
|
|
145
|
+
.filter((line) => line.length > 0);
|
|
146
|
+
return normalized.slice(-Math.max(1, maxLines));
|
|
147
|
+
}
|
|
148
|
+
function detectTerminalInteractivePrompt(rawText, options = {}) {
|
|
149
|
+
const strategy = options.strategy ?? "strict";
|
|
150
|
+
const minScore = options.minScore ?? (strategy === "balanced" ? 4 : 5);
|
|
151
|
+
const candidateLines = collectCandidateLines(rawText, options.maxLines ?? 40);
|
|
152
|
+
if (candidateLines.length === 0) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const scoredLines = [];
|
|
156
|
+
let score = 0;
|
|
157
|
+
const reasons = new Set();
|
|
158
|
+
for (const line of candidateLines) {
|
|
159
|
+
if (isNoiseLine(line)) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const contributions = scoreStrongLine(line);
|
|
163
|
+
if (contributions.length === 0) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
scoredLines.push({ line, contributions });
|
|
167
|
+
for (const contribution of contributions) {
|
|
168
|
+
score += contribution.score;
|
|
169
|
+
reasons.add(contribution.reason);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const optionLineCount = candidateLines.filter((line) => /^(\d+\.\s+|[-*]\s+|\[[ xX]\]\s+)/u.test(line)).length;
|
|
173
|
+
if (scoredLines.length > 0 && optionLineCount >= 2) {
|
|
174
|
+
score += 3;
|
|
175
|
+
reasons.add("multiple_options");
|
|
176
|
+
}
|
|
177
|
+
for (const signal of detectGroupedSignals(candidateLines, strategy)) {
|
|
178
|
+
score += signal.score;
|
|
179
|
+
reasons.add(signal.reason);
|
|
180
|
+
}
|
|
181
|
+
const hasStrongReason = Array.from(reasons).some(isStrongReason);
|
|
182
|
+
const hasGroupedReason = reasons.has("approval_choice_group") || reasons.has("submit_cancel_hint");
|
|
183
|
+
const hasOnlyQuestionMarkReason = reasons.size === 1 && reasons.has("question_mark");
|
|
184
|
+
if (strategy === "strict") {
|
|
185
|
+
if (hasOnlyQuestionMarkReason) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if (!hasStrongReason) {
|
|
189
|
+
if (!hasGroupedReason) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const canUseMediumSignals = strategy === "balanced" ||
|
|
195
|
+
hasStrongReason ||
|
|
196
|
+
hasGroupedReason ||
|
|
197
|
+
reasons.has("multiple_options");
|
|
198
|
+
if (canUseMediumSignals) {
|
|
199
|
+
for (const line of candidateLines) {
|
|
200
|
+
if (isNoiseLine(line)) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const contributions = scoreMediumLine(line, strategy);
|
|
204
|
+
if (contributions.length === 0) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const existing = scoredLines.find((entry) => entry.line === line);
|
|
208
|
+
if (existing) {
|
|
209
|
+
existing.contributions.push(...contributions);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
scoredLines.push({ line, contributions: [...contributions] });
|
|
213
|
+
}
|
|
214
|
+
for (const contribution of contributions) {
|
|
215
|
+
score += contribution.score;
|
|
216
|
+
reasons.add(contribution.reason);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (score < minScore || scoredLines.length === 0) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
const matchedLines = scoredLines
|
|
224
|
+
.map((entry) => entry.line)
|
|
225
|
+
.slice(-6);
|
|
226
|
+
const excerpt = matchedLines.join("\n");
|
|
227
|
+
const fingerprint = (0, node_crypto_1.createHash)("sha1")
|
|
228
|
+
.update(`${strategy}\n${excerpt}`)
|
|
229
|
+
.digest("hex");
|
|
230
|
+
return {
|
|
231
|
+
score,
|
|
232
|
+
fingerprint,
|
|
233
|
+
excerpt,
|
|
234
|
+
matchedLines,
|
|
235
|
+
reasons: Array.from(reasons),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
@@ -3,14 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TELLYMCP_CAPABILITIES = exports.TELLYMCP_PROTOCOL_VERSION = void 0;
|
|
6
|
+
exports.TELLYMCP_CAPABILITIES = exports.TELLYMCP_PACKAGE_NAME = exports.TELLYMCP_PROTOCOL_VERSION = void 0;
|
|
7
7
|
exports.parseProtocolVersion = parseProtocolVersion;
|
|
8
8
|
exports.evaluateVersionCompatibility = evaluateVersionCompatibility;
|
|
9
9
|
exports.findPackageRoot = findPackageRoot;
|
|
10
|
+
exports.getTellyMcpPackageRoot = getTellyMcpPackageRoot;
|
|
10
11
|
exports.getTellyMcpPackageVersion = getTellyMcpPackageVersion;
|
|
12
|
+
exports.comparePackageVersions = comparePackageVersions;
|
|
13
|
+
exports.fetchLatestPublishedPackageVersion = fetchLatestPublishedPackageVersion;
|
|
14
|
+
exports.detectAvailablePackageUpdate = detectAvailablePackageUpdate;
|
|
11
15
|
const node_fs_1 = require("node:fs");
|
|
12
16
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
17
|
exports.TELLYMCP_PROTOCOL_VERSION = "1.0";
|
|
18
|
+
exports.TELLYMCP_PACKAGE_NAME = "@deadragdoll/tellymcp";
|
|
14
19
|
exports.TELLYMCP_CAPABILITIES = [
|
|
15
20
|
"collab_projects",
|
|
16
21
|
"delivery_status_push",
|
|
@@ -103,7 +108,11 @@ function findPackageRoot(startDir) {
|
|
|
103
108
|
currentDir = parentDir;
|
|
104
109
|
}
|
|
105
110
|
}
|
|
111
|
+
function getTellyMcpPackageRoot(startDir) {
|
|
112
|
+
return findPackageRoot(startDir);
|
|
113
|
+
}
|
|
106
114
|
let cachedPackageVersion = null;
|
|
115
|
+
let latestPublishedVersionPromise = null;
|
|
107
116
|
function getTellyMcpPackageVersion(startDir) {
|
|
108
117
|
if (cachedPackageVersion) {
|
|
109
118
|
return cachedPackageVersion;
|
|
@@ -122,3 +131,122 @@ function getTellyMcpPackageVersion(startDir) {
|
|
|
122
131
|
return "0.0.0-unknown";
|
|
123
132
|
}
|
|
124
133
|
}
|
|
134
|
+
function parseSemver(value) {
|
|
135
|
+
const match = value
|
|
136
|
+
.trim()
|
|
137
|
+
.match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u);
|
|
138
|
+
if (!match) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
major: Number(match[1]),
|
|
143
|
+
minor: Number(match[2]),
|
|
144
|
+
patch: Number(match[3]),
|
|
145
|
+
prerelease: match[4]?.split(".").filter(Boolean) ?? [],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function comparePrerelease(left, right) {
|
|
149
|
+
if (left.length === 0 && right.length === 0) {
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
if (left.length === 0) {
|
|
153
|
+
return 1;
|
|
154
|
+
}
|
|
155
|
+
if (right.length === 0) {
|
|
156
|
+
return -1;
|
|
157
|
+
}
|
|
158
|
+
const maxLength = Math.max(left.length, right.length);
|
|
159
|
+
for (let index = 0; index < maxLength; index += 1) {
|
|
160
|
+
const leftPart = left[index];
|
|
161
|
+
const rightPart = right[index];
|
|
162
|
+
if (leftPart === undefined) {
|
|
163
|
+
return -1;
|
|
164
|
+
}
|
|
165
|
+
if (rightPart === undefined) {
|
|
166
|
+
return 1;
|
|
167
|
+
}
|
|
168
|
+
const leftNumber = /^\d+$/u.test(leftPart) ? Number(leftPart) : null;
|
|
169
|
+
const rightNumber = /^\d+$/u.test(rightPart) ? Number(rightPart) : null;
|
|
170
|
+
if (leftNumber !== null && rightNumber !== null) {
|
|
171
|
+
if (leftNumber !== rightNumber) {
|
|
172
|
+
return leftNumber > rightNumber ? 1 : -1;
|
|
173
|
+
}
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (leftNumber !== null) {
|
|
177
|
+
return -1;
|
|
178
|
+
}
|
|
179
|
+
if (rightNumber !== null) {
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
if (leftPart !== rightPart) {
|
|
183
|
+
return leftPart > rightPart ? 1 : -1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
function comparePackageVersions(leftVersion, rightVersion) {
|
|
189
|
+
const left = parseSemver(leftVersion);
|
|
190
|
+
const right = parseSemver(rightVersion);
|
|
191
|
+
if (!left || !right) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
if (left.major !== right.major) {
|
|
195
|
+
return left.major > right.major ? 1 : -1;
|
|
196
|
+
}
|
|
197
|
+
if (left.minor !== right.minor) {
|
|
198
|
+
return left.minor > right.minor ? 1 : -1;
|
|
199
|
+
}
|
|
200
|
+
if (left.patch !== right.patch) {
|
|
201
|
+
return left.patch > right.patch ? 1 : -1;
|
|
202
|
+
}
|
|
203
|
+
return comparePrerelease(left.prerelease, right.prerelease);
|
|
204
|
+
}
|
|
205
|
+
async function fetchLatestPublishedPackageVersion(timeoutMs = 1500) {
|
|
206
|
+
if (!latestPublishedVersionPromise) {
|
|
207
|
+
latestPublishedVersionPromise = (async () => {
|
|
208
|
+
const controller = new AbortController();
|
|
209
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
210
|
+
try {
|
|
211
|
+
const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(exports.TELLYMCP_PACKAGE_NAME)}/latest`, {
|
|
212
|
+
method: "GET",
|
|
213
|
+
headers: {
|
|
214
|
+
accept: "application/json",
|
|
215
|
+
},
|
|
216
|
+
signal: controller.signal,
|
|
217
|
+
});
|
|
218
|
+
if (!response.ok) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const parsed = (await response.json());
|
|
222
|
+
return typeof parsed.version === "string" && parsed.version.trim()
|
|
223
|
+
? parsed.version.trim()
|
|
224
|
+
: null;
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
clearTimeout(timeout);
|
|
231
|
+
}
|
|
232
|
+
})();
|
|
233
|
+
}
|
|
234
|
+
return latestPublishedVersionPromise;
|
|
235
|
+
}
|
|
236
|
+
async function detectAvailablePackageUpdate(input) {
|
|
237
|
+
if (!input.currentVersion.trim() || input.currentVersion === "0.0.0-unknown") {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const latestVersion = await fetchLatestPublishedPackageVersion(input.timeoutMs);
|
|
241
|
+
if (!latestVersion) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
const comparison = comparePackageVersions(latestVersion, input.currentVersion);
|
|
245
|
+
if (comparison === null || comparison <= 0) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
currentVersion: input.currentVersion,
|
|
250
|
+
latestVersion,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildIncomingPartnerActionDesc = buildIncomingPartnerActionDesc;
|
|
4
|
+
exports.buildIncomingPartnerTools = buildIncomingPartnerTools;
|
|
5
|
+
exports.buildOutgoingPartnerActionDesc = buildOutgoingPartnerActionDesc;
|
|
6
|
+
exports.buildOutgoingPartnerTools = buildOutgoingPartnerTools;
|
|
7
|
+
exports.buildLocalHandoffActionDesc = buildLocalHandoffActionDesc;
|
|
8
|
+
exports.buildLocalHandoffTools = buildLocalHandoffTools;
|
|
9
|
+
exports.buildIncomingTelegramMessageActionDesc = buildIncomingTelegramMessageActionDesc;
|
|
10
|
+
exports.buildIncomingTelegramMessageTools = buildIncomingTelegramMessageTools;
|
|
11
|
+
exports.detectIncomingTelegramBrowserScreenshotRequest = detectIncomingTelegramBrowserScreenshotRequest;
|
|
12
|
+
function looksLikeBrowserScreenshotRequest(text) {
|
|
13
|
+
const haystack = text.toLowerCase();
|
|
14
|
+
return (/\b(browser_open|browser_screenshot|playwright)\b/u.test(haystack) ||
|
|
15
|
+
/\b(скриншот|screenshot|скрин)\b/u.test(haystack) ||
|
|
16
|
+
/\bhttps?:\/\/[^\s]+/u.test(haystack));
|
|
17
|
+
}
|
|
18
|
+
function buildIncomingPartnerActionDesc(kind, requiresReply, prefersFileDelivery = false, prefersBrowserScreenshot = false) {
|
|
19
|
+
if (requiresReply || kind === "question" || kind === "request") {
|
|
20
|
+
if (prefersBrowserScreenshot) {
|
|
21
|
+
return "Start with get_xchange_record for the newest partner_note. For a webpage screenshot request, use browser_open and browser_screenshot in this console to create the screenshot artifact, then send that real file back with send_partner_file. Do not stop at analysis, do not just summarize the request, and do not replace the browser workflow with a shell fallback unless the browser tools actually fail. The task is not complete until send_partner_file succeeds. Only after that may you call mark_xchange_record_read.";
|
|
22
|
+
}
|
|
23
|
+
if (prefersFileDelivery) {
|
|
24
|
+
return "Start with get_xchange_record for the newest partner_note, then carry out the requested work in this session and send the result back as a real file with send_partner_file. Do not stop at analysis, do not just summarize the request, and do not paste file contents into send_partner_note. The task is not complete until send_partner_file succeeds. Only after that may you call mark_xchange_record_read.";
|
|
25
|
+
}
|
|
26
|
+
return "Start with get_xchange_record for the newest partner_note, then carry out the requested work in this session and send the result back with send_partner_note. Do not stop at analysis and do not just restate the request. The task is not complete until send_partner_note succeeds. Only after that may you call mark_xchange_record_read.";
|
|
27
|
+
}
|
|
28
|
+
if (kind === "reply") {
|
|
29
|
+
return "Read the reply and inspect any returned artifacts. If this reply completes a task that originally came from a human telegram_message in this session, you must forward the final result to the human now. Use notify_telegram for text-only results. If the reply returned a real local artifact or file, use send_file_to_telegram to deliver that file to the human Telegram chat. Do not leave the result only in local xchange records. Only after the human-facing delivery succeeds, or after you have incorporated the reply into a non-human internal task, may you call mark_xchange_record_read.";
|
|
30
|
+
}
|
|
31
|
+
if (kind === "handoff") {
|
|
32
|
+
return "Inspect the attached artifacts and body_text, then continue the task in this session. Reply only if the sender requested confirmation or more work.";
|
|
33
|
+
}
|
|
34
|
+
return "Read the shared update and attached artifacts, then continue the task in this session.";
|
|
35
|
+
}
|
|
36
|
+
function buildIncomingPartnerTools(kind, requiresReply, prefersFileDelivery = false, prefersBrowserScreenshot = false) {
|
|
37
|
+
const tools = ["get_xchange_record"];
|
|
38
|
+
if (prefersBrowserScreenshot) {
|
|
39
|
+
tools.push("browser_open", "browser_screenshot");
|
|
40
|
+
}
|
|
41
|
+
if (prefersFileDelivery) {
|
|
42
|
+
tools.push("send_partner_file");
|
|
43
|
+
}
|
|
44
|
+
if (requiresReply || kind === "question" || kind === "request") {
|
|
45
|
+
tools.push("send_partner_note");
|
|
46
|
+
}
|
|
47
|
+
if (kind === "handoff" && !tools.includes("send_partner_file")) {
|
|
48
|
+
tools.push("send_partner_file");
|
|
49
|
+
}
|
|
50
|
+
if (kind === "reply") {
|
|
51
|
+
tools.push("notify_telegram", "send_file_to_telegram");
|
|
52
|
+
}
|
|
53
|
+
tools.push("mark_xchange_record_read");
|
|
54
|
+
return tools;
|
|
55
|
+
}
|
|
56
|
+
function buildOutgoingPartnerActionDesc(kind, requiresReply) {
|
|
57
|
+
if (requiresReply || kind === "question" || kind === "request") {
|
|
58
|
+
return "Outgoing collaboration note was sent to the target session. Do not block on sleep, polling, or repeated list_xchange_records calls in the same turn. The target console will be nudged separately and can reply later through the normal xchange path.";
|
|
59
|
+
}
|
|
60
|
+
return "Outgoing collaboration note was sent to the target session.";
|
|
61
|
+
}
|
|
62
|
+
function buildOutgoingPartnerTools(kind, requiresReply) {
|
|
63
|
+
void kind;
|
|
64
|
+
void requiresReply;
|
|
65
|
+
return ["get_xchange_record"];
|
|
66
|
+
}
|
|
67
|
+
function buildLocalHandoffActionDesc() {
|
|
68
|
+
return "Read body_text, inspect the attached local artifacts, and continue the task in this same session.";
|
|
69
|
+
}
|
|
70
|
+
function buildLocalHandoffTools() {
|
|
71
|
+
return ["get_xchange_record", "mark_xchange_record_read"];
|
|
72
|
+
}
|
|
73
|
+
function buildIncomingTelegramMessageActionDesc(kind, prefersBrowserScreenshot = false) {
|
|
74
|
+
if (kind === "question" || kind === "request") {
|
|
75
|
+
if (prefersBrowserScreenshot) {
|
|
76
|
+
return "Start with get_xchange_record for the newest telegram_message. For a webpage screenshot request, use browser_open and browser_screenshot in this console, and set send_to_telegram=true on browser_screenshot so the PNG goes directly back to the human Telegram chat. Do not stop at analysis, do not just restate the request, do not save the screenshot locally and then search for route metadata, and do not call get_session_context just to deliver the screenshot. The task is not complete until browser_screenshot succeeds with send_to_telegram=true. Only after that may you call mark_xchange_record_read.";
|
|
77
|
+
}
|
|
78
|
+
return "Start with get_xchange_record for the newest telegram_message, then carry out the requested work in this session and reply to the human through notify_telegram. Do not stop at analysis and do not just restate the request. The task is not complete until notify_telegram succeeds. Only after that may you call mark_xchange_record_read.";
|
|
79
|
+
}
|
|
80
|
+
return "Read the Telegram message and attachments, continue the task in this session, and use notify_telegram only if a human-facing reply is needed.";
|
|
81
|
+
}
|
|
82
|
+
function buildIncomingTelegramMessageTools(kind, prefersBrowserScreenshot = false) {
|
|
83
|
+
const tools = ["get_xchange_record"];
|
|
84
|
+
if (prefersBrowserScreenshot && (kind === "question" || kind === "request")) {
|
|
85
|
+
tools.push("browser_open", "browser_screenshot");
|
|
86
|
+
}
|
|
87
|
+
else if (kind === "question" || kind === "request") {
|
|
88
|
+
tools.push("notify_telegram");
|
|
89
|
+
}
|
|
90
|
+
tools.push("mark_xchange_record_read");
|
|
91
|
+
return tools;
|
|
92
|
+
}
|
|
93
|
+
function detectIncomingTelegramBrowserScreenshotRequest(input) {
|
|
94
|
+
if (input.kind !== "question" && input.kind !== "request") {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return looksLikeBrowserScreenshotRequest([input.summary ?? "", input.text].join("\n"));
|
|
98
|
+
}
|
|
@@ -30,6 +30,7 @@ const TelegramMcpStandaloneHttpService = {
|
|
|
30
30
|
],
|
|
31
31
|
created() {
|
|
32
32
|
this.httpServer = null;
|
|
33
|
+
this.upgradeHandler = null;
|
|
33
34
|
},
|
|
34
35
|
async started() {
|
|
35
36
|
if (process.env.TELLYMCP_STANDALONE_HTTP === "false") {
|
|
@@ -47,7 +48,7 @@ const TelegramMcpStandaloneHttpService = {
|
|
|
47
48
|
if (!httpService?.routeRequest) {
|
|
48
49
|
throw new Error(`Local Moleculer service '${mcp_http_service_1.TELEGRAM_MCP_HTTP_SERVICE_NAME}' is unavailable`);
|
|
49
50
|
}
|
|
50
|
-
const runtime = runtimeService.
|
|
51
|
+
const runtime = await runtimeService.waitUntilReady();
|
|
51
52
|
const { host, port, publicRootPrefix } = resolveStandaloneBind(runtime);
|
|
52
53
|
this.httpServer = (0, node_http_1.createServer)(async (req, res) => {
|
|
53
54
|
try {
|
|
@@ -67,6 +68,16 @@ const TelegramMcpStandaloneHttpService = {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
});
|
|
71
|
+
this.upgradeHandler = (req, socket, head) => {
|
|
72
|
+
const requestUrl = new URL(req.url ?? "/", "http://standalone.local");
|
|
73
|
+
void httpService.routeUpgrade?.(req, socket, head, requestUrl.pathname).catch((error) => {
|
|
74
|
+
this.logger.error("Standalone HTTP upgrade failed", {
|
|
75
|
+
error: error instanceof Error ? (error.stack ?? error.message) : String(error),
|
|
76
|
+
});
|
|
77
|
+
socket.destroy();
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
this.httpServer.on("upgrade", this.upgradeHandler);
|
|
70
81
|
await new Promise((resolve, reject) => {
|
|
71
82
|
const server = this.httpServer;
|
|
72
83
|
if (!server) {
|
|
@@ -96,6 +107,7 @@ const TelegramMcpStandaloneHttpService = {
|
|
|
96
107
|
async stopped() {
|
|
97
108
|
const server = this.httpServer;
|
|
98
109
|
this.httpServer = null;
|
|
110
|
+
this.upgradeHandler = null;
|
|
99
111
|
if (!server) {
|
|
100
112
|
return;
|
|
101
113
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TELEGRAM_MCP_TERMINAL_BUFFER_SERVICE_NAME = void 0;
|
|
4
|
+
const runtime_service_1 = require("./runtime.service");
|
|
5
|
+
const remoteConsoleActionClient_1 = require("./src/features/distributed-gateway/model/remoteConsoleActionClient");
|
|
6
|
+
const terminalBufferService_1 = require("./src/features/terminal-buffer/model/terminalBufferService");
|
|
7
|
+
exports.TELEGRAM_MCP_TERMINAL_BUFFER_SERVICE_NAME = "telegramMcp.terminalBuffer";
|
|
8
|
+
const TelegramMcpTerminalBufferService = {
|
|
9
|
+
name: exports.TELEGRAM_MCP_TERMINAL_BUFFER_SERVICE_NAME,
|
|
10
|
+
dependencies: [runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME],
|
|
11
|
+
actions: {
|
|
12
|
+
captureBufferRemote: {
|
|
13
|
+
params: { type: "object" },
|
|
14
|
+
async handler(ctx) {
|
|
15
|
+
return this.getTerminalBufferService().captureBuffer(ctx.params);
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
created() {
|
|
20
|
+
this.terminalBufferService = null;
|
|
21
|
+
},
|
|
22
|
+
methods: {
|
|
23
|
+
getTerminalBufferService() {
|
|
24
|
+
if (!this.terminalBufferService) {
|
|
25
|
+
throw new Error("telegram_mcp terminal-buffer service is not initialized yet");
|
|
26
|
+
}
|
|
27
|
+
return this.terminalBufferService;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async started() {
|
|
31
|
+
await this.broker.waitForServices([runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME]);
|
|
32
|
+
const runtimeService = this.broker.getLocalService(runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME);
|
|
33
|
+
if (!runtimeService) {
|
|
34
|
+
throw new Error(`Local Moleculer service '${runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME}' is unavailable`);
|
|
35
|
+
}
|
|
36
|
+
const runtime = await runtimeService.waitUntilReady();
|
|
37
|
+
this.logger.info("Starting telegram_mcp terminal-buffer service");
|
|
38
|
+
this.terminalBufferService = new terminalBufferService_1.TerminalBufferService(runtime.config, runtime.sessionStore, runtime.logger, runtime.projectIdentityResolver, new remoteConsoleActionClient_1.RemoteConsoleActionClient((actionName, params) => this.broker.call(actionName, params, { meta: { internal_call: true } })));
|
|
39
|
+
this.logger.info("telegram_mcp terminal-buffer service is ready");
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
exports.default = TelegramMcpTerminalBufferService;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TELEGRAM_MCP_TERMINAL_INPUT_SERVICE_NAME = void 0;
|
|
4
|
+
const runtime_service_1 = require("./runtime.service");
|
|
5
|
+
const terminalInputService_1 = require("./src/features/terminal-input/model/terminalInputService");
|
|
6
|
+
exports.TELEGRAM_MCP_TERMINAL_INPUT_SERVICE_NAME = "telegramMcp.terminalInput";
|
|
7
|
+
const TelegramMcpTerminalInputService = {
|
|
8
|
+
name: exports.TELEGRAM_MCP_TERMINAL_INPUT_SERVICE_NAME,
|
|
9
|
+
dependencies: [runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME],
|
|
10
|
+
actions: {
|
|
11
|
+
submitHumanMessageRemote: {
|
|
12
|
+
params: { type: "object" },
|
|
13
|
+
async handler(ctx) {
|
|
14
|
+
return this.getTerminalInputService().submitHumanMessage(ctx.params);
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
created() {
|
|
19
|
+
this.terminalInputService = null;
|
|
20
|
+
},
|
|
21
|
+
methods: {
|
|
22
|
+
getTerminalInputService() {
|
|
23
|
+
if (!this.terminalInputService) {
|
|
24
|
+
throw new Error("telegram_mcp terminal-input service is not initialized yet");
|
|
25
|
+
}
|
|
26
|
+
return this.terminalInputService;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async started() {
|
|
30
|
+
await this.broker.waitForServices([runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME]);
|
|
31
|
+
const runtimeService = this.broker.getLocalService(runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME);
|
|
32
|
+
if (!runtimeService) {
|
|
33
|
+
throw new Error(`Local Moleculer service '${runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME}' is unavailable`);
|
|
34
|
+
}
|
|
35
|
+
const runtime = await runtimeService.waitUntilReady();
|
|
36
|
+
this.logger.info("Starting telegram_mcp terminal-input service");
|
|
37
|
+
this.terminalInputService = new terminalInputService_1.TerminalInputService(runtime.config, runtime.sessionStore, runtime.logger);
|
|
38
|
+
this.logger.info("telegram_mcp terminal-input service is ready");
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
exports.default = TelegramMcpTerminalInputService;
|
|
@@ -2,11 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TELEGRAM_MCP_TOOLS_SYNC_SERVICE_NAME = void 0;
|
|
4
4
|
const runtime_service_1 = require("./runtime.service");
|
|
5
|
+
const remoteConsoleActionClient_1 = require("./src/features/distributed-gateway/model/remoteConsoleActionClient");
|
|
5
6
|
const refreshToolsMarkdownService_1 = require("./src/features/tools-sync/model/refreshToolsMarkdownService");
|
|
6
7
|
exports.TELEGRAM_MCP_TOOLS_SYNC_SERVICE_NAME = "telegramMcp.toolsSync";
|
|
7
8
|
const TelegramMcpToolsSyncService = {
|
|
8
9
|
name: exports.TELEGRAM_MCP_TOOLS_SYNC_SERVICE_NAME,
|
|
9
10
|
dependencies: [runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME],
|
|
11
|
+
actions: {
|
|
12
|
+
refreshToolsMarkdownRemote: {
|
|
13
|
+
params: {
|
|
14
|
+
$$strict: false,
|
|
15
|
+
session_id: { type: "string", optional: true, empty: false },
|
|
16
|
+
cwd: { type: "string", optional: true, empty: false },
|
|
17
|
+
known_hash: { type: "string", optional: true, empty: false },
|
|
18
|
+
},
|
|
19
|
+
async handler(ctx) {
|
|
20
|
+
return this.getRefreshToolsMarkdownService().refresh(ctx.params);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
10
24
|
created() {
|
|
11
25
|
this.refreshToolsMarkdownService = null;
|
|
12
26
|
},
|
|
@@ -24,9 +38,9 @@ const TelegramMcpToolsSyncService = {
|
|
|
24
38
|
if (!runtimeService) {
|
|
25
39
|
throw new Error(`Local Moleculer service '${runtime_service_1.TELEGRAM_MCP_RUNTIME_SERVICE_NAME}' is unavailable`);
|
|
26
40
|
}
|
|
27
|
-
const runtime = runtimeService.
|
|
41
|
+
const runtime = await runtimeService.waitUntilReady();
|
|
28
42
|
this.logger.info("Starting telegram_mcp tools sync service");
|
|
29
|
-
this.refreshToolsMarkdownService = new refreshToolsMarkdownService_1.RefreshToolsMarkdownService(runtime.config, runtime.
|
|
43
|
+
this.refreshToolsMarkdownService = new refreshToolsMarkdownService_1.RefreshToolsMarkdownService(runtime.config, runtime.sessionStore, runtime.logger, runtime.projectIdentityResolver, new remoteConsoleActionClient_1.RemoteConsoleActionClient((actionName, params) => this.broker.call(actionName, params, { meta: { internal_call: true } })));
|
|
30
44
|
this.logger.info("telegram_mcp tools sync service is ready");
|
|
31
45
|
},
|
|
32
46
|
};
|