openclaw-knowledge-engine/index.ts
Claudia 8964d93c60 feat: knowledge-engine v0.1.0 — all Cerberus findings fixed
- 83/83 tests passing (was 32/45)
- New: src/http-client.ts (shared HTTP/HTTPS client, fixes C2+H1)
- Fixed: proper_noun regex exclusions (C6)
- Fixed: shutdown hooks registered in hooks.ts (C3)
- Fixed: all timers use .unref() (H6)
- Fixed: resolveConfig split into smaller functions (C4)
- Fixed: extract() split with processMatch helper (C5)
- Fixed: FactStore.addFact isLoaded guard (H3)
- Fixed: validateConfig split (H2)
- Fixed: type-safe config merge, removed as any (H4)
- Added: http-client tests, expanded coverage (H5)
- Fixed: LLM batch await (S1), fresh RegExp per call (S2)
- 1530 LOC source, 1298 LOC tests, strict TypeScript
2026-02-17 16:10:13 +01:00

38 lines
1.2 KiB
TypeScript

// index.ts
import { resolveConfig } from './src/config.js';
import { HookManager } from './src/hooks.js';
import type { OpenClawPluginApi } from './src/types.js';
// The main entry point for the OpenClaw plugin.
// This function is called by the OpenClaw host during plugin loading.
export default (api: OpenClawPluginApi, context: { workspace: string }): void => {
const { pluginConfig, logger } = api;
const { workspace: openClawWorkspace } = context;
// 1. Resolve and validate the configuration
const config = resolveConfig(pluginConfig, logger, openClawWorkspace);
if (!config) {
logger.error('Failed to initialize Knowledge Engine: Invalid configuration. The plugin will be disabled.');
return;
}
if (!config.enabled) {
logger.info('Knowledge Engine is disabled in the configuration.');
return;
}
// 2. Initialize the Hook Manager with the resolved config
try {
const hookManager = new HookManager(api, config);
// 3. Register all the event hooks
hookManager.registerHooks();
logger.info('Knowledge Engine plugin initialized successfully.');
} catch (err) {
logger.error('An unexpected error occurred during Knowledge Engine initialization.', err as Error);
}
};