openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
141 lines • 5.42 kB
TypeScript
import { n as HistoryMediaEntry, t as HistoryEntry } from "../history.types-AP0C5aEq.js";
//#region src/auto-reply/reply/history-limit.d.ts
export declare const DEFAULT_GROUP_HISTORY_LIMIT = 50;
//#endregion
//#region src/auto-reply/reply/history.d.ts
export declare const HISTORY_CONTEXT_MARKER = "[Chat messages since your last reply - for context]";
/**
* Evict oldest keys from a history map when it exceeds MAX_HISTORY_KEYS.
* Uses Map's insertion order for LRU-like behavior.
*/
export declare function evictOldHistoryKeys<T>(historyMap: Map<string, T[]>, maxKeys?: number): void;
export declare function buildHistoryContext(params: {
historyText: string;
currentMessage: string;
lineBreak?: string;
historyKind?: "pending" | "recent";
}): string;
/** Appends one history entry, enforces per-session limit, and refreshes LRU key order. */
declare function recordChannelHistoryEntryIfEnabled<T extends HistoryEntry>(params: {
historyMap: Map<string, T[]>;
historyKey: string;
entry?: T | null;
limit: number;
}): T[];
/**
* @deprecated Plugin message-turn code should use `createChannelHistoryWindow(...).record(...)`.
* This helper remains for core internals and older plugin compatibility.
*/
export declare const recordPendingHistoryEntryIfEnabled: typeof recordChannelHistoryEntryIfEnabled;
type MaybePromise<T> = T | Promise<T>;
/** Filters history media to local image entries safe to re-attach to prompt context. */
export declare function normalizeHistoryMediaEntries(params: {
media?: readonly HistoryMediaEntry[] | null;
limit?: number;
messageId?: string;
}): HistoryMediaEntry[];
declare function recordChannelHistoryEntryWithMedia<T extends HistoryEntry>(params: {
historyMap: Map<string, T[]>;
historyKey: string;
entry?: T | null;
limit: number;
media?: readonly HistoryMediaEntry[] | null | (() => MaybePromise<readonly HistoryMediaEntry[] | null | undefined>);
mediaLimit?: number;
messageId?: string;
shouldRecord?: () => boolean;
}): Promise<T[]>;
/**
* @deprecated Plugin message-turn code should use
* `createChannelHistoryWindow(...).recordWithMedia(...)`.
*/
export declare const recordPendingHistoryEntryWithMedia: typeof recordChannelHistoryEntryWithMedia;
declare function buildChannelPendingHistoryContext(params: {
historyMap: Map<string, HistoryEntry[]>;
historyKey: string;
limit: number;
currentMessage: string;
formatEntry: (entry: HistoryEntry) => string;
lineBreak?: string;
}): string;
/**
* @deprecated Plugin message-turn code should use
* `createChannelHistoryWindow(...).buildPendingContext(...)`.
*/
export declare const buildPendingHistoryContextFromMap: typeof buildChannelPendingHistoryContext;
declare function buildChannelInboundHistory<T extends HistoryEntry>(params: {
historyMap: Map<string, T[]>;
historyKey: string;
limit: number;
}): HistoryEntry[] | undefined;
/**
* @deprecated Plugin message-turn code should use
* `createChannelHistoryWindow(...).buildInboundHistory(...)`.
*/
export declare const buildInboundHistoryFromMap: typeof buildChannelInboundHistory;
export declare function buildInboundHistoryFromEntries(params: {
entries: readonly HistoryEntry[];
limit: number;
}): HistoryEntry[] | undefined;
/**
* @deprecated Prefer `buildHistoryContextFromEntries(...)` for existing entry
* arrays, or `createChannelHistoryWindow(...)` when working from a history map.
* This helper remains for older plugin compatibility.
*/
export declare function buildHistoryContextFromMap(params: {
historyMap: Map<string, HistoryEntry[]>;
historyKey: string;
limit: number;
entry?: HistoryEntry;
currentMessage: string;
formatEntry: (entry: HistoryEntry) => string;
lineBreak?: string;
excludeLast?: boolean;
}): string;
declare function clearChannelHistoryIfEnabled(params: {
historyMap: Map<string, HistoryEntry[]>;
historyKey: string;
limit: number;
}): void;
/**
* @deprecated Plugin message-turn code should use `createChannelHistoryWindow(...).clear(...)`.
* This helper remains for core internals and older plugin compatibility.
*/
export declare const clearHistoryEntriesIfEnabled: typeof clearChannelHistoryIfEnabled;
export declare function buildHistoryContextFromEntries(params: {
entries: HistoryEntry[];
currentMessage: string;
formatEntry: (entry: HistoryEntry) => string;
lineBreak?: string;
excludeLast?: boolean;
historyKind?: "pending" | "recent";
}): string;
//#endregion
//#region src/channels/turn/history-window.d.ts
type ChannelHistoryWindow<T extends HistoryEntry = HistoryEntry> = {
record: (params: {
historyKey: string;
entry?: T | null;
limit: number;
}) => T[];
recordWithMedia: (params: Omit<Parameters<typeof recordChannelHistoryEntryWithMedia<T>>[0], "historyMap">) => Promise<T[]>;
buildPendingContext: (params: {
historyKey: string;
limit: number;
currentMessage: string;
formatEntry: (entry: T) => string;
lineBreak?: string;
}) => string;
buildInboundHistory: (params: {
historyKey: string;
limit: number;
}) => HistoryEntry[] | undefined;
clear: (params: {
historyKey: string;
limit: number;
}) => void;
};
export declare function createChannelHistoryWindow<T extends HistoryEntry = HistoryEntry>(params: {
historyMap: Map<string, T[]>;
}): ChannelHistoryWindow<T>;
//#endregion
export type { ChannelHistoryWindow, HistoryEntry, HistoryMediaEntry };