/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import type { CompressionStatus, MCPServerConfig, ThoughtSummary, ToolCallConfirmationDetails, ToolConfirmationOutcome, ToolResultDisplay, AgentStatus, ArenaDiffSummary } from '@hoptrendy/hopcode-core';
import type { PartListUnion } from '@google/genai';
import { type ReactNode } from 'react';
export type { ThoughtSummary };
export declare enum AuthState {
    Unauthenticated = "unauthenticated",
    Updating = "updating",
    Authenticated = "authenticated"
}
export declare enum StreamingState {
    Idle = "idle",
    Responding = "responding",
    WaitingForConfirmation = "waiting_for_confirmation"
}
export declare enum HopCodeEventType {
    Content = "content",
    ToolCallRequest = "tool_call_request"
}
export declare enum ToolCallStatus {
    Pending = "Pending",
    Canceled = "Canceled",
    Confirming = "Confirming",
    Executing = "Executing",
    Success = "Success",
    Error = "Error"
}
export interface ToolCallEvent {
    type: 'tool_call';
    status: ToolCallStatus;
    callId: string;
    name: string;
    args: Record<string, never>;
    resultDisplay: ToolResultDisplay | undefined;
    confirmationDetails: ToolCallConfirmationDetails | undefined;
}
export interface IndividualToolCallDisplay {
    callId: string;
    name: string;
    description: string;
    resultDisplay: ToolResultDisplay | string | undefined;
    status: ToolCallStatus;
    confirmationDetails: ToolCallConfirmationDetails | undefined;
    renderOutputAsMarkdown?: boolean;
    ptyId?: number;
    executionStartTime?: number;
    /** If this tool call operated on a managed-auto-memory file, indicates whether it was a read or write. */
    isMemoryOp?: 'read' | 'write';
}
export interface CompressionProps {
    isPending: boolean;
    originalTokenCount: number | null;
    newTokenCount: number | null;
    compressionStatus: CompressionStatus | null;
}
export interface SummaryProps {
    isPending: boolean;
    stage: 'generating' | 'saving' | 'completed';
    filePath?: string;
}
export interface HistoryItemBase {
    text?: string;
}
export type HistoryItemUser = HistoryItemBase & {
    type: 'user';
    text: string;
};
export type HistoryItemGemini = HistoryItemBase & {
    type: 'gemini';
    text: string;
};
export type HistoryItemGeminiContent = HistoryItemBase & {
    type: 'gemini_content';
    text: string;
};
export type HistoryItemGeminiThought = HistoryItemBase & {
    type: 'gemini_thought';
    text: string;
};
export type HistoryItemGeminiThoughtContent = HistoryItemBase & {
    type: 'gemini_thought_content';
    text: string;
};
export type HistoryItemInfo = HistoryItemBase & {
    type: 'info';
    text: string;
    linkUrl?: string;
    linkText?: string;
};
export type HistoryItemError = HistoryItemBase & {
    type: 'error';
    text: string;
    hint?: string;
};
export type HistoryItemWarning = HistoryItemBase & {
    type: 'warning';
    text: string;
};
export type HistoryItemSuccess = HistoryItemBase & {
    type: 'success';
    text: string;
};
export type HistoryItemRetryCountdown = HistoryItemBase & {
    type: 'retry_countdown';
    text: string;
};
export type HistoryItemAbout = HistoryItemBase & {
    type: 'about';
    systemInfo: {
        cliVersion: string;
        osPlatform: string;
        osArch: string;
        osRelease: string;
        nodeVersion: string;
        npmVersion: string;
        sandboxEnv: string;
        modelVersion: string;
        selectedAuthType: string;
        ideClient: string;
        sessionId: string;
        memoryUsage: string;
        baseUrl?: string;
        gitCommit?: string;
    };
};
export type HistoryItemHelp = HistoryItemBase & {
    type: 'help';
    timestamp: Date;
};
export type HistoryItemStats = HistoryItemBase & {
    type: 'stats';
    duration: string;
};
export type HistoryItemModelStats = HistoryItemBase & {
    type: 'model_stats';
};
export type HistoryItemToolStats = HistoryItemBase & {
    type: 'tool_stats';
};
export type HistoryItemQuit = HistoryItemBase & {
    type: 'quit';
    duration: string;
};
/**
 * Displayed after a turn when managed-auto-memory files were written
 * (either in-turn by the model, or by the post-turn dream/extract pipeline).
 */
export type HistoryItemMemorySaved = HistoryItemBase & {
    type: 'memory_saved';
    /** Number of memory files written / updated. */
    writtenCount: number;
    /** Verb to display, e.g. 'Saved' or 'Updated'. Defaults to 'Saved'. */
    verb?: string;
};
export type HistoryItemToolGroup = HistoryItemBase & {
    type: 'tool_group';
    tools: IndividualToolCallDisplay[];
    /** Count of tool calls that wrote to managed-auto-memory files. Pre-computed for badge rendering. */
    memoryWriteCount?: number;
    /** Count of tool calls that read from managed-auto-memory files. Pre-computed for badge rendering. */
    memoryReadCount?: number;
    isUserInitiated?: boolean;
};
/**
 * Short LLM-generated label summarizing a preceding tool batch. Emitted after
 * the batch completes and consumed by compact-mode rendering to replace the
 * generic "Tool × N" line with something like "Searched in auth/". Also
 * surfaces to SDK clients as a `tool_use_summary` stream message.
 */
export type HistoryItemToolUseSummary = HistoryItemBase & {
    type: 'tool_use_summary';
    summary: string;
    /** Tool callIds this summary describes. Used to locate the target tool_group. */
    precedingToolUseIds: string[];
};
export type HistoryItemNotification = HistoryItemBase & {
    type: 'notification';
    text: string;
};
export type HistoryItemUserShell = HistoryItemBase & {
    type: 'user_shell';
    text: string;
};
export type HistoryItemCompression = HistoryItemBase & {
    type: 'compression';
    compression: CompressionProps;
};
export type HistoryItemSummary = HistoryItemBase & {
    type: 'summary';
    summary: SummaryProps;
};
export type HistoryItemExtensionsList = HistoryItemBase & {
    type: 'extensions_list';
};
export interface ToolDefinition {
    name: string;
    displayName: string;
    description?: string;
}
export interface SkillDefinition {
    name: string;
}
export type HistoryItemToolsList = HistoryItemBase & {
    type: 'tools_list';
    tools: ToolDefinition[];
    showDescriptions: boolean;
};
export type HistoryItemSkillsList = HistoryItemBase & {
    type: 'skills_list';
    skills: SkillDefinition[];
};
export interface JsonMcpTool {
    serverName: string;
    name: string;
    description?: string;
    schema?: {
        parametersJsonSchema?: unknown;
        parameters?: unknown;
    };
}
export interface JsonMcpPrompt {
    serverName: string;
    name: string;
    description?: string;
}
export type HistoryItemMcpStatus = HistoryItemBase & {
    type: 'mcp_status';
    servers: Record<string, MCPServerConfig>;
    tools: JsonMcpTool[];
    prompts: JsonMcpPrompt[];
    authStatus: Record<string, 'authenticated' | 'expired' | 'unauthenticated' | 'not-configured'>;
    blockedServers: Array<{
        name: string;
        extensionName: string;
    }>;
    discoveryInProgress: boolean;
    connectingServers: string[];
    showDescriptions: boolean;
    showSchema: boolean;
    showTips: boolean;
};
export interface ContextCategoryBreakdown {
    systemPrompt: number;
    builtinTools: number;
    mcpTools: number;
    memoryFiles: number;
    skills: number;
    messages: number;
    freeSpace: number;
    autocompactBuffer: number;
}
export interface ContextToolDetail {
    name: string;
    tokens: number;
}
export interface ContextMemoryDetail {
    path: string;
    tokens: number;
}
export interface ContextSkillDetail {
    name: string;
    /** Token cost of the skill listing (name+description) in the tool definition */
    tokens: number;
    /** Whether this skill has been invoked and its full body loaded into context */
    loaded?: boolean;
    /** Token cost of the loaded SKILL.md body (only set when loaded is true) */
    bodyTokens?: number;
}
export type HistoryItemContextUsage = HistoryItemBase & {
    type: 'context_usage';
    modelName: string;
    totalTokens: number;
    contextWindowSize: number;
    breakdown: ContextCategoryBreakdown;
    builtinTools: ContextToolDetail[];
    mcpTools: ContextToolDetail[];
    memoryFiles: ContextMemoryDetail[];
    skills: ContextSkillDetail[];
    /** True when totalTokens is estimated (no API call yet) rather than from API response */
    isEstimated?: boolean;
    /** When true, show per-item detail sections (tools, memory, skills). Default: false (compact). */
    showDetails?: boolean;
};
/**
 * Arena agent completion card data.
 */
export interface ArenaAgentCardData {
    label: string;
    status: AgentStatus;
    durationMs: number;
    totalTokens: number;
    inputTokens: number;
    outputTokens: number;
    toolCalls: number;
    successfulToolCalls: number;
    failedToolCalls: number;
    rounds: number;
    error?: string;
    diff?: string;
    diffSummary?: ArenaDiffSummary;
    modifiedFiles?: string[];
    approachSummary?: string;
}
export type HistoryItemArenaAgentComplete = HistoryItemBase & {
    type: 'arena_agent_complete';
    agent: ArenaAgentCardData;
};
export type HistoryItemArenaSessionComplete = HistoryItemBase & {
    type: 'arena_session_complete';
    sessionStatus: string;
    task: string;
    totalDurationMs: number;
    agents: ArenaAgentCardData[];
};
/**
 * Insight progress message.
 */
export type HistoryItemInsightProgress = HistoryItemBase & {
    type: 'insight_progress';
    progress: InsightProgressProps;
};
export interface BtwProps {
    question: string;
    answer: string;
    isPending: boolean;
}
export type HistoryItemBtw = HistoryItemBase & {
    type: 'btw';
    btw: BtwProps;
};
/**
 * Away-summary recap shown when the user returns to the session after a
 * period of inactivity (or via /recap). Rendered inline as a regular
 * history item (matching Claude Code's away_summary message); scrolls
 * with the conversation, no sticky pinning.
 */
export type HistoryItemAwayRecap = HistoryItemBase & {
    type: 'away_recap';
    text: string;
};
/**
 * UserPromptSubmit hook blocked event.
 * Displayed when a UserPromptSubmit hook blocks the user's prompt.
 */
export type HistoryItemUserPromptSubmitBlocked = HistoryItemBase & {
    type: 'user_prompt_submit_blocked';
    reason: string;
    originalPrompt: string;
};
/**
 * Stop hook loop event.
 * Displayed when Stop hooks create a loop, forcing the agent to continue.
 */
export type HistoryItemStopHookLoop = HistoryItemBase & {
    type: 'stop_hook_loop';
    iterationCount: number;
    reasons: string[];
    stopHookCount: number;
};
/**
 * Stop hook system message.
 * Displayed when Stop hooks return a systemMessage to show to the user.
 */
export type HistoryItemStopHookSystemMessage = HistoryItemBase & {
    type: 'stop_hook_system_message';
    message: string;
};
export type DoctorCheckStatus = 'pass' | 'warn' | 'fail';
export interface DoctorCheckResult {
    category: string;
    name: string;
    status: DoctorCheckStatus;
    message: string;
    detail?: string;
}
export type HistoryItemDoctor = HistoryItemBase & {
    type: 'doctor';
    checks: DoctorCheckResult[];
    summary: {
        pass: number;
        warn: number;
        fail: number;
    };
};
export type HistoryItemWithoutId = HistoryItemUser | HistoryItemNotification | HistoryItemUserShell | HistoryItemGemini | HistoryItemGeminiContent | HistoryItemGeminiThought | HistoryItemGeminiThoughtContent | HistoryItemInfo | HistoryItemError | HistoryItemWarning | HistoryItemSuccess | HistoryItemRetryCountdown | HistoryItemAbout | HistoryItemHelp | HistoryItemToolGroup | HistoryItemToolUseSummary | HistoryItemStats | HistoryItemModelStats | HistoryItemToolStats | HistoryItemQuit | HistoryItemCompression | HistoryItemSummary | HistoryItemCompression | HistoryItemExtensionsList | HistoryItemToolsList | HistoryItemSkillsList | HistoryItemMcpStatus | HistoryItemContextUsage | HistoryItemArenaAgentComplete | HistoryItemArenaSessionComplete | HistoryItemInsightProgress | HistoryItemBtw | HistoryItemMemorySaved | HistoryItemAwayRecap | HistoryItemUserPromptSubmitBlocked | HistoryItemStopHookLoop | HistoryItemStopHookSystemMessage | HistoryItemDoctor;
export type HistoryItem = HistoryItemWithoutId & {
    id: number;
};
export declare enum MessageType {
    INFO = "info",
    SUCCESS = "success",
    ERROR = "error",
    WARNING = "warning",
    USER = "user",
    ABOUT = "about",
    HELP = "help",
    STATS = "stats",
    MODEL_STATS = "model_stats",
    TOOL_STATS = "tool_stats",
    QUIT = "quit",
    GEMINI = "gemini",
    COMPRESSION = "compression",
    SUMMARY = "summary",
    EXTENSIONS_LIST = "extensions_list",
    TOOLS_LIST = "tools_list",
    SKILLS_LIST = "skills_list",
    MCP_STATUS = "mcp_status",
    CONTEXT_USAGE = "context_usage",
    ARENA_AGENT_COMPLETE = "arena_agent_complete",
    ARENA_SESSION_COMPLETE = "arena_session_complete",
    INSIGHT_PROGRESS = "insight_progress",
    BTW = "btw"
}
export interface InsightProgressProps {
    stage: string;
    progress: number;
    detail?: string;
    isComplete?: boolean;
    error?: string;
}
export type Message = {
    type: MessageType.INFO | MessageType.ERROR | MessageType.WARNING | MessageType.SUCCESS | MessageType.USER;
    content: string;
    timestamp: Date;
} | {
    type: MessageType.ABOUT;
    timestamp: Date;
    systemInfo: {
        cliVersion: string;
        osPlatform: string;
        osArch: string;
        osRelease: string;
        nodeVersion: string;
        npmVersion: string;
        sandboxEnv: string;
        modelVersion: string;
        selectedAuthType: string;
        ideClient: string;
        sessionId: string;
        memoryUsage: string;
        baseUrl?: string;
        gitCommit?: string;
    };
    content?: string;
} | {
    type: MessageType.HELP;
    timestamp: Date;
    content?: string;
} | {
    type: MessageType.STATS;
    timestamp: Date;
    duration: string;
    content?: string;
} | {
    type: MessageType.MODEL_STATS;
    timestamp: Date;
    content?: string;
} | {
    type: MessageType.TOOL_STATS;
    timestamp: Date;
    content?: string;
} | {
    type: MessageType.QUIT;
    timestamp: Date;
    duration: string;
    content?: string;
} | {
    type: MessageType.COMPRESSION;
    compression: CompressionProps;
    timestamp: Date;
} | {
    type: MessageType.SUMMARY;
    summary: SummaryProps;
    timestamp: Date;
} | {
    type: MessageType.INSIGHT_PROGRESS;
    progress: InsightProgressProps;
    timestamp: Date;
};
export interface ConsoleMessageItem {
    type: 'log' | 'warn' | 'error' | 'debug' | 'info';
    content: string;
    count: number;
}
/**
 * Result type for a slash command that should immediately result in a prompt
 * being submitted to the Gemini model.
 */
export interface SubmitPromptResult {
    type: 'submit_prompt';
    content: PartListUnion;
    /** Optional callback invoked after the agent turn completes successfully. */
    onComplete?: () => Promise<void>;
}
/**
 * Defines the result of the slash command processor for its consumer (useHopCodeStream).
 */
export type SlashCommandProcessorResult = {
    type: 'schedule_tool';
    toolName: string;
    toolArgs: Record<string, unknown>;
} | {
    type: 'handled';
} | SubmitPromptResult;
export interface ShellConfirmationRequest {
    commands: string[];
    onConfirm: (outcome: ToolConfirmationOutcome, approvedCommands?: string[]) => void;
}
export interface ConfirmationRequest {
    prompt: ReactNode;
    onConfirm: (confirm: boolean) => void;
}
export interface LoopDetectionConfirmationRequest {
    onComplete: (result: {
        userSelection: 'disable' | 'keep';
    }) => void;
}
export interface SettingInputRequest {
    settingName: string;
    settingDescription: string;
    sensitive: boolean;
    onSubmit: (value: string) => void;
    onCancel: () => void;
}
export interface PluginChoice {
    name: string;
    description?: string;
}
export interface PluginChoiceRequest {
    marketplaceName: string;
    plugins: PluginChoice[];
    onSelect: (pluginName: string) => void;
    onCancel: () => void;
}
