neuro-cli 4.1.0

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 (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +510 -0
  3. package/dist/advisor/advisor.d.ts +50 -0
  4. package/dist/advisor/advisor.js +178 -0
  5. package/dist/agents/base.d.ts +62 -0
  6. package/dist/agents/base.js +215 -0
  7. package/dist/agents/orchestrator.d.ts +46 -0
  8. package/dist/agents/orchestrator.js +192 -0
  9. package/dist/agents/team.d.ts +51 -0
  10. package/dist/agents/team.js +210 -0
  11. package/dist/api/models.d.ts +23 -0
  12. package/dist/api/models.js +514 -0
  13. package/dist/api/ollama.d.ts +153 -0
  14. package/dist/api/ollama.js +751 -0
  15. package/dist/api/openrouter.d.ts +55 -0
  16. package/dist/api/openrouter.js +223 -0
  17. package/dist/commands/commands.d.ts +43 -0
  18. package/dist/commands/commands.js +308 -0
  19. package/dist/config/config.d.ts +8 -0
  20. package/dist/config/config.js +311 -0
  21. package/dist/context/compaction.d.ts +54 -0
  22. package/dist/context/compaction.js +251 -0
  23. package/dist/context/custom-agents.d.ts +107 -0
  24. package/dist/context/custom-agents.js +397 -0
  25. package/dist/context/custom-tools.d.ts +120 -0
  26. package/dist/context/custom-tools.js +564 -0
  27. package/dist/context/git-checkpoint.d.ts +52 -0
  28. package/dist/context/git-checkpoint.js +240 -0
  29. package/dist/context/neuro-md.d.ts +48 -0
  30. package/dist/context/neuro-md.js +202 -0
  31. package/dist/context/neuroignore.d.ts +102 -0
  32. package/dist/context/neuroignore.js +441 -0
  33. package/dist/context/repo-map.d.ts +38 -0
  34. package/dist/context/repo-map.js +220 -0
  35. package/dist/context/skill-standard.d.ts +262 -0
  36. package/dist/context/skill-standard.js +1156 -0
  37. package/dist/context/skill-system.d.ts +75 -0
  38. package/dist/context/skill-system.js +578 -0
  39. package/dist/context/tree-sitter.d.ts +99 -0
  40. package/dist/context/tree-sitter.js +1956 -0
  41. package/dist/core/acp.d.ts +325 -0
  42. package/dist/core/acp.js +1498 -0
  43. package/dist/core/api-server.d.ts +143 -0
  44. package/dist/core/api-server.js +550 -0
  45. package/dist/core/approval.d.ts +81 -0
  46. package/dist/core/approval.js +432 -0
  47. package/dist/core/auto-compact.d.ts +127 -0
  48. package/dist/core/auto-compact.js +436 -0
  49. package/dist/core/auto-mode.d.ts +232 -0
  50. package/dist/core/auto-mode.js +831 -0
  51. package/dist/core/background-session.d.ts +166 -0
  52. package/dist/core/background-session.js +696 -0
  53. package/dist/core/cicd.d.ts +257 -0
  54. package/dist/core/cicd.js +1443 -0
  55. package/dist/core/cloud-sync.d.ts +156 -0
  56. package/dist/core/cloud-sync.js +582 -0
  57. package/dist/core/code-review.d.ts +132 -0
  58. package/dist/core/code-review.js +1191 -0
  59. package/dist/core/completion.d.ts +49 -0
  60. package/dist/core/completion.js +384 -0
  61. package/dist/core/context.d.ts +38 -0
  62. package/dist/core/context.js +144 -0
  63. package/dist/core/diff-preview.d.ts +35 -0
  64. package/dist/core/diff-preview.js +173 -0
  65. package/dist/core/doom-loop.d.ts +51 -0
  66. package/dist/core/doom-loop.js +179 -0
  67. package/dist/core/engine.d.ts +183 -0
  68. package/dist/core/engine.js +942 -0
  69. package/dist/core/extended-thinking.d.ts +103 -0
  70. package/dist/core/extended-thinking.js +269 -0
  71. package/dist/core/fallback.d.ts +54 -0
  72. package/dist/core/fallback.js +104 -0
  73. package/dist/core/git-worktree.d.ts +139 -0
  74. package/dist/core/git-worktree.js +614 -0
  75. package/dist/core/headless.d.ts +30 -0
  76. package/dist/core/headless.js +101 -0
  77. package/dist/core/i18n.d.ts +83 -0
  78. package/dist/core/i18n.js +739 -0
  79. package/dist/core/linting.d.ts +129 -0
  80. package/dist/core/linting.js +699 -0
  81. package/dist/core/model-router.d.ts +109 -0
  82. package/dist/core/model-router.js +581 -0
  83. package/dist/core/multi-model.d.ts +243 -0
  84. package/dist/core/multi-model.js +1099 -0
  85. package/dist/core/multi-session.d.ts +144 -0
  86. package/dist/core/multi-session.js +442 -0
  87. package/dist/core/multimodal.d.ts +125 -0
  88. package/dist/core/multimodal.js +286 -0
  89. package/dist/core/observability.d.ts +93 -0
  90. package/dist/core/observability.js +737 -0
  91. package/dist/core/os-sandbox.d.ts +122 -0
  92. package/dist/core/os-sandbox.js +1193 -0
  93. package/dist/core/outcome-grading.d.ts +228 -0
  94. package/dist/core/outcome-grading.js +1123 -0
  95. package/dist/core/output-styles.d.ts +57 -0
  96. package/dist/core/output-styles.js +382 -0
  97. package/dist/core/parallel-agents.d.ts +183 -0
  98. package/dist/core/parallel-agents.js +563 -0
  99. package/dist/core/plugin-bundle.d.ts +236 -0
  100. package/dist/core/plugin-bundle.js +887 -0
  101. package/dist/core/plugin-sdk.d.ts +139 -0
  102. package/dist/core/plugin-sdk.js +273 -0
  103. package/dist/core/prompt-cache.d.ts +163 -0
  104. package/dist/core/prompt-cache.js +599 -0
  105. package/dist/core/sandbox.d.ts +127 -0
  106. package/dist/core/sandbox.js +369 -0
  107. package/dist/core/scheduled-tasks.d.ts +151 -0
  108. package/dist/core/scheduled-tasks.js +502 -0
  109. package/dist/core/security-scanner.d.ts +160 -0
  110. package/dist/core/security-scanner.js +1494 -0
  111. package/dist/core/session.d.ts +83 -0
  112. package/dist/core/session.js +269 -0
  113. package/dist/core/shell-completion.d.ts +51 -0
  114. package/dist/core/shell-completion.js +674 -0
  115. package/dist/core/smart-monitor.d.ts +146 -0
  116. package/dist/core/smart-monitor.js +1199 -0
  117. package/dist/core/spec-driven.d.ts +233 -0
  118. package/dist/core/spec-driven.js +1485 -0
  119. package/dist/core/spending-warnings.d.ts +123 -0
  120. package/dist/core/spending-warnings.js +456 -0
  121. package/dist/core/sub-agent.d.ts +298 -0
  122. package/dist/core/sub-agent.js +1023 -0
  123. package/dist/core/telemetry.d.ts +157 -0
  124. package/dist/core/telemetry.js +412 -0
  125. package/dist/core/terminal-ux.d.ts +134 -0
  126. package/dist/core/terminal-ux.js +649 -0
  127. package/dist/core/testing.d.ts +146 -0
  128. package/dist/core/testing.js +1200 -0
  129. package/dist/core/types.d.ts +439 -0
  130. package/dist/core/types.js +6 -0
  131. package/dist/core/undo-redo.d.ts +112 -0
  132. package/dist/core/undo-redo.js +290 -0
  133. package/dist/core/updater.d.ts +159 -0
  134. package/dist/core/updater.js +608 -0
  135. package/dist/core/vim-mode.d.ts +151 -0
  136. package/dist/core/vim-mode.js +771 -0
  137. package/dist/core/voice.d.ts +137 -0
  138. package/dist/core/voice.js +538 -0
  139. package/dist/core/web-dashboard.d.ts +109 -0
  140. package/dist/core/web-dashboard.js +484 -0
  141. package/dist/hooks/hooks.d.ts +74 -0
  142. package/dist/hooks/hooks.js +160 -0
  143. package/dist/hooks/llm-evaluator.d.ts +165 -0
  144. package/dist/hooks/llm-evaluator.js +560 -0
  145. package/dist/index.d.ts +3 -0
  146. package/dist/index.js +1186 -0
  147. package/dist/lsp/lsp-manager.d.ts +63 -0
  148. package/dist/lsp/lsp-manager.js +351 -0
  149. package/dist/mcp/client.d.ts +133 -0
  150. package/dist/mcp/client.js +684 -0
  151. package/dist/mcp/mcp-apps.d.ts +70 -0
  152. package/dist/mcp/mcp-apps.js +1007 -0
  153. package/dist/tools/bash.d.ts +5 -0
  154. package/dist/tools/bash.js +195 -0
  155. package/dist/tools/browser.d.ts +92 -0
  156. package/dist/tools/browser.js +1570 -0
  157. package/dist/tools/extended.d.ts +6 -0
  158. package/dist/tools/extended.js +191 -0
  159. package/dist/tools/file.d.ts +10 -0
  160. package/dist/tools/file.js +382 -0
  161. package/dist/tools/github.d.ts +389 -0
  162. package/dist/tools/github.js +759 -0
  163. package/dist/tools/index.d.ts +9 -0
  164. package/dist/tools/index.js +40 -0
  165. package/dist/tools/memory.d.ts +6 -0
  166. package/dist/tools/memory.js +197 -0
  167. package/dist/tools/registry.d.ts +29 -0
  168. package/dist/tools/registry.js +64 -0
  169. package/dist/tools/web.d.ts +6 -0
  170. package/dist/tools/web.js +150 -0
  171. package/dist/ui/renderer.d.ts +97 -0
  172. package/dist/ui/renderer.js +279 -0
  173. package/dist/ui/theme.d.ts +27 -0
  174. package/dist/ui/theme.js +106 -0
  175. package/package.json +83 -0
@@ -0,0 +1,63 @@
1
+ export interface LSPDiagnostic {
2
+ file: string;
3
+ line: number;
4
+ column: number;
5
+ severity: 'error' | 'warning' | 'info' | 'hint';
6
+ message: string;
7
+ source?: string;
8
+ code?: string;
9
+ }
10
+ export interface LSPDefinition {
11
+ file: string;
12
+ line: number;
13
+ column: number;
14
+ name: string;
15
+ kind: string;
16
+ }
17
+ export interface LSPReference {
18
+ file: string;
19
+ line: number;
20
+ column: number;
21
+ }
22
+ export declare class LSPManager {
23
+ private servers;
24
+ private workingDirectory;
25
+ private diagnostics;
26
+ private initialized;
27
+ constructor(workingDirectory: string);
28
+ /**
29
+ * Initialize LSP servers based on project tech stack
30
+ */
31
+ initialize(): Promise<void>;
32
+ /**
33
+ * Get diagnostics for a file
34
+ */
35
+ getDiagnostics(filePath: string): LSPDiagnostic[];
36
+ /**
37
+ * Get all diagnostics across all files
38
+ */
39
+ getAllDiagnostics(): LSPDiagnostic[];
40
+ /**
41
+ * Get diagnostics as context string for LLM
42
+ */
43
+ getDiagnosticsContext(): string;
44
+ /**
45
+ * Request diagnostics for a file after edit
46
+ */
47
+ requestDiagnostics(filePath: string): Promise<LSPDiagnostic[]>;
48
+ /**
49
+ * Go to definition
50
+ */
51
+ gotoDefinition(filePath: string, line: number, column: number): Promise<LSPDefinition | null>;
52
+ /**
53
+ * Find references
54
+ */
55
+ findReferences(filePath: string, line: number, column: number): Promise<LSPReference[]>;
56
+ /**
57
+ * Shutdown all LSP servers
58
+ */
59
+ shutdown(): void;
60
+ private detectLanguageServers;
61
+ private findServerForFile;
62
+ }
63
+ //# sourceMappingURL=lsp-manager.d.ts.map
@@ -0,0 +1,351 @@
1
+ // ============================================================
2
+ // NeuroCLI - LSP Integration
3
+ // Real-time code intelligence via Language Servers
4
+ // (Like OpenCode/CRUSH - unique killer feature)
5
+ // ============================================================
6
+ import { spawn } from 'child_process';
7
+ import { existsSync } from 'fs';
8
+ import { join, extname } from 'path';
9
+ export class LSPManager {
10
+ servers = new Map();
11
+ workingDirectory;
12
+ diagnostics = new Map();
13
+ initialized = false;
14
+ constructor(workingDirectory) {
15
+ this.workingDirectory = workingDirectory;
16
+ }
17
+ /**
18
+ * Initialize LSP servers based on project tech stack
19
+ */
20
+ async initialize() {
21
+ if (this.initialized)
22
+ return;
23
+ const detectedServers = this.detectLanguageServers();
24
+ for (const config of detectedServers) {
25
+ try {
26
+ const server = new LSPServer(config, this.workingDirectory);
27
+ await server.start();
28
+ this.servers.set(config.language, server);
29
+ }
30
+ catch (error) {
31
+ // Silently skip servers that can't start
32
+ }
33
+ }
34
+ this.initialized = true;
35
+ }
36
+ /**
37
+ * Get diagnostics for a file
38
+ */
39
+ getDiagnostics(filePath) {
40
+ return this.diagnostics.get(filePath) || [];
41
+ }
42
+ /**
43
+ * Get all diagnostics across all files
44
+ */
45
+ getAllDiagnostics() {
46
+ const all = [];
47
+ for (const diags of this.diagnostics.values()) {
48
+ all.push(...diags);
49
+ }
50
+ return all;
51
+ }
52
+ /**
53
+ * Get diagnostics as context string for LLM
54
+ */
55
+ getDiagnosticsContext() {
56
+ const all = this.getAllDiagnostics();
57
+ if (all.length === 0)
58
+ return '';
59
+ const errors = all.filter(d => d.severity === 'error');
60
+ const warnings = all.filter(d => d.severity === 'warning');
61
+ const lines = [];
62
+ if (errors.length > 0) {
63
+ lines.push(`⚠️ LSP Errors (${errors.length}):`);
64
+ for (const e of errors.slice(0, 20)) {
65
+ lines.push(` ${e.file}:${e.line} - ${e.message}`);
66
+ }
67
+ }
68
+ if (warnings.length > 0) {
69
+ lines.push(`🟡 LSP Warnings (${warnings.length}):`);
70
+ for (const w of warnings.slice(0, 10)) {
71
+ lines.push(` ${w.file}:${w.line} - ${w.message}`);
72
+ }
73
+ }
74
+ return lines.join('\n');
75
+ }
76
+ /**
77
+ * Request diagnostics for a file after edit
78
+ */
79
+ async requestDiagnostics(filePath) {
80
+ const ext = extname(filePath);
81
+ const server = this.findServerForFile(ext);
82
+ if (!server)
83
+ return [];
84
+ try {
85
+ const diags = await server.getDiagnostics(filePath);
86
+ this.diagnostics.set(filePath, diags);
87
+ return diags;
88
+ }
89
+ catch {
90
+ return [];
91
+ }
92
+ }
93
+ /**
94
+ * Go to definition
95
+ */
96
+ async gotoDefinition(filePath, line, column) {
97
+ const server = this.findServerForFile(extname(filePath));
98
+ if (!server)
99
+ return null;
100
+ try {
101
+ return await server.gotoDefinition(filePath, line, column);
102
+ }
103
+ catch {
104
+ return null;
105
+ }
106
+ }
107
+ /**
108
+ * Find references
109
+ */
110
+ async findReferences(filePath, line, column) {
111
+ const server = this.findServerForFile(extname(filePath));
112
+ if (!server)
113
+ return [];
114
+ try {
115
+ return await server.findReferences(filePath, line, column);
116
+ }
117
+ catch {
118
+ return [];
119
+ }
120
+ }
121
+ /**
122
+ * Shutdown all LSP servers
123
+ */
124
+ shutdown() {
125
+ for (const server of this.servers.values()) {
126
+ server.shutdown();
127
+ }
128
+ this.servers.clear();
129
+ this.initialized = false;
130
+ }
131
+ // ---- Private ----
132
+ detectLanguageServers() {
133
+ const servers = [];
134
+ const cwd = this.workingDirectory;
135
+ // TypeScript
136
+ if (existsSync(join(cwd, 'tsconfig.json')) || existsSync(join(cwd, 'package.json'))) {
137
+ servers.push({
138
+ language: 'typescript',
139
+ command: 'typescript-language-server',
140
+ args: ['--stdio'],
141
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
142
+ });
143
+ }
144
+ // Python
145
+ if (existsSync(join(cwd, 'pyproject.toml')) || existsSync(join(cwd, 'setup.py'))) {
146
+ servers.push({
147
+ language: 'python',
148
+ command: 'pyright-langserver',
149
+ args: ['--stdio'],
150
+ extensions: ['.py', '.pyi'],
151
+ });
152
+ }
153
+ // Go
154
+ if (existsSync(join(cwd, 'go.mod'))) {
155
+ servers.push({
156
+ language: 'go',
157
+ command: 'gopls',
158
+ args: [],
159
+ extensions: ['.go'],
160
+ });
161
+ }
162
+ // Rust
163
+ if (existsSync(join(cwd, 'Cargo.toml'))) {
164
+ servers.push({
165
+ language: 'rust',
166
+ command: 'rust-analyzer',
167
+ args: [],
168
+ extensions: ['.rs'],
169
+ });
170
+ }
171
+ return servers;
172
+ }
173
+ findServerForFile(ext) {
174
+ for (const [_, server] of this.servers) {
175
+ if (server.config.extensions.includes(ext)) {
176
+ return server;
177
+ }
178
+ }
179
+ return undefined;
180
+ }
181
+ }
182
+ class LSPServer {
183
+ config;
184
+ process = null;
185
+ workingDirectory;
186
+ requestId = 0;
187
+ pendingRequests = new Map();
188
+ buffer = '';
189
+ constructor(config, workingDirectory) {
190
+ this.config = config;
191
+ this.workingDirectory = workingDirectory;
192
+ }
193
+ async start() {
194
+ this.process = spawn(this.config.command, this.config.args, {
195
+ cwd: this.workingDirectory,
196
+ stdio: ['pipe', 'pipe', 'pipe'],
197
+ });
198
+ if (!this.process.stdin || !this.process.stdout) {
199
+ throw new Error(`Failed to start LSP server: ${this.config.command}`);
200
+ }
201
+ this.process.stdout.on('data', (data) => {
202
+ this.handleData(data.toString());
203
+ });
204
+ // Initialize
205
+ await this.sendRequest('initialize', {
206
+ processId: process.pid,
207
+ rootUri: `file://${this.workingDirectory}`,
208
+ capabilities: {
209
+ textDocument: {
210
+ publishDiagnostics: { relatedInformation: true },
211
+ definition: { linkSupport: true },
212
+ references: {},
213
+ },
214
+ },
215
+ });
216
+ // Send initialized notification
217
+ this.sendNotification('initialized', {});
218
+ }
219
+ async getDiagnostics(filePath) {
220
+ // Read file content for proper diagnostics
221
+ let fileContent = '';
222
+ try {
223
+ const { readFileSync } = await import('fs');
224
+ fileContent = readFileSync(filePath.replace('file://', ''), 'utf-8');
225
+ }
226
+ catch { }
227
+ this.sendNotification('textDocument/didOpen', {
228
+ textDocument: {
229
+ uri: `file://${filePath}`,
230
+ languageId: this.config.language,
231
+ version: 1,
232
+ text: fileContent,
233
+ },
234
+ });
235
+ // Wait a bit for diagnostics
236
+ await new Promise(resolve => setTimeout(resolve, 1000));
237
+ return this.diagnosticsByFile.get(filePath) || [];
238
+ }
239
+ async gotoDefinition(filePath, line, column) {
240
+ const result = await this.sendRequest('textDocument/definition', {
241
+ textDocument: { uri: `file://${filePath}` },
242
+ position: { line: line - 1, character: column - 1 },
243
+ });
244
+ if (result) {
245
+ const loc = Array.isArray(result) ? result[0] : result;
246
+ if (loc?.targetUri || loc?.uri) {
247
+ const uri = loc.targetUri || loc.uri;
248
+ const range = loc.targetRange || loc.range;
249
+ return {
250
+ file: uri.replace('file://', ''),
251
+ line: (range?.start?.line || 0) + 1,
252
+ column: (range?.start?.character || 0) + 1,
253
+ name: '',
254
+ kind: 'definition',
255
+ };
256
+ }
257
+ }
258
+ return null;
259
+ }
260
+ async findReferences(filePath, line, column) {
261
+ const result = await this.sendRequest('textDocument/references', {
262
+ textDocument: { uri: `file://${filePath}` },
263
+ position: { line: line - 1, character: column - 1 },
264
+ context: { includeDeclaration: true },
265
+ });
266
+ if (Array.isArray(result)) {
267
+ return result.map((ref) => ({
268
+ file: (ref.uri || '').replace('file://', ''),
269
+ line: (ref.range?.start?.line || 0) + 1,
270
+ column: (ref.range?.start?.character || 0) + 1,
271
+ }));
272
+ }
273
+ return [];
274
+ }
275
+ diagnosticsByFile = new Map();
276
+ sendRequest(method, params) {
277
+ return new Promise((resolve, reject) => {
278
+ const id = ++this.requestId;
279
+ this.pendingRequests.set(id, { resolve, reject });
280
+ const message = JSON.stringify({
281
+ jsonrpc: '2.0',
282
+ id,
283
+ method,
284
+ params,
285
+ });
286
+ this.sendMessage(message);
287
+ });
288
+ }
289
+ sendNotification(method, params) {
290
+ const message = JSON.stringify({
291
+ jsonrpc: '2.0',
292
+ method,
293
+ params,
294
+ });
295
+ this.sendMessage(message);
296
+ }
297
+ sendMessage(message) {
298
+ if (!this.process?.stdin)
299
+ return;
300
+ const header = `Content-Length: ${Buffer.byteLength(message)}\r\n\r\n`;
301
+ this.process.stdin.write(header + message);
302
+ }
303
+ handleData(data) {
304
+ this.buffer += data;
305
+ while (true) {
306
+ const headerEnd = this.buffer.indexOf('\r\n\r\n');
307
+ if (headerEnd === -1)
308
+ break;
309
+ const header = this.buffer.slice(0, headerEnd);
310
+ const contentLengthMatch = header.match(/Content-Length:\s*(\d+)/i);
311
+ if (!contentLengthMatch)
312
+ break;
313
+ const contentLength = parseInt(contentLengthMatch[1], 10);
314
+ const bodyStart = headerEnd + 4;
315
+ const bodyEnd = bodyStart + contentLength;
316
+ if (this.buffer.length < bodyEnd)
317
+ break;
318
+ const body = this.buffer.slice(bodyStart, bodyEnd);
319
+ this.buffer = this.buffer.slice(bodyEnd);
320
+ try {
321
+ const message = JSON.parse(body);
322
+ if (message.id && this.pendingRequests.has(message.id)) {
323
+ const { resolve } = this.pendingRequests.get(message.id);
324
+ this.pendingRequests.delete(message.id);
325
+ resolve(message.result);
326
+ }
327
+ if (message.method === 'textDocument/publishDiagnostics') {
328
+ const uri = message.params?.uri || '';
329
+ const diags = (message.params?.diagnostics || []).map((d) => ({
330
+ file: uri.replace('file://', ''),
331
+ line: (d.range?.start?.line || 0) + 1,
332
+ column: (d.range?.start?.character || 0) + 1,
333
+ severity: ['hint', 'info', 'warning', 'error'][d.severity - 1] || 'info',
334
+ message: d.message || '',
335
+ source: d.source,
336
+ code: d.code?.toString(),
337
+ }));
338
+ this.diagnosticsByFile.set(uri.replace('file://', ''), diags);
339
+ }
340
+ }
341
+ catch { }
342
+ }
343
+ }
344
+ shutdown() {
345
+ if (this.process) {
346
+ this.process.kill();
347
+ this.process = null;
348
+ }
349
+ }
350
+ }
351
+ //# sourceMappingURL=lsp-manager.js.map
@@ -0,0 +1,133 @@
1
+ import { ToolDefinition } from '../core/types.js';
2
+ export interface MCPServerConfig {
3
+ name: string;
4
+ transport: 'stdio' | 'sse' | 'http';
5
+ command?: string;
6
+ args?: string[];
7
+ env?: Record<string, string>;
8
+ url?: string;
9
+ headers?: Record<string, string>;
10
+ timeout?: number;
11
+ disabled?: boolean;
12
+ /** Auto-reconnect on disconnect (default: true) */
13
+ autoReconnect?: boolean;
14
+ /** Max reconnect attempts (default: 3) */
15
+ maxReconnectAttempts?: number;
16
+ /** Health check interval in ms (default: 60000 = 1 min) */
17
+ healthCheckIntervalMs?: number;
18
+ }
19
+ export interface MCPConfig {
20
+ mcpServers: Record<string, MCPServerConfig>;
21
+ }
22
+ export interface MCPTool {
23
+ name: string;
24
+ description: string;
25
+ inputSchema: {
26
+ type: 'object';
27
+ properties: Record<string, unknown>;
28
+ required?: string[];
29
+ };
30
+ }
31
+ export interface MCPResource {
32
+ uri: string;
33
+ name: string;
34
+ description?: string;
35
+ mimeType?: string;
36
+ }
37
+ export interface MCPPrompt {
38
+ name: string;
39
+ description?: string;
40
+ arguments?: Array<{
41
+ name: string;
42
+ description?: string;
43
+ required?: boolean;
44
+ }>;
45
+ }
46
+ export interface MCPConnectionState {
47
+ name: string;
48
+ status: 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error';
49
+ lastConnected?: number;
50
+ lastError?: string;
51
+ reconnectAttempts: number;
52
+ toolCount: number;
53
+ resourceCount: number;
54
+ promptCount: number;
55
+ }
56
+ export declare class MCPClient {
57
+ private processes;
58
+ private nextId;
59
+ private pendingRequests;
60
+ private tools;
61
+ private resources;
62
+ private prompts;
63
+ private servers;
64
+ private inputBuffers;
65
+ private configPath;
66
+ private connectionStates;
67
+ private healthCheckTimers;
68
+ private reconnectTimers;
69
+ private eventSource;
70
+ private sseEventHandlers;
71
+ constructor(configPath?: string);
72
+ loadConfig(): MCPConfig;
73
+ saveConfig(config: MCPConfig, global?: boolean): void;
74
+ addServer(name: string, config: MCPServerConfig): void;
75
+ removeServer(name: string): boolean;
76
+ listServers(): Array<{
77
+ name: string;
78
+ config: MCPServerConfig;
79
+ connected: boolean;
80
+ toolCount: number;
81
+ resourceCount: number;
82
+ }>;
83
+ getConnectionStates(): MCPConnectionState[];
84
+ getConnectionState(name: string): MCPConnectionState | undefined;
85
+ private setConnectionState;
86
+ private startHealthCheck;
87
+ private stopHealthCheck;
88
+ private attemptReconnect;
89
+ connectAll(): Promise<number>;
90
+ connect(name: string, config: MCPServerConfig): Promise<void>;
91
+ private connectStdio;
92
+ private connectSSE;
93
+ private handleSSEEvent;
94
+ /**
95
+ * Register a custom SSE event handler
96
+ */
97
+ onSSEEvent(serverName: string, handler: (event: string, data: string) => void): void;
98
+ disconnect(name: string): Promise<void>;
99
+ disconnectAll(): Promise<void>;
100
+ private initialize;
101
+ callTool(serverName: string, toolName: string, args: Record<string, unknown>): Promise<unknown>;
102
+ private callToolHTTP;
103
+ readResource(serverName: string, uri: string): Promise<unknown>;
104
+ getPrompt(serverName: string, promptName: string, args?: Record<string, string>): Promise<unknown>;
105
+ private sendRequest;
106
+ private sendRequestSSE;
107
+ private sendNotification;
108
+ private handleResponse;
109
+ getAllTools(): Array<{
110
+ serverName: string;
111
+ tool: MCPTool;
112
+ }>;
113
+ getToolDefinitions(): ToolDefinition[];
114
+ getAllResources(): Array<{
115
+ serverName: string;
116
+ resource: MCPResource;
117
+ }>;
118
+ getAllPrompts(): Array<{
119
+ serverName: string;
120
+ prompt: MCPPrompt;
121
+ }>;
122
+ parseMCPToolName(fullName: string): {
123
+ serverName: string;
124
+ toolName: string;
125
+ } | null;
126
+ isConnected(name: string): boolean;
127
+ getServerNames(): string[];
128
+ /**
129
+ * Print a health report of all MCP connections
130
+ */
131
+ healthReport(): void;
132
+ }
133
+ //# sourceMappingURL=client.d.ts.map