@sema-agent/core
Version:
Stateless, task-oriented AI agent core
25 lines (24 loc) • 1.84 kB
TypeScript
import { type SessionHead, type SessionRowExpectation, type SessionRowRead, type SessionTreeEntry } from "../internal/harness.js";
import type { SessionLogTransfer } from "./session.js";
/**
* What a store's {@link SessionLogTransfer} reads and writes through: the repo's one read of a row (metadata, head and log of one
* generation) and its conditional import (judged against the row as that read answered it, in the import's own step, answering the head
* it wrote), and the store's own hold of an id — the one gate its other row writers (acquire, register, release) wait on, which also drops
* the store's cached view of the id so the view a commit replaces is not served again. Writers the hold does not see (another instance,
* a write straight through the repo) are met by the import's expectation instead.
*/
export interface LogTransferSeat {
readRow(sessionId: string): Promise<SessionRowRead | undefined>;
importEntries(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[], options: {
preserveActorAssertions?: boolean;
expect: SessionRowExpectation;
}): Promise<SessionHead>;
holding<T>(sessionId: string, work: () => Promise<T>): Promise<T>;
}
/**
* The {@link SessionLogTransfer} of a store over a repo that holds each log whole: reads are the repo's row read, a staging lives in this
* process until its commit, and a commit is the repo's conditional import under the store's hold of the id — the import itself judging,
* in the step that replaces the log, the write law (`importRowCells`: an existing row must already be the committer's; a placed row is
* refused) and that the row is still the one the commit read (its head, log included), and answering the head it wrote.
*/
export declare function repoLogTransfer(seat: LogTransferSeat): SessionLogTransfer;