@sema-agent/core
Version:
Stateless, task-oriented AI agent core
35 lines (34 loc) • 2.79 kB
TypeScript
/**
* A tool policy that THREW — the one form its failure takes on each of the two surfaces it reaches, for every seat that
* consults a policy chain (the gate's target reading, the adjudicate seat, the inherited-constraint station, the two
* re-checks of an approved edit).
*
* The MODEL reads one line of the thrown value inside the seat's deny: secret-shaped runs redacted, then folded to one line
* and capped (`inlineUntrusted`, which also neutralizes a reminder fence), so a policy's error text never carries a
* credential, a multi-kilobyte body or a forged frame into the conversation. The DEPLOYMENT hears the failure once, on the
* seat's hook-failure lane (`onError`, phase `hook`): an error whose message names the seat and the call and carries the
* class and the redacted text — and no `cause`, because a host's serializer walks a cause chain and the raw value would
* carry the unredacted text there.
*/
import type { PermissionResult } from "../tool-policy.js";
/** The model's line of a thrown policy value: redacted BEFORE the cap (a cut must never leave half a token unredacted),
* one line, at most {@link PROBE_REASON_MAX} code points; never empty. */
export declare function policyThrowLine(err: unknown): string;
/** The deny of a judgment whose wait the task's signal ended — a timeout or a cancellation, nothing the policy said. */
export declare function policyCheckAbortedDeny(): PermissionResult;
/** The deny of a judgment that FAILED (threw or rejected) while `signal` bounded its wait: the aborted deny when the signal had
* already ended the wait (a cancellation — not reported), else the policy's own throw — its sentence and one line of what it
* threw — reported once through {@link reportPolicyThrow}. A seat that raced the judgment against its signal has told the two
* apart already and passes no signal. */
export declare function failedJudgmentDeny(err: unknown, signal: AbortSignal | undefined, report: (err: Error) => void, seat: string, call: {
readonly toolName: string;
readonly toolCallId: string;
}): PermissionResult;
/** Hand the deployment, through `report` (the seat's hook-failure lane), the failure of the policy that threw while `seat`
* judged `call`. A rejection that arrives with the judgment's `signal` already aborted is the task ending mid-judgment — a
* cancellation, not a policy defect — and is not reported (the deny it produced stands either way). A report lane that
* throws is swallowed: the fail-closed deny is decided before the report and must not depend on the sink. */
export declare function reportPolicyThrow(report: (err: Error) => void, seat: string, call: {
readonly toolName: string;
readonly toolCallId: string;
}, err: unknown, signal?: AbortSignal): void;