/** * CLI Commands Implementation - Direct Core Integration with Space-Separated and Bidirectional Aliases * * Features: * - Direct command mapping system with interactive parameter collection * - Core function calls without command processing layer * - User-friendly messages with technical details for debugging * - Automatic world state management and refreshing * - Help message generation with command documentation * - Dual input handling for commands and messages * - World instance isolation and proper cleanup during refresh * - Space-separated command aliases for natural command syntax * - Bidirectional aliases (e.g., /chat new and /new chat both work) * - Backward compatibility with hyphenated aliases * - Context-sensitive commands that adapt based on world selection * - World data persistence to File Storage or SQLite with folder selection * * Available Commands: * - World: list, show, create, update, delete, select, export, save * - Agent: list, show, create, update, delete, clear * - Chat: list, create, select, switch, delete, rename, export * - System: help, quit, exit * - Short Explicit: lsw (list worlds), lsa (list agents) * * Alias System: * - Space-separated format: /new chat, /add agent, /list worlds (preferred) * - Bidirectional aliases: /chat new = /new chat, /agent add = /add agent * - Backward compatible: /new-chat, /add-agent, /list-worlds (still work) * - Context-sensitive: /new creates world, /add creates agent (when world selected) * - Explicit aliases like /lsw, /lsa provide unambiguous targeting * * World Refresh Mechanism: * - Commands that modify world state signal refresh requirement via `refreshWorld: true` * - CLI properly destroys old world instances and creates fresh ones * - Event subscriptions are cleanly transferred to new world instances * - Prevents memory leaks and ensures event isolation between old/new worlds * - Agent persistence maintained across refresh cycles * * World Save Feature: * - Interactive storage type selection (File or SQLite) * - Custom folder path with default option * - Saves world, all agents, all chat histories, and all events * - Creates target directory if it doesn't exist * - Supports migration between storage types * - Event history preserved across different storage backends * * Recent Changes: * - 2026-03-06: Removed runtime message/export fallback to `world.currentChatId`; CLI execution now requires explicit selected chat state. * - 2026-03-10: Switched CLI user message send path to the queue-only `enqueueAndProcessUserTurn` API. * - 2026-03-04: Added queue metadata (`messageId`, `queueStatus`, `queueRetryCount`) to successful message-send CLI results for queue error visibility. */ import { World } from '../core/types.js'; export interface CLIResponse { success: boolean; message: string; data?: any; technicalDetails?: string; needsWorldRefresh?: boolean; refreshWorld?: boolean; error?: string; } export interface CLIContext { currentWorldName?: string; currentWorld?: World | null; selectedChatId?: string | null; } export type PromptFunction = (question: string, options?: string[]) => Promise; /** * Display chat messages in a formatted, readable way * Shows sender, timestamp, and content for each message * Logic: * - HUMAN messages: deduplicate by messageId (they're replicated across all agents) * - Agent messages: only show if sender matches agentId (the agent that created it) * - System messages: deduplicate by messageId */ export declare function displayChatMessages(worldId: string, chatId?: string | null): Promise; type CLICommandCategory = 'world' | 'agent' | 'chat' | 'system'; interface CLICommandParameter { name: string; required: boolean; description: string; type: 'string' | 'number' | 'boolean'; options?: string[]; } export interface CLICommandDefinition { type: string; requiresWorld: boolean; description: string; usage: string; parameters: CLICommandParameter[]; aliases?: string[]; category: CLICommandCategory; } export declare const CLI_COMMAND_MAP: Record; export declare const CLI_COMMAND_ALIASES: Record; export declare function parseCLICommand(input: string): { command: string; args: string[]; commandType: string; isValid: boolean; error?: string; }; export declare function generateHelpMessage(target?: string): string; export declare function checkTargetExists(targetPath: string, storageType: 'file' | 'sqlite', worldId: string): Promise<{ exists: boolean; message: string; }>; export declare function deleteExistingData(targetPath: string, storageType: 'file' | 'sqlite', worldId: string): Promise<{ success: boolean; error?: string; }>; export declare function performWorldSave(world: World, storageType: 'file' | 'sqlite', targetPath: string): Promise; export declare function processCLICommand(input: string, context: CLIContext, promptFn: PromptFunction): Promise; export declare function processCLIInput(input: string, world: World | null, sender?: string, selectedChatId?: string | null): Promise; export {};