export class WorkingMemory {
    items = [];
    maxItems;
    constructor(maxItems = 8) {
        this.maxItems = Math.max(1, maxItems);
    }
    remember(text, confidence, turn) {
        const normalized = text.trim();
        if (!normalized) {
            return;
        }
        const item = {
            id: `wm-${turn}-${this.items.length + 1}`,
            text: normalized,
            confidence: Math.min(1, Math.max(0, confidence)),
            turn,
        };
        this.items = [item, ...this.items].slice(0, this.maxItems);
    }
    snapshot() {
        const confidence = this.items.length === 0 ? 1 : this.items.reduce((sum, item) => sum + item.confidence, 0) / this.items.length;
        return {
            items: [...this.items],
            confidence,
        };
    }
}
//# sourceMappingURL=working-memory.js.map