feat: add explicit plugins config to control plugin auto-detection
Previously, plugins: [] still auto-detected cortex because autoDetect() always tried importing @soulcraft/cortex regardless of config. Now: - undefined (default): auto-detect installed plugins - false: no plugins, skip auto-detection entirely - []: no plugins, skip auto-detection entirely - ['@soulcraft/cortex']: load only specified, no auto-detection Also adds typed plugins field to BrainyConfig interface.
This commit is contained in:
parent
389e9d6258
commit
6625385913
2 changed files with 35 additions and 3 deletions
|
|
@ -6438,6 +6438,8 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
||||||
hnsw: config?.hnsw ?? undefined as any,
|
hnsw: config?.hnsw ?? undefined as any,
|
||||||
// Embedding initialization - false = lazy init on first embed()
|
// Embedding initialization - false = lazy init on first embed()
|
||||||
eagerEmbeddings: config?.eagerEmbeddings ?? false,
|
eagerEmbeddings: config?.eagerEmbeddings ?? false,
|
||||||
|
// Plugin configuration - undefined = auto-detect
|
||||||
|
plugins: config?.plugins ?? undefined as any,
|
||||||
// Integration Hub - undefined/false = disabled
|
// Integration Hub - undefined/false = disabled
|
||||||
integrations: config?.integrations ?? undefined as any
|
integrations: config?.integrations ?? undefined as any
|
||||||
}
|
}
|
||||||
|
|
@ -6691,9 +6693,31 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
||||||
* Called internally during init().
|
* Called internally during init().
|
||||||
*/
|
*/
|
||||||
private async loadPlugins(): Promise<void> {
|
private async loadPlugins(): Promise<void> {
|
||||||
// Auto-detect installed plugins (e.g., @soulcraft/cortex)
|
// plugins config:
|
||||||
const pluginPackages = (this.config as any).plugins as string[] | undefined
|
// undefined (default) → auto-detect installed plugins
|
||||||
await this.pluginRegistry.autoDetect(pluginPackages || [])
|
// false → no plugins, skip auto-detection
|
||||||
|
// [] → no plugins, skip auto-detection
|
||||||
|
// ['@soulcraft/cortex'] → load only these, no auto-detection
|
||||||
|
const pluginConfig = this.config.plugins
|
||||||
|
if (pluginConfig === false) {
|
||||||
|
// Explicitly disabled — no plugins
|
||||||
|
} else if (Array.isArray(pluginConfig)) {
|
||||||
|
// Explicit list: only register the specified packages, no auto-detection
|
||||||
|
for (const pkg of pluginConfig) {
|
||||||
|
try {
|
||||||
|
const mod = await import(pkg)
|
||||||
|
const plugin: BrainyPlugin = mod.default || mod
|
||||||
|
if (plugin && typeof plugin.activate === 'function' && plugin.name) {
|
||||||
|
this.pluginRegistry.register(plugin)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Package not found — skip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Default: auto-detect known plugins
|
||||||
|
await this.pluginRegistry.autoDetect()
|
||||||
|
}
|
||||||
|
|
||||||
// Create plugin context
|
// Create plugin context
|
||||||
const context: BrainyPluginContext = {
|
const context: BrainyPluginContext = {
|
||||||
|
|
|
||||||
|
|
@ -747,6 +747,14 @@ export interface BrainyConfig {
|
||||||
// WASM compilation to happen during container startup, not on first request
|
// WASM compilation to happen during container startup, not on first request
|
||||||
eagerEmbeddings?: boolean
|
eagerEmbeddings?: boolean
|
||||||
|
|
||||||
|
// Plugin configuration
|
||||||
|
// Controls which plugins are loaded during init()
|
||||||
|
// - undefined (default): Auto-detect installed plugins (@soulcraft/cortex, etc.)
|
||||||
|
// - false: No plugins — skip auto-detection entirely
|
||||||
|
// - []: No plugins — skip auto-detection entirely
|
||||||
|
// - ['@soulcraft/cortex']: Load only specified plugins, no auto-detection
|
||||||
|
plugins?: string[] | false
|
||||||
|
|
||||||
// Logging configuration
|
// Logging configuration
|
||||||
verbose?: boolean // Enable verbose logging
|
verbose?: boolean // Enable verbose logging
|
||||||
silent?: boolean // Suppress all logging output
|
silent?: boolean // Suppress all logging output
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue