@sema-agent/core
Version:
Stateless, task-oriented AI agent core
36 lines (35 loc) • 2.6 kB
TypeScript
/**
* The resolver's reading of an approver's `readRootGrant` (`AskOutcome`) — and of the `readRootGrantLasts` beside it —
* against the card it answered. It only READS: widening a run's read roots, or writing the session rule that keeps a
* directory for the session, is that run's own station's act, and the resolver holds no run.
*/
import type { ReadRootGrantCandidate } from "./types.js";
/** How long a granted directory lasts, each word spelled once: `"session"` — for the rest of the session (the
* session rule a station writes); `"run"` — for the rest of this run. The candidate's `lasts` and the answer's
* `readRootGrantLasts` take these words and no others. */
export declare const READ_ROOT_GRANT_LASTS: readonly ["session", "run"];
export type ReadRootGrantLasts = (typeof READ_ROOT_GRANT_LASTS)[number];
/** `granted` ⇔ an `allow` whose grant is byte-equal to the request's `readRootCandidate.dir` (the candidate rides
* back whole, `covers` and `lasts` included), with `lasts` the duration the answer can take: `"session"` only when the
* answer asked for it, the card offered it, and a person answered — else `"run"`, and `narrowed` says why a
* `"session"` answer became `"run"`. Otherwise `rejected` with ONE reason (a choice that did not take), the card's `offered`
* dir when it had one, and the `requested` grant when it was a string (verbatim host text — a notice bounds it). */
export type ReadRootGrantScreen = {
readonly verdict: "granted";
readonly candidate: ReadRootGrantCandidate;
readonly lasts: ReadRootGrantLasts;
readonly narrowed?: "not_offered" | "not_a_person";
} | {
readonly verdict: "rejected";
readonly reason: "not_a_string" | "lasts_invalid" | "no_candidate" | "mismatch";
readonly offered?: string;
readonly requested?: string;
};
/** Screen an ALLOW's two grant members, each read once by the caller (a grant rides an approval: a refusal carries no grant
* screen, and nothing is announced for it); `{}` when the answer carried neither. `byPerson`: a person answered (not a
* deployment's policy) — the only party whose yes may become a standing session rule. */
export declare function readRootGrantSeat(grant: unknown, lasts: unknown, candidate: ReadRootGrantCandidate | undefined, byPerson: boolean): {
readRootGrant?: ReadRootGrantScreen;
};
/** An engine-owned copy of a card's offer (one read per member), taken before an approver can touch the object. */
export declare function ownReadRootCandidate(c: ReadRootGrantCandidate | undefined): ReadRootGrantCandidate | undefined;