SequentialGraphitiIntegration.js•3.78 kB
import { FactStore } from '../storage/FactStore.js';
import { QualityScorer } from './QualityScorer.js';
import { SequentialThinkingProcessor } from './SequentialThinkingProcessor.js';
import { HookManager } from '../hooks/HookManager.js';
import { FactTypeManager } from './FactTypeManager.js';
import { ConfigurationManager } from '../config/ConfigurationManager.js';
import { MemoryTools } from '../tools/MemoryTools.js';
import { ConfigurationTools } from '../tools/ConfigurationTools.js';
import { SlashCommands } from '../commands/SlashCommands.js';
export class SequentialGraphitiIntegration {
constructor() {
this.factStore = null;
this.qualityScorer = null;
this.processor = null;
this.hookManager = null;
this.factTypeManager = null;
this.configManager = null;
this.memoryTools = null;
this.configurationTools = null;
this.slashCommands = null;
this.initialized = false;
}
async initialize() {
if (this.initialized) return;
try {
this.configManager = new ConfigurationManager();
await this.configManager.initialize();
this.factTypeManager = new FactTypeManager(this.configManager);
await this.factTypeManager.initialize();
this.qualityScorer = new QualityScorer(this.configManager);
this.factStore = new FactStore(this.configManager);
await this.factStore.initialize();
this.processor = new SequentialThinkingProcessor(
this.factStore,
this.qualityScorer,
this.factTypeManager
);
this.hookManager = new HookManager(this.processor);
await this.hookManager.initialize();
this.memoryTools = new MemoryTools(
this.factStore,
this.processor,
this.qualityScorer
);
this.configurationTools = new ConfigurationTools(
this.configManager,
this.factTypeManager
);
this.slashCommands = new SlashCommands(
this.memoryTools,
this.configurationTools,
this.factStore
);
// Connect slash commands to hook manager
this.hookManager.setSlashCommandProcessor(this.slashCommands);
this.initialized = true;
console.log('Sequential-Graphiti integration initialized successfully');
} catch (error) {
console.error('Failed to initialize Sequential-Graphiti integration:', error);
throw error;
}
}
async registerTools(server) {
if (!this.initialized) {
throw new Error('Integration must be initialized before registering tools');
}
await this.memoryTools.registerTools(server);
await this.configurationTools.registerTools(server);
}
async shutdown() {
try {
if (this.hookManager) {
await this.hookManager.shutdown();
}
if (this.factStore) {
await this.factStore.shutdown();
}
console.log('Sequential-Graphiti integration shut down successfully');
} catch (error) {
console.error('Error during shutdown:', error);
}
}
async processSlashCommand(prompt) {
if (!this.initialized) {
throw new Error('Integration must be initialized before processing slash commands');
}
return await this.slashCommands.processSlashCommand(prompt);
}
getAvailableSlashCommands() {
if (!this.slashCommands) return [];
return this.slashCommands.getAvailableCommands();
}
getStatus() {
return {
initialized: this.initialized,
components: {
factStore: !!this.factStore,
qualityScorer: !!this.qualityScorer,
processor: !!this.processor,
hookManager: !!this.hookManager,
factTypeManager: !!this.factTypeManager,
configManager: !!this.configManager,
slashCommands: !!this.slashCommands,
},
};
}
}