askeroo
Version:
A modern CLI prompt library with flow control, history navigation, and conditional prompts
150 lines • 4.39 kB
TypeScript
/**
* PromptRuntime - Main runtime class for executing prompt flows
*
* Orchestrates interactive CLI prompts with clean state management,
* navigation, discovery, and plugin integration.
*/
import { PromptOpts, GroupMeta, GroupOpts, UI, BackToken } from "../types/index.js";
import { PromptTreeManager } from "./prompt-tree.js";
export declare class PromptRuntime {
private idGenerator;
private state;
private fieldDiscovery;
private ui;
private tree;
private engine;
private pluginPrompts;
private cancelCallbacks;
private sigintHandler;
private cancelModeActive;
private ctrlCPressCount;
readonly BACK: BackToken;
constructor(ui: UI);
/**
* Execute a prompt flow
*/
executeFlow<T>(flowDefinition: (api: {
BACK: BackToken;
} & Record<string, any>) => Promise<T>): Promise<T>;
/**
* Ask a prompt question (wrapper for executeFlow compatibility)
*/
ask(opts: PromptOpts): Promise<any>;
/**
* Create a group of prompts (public API wrapper)
*/
/**
* Create a group of prompts (called by the group plugin)
*
* Note: The public group() API is now exposed through the group plugin.
* This method is called internally by the plugin to handle group execution.
*/
group(meta: GroupMeta, body: () => Promise<any>, opts?: GroupOpts): Promise<any>;
/**
* Create a group of prompts (internal implementation)
*/
createGroup(meta: GroupMeta, body: () => Promise<any>, opts?: GroupOpts): Promise<any>;
/**
* Execute group body (called by group plugin)
* This is the main entry point for the group plugin's execute hook
*/
executeGroupBody(opts: any, body: () => Promise<any>): Promise<any>;
/**
* Re-scan fields for a static group
* Used by UI for field re-rendering
*/
rescanStaticGroupFields(groupId: string): Promise<import("./discovery-service.js").DiscoveredField[] | undefined>;
/**
* Process a single prompt step - handles both groups and fields
*/
private processPromptStep;
/**
* Handle a group step
*/
private handleGroupStep;
/**
* Handle a field step
*/
private handleFieldStep;
/**
* Handle field registration during scanning mode
*/
private handleFieldDuringScanning;
/**
* Prompt the user for an answer
*/
private promptUserForAnswer;
/**
* Initialize plugin prompt functions
*/
private initializePluginPrompts;
/**
* Check if a value is a BACK token
*/
private isBackToken;
/**
* Get plugin prompts for external access
*/
getPluginPrompts(): Record<string, any>;
/**
* Get the tree manager (for UI access)
*/
getTree(): PromptTreeManager;
/**
* Get current runtime state snapshot (for debugging)
*/
getDebugInfo(): {
state: {
answerCount: number;
totalPrompts: number;
currentIndex: number;
isExecuting: boolean;
isReplaying: boolean;
groupDepth: number;
currentGroup: string | undefined;
processedGroupsCount: number;
};
tree: {
nodeCount: number;
historyLength: number;
activeNode: string | undefined;
};
fieldDiscovery: {
isScanning: boolean;
discoveredGroupsCount: number;
storedBodiesCount: number;
groups: string[];
};
idGenerator: {
groupCount: number;
};
};
/**
* Set up SIGINT handler to call cancel callbacks when Ctrl+C is pressed
*/
private setupCancelHandler;
/**
* Clean up SIGINT handler and cancel callbacks
*/
private cleanupCancelHandler;
/**
* Register a cancel callback
*/
registerCancelCallback(callback: (context: {
results: Record<string, any>;
cleanup: () => void;
}) => void): void;
/**
* Check if any cancel callbacks are registered
*/
hasCancelCallbacks(): boolean;
/**
* Check if we're currently in cancel mode
*/
isInCancelMode(): boolean;
/**
* Handle Ctrl+C from UI (called by useInput hook in PromptApp)
*/
handleCtrlC(): void;
}
//# sourceMappingURL=prompt-runtime.d.ts.map