/** * @license * Copyright 2025 Vybestack LLC * SPDX-License-Identifier: Apache-2.0 */ /** * @plan:PLAN-20260216-HOOKSYSTEMREWRITE.P03 * @requirement:HOOK-001,HOOK-003,HOOK-004,HOOK-005,HOOK-006,HOOK-007,HOOK-008,HOOK-142 * @pseudocode:analysis/pseudocode/01-hook-system-lifecycle.md */ import type { Config } from '../config/config.js'; import { HookRegistry, type HookRegistryEntry } from './hookRegistry.js'; import { HookEventHandler } from './hookEventHandler.js'; import { DebugLogger } from '../debug/index.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; /** * HookSystem is the central coordinator for all hook infrastructure. * It owns single shared instances of HookRegistry, HookPlanner, HookRunner, * HookAggregator, and HookEventHandler, reused across all event fires. * * @requirement:HOOK-001 - Created lazily on first call to Config.getHookSystem() * @requirement:HOOK-003 - Calls HookRegistry.initialize() to load hooks from config * @requirement:HOOK-005 - Throws HookSystemNotInitializedError if accessed before initialize() * @requirement:HOOK-006 - Exposes getRegistry(), getEventHandler() as public accessors * @requirement:HOOK-007 - Trigger functions obtain components from HookSystem, never construct new ones * @requirement:HOOK-008 - First hook event fires initialize() before delegating to event handler * @requirement:HOOK-142 - Importable from packages/core/src/hooks/hookSystem.ts */ export declare class HookSystem { private readonly config; private readonly registry; private readonly planner; private readonly runner; private readonly aggregator; private eventHandler; /** * @plan PLAN-20250218-HOOKSYSTEM.P03 * @requirement DELTA-HSYS-001 */ private readonly messageBus; /** * @plan PLAN-20250218-HOOKSYSTEM.P03 * @requirement DELTA-HSYS-001 */ private readonly injectedDebugLogger; /** * @plan PLAN-20250218-HOOKSYSTEM.P03 * @requirement DELTA-HSYS-001 */ constructor(config: Config, messageBus?: MessageBus, injectedDebugLogger?: DebugLogger); /** * Initialize the hook system. Must be called before getRegistry() or getEventHandler(). * Can be called multiple times to reload hooks from config. * * WARNING: Not safe for concurrent calls. Ensure initialize() completes before * calling again. JavaScript is single-threaded but async, so callers must * await each initialize() call before starting another. * * @requirement:HOOK-003 - Calls HookRegistry.initialize() to load hooks from config * @requirement:HOOK-008 - Called by trigger functions on first event fire */ initialize(): Promise; /** * Get the hook registry. * @throws {HookSystemNotInitializedError} if called before initialize() * @requirement:HOOK-005,HOOK-006 */ getRegistry(): HookRegistry; /** * Get the hook event handler. * @throws {HookSystemNotInitializedError} if called before initialize() * @requirement:HOOK-005,HOOK-006 */ getEventHandler(): HookEventHandler; /** * Check if the hook system is initialized. */ isInitialized(): boolean; /** * Enable or disable a specific hook by ID. * * @plan PLAN-20250218-HOOKSYSTEM.P05 * @requirement DELTA-HSYS-002 * @pseudocode message-bus-integration.md lines 30-36 */ setHookEnabled(hookId: string, enabled: boolean): void; /** * Return all registered hook definitions. * * @plan PLAN-20250218-HOOKSYSTEM.P05 * @requirement DELTA-HSYS-002 * @pseudocode message-bus-integration.md lines 30-36 */ getAllHooks(): HookRegistryEntry[]; /** * Dispose the HookSystem, releasing any held resources. * * @plan PLAN-20250218-HOOKSYSTEM.P03 * @requirement DELTA-HEVT-004 */ dispose(): void; }