/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
export class SessionMemoryStore {
    memories = [];
    counter = 0;
    /** Add a memory, returns the assigned ID. Returns empty string if text is blank. */
    add(text) {
        const trimmed = text.trim();
        if (!trimmed)
            return '';
        this.counter++;
        const id = `mem-${this.counter}`;
        this.memories.push({ id, text: trimmed, createdAt: Date.now() });
        return id;
    }
    /** Remove a memory by ID, returns true if found */
    remove(id) {
        const idx = this.memories.findIndex(m => m.id === id);
        if (idx === -1)
            return false;
        this.memories.splice(idx, 1);
        return true;
    }
    /** List all memories */
    list() {
        return this.memories;
    }
    /** Format memories for compaction output. Returns null if no memories. */
    format() {
        if (this.memories.length === 0)
            return null;
        const lines = this.memories.map(m => `- [${m.id}] ${m.text}`);
        return `## Session Memories (pinned)\n${lines.join('\n')}`;
    }
    /** Get total estimated tokens across all memories (rough: chars / 4) */
    estimateTokens() {
        return Math.ceil(this.memories.reduce((sum, m) => sum + m.text.length, 0) / 4);
    }
    /** Clear all memories. NOTE: counter is intentionally NOT reset — IDs must remain unique
     *  across the lifetime of the store even after a clear(). */
    clear() {
        this.memories = [];
    }
}
