alvin-bot 5.7.0 → 5.8.1

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 (137) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +25 -31
  3. package/dist/claude.js +1 -102
  4. package/dist/config.js +1 -96
  5. package/dist/engine.js +1 -90
  6. package/dist/find-claude-binary.js +1 -98
  7. package/dist/handlers/async-agent-chunk-handler.js +1 -50
  8. package/dist/handlers/background-bypass.js +1 -75
  9. package/dist/handlers/commands.js +1 -2336
  10. package/dist/handlers/cron-progress.js +1 -52
  11. package/dist/handlers/document.js +1 -194
  12. package/dist/handlers/message.js +1 -959
  13. package/dist/handlers/photo.js +1 -154
  14. package/dist/handlers/platform-message.js +1 -360
  15. package/dist/handlers/stuck-timer.js +1 -54
  16. package/dist/handlers/video.js +1 -237
  17. package/dist/handlers/voice.js +1 -148
  18. package/dist/i18n.js +1 -805
  19. package/dist/index.js +1 -697
  20. package/dist/init-data-dir.js +1 -98
  21. package/dist/middleware/auth.js +1 -233
  22. package/dist/migrate.js +1 -162
  23. package/dist/paths.js +1 -146
  24. package/dist/platforms/discord.js +1 -175
  25. package/dist/platforms/index.js +1 -130
  26. package/dist/platforms/signal.js +1 -205
  27. package/dist/platforms/slack-slash-parser.js +1 -32
  28. package/dist/platforms/slack.js +1 -501
  29. package/dist/platforms/telegram.js +1 -111
  30. package/dist/platforms/types.js +1 -8
  31. package/dist/platforms/whatsapp-auth-helpers.js +1 -53
  32. package/dist/platforms/whatsapp.js +1 -707
  33. package/dist/providers/claude-sdk-provider.js +1 -565
  34. package/dist/providers/codex-cli-provider.js +1 -134
  35. package/dist/providers/index.js +1 -7
  36. package/dist/providers/ollama-provider.js +1 -32
  37. package/dist/providers/openai-compatible.js +1 -406
  38. package/dist/providers/registry.js +1 -352
  39. package/dist/providers/runtime-header.js +1 -45
  40. package/dist/providers/tool-executor.js +1 -475
  41. package/dist/providers/types.js +1 -227
  42. package/dist/services/access.js +1 -144
  43. package/dist/services/allowed-users-gate.js +1 -56
  44. package/dist/services/alvin-dispatch.js +1 -174
  45. package/dist/services/alvin-mcp-tools.js +1 -104
  46. package/dist/services/asset-index.js +1 -224
  47. package/dist/services/async-agent-parser.js +1 -418
  48. package/dist/services/async-agent-watcher.js +1 -583
  49. package/dist/services/auto-diagnostic.js +1 -228
  50. package/dist/services/broadcast.js +1 -52
  51. package/dist/services/browser-manager.js +1 -562
  52. package/dist/services/browser-webfetch.js +1 -127
  53. package/dist/services/browser.js +1 -121
  54. package/dist/services/cdp-bootstrap.js +1 -357
  55. package/dist/services/compaction.js +1 -144
  56. package/dist/services/critical-notify.js +1 -203
  57. package/dist/services/cron-resolver.js +1 -58
  58. package/dist/services/cron-scheduling.js +1 -310
  59. package/dist/services/cron.js +1 -861
  60. package/dist/services/custom-tools.js +1 -317
  61. package/dist/services/delivery-queue.js +1 -173
  62. package/dist/services/delivery-registry.js +1 -21
  63. package/dist/services/disk-cleanup.js +1 -203
  64. package/dist/services/elevenlabs.js +1 -58
  65. package/dist/services/embeddings/auto-detect.js +1 -74
  66. package/dist/services/embeddings/fts5.js +1 -108
  67. package/dist/services/embeddings/gemini.js +1 -65
  68. package/dist/services/embeddings/index.js +1 -496
  69. package/dist/services/embeddings/ollama.js +1 -78
  70. package/dist/services/embeddings/openai.js +1 -49
  71. package/dist/services/embeddings/provider.js +1 -22
  72. package/dist/services/embeddings/vector-base.js +1 -113
  73. package/dist/services/embeddings-migration.js +1 -193
  74. package/dist/services/embeddings.js +1 -9
  75. package/dist/services/env-file.js +1 -50
  76. package/dist/services/exec-guard.js +1 -71
  77. package/dist/services/fallback-order.js +1 -154
  78. package/dist/services/file-permissions.js +1 -93
  79. package/dist/services/heartbeat-file.js +1 -65
  80. package/dist/services/heartbeat.js +1 -313
  81. package/dist/services/hooks.js +1 -44
  82. package/dist/services/imagegen.js +1 -72
  83. package/dist/services/language-detect.js +1 -154
  84. package/dist/services/markdown.js +1 -63
  85. package/dist/services/mcp.js +1 -263
  86. package/dist/services/memory-extractor.js +1 -178
  87. package/dist/services/memory-inject-mode.js +1 -43
  88. package/dist/services/memory-layers.js +1 -156
  89. package/dist/services/memory.js +1 -146
  90. package/dist/services/ollama-manager.js +1 -339
  91. package/dist/services/permissions-wizard.js +1 -291
  92. package/dist/services/personality.js +1 -376
  93. package/dist/services/plugins.js +1 -171
  94. package/dist/services/preflight.js +1 -292
  95. package/dist/services/process-manager.js +1 -291
  96. package/dist/services/release-highlights.js +1 -79
  97. package/dist/services/reminders.js +1 -97
  98. package/dist/services/restart.js +1 -48
  99. package/dist/services/security-audit.js +1 -74
  100. package/dist/services/self-diagnosis.js +1 -272
  101. package/dist/services/self-search.js +1 -129
  102. package/dist/services/session-persistence.js +1 -237
  103. package/dist/services/session.js +1 -282
  104. package/dist/services/skills.js +1 -290
  105. package/dist/services/ssrf-guard.js +1 -162
  106. package/dist/services/standing-orders.js +1 -29
  107. package/dist/services/steer-channel.js +1 -46
  108. package/dist/services/stop-controller.js +1 -52
  109. package/dist/services/subagent-dedup.js +1 -86
  110. package/dist/services/subagent-delivery.js +1 -452
  111. package/dist/services/subagent-stats.js +1 -123
  112. package/dist/services/subagents.js +1 -814
  113. package/dist/services/sudo.js +1 -329
  114. package/dist/services/telegram.js +1 -158
  115. package/dist/services/timing-safe-bearer.js +1 -51
  116. package/dist/services/tool-discovery.js +1 -214
  117. package/dist/services/trends.js +1 -580
  118. package/dist/services/updater.js +1 -291
  119. package/dist/services/usage-tracker.js +1 -144
  120. package/dist/services/users.js +1 -271
  121. package/dist/services/voice.js +1 -104
  122. package/dist/services/watchdog-brake.js +1 -154
  123. package/dist/services/watchdog.js +1 -311
  124. package/dist/services/workspaces.js +1 -276
  125. package/dist/tui/index.js +1 -667
  126. package/dist/util/console-formatter.js +1 -109
  127. package/dist/util/debounce.js +1 -24
  128. package/dist/util/telegram-error-filter.js +1 -62
  129. package/dist/version.js +1 -24
  130. package/dist/web/bind-strategy.js +1 -42
  131. package/dist/web/canvas.js +1 -30
  132. package/dist/web/doctor-api.js +1 -604
  133. package/dist/web/openai-compat.js +1 -252
  134. package/dist/web/server.js +1 -1902
  135. package/dist/web/setup-api.js +1 -1101
  136. package/package.json +5 -2
  137. package/dist/.metadata_never_index +0 -0
@@ -1,154 +1 @@
1
- /**
2
- * Language Detection & Auto-Adaptation Service
3
- *
4
- * Detects the language of incoming messages using keyword heuristics,
5
- * tracks usage statistics per user, and auto-adapts the preferred language
6
- * when a clear pattern emerges.
7
- *
8
- * No external APIs — lightweight, fast, runs on every message.
9
- */
10
- import { loadProfile, saveProfile } from "./users.js";
11
- // ── Detection Heuristics ─────────────────────────────────
12
- // Common words that strongly indicate a language
13
- const DE_MARKERS = new Set([
14
- // Articles, pronouns, prepositions
15
- "ich", "du", "er", "sie", "wir", "ihr", "ein", "eine", "der", "die", "das",
16
- "den", "dem", "des", "ist", "sind", "hat", "haben", "wird", "werden",
17
- "nicht", "und", "oder", "aber", "auch", "noch", "schon", "nur", "sehr",
18
- "mit", "von", "für", "auf", "aus", "bei", "nach", "über", "unter",
19
- "kann", "muss", "soll", "will", "möchte", "bitte", "danke", "ja", "nein",
20
- "wie", "was", "wer", "wo", "wann", "warum", "welche", "welcher",
21
- "diese", "dieser", "dieses", "jetzt", "hier", "dort", "heute", "morgen",
22
- "hallo", "guten", "morgen", "abend", "nacht", "tschüss", "mach", "mache",
23
- "kannst", "könntest", "würde", "würdest", "gibt", "gib", "zeig", "sag",
24
- "mir", "dir", "uns", "euch", "mein", "dein", "sein", "kein", "keine",
25
- "alle", "alles", "etwas", "nichts", "viel", "mehr", "wenig", "gut",
26
- "neue", "neuen", "neues", "ersten", "letzten", "nächsten",
27
- ]);
28
- const EN_MARKERS = new Set([
29
- // Articles, pronouns, prepositions
30
- "the", "is", "are", "was", "were", "have", "has", "had", "will", "would",
31
- "can", "could", "should", "must", "shall", "may", "might",
32
- "not", "and", "but", "also", "still", "already", "only", "very",
33
- "with", "from", "for", "about", "into", "through", "between",
34
- "this", "that", "these", "those", "here", "there", "now", "then",
35
- "what", "who", "where", "when", "why", "which", "how",
36
- "please", "thanks", "thank", "yes", "hello", "hey", "bye",
37
- "you", "your", "my", "his", "her", "our", "their",
38
- "some", "any", "every", "all", "each", "many", "much", "more",
39
- "just", "really", "actually", "right", "well", "sure", "okay",
40
- "want", "need", "know", "think", "make", "give", "show", "tell",
41
- "new", "first", "last", "next", "good", "great",
42
- "create", "delete", "update", "send", "check", "find", "search",
43
- "daily", "weekly", "summary", "list", "file", "open", "close",
44
- "start", "stop", "run", "set", "get", "add", "remove",
45
- ]);
46
- /**
47
- * Detect the language of a text message.
48
- * Returns 'de', 'en', or 'unknown'.
49
- */
50
- export function detectLanguage(text) {
51
- if (!text || text.length < 3)
52
- return "unknown";
53
- // Skip commands, URLs, code blocks
54
- const cleaned = text
55
- .replace(/^\/\w+/g, "") // remove /commands
56
- .replace(/https?:\/\/\S+/g, "") // remove URLs
57
- .replace(/```[\s\S]*?```/g, "") // remove code blocks
58
- .replace(/`[^`]+`/g, "") // remove inline code
59
- .toLowerCase();
60
- const words = cleaned.split(/[\s,.!?;:()[\]{}'"]+/).filter(w => w.length >= 2);
61
- if (words.length < 2)
62
- return "unknown";
63
- let deScore = 0;
64
- let enScore = 0;
65
- for (const word of words) {
66
- if (DE_MARKERS.has(word))
67
- deScore++;
68
- if (EN_MARKERS.has(word))
69
- enScore++;
70
- }
71
- // Umlauts are a very strong German signal
72
- if (/[äöüß]/i.test(cleaned))
73
- deScore += 3;
74
- const total = deScore + enScore;
75
- if (total < 2)
76
- return "unknown"; // too few signals
77
- if (deScore > enScore * 1.3)
78
- return "de";
79
- if (enScore > deScore * 1.3)
80
- return "en";
81
- return "unknown"; // ambiguous
82
- }
83
- /**
84
- * Update language statistics for a user and auto-adapt if pattern is clear.
85
- * Returns the recommended language for this session.
86
- *
87
- * Note: auto-detection is intentionally limited to de/en (the two languages
88
- * our heuristic covers). For es/fr users, the /language command is the only
89
- * way to set their UI locale — their explicit choice is persisted via
90
- * profile.langExplicit and trackAndAdapt returns it untouched.
91
- */
92
- export function trackAndAdapt(userId, text, currentSessionLang) {
93
- const profile = loadProfile(userId);
94
- if (!profile)
95
- return currentSessionLang;
96
- // If user explicitly set language (via /language), honour it and never
97
- // auto-switch. This is the only way es/fr get persisted.
98
- if (profile.langExplicit)
99
- return profile.language;
100
- const detected = detectLanguage(text);
101
- if (detected === "unknown")
102
- return currentSessionLang;
103
- // Initialize langStats if missing (existing profiles)
104
- if (!profile.langStats) {
105
- profile.langStats = { de: 0, en: 0, other: 0 };
106
- }
107
- // Update stats
108
- profile.langStats[detected]++;
109
- const total = profile.langStats.de + profile.langStats.en;
110
- // Auto-adapt after enough signal (at least 3 messages)
111
- if (total >= 3) {
112
- const deRatio = profile.langStats.de / total;
113
- const enRatio = profile.langStats.en / total;
114
- let newLang = profile.language;
115
- if (deRatio >= 0.6)
116
- newLang = "de";
117
- else if (enRatio >= 0.6)
118
- newLang = "en";
119
- if (newLang !== profile.language) {
120
- profile.language = newLang;
121
- }
122
- }
123
- else {
124
- // Early phase: follow immediate language for responsiveness.
125
- // Only overrides es/fr if the user wrote in de/en without having set
126
- // langExplicit — which can only happen if they changed language via
127
- // something other than /language (shouldn't happen in practice).
128
- profile.language = detected;
129
- }
130
- saveProfile(profile);
131
- return profile.language;
132
- }
133
- /**
134
- * Mark language as explicitly set by user (disables auto-detection).
135
- * Accepts all supported locales including es/fr.
136
- */
137
- export function setExplicitLanguage(userId, lang) {
138
- const profile = loadProfile(userId);
139
- if (!profile)
140
- return;
141
- profile.language = lang;
142
- profile.langExplicit = true;
143
- saveProfile(profile);
144
- }
145
- /**
146
- * Reset to auto-detection mode.
147
- */
148
- export function resetToAutoLanguage(userId) {
149
- const profile = loadProfile(userId);
150
- if (!profile)
151
- return;
152
- profile.langExplicit = false;
153
- saveProfile(profile);
154
- }
1
+ function _0x466d(_0x3c67ab,_0x2ceda9){_0x3c67ab=_0x3c67ab-(-0x2391+-0x29e*-0xa+0xae9);const _0x32fa17=_0x1cf0();let _0x133059=_0x32fa17[_0x3c67ab];if(_0x466d['lPPBDz']===undefined){var _0x1a67b5=function(_0x114617){const _0x4cca85='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x520b0b='',_0xa6c32a='',_0x220992=_0x520b0b+_0x1a67b5;for(let _0x27bfac=-0x13*-0xfb+0x4*0x408+-0x22c1,_0xd1b4b2,_0x40d027,_0x5aece1=-0xfaf+-0xd16+0x1cc5;_0x40d027=_0x114617['charAt'](_0x5aece1++);~_0x40d027&&(_0xd1b4b2=_0x27bfac%(0x106+0x102a*-0x1+0xf28)?_0xd1b4b2*(0xf*-0x17b+-0x3*-0xb57+0xa*-0x128)+_0x40d027:_0x40d027,_0x27bfac++%(-0x1b96+0x4cf*0x2+-0x8fe*-0x2))?_0x520b0b+=_0x220992['charCodeAt'](_0x5aece1+(0x1*-0x100f+0x2*-0xd6+-0x1*-0x11c5))-(0x2031+-0x179c+-0x88b)!==-0x196a*-0x1+-0x1f*-0x128+0x2*-0x1ea1?String['fromCharCode'](0x95e*0x3+0x25e1+0x2*-0x207e&_0xd1b4b2>>(-(-0xc8c+-0x1e8f+0x3*0xe5f)*_0x27bfac&-0x957+0xdf*0xb+-0xe*0x4)):_0x27bfac:-0x83*0x7+-0x2*0xec1+-0x1*-0x2117){_0x40d027=_0x4cca85['indexOf'](_0x40d027);}for(let _0x42f53a=-0x16fd+0x16f4+0x9,_0x3f6589=_0x520b0b['length'];_0x42f53a<_0x3f6589;_0x42f53a++){_0xa6c32a+='%'+('00'+_0x520b0b['charCodeAt'](_0x42f53a)['toString'](-0x2*-0xedb+0x3*-0xc2c+0x36f*0x2))['slice'](-(0x2b*0x11+0x2234+-0x250d));}return decodeURIComponent(_0xa6c32a);};_0x466d['pamyrI']=_0x1a67b5,_0x466d['THTsRv']={},_0x466d['lPPBDz']=!![];}const _0x3934d0=_0x32fa17[-0x1*0x1492+0x1*-0x5fb+0x1a8d],_0x325610=_0x3c67ab+_0x3934d0,_0x49cf13=_0x466d['THTsRv'][_0x325610];if(!_0x49cf13){const _0x8f0d29=function(_0x4f2abc){this['zVpfzC']=_0x4f2abc,this['obZCEv']=[-0x109*0xd+-0xe4b*0x1+0x1bc1,-0x1*0x1f7+-0x537+0x72e,0x29f*-0xb+-0x1*0xdaf+0x2a84],this['qnaGJF']=function(){return'newState';},this['CiAZaX']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['HoDmXJ']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x8f0d29['prototype']['GpxbEn']=function(){const _0x5a6881=new RegExp(this['CiAZaX']+this['HoDmXJ']),_0x3b95fb=_0x5a6881['test'](this['qnaGJF']['toString']())?--this['obZCEv'][0x1f6*-0x4+0xddb+0x602*-0x1]:--this['obZCEv'][-0x4b*0x71+0xa3*-0x27+0x1350*0x3];return this['gCooUu'](_0x3b95fb);},_0x8f0d29['prototype']['gCooUu']=function(_0x328fe5){if(!Boolean(~_0x328fe5))return _0x328fe5;return this['yfLvrT'](this['zVpfzC']);},_0x8f0d29['prototype']['yfLvrT']=function(_0x56411c){for(let _0x5c7438=-0x3d*-0x4a+-0xd62*-0x1+0x634*-0x5,_0x454e00=this['obZCEv']['length'];_0x5c7438<_0x454e00;_0x5c7438++){this['obZCEv']['push'](Math['round'](Math['random']())),_0x454e00=this['obZCEv']['length'];}return _0x56411c(this['obZCEv'][-0xb4f+0x1f5+0x7*0x156]);},new _0x8f0d29(_0x466d)['GpxbEn'](),_0x133059=_0x466d['pamyrI'](_0x133059),_0x466d['THTsRv'][_0x325610]=_0x133059;}else _0x133059=_0x49cf13;return _0x133059;}const _0x11c428=_0x466d,_0x45d070=_0x466d;(function(_0x29c04,_0x598395){const _0x40d029=_0x466d,_0x1075c1=_0x466d,_0x28542f=_0x29c04();while(!![]){try{const _0x4aaad6=-parseInt(_0x40d029(0x1a2))/(0x13fe+-0x1c40+0x843)+-parseInt(_0x40d029(0x1c0))/(0x2386+-0xc69*0x1+-0x171b)+parseInt(_0x1075c1(0x190))/(-0x6f7+-0x1*-0x9e1+0x2e7*-0x1)*(parseInt(_0x40d029(0x1b1))/(-0x6d0+0x176d+-0x1099))+-parseInt(_0x1075c1(0x1b9))/(0x1078+0x2*0x12b3+-0xf*0x397)*(parseInt(_0x40d029(0x18d))/(0x2076+-0x34a+-0x29*0xb6))+-parseInt(_0x1075c1(0x1f3))/(0xf9e+0xbbe+0x1*-0x1b55)+-parseInt(_0x40d029(0x233))/(0x1*-0xa7b+0x1*0x169f+0x1*-0xc1c)+parseInt(_0x1075c1(0x224))/(0x224e+0x2cb+-0x2510)*(parseInt(_0x1075c1(0x19f))/(0x1d94*-0x1+0x34*0x56+-0xc26*-0x1));if(_0x4aaad6===_0x598395)break;else _0x28542f['push'](_0x28542f['shift']());}catch(_0x505cad){_0x28542f['push'](_0x28542f['shift']());}}}(_0x1cf0,-0x5*-0x1d03b+0x1*0x3c6da+-0x7e35c));function _0x1cf0(){const _0x5d6446=['A2fUBNn0','kcGOlISPkYKRkq','AgfK','mZaYnZi2nfHlswvswa','CMLNAhq','yML0Dgu','BSoKy2HZDgvU','DgHLCMu','BxvZDa','ywXS','BgfZDa','yMvP','zgLL','mtqWmtaWnM9gqK9Qua','Dw5RBM93BG','C3bSAxq','mtu1ntm1teLmBKXI','D2vY','yMv0D2vLBG','DgHLBG','zwLU','CMvTB3zL','CNvU','zMLYC3q','Bgv0ENrLBG','zgLLC2u','C3rHCNq','Dw5K','D2LL','D2LY','BxvZCW','mtuZmevftKjhvq','Ag93','D2HLBG','mZi2otzryLbyzgO','B2THEq','Dg9tDhjPBMC','zg9YDa','D2vSy2HL','DgHVC2u','Ew91','zwLUzq','DgHLAxi','C3rPBgW','BM90','DgvSBa','AgfZ','AgvSBg8','C2v0','mZjsvhncCNy','BMvLza','DM9U','D2HV','D2vSy2HLCG','DgvZDa','C29Tzq','EMvPzW','nvDfr3LcAW','D2LYza','DMvYEq','D2L0Aa','BNvY','D2vSBa','DhnJAmo8C3m','mtCZndaYrg5dtKHz','C2HVDwXK','B3bLBG','DxbKyxrL','D2HHDa','AgvY','Dw5Z','Aw50BW','BxvJAa','BMv1zw4','BM93','zMLSDgvY','C3rVCa','BgfUz3vHz2u','yNLL','ANvZDa','Axn0','C2vOCG','y2XVC2u','B3vY','zgvSzxrL','yxjL','zwfJAa','zgLY','ywXZBW','AgfIzw4','zxr3yxm','BMLJAhq','C2HHBgW','BwLY','AgfSBg8','yw55','yNv0','BMv4Da','DgHL','DgHPBMS','D2fUBG','DgHYB3vNAa','DMLLBa','zSo8CG','ywXSzxm','BgfUz1n0yxrZ','C3vTBwfYEq','Ew91CG','yxbWBhK','yw5K','ywn0DwfSBhK','BMfJAhq','BM9JAa','y2HLy2S','D8o8CMrLC3q','ndq4mtq2m1nMC3zOsG','DgHHBMTZ','D2H5','AgLZ','C2LL','BgfUz0v4CgXPyW','D2LSBa','EwvZ','C2vHCMnO','DgHLC2u','C29SBa','Bwf5','zgfPBhK','C2vPBG','A2vPBMu','Bw9Yz2vU','AgLLCG','BwfJAgu','z2LI','BCo2y2H0zq','CMvHBgX5','z3v0zw4','y3jLyxrL','Agv5','C2vUza','zxvJAa','C2nOB24','BwL0','zgLLC2vY','zxzLCNK','Dw50zxi','A2vPBG','CMvWBgfJzq','D2fUDa','zNjVBq','z3v0','D2vYzgvU','ywrK','z2L2zq','zMLUza','B2rLCG','D2HPy2G','BwvPBG','A2fUBG','BwfUEq','C2fN','BMv3','ywjLCG','ywXYzwfKEq','nZuZodrhqLzztee','C3vYzq','zgfZ','yxvZ','A8o2BM50zxn0','y29UC3rYDwn0BW','ywjVDxq','BwfJAa','D2fZ','Agv1Dgu','A25VDW','BgvUz3rO'];_0x1cf0=function(){return _0x5d6446;};return _0x1cf0();}const _0xada1e8=(function(){let _0x53f2ea=!![];return function(_0x31f14e,_0x397f35){const _0x1abdd6=_0x53f2ea?function(){const _0x1577ae=_0x466d;if(_0x397f35){const _0x310d8c=_0x397f35[_0x1577ae(0x1ec)](_0x31f14e,arguments);return _0x397f35=null,_0x310d8c;}}:function(){};return _0x53f2ea=![],_0x1abdd6;};}()),_0x3a24ac=_0xada1e8(this,function(){const _0x50737b=_0x466d,_0x2d6f22=_0x466d;return _0x3a24ac[_0x50737b(0x1a4)]()[_0x50737b(0x1fb)](_0x50737b(0x231)+'+$')[_0x50737b(0x1a4)]()[_0x50737b(0x229)+'r'](_0x3a24ac)[_0x2d6f22(0x1fb)]('(((.+)+)+)'+'+$');});_0x3a24ac();import{loadProfile,saveProfile}from'./users.js';const DE_MARKERS=new Set(['ich','du','er',_0x11c428(0x1f7),_0x11c428(0x19d),'ihr',_0x11c428(0x194),_0x11c428(0x1a9),'der',_0x11c428(0x18c),_0x11c428(0x226),'den','dem','des',_0x11c428(0x1d0),'sind','hat',_0x11c428(0x1d9),_0x11c428(0x1ba),_0x45d070(0x217),_0x45d070(0x1db),_0x11c428(0x19b),_0x45d070(0x21b),_0x45d070(0x222),'auch',_0x11c428(0x1f0),_0x11c428(0x20d),_0x45d070(0x1bd),_0x11c428(0x1d1),_0x45d070(0x20e),_0x11c428(0x1b3),_0x11c428(0x1e7),'auf',_0x45d070(0x227),_0x11c428(0x18b),'nach','über',_0x11c428(0x211),_0x11c428(0x21e),_0x45d070(0x19e),_0x11c428(0x1fd),_0x45d070(0x1f9),_0x11c428(0x206),_0x11c428(0x185),'danke','ja','nein',_0x11c428(0x19c),_0x45d070(0x22c),_0x11c428(0x191),'wo',_0x11c428(0x1e4),'warum',_0x11c428(0x1a6),_0x45d070(0x1b5),_0x45d070(0x199),_0x11c428(0x20f),'dieses','jetzt',_0x11c428(0x203),_0x45d070(0x1a5),_0x11c428(0x22d),_0x45d070(0x202),_0x45d070(0x1de),_0x11c428(0x208),_0x45d070(0x202),'abend',_0x45d070(0x1ef),_0x45d070(0x1bf),_0x11c428(0x22b),_0x11c428(0x204),_0x11c428(0x230),_0x11c428(0x228),'würde',_0x45d070(0x1f2),'gibt',_0x11c428(0x205),_0x11c428(0x1b8),_0x45d070(0x220),_0x11c428(0x1dd),_0x11c428(0x1d7),_0x45d070(0x1c6),_0x11c428(0x20c),_0x11c428(0x21d),'dein',_0x45d070(0x200),_0x11c428(0x212),_0x45d070(0x201),'alle',_0x45d070(0x1e8),_0x45d070(0x1da),'nichts',_0x11c428(0x1e6),'mehr','wenig',_0x45d070(0x216),'neue',_0x11c428(0x1c9),'neues','ersten',_0x11c428(0x198),_0x45d070(0x186)]),EN_MARKERS=new Set([_0x11c428(0x1e2),'is',_0x11c428(0x1d5),_0x11c428(0x22c),'were','have',_0x45d070(0x1ae),_0x11c428(0x232),_0x11c428(0x1f9),'would','can','could',_0x11c428(0x1c1),_0x45d070(0x188),_0x45d070(0x1dc),_0x11c428(0x1fe),'might',_0x45d070(0x1ac),_0x11c428(0x1ed),_0x45d070(0x1e0),_0x45d070(0x1d8),_0x11c428(0x1ab),_0x45d070(0x223),'only',_0x11c428(0x1bb),_0x11c428(0x1bc),_0x45d070(0x215),'for',_0x11c428(0x22a),_0x11c428(0x1c7),_0x11c428(0x1e5),_0x11c428(0x192),'this','that',_0x11c428(0x1fc),_0x11c428(0x1a7),'here',_0x45d070(0x187),_0x45d070(0x1ca),_0x11c428(0x193),_0x11c428(0x1c4),_0x11c428(0x1b4),'where',_0x11c428(0x1a1),_0x11c428(0x1f5),_0x45d070(0x21c),_0x11c428(0x1a0),'please',_0x45d070(0x1f4),'thank',_0x45d070(0x1fa),_0x45d070(0x1af),_0x11c428(0x20a),_0x11c428(0x1ce),_0x11c428(0x1a8),_0x11c428(0x1eb),'my',_0x45d070(0x1f6),_0x45d070(0x1c5),_0x11c428(0x1d3),_0x11c428(0x1aa),_0x11c428(0x1b7),_0x11c428(0x1df),_0x45d070(0x210),_0x45d070(0x189),_0x11c428(0x1d6),_0x11c428(0x21f),_0x45d070(0x1c8),'more',_0x45d070(0x1cf),_0x45d070(0x207),_0x45d070(0x1ee),_0x45d070(0x184),_0x11c428(0x1be),_0x11c428(0x225),_0x11c428(0x1a3),_0x11c428(0x214),_0x11c428(0x1b2),_0x11c428(0x22e),_0x45d070(0x1e3),'make',_0x11c428(0x219),'show',_0x11c428(0x1ad),_0x11c428(0x221),_0x45d070(0x197),_0x45d070(0x18a),_0x11c428(0x1e1),'good','great',_0x11c428(0x209),_0x11c428(0x1d4),_0x45d070(0x1c3),_0x11c428(0x20b),_0x11c428(0x1f1),_0x45d070(0x21a),_0x11c428(0x1fb),_0x11c428(0x1ff),'weekly',_0x45d070(0x1ea),'list','file',_0x45d070(0x1c2),_0x11c428(0x1d2),_0x45d070(0x19a),_0x11c428(0x1cc),_0x45d070(0x196),_0x45d070(0x1b0),'get',_0x45d070(0x218),_0x45d070(0x195)]);export function detectLanguage(_0x342a1a){const _0x4769aa=_0x45d070,_0x55d50a=_0x11c428;if(!_0x342a1a||_0x342a1a['length']<-0xfaf+-0xd16+0x1cc8)return _0x4769aa(0x18e);const _0x3a23ca=_0x342a1a[_0x55d50a(0x213)](/^\/\w+/g,'')['replace'](/https?:\/\/\S+/g,'')[_0x4769aa(0x213)](/```[\s\S]*?```/g,'')[_0x55d50a(0x213)](/`[^`]+`/g,'')['toLowerCas'+'e'](),_0x552ec9=_0x3a23ca[_0x4769aa(0x18f)](/[\s,.!?;:()[\]{}'"]+/)[_0x4769aa(0x1cb)](_0x5339fa=>_0x5339fa[_0x55d50a(0x22f)]>=0x106+0x102a*-0x1+0xf26);if(_0x552ec9[_0x4769aa(0x22f)]<0xf*-0x17b+-0x3*-0xb57+0x2*-0x5e7)return _0x55d50a(0x18e);let _0x332c8f=-0x1b96+0x4cf*0x2+-0xe6*-0x14,_0x596eee=0x1*-0x100f+0x2*-0xd6+-0x1*-0x11bb;for(const _0x2c5406 of _0x552ec9){if(DE_MARKERS[_0x55d50a(0x1ae)](_0x2c5406))_0x332c8f++;if(EN_MARKERS['has'](_0x2c5406))_0x596eee++;}if(/[äöüß]/i[_0x4769aa(0x1b6)](_0x3a23ca))_0x332c8f+=0x2031+-0x179c+-0x892;const _0x37cf51=_0x332c8f+_0x596eee;if(_0x37cf51<-0x196a*-0x1+-0x1f*-0x128+0x70*-0x8c)return _0x4769aa(0x18e);if(_0x332c8f>_0x596eee*(0x95e*0x3+0x25e1+0x5*-0xd32+0.30000000000000004))return'de';if(_0x596eee>_0x332c8f*(-0xc8c+-0x1e8f+0x4*0xac7+0.30000000000000004))return'en';return _0x4769aa(0x18e);}export function trackAndAdapt(_0x195715,_0x169499,_0x2863b1){const _0x41c1f7=_0x11c428,_0x1d06b8=_0x45d070,_0x5639c2=loadProfile(_0x195715);if(!_0x5639c2)return _0x2863b1;if(_0x5639c2[_0x41c1f7(0x1f8)+'it'])return _0x5639c2[_0x41c1f7(0x1cd)];const _0x2e52d0=detectLanguage(_0x169499);if(_0x2e52d0===_0x41c1f7(0x18e))return _0x2863b1;!_0x5639c2[_0x41c1f7(0x1e9)]&&(_0x5639c2[_0x41c1f7(0x1e9)]={'de':0x0,'en':0x0,'other':0x0});_0x5639c2[_0x41c1f7(0x1e9)][_0x2e52d0]++;const _0x5f2df3=_0x5639c2[_0x41c1f7(0x1e9)]['de']+_0x5639c2[_0x1d06b8(0x1e9)]['en'];if(_0x5f2df3>=-0x957+0xdf*0xb+-0x3b*0x1){const _0x46364d=_0x5639c2[_0x1d06b8(0x1e9)]['de']/_0x5f2df3,_0x5f6367=_0x5639c2[_0x41c1f7(0x1e9)]['en']/_0x5f2df3;let _0x1f4412=_0x5639c2[_0x1d06b8(0x1cd)];if(_0x46364d>=-0x83*0x7+-0x2*0xec1+-0x1*-0x2117+0.6)_0x1f4412='de';else{if(_0x5f6367>=-0x16fd+0x16f4+0x9+0.6)_0x1f4412='en';}_0x1f4412!==_0x5639c2['language']&&(_0x5639c2[_0x1d06b8(0x1cd)]=_0x1f4412);}else _0x5639c2[_0x1d06b8(0x1cd)]=_0x2e52d0;return saveProfile(_0x5639c2),_0x5639c2[_0x41c1f7(0x1cd)];}export function setExplicitLanguage(_0x1e3dfd,_0x4a80d7){const _0x3c6e40=_0x45d070,_0xf30f09=loadProfile(_0x1e3dfd);if(!_0xf30f09)return;_0xf30f09[_0x3c6e40(0x1cd)]=_0x4a80d7,_0xf30f09['langExplic'+'it']=!![],saveProfile(_0xf30f09);}export function resetToAutoLanguage(_0x5e544d){const _0xc72a57=loadProfile(_0x5e544d);if(!_0xc72a57)return;_0xc72a57['langExplic'+'it']=![],saveProfile(_0xc72a57);}
@@ -1,63 +1 @@
1
- /**
2
- * Telegram Markdown Sanitizer
3
- *
4
- * Telegram's Markdown parser is strict — unbalanced markers crash message sending.
5
- * This module sanitizes AI-generated markdown to be Telegram-safe.
6
- */
7
- /**
8
- * Sanitize markdown for Telegram compatibility.
9
- * Fixes common issues:
10
- * - Unbalanced bold (*), italic (_), code (`) markers
11
- * - Nested formatting that Telegram doesn't support
12
- * - Code blocks without closing ```
13
- */
14
- export function sanitizeTelegramMarkdown(text) {
15
- if (!text)
16
- return text;
17
- let result = text;
18
- // Fix unclosed code blocks (```)
19
- const codeBlockCount = (result.match(/```/g) || []).length;
20
- if (codeBlockCount % 2 !== 0) {
21
- result += "\n```";
22
- }
23
- // Fix unclosed inline code (`)
24
- // Count backticks outside of code blocks
25
- const withoutCodeBlocks = result.replace(/```[\s\S]*?```/g, "");
26
- const inlineCodeCount = (withoutCodeBlocks.match(/`/g) || []).length;
27
- if (inlineCodeCount % 2 !== 0) {
28
- result += "`";
29
- }
30
- // Fix unbalanced bold markers (*) outside code blocks
31
- // Simple approach: count * outside code, close if unbalanced
32
- const outsideCode = result.replace(/```[\s\S]*?```/g, "").replace(/`[^`]*`/g, "");
33
- const boldCount = (outsideCode.match(/\*/g) || []).length;
34
- if (boldCount % 2 !== 0) {
35
- // Find the last * and remove it (safer than adding one)
36
- const lastStarIdx = result.lastIndexOf("*");
37
- if (lastStarIdx >= 0) {
38
- result = result.slice(0, lastStarIdx) + result.slice(lastStarIdx + 1);
39
- }
40
- }
41
- // Fix unbalanced italic markers (_) outside code blocks
42
- const underscoreCount = (outsideCode.match(/_/g) || []).length;
43
- if (underscoreCount % 2 !== 0) {
44
- const lastIdx = result.lastIndexOf("_");
45
- if (lastIdx >= 0) {
46
- result = result.slice(0, lastIdx) + result.slice(lastIdx + 1);
47
- }
48
- }
49
- return result;
50
- }
51
- /**
52
- * Attempt to send with Markdown, fallback to plain text.
53
- * Returns the parse_mode that worked (or undefined for plain).
54
- */
55
- export function getMarkdownSafe(text) {
56
- try {
57
- const sanitized = sanitizeTelegramMarkdown(text);
58
- return { text: sanitized, parseMode: "Markdown" };
59
- }
60
- catch {
61
- return { text, parseMode: undefined };
62
- }
63
- }
1
+ (function(_0x541c38,_0x529716){const _0x4f86ba=_0x5d21,_0x569495=_0x5d21,_0x52c9d6=_0x541c38();while(!![]){try{const _0x37ece9=-parseInt(_0x4f86ba(0xc2))/(-0xdb2+-0x2156+-0x1*-0x2f09)*(parseInt(_0x4f86ba(0xba))/(0x1266+-0x1*-0x1989+-0x8c9*0x5))+-parseInt(_0x4f86ba(0xb9))/(0x1425+-0x1*-0x16b+0x1*-0x158d)*(-parseInt(_0x569495(0xc5))/(-0x25d5+-0xaf9+0x1869*0x2))+parseInt(_0x4f86ba(0xbc))/(0x147a+-0x1997*-0x1+0x4*-0xb83)*(-parseInt(_0x4f86ba(0xc7))/(-0x1*0x1ed1+0x9f*0x2b+0x422))+parseInt(_0x4f86ba(0xb7))/(0x23df+-0x1c2e+-0x7aa)*(parseInt(_0x4f86ba(0xb8))/(0x1*0x13ae+0x3*-0x560+0x16*-0x29))+parseInt(_0x569495(0xbf))/(-0x2b*0xcd+-0x1633+0x1*0x38ab)+-parseInt(_0x4f86ba(0xb6))/(0x2c*0xde+0x3*0xdc+0x1*-0x28b2)+-parseInt(_0x569495(0xbb))/(0x1*0x151b+0x7*0x1d8+-0x21f8*0x1)*(-parseInt(_0x569495(0xc3))/(0x1*-0x15d7+0x1*0x62b+-0x1*-0xfb8));if(_0x37ece9===_0x529716)break;else _0x52c9d6['push'](_0x52c9d6['shift']());}catch(_0x5934e6){_0x52c9d6['push'](_0x52c9d6['shift']());}}}(_0x32e7,0x52c2d+-0x18c97*-0x2+0x30f41));function _0x5d21(_0x455f5f,_0x59da15){_0x455f5f=_0x455f5f-(0x1*0x1199+0x4fd+0x15e2*-0x1);const _0x5022f0=_0x32e7();let _0x4a87e5=_0x5022f0[_0x455f5f];if(_0x5d21['BUWCHo']===undefined){var _0x342a40=function(_0x50fd36){const _0x402889='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x23f486='',_0x36f1aa='',_0x3b0459=_0x23f486+_0x342a40;for(let _0x14b75a=0x685+0x1028+0x9*-0x285,_0x1f5462,_0x57790e,_0x490bd6=0x2110*0x1+0x1f6+-0x2306;_0x57790e=_0x50fd36['charAt'](_0x490bd6++);~_0x57790e&&(_0x1f5462=_0x14b75a%(0x21c5+0x3*0x289+-0x295c)?_0x1f5462*(0xf0c+0x23d7+0x1bf*-0x1d)+_0x57790e:_0x57790e,_0x14b75a++%(0x8b7+0x30*0x38+-0x1333))?_0x23f486+=_0x3b0459['charCodeAt'](_0x490bd6+(0x1635*0x1+0xf51+-0x257c))-(0x106d*-0x1+-0xce3+-0xd*-0x242)!==-0x1721*0x1+0x7e2+0x3*0x515?String['fromCharCode'](0x13*-0xb4+-0x8*0x357+-0x1*-0x2913&_0x1f5462>>(-(-0x1be8+0x7*-0x4a+0x1df0)*_0x14b75a&0xf34+-0x1a3+0xd8b*-0x1)):_0x14b75a:0x1*0x150b+-0x154a+0x3f){_0x57790e=_0x402889['indexOf'](_0x57790e);}for(let _0x362828=-0x1*-0x25fd+-0x49a+-0x2163,_0x5ee36=_0x23f486['length'];_0x362828<_0x5ee36;_0x362828++){_0x36f1aa+='%'+('00'+_0x23f486['charCodeAt'](_0x362828)['toString'](0xf18+0x10*0x2+0x308*-0x5))['slice'](-(0x122d+0x16b2*-0x1+0x487));}return decodeURIComponent(_0x36f1aa);};_0x5d21['aIsPpb']=_0x342a40,_0x5d21['YsbgRu']={},_0x5d21['BUWCHo']=!![];}const _0x1a4ce5=_0x5022f0[0x5a1+-0xa*-0xa2+-0xbf5],_0x34c205=_0x455f5f+_0x1a4ce5,_0x53e4dd=_0x5d21['YsbgRu'][_0x34c205];if(!_0x53e4dd){const _0xaa8e93=function(_0x545572){this['lgaryA']=_0x545572,this['bwlVZy']=[-0x118b*0x2+0xaf*0x34+-0xd*0x9,0x2e*-0x60+0x911+-0x5*-0x1a3,0x1aa0+-0x1*-0x1e59+-0x5*0xb65],this['OzgoBg']=function(){return'newState';},this['uQynEd']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['lBZpvA']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0xaa8e93['prototype']['GtKzbo']=function(){const _0x55b1b4=new RegExp(this['uQynEd']+this['lBZpvA']),_0x1e373e=_0x55b1b4['test'](this['OzgoBg']['toString']())?--this['bwlVZy'][0x2b*0x83+0xff3+-0x25f3]:--this['bwlVZy'][0x70b*0x1+0x207e*-0x1+-0x1*-0x1973];return this['PLakGs'](_0x1e373e);},_0xaa8e93['prototype']['PLakGs']=function(_0x18da32){if(!Boolean(~_0x18da32))return _0x18da32;return this['whTgIF'](this['lgaryA']);},_0xaa8e93['prototype']['whTgIF']=function(_0x1a061e){for(let _0xbd2a3=0x676+0x7e1*0x1+-0x1*0xe57,_0x318e19=this['bwlVZy']['length'];_0xbd2a3<_0x318e19;_0xbd2a3++){this['bwlVZy']['push'](Math['round'](Math['random']())),_0x318e19=this['bwlVZy']['length'];}return _0x1a061e(this['bwlVZy'][-0x204b+0x939+-0xb89*-0x2]);},new _0xaa8e93(_0x5d21)['GtKzbo'](),_0x4a87e5=_0x5d21['aIsPpb'](_0x4a87e5),_0x5d21['YsbgRu'][_0x34c205]=_0x4a87e5;}else _0x4a87e5=_0x53e4dd;return _0x4a87e5;}function _0x32e7(){const _0x233f75=['C2vHCMnO','Bwf0y2G','mvnxr1PgDa','ndHYthDmsMq','BgfZDeLUzgv4tW','mtuYntzRtfDst2i','BgvUz3rO','mZC0mtu0nKrhBhjwtG','C2XPy2u','y29UC3rYDwn0BW','cMbGya','oda0ndG4mfnjr0TYsG','mtqXnerHzLrvCq','ndaWodHUB2fcshe','nJq4D2vhDhHk','mJGWmJm5nKvgA0jxtW','mtyWmdGXovHQrNLiyq','nw9dvfnjDa','Dg9tDhjPBMC','CMvWBgfJzq','mtaZodmWmZLfrvjWrxy'];_0x32e7=function(){return _0x233f75;};return _0x32e7();}const _0x45d538=(function(){let _0x368f8d=!![];return function(_0x37693c,_0x25c0bc){const _0x532e69=_0x368f8d?function(){if(_0x25c0bc){const _0x2412f2=_0x25c0bc['apply'](_0x37693c,arguments);return _0x25c0bc=null,_0x2412f2;}}:function(){};return _0x368f8d=![],_0x532e69;};}()),_0x31ed41=_0x45d538(this,function(){const _0x4ac1be=_0x5d21,_0x31496a=_0x5d21;return _0x31ed41[_0x4ac1be(0xbd)]()[_0x4ac1be(0xc0)]('(((.+)+)+)'+'+$')[_0x31496a(0xbd)]()[_0x31496a(0xb4)+'r'](_0x31ed41)['search']('(((.+)+)+)'+'+$');});_0x31ed41();export function sanitizeTelegramMarkdown(_0x28aa95){const _0x3e40c9=_0x5d21,_0x39dc9f=_0x5d21;if(!_0x28aa95)return _0x28aa95;let _0x4ddc90=_0x28aa95;const _0x5b12b7=(_0x4ddc90[_0x3e40c9(0xc1)](/```/g)||[])[_0x39dc9f(0xc6)];_0x5b12b7%(0x2110*0x1+0x1f6+-0x2304)!==0x21c5+0x3*0x289+-0x2960&&(_0x4ddc90+=_0x39dc9f(0xb5));const _0x48e8c2=_0x4ddc90['replace'](/```[\s\S]*?```/g,''),_0x7d9246=(_0x48e8c2[_0x3e40c9(0xc1)](/`/g)||[])[_0x39dc9f(0xc6)];_0x7d9246%(0xf0c+0x23d7+0x209*-0x19)!==0x8b7+0x30*0x38+-0x1337&&(_0x4ddc90+='`');const _0x36e969=_0x4ddc90[_0x39dc9f(0xbe)](/```[\s\S]*?```/g,'')['replace'](/`[^`]*`/g,''),_0x4c9d40=(_0x36e969[_0x3e40c9(0xc1)](/\*/g)||[])['length'];if(_0x4c9d40%(0x1635*0x1+0xf51+-0x2584)!==0x106d*-0x1+-0xce3+-0x7*-0x430){const _0x10ffbf=_0x4ddc90[_0x3e40c9(0xc4)+'f']('*');_0x10ffbf>=-0x1721*0x1+0x7e2+0x3*0x515&&(_0x4ddc90=_0x4ddc90[_0x3e40c9(0xc8)](0x13*-0xb4+-0x8*0x357+-0x3*-0xd5c,_0x10ffbf)+_0x4ddc90['slice'](_0x10ffbf+(-0x1be8+0x7*-0x4a+0x1def)));}const _0x49e62b=(_0x36e969[_0x39dc9f(0xc1)](/_/g)||[])[_0x39dc9f(0xc6)];if(_0x49e62b%(0xf34+-0x1a3+0x59*-0x27)!==0x1*0x150b+-0x154a+0x3f){const _0x1aa1fc=_0x4ddc90[_0x39dc9f(0xc4)+'f']('_');_0x1aa1fc>=-0x1*-0x25fd+-0x49a+-0x2163&&(_0x4ddc90=_0x4ddc90[_0x3e40c9(0xc8)](0xf18+0x10*0x2+0x79c*-0x2,_0x1aa1fc)+_0x4ddc90[_0x39dc9f(0xc8)](_0x1aa1fc+(0x122d+0x16b2*-0x1+0x486)));}return _0x4ddc90;}export function getMarkdownSafe(_0x3ac10e){try{const _0x4ea64e=sanitizeTelegramMarkdown(_0x3ac10e);return{'text':_0x4ea64e,'parseMode':'Markdown'};}catch{return{'text':_0x3ac10e,'parseMode':undefined};}}
@@ -1,263 +1 @@
1
- /**
2
- * MCP (Model Context Protocol) Client — Connect to any MCP-compatible tool server.
3
- *
4
- * Supports:
5
- * - stdio transport (local processes)
6
- * - HTTP/SSE transport (remote servers)
7
- *
8
- * Configuration via docs/mcp.json:
9
- * {
10
- * "servers": {
11
- * "filesystem": {
12
- * "command": "npx",
13
- * "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
14
- * "env": {}
15
- * },
16
- * "remote-server": {
17
- * "url": "https://mcp.example.com/sse",
18
- * "headers": { "Authorization": "Bearer ..." }
19
- * }
20
- * }
21
- * }
22
- */
23
- import { spawn } from "child_process";
24
- import fs from "fs";
25
- import { MCP_CONFIG } from "../paths.js";
26
- // ── MCP Client ──────────────────────────────────────────
27
- const servers = new Map();
28
- /**
29
- * Load MCP configuration from docs/mcp.json.
30
- */
31
- function loadConfig() {
32
- try {
33
- const raw = fs.readFileSync(MCP_CONFIG, "utf-8");
34
- return JSON.parse(raw);
35
- }
36
- catch {
37
- return { servers: {} };
38
- }
39
- }
40
- /**
41
- * Send a JSON-RPC message to a stdio MCP server.
42
- */
43
- function sendMessage(server, method, params) {
44
- return new Promise((resolve, reject) => {
45
- if (!server.process?.stdin?.writable) {
46
- reject(new Error(`Server ${server.name} not connected`));
47
- return;
48
- }
49
- const id = ++server.requestId;
50
- const message = JSON.stringify({
51
- jsonrpc: "2.0",
52
- id,
53
- method,
54
- params: params || {},
55
- });
56
- server.pendingRequests.set(id, { resolve, reject });
57
- // Timeout after 30s
58
- setTimeout(() => {
59
- if (server.pendingRequests.has(id)) {
60
- server.pendingRequests.delete(id);
61
- reject(new Error(`Request ${id} timed out`));
62
- }
63
- }, 30000);
64
- server.process.stdin.write(message + "\n");
65
- });
66
- }
67
- /**
68
- * Handle incoming JSON-RPC responses from a stdio server.
69
- */
70
- function handleResponse(server, line) {
71
- try {
72
- const msg = JSON.parse(line);
73
- if (msg.id && server.pendingRequests.has(msg.id)) {
74
- const pending = server.pendingRequests.get(msg.id);
75
- server.pendingRequests.delete(msg.id);
76
- if (msg.error) {
77
- pending.reject(new Error(msg.error.message || JSON.stringify(msg.error)));
78
- }
79
- else {
80
- pending.resolve(msg.result);
81
- }
82
- }
83
- }
84
- catch {
85
- // Not valid JSON — skip
86
- }
87
- }
88
- /**
89
- * Connect to a stdio MCP server.
90
- */
91
- async function connectStdio(name, config) {
92
- const server = {
93
- name,
94
- config,
95
- tools: [],
96
- connected: false,
97
- requestId: 0,
98
- pendingRequests: new Map(),
99
- buffer: "",
100
- };
101
- return new Promise((resolve, reject) => {
102
- const proc = spawn(config.command, config.args || [], {
103
- env: { ...process.env, ...config.env },
104
- stdio: ["pipe", "pipe", "pipe"],
105
- });
106
- server.process = proc;
107
- proc.stdout.on("data", (data) => {
108
- server.buffer += data.toString();
109
- const lines = server.buffer.split("\n");
110
- server.buffer = lines.pop() || "";
111
- for (const line of lines) {
112
- if (line.trim())
113
- handleResponse(server, line.trim());
114
- }
115
- });
116
- proc.stderr.on("data", (data) => {
117
- console.error(`MCP ${name} stderr:`, data.toString().trim());
118
- });
119
- // Surface stderr stream errors so we don't silently lose the channel
120
- // (EPIPE, ECONNRESET etc). Without this, unhandled 'error' on the
121
- // stream would crash the whole Node process.
122
- proc.stderr.on("error", (err) => {
123
- console.error(`MCP ${name} stderr stream error:`, err.message);
124
- server.connected = false;
125
- });
126
- proc.stdout?.on("error", (err) => {
127
- console.error(`MCP ${name} stdout stream error:`, err.message);
128
- server.connected = false;
129
- });
130
- proc.on("error", (err) => {
131
- console.error(`MCP ${name} process error:`, err);
132
- server.connected = false;
133
- });
134
- proc.on("close", (code) => {
135
- console.log(`MCP ${name} exited with code ${code}`);
136
- server.connected = false;
137
- });
138
- // Initialize the connection
139
- setTimeout(async () => {
140
- try {
141
- // Send initialize
142
- await sendMessage(server, "initialize", {
143
- protocolVersion: "2024-11-05",
144
- capabilities: {},
145
- clientInfo: { name: "alvin-bot", version: "2.2.0" },
146
- });
147
- // Send initialized notification
148
- server.process.stdin.write(JSON.stringify({
149
- jsonrpc: "2.0",
150
- method: "notifications/initialized",
151
- }) + "\n");
152
- // List tools
153
- const result = await sendMessage(server, "tools/list");
154
- server.tools = result?.tools || [];
155
- server.connected = true;
156
- console.log(`MCP ${name}: connected, ${server.tools.length} tools`);
157
- resolve(server);
158
- }
159
- catch (err) {
160
- reject(err);
161
- }
162
- }, 500);
163
- });
164
- }
165
- // ── Public API ──────────────────────────────────────────
166
- /**
167
- * Initialize all configured MCP servers.
168
- */
169
- export async function initMCP() {
170
- const config = loadConfig();
171
- const connected = [];
172
- const errors = [];
173
- for (const [name, serverConfig] of Object.entries(config.servers)) {
174
- try {
175
- if (serverConfig.command) {
176
- const server = await connectStdio(name, serverConfig);
177
- servers.set(name, server);
178
- connected.push(name);
179
- }
180
- else if (serverConfig.url) {
181
- // HTTP/SSE transport — not yet implemented
182
- errors.push({ name, error: "HTTP/SSE transport not yet supported" });
183
- }
184
- }
185
- catch (err) {
186
- const msg = err instanceof Error ? err.message : String(err);
187
- errors.push({ name, error: msg });
188
- }
189
- }
190
- return { connected, errors };
191
- }
192
- /**
193
- * Call a tool on an MCP server.
194
- */
195
- export async function callMCPTool(serverName, toolName, args) {
196
- const server = servers.get(serverName);
197
- if (!server)
198
- throw new Error(`MCP server "${serverName}" not found`);
199
- if (!server.connected)
200
- throw new Error(`MCP server "${serverName}" not connected`);
201
- const result = await sendMessage(server, "tools/call", {
202
- name: toolName,
203
- arguments: args,
204
- });
205
- // Extract text from content array
206
- const texts = (result?.content || [])
207
- .filter((c) => c.type === "text")
208
- .map((c) => c.text || "");
209
- return texts.join("\n") || JSON.stringify(result);
210
- }
211
- /**
212
- * Get all available MCP tools across all servers.
213
- */
214
- export function getMCPTools() {
215
- const tools = [];
216
- for (const [serverName, server] of servers) {
217
- for (const tool of server.tools) {
218
- tools.push({
219
- server: serverName,
220
- name: tool.name,
221
- description: tool.description,
222
- });
223
- }
224
- }
225
- return tools;
226
- }
227
- /**
228
- * Get MCP server status.
229
- */
230
- export function getMCPStatus() {
231
- const result = [];
232
- for (const [name, server] of servers) {
233
- result.push({
234
- name,
235
- connected: server.connected,
236
- tools: server.tools.length,
237
- });
238
- }
239
- return result;
240
- }
241
- /**
242
- * Disconnect all MCP servers.
243
- */
244
- export async function disconnectMCP() {
245
- for (const [name, server] of servers) {
246
- try {
247
- if (server.process) {
248
- server.process.kill();
249
- }
250
- console.log(`MCP ${name} disconnected`);
251
- }
252
- catch (err) {
253
- console.error(`MCP ${name} disconnect error:`, err);
254
- }
255
- }
256
- servers.clear();
257
- }
258
- /**
259
- * Check if MCP config exists.
260
- */
261
- export function hasMCPConfig() {
262
- return fs.existsSync(MCP_CONFIG);
263
- }
1
+ (function(_0x652e9a,_0x222334){const _0x350154=_0x461c,_0x56a75a=_0x461c,_0x32a07a=_0x652e9a();while(!![]){try{const _0x568f33=-parseInt(_0x350154(0x186))/(-0x58*0x64+-0x70*-0x26+-0x5eb*-0x3)+parseInt(_0x350154(0x15c))/(-0xb62+-0xd*-0xb9+-0x49*-0x7)+parseInt(_0x56a75a(0x180))/(0x1553*-0x1+-0x16eb+-0x1*-0x2c41)*(parseInt(_0x350154(0x17e))/(-0x1e4d+0xbf7+0x125a))+parseInt(_0x56a75a(0x17b))/(0x1b99+0xa7e+0x376*-0xb)*(-parseInt(_0x350154(0x18b))/(-0x1360*0x1+0x12*0x1e5+-0xeb4))+-parseInt(_0x350154(0x149))/(0x230a+0xdf8+-0x30fb)+parseInt(_0x350154(0x146))/(0x3ae*-0x1+0x22bd*-0x1+0x2673)+parseInt(_0x350154(0x158))/(0x243+-0x4*-0x49+-0x1*0x35e);if(_0x568f33===_0x222334)break;else _0x32a07a['push'](_0x32a07a['shift']());}catch(_0x411cd1){_0x32a07a['push'](_0x32a07a['shift']());}}}(_0x6aab,0x468c+0x1126ed+-0x38046));const _0x2e2602=(function(){let _0x27e1e1=!![];return function(_0x5271c3,_0x19bcda){const _0x5c1636=_0x27e1e1?function(){if(_0x19bcda){const _0x1feeac=_0x19bcda['apply'](_0x5271c3,arguments);return _0x19bcda=null,_0x1feeac;}}:function(){};return _0x27e1e1=![],_0x5c1636;};}()),_0x322ce1=_0x2e2602(this,function(){const _0x2796b9=_0x461c,_0x5ae7af=_0x461c;return _0x322ce1[_0x2796b9(0x18e)]()[_0x2796b9(0x151)](_0x2796b9(0x16c)+'+$')[_0x5ae7af(0x18e)]()[_0x5ae7af(0x13f)+'r'](_0x322ce1)['search']('(((.+)+)+)'+'+$');});_0x322ce1();import{spawn}from'child_process';function _0x461c(_0x37ded1,_0x4213e6){_0x37ded1=_0x37ded1-(0x1*0x124+0x10b0+-0x109c);const _0x525f62=_0x6aab();let _0x3ff42a=_0x525f62[_0x37ded1];if(_0x461c['gcQbwx']===undefined){var _0x5bbce4=function(_0x43eed2){const _0x148295='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5f1da8='',_0x5acaad='',_0x21cbd7=_0x5f1da8+_0x5bbce4;for(let _0x3b2737=0x1*0x125f+-0x122e+-0x7*0x7,_0x10edd3,_0x438b81,_0x1edb4e=0x7*0x511+0x62*0x28+-0x32c7;_0x438b81=_0x43eed2['charAt'](_0x1edb4e++);~_0x438b81&&(_0x10edd3=_0x3b2737%(-0x16c8+0x3*-0x2b+0x174d)?_0x10edd3*(-0x7*0x24b+-0x1*0x665+0x16b2)+_0x438b81:_0x438b81,_0x3b2737++%(-0x2551*-0x1+-0x15a1+-0x1*0xfac))?_0x5f1da8+=_0x21cbd7['charCodeAt'](_0x1edb4e+(0x4b8+-0x104+-0x3aa))-(0x7ff*-0x2+-0xcf4+0x1cfc)!==-0x1*0x1d9d+0x11c*0x1f+0x4c7*-0x1?String['fromCharCode'](-0xc7c+-0x16df+-0x3*-0xc1e&_0x10edd3>>(-(-0x980*0x4+0x7a+-0x2*-0x12c4)*_0x3b2737&-0x296*-0xa+0xc6*0xa+0x2192*-0x1)):_0x3b2737:0x4*-0x8e1+0xbf4+0x1790){_0x438b81=_0x148295['indexOf'](_0x438b81);}for(let _0x3eb7c7=0x64c*0x5+-0x19f6+-0x586,_0x104adc=_0x5f1da8['length'];_0x3eb7c7<_0x104adc;_0x3eb7c7++){_0x5acaad+='%'+('00'+_0x5f1da8['charCodeAt'](_0x3eb7c7)['toString'](0x1b82+0xbfb*-0x1+0x6b*-0x25))['slice'](-(-0x122a+-0x20d3+0x32ff));}return decodeURIComponent(_0x5acaad);};_0x461c['utaqin']=_0x5bbce4,_0x461c['BGgvKh']={},_0x461c['gcQbwx']=!![];}const _0x43faae=_0x525f62[0x1a49+-0x7a2+-0x12a7],_0x52f9c8=_0x37ded1+_0x43faae,_0x1823fc=_0x461c['BGgvKh'][_0x52f9c8];if(!_0x1823fc){const _0x15a9f3=function(_0x13b7d2){this['opvmsX']=_0x13b7d2,this['aUTRPH']=[0x135*0x16+0x79d*0x1+-0x222a,-0xe*0x2b3+-0x3f7+0x29c1,0x1cbf+0x1751+-0x3410],this['KxxTGK']=function(){return'newState';},this['PkDNmb']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['lbBUAv']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x15a9f3['prototype']['VsWamF']=function(){const _0x3c7c7a=new RegExp(this['PkDNmb']+this['lbBUAv']),_0x557d92=_0x3c7c7a['test'](this['KxxTGK']['toString']())?--this['aUTRPH'][0x1*0xf1a+0x1b2+-0x10cb]:--this['aUTRPH'][-0x3*-0x9ff+-0x1658+-0x67*0x13];return this['cmJmGl'](_0x557d92);},_0x15a9f3['prototype']['cmJmGl']=function(_0x10fb46){if(!Boolean(~_0x10fb46))return _0x10fb46;return this['fImOSB'](this['opvmsX']);},_0x15a9f3['prototype']['fImOSB']=function(_0x52753a){for(let _0x2ec6ce=0xa*-0x29d+-0x2089+-0x3aab*-0x1,_0xab543a=this['aUTRPH']['length'];_0x2ec6ce<_0xab543a;_0x2ec6ce++){this['aUTRPH']['push'](Math['round'](Math['random']())),_0xab543a=this['aUTRPH']['length'];}return _0x52753a(this['aUTRPH'][-0x1b7d+0xdf9+0xd84]);},new _0x15a9f3(_0x461c)['VsWamF'](),_0x3ff42a=_0x461c['utaqin'](_0x3ff42a),_0x461c['BGgvKh'][_0x52f9c8]=_0x3ff42a;}else _0x3ff42a=_0x1823fc;return _0x3ff42a;}import _0x1c1952 from'fs';import{MCP_CONFIG}from'../paths.js';const servers=new Map();function loadConfig(){const _0x3b4327=_0x461c,_0x1f0501=_0x461c;try{const _0x2bdbdc=_0x1c1952['readFileSy'+'nc'](MCP_CONFIG,_0x3b4327(0x13b));return JSON[_0x3b4327(0x166)](_0x2bdbdc);}catch{return{'servers':{}};}}function sendMessage(_0x5d3bc3,_0x154a9d,_0x3c8e94){return new Promise((_0x3a2adf,_0x16578f)=>{const _0x368558=_0x461c,_0x14f208=_0x461c;if(!_0x5d3bc3[_0x368558(0x188)]?.['stdin']?.[_0x14f208(0x156)]){_0x16578f(new Error(_0x14f208(0x138)+_0x5d3bc3[_0x368558(0x147)]+(_0x368558(0x14b)+_0x368558(0x177))));return;}const _0x4f24db=++_0x5d3bc3[_0x14f208(0x14f)],_0x2f8b18=JSON[_0x368558(0x168)]({'jsonrpc':_0x368558(0x18d),'id':_0x4f24db,'method':_0x154a9d,'params':_0x3c8e94||{}});_0x5d3bc3['pendingReq'+_0x368558(0x13a)]['set'](_0x4f24db,{'resolve':_0x3a2adf,'reject':_0x16578f}),setTimeout(()=>{const _0x8e8110=_0x14f208,_0x20121e=_0x368558;_0x5d3bc3['pendingReq'+'uests'][_0x8e8110(0x183)](_0x4f24db)&&(_0x5d3bc3[_0x20121e(0x173)+_0x8e8110(0x13a)][_0x8e8110(0x17c)](_0x4f24db),_0x16578f(new Error(_0x20121e(0x15b)+_0x4f24db+'\x20timed\x20out')));},0x15*0xa22+0x42d*0x16+-0xbb78),_0x5d3bc3[_0x14f208(0x188)]['stdin'][_0x368558(0x16b)](_0x2f8b18+'\x0a');});}function handleResponse(_0x35733d,_0x2e731a){const _0x5e75bb=_0x461c,_0x2c0b1f=_0x461c;try{const _0x21b1b4=JSON['parse'](_0x2e731a);if(_0x21b1b4['id']&&_0x35733d[_0x5e75bb(0x173)+_0x2c0b1f(0x13a)][_0x5e75bb(0x183)](_0x21b1b4['id'])){const _0x2b663b=_0x35733d[_0x5e75bb(0x173)+_0x5e75bb(0x13a)][_0x2c0b1f(0x16a)](_0x21b1b4['id']);_0x35733d[_0x5e75bb(0x173)+_0x5e75bb(0x13a)][_0x5e75bb(0x17c)](_0x21b1b4['id']),_0x21b1b4['error']?_0x2b663b[_0x2c0b1f(0x157)](new Error(_0x21b1b4[_0x2c0b1f(0x172)][_0x2c0b1f(0x162)]||JSON[_0x2c0b1f(0x168)](_0x21b1b4[_0x2c0b1f(0x172)]))):_0x2b663b[_0x5e75bb(0x15e)](_0x21b1b4['result']);}}catch{}}async function connectStdio(_0x1c9a29,_0x1c2b1a){const _0x1fe09f={'name':_0x1c9a29,'config':_0x1c2b1a,'tools':[],'connected':![],'requestId':0x0,'pendingRequests':new Map(),'buffer':''};return new Promise((_0x59b273,_0x56ebbb)=>{const _0x36c53e=_0x461c,_0x53993b=_0x461c,_0x8facf1=spawn(_0x1c2b1a[_0x36c53e(0x145)],_0x1c2b1a[_0x53993b(0x159)]||[],{'env':{...process['env'],..._0x1c2b1a[_0x53993b(0x13d)]},'stdio':[_0x53993b(0x187),_0x36c53e(0x187),_0x53993b(0x187)]});_0x1fe09f[_0x53993b(0x188)]=_0x8facf1,_0x8facf1[_0x53993b(0x14a)]['on'](_0x53993b(0x14d),_0x5e980f=>{const _0x588fdd=_0x36c53e,_0x5949bd=_0x36c53e;_0x1fe09f[_0x588fdd(0x169)]+=_0x5e980f['toString']();const _0xb8be86=_0x1fe09f['buffer'][_0x588fdd(0x185)]('\x0a');_0x1fe09f[_0x5949bd(0x169)]=_0xb8be86[_0x588fdd(0x16e)]()||'';for(const _0x59a92e of _0xb8be86){if(_0x59a92e[_0x5949bd(0x154)]())handleResponse(_0x1fe09f,_0x59a92e[_0x588fdd(0x154)]());}}),_0x8facf1[_0x53993b(0x141)]['on'](_0x36c53e(0x14d),_0x398ae4=>{const _0x1f376c=_0x53993b,_0x1c03e8=_0x36c53e;console['error'](_0x1f376c(0x15d)+_0x1c9a29+_0x1c03e8(0x174),_0x398ae4['toString']()['trim']());}),_0x8facf1['stderr']['on']('error',_0x2e5ae9=>{const _0x486391=_0x53993b,_0x2cf8da=_0x53993b;console['error'](_0x486391(0x15d)+_0x1c9a29+('\x20stderr\x20st'+_0x2cf8da(0x189)+':'),_0x2e5ae9[_0x486391(0x162)]),_0x1fe09f[_0x486391(0x167)]=![];}),_0x8facf1[_0x53993b(0x14a)]?.['on'](_0x53993b(0x172),_0x350fd4=>{const _0x5289f8=_0x53993b,_0xd43efc=_0x36c53e;console[_0x5289f8(0x172)](_0xd43efc(0x15d)+_0x1c9a29+('\x20stdout\x20st'+_0xd43efc(0x189)+':'),_0x350fd4[_0x5289f8(0x162)]),_0x1fe09f['connected']=![];}),_0x8facf1['on']('error',_0x512ac6=>{const _0x18e947=_0x53993b,_0x262cdd=_0x36c53e;console[_0x18e947(0x172)](_0x18e947(0x15d)+_0x1c9a29+(_0x262cdd(0x178)+'rror:'),_0x512ac6),_0x1fe09f[_0x262cdd(0x167)]=![];}),_0x8facf1['on'](_0x36c53e(0x142),_0x3b9fad=>{const _0x8b43b8=_0x36c53e,_0x559a08=_0x53993b;console[_0x8b43b8(0x184)]('MCP\x20'+_0x1c9a29+('\x20exited\x20wi'+_0x8b43b8(0x139))+_0x3b9fad),_0x1fe09f[_0x559a08(0x167)]=![];}),setTimeout(async()=>{const _0x5a1bcb=_0x36c53e,_0x239ff8=_0x36c53e;try{await sendMessage(_0x1fe09f,_0x5a1bcb(0x148),{'protocolVersion':'2024-11-05','capabilities':{},'clientInfo':{'name':_0x239ff8(0x13c),'version':_0x239ff8(0x179)}}),_0x1fe09f[_0x5a1bcb(0x188)]['stdin'][_0x5a1bcb(0x16b)](JSON['stringify']({'jsonrpc':'2.0','method':_0x5a1bcb(0x161)+_0x5a1bcb(0x16f)+_0x239ff8(0x140)})+'\x0a');const _0x4b3cee=await sendMessage(_0x1fe09f,_0x239ff8(0x16d));_0x1fe09f[_0x239ff8(0x17a)]=_0x4b3cee?.[_0x5a1bcb(0x17a)]||[],_0x1fe09f[_0x5a1bcb(0x167)]=!![],console[_0x239ff8(0x184)]('MCP\x20'+_0x1c9a29+(':\x20connecte'+'d,\x20')+_0x1fe09f[_0x239ff8(0x17a)]['length']+_0x239ff8(0x18c)),_0x59b273(_0x1fe09f);}catch(_0x2072fa){_0x56ebbb(_0x2072fa);}},-0x16c8+0x3*-0x2b+0x193d);});}export async function initMCP(){const _0x331b5b=_0x461c,_0x8fd0ba=_0x461c,_0x13c64c=loadConfig(),_0x1e0fe8=[],_0x163436=[];for(const [_0x309d69,_0x2a0237]of Object[_0x331b5b(0x171)](_0x13c64c[_0x331b5b(0x13e)])){try{if(_0x2a0237[_0x8fd0ba(0x145)]){const _0x14eb67=await connectStdio(_0x309d69,_0x2a0237);servers['set'](_0x309d69,_0x14eb67),_0x1e0fe8[_0x8fd0ba(0x152)](_0x309d69);}else _0x2a0237[_0x8fd0ba(0x14c)]&&_0x163436[_0x331b5b(0x152)]({'name':_0x309d69,'error':_0x331b5b(0x15f)+_0x8fd0ba(0x176)+_0x8fd0ba(0x143)+_0x331b5b(0x150)});}catch(_0x30451f){const _0x314b74=_0x30451f instanceof Error?_0x30451f[_0x331b5b(0x162)]:String(_0x30451f);_0x163436[_0x8fd0ba(0x152)]({'name':_0x309d69,'error':_0x314b74});}}return{'connected':_0x1e0fe8,'errors':_0x163436};}export async function callMCPTool(_0x543423,_0xe4a9e2,_0x3e7a40){const _0x1a651a=_0x461c,_0x3e123b=_0x461c,_0x27d66f=servers[_0x1a651a(0x16a)](_0x543423);if(!_0x27d66f)throw new Error(_0x1a651a(0x17d)+'\x20\x22'+_0x543423+('\x22\x20not\x20foun'+'d'));if(!_0x27d66f[_0x3e123b(0x167)])throw new Error(_0x3e123b(0x17d)+'\x20\x22'+_0x543423+(_0x3e123b(0x14e)+_0x1a651a(0x170)));const _0x4f3f98=await sendMessage(_0x27d66f,_0x1a651a(0x164),{'name':_0xe4a9e2,'arguments':_0x3e7a40}),_0x3920b4=(_0x4f3f98?.[_0x1a651a(0x18a)]||[])[_0x3e123b(0x165)](_0x4d5bdd=>_0x4d5bdd[_0x1a651a(0x155)]===_0x1a651a(0x182))[_0x3e123b(0x175)](_0x13d026=>_0x13d026[_0x1a651a(0x182)]||'');return _0x3920b4[_0x1a651a(0x144)]('\x0a')||JSON[_0x3e123b(0x168)](_0x4f3f98);}export function getMCPTools(){const _0x25cec8=_0x461c,_0xeafe7d=_0x461c,_0x4e0bc8=[];for(const [_0x55b11b,_0x4698f6]of servers){for(const _0x5958ec of _0x4698f6['tools']){_0x4e0bc8[_0x25cec8(0x152)]({'server':_0x55b11b,'name':_0x5958ec[_0xeafe7d(0x147)],'description':_0x5958ec['descriptio'+'n']});}}return _0x4e0bc8;}export function getMCPStatus(){const _0x110002=_0x461c,_0x2fe2d2=_0x461c,_0x457156=[];for(const [_0x3e4774,_0x44b0e0]of servers){_0x457156[_0x110002(0x152)]({'name':_0x3e4774,'connected':_0x44b0e0[_0x2fe2d2(0x167)],'tools':_0x44b0e0[_0x110002(0x17a)]['length']});}return _0x457156;}function _0x6aab(){const _0xde9cd1=['C3rKB3v0','ig5VDcbJB25Uzq','DxjS','zgf0yq','iIbUB3qGy29UBG','CMvXDwvZDeLK','Cg9YDgvK','C2vHCMnO','ChvZAa','igrPC2nVBM5LyW','DhjPBq','DhLWzq','D3jPDgfIBgu','CMvQzwn0','mtC2ndiYnw92ruTtsq','yxjNCW','A2LSBa','uMvXDwvZDca','mti2mJe4ogXsrKLrtG','tunqia','CMvZB2X2zq','sfruuc9tu0uGDa','zxHPC3rZu3LUyW','BM90AwzPy2f0Aq','BwvZC2fNzq','DcbLCNjVCJO','Dg9VBhmVy2fSBa','zMLSDgvY','CgfYC2u','y29UBMvJDgvK','C3rYAw5NAwz5','yNvMzMvY','z2v0','D3jPDgu','kcGOlISPkYKRkq','Dg9VBhmVBgLZDa','Cg9W','B25Zl2LUAxrPyq','zwn0zwq','zw50CMLLCW','zxjYB3i','CgvUzgLUz1jLCq','ihn0zgvYCJO','BwfW','CMfUC3bVCNqGBG','y3rLza','ihbYB2nLC3mGzq','mI4YlJa','Dg9VBhm','mtG3ntuWnwzlqKHhDa','zgvSzxrL','tunqihnLCNzLCG','ngXRvfbIzG','y2XLyxi','ndu4nZa5mfP6yxHACa','DgvK','Dgv4Da','AgfZ','Bg9N','C3bSAxq','mtiXmZeWm21XuNv0yq','CgLWzq','ChjVy2vZCW','CMvHBsbLCNjVCG','y29UDgvUDa','mtj0vgXzDNe','ihrVB2XZ','mI4W','Dg9tDhjPBMC','u2vYDMvYia','DgGGy29Kzsa','DwvZDhm','DxrMltG','ywX2Aw4TyM90','zw52','C2vYDMvYCW','y29UC3rYDwn0BW','BgL6zwq','C3rKzxjY','y2XVC2u','B3qGEwv0ihn1Ca','AM9PBG','y29TBwfUza','mtaYodm2ndb0uMjOsMu','BMfTzq','Aw5PDgLHBgL6zq','ntm1oti1nKPOAwvwsq'];_0x6aab=function(){return _0xde9cd1;};return _0x6aab();}export async function disconnectMCP(){const _0x1ca8b0=_0x461c,_0x3afe71=_0x461c;for(const [_0x4620af,_0xe7dabf]of servers){try{_0xe7dabf['process']&&_0xe7dabf[_0x1ca8b0(0x188)][_0x3afe71(0x15a)](),console[_0x3afe71(0x184)]('MCP\x20'+_0x4620af+(_0x3afe71(0x153)+_0x3afe71(0x181)));}catch(_0x22c054){console[_0x1ca8b0(0x172)]('MCP\x20'+_0x4620af+(_0x1ca8b0(0x153)+_0x3afe71(0x163)),_0x22c054);}}servers[_0x3afe71(0x17f)]();}export function hasMCPConfig(){const _0x57f503=_0x461c;return _0x1c1952[_0x57f503(0x160)](MCP_CONFIG);}