NOTE: This is very WIP
A JavaScript SDK for interacting with liblogos_core, providing a clean abstraction over FFI functionality for plugin management, async operations, and event handling.
const LogosAPI = require('logos-api');
// Initialize with default settings
const logos = new LogosAPI();
// Or with custom options
const logos = new LogosAPI({
libPath: '/custom/path/to/liblogos_core.dylib',
pluginsDir: '/custom/plugins/directory',
autoInit: true
});
// Start the system
logos.start();
// Load plugins
const results = logos.processAndLoadPlugins(['waku_module', 'chat', 'template_module']);
console.log('Plugin loading results:', results);
// Check plugin status
const status = logos.getPluginStatus();
console.log('Loaded plugins:', status.loaded);
console.log('Known plugins:', status.known);
// Call a plugin method asynchronously
logos.callPluginMethodAsync('chat', 'initialize', JSON.stringify([]), (success, message, meta) => {
if (success) {
console.log('Chat initialized:', message);
} else {
console.error('Failed to initialize chat:', message);
}
});
// Register event listener
logos.registerEventListener('chat', 'chatMessage', (success, message, meta) => {
if (success && message.event === 'chatMessage') {
const [timestamp, username, text] = message.data;
console.log(`Message from ${username}: ${text}`);
}
});
// Start event processing
logos.startEventProcessing();
// Cleanup when done
process.on('SIGINT', () => {
logos.cleanup();
process.exit(0);
});const options = {
libPath: string, // Custom path to liblogos_core library
pluginsDir: string, // Custom plugins directory
autoInit: boolean // Auto-initialize on construction (default: true)
};init()- Initialize the librarystart()- Start the LogosCore systemcleanup()- Clean up and shutdown
getLoadedPlugins()- Get array of loaded plugin namesgetKnownPlugins()- Get array of known plugin namesgetPluginStatus()- Get object with loaded and known pluginsprocessPlugin(pluginName)- Process a plugin fileloadPlugin(pluginName)- Load a pluginunloadPlugin(pluginName)- Unload a pluginprocessAndLoadPlugin(pluginName)- Process and load in one stepprocessAndLoadPlugins(pluginNames[])- Process and load multiple plugins
callPluginMethodAsync(pluginName, methodName, params, callback)- Call plugin methodregisterEventListener(pluginName, eventName, callback)- Register event listener
startEventProcessing(interval)- Start event processing loopstopEventProcessing()- Stop event processing loopexec()- Execute blocking event loop
- Node.js 18+
- liblogos_core built and available
- ffi-napi and ref-napi dependencies
Before using this SDK, ensure liblogos_core is built:
./scripts/run_core.sh buildThe library should be available at logos-liblogos/build/lib/liblogos_core.{dylib|so|dll} and plugins at logos-liblogos/build/modules/.