/** * Unified Orchestrator Client * * Supports two modes: * 1. Direct Mode (DEFAULT): Imports core library directly for maximum performance * 2. Server Mode (--server): Uses HTTP client to connect to remote server * * Usage: * const client = new OrchestratorClient({ mode: 'direct' }); * const client = new OrchestratorClient({ mode: 'server', serverUrl: 'http://localhost:4000' }); */ import type { SubAgentEventCallback } from '@nexus-cortex/core'; export type ClientMode = 'direct' | 'server'; export interface OrchestratorClientOptions { mode?: ClientMode; serverUrl?: string; defaultModelId?: string; projectPath?: string; debug?: boolean; /** * Callbacks for pausing/resuming custom input handling during approval dialogs. * Use this with persistent input systems that manage their own terminal state. */ inputHandlerCallbacks?: { onBeforeApproval: () => void; onAfterApproval: () => void; }; /** * Callback to render tool-specific previews before approval prompts. * Use this to show diffs for Edit tools, file content for Write tools, etc. */ previewRenderer?: (request: { toolName: string; toolInput: any; reason: string; timestamp: Date; }) => void; /** * Callback for sub-agent events (parallel agent activity). * Use this to display real-time sub-agent progress in the UI. */ onSubAgentEvent?: SubAgentEventCallback; } export type ReasoningEffort = 'none' | 'low' | 'medium' | 'high'; export interface MessageOptions { model?: string; system?: string; tools?: any[]; max_tokens?: number; temperature?: number; top_p?: number; stream?: boolean; /** OpenAI GPT-5 reasoning effort level (none, low, medium, high) */ reasoningEffort?: ReasoningEffort; /** Abort signal for cancelling long-running operations (ESC key) */ abortSignal?: AbortSignal; /** * Turn-prediction provenance of THIS message vs the displayed ghost prefill * (spec §5.1): 'none' | 'shown' | 'inserted'. TUI-only; defaults to 'none'. */ prefillProvenance?: 'none' | 'shown' | 'inserted'; } /** Result of a file-backed permission grant/revoke. */ export interface PermissionWriteResult { path: string; profile: string; changed: boolean; } export declare class OrchestratorClient { private mode; private orchestrator?; private serverUrl?; private options; constructor(options?: OrchestratorClientOptions); /** * Set input handler callbacks for pausing/resuming custom input during approval dialogs. * Call this before initialize() if you need to set up callbacks that depend on other * objects created after the client (e.g., persistentInput). */ setInputHandlerCallbacks(callbacks: { onBeforeApproval: () => void; onAfterApproval: () => void; }): void; /** * Set preview renderer for showing tool-specific previews before approval prompts. * Call this before initialize() to configure diff previews for Edit tools, etc. */ setPreviewRenderer(renderer: (request: { toolName: string; toolInput: any; reason: string; timestamp: Date; }) => void): void; /** * Initialize the client */ initialize(): Promise; /** * Release resources held by the orchestrator in direct mode (MCP sockets, * file watchers). Without this, MCP TCP handles keep the event loop alive * and short-lived commands (tools/models list) never exit. Safe to call * multiple times and in server mode (no-op). */ disconnect(): Promise; /** * Resume an existing session */ resumeSession(sessionId: string): Promise; /** * Find Nexus Cortex installation root (for locating .cortex/ config, not for tool cwd) */ static findInstallRoot(): string; /** * @deprecated Use findInstallRoot() for config, process.cwd() for tool cwd */ static findProjectRoot(_startPath: string): string; /** * Resolve the project root + profile name used for file-backed permission * edits. Profile honors PERMISSION_PROFILE (dev|test|prod), default 'dev'. */ static resolvePermissionTarget(): { root: string; profile: 'dev' | 'test' | 'prod'; }; /** * Get the resolved project path — this is the working directory for tool execution. * Always uses the user's cwd unless explicitly overridden via constructor option. */ getProjectPath(): string; /** * Initialize direct mode (import core library) */ private initializeDirect; /** * Initialize server mode (check server health) */ private initializeServer; /** * Send a message */ sendMessage(content: string | any[], options?: MessageOptions): Promise; /** * Send message in direct mode */ private sendMessageDirect; /** * Send message in server mode */ private sendMessageServer; /** * Stream a message with real-time response chunks * * Returns async generator that yields StreamChunk objects: * - text_delta: Text content * - content_block_delta: Thinking/reasoning content (check chunk.data.reasoning === true) * - tool_use_complete: Complete tool ready for execution * - message_start, message_stop, etc. */ streamMessage(content: string | any[], options?: MessageOptions): AsyncGenerator; /** * Stream message in direct mode */ private streamMessageDirect; /** * Create a new session (server mode only) */ private createNewSession; /** * Get current model */ getCurrentModel(): any; /** * Switch model */ switchModel(modelId: string, reason?: string): Promise; /** * Get cache metrics */ getCacheMetrics(): Promise; /** * Get message history */ getMessageHistory(): any[]; /** * Get session ID */ getSessionId(): string | null; /** * Get approval mode */ getApprovalMode(): Promise<{ autoApproveActions: boolean; yoloMode?: boolean; context?: string; }>; /** * Set approval mode */ setApprovalMode(autoApprove: boolean): Promise<{ success: boolean; message?: string; path?: string; }>; /** * Enable YOLO mode - auto-approve ALL operations (white/gray/blacklist) */ enableYoloMode(): Promise; /** * Disable YOLO mode */ disableYoloMode(): Promise; /** * Check if YOLO mode is active */ isYoloModeActive(): boolean; updateRuntimeConfig(updates: Record): void; setDebug(enabled: boolean): void; isDebugActive(): boolean; /** * Set a custom approval handler for tool permissions * * This allows UI frameworks (like React/Ink) to provide their own * approval dialog implementation instead of using the default CLI handler. * * @param handler - Custom ApprovalHandler implementation with requestApproval method */ setApprovalHandler(handler: { requestApproval: (request: any) => Promise; }): void; /** * Set sub-agent event callback for real-time UI updates. * Call this to display sub-agent progress in the UI. * * @param callback - Function to receive sub-agent events */ setSubAgentEventCallback(callback: SubAgentEventCallback): void; /** * Get all registered permission policies */ getPolicies(): Promise; /** * Get audit log for session */ getAuditLog(sessionId?: string): Promise; /** * Get audit statistics */ getAuditStatistics(): Promise; /** * Get all denied operations */ getDeniedOperations(): Promise; /** * Grant permission to a tool (convenience method) * Creates a WhitelistPolicy for the specified tool */ grantToolPermission(toolName: string): Promise; /** * Revoke permission from a tool (convenience method) * Creates a BlacklistPolicy for the specified tool */ revokeToolPermission(toolName: string): Promise; /** * Register a custom permission policy */ registerPolicy(policy: any): Promise; /** * Unregister a permission policy */ unregisterPolicy(policyName: string): Promise; /** * Create checkpoint */ createCheckpoint(name: string): Promise; /** * List checkpoints */ listCheckpoints(): Promise; /** * Get cache report */ getCacheReport(): string; /** * Get client mode */ getMode(): ClientMode; /** * Get server URL (if in server mode) */ getServerUrl(): string | undefined; /** * List all available models * * Uses core library's listAvailableModels method in direct mode. * In server mode, makes HTTP request to server. * * Transforms ModelConfig format to CLI-expected format */ listModels(): Promise; /** * List MCP servers */ listMcpServers(): Promise<{ enabled: boolean; servers: any[]; }>; /** * List all sessions */ listSessions(): Promise<{ sessions: any[]; }>; /** * List all available tools */ listTools(grouped?: boolean): Promise; /** * Get detailed information about a specific tool */ getToolInfo(toolName: string): Promise; /** * Get detailed model information * * Uses core library's listAvailableModels method in direct mode. * In server mode, makes HTTP request to server. */ getModelInfo(modelId: string): Promise; /** * Enable an MCP server * * Uses EnableMcpServer tool executor with managers from orchestrator. * In server mode, makes HTTP request to server. */ enableMCPServer(serverName: string): Promise; /** * Disable an MCP server * * Uses DisableMcpServer tool executor with managers from orchestrator. * In server mode, makes HTTP request to server. */ disableMCPServer(serverName: string): Promise; /** * Get configuration value * * Uses SettingsLoader from core library in direct mode. * In server mode, makes HTTP request to server. */ getConfig(key: string): Promise; /** * Set configuration value * * Uses SettingsWriter from core library in direct mode. * In server mode, makes HTTP request to server. * * Note: Direct mode currently requires restart for changes to take effect. */ setConfig(key: string, value: string): Promise; /** * Get all configuration settings with summary * * Uses SettingsLoader from core library in direct mode. */ getConfigSummary(): Promise<{ providers: string[]; defaultModel: string; helperModel: string; mentorshipEnabled: boolean; debugEnabled: boolean; allSettings: Record; }>; /** * List available configuration keys */ listConfigKeys(): Promise; /** * List system messages * * Returns list of system message files in .cortex/system-messages/ */ listSystemMessages(): Promise>; /** * Get system message content */ getSystemMessageContent(filename: string): Promise; } //# sourceMappingURL=OrchestratorClient.d.ts.map