import { InterruptPolicy, PolicyContext } from "./contracts/approval.type.mjs"; //#region ../ai/src/human/policy.d.ts /** * Verdict of evaluating an {@link InterruptPolicy} against a single * pending tool call. * * - `requiresApproval` — `true` when the call must be routed to a human * before the real tool runs; `false` when the policy lets it through * untouched. * - `tags` — author-supplied labels from the matched rule (e.g. * `"destructive"`, `"money"`), surfaced verbatim on the resulting * `ApprovalRequest.context.tags`. Only ever present when * `requiresApproval` is `true`; `undefined` when the rule produced no * tags. */ interface PolicyVerdict { /** Whether this tool call must be approved by a human. */ requiresApproval: boolean; /** Author-supplied tags from the matched rule, when any. */ tags?: string[]; } /** * Decide whether a single pending tool call requires human approval — * the pure core behind the `ai.human.approval` middleware's gate. * * **Pure.** No IO, no throwing, no mutation of `policy` or `context`. The * middleware calls this once per tool dispatch and routes to a human only * when {@link PolicyVerdict.requiresApproval} is `true`. * * **The three rule types** ({@link InterruptPolicy}): * - `allowlist` — gate the call **only** when its tool name is listed; an * optional `tags(toolName)` callback derives the verdict tags. * - `denylist` — gate **every** call **except** the listed tool names; * the same optional `tags(toolName)` callback applies to the gated * (non-listed) name. * - `predicate` — gate the call when `requiresApproval(context)` returns a * truthy result. A non-empty `string[]` both gates the call **and** * supplies the verdict tags; `true` gates with no tags; `false` (or an * **empty** array — "no rule matched") lets the call through. * * @param policy - The interrupt policy to evaluate. * @param context - The read-only view of the pending tool call. * @returns A {@link PolicyVerdict} — gate-or-skip plus any tags. * * @example * const verdict = evaluatePolicy( * { type: "allowlist", tools: ["refundCustomer"], tags: () => ["money"] }, * { toolName: "refundCustomer", args: { amount: 50 }, agentName: "support", tripIndex: 0 }, * ); * // → { requiresApproval: true, tags: ["money"] } */ declare function evaluatePolicy(policy: InterruptPolicy, context: PolicyContext): PolicyVerdict; //#endregion export { PolicyVerdict, evaluatePolicy }; //# sourceMappingURL=policy.d.mts.map