@webdevtoday/grok-cli
Version:
A sophisticated CLI tool for interacting with xAI Grok 4, featuring conversation history, file reference, custom commands, memory system, and genetic development workflows
109 lines • 2.75 kB
TypeScript
/**
* Base tool classes and interfaces for Grok CLI
*/
import type { ToolResult, PermissionManager } from '../types';
/**
* Abstract base class for all tools
*/
export declare abstract class BaseTool {
readonly name: string;
readonly description: string;
constructor(name: string, description: string);
/**
* Execute the tool with given parameters
*/
abstract execute(params: Record<string, unknown>): Promise<ToolResult>;
/**
* Validate parameters before execution
*/
validateParams(_params: Record<string, unknown>): boolean;
/**
* Check if the tool is allowed to execute with given parameters
*/
validatePermissions(permissions: PermissionManager, params: Record<string, unknown>): boolean;
/**
* Get parameter schema for validation (optional)
*/
getParameterSchema(): Record<string, unknown> | null;
/**
* Get usage examples (optional)
*/
getUsageExamples(): string[];
}
/**
* Tool registry for managing all available tools
*/
export declare class ToolRegistry {
private tools;
/**
* Register a tool
*/
register(tool: BaseTool): void;
/**
* Unregister a tool
*/
unregister(toolName: string): void;
/**
* Get a tool by name
*/
getTool(name: string): BaseTool | undefined;
/**
* Get all registered tools
*/
getAllTools(): BaseTool[];
/**
* Get tool names
*/
getToolNames(): string[];
/**
* Check if a tool is registered
*/
hasTool(name: string): boolean;
/**
* Clear all tools
*/
clear(): void;
/**
* Get tools by category/pattern
*/
getToolsByPattern(pattern: RegExp): BaseTool[];
}
/**
* Tool execution context
*/
export interface ToolContext {
sessionId: string;
cwd: string;
userId?: string;
timestamp: Date;
}
/**
* Tool execution wrapper with hooks and permissions
*/
export declare class ToolExecutor {
private registry;
private permissions;
private hookManager?;
constructor(registry: ToolRegistry, permissions: PermissionManager);
/**
* Set hook manager for lifecycle hooks
*/
setHookManager(hookManager: any): void;
/**
* Get the permission manager
*/
getPermissionManager(): PermissionManager;
/**
* Execute a tool with full lifecycle (hooks, permissions, etc.)
*/
executeTool(toolName: string, params: Record<string, unknown>, context: ToolContext): Promise<ToolResult>;
/**
* Get the tool registry
*/
getRegistry(): ToolRegistry;
/**
* Update permissions manager
*/
setPermissions(permissions: PermissionManager): void;
}
//# sourceMappingURL=base.d.ts.map