/**
 * Command Handler - Parses and executes commands
 *
 * Handles command execution using the unified command system.
 */
import type { MessageBus } from '../../infra/bus/index.js';
import type { Config } from '../../config/schema.js';
import type { SessionConfigStore, SessionStore } from '../../session/index.js';
import type { ThinkLevel } from '../transcript/thinking-types.js';
import type { CompactionResult } from '../memory/compaction.js';
import type { PersistentGoalApis } from '../goals/persistent-goal-apis.js';
export interface CommandContext {
    sessionKey: string;
    channel: string;
    chatId: string;
    senderId: string;
    isGroup: boolean;
    /** From inbound message metadata (thread/account, etc.) for `/goal` continuation routing. */
    inboundMetadata?: Record<string, unknown>;
}
export interface CommandHandlerConfig {
    config: Config;
    bus: MessageBus;
    sessionStore: SessionStore;
    sessionConfigStore?: SessionConfigStore;
    /** After /think persists, sync pi-agent */
    applySessionThinkingLevel?: (sessionKey: string, level: ThinkLevel) => void;
    getCurrentModel: () => string;
    switchModelForSession: (sessionKey: string, modelId: string) => Promise<boolean>;
    /** Drop in-memory agent after session file is cleared (e.g. /new) */
    invalidateAgentSession?: (sessionKey: string) => void;
    /** Reset session in place (archive transcript, new session id; preserve overrides) */
    resetSession?: (sessionKey: string) => Promise<{
        sessionId: string;
        previousSessionId: string;
    } | null>;
    /** Cancel streaming preview + in-flight LLM work for this session (e.g. /abort) */
    abortSessionTurn?: (sessionKey: string) => Promise<void>;
    compactSession?: (sessionKey: string, options?: {
        instructions?: string;
        force?: boolean;
    }) => Promise<CompactionResult>;
    btwQuery?: (sessionKey: string, question: string) => Promise<{
        text: string;
        error?: string;
    }>;
    getSessionContextReport?: (sessionKey: string, mode: 'list' | 'detail' | 'json') => Promise<string>;
    getPersistentGoalApisForCommand: (routing: {
        sessionKey: string;
        channel: string;
        chatId: string;
        inboundMetadata?: Record<string, unknown>;
    }) => PersistentGoalApis;
}
export declare class CommandHandler {
    private config;
    private bus;
    private sessionStore;
    private sessionConfigStore?;
    private applySessionThinkingLevel?;
    private getCurrentModel;
    private switchModelForSession;
    private invalidateAgentSession?;
    private abortSessionTurn?;
    private compactSession?;
    private btwQuery?;
    private getSessionContextReport?;
    private getPersistentGoalApisForCommand;
    private resetSession?;
    constructor(handlerConfig: CommandHandlerConfig);
    /** Replace config reference after hot reload or gateway PATCH so commands see current defaults. */
    updateAgentConfig(config: Config): void;
    /**
     * Build the unified command context shared by all execute paths.
     * When `recorder` is set, every reply text is also captured (for SSE / CLI aggregation).
     */
    private buildCommandContext;
    /**
     * Execute a command using the unified command system
     */
    executeCommand(commandName: string, args: string, context: CommandContext): Promise<boolean>;
    /**
     * Run command and return all user-visible text (ctx.reply + result.content) for SSE/CLI.
     * Same bus side effects as {@link executeCommand}.
     */
    executeCommandAndAggregateReply(commandName: string, args: string, context: CommandContext): Promise<{
        handled: boolean;
        aggregatedText: string;
    }>;
}
