Interface IHistoryInstanceCallbacks

Callbacks for managing history instance lifecycle and message handling.

interface IHistoryInstanceCallbacks {
    filterCondition?: (
        message: IModelMessage,
        clientId: string,
        agentName: string,
    ) => boolean | Promise<boolean>;
    getData: (
        clientId: string,
        agentName: string,
    ) => IModelMessage<object>[] | Promise<IModelMessage<object>[]>;
    getSystemPrompt?: (
        clientId: string,
        agentName: string,
    ) => string[] | Promise<string[]>;
    onChange: (
        data: IModelMessage<object>[],
        clientId: string,
        agentName: string,
    ) => void;
    onDispose: (clientId: string) => void;
    onInit: (clientId: string) => void;
    onPop: (
        data: IModelMessage<object>,
        clientId: string,
        agentName: string,
    ) => void;
    onPush: (data: IModelMessage, clientId: string, agentName: string) => void;
    onRead: (
        message: IModelMessage,
        clientId: string,
        agentName: string,
    ) => void;
    onReadBegin: (clientId: string, agentName: string) => void;
    onReadEnd: (clientId: string, agentName: string) => void;
    onRef: (history: IHistoryInstance) => void;
}

Properties

filterCondition?: (
    message: IModelMessage,
    clientId: string,
    agentName: string,
) => boolean | Promise<boolean>

Determines whether a message should be included in the history iteration.

Type declaration

    • (
          message: IModelMessage,
          clientId: string,
          agentName: string,
      ): boolean | Promise<boolean>
    • Parameters

      • message: IModelMessage

        The message to evaluate.

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns boolean | Promise<boolean>

      Whether the message passes the filter.

getData: (
    clientId: string,
    agentName: string,
) => IModelMessage<object>[] | Promise<IModelMessage<object>[]>

Fetches initial history data for an agent.

Type declaration

    • (
          clientId: string,
          agentName: string,
      ): IModelMessage<object>[] | Promise<IModelMessage<object>[]>
    • Parameters

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns IModelMessage<object>[] | Promise<IModelMessage<object>[]>

      The initial array of history messages.

getSystemPrompt?: (
    clientId: string,
    agentName: string,
) => string[] | Promise<string[]>

Retrieves dynamic system prompt messages for an agent.

Type declaration

    • (clientId: string, agentName: string): string[] | Promise<string[]>
    • Parameters

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns string[] | Promise<string[]>

      An array of system prompt message contents.

onChange: (
    data: IModelMessage<object>[],
    clientId: string,
    agentName: string,
) => void

Called when the history array changes (e.g., after push or pop).

Type declaration

    • (data: IModelMessage<object>[], clientId: string, agentName: string): void
    • Parameters

      • data: IModelMessage<object>[]

        The updated array of history messages.

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns void

onDispose: (clientId: string) => void

Called when the history instance is disposed.

Type declaration

    • (clientId: string): void
    • Parameters

      • clientId: string

        The client ID.

      Returns void

onInit: (clientId: string) => void

Called when the history instance is initialized.

Type declaration

    • (clientId: string): void
    • Parameters

      • clientId: string

        The client ID.

      Returns void

onPop: (
    data: IModelMessage<object>,
    clientId: string,
    agentName: string,
) => void

Called when the last message is popped from the history.

Type declaration

    • (data: IModelMessage<object>, clientId: string, agentName: string): void
    • Parameters

      • data: IModelMessage<object>

        The popped message, or null if the history is empty.

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns void

onPush: (data: IModelMessage, clientId: string, agentName: string) => void

Called when a new message is pushed to the history.

Type declaration

    • (data: IModelMessage, clientId: string, agentName: string): void
    • Parameters

      • data: IModelMessage

        The newly pushed message.

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns void

onRead: (message: IModelMessage, clientId: string, agentName: string) => void

Called for each message during iteration when reading.

Type declaration

    • (message: IModelMessage, clientId: string, agentName: string): void
    • Parameters

      • message: IModelMessage

        The current message being read.

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns void

onReadBegin: (clientId: string, agentName: string) => void

Called at the start of a history read operation.

Type declaration

    • (clientId: string, agentName: string): void
    • Parameters

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns void

onReadEnd: (clientId: string, agentName: string) => void

Called at the end of a history read operation.

Type declaration

    • (clientId: string, agentName: string): void
    • Parameters

      • clientId: string

        The client ID.

      • agentName: string

        The name of the agent.

      Returns void

onRef: (history: IHistoryInstance) => void

Provides a reference to the history instance after creation.

Type declaration

MMNEPVFCICPMFPCPTTAAATR