actrone-memory
    Preparing search index...

    Interface L1Store

    Hot session store (recent conversation turns).

    interface L1Store {
        appendTurn(
            agentId: string,
            sessionId: string,
            turn: Turn,
        ): Promise<void>;
        getRecentTurns(
            agentId: string,
            sessionId: string,
            n?: number,
        ): Promise<Turn[]>;
        turnCount(agentId: string, sessionId: string): Promise<number>;
        clearSession(agentId: string, sessionId: string): Promise<void>;
        getSessionMetadata(
            agentId: string,
            sessionId: string,
        ): Promise<SessionMetadata | null>;
        tryAcquireSummaryLock?(
            agentId: string,
            sessionId: string,
            ttlSeconds: number,
        ): Promise<boolean>;
        close?(): Promise<void>;
    }

    Implemented by

    Index
    • Parameters

      • agentId: string
      • sessionId: string
      • turn: Turn

      Returns Promise<void>

    • Recent turns, oldest → newest, capped at n (defaults to all retained).

      Parameters

      • agentId: string
      • sessionId: string
      • Optionaln: number

      Returns Promise<Turn[]>

    • Parameters

      • agentId: string
      • sessionId: string

      Returns Promise<number>

    • Parameters

      • agentId: string
      • sessionId: string

      Returns Promise<void>

    • Claim the right to run a background job for this session, fleet-wide, for ttlSeconds. Returns true for exactly one caller per window.

      Optional, and nothing in this library calls it yet: it is the primitive the Python library's auto-summarisation uses to keep one holder across processes, and it is declared here so an adapter written against either library implements the same contract. Implement it with a single atomic operation (Redis SET NX EX, Postgres INSERT ... ON CONFLICT ... WHERE expires_at <= now()), never a read-then-write.

      Parameters

      • agentId: string
      • sessionId: string
      • ttlSeconds: number

      Returns Promise<boolean>

    • Release resources this store owns. Optional, because the built-in adapters take an injected client whose lifetime the application owns, so they have nothing to close. A store that opens its own connection should implement it; MemoryManager.close() calls it when present.

      Returns Promise<void>