UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

59 lines (58 loc) • 4.12 kB
/** * The card's half of the session call grant (`session-call-grant.ts`): the option a card carries, the resolver's reading of an * approver's `sessionCallGrant` against it, and the rejection words. It only READS: writing the session row is * the asking run's own station's act. A leaf (it imports nothing), so the resolver can read it without the rule model. */ /** * The option on a card (`AskRequest.sessionCallGrant`), and the same members for a listed row (`sessionCallGrantOfRow`). * `grant` is the key a host sends back; every other member is display, never read back. Every fact `sentence` states is one * of the structured members, so a surface in another language composes its own line from them. All nine members are always * present: a list with nothing in it is `[]`, and `programs` is never empty (a binding has at least one run). */ export interface SessionCallGrantOffer { /** The grant's key: the session row's rule text. Sent back verbatim as `AskOutcome.sessionCallGrant`; on a listed row, its `rule`. */ readonly grant: string; /** The engine's sentence for the person — one language (English), for a surface with none of its own (a headless host, a log). */ readonly sentence: string; /** The first 12 hex digits of the digest of the command's text (its words, operands masked, when `operandDirs` is not empty). */ readonly fingerprint: string; /** The canonical directory the call starts in. */ readonly cwd: string; /** The canonical path each run's program resolved to (a builtin by name), run order. */ readonly programs: readonly string[]; /** The scripts bound by their content (with the interpreter's source files beside each), run order. */ readonly scripts: readonly string[]; /** The first 12 hex digits of each inline-code word's digest (`node -e <code>`), run order. */ readonly inlineCode: readonly string[]; /** The canonical path of each file a redirection writes or reads, run order. */ readonly writes: readonly string[]; /** The directories an operand may name another file inside. */ readonly operandDirs: readonly string[]; } /** An engine-owned copy of a card's option, taken before an approver can touch the object. */ export declare function ownSessionCallGrantOffer(o: SessionCallGrantOffer | undefined): SessionCallGrantOffer | undefined; /** * Why a person's "for the rest of the session" took no effect, each word spelled once — the `detail.reason` of * `approval.session_call_grant_rejected` (attention `audit`, the record of the person's own answer): every word is a choice * that did not take. * An answer the option does not apply to is no such choice and mints nothing: a refusal of the call, or the card's own key in * an answer no person gave (its host reports `settledBy: "policy"`), edited or not. Any key on a card that offered none is * `no_offer`, and a key other than the card's is `mismatch`, whoever sent it (a policy seat's card offers none). */ export declare const SESSION_CALL_GRANT_REJECTIONS: readonly ["not_a_string", "no_offer", "mismatch", "edited", "not_written"]; export type SessionCallGrantRejection = (typeof SESSION_CALL_GRANT_REJECTIONS)[number]; /** The resolver's reading of an answer's `sessionCallGrant` against the card it answered. */ export type SessionCallGrantScreen = { readonly verdict: "granted"; readonly grant: string; } | { readonly verdict: "rejected"; readonly reason: Exclude<SessionCallGrantRejection, "not_written">; readonly requested?: string; }; /** Screen an ALLOW's member (read once by the caller; a refusal carries no grant screen — on it the option does not apply); * `{}` when the answer carried none, or the card's own key in an answer no person gave (`byPerson` false). `edited`: the * approver changed the input — the grant names the call the card showed, which is not the one that runs. */ export declare function sessionCallGrantSeat(raw: unknown, offered: SessionCallGrantOffer | undefined, edited: boolean, byPerson: boolean): { sessionCallGrant?: SessionCallGrantScreen; };