UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

60 lines (59 loc) • 4.36 kB
/** * Auto mode's classifier on the Artifact tool's shared-read consent — the question the tool asks INSIDE its execution (the bytes are * fetched before the tool can tell the target is someone else's), class `artifact_shared_read`. The gate's classifier station cannot * reach a question put after the gate, so the tool asks this seat, which answers by the gate's rule for an ask its classifier may * answer (gate-lanes' classifier station, the one reading of a verdict): * · `allow` — the read is delivered, for this call only (a classifier's allow is no person's nod), and the streak ends; * · a ruling `block` — counted first, judged second: below the denial limit the read is refused with the classifier's reason, the * block that reaches the limit hands the question on as the denial-limit fallback (a person's allow of it then ends the streak); * · no ruling (the classifier could not run, or replied with no verdict) — the gate's one exit ({@link classifierNoRulingArm}) on the * tool's approval route (`route`, the frozen approver's: a person's or a policy's callback; a blanket word or none is `none`): with a * decider on the route the question goes on carrying why, without one the read is refused (a reply with no verdict and no decider * takes the counted ruling path, as at the gate); * · a leg steered out of `auto` while it decided takes no allow from it — the question goes back to the mode now in force. * A question handed on names the class it gained (`also`), so the tool reads the mode in force over the whole set before anyone is * asked, as the gate's mode read point reads a no-ruling ask, and carries the question the classification MINTED (`request`): the tool * puts that question to the person as it is — the fallback sentence and member at the bound, the question saying why it needs a person * when the classifier did not rule. No decider armed ⇒ the question goes on unchanged. */ import { type AutoModeDecider, type AutoModeDenialTracker } from "../auto-mode.js"; import type { AskClass, PermissionMode } from "../ask-origin.js"; import type { ApprovalRoute } from "../approval-route.js"; import { type AskRequestCarry } from "./denial-limit-arms.js"; /** The question a classification minted, as the person's card carries it: its sentence and the two request members the gate's own * mint station carries for such a question ({@link gateAskCarry}: the denial-limit fallback — its timed window armed for an approver * that answers — and the no-ruling cause). The card reads these three by name and nothing else. */ export type SharedReadRequest = { readonly message: string; } & Pick<AskRequestCarry, "denialLimitFallback" | "classifierNoRuling">; /** What the seat decided: deliver, refuse with `reason` (the sentence the model reads), or hand the question on — `also` the class * the classification added to it (absent: the question as it was), `request` the question it minted (called once, when the card is * put: that is when the fallback's window is armed), `settle` told whether a person allowed it (a person's allow of a denial-limit * fallback ends the streak). */ export type SharedReadJudgment = { readonly kind: "allow"; } | { readonly kind: "deny"; readonly reason: string; } | { readonly kind: "ask"; readonly also?: Extract<AskClass, "classifier_no_ruling" | "denial_limit_fallback">; readonly request?: () => SharedReadRequest; readonly settle?: (allowed: boolean) => void; }; /** The question as the classifier is shown it: the call (its tool name and arguments) and the gate line. */ export interface SharedReadQuestion { readonly toolCallId: string; readonly toolName: string; readonly args: unknown; readonly message: string; } export type SharedReadClassifier = (question: SharedReadQuestion, signal?: AbortSignal) => Promise<SharedReadJudgment>; /** The seat over the leg's auto-mode decider and denial tracker (read per question: arming is late-bound), the leg's live mode and * the tool's approval route. */ export declare function sharedReadClassifier(seat: { readonly decider: () => AutoModeDecider | undefined; readonly tracking: () => AutoModeDenialTracker | undefined; readonly mode: () => PermissionMode; readonly route: ApprovalRoute; }): SharedReadClassifier;