UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

56 lines (55 loc) • 4.99 kB
/** * Who may clear an ask that demands a person — the rule {@link import("./tool-policy.js").AskRequest.requiresRealApproval} * states ("a person, not a configuration"), in one place for every station that settles such an ask. Two allows * are a configuration: the blanket `onAsk: "allow"` seat, and an approver's allow it reports as the deployment's * policy (`settledBy: "policy"` / `hostDecision.decidedBy: "policy"`). A person's allow clears the ask; the policy * may still refuse it. */ import { type AskClass } from "./ask-origin.js"; import type { Checkpoint } from "./checkpoint-store.js"; import type { HostDecider } from "./gate-outcome.js"; import type { OrgGateVerdict } from "./hooks.js"; import type { AskRequest, PermissionResult, ResolverArmResult } from "./tool-policy.js"; /** The synchronous seat's refusal of a configuration's allow: one settlement word for both forms * (`blanket_allow_refused`, nobody's — no person decided), a sentence that says which configuration it was. */ export declare function unjudgedAllowRefused(req: AskRequest, by: "blanket" | "policy"): Extract<ResolverArmResult, { action: "deny"; }>; /** A durable row demands a person when its gate carries the real-approval bit (the gate's own, which every resume * check reads; the pending action's `requiresRealApproval` is its display twin). A plan-pause gate carries no bit, so * the same predicate lets the deployment's policy decide a plan pause — and would refuse it the day a gate stamps one. */ export declare function rowDemandsAPerson(cp: Checkpoint): boolean; /** A question a decide is held against, in each form a station holds one: the parked row, a policy's re-check of an * approver's edit, the organization's CURRENT verdict about the call, and the request an approver was handed (the card a * live door answers). */ export type HeldQuestion = Checkpoint | PermissionResult | OrgGateVerdict | AskRequest; /** Whether a decide made by `decidedBy` cannot answer the held question: a question demanding a person is not * the policy's to answer. One predicate for every station that holds a decide against such a question — the resume * entry (the row, an edit's re-check, the org's current verdict), the execution belt (the last two, re-read) and a live * door answering the request an approver was handed. */ export declare function policyCannotAnswer(question: HeldQuestion, decidedBy: HostDecider): boolean; /** Whether a person answered a question that carried every one of the obligation's classes: `answered` is the classes of the * question a PERSON answered (absent when nobody did — a policy's answer, a relayed standing grant, a row or record that carries * no classes), `of` is the obligation's own classes. A value that is not a class list answers no question; an obligation with no * class is answered by nobody. One reading for every station that lets a person's earlier answer stand for an obligation that * holds NOW: the cross-boundary exit (`cross_boundary`) and the three belts a resumed call meets (the org's current question, * the PreToolUse hook's, an edit's re-check). */ export declare function personAnswered(answered: readonly AskClass[] | undefined, of: readonly AskClass[]): boolean; /** Whether a question a belt holds NOW demands a person that the recorded answer did not give: it demands a person * ({@link demandsAPerson}) and no person answered a question carrying its classes ({@link personAnswered}). A person's answer to * a question that did not ask this is no answer to it; a policy's answer never is. */ export declare function beltUnanswered(question: HeldQuestion, of: readonly AskClass[], answered: readonly AskClass[] | undefined): boolean; /** {@link beltUnanswered} for a policy's re-check of an approver's edit: the question is the re-check's own, its classes the ones the * policy fold reads off it ({@link decisionAskClassesOf}) — so an edit whose re-check raises the obligation the row's question * carried stands on a person's answer, and one that raises an obligation the row's question did not carry is refused. Both stations * that re-check an edit (the resume entry before the claim, the execution belt after it) read it here. * * The bare bit is read as the row's table reads it. The row's classes drop `policy_rra` when a class beside it explains the bit * ({@link explainsRealApprovalBit}, judged over the whole set at the mint); the re-check sees the policy's half alone, so the same * bit comes back as `policy_rra` — a class the row never lacked, only never needed: the class that explained it demands a person * too, and a person answered it. A bare bit the answered classes explain is that answer; one nothing in them explains still owes * its own. */ export declare function editRecheckUnanswered(rechecked: PermissionResult, call: { readonly toolCallId: string; readonly toolName: string; }, answered: readonly AskClass[] | undefined): boolean;