@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
53 lines (52 loc) • 2.12 kB
TypeScript
/**
* Effective History Filter
*
* Filters message arrays to return only "visible" messages,
* excluding those tagged by condensation or truncation.
* Supports non-destructive context management where messages
* are tagged instead of deleted.
*/
import type { ChatMessage } from "../types/index.js";
/**
* Get the effective (visible) history from a message array.
*
* Filters out:
* - Messages with a condenseParent (replaced by a summary)
* - Messages with a truncationParent (hidden by truncation)
*
* Keeps:
* - Summary messages (isSummary = true)
* - Truncation markers (isTruncationMarker = true)
* - All other untagged messages
*/
export declare function getEffectiveHistory(messages: ChatMessage[]): ChatMessage[];
/**
* Tag messages for condensation (non-destructive summary).
*
* @param messages - Full message array
* @param fromIndex - Start index of messages to condense
* @param toIndex - End index (exclusive) of messages to condense
* @param condenseId - UUID for this condensation group
* @returns Updated message array with tags applied
*/
export declare function tagForCondensation(messages: ChatMessage[], fromIndex: number, toIndex: number, condenseId: string): ChatMessage[];
/**
* Tag messages for truncation (non-destructive hiding).
*
* @param messages - Full message array
* @param fromIndex - Start index of messages to truncate
* @param toIndex - End index (exclusive) of messages to truncate
* @param truncationId - UUID for this truncation group
* @returns Updated message array with tags applied
*/
export declare function tagForTruncation(messages: ChatMessage[], fromIndex: number, toIndex: number, truncationId: string): ChatMessage[];
/**
* Remove condensation tags (rewind).
* Makes previously condensed messages visible again.
*/
export declare function removeCondensationTags(messages: ChatMessage[], condenseId: string): ChatMessage[];
/**
* Remove truncation tags (rewind).
* Makes previously truncated messages visible again.
*/
export declare function removeTruncationTags(messages: ChatMessage[], truncationId: string): ChatMessage[];