@threadplane/ag-uiInterfacev0.3.7

SessionPersistence

Application-owned durable storage for one session's thread.

import type { SessionPersistence } from '@threadplane/ag-ui';

Declaration

export interface SessionPersistence  {
  readonly namespace: string;
  readonly reconcile?: (record: ThreadRecord) => Promise<ReconcileAnswer>;
  readonly store: {
        load(key: string): Promise<ThreadRecord | null>;
        compareAndSwap(key: string, expectedRevision: number | null, next: ThreadRecord): Promise<boolean>;
    };
}

Members

namespace

Scopes the keys, so two applications sharing a store never collide.

readonly namespace: string;

reconcile

Asks the backend what became of the saved thread. Read-only: it must not send the answer again. Enables checkStatus and reconcileInterrupt.

readonly reconcile?: (record: ThreadRecord) => Promise<ReconcileAnswer>;

store

readonly store: {
        load(key: string): Promise<ThreadRecord | null>;
        compareAndSwap(key: string, expectedRevision: number | null, next: ThreadRecord): Promise<boolean>;
    };