...
This commit is contained in:
50
static/js/macro-system.js
Normal file
50
static/js/macro-system.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Macro System
|
||||
* Generic plugin-based macro processor
|
||||
*/
|
||||
|
||||
class MacroPlugin {
|
||||
/**
|
||||
* Base class for macro plugins
|
||||
* Subclass and implement these methods:
|
||||
* - canHandle(actor, method): boolean
|
||||
* - process(macro, context): Promise<{ success, content, error }>
|
||||
*/
|
||||
|
||||
canHandle(actor, method) {
|
||||
throw new Error('Must implement canHandle()');
|
||||
}
|
||||
|
||||
async process(macro, context) {
|
||||
throw new Error('Must implement process()');
|
||||
}
|
||||
}
|
||||
|
||||
class MacroRegistry {
|
||||
constructor() {
|
||||
this.plugins = new Map();
|
||||
console.log('[MacroRegistry] Initializing macro registry');
|
||||
}
|
||||
|
||||
register(actor, method, plugin) {
|
||||
const key = `${actor}.${method}`;
|
||||
this.plugins.set(key, plugin);
|
||||
console.log(`[MacroRegistry] Registered plugin: ${key}`);
|
||||
}
|
||||
|
||||
resolve(actor, method) {
|
||||
// Try exact match
|
||||
let key = `${actor}.${method}`;
|
||||
if (this.plugins.has(key)) {
|
||||
console.log(`[MacroRegistry] Found plugin: ${key}`);
|
||||
return this.plugins.get(key);
|
||||
}
|
||||
|
||||
// No plugin found
|
||||
console.warn(`[MacroRegistry] No plugin found for: ${key}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
window.MacroRegistry = MacroRegistry;
|
||||
window.MacroPlugin = MacroPlugin;
|
||||
Reference in New Issue
Block a user