agentic-qe
Version:
Agentic Quality Engineering Fleet System - AI-driven quality management platform
168 lines • 4.6 kB
TypeScript
/**
* Hook Executor Service
*
* Executes Claude Flow hooks for agent lifecycle events and coordination.
* Bridges MCP agents with Claude Flow's memory and event system.
*
* @version 1.0.0
* @author Agentic QE Team
*/
export type HookType = 'pre_task' | 'post_task' | 'post_edit' | 'session_start' | 'session_end' | 'notify' | 'pre-task' | 'post-task';
export interface HookParams {
description?: string;
agentType?: string;
agentId?: string;
taskType?: string;
taskId?: string;
results?: any;
status?: string;
result?: any;
metadata?: any;
file?: string;
fileName?: string;
memoryKey?: string;
message?: string;
level?: 'info' | 'warn' | 'error';
sessionId?: string;
exportMetrics?: boolean;
}
export interface HookExecutionResult {
success: boolean;
hookType: HookType;
commands: string[];
outputs: string[];
errors: string[];
executionTime: number;
}
/**
* HookExecutor - Execute Claude Flow hooks for agent coordination
*
* Responsibilities:
* - Execute pre/post task hooks
* - Coordinate memory storage/retrieval
* - Send notifications to Claude Flow
* - Handle session lifecycle
* - Bridge MCP agents with Claude Flow ecosystem
*/
export declare class HookExecutor {
private logger;
private enabled;
private dryRun;
private timeout;
constructor(config?: {
enabled?: boolean;
dryRun?: boolean;
timeout?: number;
});
/**
* Execute a hook with specified parameters
*
* @param hookType - Type of hook to execute
* @param params - Hook parameters
* @returns Execution result
*/
executeHook(hookType: HookType, params: HookParams): Promise<HookExecutionResult>;
/**
* Execute pre-task hook
*
* @param params - Pre-task parameters
* @returns Execution result
*/
executePreTask(params: HookParams): Promise<HookExecutionResult>;
/**
* Execute post-task hook
*
* @param params - Post-task parameters
* @returns Execution result
*/
executePostTask(params: HookParams): Promise<HookExecutionResult>;
/**
* Execute post-edit hook
*
* @param params - Post-edit parameters
* @returns Execution result
*/
executePostEdit(params: HookParams): Promise<HookExecutionResult>;
/**
* Send notification to Claude Flow
*
* @param params - Notification parameters
* @returns Execution result
*/
notify(params: HookParams): Promise<HookExecutionResult>;
/**
* Store data in Claude Flow memory
*
* @param key - Memory key
* @param value - Value to store (will be JSON stringified)
* @returns Execution result
*/
storeMemory(key: string, value: any): Promise<HookExecutionResult>;
/**
* Retrieve data from Claude Flow memory
*
* @param key - Memory key
* @returns Retrieved value or null
*/
retrieveMemory(key: string): Promise<any>;
/**
* Enable/disable hook execution
*
* @param enabled - True to enable, false to disable
*/
setEnabled(enabled: boolean): void;
/**
* Enable/disable dry-run mode
*
* @param dryRun - True for dry-run, false for real execution
*/
setDryRun(dryRun: boolean): void;
/**
* Build hook commands based on type and parameters
*
* @param hookType - Hook type
* @param params - Hook parameters
* @returns Array of commands to execute
*/
private buildHookCommands;
/**
* Execute a shell command with timeout
*
* @param command - Command to execute
* @returns Command output
*/
private executeCommand;
/**
* Escape shell argument to prevent injection
*
* @param arg - Argument to escape
* @returns Escaped argument
*/
private escapeShellArg;
/**
* Create success result
*
* @param hookType - Hook type
* @param commands - Executed commands
* @param outputs - Command outputs
* @param errors - Errors (empty for success)
* @returns Execution result
*/
private createSuccessResult;
}
/**
* Get or create global hook executor
*
* @param config - Optional configuration
* @returns Global hook executor instance
*/
export declare function getHookExecutor(config?: {
enabled?: boolean;
dryRun?: boolean;
timeout?: number;
}): HookExecutor;
/**
* Reset global hook executor (for testing)
*/
export declare function resetHookExecutor(): void;
//# sourceMappingURL=HookExecutor.d.ts.map