Skip to content

MessageLog ​

In-memory message history with ring-buffer semantics.

Import ​

ts
import { MessageLog } from "@halo-ai/core";

Constructor ​

ts
new MessageLog(opts?: { storageLimit?: number }) // default: 10_000

Properties ​

PropertyTypeDescription
lengthnumberCurrent message count
versionnumberMonotonic counter, increments on append() and hydrate()

Methods ​

MethodDescription
append(msg)Add a message. Drops oldest if over storageLimit
hydrate(messages)Replace all entries. Use for restoring external state
toFullHistory()Shallow copy of all messages
recent(n)Shallow copy of last N messages

Released under the MIT License.