@sema-agent/core
Version:
Stateless, task-oriented AI agent core
40 lines (39 loc) • 2.09 kB
TypeScript
import { type ContractAssertionRunner } from "../store-contracts/contract-harness.js";
import type { TraceRecord } from "../trace.js";
/** Who a reader shows a record to, narrowest first. */
export type OpenFaceAudience = "none" | "operator" | "user";
/** The engine that sent a record, as the reader's transport knows it. */
export interface OpenFaceOrigin {
readonly engineVersion: string;
}
/** What a reader did with one record: the four clauses of `vocabulary.open`, as the kit observes them. */
export interface OpenFaceReading {
/** (1) The record is kept: not dropped, and its request did not fail. */
readonly kept: boolean;
/** (2) Who the reader shows it to. */
readonly audience: OpenFaceAudience;
/** (3) The unknown word this reading recorded for audit, or `undefined` when it recorded none (a known word, or a word already recorded). */
readonly recorded: {
readonly subject: string;
readonly word: string;
readonly engineVersion: string;
} | undefined;
/** (4) What the reader decided, in its own words — compared, never interpreted. */
readonly decision: string;
}
/** A downstream reader of the records of every subject `OPEN_FACE` lists. */
export interface OpenFaceConsumer {
/** Read one trace record that crossed a process or version boundary. */
readTrace(record: TraceRecord, origin: OpenFaceOrigin): OpenFaceReading | Promise<OpenFaceReading>;
}
export interface OpenFaceContractHooks {
runAssertion?: ContractAssertionRunner;
}
/** The prefix every word the kit invents starts with; no subject ever spells it. */
export declare const CONTRACT_PROBE_PREFIX = "__contract_probe__.";
/**
* The reader side of `vocabulary.open`, run against a downstream reader: each case builds a fresh reader
* through `make()` and feeds it, per open subject, a record this build mints and records carrying words it
* does not mint — invented ones and the names an object inherits.
*/
export declare function openFaceContract(make: () => OpenFaceConsumer, hooks?: OpenFaceContractHooks): Promise<void>;