UNPKG

@kya-os/cli

Version:

CLI for MCP-I setup and management

199 lines 4.87 kB
/** * Core types and interfaces for the Terminal Effects Engine * Based on TerminalTextEffects Python library architecture */ /** * RGB color string in hex format (without #) */ export type RGBColor = string; /** * XTerm 256 color code */ export type XTermColor = number; /** * Color can be RGB hex or XTerm-256 */ export type Color = RGBColor | XTermColor | null; /** * Color pair for foreground and background */ export interface ColorPair { fg: Color; bg: Color; } /** * Character visual state at a point in time */ export interface CharacterVisual { symbol: string; colors: ColorPair; } /** * Single frame of animation */ export interface Frame { characters: CharacterVisual[]; duration?: number; } /** * Terminal dimensions */ export interface TerminalDimensions { width: number; height: number; } /** * Coordinate in 2D space */ export interface Coordinate { x: number; y: number; } /** * Animation easing function */ export type EasingFunction = (t: number) => number; /** * Effect configuration options */ export interface EffectConfig { /** Target frame rate (fps) */ frameRate: number; /** Use XTerm colors instead of RGB */ useXTermColors: boolean; /** Disable all colors */ noColor: boolean; /** Canvas dimensions */ canvas?: TerminalDimensions; /** Custom parameters for specific effects */ [key: string]: any; } /** * Base interface for all effects */ export interface Effect { /** Effect name for identification */ readonly name: string; /** Effect description */ readonly description: string; /** Initialize the effect with text and config */ initialize(text: string, config: Partial<EffectConfig>): void; /** Render the next frame of the effect */ render(): Promise<string[]>; /** Render fallback plain text version */ renderFallback(): string[]; /** Check if the effect is complete */ isComplete(): boolean; /** Reset the effect to initial state */ reset(): void; /** Cleanup any resources */ cleanup(): void; } /** * Scene represents a sequence of visual changes */ export interface Scene { id: string; frames: Frame[]; isLooping: boolean; currentFrame: number; } /** * Motion path for character movement */ export interface Path { waypoints: Coordinate[]; currentPosition: number; easing?: EasingFunction; } /** * Character state including position and animation */ export interface EffectCharacter { id: string; originalSymbol: string; originalPosition: Coordinate; currentPosition: Coordinate; visual: CharacterVisual; motion?: Path; scene?: Scene; } /** * Effect execution result */ export interface EffectResult { success: boolean; frames?: string[]; error?: Error; duration?: number; } /** * Terminal capability detection result */ export interface TerminalCapabilities { supportsColor: boolean; supports256Color: boolean; supportsTrueColor: boolean; dimensions: TerminalDimensions; isInteractive: boolean; } /** * Effect registry entry */ export interface EffectRegistryEntry { name: string; description: string; factory: () => Effect; } /** * Safety configuration for effects */ export interface SafetyConfig { /** Maximum execution time in milliseconds */ maxExecutionTime: number; /** Maximum memory usage in MB */ maxMemoryUsage: number; /** Enable performance monitoring */ enableMonitoring: boolean; /** Force fallback mode */ forceFallback: boolean; } /** * Performance metrics for monitoring */ export interface PerformanceMetrics { frameCount: number; totalDuration: number; averageFrameTime: number; maxFrameTime: number; memoryUsage: number; } /** * Abstract base class for effects */ export declare abstract class BaseEffect implements Effect { abstract readonly name: string; abstract readonly description: string; protected text: string; protected config: EffectConfig; protected characters: EffectCharacter[]; protected frameCount: number; protected isInitialized: boolean; initialize(text: string, config: Partial<EffectConfig>): void; abstract render(): Promise<string[]>; abstract renderFallback(): string[]; abstract isComplete(): boolean; reset(): void; cleanup(): void; protected abstract onInitialize(): void; protected abstract onReset(): void; protected onCleanup(): void; protected createCharacters(text: string): EffectCharacter[]; protected getCanvasDimensions(): TerminalDimensions; } /** * Type guard for Color types */ export declare function isRGBColor(color: Color): color is RGBColor; export declare function isXTermColor(color: Color): color is XTermColor; //# sourceMappingURL=types.d.ts.map