claude-flow-novice
Version:
Claude Flow Novice - Advanced orchestration platform for multi-agent AI workflows with CFN Loop architecture Includes Local RuVector Accelerator and all CFN skills for complete functionality.
58 lines (57 loc) • 2.05 kB
JavaScript
/**
* Agent Registry with Memory Integration
* Provides persistent storage and coordination for agent management
*/ import { EventEmitter } from 'node:events';
/**
* Centralized agent registry with persistent storage
*/ export class AgentRegistry extends EventEmitter {
memory;
namespace;
cache = new Map();
cacheExpiry = 60000;
lastCacheUpdate = 0;
constructor(memory, namespace = 'agents'){
super();
this.memory = memory;
this.namespace = namespace;
}
async initialize() {
await this.loadFromMemory();
this.emit('registry:initialized');
}
async loadFromMemory() {
try {
const storedAgents = await this.memory.get(`${this.namespace}:registry`);
if (storedAgents) {
// Restore cached agents from memory
for (const [key, entry] of Object.entries(storedAgents)){
this.cache.set(key, entry);
}
}
} catch (error) {
console.error('Failed to load agents from memory:', error);
}
}
calculateAgentScore(agent, taskType, requiredCapabilities) {
// Comprehensive scoring logic
let score = 0;
// Basic type matching
if (agent.type === taskType) {
score += 50;
}
// Capability matching
if (agent.capabilities.domains && agent.capabilities.domains.includes(taskType) || agent.capabilities.languages && agent.capabilities.languages.includes(taskType)) {
score += 30;
}
// Required capabilities
for (const capability of requiredCapabilities){
if (agent.capabilities.domains && agent.capabilities.domains.includes(capability) || agent.capabilities.languages && agent.capabilities.languages.includes(capability)) {
score += 10;
}
}
// Health bonus
score += Math.floor(agent.health * 10);
return score;
}
}
//# sourceMappingURL=agent-registry.js.map