@1mcp/agent 0.22.3 → 0.23.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/build/commands/mcp/tokens.d.ts +6 -0
- package/build/commands/mcp/tokens.d.ts.map +1 -1
- package/build/commands/mcp/tokens.js +181 -66
- package/build/commands/mcp/tokens.js.map +1 -1
- package/build/commands/serve/index.d.ts +6 -0
- package/build/commands/serve/index.d.ts.map +1 -1
- package/build/commands/serve/index.js +12 -0
- package/build/commands/serve/index.js.map +1 -1
- package/build/commands/serve/serve.d.ts +1 -0
- package/build/commands/serve/serve.d.ts.map +1 -1
- package/build/commands/serve/serve.js +84 -3
- package/build/commands/serve/serve.js.map +1 -1
- package/build/constants.d.ts +6 -1
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +9 -1
- package/build/constants.js.map +1 -1
- package/build/core/client/clientManager.d.ts +13 -0
- package/build/core/client/clientManager.d.ts.map +1 -1
- package/build/core/client/clientManager.js +48 -0
- package/build/core/client/clientManager.js.map +1 -1
- package/build/core/filtering/filteringService.d.ts +85 -0
- package/build/core/filtering/filteringService.d.ts.map +1 -0
- package/build/core/filtering/filteringService.js +253 -0
- package/build/core/filtering/filteringService.js.map +1 -0
- package/build/core/instructions/instructionAggregator.d.ts +141 -0
- package/build/core/instructions/instructionAggregator.d.ts.map +1 -0
- package/build/core/instructions/instructionAggregator.js +385 -0
- package/build/core/instructions/instructionAggregator.js.map +1 -0
- package/build/core/instructions/templateTypes.d.ts +77 -0
- package/build/core/instructions/templateTypes.d.ts.map +1 -0
- package/build/core/instructions/templateTypes.js +90 -0
- package/build/core/instructions/templateTypes.js.map +1 -0
- package/build/core/instructions/templateValidator.d.ts +53 -0
- package/build/core/instructions/templateValidator.d.ts.map +1 -0
- package/build/core/instructions/templateValidator.js +142 -0
- package/build/core/instructions/templateValidator.js.map +1 -0
- package/build/core/server/serverManager.d.ts +11 -0
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +38 -1
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/types/client.d.ts +2 -0
- package/build/core/types/client.d.ts.map +1 -1
- package/build/core/types/server.d.ts +2 -1
- package/build/core/types/server.d.ts.map +1 -1
- package/build/core/types/server.js.map +1 -1
- package/build/handlers/requestHandlers.d.ts.map +1 -1
- package/build/handlers/requestHandlers.js +14 -42
- package/build/handlers/requestHandlers.js.map +1 -1
- package/build/server.d.ts +3 -0
- package/build/server.d.ts.map +1 -1
- package/build/server.js +13 -0
- package/build/server.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import Handlebars from 'handlebars';
|
|
3
|
+
import { LRUCache } from 'lru-cache';
|
|
4
|
+
import logger from '../../logger/logger.js';
|
|
5
|
+
import { FilteringService } from '../filtering/filteringService.js';
|
|
6
|
+
import { DEFAULT_TEMPLATE_CONFIG, DEFAULT_INSTRUCTION_TEMPLATE, } from './templateTypes.js';
|
|
7
|
+
/**
|
|
8
|
+
* Aggregates instructions from multiple MCP servers into a single instruction string.
|
|
9
|
+
* Provides both simple concatenation and filtered instructions with educational templates.
|
|
10
|
+
* The aggregator acts as an educational prompt to help LLMs understand 1MCP better.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const aggregator = new InstructionAggregator();
|
|
15
|
+
* aggregator.on('instructions-changed', () => {
|
|
16
|
+
* // Server instructions have changed
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // When server comes online
|
|
20
|
+
* aggregator.setInstructions('server1', 'Server 1 instructions');
|
|
21
|
+
*
|
|
22
|
+
* // Get filtered instructions for a client
|
|
23
|
+
* const filtered = aggregator.getFilteredInstructions(config, connections);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export class InstructionAggregator extends EventEmitter {
|
|
27
|
+
serverInstructions = new Map();
|
|
28
|
+
isInitialized = false;
|
|
29
|
+
templateCache;
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.setMaxListeners(50);
|
|
33
|
+
// Initialize LRU cache with reasonable limits
|
|
34
|
+
this.templateCache = new LRUCache({
|
|
35
|
+
max: 100, // Maximum 100 compiled templates
|
|
36
|
+
maxSize: 10 * 1024 * 1024, // 10MB total size limit
|
|
37
|
+
sizeCalculation: (template, key) => {
|
|
38
|
+
// Estimate size based on template string length (key) plus overhead
|
|
39
|
+
return key.length + 1024; // Template overhead estimate
|
|
40
|
+
},
|
|
41
|
+
ttl: 1000 * 60 * 60, // 1 hour TTL to prevent indefinite growth
|
|
42
|
+
});
|
|
43
|
+
// Set up cache invalidation on instruction changes
|
|
44
|
+
this.on('instructions-changed', () => {
|
|
45
|
+
this.invalidateTemplateCache('instructions-changed');
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Set or update instructions for a specific server
|
|
50
|
+
* @param serverName The name of the server
|
|
51
|
+
* @param instructions The instruction string from the server, or undefined to remove
|
|
52
|
+
*/
|
|
53
|
+
setInstructions(serverName, instructions) {
|
|
54
|
+
const previousInstructions = this.serverInstructions.get(serverName);
|
|
55
|
+
const hasChanges = previousInstructions !== instructions;
|
|
56
|
+
if (instructions?.trim()) {
|
|
57
|
+
this.serverInstructions.set(serverName, instructions.trim());
|
|
58
|
+
logger.debug(`Updated instructions for server: ${serverName}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.serverInstructions.delete(serverName);
|
|
62
|
+
logger.debug(`Removed instructions for server: ${serverName}`);
|
|
63
|
+
}
|
|
64
|
+
if (!this.isInitialized) {
|
|
65
|
+
this.isInitialized = true;
|
|
66
|
+
logger.debug('InstructionAggregator initialized');
|
|
67
|
+
}
|
|
68
|
+
if (hasChanges) {
|
|
69
|
+
logger.info(`Instructions changed. Total servers with instructions: ${this.serverInstructions.size}`);
|
|
70
|
+
this.emit('instructions-changed');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Remove instructions for a specific server
|
|
75
|
+
* @param serverName The name of the server to remove
|
|
76
|
+
*/
|
|
77
|
+
removeServer(serverName) {
|
|
78
|
+
const hadInstructions = this.serverInstructions.has(serverName);
|
|
79
|
+
this.serverInstructions.delete(serverName);
|
|
80
|
+
if (hadInstructions) {
|
|
81
|
+
logger.info(`Removed server instructions: ${serverName}. Remaining servers: ${this.serverInstructions.size}`);
|
|
82
|
+
this.emit('instructions-changed');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get filtered instructions for a specific client based on their configuration
|
|
87
|
+
* This is the main method that should be used by server connections
|
|
88
|
+
*
|
|
89
|
+
* @param config Client's inbound connection configuration
|
|
90
|
+
* @param connections All available outbound connections
|
|
91
|
+
* @returns Formatted instruction string with educational template or custom template
|
|
92
|
+
*/
|
|
93
|
+
getFilteredInstructions(config, connections) {
|
|
94
|
+
logger.debug('InstructionAggregator: Getting filtered instructions', {
|
|
95
|
+
filterMode: config.tagFilterMode,
|
|
96
|
+
totalConnections: connections.size,
|
|
97
|
+
totalInstructions: this.serverInstructions.size,
|
|
98
|
+
hasCustomTemplate: !!config.customTemplate,
|
|
99
|
+
});
|
|
100
|
+
// Filter connections based on client configuration
|
|
101
|
+
const filteredConnections = FilteringService.getFilteredConnections(connections, config);
|
|
102
|
+
// Get filtering summary for logging
|
|
103
|
+
const filteringSummary = FilteringService.getFilteringSummary(connections, filteredConnections, config);
|
|
104
|
+
logger.info('InstructionAggregator: Filtering applied', filteringSummary);
|
|
105
|
+
// Use custom template if provided, otherwise use default template
|
|
106
|
+
const template = config.customTemplate || DEFAULT_INSTRUCTION_TEMPLATE;
|
|
107
|
+
return this.renderCustomTemplate(template, filteredConnections, config);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the number of servers that have provided instructions
|
|
111
|
+
* @returns The count of servers with instructions
|
|
112
|
+
*/
|
|
113
|
+
getServerCount() {
|
|
114
|
+
return this.serverInstructions.size;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get a list of server names that have provided instructions
|
|
118
|
+
* @returns Array of server names
|
|
119
|
+
*/
|
|
120
|
+
getServerNames() {
|
|
121
|
+
return Array.from(this.serverInstructions.keys()).sort();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if a specific server has instructions
|
|
125
|
+
* @param serverName The server name to check
|
|
126
|
+
* @returns True if the server has instructions
|
|
127
|
+
*/
|
|
128
|
+
hasInstructions(serverName) {
|
|
129
|
+
return this.serverInstructions.has(serverName);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get instructions for a specific server
|
|
133
|
+
* @param serverName The server name
|
|
134
|
+
* @returns The instructions for the server, or undefined if not found
|
|
135
|
+
*/
|
|
136
|
+
getServerInstructions(serverName) {
|
|
137
|
+
return this.serverInstructions.get(serverName);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Clear all instructions (useful for testing)
|
|
141
|
+
*/
|
|
142
|
+
clear() {
|
|
143
|
+
const hadInstructions = this.serverInstructions.size > 0;
|
|
144
|
+
this.serverInstructions.clear();
|
|
145
|
+
if (hadInstructions) {
|
|
146
|
+
logger.debug('Cleared all server instructions');
|
|
147
|
+
this.emit('instructions-changed');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get filter context description for the template
|
|
152
|
+
*/
|
|
153
|
+
getFilterContext(config) {
|
|
154
|
+
if (!config.tagFilterMode || config.tagFilterMode === 'none') {
|
|
155
|
+
return '';
|
|
156
|
+
}
|
|
157
|
+
if (config.tagFilterMode === 'simple-or' && config.tags?.length) {
|
|
158
|
+
return ` (filtered by tags: ${config.tags.join(', ')})`;
|
|
159
|
+
}
|
|
160
|
+
if (config.tagFilterMode === 'advanced' && config.tagExpression) {
|
|
161
|
+
return ' (filtered by advanced expression)';
|
|
162
|
+
}
|
|
163
|
+
if (config.tagFilterMode === 'preset') {
|
|
164
|
+
return ' (filtered by preset)';
|
|
165
|
+
}
|
|
166
|
+
return ' (filtered)';
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get a summary of current instruction state for logging
|
|
170
|
+
*/
|
|
171
|
+
getSummary() {
|
|
172
|
+
const serverCount = this.serverInstructions.size;
|
|
173
|
+
const serverNames = this.getServerNames();
|
|
174
|
+
return `${serverCount} servers with instructions: ${serverNames.join(', ')}`;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Render a custom Handlebars template with template variables
|
|
178
|
+
* @param template Custom template string
|
|
179
|
+
* @param filteredConnections Filtered server connections
|
|
180
|
+
* @param config Client configuration
|
|
181
|
+
* @returns Rendered template string
|
|
182
|
+
*/
|
|
183
|
+
renderCustomTemplate(template, filteredConnections, config) {
|
|
184
|
+
try {
|
|
185
|
+
// Get or compile template
|
|
186
|
+
const compiledTemplate = this.getCompiledTemplate(template);
|
|
187
|
+
// Generate template variables
|
|
188
|
+
const variables = this.generateTemplateVariables(filteredConnections, config);
|
|
189
|
+
// Render template
|
|
190
|
+
const rendered = compiledTemplate(variables);
|
|
191
|
+
logger.debug('InstructionAggregator: Custom template rendered successfully', {
|
|
192
|
+
templateLength: template.length,
|
|
193
|
+
variableCount: Object.keys(variables).length,
|
|
194
|
+
renderedLength: rendered.length,
|
|
195
|
+
});
|
|
196
|
+
return rendered;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
200
|
+
logger.error('InstructionAggregator: Failed to render custom template', {
|
|
201
|
+
error: errorMessage,
|
|
202
|
+
templateLength: template.length,
|
|
203
|
+
});
|
|
204
|
+
// Provide actionable guidance for template errors
|
|
205
|
+
logger.warn('InstructionAggregator: Template rendering failed, returning error instructions with guidance');
|
|
206
|
+
const serverCount = Array.from(filteredConnections.keys()).filter((name) => this.serverInstructions.has(name)).length;
|
|
207
|
+
// Generate helpful error message with troubleshooting steps
|
|
208
|
+
return `# 1MCP - Template Rendering Error
|
|
209
|
+
|
|
210
|
+
⚠️ **Template rendering failed:** ${errorMessage}
|
|
211
|
+
|
|
212
|
+
## Available Resources
|
|
213
|
+
- **${serverCount} server(s)** are connected and have instructions
|
|
214
|
+
- **Built-in template** is available as fallback
|
|
215
|
+
|
|
216
|
+
## Troubleshooting Steps
|
|
217
|
+
|
|
218
|
+
1. **Check Template Syntax**:
|
|
219
|
+
- Verify all Handlebars expressions use correct syntax: \`{{variable}}\`
|
|
220
|
+
- Ensure block helpers are properly closed: \`{{#if}}...{{/if}}\`
|
|
221
|
+
- Check for unmatched braces or quotes
|
|
222
|
+
|
|
223
|
+
2. **Validate Template Variables**:
|
|
224
|
+
- Use only supported variables: \`serverCount\`, \`serverNames\`, \`hasServers\`, etc.
|
|
225
|
+
- Check template documentation for full variable list
|
|
226
|
+
|
|
227
|
+
3. **Test Template**:
|
|
228
|
+
- Start with a simple template: \`# {{title}}\\n{{serverCount}} servers available\`
|
|
229
|
+
- Add complexity gradually
|
|
230
|
+
|
|
231
|
+
4. **Get Help**:
|
|
232
|
+
- Remove custom template to use built-in version
|
|
233
|
+
- Check server logs for detailed error information
|
|
234
|
+
- Consult 1MCP documentation for template examples
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
*To restore normal operation, remove or fix the custom template file*`;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get or compile a Handlebars template with caching
|
|
242
|
+
* @param template Template string
|
|
243
|
+
* @returns Compiled template function
|
|
244
|
+
*/
|
|
245
|
+
getCompiledTemplate(template) {
|
|
246
|
+
// Validate template size before processing
|
|
247
|
+
if (template.length > 1024 * 1024) {
|
|
248
|
+
// 1MB limit per template
|
|
249
|
+
const sizeMB = (template.length / 1024 / 1024).toFixed(1);
|
|
250
|
+
throw new Error(`Template too large: ${sizeMB}MB (max 1.0MB). ` +
|
|
251
|
+
'Consider splitting into smaller files or removing unnecessary content. ' +
|
|
252
|
+
'Large templates can cause memory issues and slow performance.');
|
|
253
|
+
}
|
|
254
|
+
// Use template string as cache key (first 500 chars + hash for uniqueness)
|
|
255
|
+
const cacheKey = template.length > 500
|
|
256
|
+
? template.substring(0, 500) + '_' + template.length + '_' + this.hashString(template)
|
|
257
|
+
: template;
|
|
258
|
+
// Check cache first
|
|
259
|
+
let compiledTemplate = this.templateCache.get(cacheKey);
|
|
260
|
+
if (!compiledTemplate) {
|
|
261
|
+
// Compile and cache template
|
|
262
|
+
compiledTemplate = Handlebars.compile(template, { noEscape: true });
|
|
263
|
+
this.templateCache.set(cacheKey, compiledTemplate);
|
|
264
|
+
logger.debug('InstructionAggregator: Compiled and cached new template', {
|
|
265
|
+
templateLength: template.length,
|
|
266
|
+
cacheSize: this.templateCache.size,
|
|
267
|
+
cacheKeyLength: cacheKey.length,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
return compiledTemplate;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Generate template variables for rendering
|
|
274
|
+
* @param filteredConnections Filtered server connections
|
|
275
|
+
* @param config Client configuration
|
|
276
|
+
* @returns Template variables object
|
|
277
|
+
*/
|
|
278
|
+
generateTemplateVariables(filteredConnections, config) {
|
|
279
|
+
// Get server data for both arrays and individual server objects
|
|
280
|
+
const availableServers = [];
|
|
281
|
+
const serverInstructionSections = [];
|
|
282
|
+
const servers = [];
|
|
283
|
+
// Sort filtered connections by name for consistent output
|
|
284
|
+
const sortedConnections = Array.from(filteredConnections.entries()).sort(([a], [b]) => a.localeCompare(b));
|
|
285
|
+
for (const [serverName, _connection] of sortedConnections) {
|
|
286
|
+
const serverInstructions = this.serverInstructions.get(serverName);
|
|
287
|
+
if (serverInstructions?.trim()) {
|
|
288
|
+
availableServers.push(serverName);
|
|
289
|
+
serverInstructionSections.push(`<${serverName}>\n${serverInstructions.trim()}\n</${serverName}>`);
|
|
290
|
+
// Add individual server data for iteration
|
|
291
|
+
servers.push({
|
|
292
|
+
name: serverName,
|
|
293
|
+
instructions: serverInstructions.trim(),
|
|
294
|
+
hasInstructions: true,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const serverCount = availableServers.length;
|
|
299
|
+
const hasServers = serverCount > 0;
|
|
300
|
+
// Merge configuration with defaults
|
|
301
|
+
const templateConfig = {
|
|
302
|
+
...DEFAULT_TEMPLATE_CONFIG,
|
|
303
|
+
title: config.title || DEFAULT_TEMPLATE_CONFIG.title,
|
|
304
|
+
toolPattern: config.toolPattern || DEFAULT_TEMPLATE_CONFIG.toolPattern,
|
|
305
|
+
examples: config.examples || DEFAULT_TEMPLATE_CONFIG.examples,
|
|
306
|
+
};
|
|
307
|
+
return {
|
|
308
|
+
// Server state
|
|
309
|
+
serverCount,
|
|
310
|
+
hasServers,
|
|
311
|
+
serverList: availableServers.join('\n'),
|
|
312
|
+
serverNames: availableServers,
|
|
313
|
+
servers,
|
|
314
|
+
pluralServers: serverCount === 1 ? 'server' : 'servers',
|
|
315
|
+
isAre: serverCount === 1 ? 'is' : 'are',
|
|
316
|
+
// Content
|
|
317
|
+
instructions: serverInstructionSections.join('\n\n'),
|
|
318
|
+
filterContext: this.getFilterContext(config),
|
|
319
|
+
// Configuration
|
|
320
|
+
toolPattern: templateConfig.toolPattern,
|
|
321
|
+
title: templateConfig.title,
|
|
322
|
+
examples: templateConfig.examples,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Clear template cache (useful for testing)
|
|
327
|
+
*/
|
|
328
|
+
clearTemplateCache() {
|
|
329
|
+
this.templateCache.clear();
|
|
330
|
+
logger.debug('InstructionAggregator: Template cache cleared');
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Get template cache statistics for monitoring
|
|
334
|
+
*/
|
|
335
|
+
getTemplateCacheStats() {
|
|
336
|
+
return {
|
|
337
|
+
size: this.templateCache.size,
|
|
338
|
+
maxSize: this.templateCache.max,
|
|
339
|
+
calculatedSize: this.templateCache.calculatedSize || 0,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Invalidate template cache with reason logging
|
|
344
|
+
* @param reason Reason for cache invalidation
|
|
345
|
+
*/
|
|
346
|
+
invalidateTemplateCache(reason) {
|
|
347
|
+
const sizeBefore = this.templateCache.size;
|
|
348
|
+
this.templateCache.clear();
|
|
349
|
+
logger.debug(`InstructionAggregator: Template cache invalidated due to ${reason}`, {
|
|
350
|
+
clearedTemplates: sizeBefore,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Force template cache invalidation (for external triggers)
|
|
355
|
+
* @param reason Reason for forced invalidation
|
|
356
|
+
*/
|
|
357
|
+
forceTemplateCacheInvalidation(reason = 'external-trigger') {
|
|
358
|
+
this.invalidateTemplateCache(reason);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Cryptographically secure hash function for template cache keys
|
|
362
|
+
* Uses SHA-256 to prevent collision attacks
|
|
363
|
+
*/
|
|
364
|
+
hashString(str) {
|
|
365
|
+
const crypto = require('crypto');
|
|
366
|
+
return crypto.createHash('sha256').update(str, 'utf8').digest('hex').substring(0, 16);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Cleanup method to remove all event listeners and clear caches
|
|
370
|
+
* Should be called when the aggregator is no longer needed
|
|
371
|
+
*/
|
|
372
|
+
cleanup() {
|
|
373
|
+
logger.debug('InstructionAggregator: Starting cleanup');
|
|
374
|
+
// Clear all event listeners
|
|
375
|
+
this.removeAllListeners();
|
|
376
|
+
// Clear template cache
|
|
377
|
+
this.templateCache.clear();
|
|
378
|
+
// Clear server instructions
|
|
379
|
+
this.serverInstructions.clear();
|
|
380
|
+
// Reset initialization state
|
|
381
|
+
this.isInitialized = false;
|
|
382
|
+
logger.info('InstructionAggregator: Cleanup completed - all listeners and caches cleared');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=instructionAggregator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructionAggregator.js","sourceRoot":"","sources":["../../../src/core/instructions/instructionAggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAGL,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAS5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IAC7C,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,aAAa,GAAY,KAAK,CAAC;IAC/B,aAAa,CAAgD;IAErE;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEzB,8CAA8C;QAC9C,IAAI,CAAC,aAAa,GAAG,IAAI,QAAQ,CAAC;YAChC,GAAG,EAAE,GAAG,EAAE,iCAAiC;YAC3C,OAAO,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,wBAAwB;YACnD,eAAe,EAAE,CAAC,QAAqC,EAAE,GAAW,EAAE,EAAE;gBACtE,oEAAoE;gBACpE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,6BAA6B;YACzD,CAAC;YACD,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,EAAE,0CAA0C;SAChE,CAAC,CAAC;QAEH,mDAAmD;QACnD,IAAI,CAAC,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;YACnC,IAAI,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,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C,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,8BAA8B,CAAC,SAAiB,kBAAkB;QACvE,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACK,UAAU,CAAC,GAAW;QAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,MAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAExD,4BAA4B;QAC5B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAE1B,uBAAuB;QACvB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAE3B,4BAA4B;QAC5B,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAEhC,6BAA6B;QAC7B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAE3B,MAAM,CAAC,IAAI,CAAC,6EAA6E,CAAC,CAAC;IAC7F,CAAC;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Individual server data for template iteration
|
|
3
|
+
*/
|
|
4
|
+
export interface ServerData {
|
|
5
|
+
/** Server name (e.g., "api-server") */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Server instructions content */
|
|
8
|
+
instructions: string;
|
|
9
|
+
/** Whether this server has instructions */
|
|
10
|
+
hasInstructions: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Template variables available for custom instruction templates
|
|
14
|
+
* These variables are provided by 1MCP and can be used in Handlebars templates
|
|
15
|
+
*/
|
|
16
|
+
export interface TemplateVariables {
|
|
17
|
+
/** Number of connected servers (e.g., 3) */
|
|
18
|
+
serverCount: number;
|
|
19
|
+
/** Boolean indicating if any servers are connected */
|
|
20
|
+
hasServers: boolean;
|
|
21
|
+
/** Newline-separated list of server names */
|
|
22
|
+
serverList: string;
|
|
23
|
+
/** Array of server names for iteration with {{#each}} */
|
|
24
|
+
serverNames: string[];
|
|
25
|
+
/** Array of server objects for detailed iteration with {{#each}} */
|
|
26
|
+
servers: ServerData[];
|
|
27
|
+
/** "server" or "servers" based on count */
|
|
28
|
+
pluralServers: string;
|
|
29
|
+
/** "is" or "are" based on count */
|
|
30
|
+
isAre: string;
|
|
31
|
+
/** All server instructions wrapped in XML-like tags */
|
|
32
|
+
instructions: string;
|
|
33
|
+
/** Filter description (e.g., " (filtered by tags: backend)") or empty string */
|
|
34
|
+
filterContext: string;
|
|
35
|
+
/** Tool naming pattern (default: "{server}_1mcp_{tool}") */
|
|
36
|
+
toolPattern: string;
|
|
37
|
+
/** Title for the template (default: "1MCP - Model Context Protocol Proxy") */
|
|
38
|
+
title: string;
|
|
39
|
+
/** Array of tool examples for documentation */
|
|
40
|
+
examples: TemplateExample[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tool example for template documentation
|
|
44
|
+
*/
|
|
45
|
+
export interface TemplateExample {
|
|
46
|
+
/** Tool name with pattern applied (e.g., "filesystem_1mcp_read_file") */
|
|
47
|
+
name: string;
|
|
48
|
+
/** Description of what the tool does */
|
|
49
|
+
description: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Template configuration options
|
|
53
|
+
*/
|
|
54
|
+
export interface TemplateConfig {
|
|
55
|
+
/** Custom Handlebars template string */
|
|
56
|
+
customTemplate?: string;
|
|
57
|
+
/** Override default title */
|
|
58
|
+
title?: string;
|
|
59
|
+
/** Override default tool pattern */
|
|
60
|
+
toolPattern?: string;
|
|
61
|
+
/** Custom tool examples */
|
|
62
|
+
examples?: TemplateExample[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Default template examples
|
|
66
|
+
*/
|
|
67
|
+
export declare const DEFAULT_TEMPLATE_EXAMPLES: TemplateExample[];
|
|
68
|
+
/**
|
|
69
|
+
* Default template configuration values
|
|
70
|
+
*/
|
|
71
|
+
export declare const DEFAULT_TEMPLATE_CONFIG: Required<Omit<TemplateConfig, 'customTemplate'>>;
|
|
72
|
+
/**
|
|
73
|
+
* Default instruction template using Handlebars syntax
|
|
74
|
+
* This template is used when no custom template is provided
|
|
75
|
+
*/
|
|
76
|
+
export declare const DEFAULT_INSTRUCTION_TEMPLATE = "# {{title}}\n\n{{#if hasServers}}\nYou are interacting with 1MCP, a proxy server that aggregates capabilities from multiple MCP (Model Context Protocol) servers. 1MCP acts as a unified gateway, allowing you to access tools and resources from various specialized MCP servers through a single connection.\n\n## How 1MCP Works\n\n- **Unified Access**: Connect to multiple MCP servers through one proxy\n- **Tool Aggregation**: All tools are available with the naming pattern `{{toolPattern}}`\n- **Resource Sharing**: Access files, data, and capabilities across different servers\n- **Intelligent Routing**: Your requests are automatically routed to the appropriate servers\n\n## Currently Connected Servers\n\n{{serverCount}} MCP {{pluralServers}} {{isAre}} currently available{{filterContext}}:\n\n{{serverList}}\n\n## Available Capabilities\n\nAll tools from connected servers are accessible using the format: `{{toolPattern}}`\n\nExamples:\n{{#each examples}}\n- `{{name}}` - {{description}}\n{{/each}}\n\n## Server-Specific Instructions\n\nThe following sections contain instructions from each connected MCP server. Each server's instructions are wrapped in XML-like tags (e.g., `<server-name>instructions</server-name>`) to clearly identify their source and scope.\n\n{{#each servers}}\n{{#if hasInstructions}}\n<{{name}}>\n{{instructions}}\n</{{name}}>\n\n{{/if}}\n{{/each}}\n\n## Tips for Using 1MCP\n\n- Tools are namespaced by server to avoid conflicts\n\n{{else}}\nYou are interacting with 1MCP, a proxy server that aggregates capabilities from multiple MCP (Model Context Protocol) servers.\n\n## Current Status\n\nNo MCP servers are currently connected. 1MCP is ready to connect to servers and provide unified access to their capabilities once they become available.\n\n## What 1MCP Provides\n\n- **Unified Access**: Connect to multiple MCP servers through one proxy\n- **Tool Aggregation**: Access tools using the pattern `{{toolPattern}}`\n- **Resource Sharing**: Share files, data, and capabilities across servers\n- **Intelligent Routing**: Automatic request routing to appropriate servers\n\n1MCP will automatically detect and connect to available MCP servers. Once connected, their tools and capabilities will become available through the unified interface.\n{{/if}}";
|
|
77
|
+
//# sourceMappingURL=templateTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateTypes.d.ts","sourceRoot":"","sources":["../../../src/core/instructions/templateTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IAEb,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IAErB,2CAA2C;IAC3C,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEhC,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IAEpB,sDAAsD;IACtD,UAAU,EAAE,OAAO,CAAC;IAEpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IAEnB,yDAAyD;IACzD,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,oEAAoE;IACpE,OAAO,EAAE,UAAU,EAAE,CAAC;IAEtB,2CAA2C;IAC3C,aAAa,EAAE,MAAM,CAAC;IAEtB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IAGd,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IAErB,gFAAgF;IAChF,aAAa,EAAE,MAAM,CAAC;IAGtB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IAEpB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IAEb,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,eAAe,EAatD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAIpF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,+uEA2DjC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default template examples
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_TEMPLATE_EXAMPLES = [
|
|
5
|
+
{
|
|
6
|
+
name: 'filesystem_1mcp_read_file',
|
|
7
|
+
description: 'Read files through filesystem server',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: 'web_1mcp_search',
|
|
11
|
+
description: 'Search the web through web server',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'database_1mcp_query',
|
|
15
|
+
description: 'Query databases through database server',
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Default template configuration values
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_TEMPLATE_CONFIG = {
|
|
22
|
+
title: '1MCP - Model Context Protocol Proxy',
|
|
23
|
+
toolPattern: '{server}_1mcp_{tool}',
|
|
24
|
+
examples: DEFAULT_TEMPLATE_EXAMPLES,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Default instruction template using Handlebars syntax
|
|
28
|
+
* This template is used when no custom template is provided
|
|
29
|
+
*/
|
|
30
|
+
export const DEFAULT_INSTRUCTION_TEMPLATE = `# {{title}}
|
|
31
|
+
|
|
32
|
+
{{#if hasServers}}
|
|
33
|
+
You are interacting with 1MCP, a proxy server that aggregates capabilities from multiple MCP (Model Context Protocol) servers. 1MCP acts as a unified gateway, allowing you to access tools and resources from various specialized MCP servers through a single connection.
|
|
34
|
+
|
|
35
|
+
## How 1MCP Works
|
|
36
|
+
|
|
37
|
+
- **Unified Access**: Connect to multiple MCP servers through one proxy
|
|
38
|
+
- **Tool Aggregation**: All tools are available with the naming pattern \`{{toolPattern}}\`
|
|
39
|
+
- **Resource Sharing**: Access files, data, and capabilities across different servers
|
|
40
|
+
- **Intelligent Routing**: Your requests are automatically routed to the appropriate servers
|
|
41
|
+
|
|
42
|
+
## Currently Connected Servers
|
|
43
|
+
|
|
44
|
+
{{serverCount}} MCP {{pluralServers}} {{isAre}} currently available{{filterContext}}:
|
|
45
|
+
|
|
46
|
+
{{serverList}}
|
|
47
|
+
|
|
48
|
+
## Available Capabilities
|
|
49
|
+
|
|
50
|
+
All tools from connected servers are accessible using the format: \`{{toolPattern}}\`
|
|
51
|
+
|
|
52
|
+
Examples:
|
|
53
|
+
{{#each examples}}
|
|
54
|
+
- \`{{name}}\` - {{description}}
|
|
55
|
+
{{/each}}
|
|
56
|
+
|
|
57
|
+
## Server-Specific Instructions
|
|
58
|
+
|
|
59
|
+
The following sections contain instructions from each connected MCP server. Each server's instructions are wrapped in XML-like tags (e.g., \`<server-name>instructions</server-name>\`) to clearly identify their source and scope.
|
|
60
|
+
|
|
61
|
+
{{#each servers}}
|
|
62
|
+
{{#if hasInstructions}}
|
|
63
|
+
<{{name}}>
|
|
64
|
+
{{instructions}}
|
|
65
|
+
</{{name}}>
|
|
66
|
+
|
|
67
|
+
{{/if}}
|
|
68
|
+
{{/each}}
|
|
69
|
+
|
|
70
|
+
## Tips for Using 1MCP
|
|
71
|
+
|
|
72
|
+
- Tools are namespaced by server to avoid conflicts
|
|
73
|
+
|
|
74
|
+
{{else}}
|
|
75
|
+
You are interacting with 1MCP, a proxy server that aggregates capabilities from multiple MCP (Model Context Protocol) servers.
|
|
76
|
+
|
|
77
|
+
## Current Status
|
|
78
|
+
|
|
79
|
+
No MCP servers are currently connected. 1MCP is ready to connect to servers and provide unified access to their capabilities once they become available.
|
|
80
|
+
|
|
81
|
+
## What 1MCP Provides
|
|
82
|
+
|
|
83
|
+
- **Unified Access**: Connect to multiple MCP servers through one proxy
|
|
84
|
+
- **Tool Aggregation**: Access tools using the pattern \`{{toolPattern}}\`
|
|
85
|
+
- **Resource Sharing**: Share files, data, and capabilities across servers
|
|
86
|
+
- **Intelligent Routing**: Automatic request routing to appropriate servers
|
|
87
|
+
|
|
88
|
+
1MCP will automatically detect and connect to available MCP servers. Once connected, their tools and capabilities will become available through the unified interface.
|
|
89
|
+
{{/if}}`;
|
|
90
|
+
//# sourceMappingURL=templateTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateTypes.js","sourceRoot":"","sources":["../../../src/core/instructions/templateTypes.ts"],"names":[],"mappings":"AAuFA;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D;QACE,IAAI,EAAE,2BAA2B;QACjC,WAAW,EAAE,sCAAsC;KACpD;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,mCAAmC;KACjD;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,yCAAyC;KACvD;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqD;IACvF,KAAK,EAAE,qCAAqC;IAC5C,WAAW,EAAE,sBAAsB;IACnC,QAAQ,EAAE,yBAAyB;CACpC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2DpC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template validation result with error details if invalid
|
|
3
|
+
*/
|
|
4
|
+
export interface TemplateValidationResult {
|
|
5
|
+
valid: boolean;
|
|
6
|
+
error?: string;
|
|
7
|
+
suggestions?: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for template validation
|
|
11
|
+
*/
|
|
12
|
+
export interface TemplateValidationConfig {
|
|
13
|
+
maxSizeBytes?: number;
|
|
14
|
+
allowUnsafeContent?: boolean;
|
|
15
|
+
customDangerousPatterns?: RegExp[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Default validation configuration
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_TEMPLATE_VALIDATION_CONFIG: Required<TemplateValidationConfig>;
|
|
21
|
+
/**
|
|
22
|
+
* Built-in dangerous patterns for template content
|
|
23
|
+
*/
|
|
24
|
+
export declare const DANGEROUS_TEMPLATE_PATTERNS: RegExp[];
|
|
25
|
+
/**
|
|
26
|
+
* Validate Handlebars template content for safety and syntax
|
|
27
|
+
* @param templateContent Template content to validate
|
|
28
|
+
* @param templatePath Path for error reporting (optional)
|
|
29
|
+
* @param config Validation configuration (optional)
|
|
30
|
+
* @returns Validation result with error details if invalid
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateTemplateContent(templateContent: string, templatePath?: string, config?: TemplateValidationConfig): TemplateValidationResult;
|
|
33
|
+
/**
|
|
34
|
+
* Validate template file size before reading
|
|
35
|
+
* @param filePath Path to template file
|
|
36
|
+
* @param maxSizeBytes Maximum allowed file size in bytes
|
|
37
|
+
* @returns True if file size is acceptable
|
|
38
|
+
*/
|
|
39
|
+
export declare function isTemplateSizeAcceptable(filePath: string, maxSizeBytes?: number): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Quick validation for template content safety (without compilation)
|
|
42
|
+
* @param templateContent Template content to check
|
|
43
|
+
* @param config Validation configuration
|
|
44
|
+
* @returns True if content appears safe
|
|
45
|
+
*/
|
|
46
|
+
export declare function isTemplateContentSafe(templateContent: string, config?: TemplateValidationConfig): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get human-readable validation error message with suggestions
|
|
49
|
+
* @param result Validation result from validateTemplateContent
|
|
50
|
+
* @returns Formatted error message with suggestions
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatValidationError(result: TemplateValidationResult): string;
|
|
53
|
+
//# sourceMappingURL=templateValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateValidator.d.ts","sourceRoot":"","sources":["../../../src/core/instructions/templateValidator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;CACpC;AAED;;GAEG;AACH,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,wBAAwB,CAIjF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAI/C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,GAAE,wBAA6B,GACpC,wBAAwB,CA0E1B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,MAAwD,GACrE,OAAO,CAQT;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,GAAE,wBAA6B,GAAG,OAAO,CAS7G;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,CAe9E"}
|