UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

18 lines (17 loc) • 1.65 kB
import { type SessionMetadata, type SessionStorage, type SessionTreeEntry } from "../harness/types.js"; import type { Session } from "../harness/types.js"; export declare function createSessionId(): string; /** The {@link SessionMetadata.incarnation} cell for a write laying a row's metadata down — the bundled repos' ONE mint point. * `existing` = the row before the write (`undefined`: none). A new row gets a fresh random v4 token (no time, no host); an * existing row keeps exactly what it had, including nothing (no token is minted for an occupant that predates the cell). */ export declare function incarnationCell(existing: Pick<SessionMetadata, "incarnation"> | undefined): Pick<SessionMetadata, "incarnation">; /** A fork lands on a row OTHER than its source: onto its own id it would mint a new occupant over the source's transcript and erase the lineage that carries the source's records. */ export declare function assertForkTarget(sourceId: string, targetId: string | undefined): void; /** A fork row's cells, minted from the SOURCE row as it stands at fork time: the lineage (`forkedFrom` + the occupant copied) and a fresh occupant of its own. */ export declare function forkRowCells(source: SessionMetadata): Pick<SessionMetadata, "forkedFrom" | "forkedFromIncarnation" | "incarnation">; export declare function createTimestamp(): string; export declare function toSession<TMetadata extends SessionMetadata>(storage: SessionStorage<TMetadata>): Session<TMetadata>; export declare function getEntriesToFork(storage: SessionStorage, options: { entryId?: string; position?: "before" | "at"; }): Promise<SessionTreeEntry[]>;