@chen-rmag/core-infra 1.0.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/README.md +46 -0
- package/dist/ProjectContextManager.d.ts +30 -0
- package/dist/ProjectContextManager.js +41 -0
- package/dist/directory-validator.d.ts +28 -0
- package/dist/directory-validator.js +90 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +44 -0
- package/dist/mcp/file-mcp-manager.d.ts +13 -0
- package/dist/mcp/file-mcp-manager.js +45 -0
- package/dist/mcp/index.d.ts +20 -0
- package/dist/mcp/index.js +16 -0
- package/dist/mcp/mcp-client.d.ts +127 -0
- package/dist/mcp/mcp-client.js +165 -0
- package/dist/mcp/mcp-manager.d.ts +20 -0
- package/dist/mcp/mcp-manager.js +98 -0
- package/dist/mcp/playwright-mcp-manager.d.ts +18 -0
- package/dist/mcp/playwright-mcp-manager.js +115 -0
- package/dist/model.d.ts +10 -0
- package/dist/model.js +207 -0
- package/dist/repositories/BaseRepository.d.ts +68 -0
- package/dist/repositories/BaseRepository.js +212 -0
- package/dist/repositories/DirectoryRepository.d.ts +69 -0
- package/dist/repositories/DirectoryRepository.js +335 -0
- package/dist/repositories/ExplorationRepository.d.ts +33 -0
- package/dist/repositories/ExplorationRepository.js +53 -0
- package/dist/repositories/FileRepository.d.ts +55 -0
- package/dist/repositories/FileRepository.js +131 -0
- package/dist/repositories/ModelConfigRepository.d.ts +33 -0
- package/dist/repositories/ModelConfigRepository.js +51 -0
- package/dist/repositories/ProjectRepository.d.ts +31 -0
- package/dist/repositories/ProjectRepository.js +66 -0
- package/dist/repositories/SettingsRepository.d.ts +18 -0
- package/dist/repositories/SettingsRepository.js +71 -0
- package/dist/repositories/TableDataRepository.d.ts +21 -0
- package/dist/repositories/TableDataRepository.js +32 -0
- package/dist/repositories/TestCaseRepository.d.ts +120 -0
- package/dist/repositories/TestCaseRepository.js +463 -0
- package/dist/repositories/TestPlanRepository.d.ts +34 -0
- package/dist/repositories/TestPlanRepository.js +79 -0
- package/dist/repositories/TestResultRepository.d.ts +29 -0
- package/dist/repositories/TestResultRepository.js +53 -0
- package/dist/repositories/index.d.ts +16 -0
- package/dist/repositories/index.js +30 -0
- package/dist/storageService.d.ts +129 -0
- package/dist/storageService.js +297 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +2 -0
- package/package.json +32 -0
- package/src/directory-validator.ts +98 -0
- package/src/index.ts +26 -0
- package/src/mcp/file-mcp-manager.ts +50 -0
- package/src/mcp/index.ts +35 -0
- package/src/mcp/mcp-client.ts +209 -0
- package/src/mcp/mcp-manager.ts +118 -0
- package/src/mcp/playwright-mcp-manager.ts +127 -0
- package/src/model.ts +234 -0
- package/src/repositories/BaseRepository.ts +193 -0
- package/src/repositories/DirectoryRepository.ts +393 -0
- package/src/repositories/ExplorationRepository.ts +57 -0
- package/src/repositories/FileRepository.ts +153 -0
- package/src/repositories/ModelConfigRepository.ts +55 -0
- package/src/repositories/ProjectRepository.ts +70 -0
- package/src/repositories/SettingsRepository.ts +38 -0
- package/src/repositories/TableDataRepository.ts +33 -0
- package/src/repositories/TestCaseRepository.ts +521 -0
- package/src/repositories/TestPlanRepository.ts +89 -0
- package/src/repositories/TestResultRepository.ts +56 -0
- package/src/repositories/index.ts +17 -0
- package/src/storageService.ts +404 -0
- package/src/types.ts +246 -0
- package/tsconfig.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @ai-test/core-infra
|
|
2
|
+
|
|
3
|
+
Core infrastructure package for AI testing framework.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **MCP (Model Context Protocol)**: Client and manager implementations
|
|
8
|
+
- **Repositories**: Data access layer with base repository pattern
|
|
9
|
+
- **Model Factory**: Language model creation and tool binding
|
|
10
|
+
- **Storage Service**: Unified storage operations facade
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @ai-test/core-infra
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { MCPManager, StorageService, createModel } from '@ai-test/core-infra';
|
|
22
|
+
|
|
23
|
+
// Use MCP manager
|
|
24
|
+
const mcpManager = new MCPManager();
|
|
25
|
+
await mcpManager.start('en-US');
|
|
26
|
+
|
|
27
|
+
// Use storage service
|
|
28
|
+
const storage = StorageService.getInstance();
|
|
29
|
+
|
|
30
|
+
// Create model
|
|
31
|
+
const model = createModel(config, true, mcpManager);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Development
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Build
|
|
38
|
+
npm run build
|
|
39
|
+
|
|
40
|
+
# Watch mode
|
|
41
|
+
npm run build:watch
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Context Manager
|
|
3
|
+
* Manages the current active project context for the entire application
|
|
4
|
+
* All data operations use this context to determine project scope
|
|
5
|
+
*/
|
|
6
|
+
export interface AgentCheckCallback {
|
|
7
|
+
hasRunningAgents: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
declare class ProjectContextManager {
|
|
10
|
+
private currentProjectId;
|
|
11
|
+
private agentCheckCallback?;
|
|
12
|
+
/**
|
|
13
|
+
* Set a callback to check if there are running agents
|
|
14
|
+
* This should be called by the host application
|
|
15
|
+
*/
|
|
16
|
+
setAgentCheckCallback(callback: AgentCheckCallback): void;
|
|
17
|
+
/**
|
|
18
|
+
* Set the current project ID
|
|
19
|
+
*/
|
|
20
|
+
setProjectId(projectId: string | null): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get the current project ID
|
|
23
|
+
*/
|
|
24
|
+
getProjectId(): string;
|
|
25
|
+
}
|
|
26
|
+
declare global {
|
|
27
|
+
var projectContextManagerInstance: ProjectContextManager | undefined;
|
|
28
|
+
}
|
|
29
|
+
export declare const projectContextManager: ProjectContextManager;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Project Context Manager
|
|
4
|
+
* Manages the current active project context for the entire application
|
|
5
|
+
* All data operations use this context to determine project scope
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.projectContextManager = void 0;
|
|
9
|
+
class ProjectContextManager {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.currentProjectId = null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Set a callback to check if there are running agents
|
|
15
|
+
* This should be called by the host application
|
|
16
|
+
*/
|
|
17
|
+
setAgentCheckCallback(callback) {
|
|
18
|
+
this.agentCheckCallback = callback;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set the current project ID
|
|
22
|
+
*/
|
|
23
|
+
setProjectId(projectId) {
|
|
24
|
+
if (this.currentProjectId !== projectId) {
|
|
25
|
+
// Check if there are running agents before switching projects
|
|
26
|
+
if (this.agentCheckCallback?.hasRunningAgents()) {
|
|
27
|
+
throw new Error(`Cannot change project while Test generation is running.`);
|
|
28
|
+
}
|
|
29
|
+
this.currentProjectId = projectId;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the current project ID
|
|
34
|
+
*/
|
|
35
|
+
getProjectId() {
|
|
36
|
+
return this.currentProjectId || 'default';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Singleton instance
|
|
40
|
+
exports.projectContextManager = global.projectContextManagerInstance ?? new ProjectContextManager();
|
|
41
|
+
global.projectContextManagerInstance = exports.projectContextManager;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory name validation utility
|
|
3
|
+
* Validates directory names against file system restrictions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Validate a directory name
|
|
7
|
+
* @param name - Directory name to validate
|
|
8
|
+
* @returns { valid: boolean; error?: string }
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateDirectoryName(name: string): {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Validate a directory path (multiple levels)
|
|
16
|
+
* @param path - Directory path like 'folder1/folder2/folder3'
|
|
17
|
+
* @returns { valid: boolean; error?: string }
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateDirectoryPath(path: string): {
|
|
20
|
+
valid: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Normalize directory name (basic cleanup)
|
|
25
|
+
* @param name - Raw directory name
|
|
26
|
+
* @returns Normalized name
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeDirectoryName(name: string): string;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Directory name validation utility
|
|
4
|
+
* Validates directory names against file system restrictions
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.validateDirectoryName = validateDirectoryName;
|
|
8
|
+
exports.validateDirectoryPath = validateDirectoryPath;
|
|
9
|
+
exports.normalizeDirectoryName = normalizeDirectoryName;
|
|
10
|
+
/**
|
|
11
|
+
* Windows and Linux forbidden characters in file/directory names
|
|
12
|
+
* Windows: < > : " | ? * and control characters
|
|
13
|
+
* Linux: only / and null character, but we also exclude other common problematic chars
|
|
14
|
+
* We use a stricter set to ensure cross-platform compatibility
|
|
15
|
+
*/
|
|
16
|
+
const FORBIDDEN_CHARS = /[<>:"|?*\\\/\x00]/;
|
|
17
|
+
const RESERVED_NAMES = [
|
|
18
|
+
'CON', 'PRN', 'AUX', 'NUL', // Standard Windows reserved names
|
|
19
|
+
'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9',
|
|
20
|
+
'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9',
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Validate a directory name
|
|
24
|
+
* @param name - Directory name to validate
|
|
25
|
+
* @returns { valid: boolean; error?: string }
|
|
26
|
+
*/
|
|
27
|
+
function validateDirectoryName(name) {
|
|
28
|
+
if (!name || name.trim().length === 0) {
|
|
29
|
+
return { valid: false, error: 'Directory name cannot be empty' };
|
|
30
|
+
}
|
|
31
|
+
// Check length
|
|
32
|
+
if (name.length > 255) {
|
|
33
|
+
return { valid: false, error: 'Directory name cannot exceed 255 characters' };
|
|
34
|
+
}
|
|
35
|
+
// Check for forbidden characters
|
|
36
|
+
if (FORBIDDEN_CHARS.test(name)) {
|
|
37
|
+
return {
|
|
38
|
+
valid: false,
|
|
39
|
+
error: 'Directory name cannot contain the following characters: < > : " | ? * \\ / and control characters',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Check for leading/trailing spaces (problematic on Windows)
|
|
43
|
+
if (name !== name.trim() || name.startsWith('.') || name.endsWith('.')) {
|
|
44
|
+
return {
|
|
45
|
+
valid: false,
|
|
46
|
+
error: 'Directory name cannot start or end with spaces or dots',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Check for reserved names (Windows)
|
|
50
|
+
const upperName = name.toUpperCase();
|
|
51
|
+
if (RESERVED_NAMES.includes(upperName)) {
|
|
52
|
+
return {
|
|
53
|
+
valid: false,
|
|
54
|
+
error: `"${name}" is a system reserved name and cannot be used as a directory name`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return { valid: true };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Validate a directory path (multiple levels)
|
|
61
|
+
* @param path - Directory path like 'folder1/folder2/folder3'
|
|
62
|
+
* @returns { valid: boolean; error?: string }
|
|
63
|
+
*/
|
|
64
|
+
function validateDirectoryPath(path) {
|
|
65
|
+
if (!path) {
|
|
66
|
+
// Empty path is valid (root level)
|
|
67
|
+
return { valid: true };
|
|
68
|
+
}
|
|
69
|
+
const parts = path.split('/').filter(p => p.length > 0);
|
|
70
|
+
// Check max 3 levels
|
|
71
|
+
if (parts.length > 3) {
|
|
72
|
+
return { valid: false, error: 'Directory depth cannot exceed 3 levels' };
|
|
73
|
+
}
|
|
74
|
+
// Validate each part
|
|
75
|
+
for (const part of parts) {
|
|
76
|
+
const validation = validateDirectoryName(part);
|
|
77
|
+
if (!validation.valid) {
|
|
78
|
+
return validation;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { valid: true };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Normalize directory name (basic cleanup)
|
|
85
|
+
* @param name - Raw directory name
|
|
86
|
+
* @returns Normalized name
|
|
87
|
+
*/
|
|
88
|
+
function normalizeDirectoryName(name) {
|
|
89
|
+
return name.trim().replace(/\s+/g, ' ');
|
|
90
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export type { MCPTool, MCPConfig } from './mcp/mcp-client';
|
|
4
|
+
export { MCPClient } from './mcp/mcp-client';
|
|
5
|
+
export type { ToolGroup } from './mcp/index';
|
|
6
|
+
export { AbstractGroupedMCPManager, type GroupedMCPManager } from './mcp/index';
|
|
7
|
+
export { MCPManager } from './mcp/mcp-manager';
|
|
8
|
+
export type { PlaywrightMCPOpts } from './mcp/playwright-mcp-manager';
|
|
9
|
+
export { PlaywrightMCPManager } from './mcp/playwright-mcp-manager';
|
|
10
|
+
export { FileMCPManager } from './mcp/file-mcp-manager';
|
|
11
|
+
export * from './repositories';
|
|
12
|
+
export { createModel, convertToZodSchema } from './model';
|
|
13
|
+
export { StorageService } from './storageService';
|
|
14
|
+
export { validateDirectoryName, validateDirectoryPath, normalizeDirectoryName } from './directory-validator';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.normalizeDirectoryName = exports.validateDirectoryPath = exports.validateDirectoryName = exports.StorageService = exports.convertToZodSchema = exports.createModel = exports.FileMCPManager = exports.PlaywrightMCPManager = exports.MCPManager = exports.AbstractGroupedMCPManager = exports.MCPClient = void 0;
|
|
18
|
+
require("server-only");
|
|
19
|
+
// Types
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
var mcp_client_1 = require("./mcp/mcp-client");
|
|
22
|
+
Object.defineProperty(exports, "MCPClient", { enumerable: true, get: function () { return mcp_client_1.MCPClient; } });
|
|
23
|
+
var index_1 = require("./mcp/index");
|
|
24
|
+
Object.defineProperty(exports, "AbstractGroupedMCPManager", { enumerable: true, get: function () { return index_1.AbstractGroupedMCPManager; } });
|
|
25
|
+
var mcp_manager_1 = require("./mcp/mcp-manager");
|
|
26
|
+
Object.defineProperty(exports, "MCPManager", { enumerable: true, get: function () { return mcp_manager_1.MCPManager; } });
|
|
27
|
+
var playwright_mcp_manager_1 = require("./mcp/playwright-mcp-manager");
|
|
28
|
+
Object.defineProperty(exports, "PlaywrightMCPManager", { enumerable: true, get: function () { return playwright_mcp_manager_1.PlaywrightMCPManager; } });
|
|
29
|
+
var file_mcp_manager_1 = require("./mcp/file-mcp-manager");
|
|
30
|
+
Object.defineProperty(exports, "FileMCPManager", { enumerable: true, get: function () { return file_mcp_manager_1.FileMCPManager; } });
|
|
31
|
+
// Repositories
|
|
32
|
+
__exportStar(require("./repositories"), exports);
|
|
33
|
+
// Model
|
|
34
|
+
var model_1 = require("./model");
|
|
35
|
+
Object.defineProperty(exports, "createModel", { enumerable: true, get: function () { return model_1.createModel; } });
|
|
36
|
+
Object.defineProperty(exports, "convertToZodSchema", { enumerable: true, get: function () { return model_1.convertToZodSchema; } });
|
|
37
|
+
// Storage Service
|
|
38
|
+
var storageService_1 = require("./storageService");
|
|
39
|
+
Object.defineProperty(exports, "StorageService", { enumerable: true, get: function () { return storageService_1.StorageService; } });
|
|
40
|
+
// Directory Validator
|
|
41
|
+
var directory_validator_1 = require("./directory-validator");
|
|
42
|
+
Object.defineProperty(exports, "validateDirectoryName", { enumerable: true, get: function () { return directory_validator_1.validateDirectoryName; } });
|
|
43
|
+
Object.defineProperty(exports, "validateDirectoryPath", { enumerable: true, get: function () { return directory_validator_1.validateDirectoryPath; } });
|
|
44
|
+
Object.defineProperty(exports, "normalizeDirectoryName", { enumerable: true, get: function () { return directory_validator_1.normalizeDirectoryName; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) Client for Playwright integration
|
|
3
|
+
* Integrates with https://github.com/microsoft/playwright-mcp
|
|
4
|
+
*/
|
|
5
|
+
import { MCPClient } from './mcp-client';
|
|
6
|
+
import { AbstractGroupedMCPManager } from '.';
|
|
7
|
+
export declare class FileMCPManager extends AbstractGroupedMCPManager {
|
|
8
|
+
private client?;
|
|
9
|
+
constructor();
|
|
10
|
+
start(forced?: boolean): Promise<void>;
|
|
11
|
+
getClient(): MCPClient;
|
|
12
|
+
private createClient;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP (Model Context Protocol) Client for Playwright integration
|
|
4
|
+
* Integrates with https://github.com/microsoft/playwright-mcp
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FileMCPManager = void 0;
|
|
8
|
+
const mcp_client_1 = require("./mcp-client");
|
|
9
|
+
const _1 = require(".");
|
|
10
|
+
class FileMCPManager extends _1.AbstractGroupedMCPManager {
|
|
11
|
+
constructor() {
|
|
12
|
+
const groups = [
|
|
13
|
+
{
|
|
14
|
+
name: 'file_mcp',
|
|
15
|
+
description: 'Read, write files on the filesystem',
|
|
16
|
+
loadByDefault: false,
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
super(groups);
|
|
20
|
+
}
|
|
21
|
+
async start(forced = false) {
|
|
22
|
+
const client = this.createClient();
|
|
23
|
+
this.client = client;
|
|
24
|
+
await client.connect(forced);
|
|
25
|
+
}
|
|
26
|
+
getClient() {
|
|
27
|
+
if (!this.client) {
|
|
28
|
+
throw new Error("MCP Client is not started yet");
|
|
29
|
+
}
|
|
30
|
+
return this.client;
|
|
31
|
+
}
|
|
32
|
+
createClient() {
|
|
33
|
+
// Build args with headless mode
|
|
34
|
+
const args = [
|
|
35
|
+
'@cotestdev/mcp-files',
|
|
36
|
+
];
|
|
37
|
+
const mcpConfig = {
|
|
38
|
+
cmd: 'npx',
|
|
39
|
+
args: args,
|
|
40
|
+
env: { ...process.env },
|
|
41
|
+
};
|
|
42
|
+
return new mcp_client_1.MCPClient(mcpConfig);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.FileMCPManager = FileMCPManager;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MCPClient } from "./mcp-client";
|
|
2
|
+
export interface ToolGroup {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
tools?: string[];
|
|
6
|
+
loadByDefault: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface GroupedMCPManager {
|
|
9
|
+
groups: ToolGroup[];
|
|
10
|
+
start(forced?: boolean): Promise<void>;
|
|
11
|
+
getToolGroupInfo(): Record<string, string>;
|
|
12
|
+
getClient(): MCPClient;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class AbstractGroupedMCPManager implements GroupedMCPManager {
|
|
15
|
+
groups: ToolGroup[];
|
|
16
|
+
constructor(groups: ToolGroup[]);
|
|
17
|
+
abstract start(forced: boolean): Promise<void>;
|
|
18
|
+
abstract getClient(): MCPClient;
|
|
19
|
+
getToolGroupInfo(): Record<string, string>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractGroupedMCPManager = void 0;
|
|
4
|
+
class AbstractGroupedMCPManager {
|
|
5
|
+
constructor(groups) {
|
|
6
|
+
this.groups = groups;
|
|
7
|
+
}
|
|
8
|
+
getToolGroupInfo() {
|
|
9
|
+
const result = {};
|
|
10
|
+
for (const group of this.groups) {
|
|
11
|
+
result[group.name] = group.description;
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.AbstractGroupedMCPManager = AbstractGroupedMCPManager;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) Client for Playwright integration
|
|
3
|
+
* Integrates with https://github.com/microsoft/playwright-mcp
|
|
4
|
+
*/
|
|
5
|
+
import { ToolCall } from '../types';
|
|
6
|
+
export interface MCPTool {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export interface MCPConfig {
|
|
12
|
+
cmd?: string;
|
|
13
|
+
args: string[];
|
|
14
|
+
url?: string;
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export declare class MCPClient {
|
|
18
|
+
private client;
|
|
19
|
+
private connected;
|
|
20
|
+
private connecting;
|
|
21
|
+
private transport;
|
|
22
|
+
private availableTools;
|
|
23
|
+
private config;
|
|
24
|
+
constructor(config: MCPConfig);
|
|
25
|
+
getConfig(): MCPConfig;
|
|
26
|
+
doCallTool(name: string, args: Record<string, any>, signal: AbortSignal): Promise<{
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
content: ({
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
annotations?: {
|
|
32
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
33
|
+
priority?: number | undefined;
|
|
34
|
+
lastModified?: string | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
_meta?: Record<string, unknown> | undefined;
|
|
37
|
+
} | {
|
|
38
|
+
type: "image";
|
|
39
|
+
data: string;
|
|
40
|
+
mimeType: string;
|
|
41
|
+
annotations?: {
|
|
42
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
43
|
+
priority?: number | undefined;
|
|
44
|
+
lastModified?: string | undefined;
|
|
45
|
+
} | undefined;
|
|
46
|
+
_meta?: Record<string, unknown> | undefined;
|
|
47
|
+
} | {
|
|
48
|
+
type: "audio";
|
|
49
|
+
data: string;
|
|
50
|
+
mimeType: string;
|
|
51
|
+
annotations?: {
|
|
52
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
53
|
+
priority?: number | undefined;
|
|
54
|
+
lastModified?: string | undefined;
|
|
55
|
+
} | undefined;
|
|
56
|
+
_meta?: Record<string, unknown> | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
type: "resource";
|
|
59
|
+
resource: {
|
|
60
|
+
uri: string;
|
|
61
|
+
text: string;
|
|
62
|
+
mimeType?: string | undefined;
|
|
63
|
+
_meta?: Record<string, unknown> | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
uri: string;
|
|
66
|
+
blob: string;
|
|
67
|
+
mimeType?: string | undefined;
|
|
68
|
+
_meta?: Record<string, unknown> | undefined;
|
|
69
|
+
};
|
|
70
|
+
annotations?: {
|
|
71
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
72
|
+
priority?: number | undefined;
|
|
73
|
+
lastModified?: string | undefined;
|
|
74
|
+
} | undefined;
|
|
75
|
+
_meta?: Record<string, unknown> | undefined;
|
|
76
|
+
} | {
|
|
77
|
+
uri: string;
|
|
78
|
+
name: string;
|
|
79
|
+
type: "resource_link";
|
|
80
|
+
description?: string | undefined;
|
|
81
|
+
mimeType?: string | undefined;
|
|
82
|
+
annotations?: {
|
|
83
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
84
|
+
priority?: number | undefined;
|
|
85
|
+
lastModified?: string | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
_meta?: {
|
|
88
|
+
[x: string]: unknown;
|
|
89
|
+
} | undefined;
|
|
90
|
+
icons?: {
|
|
91
|
+
src: string;
|
|
92
|
+
mimeType?: string | undefined;
|
|
93
|
+
sizes?: string[] | undefined;
|
|
94
|
+
theme?: "light" | "dark" | undefined;
|
|
95
|
+
}[] | undefined;
|
|
96
|
+
title?: string | undefined;
|
|
97
|
+
})[];
|
|
98
|
+
_meta?: {
|
|
99
|
+
[x: string]: unknown;
|
|
100
|
+
progressToken?: string | number | undefined;
|
|
101
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
102
|
+
taskId: string;
|
|
103
|
+
} | undefined;
|
|
104
|
+
} | undefined;
|
|
105
|
+
structuredContent?: Record<string, unknown> | undefined;
|
|
106
|
+
isError?: boolean | undefined;
|
|
107
|
+
} | {
|
|
108
|
+
[x: string]: unknown;
|
|
109
|
+
toolResult: unknown;
|
|
110
|
+
_meta?: {
|
|
111
|
+
[x: string]: unknown;
|
|
112
|
+
progressToken?: string | number | undefined;
|
|
113
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
114
|
+
taskId: string;
|
|
115
|
+
} | undefined;
|
|
116
|
+
} | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
callTool(toolCall: ToolCall, signal: AbortSignal): Promise<any>;
|
|
119
|
+
connect(forced?: boolean): Promise<void>;
|
|
120
|
+
doConnect(): Promise<void>;
|
|
121
|
+
private loadAvailableTools;
|
|
122
|
+
getAvailableTools(): MCPTool[];
|
|
123
|
+
getToolByName(name: string): MCPTool | undefined;
|
|
124
|
+
getToolsDescription(): string;
|
|
125
|
+
disconnect(): Promise<void>;
|
|
126
|
+
isConnected(): boolean;
|
|
127
|
+
}
|