@defai.digital/ax-cli 3.2.0 → 3.3.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.
- package/.ax-cli/memory.json +8 -1
- package/README.md +8 -2
- package/config/models.yaml +13 -0
- package/dist/agent/context-manager.d.ts +5 -5
- package/dist/agent/context-manager.js +19 -9
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/llm-agent.d.ts +0 -2
- package/dist/agent/llm-agent.js +7 -50
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/subagent.js +2 -1
- package/dist/agent/subagent.js.map +1 -1
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/frontend.d.ts +9 -0
- package/dist/commands/frontend.js +645 -0
- package/dist/commands/frontend.js.map +1 -0
- package/dist/commands/mcp.js +409 -3
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/models.js +2 -2
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/setup.js +15 -13
- package/dist/commands/setup.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/use-enhanced-input.js +16 -3
- package/dist/hooks/use-enhanced-input.js.map +1 -1
- package/dist/hooks/use-input-handler.js +7 -3
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/llm/client.d.ts +1 -0
- package/dist/llm/types.d.ts +49 -22
- package/dist/llm/types.js +12 -8
- package/dist/llm/types.js.map +1 -1
- package/dist/mcp/config.d.ts +1 -1
- package/dist/mcp/config.js +2 -2
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/health.d.ts +111 -0
- package/dist/mcp/health.js +244 -0
- package/dist/mcp/health.js.map +1 -0
- package/dist/mcp/templates.d.ts +52 -0
- package/dist/mcp/templates.js +624 -0
- package/dist/mcp/templates.js.map +1 -0
- package/dist/schemas/api-schemas.d.ts +2 -1
- package/dist/schemas/api-schemas.js +6 -4
- package/dist/schemas/api-schemas.js.map +1 -1
- package/dist/tools/bash.js +25 -10
- package/dist/tools/bash.js.map +1 -1
- package/dist/ui/components/api-key-input.js +2 -2
- package/dist/ui/components/api-key-input.js.map +1 -1
- package/dist/ui/components/chat-history.js +14 -7
- package/dist/ui/components/chat-history.js.map +1 -1
- package/dist/ui/components/chat-input.js +12 -7
- package/dist/ui/components/chat-input.js.map +1 -1
- package/dist/ui/components/chat-interface.js +64 -53
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/keyboard-hints.js +3 -2
- package/dist/ui/components/keyboard-hints.js.map +1 -1
- package/dist/ui/components/quick-actions.js +1 -0
- package/dist/ui/components/quick-actions.js.map +1 -1
- package/dist/ui/components/reasoning-display.js +14 -4
- package/dist/ui/components/reasoning-display.js.map +1 -1
- package/dist/ui/components/toast-notification.d.ts +29 -0
- package/dist/ui/components/toast-notification.js +15 -1
- package/dist/ui/components/toast-notification.js.map +1 -1
- package/dist/ui/components/welcome-panel.js +21 -2
- package/dist/ui/components/welcome-panel.js.map +1 -1
- package/dist/utils/config-loader.d.ts +1 -0
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/setup-validator.js +1 -0
- package/dist/utils/setup-validator.js.map +1 -1
- package/dist/utils/text-utils.d.ts +1 -0
- package/dist/utils/text-utils.js +12 -0
- package/dist/utils/text-utils.js.map +1 -1
- package/package.json +1 -2
- package/vitest.config.ts +1 -0
package/dist/llm/types.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export interface ChatOptions {
|
|
|
86
86
|
/**
|
|
87
87
|
* Model identifier
|
|
88
88
|
* @default "glm-4.6"
|
|
89
|
-
* @example "glm-4.6", "
|
|
89
|
+
* @example "glm-4.6", "glm-4-air"
|
|
90
90
|
*/
|
|
91
91
|
model?: string;
|
|
92
92
|
/**
|
|
@@ -254,6 +254,25 @@ export declare function hasReasoningContent(chunk: GLM46StreamChunk): chunk is G
|
|
|
254
254
|
};
|
|
255
255
|
}>;
|
|
256
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* Message content part for multimodal messages
|
|
259
|
+
*/
|
|
260
|
+
export type MessageContentPart = {
|
|
261
|
+
type: "text";
|
|
262
|
+
text: string;
|
|
263
|
+
} | {
|
|
264
|
+
type: "image_url";
|
|
265
|
+
image_url: {
|
|
266
|
+
url: string;
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Message with multimodal content support
|
|
271
|
+
*/
|
|
272
|
+
export interface MultimodalMessage {
|
|
273
|
+
role: "user" | "assistant" | "system";
|
|
274
|
+
content: string | MessageContentPart[];
|
|
275
|
+
}
|
|
257
276
|
/**
|
|
258
277
|
* GLM-4.6 model configurations
|
|
259
278
|
*
|
|
@@ -264,6 +283,7 @@ export declare const GLM_MODELS: {
|
|
|
264
283
|
readonly contextWindow: 200000;
|
|
265
284
|
readonly maxOutputTokens: 128000;
|
|
266
285
|
readonly supportsThinking: true;
|
|
286
|
+
readonly supportsVision: false;
|
|
267
287
|
readonly defaultTemperature: 0.7;
|
|
268
288
|
readonly temperatureRange: {
|
|
269
289
|
readonly min: 0.6;
|
|
@@ -271,21 +291,11 @@ export declare const GLM_MODELS: {
|
|
|
271
291
|
};
|
|
272
292
|
readonly tokenEfficiency: 1.3;
|
|
273
293
|
};
|
|
274
|
-
readonly "grok-code-fast-1": {
|
|
275
|
-
readonly contextWindow: 128000;
|
|
276
|
-
readonly maxOutputTokens: 4096;
|
|
277
|
-
readonly supportsThinking: false;
|
|
278
|
-
readonly defaultTemperature: 0.7;
|
|
279
|
-
readonly temperatureRange: {
|
|
280
|
-
readonly min: 0;
|
|
281
|
-
readonly max: 2;
|
|
282
|
-
};
|
|
283
|
-
readonly tokenEfficiency: 1;
|
|
284
|
-
};
|
|
285
294
|
readonly "glm-4-air": {
|
|
286
295
|
readonly contextWindow: 128000;
|
|
287
296
|
readonly maxOutputTokens: 8192;
|
|
288
297
|
readonly supportsThinking: false;
|
|
298
|
+
readonly supportsVision: false;
|
|
289
299
|
readonly defaultTemperature: 0.7;
|
|
290
300
|
readonly temperatureRange: {
|
|
291
301
|
readonly min: 0.6;
|
|
@@ -297,6 +307,7 @@ export declare const GLM_MODELS: {
|
|
|
297
307
|
readonly contextWindow: 8192;
|
|
298
308
|
readonly maxOutputTokens: 8192;
|
|
299
309
|
readonly supportsThinking: false;
|
|
310
|
+
readonly supportsVision: false;
|
|
300
311
|
readonly defaultTemperature: 0.7;
|
|
301
312
|
readonly temperatureRange: {
|
|
302
313
|
readonly min: 0.6;
|
|
@@ -304,6 +315,18 @@ export declare const GLM_MODELS: {
|
|
|
304
315
|
};
|
|
305
316
|
readonly tokenEfficiency: 1.1;
|
|
306
317
|
};
|
|
318
|
+
readonly "glm-4.5v": {
|
|
319
|
+
readonly contextWindow: 64000;
|
|
320
|
+
readonly maxOutputTokens: 16000;
|
|
321
|
+
readonly supportsThinking: true;
|
|
322
|
+
readonly supportsVision: true;
|
|
323
|
+
readonly defaultTemperature: 0.7;
|
|
324
|
+
readonly temperatureRange: {
|
|
325
|
+
readonly min: 0.6;
|
|
326
|
+
readonly max: 1;
|
|
327
|
+
};
|
|
328
|
+
readonly tokenEfficiency: 1.2;
|
|
329
|
+
};
|
|
307
330
|
};
|
|
308
331
|
export type SupportedModel = keyof typeof GLM_MODELS;
|
|
309
332
|
/**
|
|
@@ -313,26 +336,18 @@ export declare function getModelConfig(model: string): {
|
|
|
313
336
|
readonly contextWindow: 200000;
|
|
314
337
|
readonly maxOutputTokens: 128000;
|
|
315
338
|
readonly supportsThinking: true;
|
|
339
|
+
readonly supportsVision: false;
|
|
316
340
|
readonly defaultTemperature: 0.7;
|
|
317
341
|
readonly temperatureRange: {
|
|
318
342
|
readonly min: 0.6;
|
|
319
343
|
readonly max: 1;
|
|
320
344
|
};
|
|
321
345
|
readonly tokenEfficiency: 1.3;
|
|
322
|
-
} | {
|
|
323
|
-
readonly contextWindow: 128000;
|
|
324
|
-
readonly maxOutputTokens: 4096;
|
|
325
|
-
readonly supportsThinking: false;
|
|
326
|
-
readonly defaultTemperature: 0.7;
|
|
327
|
-
readonly temperatureRange: {
|
|
328
|
-
readonly min: 0;
|
|
329
|
-
readonly max: 2;
|
|
330
|
-
};
|
|
331
|
-
readonly tokenEfficiency: 1;
|
|
332
346
|
} | {
|
|
333
347
|
readonly contextWindow: 128000;
|
|
334
348
|
readonly maxOutputTokens: 8192;
|
|
335
349
|
readonly supportsThinking: false;
|
|
350
|
+
readonly supportsVision: false;
|
|
336
351
|
readonly defaultTemperature: 0.7;
|
|
337
352
|
readonly temperatureRange: {
|
|
338
353
|
readonly min: 0.6;
|
|
@@ -343,12 +358,24 @@ export declare function getModelConfig(model: string): {
|
|
|
343
358
|
readonly contextWindow: 8192;
|
|
344
359
|
readonly maxOutputTokens: 8192;
|
|
345
360
|
readonly supportsThinking: false;
|
|
361
|
+
readonly supportsVision: false;
|
|
346
362
|
readonly defaultTemperature: 0.7;
|
|
347
363
|
readonly temperatureRange: {
|
|
348
364
|
readonly min: 0.6;
|
|
349
365
|
readonly max: 1;
|
|
350
366
|
};
|
|
351
367
|
readonly tokenEfficiency: 1.1;
|
|
368
|
+
} | {
|
|
369
|
+
readonly contextWindow: 64000;
|
|
370
|
+
readonly maxOutputTokens: 16000;
|
|
371
|
+
readonly supportsThinking: true;
|
|
372
|
+
readonly supportsVision: true;
|
|
373
|
+
readonly defaultTemperature: 0.7;
|
|
374
|
+
readonly temperatureRange: {
|
|
375
|
+
readonly min: 0.6;
|
|
376
|
+
readonly max: 1;
|
|
377
|
+
};
|
|
378
|
+
readonly tokenEfficiency: 1.2;
|
|
352
379
|
};
|
|
353
380
|
/**
|
|
354
381
|
* Validate temperature for a given model
|
package/dist/llm/types.js
CHANGED
|
@@ -35,22 +35,16 @@ export const GLM_MODELS = {
|
|
|
35
35
|
contextWindow: 200000, // 200K tokens
|
|
36
36
|
maxOutputTokens: 128000, // 128K max output
|
|
37
37
|
supportsThinking: true,
|
|
38
|
+
supportsVision: false,
|
|
38
39
|
defaultTemperature: 0.7,
|
|
39
40
|
temperatureRange: { min: 0.6, max: 1.0 },
|
|
40
41
|
tokenEfficiency: 1.3, // 30% more efficient
|
|
41
42
|
},
|
|
42
|
-
"grok-code-fast-1": {
|
|
43
|
-
contextWindow: 128000, // 128K tokens
|
|
44
|
-
maxOutputTokens: 4096,
|
|
45
|
-
supportsThinking: false,
|
|
46
|
-
defaultTemperature: 0.7,
|
|
47
|
-
temperatureRange: { min: 0.0, max: 2.0 },
|
|
48
|
-
tokenEfficiency: 1.0,
|
|
49
|
-
},
|
|
50
43
|
"glm-4-air": {
|
|
51
44
|
contextWindow: 128000,
|
|
52
45
|
maxOutputTokens: 8192,
|
|
53
46
|
supportsThinking: false,
|
|
47
|
+
supportsVision: false,
|
|
54
48
|
defaultTemperature: 0.7,
|
|
55
49
|
temperatureRange: { min: 0.6, max: 1.0 },
|
|
56
50
|
tokenEfficiency: 1.15,
|
|
@@ -59,10 +53,20 @@ export const GLM_MODELS = {
|
|
|
59
53
|
contextWindow: 8192,
|
|
60
54
|
maxOutputTokens: 8192,
|
|
61
55
|
supportsThinking: false,
|
|
56
|
+
supportsVision: false,
|
|
62
57
|
defaultTemperature: 0.7,
|
|
63
58
|
temperatureRange: { min: 0.6, max: 1.0 },
|
|
64
59
|
tokenEfficiency: 1.1,
|
|
65
60
|
},
|
|
61
|
+
"glm-4.5v": {
|
|
62
|
+
contextWindow: 64000, // 64K multimodal context
|
|
63
|
+
maxOutputTokens: 16000, // 16K max output
|
|
64
|
+
supportsThinking: true,
|
|
65
|
+
supportsVision: true, // Vision capabilities
|
|
66
|
+
defaultTemperature: 0.7,
|
|
67
|
+
temperatureRange: { min: 0.6, max: 1.0 },
|
|
68
|
+
tokenEfficiency: 1.2,
|
|
69
|
+
},
|
|
66
70
|
};
|
|
67
71
|
/**
|
|
68
72
|
* Get model configuration by name
|
package/dist/llm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyPhD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC/C,OAAO,CACL,OAAO,QAAQ,KAAK,QAAQ;QAC5B,QAAQ,KAAK,IAAI;QACjB,SAAS,IAAI,QAAQ;QACrB,KAAK,CAAC,OAAO,CAAE,QAAgB,CAAC,OAAO,CAAC,CACzC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAuB;IAIvB,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QACxB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,KAAK,QAAQ;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CACpD,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyPhD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC/C,OAAO,CACL,OAAO,QAAQ,KAAK,QAAQ;QAC5B,QAAQ,KAAK,IAAI;QACjB,SAAS,IAAI,QAAQ;QACrB,KAAK,CAAC,OAAO,CAAE,QAAgB,CAAC,OAAO,CAAC,CACzC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAuB;IAIvB,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QACxB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAA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,CAAC;YAC1D,MAAM,IAAI,KAAK,CACb,4CAA4C,QAAQ,CAAC,IAAI,EAAE,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,oCAAoC;IACpC,IAAI,QAAQ,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QAChC,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAChC,mCAAmC;QACrC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,yEAAyE;gBACzE,8EAA8E,CAC/E,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAa;IACvD,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,uCAAuC;KAC9F,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe,GAAG;IACvD,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,IAAI;KACL,CAAC;AACJ,CAAC"}
|
package/dist/mcp/config.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export declare function saveMCPConfig(config: MCPConfig): void;
|
|
|
10
10
|
export declare function addMCPServer(config: MCPServerConfig): void;
|
|
11
11
|
export declare function removeMCPServer(serverName: string): void;
|
|
12
12
|
export declare function getMCPServer(serverName: string): MCPServerConfig | undefined;
|
|
13
|
-
export
|
|
13
|
+
export { TEMPLATES as PREDEFINED_SERVERS, getTemplate, hasTemplate, generateConfigFromTemplate } from './templates.js';
|
package/dist/mcp/config.js
CHANGED
|
@@ -61,6 +61,6 @@ export function getMCPServer(serverName) {
|
|
|
61
61
|
const projectSettings = manager.loadProjectSettings();
|
|
62
62
|
return projectSettings.mcpServers?.[serverName];
|
|
63
63
|
}
|
|
64
|
-
//
|
|
65
|
-
export
|
|
64
|
+
// Import templates
|
|
65
|
+
export { TEMPLATES as PREDEFINED_SERVERS, getTemplate, hasTemplate, generateConfigFromTemplate } from './templates.js';
|
|
66
66
|
//# sourceMappingURL=config.js.map
|
package/dist/mcp/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAM9E;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU;QAC3C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC;QAC3C,CAAC,CAAC,EAAE,CAAC;IAEP,8BAA8B;IAC9B,MAAM,gBAAgB,GAAsB,EAAE,CAAC;IAC/C,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAuB,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,kBAAkB,CAChB,aAAa,CAAC,UAAU,EACxB,qCAAsC,MAAc,EAAE,IAAI,IAAI,SAAS,GAAG,EAC1E,MAAM,CAAC,KAAK,IAAI,uBAAuB,CACxC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE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C,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC;QAChD,OAAO,CAAC,oBAAoB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC;IAE9C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;QAC9B,OAAO,CAAC,oBAAoB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACtD,OAAO,eAAe,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC;AAClD,CAAC;AAED,mBAAmB;AACnB,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Health Monitoring
|
|
3
|
+
*
|
|
4
|
+
* Provides health checking, status monitoring, and automatic reconnection
|
|
5
|
+
* for MCP servers.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import type { MCPManager } from './client.js';
|
|
9
|
+
/**
|
|
10
|
+
* Health status for an MCP server
|
|
11
|
+
*/
|
|
12
|
+
export interface ServerHealth {
|
|
13
|
+
/** Server name */
|
|
14
|
+
serverName: string;
|
|
15
|
+
/** Connection status */
|
|
16
|
+
connected: boolean;
|
|
17
|
+
/** Number of available tools */
|
|
18
|
+
toolCount: number;
|
|
19
|
+
/** Server uptime in milliseconds */
|
|
20
|
+
uptime?: number;
|
|
21
|
+
/** Connection start time */
|
|
22
|
+
connectedAt?: number;
|
|
23
|
+
/** Last successful call timestamp */
|
|
24
|
+
lastSuccess?: number;
|
|
25
|
+
/** Last error message */
|
|
26
|
+
lastError?: string;
|
|
27
|
+
/** Last error timestamp */
|
|
28
|
+
lastErrorAt?: number;
|
|
29
|
+
/** Total number of successful tool calls */
|
|
30
|
+
successCount: number;
|
|
31
|
+
/** Total number of failed tool calls */
|
|
32
|
+
failureCount: number;
|
|
33
|
+
/** Average latency in milliseconds */
|
|
34
|
+
avgLatency?: number;
|
|
35
|
+
/** P95 latency in milliseconds */
|
|
36
|
+
p95Latency?: number;
|
|
37
|
+
/** Success rate percentage (0-100) */
|
|
38
|
+
successRate: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Health check event types
|
|
42
|
+
*/
|
|
43
|
+
export interface HealthCheckEvents {
|
|
44
|
+
'health-check': (health: ServerHealth) => void;
|
|
45
|
+
'server-disconnected': (serverName: string) => void;
|
|
46
|
+
'server-reconnected': (serverName: string) => void;
|
|
47
|
+
'health-check-error': (serverName: string, error: Error) => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* MCP Health Monitor
|
|
51
|
+
*
|
|
52
|
+
* Monitors the health of MCP servers and provides automatic reconnection
|
|
53
|
+
*/
|
|
54
|
+
export declare class MCPHealthMonitor extends EventEmitter {
|
|
55
|
+
private mcpManager;
|
|
56
|
+
private healthCheckInterval;
|
|
57
|
+
private serverStats;
|
|
58
|
+
constructor(mcpManager: MCPManager);
|
|
59
|
+
/**
|
|
60
|
+
* Start health monitoring with specified interval
|
|
61
|
+
*/
|
|
62
|
+
start(intervalMs?: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Stop health monitoring
|
|
65
|
+
*/
|
|
66
|
+
stop(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Perform health checks on all servers
|
|
69
|
+
*/
|
|
70
|
+
private performHealthChecks;
|
|
71
|
+
/**
|
|
72
|
+
* Check health of a specific server
|
|
73
|
+
*/
|
|
74
|
+
checkServerHealth(serverName: string): Promise<ServerHealth>;
|
|
75
|
+
/**
|
|
76
|
+
* Record a successful tool call
|
|
77
|
+
*/
|
|
78
|
+
recordSuccess(serverName: string, latencyMs: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Record a failed tool call
|
|
81
|
+
*/
|
|
82
|
+
recordFailure(serverName: string, error: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Attempt to reconnect to a disconnected server
|
|
85
|
+
*/
|
|
86
|
+
private attemptReconnection;
|
|
87
|
+
/**
|
|
88
|
+
* Calculate percentile from array of values
|
|
89
|
+
*/
|
|
90
|
+
private calculatePercentile;
|
|
91
|
+
/**
|
|
92
|
+
* Get health report for all servers
|
|
93
|
+
*/
|
|
94
|
+
getHealthReport(): Promise<ServerHealth[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Get health status for a specific server
|
|
97
|
+
*/
|
|
98
|
+
getServerStatus(serverName: string): Promise<ServerHealth | null>;
|
|
99
|
+
/**
|
|
100
|
+
* Reset stats for a server
|
|
101
|
+
*/
|
|
102
|
+
resetStats(serverName: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Get formatted uptime string
|
|
105
|
+
*/
|
|
106
|
+
static formatUptime(uptimeMs: number): string;
|
|
107
|
+
/**
|
|
108
|
+
* Get formatted latency string
|
|
109
|
+
*/
|
|
110
|
+
static formatLatency(latencyMs: number): string;
|
|
111
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Health Monitoring
|
|
3
|
+
*
|
|
4
|
+
* Provides health checking, status monitoring, and automatic reconnection
|
|
5
|
+
* for MCP servers.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
/**
|
|
9
|
+
* MCP Health Monitor
|
|
10
|
+
*
|
|
11
|
+
* Monitors the health of MCP servers and provides automatic reconnection
|
|
12
|
+
*/
|
|
13
|
+
export class MCPHealthMonitor extends EventEmitter {
|
|
14
|
+
mcpManager;
|
|
15
|
+
healthCheckInterval = null;
|
|
16
|
+
serverStats = new Map();
|
|
17
|
+
constructor(mcpManager) {
|
|
18
|
+
super();
|
|
19
|
+
this.mcpManager = mcpManager;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Start health monitoring with specified interval
|
|
23
|
+
*/
|
|
24
|
+
start(intervalMs = 60000) {
|
|
25
|
+
if (this.healthCheckInterval) {
|
|
26
|
+
throw new Error('Health monitoring already started');
|
|
27
|
+
}
|
|
28
|
+
// Initialize stats for existing servers
|
|
29
|
+
const servers = this.mcpManager.getServers();
|
|
30
|
+
for (const serverName of servers) {
|
|
31
|
+
if (!this.serverStats.has(serverName)) {
|
|
32
|
+
this.serverStats.set(serverName, {
|
|
33
|
+
connectedAt: Date.now(),
|
|
34
|
+
successCount: 0,
|
|
35
|
+
failureCount: 0,
|
|
36
|
+
latencies: [],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.healthCheckInterval = setInterval(async () => {
|
|
41
|
+
await this.performHealthChecks();
|
|
42
|
+
}, intervalMs);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Stop health monitoring
|
|
46
|
+
*/
|
|
47
|
+
stop() {
|
|
48
|
+
if (this.healthCheckInterval) {
|
|
49
|
+
clearInterval(this.healthCheckInterval);
|
|
50
|
+
this.healthCheckInterval = null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Perform health checks on all servers
|
|
55
|
+
*/
|
|
56
|
+
async performHealthChecks() {
|
|
57
|
+
const servers = this.mcpManager.getServers();
|
|
58
|
+
for (const serverName of servers) {
|
|
59
|
+
try {
|
|
60
|
+
const health = await this.checkServerHealth(serverName);
|
|
61
|
+
this.emit('health-check', health);
|
|
62
|
+
// Check if server is unhealthy
|
|
63
|
+
if (!health.connected && health.successRate < 50) {
|
|
64
|
+
this.emit('server-disconnected', serverName);
|
|
65
|
+
await this.attemptReconnection(serverName);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
this.emit('health-check-error', serverName, error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check health of a specific server
|
|
75
|
+
*/
|
|
76
|
+
async checkServerHealth(serverName) {
|
|
77
|
+
const tools = this.mcpManager.getTools().filter((t) => t.serverName === serverName);
|
|
78
|
+
// Initialize stats if not present
|
|
79
|
+
if (!this.serverStats.has(serverName)) {
|
|
80
|
+
this.serverStats.set(serverName, {
|
|
81
|
+
connectedAt: Date.now(),
|
|
82
|
+
successCount: 0,
|
|
83
|
+
failureCount: 0,
|
|
84
|
+
latencies: [],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const stats = this.serverStats.get(serverName);
|
|
88
|
+
// Calculate success rate
|
|
89
|
+
const total = stats.successCount + stats.failureCount;
|
|
90
|
+
const successRate = total > 0 ? (stats.successCount / total) * 100 : 100;
|
|
91
|
+
// Calculate latencies
|
|
92
|
+
const avgLatency = stats.latencies.length > 0
|
|
93
|
+
? stats.latencies.reduce((a, b) => a + b, 0) / stats.latencies.length
|
|
94
|
+
: undefined;
|
|
95
|
+
const p95Latency = stats.latencies.length > 0
|
|
96
|
+
? this.calculatePercentile(stats.latencies, 0.95)
|
|
97
|
+
: undefined;
|
|
98
|
+
// Calculate uptime
|
|
99
|
+
const uptime = Date.now() - stats.connectedAt;
|
|
100
|
+
return {
|
|
101
|
+
serverName,
|
|
102
|
+
connected: tools.length > 0,
|
|
103
|
+
toolCount: tools.length,
|
|
104
|
+
uptime,
|
|
105
|
+
connectedAt: stats.connectedAt,
|
|
106
|
+
lastSuccess: stats.lastSuccess,
|
|
107
|
+
lastError: stats.lastError,
|
|
108
|
+
lastErrorAt: stats.lastErrorAt,
|
|
109
|
+
successCount: stats.successCount,
|
|
110
|
+
failureCount: stats.failureCount,
|
|
111
|
+
avgLatency,
|
|
112
|
+
p95Latency,
|
|
113
|
+
successRate,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Record a successful tool call
|
|
118
|
+
*/
|
|
119
|
+
recordSuccess(serverName, latencyMs) {
|
|
120
|
+
// Initialize stats if not present
|
|
121
|
+
if (!this.serverStats.has(serverName)) {
|
|
122
|
+
this.serverStats.set(serverName, {
|
|
123
|
+
connectedAt: Date.now(),
|
|
124
|
+
successCount: 0,
|
|
125
|
+
failureCount: 0,
|
|
126
|
+
latencies: [],
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const stats = this.serverStats.get(serverName);
|
|
130
|
+
stats.successCount++;
|
|
131
|
+
stats.lastSuccess = Date.now();
|
|
132
|
+
stats.latencies.push(latencyMs);
|
|
133
|
+
// Keep only last 100 latencies
|
|
134
|
+
if (stats.latencies.length > 100) {
|
|
135
|
+
stats.latencies.shift();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Record a failed tool call
|
|
140
|
+
*/
|
|
141
|
+
recordFailure(serverName, error) {
|
|
142
|
+
// Initialize stats if not present
|
|
143
|
+
if (!this.serverStats.has(serverName)) {
|
|
144
|
+
this.serverStats.set(serverName, {
|
|
145
|
+
connectedAt: Date.now(),
|
|
146
|
+
successCount: 0,
|
|
147
|
+
failureCount: 0,
|
|
148
|
+
latencies: [],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const stats = this.serverStats.get(serverName);
|
|
152
|
+
stats.failureCount++;
|
|
153
|
+
stats.lastError = error;
|
|
154
|
+
stats.lastErrorAt = Date.now();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Attempt to reconnect to a disconnected server
|
|
158
|
+
*/
|
|
159
|
+
async attemptReconnection(serverName) {
|
|
160
|
+
try {
|
|
161
|
+
// Get server configuration (if available)
|
|
162
|
+
// Note: This would require extending MCPManager to expose config
|
|
163
|
+
// For now, we just emit an event
|
|
164
|
+
this.emit('server-reconnected', serverName);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
this.emit('health-check-error', serverName, error);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Calculate percentile from array of values
|
|
172
|
+
*/
|
|
173
|
+
calculatePercentile(values, percentile) {
|
|
174
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
175
|
+
const index = Math.ceil(sorted.length * percentile) - 1;
|
|
176
|
+
return sorted[index] || 0;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get health report for all servers
|
|
180
|
+
*/
|
|
181
|
+
async getHealthReport() {
|
|
182
|
+
const servers = this.mcpManager.getServers();
|
|
183
|
+
const report = [];
|
|
184
|
+
for (const serverName of servers) {
|
|
185
|
+
const health = await this.checkServerHealth(serverName);
|
|
186
|
+
report.push(health);
|
|
187
|
+
}
|
|
188
|
+
return report;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Get health status for a specific server
|
|
192
|
+
*/
|
|
193
|
+
async getServerStatus(serverName) {
|
|
194
|
+
const servers = this.mcpManager.getServers();
|
|
195
|
+
if (!servers.includes(serverName)) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return await this.checkServerHealth(serverName);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Reset stats for a server
|
|
202
|
+
*/
|
|
203
|
+
resetStats(serverName) {
|
|
204
|
+
this.serverStats.set(serverName, {
|
|
205
|
+
connectedAt: Date.now(),
|
|
206
|
+
successCount: 0,
|
|
207
|
+
failureCount: 0,
|
|
208
|
+
latencies: [],
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get formatted uptime string
|
|
213
|
+
*/
|
|
214
|
+
static formatUptime(uptimeMs) {
|
|
215
|
+
const seconds = Math.floor(uptimeMs / 1000);
|
|
216
|
+
const minutes = Math.floor(seconds / 60);
|
|
217
|
+
const hours = Math.floor(minutes / 60);
|
|
218
|
+
const days = Math.floor(hours / 24);
|
|
219
|
+
if (days > 0) {
|
|
220
|
+
return `${days}d ${hours % 24}h`;
|
|
221
|
+
}
|
|
222
|
+
else if (hours > 0) {
|
|
223
|
+
return `${hours}h ${minutes % 60}m`;
|
|
224
|
+
}
|
|
225
|
+
else if (minutes > 0) {
|
|
226
|
+
return `${minutes}m ${seconds % 60}s`;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return `${seconds}s`;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get formatted latency string
|
|
234
|
+
*/
|
|
235
|
+
static formatLatency(latencyMs) {
|
|
236
|
+
if (latencyMs < 1000) {
|
|
237
|
+
return `${Math.round(latencyMs)}ms`;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return `${(latencyMs / 1000).toFixed(2)}s`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/mcp/health.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AA6CtC;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACxC,UAAU,CAAa;IACvB,mBAAmB,GAA0B,IAAI,CAAC;IAClD,WAAW,GAQd,IAAI,GAAG,EAAE,CAAC;IAEf,YAAY,UAAsB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAqB,KAAK;QAC9B,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,MAAM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AAC,QAAgB;QAClC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QAEpC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,KAAK,KAAK,GAAG,EAAE,GAAG,CAAC;QACnC,CAAC;aAAM,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,GAAG,KAAK,KAAK,OAAO,GAAG,EAAE,GAAG,CAAC;QACtC,CAAC;aAAM,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,GAAG,OAAO,KAAK,OAAO,GAAG,EAAE,GAAG,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,OAAO,GAAG,CAAC;QACvB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAiB;QACpC,IAAI,SAAS,GAAG,IAAI,EAAE,CAAC;YACrB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QAC7C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-configured MCP server templates for popular services
|
|
3
|
+
* Enables one-command setup: ax-cli mcp add <name> --template
|
|
4
|
+
*/
|
|
5
|
+
import { MCPServerConfig } from '../schemas/settings-schemas.js';
|
|
6
|
+
export interface MCPServerTemplate {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
category: 'design' | 'deployment' | 'testing' | 'monitoring' | 'backend' | 'version-control';
|
|
10
|
+
officialServer: boolean;
|
|
11
|
+
config: MCPServerConfig;
|
|
12
|
+
requiredEnv: Array<{
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
}>;
|
|
17
|
+
setupInstructions: string;
|
|
18
|
+
usageExamples: string[];
|
|
19
|
+
troubleshooting: Array<{
|
|
20
|
+
issue: string;
|
|
21
|
+
solution: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Pre-configured templates for popular MCP servers
|
|
26
|
+
* Focus on front-end development tools
|
|
27
|
+
*/
|
|
28
|
+
export declare const TEMPLATES: Record<string, MCPServerTemplate>;
|
|
29
|
+
/**
|
|
30
|
+
* Get all available template names
|
|
31
|
+
*/
|
|
32
|
+
export declare function getTemplateNames(): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Get template by name
|
|
35
|
+
*/
|
|
36
|
+
export declare function getTemplate(name: string): MCPServerTemplate | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Get templates by category
|
|
39
|
+
*/
|
|
40
|
+
export declare function getTemplatesByCategory(category: MCPServerTemplate['category']): MCPServerTemplate[];
|
|
41
|
+
/**
|
|
42
|
+
* Search templates by keyword
|
|
43
|
+
*/
|
|
44
|
+
export declare function searchTemplates(query: string): MCPServerTemplate[];
|
|
45
|
+
/**
|
|
46
|
+
* Check if a template exists
|
|
47
|
+
*/
|
|
48
|
+
export declare function hasTemplate(name: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Generate MCP config from template with environment variables
|
|
51
|
+
*/
|
|
52
|
+
export declare function generateConfigFromTemplate(templateName: string, envVars: Record<string, string>): MCPServerConfig;
|