import type { Message, Thread } from 'chat';
import type { ChannelLogContext } from './agent-channels.js';
/**
 * How far past the history window the first-mention walk counts omitted
 * messages before giving up on an exact count. Slack's backward paging fetches
 * at least 200 per call, so this costs at most a few calls.
 */
export declare const THREAD_HISTORY_OMITTED_CAP = 500;
/** Log sink shaped like `AgentChannels.log`. */
export type ThreadHistoryLog = (level: 'warn' | 'debug', message: string, fields?: ChannelLogContext) => void;
/** Identifiers attached to every thread-history log line. */
export interface ThreadHistoryLogContext {
    platform: string;
    /** Platform thread id. */
    threadId: string;
    mastraThreadId: string;
    /** The mention that triggered the history fetch. */
    messageId: string;
}
/** Prior platform messages gathered for a first mention. */
export interface ThreadHistoryWindow {
    /** The thread's first message, when it falls outside `recent`. */
    root: Message | undefined;
    /** Messages between `root` and `recent` that are not included. */
    omitted: number;
    /** True when the walk stopped at THREAD_HISTORY_OMITTED_CAP; `omitted` is a lower bound. */
    capped: boolean;
    /** The most recent `maxMessages - 1` messages before the trigger, oldest first. */
    recent: Message[];
}
/**
 * Rich text when the platform provided it, else the plain text, followed by
 * any Slack layout-block text (header, section, context, markdown) the
 * message text doesn't already contain.
 */
export declare function messageText(message: Message): string;
/** Gap marker between the thread's first message and the recent window, e.g. `[… 6 earlier Slack messages omitted]`. */
export declare function formatOmittedMarker(platform: string, omitted: string): string;
/** The omitted count as rendered, with a `+` suffix when the walk hit the cap. */
export declare function formatOmittedCount(history: ThreadHistoryWindow): string;
/**
 * Collect the platform thread's prior messages for a first mention: the
 * thread's root message, how many messages sit between it and the window,
 * and the most recent `maxMessages - 1` messages (oldest first), excluding
 * the messages that triggered this request.
 *
 * The platform exposes no reply count, so the omitted count comes from
 * walking `chatThread.messages` (newest first) past the window. The walk
 * stops at THREAD_HISTORY_OMITTED_CAP; beyond that the root is fetched from
 * the front of the thread and the count renders as `${cap}+`.
 */
export declare function collectThreadHistory(chatThread: Thread, excludeIds: ReadonlySet<string>, maxMessages: number, log?: ThreadHistoryLog): Promise<ThreadHistoryWindow>;
/** The pre-signals history shape, kept for agents that cannot persist rows. */
export declare function formatLegacyHistoryBlock(history: ThreadHistoryWindow, chatThread: Thread, platform: string): string;
//# sourceMappingURL=thread-history.d.ts.map