/** * The run gate: evaluate the run's policy for one tool call and, when the policy * will not decide alone, wait for a human through the approval channel. * * Harness-neutral on purpose. An adapter owns one line of glue — map its * harness's tool-call event onto `decide()` and turn the outcome into whatever * that harness expects from a blocked call — so the policy, the approval * rendezvous and the audit record are the same for every harness. */ import { type ApprovalChannel, type ApprovalRequest } from './approvals'; import { RunGatePolicy, type RunGatePolicyOptions, type RunGateVerdict } from './run-policy'; export interface RunGateDecisionRecord { runId: string; toolCallId: string; toolName: string; input: Record; /** What the policy said. */ verdict: RunGateVerdict; /** How the request was finally settled. */ decision: 'allow' | 'deny'; reason?: string; actorId?: string; decidedAt: string; } export interface RunGateOptions { runId: string; /** A policy, or the options to build one. */ policy: RunGatePolicy | RunGatePolicyOptions; /** Required only if the policy can produce `ask`. */ approvals?: ApprovalChannel; /** Every settled decision, for the run log / audit trail. */ onDecision?: (record: RunGateDecisionRecord) => void; now?: () => Date; } export interface RunGateToolCall { toolCallId: string; toolName: string; input?: Record; } export interface RunGateOutcome { /** `false` means the harness must not run the call. */ allowed: boolean; /** The model's only explanation for a refusal, so policies should be specific. */ reason?: string; } export declare class RunGate { readonly policy: RunGatePolicy; /** Requests currently waiting on a human. */ readonly pending: ReadonlyMap; private readonly options; private readonly now; private readonly waiting; constructor(options: RunGateOptions); decide(call: RunGateToolCall): Promise; private ask; } export declare function createRunGate(options: RunGateOptions): RunGate;