UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

28 lines (27 loc) • 1.82 kB
import { type MemoryPartitionIncidentSink, type SessionIdentityRead } from "./layout.js"; /** The current occupant's token, and the identity seat a per-session record read is made under. */ export interface SessionIncarnationSeat { incarnationOf(sessionId: string): string | undefined; identityRead(sessionId: string): SessionIdentityRead; } /** Build the seat over a host resolver (absent ⇒ nothing stamped, nothing asked, every record binds * by id — the pre-incarnation answer). Both disclosures are DEDUPED on the axis their fact belongs to: the resolver * fault once per engine (a wiring fact), a separation once per session id (a fact about that id). */ export declare function createSessionIncarnationSeat(input: { resolve: ((session: { sessionId: string; }) => string | undefined) | undefined; onIncident: MemoryPartitionIncidentSink | undefined; }): SessionIncarnationSeat; /** Remember an in-process record under its session id, FIRST-WINS PER IDENTITY: this map is the * durable half's fallback exactly when the durable write failed, so keeping only the first * occupant's row would leave the next one unprotected on the one path it exists to cover. */ export declare function rememberForIdentity<T extends { incarnation?: string; }>(map: Map<string, T[]>, sessionId: string, record: T): void; /** The remembered record that BINDS `asking` ({@link sessionRecordBindsIncarnation}), if any. */ export declare function recalledForIdentity<T extends { incarnation?: string; }>(map: Map<string, T[]>, sessionId: string, asking: string | undefined): T | undefined; /** The first record remembered for `sessionId` by ANY occupant — for the id-blind faces. */ export declare function recalledForAnyIdentity<T>(map: Map<string, T[]>, sessionId: string): T | undefined;