import { Value } from '../utils'; import { Environment, OnBlock, RobinPath } from '../index'; export declare class RobinPathThread { private environment; private executor; readonly id: string; private parent; private serializer; constructor(baseEnvironment: Environment, id: string, parent?: RobinPath); /** * Check if a script needs more input (incomplete block) * Returns { needsMore: true, waitingFor: 'endif' | 'enddef' | 'endfor' | 'enddo' | 'subexpr' | 'paren' | 'object' | 'array' } if incomplete, * or { needsMore: false } if complete. */ needsMoreInput(script: string): Promise<{ needsMore: boolean; waitingFor?: 'endif' | 'enddef' | 'endfor' | 'enddo' | 'subexpr' | 'paren' | 'object' | 'array'; }>; /** * Execute a RobinPath script in this thread */ executeScript(script: string): Promise; /** * Execute a single line in this thread (for REPL) */ executeLine(line: string): Promise; /** * Get the last value ($) from this thread */ getLastValue(): Value; /** * Get a variable value from this thread */ getVariable(name: string): Value; /** * Set a variable value in this thread */ setVariable(name: string, value: Value): void; /** * Get all variables in this thread as a plain object */ getVariableState(): Record; /** * Get the current module name (set by "use" command) * Returns null if no module is currently in use */ getCurrentModule(): string | null; /** * Get the parent RobinPath instance */ getParent(): RobinPath | null; /** * Get the environment for this thread (for CLI access to metadata) */ getEnvironment(): Environment; /** * Get the AST without execution state * Returns a JSON-serializable AST array * * Note: This method only parses the script, it does not execute it. */ getAST(script: string): Promise; /** * Get extracted function definitions (def/enddef blocks) from a script * Returns a JSON-serializable array of function definitions * * Note: This method only parses the script, it does not execute it. */ getExtractedFunctions(script: string): Promise; /** * Get all event handlers as a flat array * @returns Array of all OnBlock handlers */ getAllEventHandlers(): OnBlock[]; /** * Get event handlers as serialized AST * @returns Array of serialized event handler AST nodes */ getEventAST(): any[]; /** * Get the AST with execution state for the current thread * Returns a JSON-serializable object with: * - AST nodes with execution state ($ lastValue at each node) * - Available variables (thread-local and global) * - Organized for UI representation * * Note: This method executes the script to capture execution state at each node. */ getASTWithState(script: string): Promise<{ ast: any[]; variables: { thread: Record; global: Record; }; lastValue: Value; callStack: Array<{ locals: Record; lastValue: Value; }>; }>; /** * Execute statements with state tracking */ private executeWithStateTracking; /** * Get all available commands, modules, and functions for this thread * Includes thread-local user-defined functions in addition to shared builtins and modules * * @param context Optional syntax context to filter commands based on what's valid next */ getAvailableCommands(context?: { inIfBlock?: boolean; inDefBlock?: boolean; afterIf?: boolean; afterDef?: boolean; afterElseif?: boolean; }): { native: Array<{ name: string; type: string; description: string; }>; builtin: Array<{ name: string; type: string; description: string; }>; modules: Array<{ name: string; type: string; description: string; author?: string; category?: string; }>; moduleFunctions: Array<{ name: string; type: string; description: string; }>; userFunctions: Array<{ name: string; type: string; description: string; }>; }; }