Skip to content

Adapters

The gate sits between “the model produced something” and “the user’s phone buzzed”. The adapters put it at the point each framework already reserves for that decision. They are typed against the shape of a call, not against the framework package, so nothing else has to be installed.

import { gateToolApproval } from "proactive-gate/ai-sdk";
const approve = gateToolApproval({ gate, toInput: (call) => call.input.gate });
const { approved, reason } = await approve(call); // answer the tool's needsApproval
import { gateProcessor } from "proactive-gate/mastra";
const agent = new Agent({ ..., outputProcessors: [gateProcessor({ gate, toInput })] });
import { gateMiddleware } from "proactive-gate/langchain";
import { gateGuardrail } from "proactive-gate/openai-agents";

Each adapter denies with the gate’s reason and, by default, commits the budget on approval.

{
"hooks": {
"PreToolUse": [
{
"matcher": "send_message",
"hooks": [{ "type": "command", "command": "npx proactive-gate hook --policy policy.json --tool send_message" }]
}
]
}
}

The hook reads the PreToolUse event on stdin, evaluates tool_input.gate = { user, candidate } against the policy, and prints a permissionDecision for the matching tool. Other tools print nothing.