@elliotding/ai-agent-mcp 0.1.26 → 0.1.27
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/dist/api/cached-client.d.ts +48 -0
- package/dist/api/cached-client.d.ts.map +1 -0
- package/dist/api/cached-client.js +126 -0
- package/dist/api/cached-client.js.map +1 -0
- package/dist/api/client.d.ts +281 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +371 -0
- package/dist/api/client.js.map +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +26 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +36 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +194 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/permissions.d.ts +60 -0
- package/dist/auth/permissions.d.ts.map +1 -0
- package/dist/auth/permissions.js +262 -0
- package/dist/auth/permissions.js.map +1 -0
- package/dist/auth/token-validator.d.ts +52 -0
- package/dist/auth/token-validator.d.ts.map +1 -0
- package/dist/auth/token-validator.js +215 -0
- package/dist/auth/token-validator.js.map +1 -0
- package/dist/cache/cache-manager.d.ts +49 -0
- package/dist/cache/cache-manager.d.ts.map +1 -0
- package/dist/cache/cache-manager.js +191 -0
- package/dist/cache/cache-manager.js.map +1 -0
- package/dist/cache/index.d.ts +6 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +12 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/redis-client.d.ts +45 -0
- package/dist/cache/redis-client.d.ts.map +1 -0
- package/dist/cache/redis-client.js +210 -0
- package/dist/cache/redis-client.js.map +1 -0
- package/dist/config/constants.d.ts +28 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +31 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/index.d.ts +71 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +190 -0
- package/dist/config/index.js.map +1 -0
- package/dist/filesystem/manager.d.ts +45 -0
- package/dist/filesystem/manager.d.ts.map +1 -0
- package/dist/filesystem/manager.js +246 -0
- package/dist/filesystem/manager.js.map +1 -0
- package/dist/git/multi-source-manager.d.ts +78 -0
- package/dist/git/multi-source-manager.d.ts.map +1 -0
- package/dist/git/multi-source-manager.js +577 -0
- package/dist/git/multi-source-manager.js.map +1 -0
- package/dist/git/operations.d.ts +27 -0
- package/dist/git/operations.d.ts.map +1 -0
- package/dist/git/operations.js +83 -0
- package/dist/git/operations.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/monitoring/health.d.ts +35 -0
- package/dist/monitoring/health.d.ts.map +1 -0
- package/dist/monitoring/health.js +105 -0
- package/dist/monitoring/health.js.map +1 -0
- package/dist/prompts/cache.d.ts +69 -0
- package/dist/prompts/cache.d.ts.map +1 -0
- package/dist/prompts/cache.js +163 -0
- package/dist/prompts/cache.js.map +1 -0
- package/dist/prompts/generator.d.ts +49 -0
- package/dist/prompts/generator.d.ts.map +1 -0
- package/dist/prompts/generator.js +160 -0
- package/dist/prompts/generator.js.map +1 -0
- package/dist/prompts/index.d.ts +13 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +24 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/manager.d.ts +207 -0
- package/dist/prompts/manager.d.ts.map +1 -0
- package/dist/prompts/manager.js +566 -0
- package/dist/prompts/manager.js.map +1 -0
- package/dist/resources/index.d.ts +6 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +10 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/loader.d.ts +88 -0
- package/dist/resources/loader.d.ts.map +1 -0
- package/dist/resources/loader.js +492 -0
- package/dist/resources/loader.js.map +1 -0
- package/dist/server/http.d.ts +57 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +435 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +201 -0
- package/dist/server.js.map +1 -0
- package/dist/session/manager.d.ts +91 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +251 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +7 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/manager.d.ts +151 -0
- package/dist/telemetry/manager.d.ts.map +1 -0
- package/dist/telemetry/manager.js +367 -0
- package/dist/telemetry/manager.js.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +29 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/manage-subscription.d.ts +47 -0
- package/dist/tools/manage-subscription.d.ts.map +1 -0
- package/dist/tools/manage-subscription.js +317 -0
- package/dist/tools/manage-subscription.js.map +1 -0
- package/dist/tools/registry.d.ts +40 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +85 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/resolve-prompt-content.d.ts +35 -0
- package/dist/tools/resolve-prompt-content.d.ts.map +1 -0
- package/dist/tools/resolve-prompt-content.js +99 -0
- package/dist/tools/resolve-prompt-content.js.map +1 -0
- package/dist/tools/search-resources.d.ts +35 -0
- package/dist/tools/search-resources.d.ts.map +1 -0
- package/dist/tools/search-resources.js +159 -0
- package/dist/tools/search-resources.js.map +1 -0
- package/dist/tools/sync-resources.d.ts +54 -0
- package/dist/tools/sync-resources.d.ts.map +1 -0
- package/dist/tools/sync-resources.js +735 -0
- package/dist/tools/sync-resources.js.map +1 -0
- package/dist/tools/track-usage.d.ts +63 -0
- package/dist/tools/track-usage.d.ts.map +1 -0
- package/dist/tools/track-usage.js +90 -0
- package/dist/tools/track-usage.js.map +1 -0
- package/dist/tools/uninstall-resource.d.ts +30 -0
- package/dist/tools/uninstall-resource.d.ts.map +1 -0
- package/dist/tools/uninstall-resource.js +174 -0
- package/dist/tools/uninstall-resource.js.map +1 -0
- package/dist/tools/upload-resource.d.ts +81 -0
- package/dist/tools/upload-resource.d.ts.map +1 -0
- package/dist/tools/upload-resource.js +393 -0
- package/dist/tools/upload-resource.js.map +1 -0
- package/dist/transport/sse.d.ts +29 -0
- package/dist/transport/sse.d.ts.map +1 -0
- package/dist/transport/sse.js +271 -0
- package/dist/transport/sse.js.map +1 -0
- package/dist/types/errors.d.ts +60 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +112 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.d.ts +50 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +6 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/resources.d.ts +109 -0
- package/dist/types/resources.d.ts.map +1 -0
- package/dist/types/resources.js +7 -0
- package/dist/types/resources.js.map +1 -0
- package/dist/types/tools.d.ts +253 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +6 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/cursor-paths.d.ts +84 -0
- package/dist/utils/cursor-paths.d.ts.map +1 -0
- package/dist/utils/cursor-paths.js +166 -0
- package/dist/utils/cursor-paths.js.map +1 -0
- package/dist/utils/log-cleaner.d.ts +18 -0
- package/dist/utils/log-cleaner.d.ts.map +1 -0
- package/dist/utils/log-cleaner.js +112 -0
- package/dist/utils/log-cleaner.js.map +1 -0
- package/dist/utils/logger.d.ts +59 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +292 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/validation.d.ts +58 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +214 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Loader Module
|
|
3
|
+
* Manages multi-source AI resource loading and indexing
|
|
4
|
+
*
|
|
5
|
+
* Implements AI Resources Multi-Source Architecture as defined in:
|
|
6
|
+
* @see Docs/AI-Resources-Multi-Source-Architecture.md
|
|
7
|
+
* @see AGENTS.md (AI Resources 开发约束)
|
|
8
|
+
*/
|
|
9
|
+
import type { ResourceMetadata, ResourceType, ResourceConflict, LoaderStats } from '../types/resources';
|
|
10
|
+
/**
|
|
11
|
+
* Resource Loader
|
|
12
|
+
*
|
|
13
|
+
* Key responsibilities:
|
|
14
|
+
* 1. Load and validate ai-resources-config.json
|
|
15
|
+
* 2. Scan resources from multiple sources
|
|
16
|
+
* 3. Build resource index with priority
|
|
17
|
+
* 4. Resolve resource name conflicts
|
|
18
|
+
* 5. Provide unified resource query interface
|
|
19
|
+
*/
|
|
20
|
+
export declare class ResourceLoader {
|
|
21
|
+
private config;
|
|
22
|
+
private configFilePath;
|
|
23
|
+
private resourceIndex;
|
|
24
|
+
private conflicts;
|
|
25
|
+
private stats;
|
|
26
|
+
private loaded;
|
|
27
|
+
private cacheEnabled;
|
|
28
|
+
private cacheTTL;
|
|
29
|
+
private lastLoadTime;
|
|
30
|
+
/**
|
|
31
|
+
* Load AI Resources configuration file
|
|
32
|
+
*/
|
|
33
|
+
loadConfig(configPath?: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Validate configuration structure and constraints
|
|
36
|
+
*/
|
|
37
|
+
private validateConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Get default configuration (fallback)
|
|
40
|
+
*/
|
|
41
|
+
private getDefaultConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Scan and index resources from all sources
|
|
44
|
+
*/
|
|
45
|
+
scanResources(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Scan resources from a single source
|
|
48
|
+
*/
|
|
49
|
+
private scanSource;
|
|
50
|
+
/**
|
|
51
|
+
* Scan resources of a specific type from a directory
|
|
52
|
+
*/
|
|
53
|
+
private scanResourceType;
|
|
54
|
+
/**
|
|
55
|
+
* Index a single resource with conflict detection
|
|
56
|
+
*/
|
|
57
|
+
private indexResource;
|
|
58
|
+
/**
|
|
59
|
+
* Get all resources by type
|
|
60
|
+
*/
|
|
61
|
+
getResourcesByType(type: ResourceType): ResourceMetadata[];
|
|
62
|
+
/**
|
|
63
|
+
* Get resource by ID (type:name)
|
|
64
|
+
*/
|
|
65
|
+
getResourceById(id: string): ResourceMetadata | null;
|
|
66
|
+
/**
|
|
67
|
+
* Search resources by name
|
|
68
|
+
*/
|
|
69
|
+
searchResourcesByName(name: string, type?: ResourceType): ResourceMetadata[];
|
|
70
|
+
/**
|
|
71
|
+
* Get all detected conflicts
|
|
72
|
+
*/
|
|
73
|
+
getConflicts(): ResourceConflict[];
|
|
74
|
+
/**
|
|
75
|
+
* Get loader statistics
|
|
76
|
+
*/
|
|
77
|
+
getStats(): LoaderStats | null;
|
|
78
|
+
/**
|
|
79
|
+
* Refresh resource index (clear cache and rescan)
|
|
80
|
+
*/
|
|
81
|
+
refresh(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Ensure resources are loaded
|
|
84
|
+
*/
|
|
85
|
+
private ensureLoaded;
|
|
86
|
+
}
|
|
87
|
+
export declare const resourceLoader: ResourceLoader;
|
|
88
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/resources/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAEV,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;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
+
*
|
|
6
|
+
* Implements AI Resources Multi-Source Architecture as defined in:
|
|
7
|
+
* @see Docs/AI-Resources-Multi-Source-Architecture.md
|
|
8
|
+
* @see AGENTS.md (AI Resources 开发约束)
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.resourceLoader = exports.ResourceLoader = void 0;
|
|
45
|
+
const fs = __importStar(require("fs/promises"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const logger_1 = require("../utils/logger");
|
|
48
|
+
/**
|
|
49
|
+
* Resource Loader
|
|
50
|
+
*
|
|
51
|
+
* Key responsibilities:
|
|
52
|
+
* 1. Load and validate ai-resources-config.json
|
|
53
|
+
* 2. Scan resources from multiple sources
|
|
54
|
+
* 3. Build resource index with priority
|
|
55
|
+
* 4. Resolve resource name conflicts
|
|
56
|
+
* 5. Provide unified resource query interface
|
|
57
|
+
*/
|
|
58
|
+
class ResourceLoader {
|
|
59
|
+
config = null;
|
|
60
|
+
configFilePath = null;
|
|
61
|
+
resourceIndex = new Map();
|
|
62
|
+
conflicts = [];
|
|
63
|
+
stats = null;
|
|
64
|
+
loaded = false;
|
|
65
|
+
// Cache configuration
|
|
66
|
+
cacheEnabled = false;
|
|
67
|
+
cacheTTL = 300000; // 5 minutes default
|
|
68
|
+
lastLoadTime = 0;
|
|
69
|
+
/**
|
|
70
|
+
* Load AI Resources configuration file
|
|
71
|
+
*/
|
|
72
|
+
async loadConfig(configPath) {
|
|
73
|
+
const startTime = Date.now();
|
|
74
|
+
try {
|
|
75
|
+
// Resolve the AI-Resources base directory using the same probing strategy
|
|
76
|
+
// as multi-source-manager so both modules agree on the path regardless of
|
|
77
|
+
// whether the server runs locally (cwd = SourceCode/) or in Docker (cwd = /app).
|
|
78
|
+
let defaultPath = path.resolve(process.cwd(), 'AI-Resources/ai-resources-config.json');
|
|
79
|
+
if (!configPath) {
|
|
80
|
+
const candidates = [
|
|
81
|
+
path.resolve(process.env['AI_RESOURCES_PATH'] ?? '', 'ai-resources-config.json'),
|
|
82
|
+
path.resolve(process.cwd(), 'AI-Resources/ai-resources-config.json'),
|
|
83
|
+
path.resolve(process.cwd(), '../AI-Resources/ai-resources-config.json'),
|
|
84
|
+
path.resolve(__dirname, '../../AI-Resources/ai-resources-config.json'),
|
|
85
|
+
].filter(Boolean);
|
|
86
|
+
for (const c of candidates) {
|
|
87
|
+
try {
|
|
88
|
+
await fs.access(c);
|
|
89
|
+
defaultPath = c;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
catch { /* try next */ }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const finalPath = configPath || defaultPath;
|
|
96
|
+
logger_1.logger.debug({ configPath: finalPath }, 'Loading AI Resources configuration...');
|
|
97
|
+
// Check if config file exists
|
|
98
|
+
try {
|
|
99
|
+
await fs.access(finalPath);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
logger_1.logger.warn({ configPath: finalPath }, 'AI Resources config file not found, using default configuration');
|
|
103
|
+
this.config = this.getDefaultConfig();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Read and parse config file
|
|
107
|
+
const configContent = await fs.readFile(finalPath, 'utf-8');
|
|
108
|
+
const parsedConfig = JSON.parse(configContent);
|
|
109
|
+
// Validate configuration
|
|
110
|
+
this.validateConfig(parsedConfig);
|
|
111
|
+
this.config = parsedConfig;
|
|
112
|
+
this.configFilePath = finalPath;
|
|
113
|
+
this.cacheEnabled = parsedConfig.cache?.enabled ?? true;
|
|
114
|
+
this.cacheTTL = (parsedConfig.cache?.ttl ?? 300) * 1000; // Convert to ms
|
|
115
|
+
const duration = Date.now() - startTime;
|
|
116
|
+
logger_1.logger.info({
|
|
117
|
+
configPath: finalPath,
|
|
118
|
+
defaultSource: parsedConfig.default_source.name,
|
|
119
|
+
extendedSourcesCount: parsedConfig.extended_sources.length,
|
|
120
|
+
duration,
|
|
121
|
+
}, 'AI Resources configuration loaded successfully');
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
logger_1.logger.error({
|
|
125
|
+
type: 'resource',
|
|
126
|
+
operation: 'load_config',
|
|
127
|
+
error: error instanceof Error ? error.message : String(error),
|
|
128
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
129
|
+
}, 'Failed to load AI Resources configuration');
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Validate configuration structure and constraints
|
|
135
|
+
*/
|
|
136
|
+
validateConfig(config) {
|
|
137
|
+
// Check version
|
|
138
|
+
if (config.version !== '1.0') {
|
|
139
|
+
throw new Error(`Unsupported config version: ${config.version}, expected 1.0`);
|
|
140
|
+
}
|
|
141
|
+
// Check default source
|
|
142
|
+
if (!config.default_source) {
|
|
143
|
+
throw new Error('Missing required field: default_source');
|
|
144
|
+
}
|
|
145
|
+
if (config.default_source.name !== 'csp') {
|
|
146
|
+
logger_1.logger.warn({ name: config.default_source.name }, 'Default source name is not "csp", this may cause compatibility issues');
|
|
147
|
+
}
|
|
148
|
+
if (config.default_source.priority !== 100) {
|
|
149
|
+
logger_1.logger.warn({ priority: config.default_source.priority }, 'Default source priority is not 100, this may affect conflict resolution');
|
|
150
|
+
}
|
|
151
|
+
if (!config.default_source.enabled) {
|
|
152
|
+
throw new Error('Default source must be enabled');
|
|
153
|
+
}
|
|
154
|
+
// Check resource types
|
|
155
|
+
const expectedTypes = ['commands', 'skills', 'mcp', 'rules'];
|
|
156
|
+
if (!config.resource_types ||
|
|
157
|
+
config.resource_types.length !== 4 ||
|
|
158
|
+
!expectedTypes.every((type) => config.resource_types.includes(type))) {
|
|
159
|
+
throw new Error(`Invalid resource_types, expected: ${expectedTypes.join(', ')}, got: ${config.resource_types?.join(', ') || 'none'}`);
|
|
160
|
+
}
|
|
161
|
+
// Check loading order
|
|
162
|
+
if (config.loading_order !== 'priority_desc') {
|
|
163
|
+
logger_1.logger.warn({ loading_order: config.loading_order }, 'Loading order is not "priority_desc", this may affect resource precedence');
|
|
164
|
+
}
|
|
165
|
+
// Check conflict resolution
|
|
166
|
+
if (config.conflict_resolution !== 'highest_priority_wins') {
|
|
167
|
+
logger_1.logger.warn({ conflict_resolution: config.conflict_resolution }, 'Conflict resolution is not "highest_priority_wins", this may affect behavior');
|
|
168
|
+
}
|
|
169
|
+
// Check extended sources priority
|
|
170
|
+
const defaultPriority = config.default_source.priority;
|
|
171
|
+
for (const source of config.extended_sources || []) {
|
|
172
|
+
if (source.priority >= defaultPriority) {
|
|
173
|
+
throw new Error(`Extended source "${source.name}" has priority ${source.priority} which is >= default source priority ${defaultPriority}. Default source must have highest priority.`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
logger_1.logger.debug('AI Resources configuration validation passed');
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get default configuration (fallback)
|
|
180
|
+
*/
|
|
181
|
+
getDefaultConfig() {
|
|
182
|
+
return {
|
|
183
|
+
version: '1.0',
|
|
184
|
+
description: 'Default AI Resources configuration',
|
|
185
|
+
default_source: {
|
|
186
|
+
name: 'csp',
|
|
187
|
+
path: 'csp/ai-resources',
|
|
188
|
+
enabled: true,
|
|
189
|
+
priority: 100,
|
|
190
|
+
resources: {
|
|
191
|
+
commands: 'commands',
|
|
192
|
+
skills: 'skills',
|
|
193
|
+
mcp: 'mcp',
|
|
194
|
+
rules: 'rules',
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
extended_sources: [],
|
|
198
|
+
resource_types: ['commands', 'skills', 'mcp', 'rules'],
|
|
199
|
+
loading_order: 'priority_desc',
|
|
200
|
+
conflict_resolution: 'highest_priority_wins',
|
|
201
|
+
cache: {
|
|
202
|
+
enabled: true,
|
|
203
|
+
ttl: 300,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Scan and index resources from all sources
|
|
209
|
+
*/
|
|
210
|
+
async scanResources() {
|
|
211
|
+
if (!this.config) {
|
|
212
|
+
throw new Error('Configuration not loaded. Call loadConfig() first.');
|
|
213
|
+
}
|
|
214
|
+
// Check cache validity
|
|
215
|
+
if (this.cacheEnabled && this.loaded) {
|
|
216
|
+
const cacheAge = Date.now() - this.lastLoadTime;
|
|
217
|
+
if (cacheAge < this.cacheTTL) {
|
|
218
|
+
logger_1.logger.debug({ cacheAge }, 'Using cached resource index');
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
logger_1.logger.debug('Resource cache expired, reloading...');
|
|
222
|
+
}
|
|
223
|
+
const startTime = Date.now();
|
|
224
|
+
this.resourceIndex.clear();
|
|
225
|
+
this.conflicts = [];
|
|
226
|
+
const stats = {
|
|
227
|
+
sourcesLoaded: 0,
|
|
228
|
+
resourcesIndexed: 0,
|
|
229
|
+
byType: {
|
|
230
|
+
commands: 0,
|
|
231
|
+
skills: 0,
|
|
232
|
+
mcp: 0,
|
|
233
|
+
rules: 0,
|
|
234
|
+
},
|
|
235
|
+
conflictsDetected: 0,
|
|
236
|
+
loadDuration: 0,
|
|
237
|
+
};
|
|
238
|
+
try {
|
|
239
|
+
// Collect all sources sorted by priority (descending)
|
|
240
|
+
const sources = [this.config.default_source, ...this.config.extended_sources.filter((s) => s.enabled)];
|
|
241
|
+
sources.sort((a, b) => b.priority - a.priority); // High priority first
|
|
242
|
+
logger_1.logger.info({ sourceCount: sources.length }, 'Scanning resources from all sources...');
|
|
243
|
+
// Scan each source
|
|
244
|
+
for (const source of sources) {
|
|
245
|
+
await this.scanSource(source, stats);
|
|
246
|
+
stats.sourcesLoaded++;
|
|
247
|
+
}
|
|
248
|
+
stats.conflictsDetected = this.conflicts.length;
|
|
249
|
+
stats.loadDuration = Date.now() - startTime;
|
|
250
|
+
this.stats = stats;
|
|
251
|
+
this.loaded = true;
|
|
252
|
+
this.lastLoadTime = Date.now();
|
|
253
|
+
logger_1.logger.info({
|
|
254
|
+
sourcesLoaded: stats.sourcesLoaded,
|
|
255
|
+
resourcesIndexed: stats.resourcesIndexed,
|
|
256
|
+
conflictsDetected: stats.conflictsDetected,
|
|
257
|
+
duration: stats.loadDuration,
|
|
258
|
+
}, 'Resource scanning completed');
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
logger_1.logger.error({
|
|
262
|
+
type: 'resource',
|
|
263
|
+
operation: 'scan_resources',
|
|
264
|
+
error: error instanceof Error ? error.message : String(error),
|
|
265
|
+
}, 'Failed to scan resources');
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Scan resources from a single source
|
|
271
|
+
*/
|
|
272
|
+
async scanSource(source, stats) {
|
|
273
|
+
logger_1.logger.debug({ source: source.name, path: source.path }, 'Scanning source...');
|
|
274
|
+
// Derive the AI-Resources base from the config file path stored on the instance,
|
|
275
|
+
// so the source subdirectory resolves correctly in Docker (cwd = /app) and local
|
|
276
|
+
// dev (cwd = SourceCode/) without needing a separate env var.
|
|
277
|
+
const aiResourcesBase = this.configFilePath
|
|
278
|
+
? path.dirname(this.configFilePath)
|
|
279
|
+
: path.resolve(process.cwd(), 'AI-Resources');
|
|
280
|
+
const baseDir = path.resolve(aiResourcesBase, source.path);
|
|
281
|
+
// Check if source directory exists
|
|
282
|
+
try {
|
|
283
|
+
await fs.access(baseDir);
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
logger_1.logger.warn({ source: source.name, path: baseDir }, 'Source directory not found, skipping');
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
// Scan each resource type
|
|
290
|
+
for (const type of this.config.resource_types) {
|
|
291
|
+
const subDir = source.resources[type];
|
|
292
|
+
if (!subDir) {
|
|
293
|
+
logger_1.logger.debug({ source: source.name, type }, 'Resource type not defined for this source, skipping');
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const resourceDir = path.join(baseDir, subDir);
|
|
297
|
+
try {
|
|
298
|
+
await fs.access(resourceDir);
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
logger_1.logger.debug({ source: source.name, type, path: resourceDir }, 'Resource directory not found, skipping');
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
await this.scanResourceType(source, type, resourceDir, stats);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Scan resources of a specific type from a directory
|
|
309
|
+
*/
|
|
310
|
+
async scanResourceType(source, type, dir, stats) {
|
|
311
|
+
try {
|
|
312
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
313
|
+
for (const entry of entries) {
|
|
314
|
+
const fullPath = path.join(dir, entry.name);
|
|
315
|
+
if (entry.isFile() && (entry.name.endsWith('.md') || entry.name.endsWith('.mdc'))) {
|
|
316
|
+
// Handle file resources (commands, rules)
|
|
317
|
+
const resourceName = path.basename(entry.name, path.extname(entry.name));
|
|
318
|
+
await this.indexResource(source, type, resourceName, fullPath, stats);
|
|
319
|
+
}
|
|
320
|
+
else if (entry.isDirectory()) {
|
|
321
|
+
// Handle directory resources:
|
|
322
|
+
// skill → must contain SKILL.md
|
|
323
|
+
// mcp → must contain mcp-config.json
|
|
324
|
+
// others → directory layout is not expected; skip
|
|
325
|
+
if (type === 'skills') {
|
|
326
|
+
const skillFile = path.join(fullPath, 'SKILL.md');
|
|
327
|
+
try {
|
|
328
|
+
await fs.access(skillFile);
|
|
329
|
+
await this.indexResource(source, type, entry.name, skillFile, stats);
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
logger_1.logger.debug({ dir: fullPath }, 'Directory does not contain SKILL.md, skipping');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else if (type === 'mcp') {
|
|
336
|
+
const mcpConfigFile = path.join(fullPath, 'mcp-config.json');
|
|
337
|
+
try {
|
|
338
|
+
await fs.access(mcpConfigFile);
|
|
339
|
+
await this.indexResource(source, type, entry.name, mcpConfigFile, stats);
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
logger_1.logger.debug({ dir: fullPath }, 'Directory does not contain mcp-config.json, skipping');
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
logger_1.logger.warn({
|
|
350
|
+
source: source.name,
|
|
351
|
+
type,
|
|
352
|
+
dir,
|
|
353
|
+
error: error instanceof Error ? error.message : String(error),
|
|
354
|
+
}, 'Failed to scan resource directory');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Index a single resource with conflict detection
|
|
359
|
+
*/
|
|
360
|
+
async indexResource(source, type, name, filePath, stats) {
|
|
361
|
+
const resourceKey = `${type}:${name}`;
|
|
362
|
+
const existing = this.resourceIndex.get(resourceKey);
|
|
363
|
+
if (existing) {
|
|
364
|
+
// Conflict detected
|
|
365
|
+
logger_1.logger.warn({
|
|
366
|
+
resourceName: name,
|
|
367
|
+
type,
|
|
368
|
+
existingSource: existing.source,
|
|
369
|
+
existingPriority: existing.priority,
|
|
370
|
+
newSource: source.name,
|
|
371
|
+
newPriority: source.priority,
|
|
372
|
+
}, 'Resource name conflict detected');
|
|
373
|
+
// Record conflict
|
|
374
|
+
const conflict = {
|
|
375
|
+
name,
|
|
376
|
+
type,
|
|
377
|
+
conflicts: [
|
|
378
|
+
{
|
|
379
|
+
source: existing.source,
|
|
380
|
+
priority: existing.priority,
|
|
381
|
+
path: existing.path,
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
source: source.name,
|
|
385
|
+
priority: source.priority,
|
|
386
|
+
path: filePath,
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
selected: source.priority > existing.priority
|
|
390
|
+
? { source: source.name, priority: source.priority, path: filePath }
|
|
391
|
+
: { source: existing.source, priority: existing.priority, path: existing.path },
|
|
392
|
+
};
|
|
393
|
+
this.conflicts.push(conflict);
|
|
394
|
+
// Keep higher priority resource (already sorted by priority)
|
|
395
|
+
if (source.priority <= existing.priority) {
|
|
396
|
+
logger_1.logger.debug({
|
|
397
|
+
resourceName: name,
|
|
398
|
+
selectedSource: existing.source,
|
|
399
|
+
}, 'Keeping existing resource (higher priority)');
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
logger_1.logger.debug({
|
|
403
|
+
resourceName: name,
|
|
404
|
+
selectedSource: source.name,
|
|
405
|
+
}, 'Replacing with new resource (higher priority)');
|
|
406
|
+
}
|
|
407
|
+
// Index resource
|
|
408
|
+
const metadata = {
|
|
409
|
+
id: resourceKey,
|
|
410
|
+
name,
|
|
411
|
+
type,
|
|
412
|
+
source: source.name,
|
|
413
|
+
priority: source.priority,
|
|
414
|
+
path: filePath,
|
|
415
|
+
};
|
|
416
|
+
this.resourceIndex.set(resourceKey, metadata);
|
|
417
|
+
stats.resourcesIndexed++;
|
|
418
|
+
stats.byType[type]++;
|
|
419
|
+
logger_1.logger.debug({ resourceKey, source: source.name }, 'Resource indexed');
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Get all resources by type
|
|
423
|
+
*/
|
|
424
|
+
getResourcesByType(type) {
|
|
425
|
+
this.ensureLoaded();
|
|
426
|
+
const results = [];
|
|
427
|
+
for (const [, metadata] of this.resourceIndex) {
|
|
428
|
+
if (metadata.type === type) {
|
|
429
|
+
results.push(metadata);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return results;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Get resource by ID (type:name)
|
|
436
|
+
*/
|
|
437
|
+
getResourceById(id) {
|
|
438
|
+
this.ensureLoaded();
|
|
439
|
+
return this.resourceIndex.get(id) || null;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Search resources by name
|
|
443
|
+
*/
|
|
444
|
+
searchResourcesByName(name, type) {
|
|
445
|
+
this.ensureLoaded();
|
|
446
|
+
const results = [];
|
|
447
|
+
const lowerName = name.toLowerCase();
|
|
448
|
+
for (const metadata of this.resourceIndex.values()) {
|
|
449
|
+
if (type && metadata.type !== type) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
if (metadata.name.toLowerCase().includes(lowerName)) {
|
|
453
|
+
results.push(metadata);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return results;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Get all detected conflicts
|
|
460
|
+
*/
|
|
461
|
+
getConflicts() {
|
|
462
|
+
this.ensureLoaded();
|
|
463
|
+
return [...this.conflicts];
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Get loader statistics
|
|
467
|
+
*/
|
|
468
|
+
getStats() {
|
|
469
|
+
return this.stats;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Refresh resource index (clear cache and rescan)
|
|
473
|
+
*/
|
|
474
|
+
async refresh() {
|
|
475
|
+
logger_1.logger.info('Refreshing resource index...');
|
|
476
|
+
this.loaded = false;
|
|
477
|
+
this.lastLoadTime = 0;
|
|
478
|
+
await this.scanResources();
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Ensure resources are loaded
|
|
482
|
+
*/
|
|
483
|
+
ensureLoaded() {
|
|
484
|
+
if (!this.loaded) {
|
|
485
|
+
throw new Error('Resources not loaded. Call scanResources() first.');
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
exports.ResourceLoader = ResourceLoader;
|
|
490
|
+
// Singleton instance
|
|
491
|
+
exports.resourceLoader = new ResourceLoader();
|
|
492
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/resources/loader.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAkC;AAClC,2CAA6B;AAC7B,4CAAyC;AASzC;;;;;;;;;GASG;AACH,MAAa,cAAc;IACjB,MAAM,GAA6B,IAAI,CAAC;IACxC,cAAc,GAAkB,IAAI,CAAC;IACrC,aAAa,GAAkC,IAAI,GAAG,EAAE,CAAC;IACzD,SAAS,GAAuB,EAAE,CAAC;IACnC,KAAK,GAAuB,IAAI,CAAC;IACjC,MA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;QACpB,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,eAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACK,YAAY;QAClB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF;AAjhBD,wCAihBC;AAED,qBAAqB;AACR,QAAA,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Server with SSE Support
|
|
3
|
+
* Uses SDK SSEServerTransport for standard MCP-over-SSE protocol,
|
|
4
|
+
* matching the same pattern as the ACM MCP server.
|
|
5
|
+
*/
|
|
6
|
+
import { FastifyInstance } from 'fastify';
|
|
7
|
+
import { type HealthStatus as MonitoringHealthStatus } from '../monitoring/health.js';
|
|
8
|
+
import { CacheManager } from '../cache/cache-manager.js';
|
|
9
|
+
export interface HealthStatus {
|
|
10
|
+
status: 'healthy' | 'unhealthy';
|
|
11
|
+
uptime: number;
|
|
12
|
+
memory: {
|
|
13
|
+
used: number;
|
|
14
|
+
total: number;
|
|
15
|
+
percentage: number;
|
|
16
|
+
};
|
|
17
|
+
sessions: {
|
|
18
|
+
active: number;
|
|
19
|
+
total: number;
|
|
20
|
+
};
|
|
21
|
+
services: MonitoringHealthStatus['services'];
|
|
22
|
+
details?: MonitoringHealthStatus['details'];
|
|
23
|
+
timestamp: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class HTTPServer {
|
|
26
|
+
private fastify;
|
|
27
|
+
private startTime;
|
|
28
|
+
private healthChecker;
|
|
29
|
+
/** Active SDK SSE transports keyed by sessionId */
|
|
30
|
+
private sseTransports;
|
|
31
|
+
constructor(cacheManager?: CacheManager);
|
|
32
|
+
private setupMiddleware;
|
|
33
|
+
private setupRoutes;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new SDK Server instance and registers all tools from toolRegistry.
|
|
36
|
+
* A fresh instance is created per SSE connection so that each session is
|
|
37
|
+
* isolated (matching ACM's createMCPServer-per-connection pattern).
|
|
38
|
+
*/
|
|
39
|
+
private createMcpServer;
|
|
40
|
+
/**
|
|
41
|
+
* GET /sse — establish SSE stream using SDK SSEServerTransport.
|
|
42
|
+
* Auth is validated via preHandler; user context is forwarded to the MCP server.
|
|
43
|
+
*/
|
|
44
|
+
private handleSSEConnection;
|
|
45
|
+
/**
|
|
46
|
+
* POST /message?sessionId=<id> — deliver JSON-RPC message to the correct transport.
|
|
47
|
+
* The SDK transport's handlePostMessage handles parsing and routing internally.
|
|
48
|
+
*/
|
|
49
|
+
private handleMessage;
|
|
50
|
+
private handleHealth;
|
|
51
|
+
start(): Promise<void>;
|
|
52
|
+
stop(): Promise<void>;
|
|
53
|
+
getFastify(): FastifyInstance;
|
|
54
|
+
setCacheManager(cacheManager: CacheManager): void;
|
|
55
|
+
}
|
|
56
|
+
export declare const httpServer: HTTPServer;
|
|
57
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/server/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAgB,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAqBjF,OAAO,EAAiB,KAAK,YAAY,IAAI,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEz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